diff --git a/include/zenoh-pico/link/link.h b/include/zenoh-pico/link/link.h index 32c9ebb42..75e2a02a7 100644 --- a/include/zenoh-pico/link/link.h +++ b/include/zenoh-pico/link/link.h @@ -28,6 +28,10 @@ #include "zenoh-pico/system/link/udp.h" #endif +#if Z_FEATURE_RAWETH_TRANSPORT == 1 +#include "zenoh-pico/system/link/raweth.h" +#endif + #if Z_FEATURE_LINK_BLUETOOTH == 1 #include "zenoh-pico/system/link/bt.h" #endif @@ -52,6 +56,7 @@ typedef enum { Z_LINK_CAP_TRANSPORT_UNICAST = 0, Z_LINK_CAP_TRANSPORT_MULTICAST = 1, + Z_LINK_CAP_TRANSPORT_RAWETH = 2, } _z_link_cap_transport_t; /** @@ -73,7 +78,7 @@ typedef enum { * transport: 2 bits, see _z_link_cap_transport_t enum. * flow: 1 bit, see _z_link_cap_flow_t enum. * reliable: 1 bit, 1 if the link is reliable (network definition) - * reserved: 4 bits, reserved for futur use + * reserved: 4 bits, reserved for future use */ typedef struct _z_link_capabilities_t { uint8_t _transport : 2; @@ -111,6 +116,9 @@ typedef struct _z_link_t { #endif #if Z_FEATURE_LINK_WS == 1 _z_ws_socket_t _ws; +#endif +#if Z_FEATURE_RAWETH_TRANSPORT == 1 + _z_raweth_socket_t _raweth; #endif } _socket; diff --git a/include/zenoh-pico/system/platform/unix.h b/include/zenoh-pico/system/platform/unix.h index 8084e22db..577ef670e 100644 --- a/include/zenoh-pico/system/platform/unix.h +++ b/include/zenoh-pico/system/platform/unix.h @@ -35,7 +35,8 @@ typedef struct timeval z_time_t; typedef struct { union { -#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 +#if Z_FEATURE_LINK_TCP == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1 || Z_FEATURE_LINK_UDP_UNICAST == 1 || \ + Z_FEATURE_RAWETH_TRANSPORT == 1 int _fd; #endif }; diff --git a/include/zenoh-pico/transport/transport.h b/include/zenoh-pico/transport/transport.h index 00356c20b..bb9ad72c2 100644 --- a/include/zenoh-pico/transport/transport.h +++ b/include/zenoh-pico/transport/transport.h @@ -135,11 +135,13 @@ typedef struct { union { _z_transport_unicast_t _unicast; _z_transport_multicast_t _multicast; + _z_transport_multicast_t _raweth; } _transport; enum { _Z_TRANSPORT_UNICAST_TYPE, _Z_TRANSPORT_MULTICAST_TYPE, + _Z_TRANSPORT_RAWETH_TYPE, } _type; } _z_transport_t; diff --git a/src/api/api.c b/src/api/api.c index 8e228fc45..9455a6a2e 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -547,6 +547,7 @@ int8_t z_info_peers_zid(const z_session_t zs, z_owned_closure_zid_t *callback) { // Call transport function switch (zs._val->_tp._type) { case _Z_TRANSPORT_MULTICAST_TYPE: + case _Z_TRANSPORT_RAWETH_TYPE: _zp_multicast_fetch_zid(&zs._val->_tp, callback); break; default: @@ -638,7 +639,7 @@ z_owned_publisher_t z_declare_publisher(z_session_t zs, z_keyexpr_t keyexpr, con // TODO: Currently, if resource declarations are done over multicast transports, the current protocol definition // lacks a way to convey them to later-joining nodes. Thus, in the current version automatic // resource declarations are only performed on unicast transports. - if (zs._val->_tp._type != _Z_TRANSPORT_MULTICAST_TYPE) { + if (zs._val->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { _z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr); if (r == NULL) { uint16_t id = _z_declare_resource(zs._val, keyexpr); @@ -794,7 +795,7 @@ z_owned_queryable_t z_declare_queryable(z_session_t zs, z_keyexpr_t keyexpr, z_o // TODO: Currently, if resource declarations are done over multicast transports, the current protocol definition // lacks a way to convey them to later-joining nodes. Thus, in the current version automatic // resource declarations are only performed on unicast transports. - if (zs._val->_tp._type != _Z_TRANSPORT_MULTICAST_TYPE) { + if (zs._val->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { _z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr); if (r == NULL) { uint16_t id = _z_declare_resource(zs._val, keyexpr); @@ -897,7 +898,7 @@ z_owned_subscriber_t z_declare_subscriber(z_session_t zs, z_keyexpr_t keyexpr, z // TODO: Currently, if resource declarations are done over multicast transports, the current protocol definition // lacks a way to convey them to later-joining nodes. Thus, in the current version automatic // resource declarations are only performed on unicast transports. - if (zs._val->_tp._type != _Z_TRANSPORT_MULTICAST_TYPE) { + if (zs._val->_tp._type == _Z_TRANSPORT_UNICAST_TYPE) { _z_resource_t *r = _z_get_resource_by_key(zs._val, &keyexpr); if (r == NULL) { char *wild = strpbrk(keyexpr._suffix, "*$"); diff --git a/src/link/link.c b/src/link/link.c index 2888da55d..ff63ec689 100644 --- a/src/link/link.c +++ b/src/link/link.c @@ -17,6 +17,7 @@ #include #include "zenoh-pico/config.h" +#include "zenoh-pico/link/config/raweth.h" #include "zenoh-pico/link/manager.h" #include "zenoh-pico/utils/logging.h" @@ -56,7 +57,6 @@ int8_t _z_open_link(_z_link_t *zl, const char *locator) { { ret = _Z_ERR_CONFIG_LOCATOR_SCHEMA_UNKNOWN; } - if (ret == _Z_RES_OK) { // Open transport link for communication if (zl->_open_f(zl) != _Z_RES_OK) { @@ -92,10 +92,11 @@ int8_t _z_listen_link(_z_link_t *zl, const char *locator) { ret = _z_new_link_bt(zl, ep); } else #endif - { + if (_z_endpoint_raweth_valid(&ep) == _Z_RES_OK) { + ret = _z_new_link_raweth(zl, ep); + } else { ret = _Z_ERR_CONFIG_LOCATOR_SCHEMA_UNKNOWN; } - if (ret == _Z_RES_OK) { // Open transport link for listening if (zl->_listen_f(zl) != _Z_RES_OK) { diff --git a/src/net/session.c b/src/net/session.c index f0e2f3b30..97a322606 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -30,6 +30,8 @@ #include "zenoh-pico/transport/multicast.h" #include "zenoh-pico/transport/multicast/lease.h" #include "zenoh-pico/transport/multicast/read.h" +#include "zenoh-pico/transport/raweth/lease.h" +#include "zenoh-pico/transport/raweth/read.h" #include "zenoh-pico/transport/unicast.h" #include "zenoh-pico/transport/unicast/lease.h" #include "zenoh-pico/transport/unicast/read.h" @@ -160,6 +162,7 @@ _z_config_t *_z_info(const _z_session_t *zn) { _zp_unicast_info_session(&zn->_tp, ps); break; case _Z_TRANSPORT_MULTICAST_TYPE: + case _Z_TRANSPORT_RAWETH_TYPE: _zp_multicast_info_session(&zn->_tp, ps); break; default: @@ -192,6 +195,9 @@ int8_t _zp_start_read_task(_z_session_t *zn, _z_task_attr_t *attr) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_start_read_task(&zn->_tp, attr, task); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_start_read_task(&zn->_tp, attr, task); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; @@ -218,6 +224,9 @@ int8_t _zp_start_lease_task(_z_session_t *zn, _z_task_attr_t *attr) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_start_lease_task(&zn->_tp, attr, task); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_start_lease_task(&zn->_tp, attr, task); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; @@ -239,6 +248,9 @@ int8_t _zp_stop_read_task(_z_session_t *zn) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_stop_read_task(&zn->_tp); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_stop_read_task(&zn->_tp); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; @@ -256,6 +268,9 @@ int8_t _zp_stop_lease_task(_z_session_t *zn) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_stop_lease_task(&zn->_tp); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_stop_lease_task(&zn->_tp); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; diff --git a/src/session/tx.c b/src/session/tx.c index b00c072f2..8f5b925bb 100644 --- a/src/session/tx.c +++ b/src/session/tx.c @@ -14,6 +14,7 @@ #include "zenoh-pico/transport/multicast/tx.h" +#include "zenoh-pico/transport/raweth/tx.h" #include "zenoh-pico/transport/unicast/tx.h" #include "zenoh-pico/utils/logging.h" @@ -29,6 +30,9 @@ int8_t _z_send_n_msg(_z_session_t *zn, const _z_network_message_t *z_msg, z_reli case _Z_TRANSPORT_MULTICAST_TYPE: ret = _z_multicast_send_n_msg(zn, z_msg, reliability, cong_ctrl); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _z_raweth_send_n_msg(zn, z_msg, reliability, cong_ctrl); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; diff --git a/src/session/utils.c b/src/session/utils.c index 1985c8f8a..32b685b78 100644 --- a/src/session/utils.c +++ b/src/session/utils.c @@ -89,6 +89,9 @@ int8_t _z_session_init(_z_session_t *zn, _z_id_t *zid) { case _Z_TRANSPORT_MULTICAST_TYPE: zn->_tp._transport._multicast._session = zn; break; + case _Z_TRANSPORT_RAWETH_TYPE: + zn->_tp._transport._raweth._session = zn; + break; default: break; } diff --git a/src/transport/common/join.c b/src/transport/common/join.c index 4d3c8498a..72bfac0e0 100644 --- a/src/transport/common/join.c +++ b/src/transport/common/join.c @@ -15,6 +15,7 @@ #include "zenoh-pico/transport/common/join.h" #include "zenoh-pico/transport/multicast/join.h" +#include "zenoh-pico/transport/raweth/join.h" int8_t _z_send_join(_z_transport_t *zt) { int8_t ret = _Z_RES_OK; @@ -23,6 +24,9 @@ int8_t _z_send_join(_z_transport_t *zt) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_send_join(&zt->_transport._multicast); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_send_join(&zt->_transport._raweth); + break; default: (void)zt; ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; diff --git a/src/transport/common/lease.c b/src/transport/common/lease.c index 8e337f497..5c2baa712 100644 --- a/src/transport/common/lease.c +++ b/src/transport/common/lease.c @@ -17,6 +17,7 @@ #include #include "zenoh-pico/transport/multicast/lease.h" +#include "zenoh-pico/transport/raweth/lease.h" #include "zenoh-pico/transport/unicast/lease.h" int8_t _z_send_keep_alive(_z_transport_t *zt) { @@ -28,6 +29,9 @@ int8_t _z_send_keep_alive(_z_transport_t *zt) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_send_keep_alive(&zt->_transport._multicast); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_send_keep_alive(&zt->_transport._raweth); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; @@ -45,6 +49,9 @@ void *_zp_lease_task(void *zt_arg) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_lease_task(&zt->_transport._multicast); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_lease_task(&zt->_transport._raweth); + break; default: ret = NULL; break; diff --git a/src/transport/common/read.c b/src/transport/common/read.c index a9e2485a4..d7db6c61d 100644 --- a/src/transport/common/read.c +++ b/src/transport/common/read.c @@ -17,6 +17,7 @@ #include #include "zenoh-pico/transport/multicast/read.h" +#include "zenoh-pico/transport/raweth/read.h" #include "zenoh-pico/transport/unicast/read.h" int8_t _z_read(_z_transport_t *zt) { @@ -28,6 +29,9 @@ int8_t _z_read(_z_transport_t *zt) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_read(&zt->_transport._multicast); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_read(&zt->_transport._raweth); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; @@ -45,6 +49,9 @@ void *_zp_read_task(void *zt_arg) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _zp_multicast_read_task(&zt->_transport._multicast); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _zp_raweth_read_task(&zt->_transport._raweth); + break; default: ret = NULL; break; diff --git a/src/transport/common/tx.c b/src/transport/common/tx.c index 6f38ac365..3508493f4 100644 --- a/src/transport/common/tx.c +++ b/src/transport/common/tx.c @@ -12,12 +12,14 @@ // ZettaScale Zenoh Team, // -#include "zenoh-pico/transport/multicast/tx.h" +#include "zenoh-pico/transport/common/tx.h" #include "zenoh-pico/api/constants.h" #include "zenoh-pico/protocol/codec/core.h" #include "zenoh-pico/protocol/codec/transport.h" #include "zenoh-pico/protocol/definitions/transport.h" +#include "zenoh-pico/transport/multicast/tx.h" +#include "zenoh-pico/transport/raweth/tx.h" #include "zenoh-pico/transport/unicast/tx.h" #include "zenoh-pico/utils/logging.h" @@ -76,6 +78,9 @@ int8_t _z_send_t_msg(_z_transport_t *zt, const _z_transport_message_t *t_msg) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _z_multicast_send_t_msg(&zt->_transport._multicast, t_msg); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _z_raweth_send_t_msg(&zt->_transport._raweth, t_msg); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; diff --git a/src/transport/manager.c b/src/transport/manager.c index 7d8f79811..351e67f83 100644 --- a/src/transport/manager.c +++ b/src/transport/manager.c @@ -18,6 +18,7 @@ #include #include "zenoh-pico/transport/multicast/transport.h" +#include "zenoh-pico/transport/raweth/transport.h" #include "zenoh-pico/transport/unicast/transport.h" int8_t _z_new_transport_client(_z_transport_t *zt, char *locator, _z_id_t *local_zid) { @@ -54,6 +55,16 @@ int8_t _z_new_transport_client(_z_transport_t *zt, char *locator, _z_id_t *local ret = _z_multicast_transport_create(zt, &zl, &tp_param); break; } + case Z_LINK_CAP_TRANSPORT_RAWETH: { + _z_transport_multicast_establish_param_t tp_param; + ret = _z_raweth_open_client(&tp_param, &zl, local_zid); + if (ret != _Z_RES_OK) { + _z_link_clear(&zl); + return ret; + } + ret = _z_raweth_transport_create(zt, &zl, &tp_param); + break; + } default: ret = _Z_ERR_GENERIC; break; @@ -92,6 +103,16 @@ int8_t _z_new_transport_peer(_z_transport_t *zt, char *locator, _z_id_t *local_z ret = _z_multicast_transport_create(zt, &zl, &tp_param); break; } + case Z_LINK_CAP_TRANSPORT_RAWETH: { + _z_transport_multicast_establish_param_t tp_param; + ret = _z_raweth_open_peer(&tp_param, &zl, local_zid); + if (ret != _Z_RES_OK) { + _z_link_clear(&zl); + return ret; + } + ret = _z_raweth_transport_create(zt, &zl, &tp_param); + break; + } default: ret = _Z_ERR_GENERIC; break; diff --git a/src/transport/transport.c b/src/transport/transport.c index 27170233c..b6fd7ac66 100644 --- a/src/transport/transport.c +++ b/src/transport/transport.c @@ -24,6 +24,9 @@ #include "zenoh-pico/transport/multicast/rx.h" #include "zenoh-pico/transport/multicast/transport.h" #include "zenoh-pico/transport/multicast/tx.h" +#include "zenoh-pico/transport/raweth/rx.h" +#include "zenoh-pico/transport/raweth/transport.h" +#include "zenoh-pico/transport/raweth/tx.h" #include "zenoh-pico/transport/unicast/rx.h" #include "zenoh-pico/transport/unicast/transport.h" #include "zenoh-pico/transport/unicast/tx.h" @@ -40,6 +43,9 @@ int8_t _z_send_close(_z_transport_t *zt, uint8_t reason, _Bool link_only) { case _Z_TRANSPORT_MULTICAST_TYPE: ret = _z_multicast_send_close(&zt->_transport._multicast, reason, link_only); break; + case _Z_TRANSPORT_RAWETH_TYPE: + ret = _z_raweth_send_close(&zt->_transport._raweth, reason, link_only); + break; default: ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE; break; @@ -57,6 +63,9 @@ void _z_transport_clear(_z_transport_t *zt) { case _Z_TRANSPORT_MULTICAST_TYPE: _z_multicast_transport_clear(zt); break; + case _Z_TRANSPORT_RAWETH_TYPE: + _z_raweth_transport_clear(zt); + break; default: break; }