32 #ifndef netio_interface_h
33 #define netio_interface_h
39 #ifndef osapi_config_h
49 #ifndef reda_sequenceNumber_h
50 #include "reda/reda_sequenceNumber.h"
54 #include "db/db_api.h"
61 #ifndef netio_address_h
62 #include "netio/netio_address.h"
66 #include "cdr/cdr_stream.h"
106 #define NETIO_PROTOCOL_INTRA (1)
112 #define NETIO_PROTOCOL_RTPS (2)
118 #define NETIO_PROTOCOL_UDP (3)
128 #define NETIO_RTPS_FLAGS_DEFAULT (0x0)
134 #define NETIO_RTPS_FLAGS_DISPOSE (0x1)
141 #define NETIO_RTPS_FLAGS_UNREGISTER (0x2)
147 #define NETIO_RTPS_FLAGS_LIVELINESS (0x4)
153 #define NETIO_RTPS_FLAGS_INLINEQOS (0x8)
160 #define NETIO_RTPS_FLAGS_LOST_DATA (0x10)
168 #define NETIO_RTPS_FLAGS_COMMIT_DATA (0x20)
174 #define NETIO_RTPS_FLAGS_DATA (0x40)
180 #define NETIO_RTPS_FLAGS_LAST_WRITE_FOR_SN (0x80)
186 #define NETIO_RTPS_FLAGS_LITTLE_ENDIAN (0x100)
192 #define NETIO_RTPS_FLAGS_DATA_BATCH (0x200)
197 struct NETIO_RtpsInfo
204 struct REDA_Buffer *inline_data;
212 struct REDA_Buffer *serialized_data_batch;
218 RTI_BOOL stream_need_byte_swap;
224 RTI_UINT16 stream_endian;
229 struct NETIO_GuidPrefix guid_prefix;
235 struct NETIO_IntraInfo
240 const void *user_data;
246 struct REDA_Buffer *inline_data;
252 #define NETIO_IntraInfo_INITIALIZER \
261 struct NETIO_PacketInfo
268 struct REDA_SequenceNumber sn;
276 struct REDA_SequenceNumber virtual_sn;
286 RTI_UINT8 valid_data;
296 struct NETIO_Guid instance;
301 RTI_UINT32 rtps_flags;
307 struct REDA_SequenceNumber committable_sn;
314 struct REDA_SequenceNumber first_available_sn;
320 struct REDA_SequenceNumber lost_sample_sn;
326 RTI_UINT32 lost_sample_count;
331 struct REDA_SequenceNumber last_committed_virtual_sn;
337 RTI_INT32 protocol_id;
345 struct NETIO_IntraInfo intra_info;
346 struct NETIO_RtpsInfo rtps_data;
354 #define NETIO_PacketInfo_INITIALIZER \
356 REDA_SEQUENCE_NUMBER_ZERO, \
357 REDA_SEQUENCE_NUMBER_ZERO, \
358 OSAPI_NTP_TIME_ZERO, \
361 NETIO_ADDRESS_GUID_UNKNOWN, \
363 REDA_SEQUENCE_NUMBER_ZERO, \
364 REDA_SEQUENCE_NUMBER_ZERO, \
365 REDA_SEQUENCE_NUMBER_ZERO, \
367 REDA_SEQUENCE_NUMBER_ZERO, \
370 {NULL,NULL,CDR_BYTESWAP_INVALID,0,\
371 {{0,0,0,0,0,0,0,0,0,0,0,0}}}}\
387 struct NETIO_Address source;
392 struct NETIO_Address local_source;
404 RTI_SIZE_T max_length;
420 RTI_SIZE_T saved_head_pos;
426 RTI_SIZE_T saved_tail_pos;
432 struct NETIO_PacketInfo info;
437 struct NETIO_AddressSeq *dests;
449 typedef struct NETIO_Packet NETIO_Packet_T;
456 typedef struct REDA_SequenceNumber NETIO_PacketId_T;
462 #define NETIO_Packet_INITIALIZER \
464 NETIO_Address_INITIALIZER,\
465 NETIO_Address_INITIALIZER,\
472 NETIO_PacketInfo_INITIALIZER,\
490 MUST_CHECK_RETURN NETIODllExport RTI_BOOL
491 NETIO_Packet_set_head(NETIO_Packet_T *
const packet,RTI_INT32 delta);
506 MUST_CHECK_RETURN NETIODllExport RTI_BOOL
507 NETIO_Packet_set_tail(NETIO_Packet_T *
const packet,RTI_INT32 delta);
523 MUST_CHECK_RETURN NETIODllExport
void*
524 NETIO_Packet_get_head(
const NETIO_Packet_T *
const packet);
540 MUST_CHECK_RETURN NETIODllExport
void*
541 NETIO_Packet_get_tail(
const NETIO_Packet_T *
const packet);
562 MUST_CHECK_RETURN NETIODllExport RTI_BOOL
563 NETIO_Packet_initialize(NETIO_Packet_T *
const packet,
565 RTI_SIZE_T init_length,
566 RTI_SIZE_T trailer_length,
567 struct NETIO_AddressSeq *dest_seq);
585 MUST_CHECK_RETURN NETIODllExport RTI_BOOL
586 NETIO_Packet_initialize_from(NETIO_Packet_T *
const out_packet,
587 const NETIO_Packet_T *
const in_packet,
589 RTI_SIZE_T max_buffer_length,
591 RTI_SIZE_T tail_pos);
605 SHOULD_CHECK_RETURN NETIODllExport RTI_BOOL
606 NETIO_Packet_finalize(NETIO_Packet_T *
const packet);
616 MUST_CHECK_RETURN NETIODllExport
struct NETIO_PacketInfo*
617 NETIO_Packet_get_info(NETIO_Packet_T *
const packet);
626 NETIO_Packet_set_source(NETIO_Packet_T *
const packet,
627 const struct NETIO_Address *
const src);
640 SHOULD_CHECK_RETURN NETIODllExport RTI_SIZE_T
641 NETIO_Packet_get_payload_length(
const NETIO_Packet_T *
const packet);
656 NETIO_Packet_save_positions(NETIO_Packet_T *
const packet);
670 NETIO_Packet_restore_positions(NETIO_Packet_T *
const packet);
686 NETIO_Packet_save_positions_to(
const NETIO_Packet_T *
const packet,
687 RTI_SIZE_T *
const head,
688 RTI_SIZE_T *
const tail);
704 NETIO_Packet_restore_positions_from(NETIO_Packet_T *
const packet,
722 #define NETIO_TABLE_NAME_SIZE (16)
727 struct NETIO_InterfaceProperty
729 struct RT_ComponentProperty _parent;
730 RTI_INT32 max_routes;
738 #define NETIO_InterfaceProperty_INITIALIZER \
740 RT_ComponentProperty_INITIALIZER,\
753 struct NETIO_InterfaceListener
758 struct RT_ComponentListener _parent;
765 #define NETIO_InterfaceListener_INITIALIZE \
767 RT_ComponentListener_INITIALIZER \
780 struct NETIO_InterfaceFactoryProperty
785 struct RT_ComponentFactoryProperty _parent;
792 #define NETIO_InterfaceFactoryProperty_INITIALIZER \
794 RT_ComponentFactoryProperty_INITIALIZER \
805 NETIO_INTERFACESTATE_CREATED,
810 NETIO_INTERFACESTATE_ENABLED
811 } NETIO_InterfaceState_T;
822 struct NETIO_Interface
827 struct RT_Component _parent;
844 struct NETIO_Address local_address;
849 NETIO_InterfaceState_T state;
855 typedef struct NETIO_Interface NETIO_Interface_T;
860 struct NETIOBindProperty
873 #define NETIOBindProperty_INITIALIZER \
881 struct NETIORouteProperty
894 #define NETIORouteProperty_INITIALIZER \
902 struct NETIOBindEntryKey
907 struct NETIO_Address source;
912 struct NETIO_Address destination;
918 struct NETIOBindEntry
923 struct NETIO_Address source;
928 struct NETIO_Address destination;
933 NETIO_Interface_T *intf;
944 NETIO_ROUTESTATE_ACTIVE,
949 NETIO_ROUTESTATE_INACTIVE
950 } NETIO_RouteState_T;
956 struct NETIORouteEntryKey
961 struct NETIO_Address destination;
966 NETIO_Interface_T *intf;
971 struct NETIO_Address intf_address;
977 struct NETIORouteEntry
982 struct NETIO_Address destination;
987 NETIO_Interface_T *intf;
992 struct NETIO_Address intf_address;
997 NETIO_RouteState_T state;
1008 NETIO_EVENTKIND_INACTIVE_PEER,
1013 NETIO_EVENTKIND_ACTIVE_PEER,
1018 NETIO_EVENTKIND_RESOURCES_FREED
1019 } NETIO_EventKind_T;
1024 struct NETIO_Event_PeerActivity
1029 struct NETIO_Address peer_addr;
1034 RTI_INT32 inactive_total;
1039 RTI_INT32 inactive_change;
1044 RTI_INT32 active_total;
1049 RTI_INT32 active_change;
1055 struct NETIO_Event_ResourcesFreed
1057 struct NETIO_Guid entity;
1071 NETIO_EventKind_T kind;
1078 struct NETIO_Event_PeerActivity peer_activity;
1079 struct NETIO_Event_ResourcesFreed resources_freed;
1083 struct NETIO_InterfaceI;
1098 NETIO_Interface_Table_name_from_id(
char *tbl_name,
1099 union RT_ComponentFactoryId *
id,
1101 RTI_INT32 instance);
1115 MUST_CHECK_RETURN NETIODllExport RTI_BOOL
1116 NETIO_Interface_initialize(
struct NETIO_Interface *netio,
1117 struct NETIO_InterfaceI *netio_intf,
1118 const struct NETIO_InterfaceProperty *
const property,
1119 const struct NETIO_InterfaceListener *
const listener);
1131 SHOULD_CHECK_RETURN NETIODllExport RTI_BOOL
1132 NETIO_Interface_finalize(
struct NETIO_Interface *netio);
1152 MUST_CHECK_RETURN NETIODllExport RTI_INT32
1153 NETIO_Interface_compare_route(RTI_INT32 flags,
1154 const DB_Record_T op1,
void *op2);
1173 MUST_CHECK_RETURN NETIODllExport RTI_INT32
1174 NETIO_Interface_compare_bind(RTI_INT32 flags,
1175 const DB_Record_T op1,
void *op2);
1189 FUNCTION_MUST_TYPEDEF(
1191 (*NETIO_Interface_sendFunc)(NETIO_Interface_T *
self,
1192 struct NETIO_Interface *source,
1193 struct NETIO_Address *destination,
1194 NETIO_Packet_T *packet)
1209 FUNCTION_MUST_TYPEDEF(
1211 (*NETIO_Interface_receiveFunc)(NETIO_Interface_T *netio_intf,
1212 struct NETIO_Address *src_addr,
1213 struct NETIO_Address *dst_addr,
1214 NETIO_Packet_T *packet)
1229 FUNCTION_MUST_TYPEDEF(
1231 (*NETIO_Interface_acknackFunc)(NETIO_Interface_T *
self,
1232 struct NETIO_Address *source,
1233 NETIO_PacketId_T *packet_id,
1254 FUNCTION_MUST_TYPEDEF(
1256 (*NETIO_Interface_requestFunc)(NETIO_Interface_T *
self,
1257 struct NETIO_Address *source,
1258 struct NETIO_Address *dest,
1259 NETIO_Packet_T **packet,
1260 NETIO_PacketId_T *packet_id,
1261 NETIO_PacketId_T *actual_packet_id)
1277 FUNCTION_MUST_TYPEDEF(
1279 (*NETIO_Interface_return_loanFunc)(NETIO_Interface_T *
self,
1280 struct NETIO_Address *source,
1281 NETIO_Packet_T *packet,
1282 NETIO_PacketId_T *packet_id)
1296 FUNCTION_MUST_TYPEDEF(
1298 (*NETIO_Interface_xmit_removeFunc)(NETIO_Interface_T *
self,
1299 struct NETIO_Address *destination,
1300 NETIO_PacketId_T *packet_id)
1315 FUNCTION_MUST_TYPEDEF(
1317 (*NETIO_Interface_add_routeFunc)(NETIO_Interface_T *
self,
1318 struct NETIO_Address *dst_addr,
1319 NETIO_Interface_T *via_intf,
1320 struct NETIO_Address *via_addr,
1321 struct NETIORouteProperty *property,
1339 FUNCTION_MUST_TYPEDEF(
1341 (*NETIO_Interface_delete_routeFunc)(NETIO_Interface_T *
self,
1342 struct NETIO_Address *dst_addr,
1343 NETIO_Interface_T *via_intf,
1344 struct NETIO_Address *via_addr,
1360 FUNCTION_MUST_TYPEDEF(
1362 (*NETIO_Interface_bindFunc)(NETIO_Interface_T *netio_intf,
1363 struct NETIO_Address *src_addr,
1364 struct NETIOBindProperty *property,
1380 FUNCTION_MUST_TYPEDEF(
1382 (*NETIO_Interface_unbindFunc)(NETIO_Interface_T *netio_intf,
1383 struct NETIO_Address *src_addr,
1384 NETIO_Interface_T *dst_intf,
1402 FUNCTION_MUST_TYPEDEF(
1404 (*NETIO_Interface_bind_externalFunc)(NETIO_Interface_T *src_intf,
1405 struct NETIO_Address *src_addr,
1406 NETIO_Interface_T *dst_intf,
1407 struct NETIO_Address *dst_addr,
1408 struct NETIOBindProperty *property,
1425 FUNCTION_MUST_TYPEDEF(
1427 (*NETIO_Interface_unbind_externalFunc)(NETIO_Interface_T *src_intf,
1428 struct NETIO_Address *src_addr,
1429 NETIO_Interface_T *dst_intf,
1430 struct NETIO_Address *dst_addr,
1447 FUNCTION_MUST_TYPEDEF(
1449 (*NETIO_Interface_get_external_interfaceFunc)(NETIO_Interface_T *netio_intf,
1450 struct NETIO_Address *src_addr,
1451 NETIO_Interface_T **dst_intf,
1452 struct NETIO_Address *dst_addr)
1467 FUNCTION_MUST_TYPEDEF(
1469 (*NETIO_Interface_reserve_addressFunc)(NETIO_Interface_T *
self,
1470 struct NETIO_AddressSeq *req_address,
1471 struct NETIO_AddressSeq *rsvd_address,
1472 struct NETIOBindProperty *property)
1485 FUNCTION_MUST_TYPEDEF(
1487 (*NETIO_Interface_release_addressFunc)(NETIO_Interface_T *
self,
1488 struct NETIO_Address *src_addr)
1501 FUNCTION_MUST_TYPEDEF(
1503 (*NETIO_Interface_set_stateFunc)(NETIO_Interface_T *netio_intf,
1504 NETIO_InterfaceState_T state)
1519 FUNCTION_MUST_TYPEDEF(
1521 (*NETIO_Interface_resolve_adddressFunc)(NETIO_Interface_T *netio_intf,
1522 const char *address_string,
1523 struct NETIO_Address *address_value,
1538 FUNCTION_MUST_TYPEDEF(
1540 (*NETIO_Interface_get_route_tableFunc)(NETIO_Interface_T *netio_intf,
1541 struct NETIO_AddressSeq *address,
1542 struct NETIO_NetmaskSeq *netmask)
1556 FUNCTION_MUST_TYPEDEF(
1558 (*NETIO_Interface_post_eventFunc)(NETIO_Interface_T *
self,
1559 NETIO_Interface_T *src_intf,
1560 struct NETIO_Event *event)
1578 FUNCTION_MUST_TYPEDEF(
1580 (*NETIO_Interface_lookup_routeFunc)(
struct NETIO_Interface *netio_intf,
1581 struct NETIO_Address *dst_reader,
1582 struct NETIO_Interface *via_intf,
1583 struct NETIO_Address *via_address,
1584 RTI_BOOL *route_exists)
1591 struct NETIO_InterfaceI
1596 struct RT_ComponentI _parent;
1601 NETIO_Interface_sendFunc send;
1606 NETIO_Interface_acknackFunc acknack;
1611 NETIO_Interface_requestFunc request;
1613 NETIO_Interface_return_loanFunc return_loan;
1618 NETIO_Interface_xmit_removeFunc xmit_remove;
1623 NETIO_Interface_add_routeFunc add_route;
1628 NETIO_Interface_delete_routeFunc delete_route;
1633 NETIO_Interface_reserve_addressFunc reserve_address;
1638 NETIO_Interface_bindFunc bind;
1643 NETIO_Interface_unbindFunc unbind;
1648 NETIO_Interface_receiveFunc receive;
1654 NETIO_Interface_get_external_interfaceFunc get_external_interface;
1659 NETIO_Interface_bind_externalFunc bind_external;
1664 NETIO_Interface_unbind_externalFunc unbind_external;
1669 NETIO_Interface_set_stateFunc set_state;
1674 NETIO_Interface_release_addressFunc release_address;
1679 NETIO_Interface_resolve_adddressFunc resolve_address;
1685 NETIO_Interface_get_route_tableFunc get_route_table;
1690 NETIO_Interface_post_eventFunc post_event;
1695 NETIO_Interface_lookup_routeFunc lookup_route;
1705 #define NETIO_InterfaceFactory_create_component(f_,p_,l_) \
1706 (NETIO_Interface_T*)((f_)->intf->create_component(\
1715 #define NETIO_InterfaceFactory_delete_component(f_,intf_) \
1716 (f_)->intf->delete_component(f_,(&(intf_)->_parent))
1731 #define NETIO_Interface_send(self_,src_intf_,dst_addr_,pkt_) \
1732 ((struct NETIO_InterfaceI*)(\
1733 (self_)->_parent._intf))->send(self_,src_intf_,dst_addr_,pkt_)
1750 #define NETIO_Interface_acknack(self_,src_intf_,sn_,nack_) \
1751 ((struct NETIO_InterfaceI*)(\
1752 (self_)->_parent._intf))->acknack(self_,src_intf_,sn_,nack_)
1774 #define NETIO_Interface_request(self_,src_,dst_,pkt_,pktid_,nextpktid_) \
1775 ((struct NETIO_InterfaceI*)(\
1776 (self_)->_parent._intf))->request(self_,src_,dst_,pkt_,pktid_,nextpktid_)
1791 #define NETIO_Interface_return_loan(self_,src_,pkt_,pkt_id_) \
1792 ((struct NETIO_InterfaceI*)(\
1793 (self_)->_parent._intf))->return_loan(self_,src_,pkt_,pkt_id_)
1808 #define NETIO_Interface_xmit_remove(self_,dst_,pkt_id_) \
1809 ((struct NETIO_InterfaceI*)(\
1810 (self_)->_parent._intf))->xmit_remove(self_,dst_,pkt_id_)
1828 #define NETIO_Interface_add_route(self_,dst_,intf_,intf_addr,prop_,ex_) \
1829 ((struct NETIO_InterfaceI*)(\
1830 (self_)->_parent._intf))->add_route(self_,dst_,intf_,intf_addr,prop_,ex_)
1848 #define NETIO_Interface_delete_route(self_,dst_,intf_,intf_addr_,exist_) \
1849 ((struct NETIO_InterfaceI*)(\
1850 (self_)->_parent._intf))->delete_route(self_,dst_,intf_,intf_addr_,exist_)
1867 #define NETIO_Interface_reserve_address(self_,src_addr_,pub_addr_,prop_)\
1868 ((struct NETIO_InterfaceI*)(\
1869 (self_)->_parent._intf))->reserve_address(self_,src_addr_,pub_addr_,prop_)
1882 #define NETIO_Interface_release_address(self_,src_addr_) \
1883 ((struct NETIO_InterfaceI*)(\
1884 (self_)->_parent._intf))->release_address(self_,src_addr_)
1902 #define NETIO_Interface_bind(self_,src_,prop_,ex_) \
1903 ((struct NETIO_InterfaceI*)(\
1904 (self_)->_parent._intf))->bind(self_,src_,prop_,ex_)
1922 #define NETIO_Interface_unbind(self_,src_,dst_,exist_) \
1923 ((struct NETIO_InterfaceI*)(\
1924 (self_)->_parent._intf))->unbind(self_,src_,dst_,exist_)
1945 #define NETIO_Interface_bind_external(src_intf_,src_adr_,dst_intf_,dst_adr_,p_,e_) \
1946 ((struct NETIO_InterfaceI*)(\
1947 (src_intf_)->_parent._intf))->bind_external(src_intf_,src_adr_,dst_intf_,dst_adr_,p_,e_)
1967 #define NETIO_Interface_unbind_external(src_intf_,src_adr_,dst_adr_,dst_intf_,exist_) \
1968 ((struct NETIO_InterfaceI*)(\
1969 (src_intf_)->_parent._intf))->unbind_external(src_intf_,src_adr_,dst_adr_,dst_intf_,exist_)
1990 #define NETIO_Interface_receive(self_,src_,dst_,p_) \
1991 ((struct NETIO_InterfaceI*)(\
1992 (self_)->_parent._intf))->receive(self_,src_,dst_,p_)
2009 #define NETIO_Interface_get_external_interface(self_,src_,ul_,dst_) \
2010 ((struct NETIO_InterfaceI*)(\
2011 (self_)->_parent._intf))->get_external_interface(self_,src_,ul_,dst_)
2025 #define NETIO_Interface_set_state(self_,state_) \
2026 ((struct NETIO_InterfaceI*)(\
2027 (self_)->_parent._intf))->set_state(self_,state_)
2044 #define NETIO_Interface_resolve_address(self_,address_,resolved_,is_invalid_) \
2045 ((struct NETIO_InterfaceI*)(\
2046 (self_)->_parent._intf))->resolve_address(self_,address_,resolved_,is_invalid_)
2061 #define NETIO_Interface_get_route_table(self_,address_,netmask_) \
2062 ((struct NETIO_InterfaceI*)(\
2063 (self_)->_parent._intf))->get_route_table(self_,address_,netmask_)
2077 #define NETIO_Interface_post_event(self_,src_intf_,event_) \
2078 ((struct NETIO_InterfaceI*)(\
2079 (self_)->_parent._intf))->post_event(self_,src_intf_,event_)
2092 #define NETIO_Interface_lookup_route(self_,dst_reader_,via_intf_,\
2093 via_address_,route_exists_) \
2094 ((struct NETIO_InterfaceI*)(\
2095 (self_)->_parent._intf))->lookup_route(self_,dst_reader_,via_intf_,\
2096 via_address_,route_exists_)