OpenDDS  Snapshot(2023/04/28-20:55)
TransportDefs.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_TRANSPORT_FRAMEWORK_TRANSPORTDEFS_H
9 #define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_TRANSPORTDEFS_H
10 
11 #include "TransportDebug.h"
12 
14 #include "dds/DCPS/Definitions.h"
15 #include "dds/DCPS/PoolAllocator.h"
16 #include "dds/DCPS/debug.h"
17 #include "dds/DCPS/Util.h"
18 
19 #include <dds/DdsDcpsGuidC.h>
20 #include <dds/DdsDcpsInfrastructureC.h>
21 
22 #include <ace/INET_Addr.h>
23 #include <ace/Basic_Types.h>
24 #include <ace/CDR_Base.h>
25 #include <ace/Synch_Traits.h>
26 
28 class ACE_Message_Block;
29 class ACE_Data_Block;
31 
32 /**
33  * Guard the allocations for the underlying memory management of the
34  * receive processing with the following:
35  *
36  * Notice that even we have only one thread for receiving per transport, the underly message blocks
37  * would interact with the threads from EndHistoricSamplesMissedSweeper which are different from the
38  * receiving threads. Therefore, we cannot use ACE_SYNCH_NULL_MUTEX here.
39  */
40 #define RECEIVE_SYNCH ACE_SYNCH_MUTEX
41 
42 /// Macro to get the individual configuration value
43 /// from ACE_Configuration_Heap and cast to the specific
44 /// type from integer.
45 #define GET_CONFIG_VALUE(CF, SECT, KEY, VALUE, TYPE) \
46  { \
47  ACE_TString stringvalue; \
48  if (CF.get_string_value (SECT, KEY, stringvalue) == -1) \
49  { \
50  if (OpenDDS::DCPS::Transport_debug_level > 0) \
51  { \
52  ACE_DEBUG ((LM_NOTICE, \
53  ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ")\
54  ACE_TEXT ("file - using code default.\n"), \
55  KEY)); \
56  } \
57  } \
58  else if (stringvalue == ACE_TEXT("")) \
59  { \
60  if (OpenDDS::DCPS::Transport_debug_level > 0) \
61  { \
62  ACE_DEBUG ((LM_WARNING, \
63  ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ") \
64  ACE_TEXT ("file, but is missing value - using code default.\n"), \
65  KEY)); \
66  } \
67  } \
68  else \
69  { \
70  VALUE = static_cast<TYPE>(ACE_OS::atoi (stringvalue.c_str())); \
71  } \
72  }
73 
74 /// Macro to get the individual configuration value
75 /// from ACE_Configuration_Heap as string type.
76 #define GET_CONFIG_STRING_VALUE(CF, SECT, KEY, VALUE) \
77  { \
78  ACE_TString stringvalue; \
79  if (CF.get_string_value (SECT, KEY, stringvalue) == -1) \
80  { \
81  if (OpenDDS::DCPS::Transport_debug_level > 0) \
82  { \
83  ACE_DEBUG ((LM_NOTICE, \
84  ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ") \
85  ACE_TEXT ("file - using code default.\n"), \
86  KEY)); \
87  } \
88  } \
89  else if (stringvalue == ACE_TEXT("")) \
90  { \
91  if (OpenDDS::DCPS::Transport_debug_level > 0) \
92  { \
93  ACE_DEBUG ((LM_WARNING, \
94  ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ") \
95  ACE_TEXT ("file, but is missing value - using code default.\n"), \
96  KEY)); \
97  } \
98  } \
99  else \
100  { \
101  if (OpenDDS::DCPS::Transport_debug_level > 0) \
102  { \
103  ACE_DEBUG ((LM_NOTICE, \
104  ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is defined in config ") \
105  ACE_TEXT ("file, with value \"%C\".\n"), \
106  KEY, ACE_TEXT_ALWAYS_CHAR(stringvalue.c_str()))); \
107  } \
108  VALUE = ACE_TEXT_ALWAYS_CHAR(stringvalue.c_str()); \
109  } \
110  }
111 
112 #define GET_CONFIG_TSTRING_VALUE(CF, SECT, KEY, VALUE) \
113  { \
114  ACE_TString stringvalue; \
115  if (CF.get_string_value (SECT, KEY, stringvalue) == -1) \
116  { \
117  if (OpenDDS::DCPS::Transport_debug_level > 0) \
118  { \
119  ACE_DEBUG ((LM_NOTICE, \
120  ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ") \
121  ACE_TEXT ("file - using code default.\n"), \
122  KEY)); \
123  } \
124  } \
125  else if (stringvalue == ACE_TEXT("")) \
126  { \
127  if (OpenDDS::DCPS::Transport_debug_level > 0) \
128  { \
129  ACE_DEBUG ((LM_WARNING, \
130  ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ") \
131  ACE_TEXT ("file, but is missing value - using code default.\n"), \
132  KEY)); \
133  } \
134  } \
135  else \
136  { \
137  VALUE = stringvalue; \
138  } \
139  }
140 
141 #define GET_CONFIG_DOUBLE_VALUE(CF, SECT, KEY, VALUE) \
142  { \
143  ACE_TString stringvalue; \
144  if (CF.get_string_value (SECT, KEY, stringvalue) == -1) \
145  { \
146  if (OpenDDS::DCPS::Transport_debug_level > 0) \
147  { \
148  ACE_DEBUG ((LM_NOTICE, \
149  ACE_TEXT ("(%P|%t) NOTICE: \"%s\" is not defined in config ") \
150  ACE_TEXT ("file - using code default.\n"), \
151  KEY)); \
152  } \
153  } \
154  else if (stringvalue == ACE_TEXT("")) \
155  { \
156  if (OpenDDS::DCPS::Transport_debug_level > 0) \
157  { \
158  ACE_DEBUG ((LM_WARNING, \
159  ACE_TEXT ("(%P|%t) WARNING: \"%s\" is defined in config ") \
160  ACE_TEXT ("file, but is missing value - using code default.\n"), \
161  KEY)); \
162  } \
163  } \
164  else \
165  { \
166  VALUE = ACE_OS::strtod (stringvalue.c_str(), 0); \
167  } \
168  }
169 
170 /// Macro to get the individual configuration value
171 /// from ACE_Configuration_Heap as TimeDuration
172 /// using milliseconds.
173 #define GET_CONFIG_TIME_VALUE(CF, SECT, KEY, VALUE) \
174  { \
175  long tv = -1; \
176  GET_CONFIG_VALUE(CF, SECT, KEY, tv, long); \
177  if (tv != -1) VALUE = TimeDuration::from_msec(tv); \
178  }
179 
181 
182 namespace OpenDDS {
183 namespace DCPS {
184 
185 // The transport and configuration section name used in the config file format
186 static const ACE_TCHAR TRANSPORT_SECTION_NAME[] = ACE_TEXT("transport");
187 static const ACE_TCHAR TRANSPORT_TEMPLATE_SECTION_NAME[] = ACE_TEXT("transport_template");
188 static const ACE_TCHAR CONFIG_SECTION_NAME[] = ACE_TEXT("config");
189 static const ACE_TCHAR CUSTOMIZATION_SECTION_NAME[] = ACE_TEXT("Customization");
190 
191 /// Identifier type for DataLink objects.
193 
194 /// Return code type for send_control() operations.
198 };
199 
200 /// Return code type for attach_transport() operations.
206 };
207 
208 // TBD - Resolve this
209 #if 0
210 // TBD SOON - The MAX_SEND_BLOCKS may conflict with the
211 // max_samples_per_packet_ configuration!
212 //MJM: The constant should just be used as part of a conditional at the
213 //MJM: points where it is used.
214 #endif
215 
216 /// Controls the maximum size of the iovec array used for a send packet.
217 #if defined (ACE_IOV_MAX) && (ACE_IOV_MAX != 0)
218 enum { MAX_SEND_BLOCKS = ACE_IOV_MAX };
219 #else
220 enum { MAX_SEND_BLOCKS = 50 };
221 #endif
222 
223 // Allocators are locked since we can not restrict the thread on
224 // which a release will occur.
225 
226 /// Allocators used for transport receiving logic.
227 enum { RECEIVE_DATA_BUFFER_SIZE = 65536 };
229 
232 
235 
239 
240 /// Default TransportInst settings
241 enum {
247 };
248 
249 /// used by DataLink::remove_sample(), TransportSendStrategy, *RemoveVisitor
252 };
253 
255 
256 typedef size_t ConnectionInfoFlags;
257 static const ConnectionInfoFlags CONNINFO_UNICAST = (1 << 0);
258 static const ConnectionInfoFlags CONNINFO_MULTICAST = (1 << 1);
259 static const ConnectionInfoFlags CONNINFO_ALL = static_cast<ConnectionInfoFlags>(-1);
260 
261 } // namespace DCPS
262 } // namespace OpenDDS
263 
265 
266 #endif /* OPENDDS_DCPS_TRANSPORTDEFS_H */
#define ACE_BEGIN_VERSIONED_NAMESPACE_DECL
Cached_Allocator_With_Overflow< ACE_Data_Block, RECEIVE_SYNCH > TransportDataBlockAllocator
static const ACE_TCHAR CUSTOMIZATION_SECTION_NAME[]
static const ConnectionInfoFlags CONNINFO_ALL
Cached_Allocator_With_Overflow< char[RECEIVE_DATA_BUFFER_SIZE], RECEIVE_SYNCH > TransportDataAllocator
ACE_UINT64 DataLinkIdType
Identifier type for DataLink objects.
RemoveResult
used by DataLink::remove_sample(), TransportSendStrategy, *RemoveVisitor
char ACE_TCHAR
static const ACE_TCHAR CONFIG_SECTION_NAME[]
#define ACE_IOV_MAX
static const ACE_TCHAR TRANSPORT_SECTION_NAME[]
#define ACE_END_VERSIONED_NAMESPACE_DECL
ACE_TEXT("TCP_Factory")
ACE_INT32 Long
unsigned long long ACE_UINT64
ACE_CDR::Long Priority
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
#define RECEIVE_SYNCH
Definition: TransportDefs.h:40
AttachStatus
Return code type for attach_transport() operations.
static const ACE_TCHAR TRANSPORT_TEMPLATE_SECTION_NAME[]
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
static const ConnectionInfoFlags CONNINFO_MULTICAST
Cached_Allocator_With_Overflow< ACE_Message_Block, RECEIVE_SYNCH > TransportMessageBlockAllocator
static const ConnectionInfoFlags CONNINFO_UNICAST
SendControlStatus
Return code type for send_control() operations.
size_t ConnectionInfoFlags