29 #ifndef netio_address_h
30 #define netio_address_h
35 #ifndef osapi_config_h
41 #ifndef reda_sequence_h
42 #include "reda/reda_sequence.h"
45 #include "db/db_api.h"
60 #define NETIO_ADDRESS_PORT_INVALID (0)
66 #define NETIO_ADDRESS_KIND_INVALID (-1)
72 #define NETIO_ADDRESS_KIND_RESERVED 0
78 #define NETIO_ADDRESS_KIND_UDPv4 1
84 #define NETIO_ADDRESS_KIND_UDPv6 2
90 #define NETIO_ADDRESS_KIND_SHMEM 3
96 #define NETIO_ADDRESS_KIND_GUID 4
102 #define NETIO_ADDRESS_MAX_32BIT (4)
108 #define NETIO_ADDRESS_MAX_8IT (16)
113 struct NETIO_GuidPrefix
121 struct NETIO_GuidEntity
129 struct NETIO_AddressRtps
133 RTI_UINT32 instance_id;
134 RTI_UINT32 object_id;
141 struct NETIO_GuidPrefix prefix;
142 struct NETIO_GuidEntity entity;
148 struct NETIO_AddressGuidPrefix
150 RTI_UINT8 prefix[12];
158 struct NETIO_AddressIp4
164 RTI_UINT8 _unused[12];
170 struct NETIO_AddressIpv6
178 struct NETIO_AddressShem
190 struct NETIO_AddressInit
202 struct NETIO_AddressInt32
211 struct NETIO_AddressUInt32
219 union NETIO_AddressValue
221 struct NETIO_AddressRtps rtps_guid;
222 struct NETIO_Guid guid;
223 struct NETIO_AddressGuidPrefix guid_prefix;
224 struct NETIO_AddressIp4 ipv4;
225 struct NETIO_AddressIpv6 ipv6;
226 struct NETIO_AddressShem shmem;
227 struct NETIO_AddressInit init;
228 struct NETIO_AddressInt32 as_int32;
229 struct NETIO_AddressUInt32 as_uint32;
251 union NETIO_AddressValue value;
258 #define NETIO_ADDRESS_FLAG_MULTICAST (0x80000000)
264 #define NETIO_ADDRESS_FLAG_INTERNAL (0x40000000)
270 #define NETIO_ADDRESS_IS_MULTICAST(a_) ((a_)->kind & NETIO_ADDRESS_FLAG_MULTICAST)
276 #define NETIO_ADDRESS_IS_INTERNAL(a_) ((a_)->kind & NETIO_ADDRESS_FLAG_INTERNAL)
282 #define NETIO_ADDRESS_SET_MULTICAST(a_) ((a_)->kind | NETIO_ADDRESS_FLAG_MULTICAST)
288 #define NETIO_ADDRESS_SET_INTERNAL(a_) ((a_)->kind | NETIO_ADDRESS_FLAG_INTERNAL)
294 #define NETIO_ADDRESS_SET_KIND(a_,k_,f_) ((a_)->kind = (k_) | (f_))
301 #define NETIO_ADDRESS_GET_KIND(a_) ((a_)->kind & 0x00ffffff)
307 #define NETIO_ADDRESS_KIND(k_) ((k_) & 0x00ffffff)
313 #define NETIO_NETMASK_MASK_LENGTH (4)
319 #define NETIO_NETMASK_MASK_SIZE ((RTI_INT32)(sizeof(RTI_INT32)))
325 #define NETIO_NETMASK_MASK_BITS_PER_UNIT ((RTI_INT32)(sizeof(RTI_INT32) * 8))
331 #define NETIO_NETMASK_MASK_MAX_BITS (NETIO_NETMASK_MAX_LENGTH * NETIO_NETMASK_ELEMENT_SIZE*8)
346 RTI_UINT32 mask[NETIO_NETMASK_MASK_LENGTH];
352 #define NETIO_Netmask_INITIALIZER \
362 REDA_DEFINE_SEQUENCE(NETIO_AddressSeq,
struct NETIO_Address)
363 REDA_DEFINE_SEQUENCE(NETIO_NetmaskSeq, struct NETIO_Netmask)
369 #define NETIO_AddressSeq_INITIALIZER REDA_DEFINE_SEQUENCE_INITIALIZER(struct NETIO_Address)
375 #define NETIO_NetmaskSeq_INITIALIZER REDA_DEFINE_SEQUENCE_INITIALIZER(struct NETIO_Netmask)
382 #define NETIO_ADDRESS_GUID_UNKNOWN {{{0,0,0,0,0,0,0,0,0,0,0,0}},{{0,0,0,0}}}
396 NETIODllExport RTI_INT32
397 NETIO_Address_compare(
const struct NETIO_Address *left_addr,
398 const struct NETIO_Address *right_addr);
404 #define NETIO_Address_INITIALIZER \
406 NETIO_ADDRESS_KIND_RESERVED, \
415 #define NETIO_Address_init(addr_,kind_) \
417 (addr_)->kind = kind_; (addr_)->port = 0; \
418 (addr_)->value.init.val0 = (addr_)->value.init.val1 = 0;\
419 (addr_)->value.init.val2 = (addr_)->value.init.val3 = 0;\
426 #define NETIO_Address_set_ipv4(addr_,port_,address_) \
428 (addr_)->kind = NETIO_ADDRESS_KIND_UDPv4; \
429 (addr_)->port = port_; \
430 (addr_)->value.ipv4.address = address_;\
437 #define NETIO_Address_set_guid(addr_,port_,guid_) \
439 (addr_)->kind = NETIO_ADDRESS_KIND_GUID; \
440 (addr_)->port = port_; \
441 OSAPI_Memory_copy(&((addr_)->value.guid),(guid_),16);\
454 #define NETIO_Address_set_guid_from_key(addr_,port_,key_) \
456 (addr_)->kind = NETIO_ADDRESS_KIND_GUID; \
457 (addr_)->port = port_; \
458 OSAPI_Memory_copy(&((addr_)->value.guid),(key_),16);\
462 #define NETIO_Address_set_guid_from_key(addr_,port_,key_) \
464 (addr_)->kind = NETIO_ADDRESS_KIND_GUID; \
465 (addr_)->port = port_; \
466 (addr_)->value.rtps_guid.host_id = NETIO_htonl((key_)->value[0]);\
467 (addr_)->value.rtps_guid.app_id = NETIO_htonl((key_)->value[1]);\
468 (addr_)->value.rtps_guid.instance_id = NETIO_htonl((key_)->value[2]);\
469 (addr_)->value.rtps_guid.object_id = NETIO_htonl((key_)->value[3]);\
480 #define NETIO_Address_set_guid_from_int32(addr_,port_,int0_,int1_,int2_,int3_) \
482 (addr_)->kind = NETIO_ADDRESS_KIND_GUID; \
483 (addr_)->port = port_; \
484 (addr_)->value.rtps_guid.host_id = int0_;\
485 (addr_)->value.rtps_guid.app_id = int1_;\
486 (addr_)->value.rtps_guid.instance_id = int2_;\
487 (addr_)->value.rtps_guid.object_id = int3_;\
491 #define NETIO_Address_set_guid_from_int32(addr_,port_,int0_,int1_,int2_,int3_) \
493 (addr_)->kind = NETIO_ADDRESS_KIND_GUID; \
494 (addr_)->port = port_; \
495 (addr_)->value.rtps_guid.host_id = NETIO_htonl(int0_);\
496 (addr_)->value.rtps_guid.app_id = NETIO_htonl(int1_);\
497 (addr_)->value.rtps_guid.instance_id = NETIO_htonl(int2_);\
498 (addr_)->value.rtps_guid.object_id = NETIO_htonl(int3_);\
506 #define NETIO_Address_is_udpv4_multicast(addr_) \
507 ((NETIO_ADDRESS_GET_KIND(addr_) == NETIO_ADDRESS_KIND_UDPv4) && \
508 ((addr_)->value.ipv4.address >= 0xe0000000) && \
509 ((addr_)->value.ipv4.address <= 0xefffffff))
546 MUST_CHECK_RETURN NETIODllExport
RTI_BOOL
547 NETIO_Address_parse(
const char *name,
548 RTI_UINT32 *base_port,
549 RTI_INT32 *low_index,
550 RTI_INT32 *high_index,
551 RT_ComponentFactoryId_T *out_id,
552 char *address_string,
553 RTI_SIZE_T address_max_string);
558 #define NETIO_ADDRESS_TOKEN_MAX_SIZE 256
565 #define NETIO_PREFIX_TOKEN_MAX_SIZE (RT_MAX_FACTORY_NAME + 1)
577 NETIO_ROUTEKIND_META,
604 (*NETIO_PortCalculateFunc_T)(
void *param,NETIO_RouteKind_T kind,
605 RTI_UINT32 port_base,RTI_INT32 index,
606 struct NETIO_Address *address);