Skip to content

Commit

Permalink
feat: fuse lease and join files
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Dec 5, 2023
1 parent e899531 commit 61439af
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 193 deletions.
22 changes: 0 additions & 22 deletions include/zenoh-pico/transport/common/join.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/zenoh-pico/transport/common/lease.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "zenoh-pico/transport/transport.h"

int8_t _z_send_join(_z_transport_t *zt);
int8_t _z_send_keep_alive(_z_transport_t *zt);
void *_zp_lease_task(void *zt_arg); // The argument is void* to avoid incompatible pointer types in tasks

#endif /* ZENOH_PICO_TRANSPORT_LEASE_H */
22 changes: 0 additions & 22 deletions include/zenoh-pico/transport/multicast/join.h

This file was deleted.

1 change: 1 addition & 0 deletions include/zenoh-pico/transport/multicast/lease.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "zenoh-pico/transport/transport.h"

int8_t _zp_multicast_send_join(_z_transport_multicast_t *ztm);
int8_t _zp_multicast_send_keep_alive(_z_transport_multicast_t *ztm);
int8_t _zp_multicast_start_lease_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task);
int8_t _zp_multicast_stop_lease_task(_z_transport_t *zt);
Expand Down
22 changes: 0 additions & 22 deletions include/zenoh-pico/transport/raweth/join.h

This file was deleted.

1 change: 1 addition & 0 deletions include/zenoh-pico/transport/raweth/lease.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "zenoh-pico/transport/transport.h"

int8_t _zp_raweth_send_join(_z_transport_multicast_t *ztm);
int8_t _zp_raweth_send_keep_alive(_z_transport_multicast_t *ztm);
int8_t _zp_raweth_start_lease_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task);
int8_t _zp_raweth_stop_lease_task(_z_transport_t *zt);
Expand Down
1 change: 0 additions & 1 deletion src/net/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "zenoh-pico/net/memory.h"
#include "zenoh-pico/protocol/core.h"
#include "zenoh-pico/session/utils.h"
#include "zenoh-pico/transport/common/join.h"
#include "zenoh-pico/transport/common/lease.h"
#include "zenoh-pico/transport/common/read.h"
#include "zenoh-pico/transport/multicast.h"
Expand Down
36 changes: 0 additions & 36 deletions src/transport/common/join.c

This file was deleted.

16 changes: 7 additions & 9 deletions src/transport/common/lease.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ int8_t _z_send_keep_alive(_z_transport_t *zt) {
return ret;
}

void *_zp_lease_task(void *zt_arg) {
void *ret = NULL;
_z_transport_t *zt = (_z_transport_t *)zt_arg;
int8_t _z_send_join(_z_transport_t *zt) {
int8_t ret = _Z_RES_OK;
// Join task only applies to multicast transports
switch (zt->_type) {
case _Z_TRANSPORT_UNICAST_TYPE:
ret = _zp_unicast_lease_task(&zt->_transport._unicast);
break;
case _Z_TRANSPORT_MULTICAST_TYPE:
ret = _zp_multicast_lease_task(&zt->_transport._multicast);
ret = _zp_multicast_send_join(&zt->_transport._multicast);
break;
case _Z_TRANSPORT_RAWETH_TYPE:
ret = _zp_raweth_lease_task(&zt->_transport._raweth);
ret = _zp_raweth_send_join(&zt->_transport._raweth);
break;
default:
ret = NULL;
(void)zt;
ret = _Z_ERR_TRANSPORT_NOT_AVAILABLE;
break;
}
return ret;
Expand Down
38 changes: 0 additions & 38 deletions src/transport/multicast/join.c

This file was deleted.

21 changes: 19 additions & 2 deletions src/transport/multicast/lease.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#include "zenoh-pico/config.h"
#include "zenoh-pico/session/utils.h"
#include "zenoh-pico/transport/common/join.h"
#include "zenoh-pico/transport/multicast/join.h"
#include "zenoh-pico/transport/common/lease.h"
#include "zenoh-pico/transport/multicast/transport.h"
#include "zenoh-pico/transport/multicast/tx.h"
#include "zenoh-pico/utils/logging.h"
Expand Down Expand Up @@ -60,6 +59,19 @@ static _z_zint_t _z_get_next_lease(_z_transport_peer_entry_list_t *peers) {
return ret;
}


int8_t _zp_multicast_send_join(_z_transport_multicast_t *ztm) {
_z_conduit_sn_list_t next_sn;
next_sn._is_qos = false;
next_sn._val._plain._best_effort = ztm->_sn_tx_best_effort;
next_sn._val._plain._reliable = ztm->_sn_tx_reliable;

_z_id_t zid = ((_z_session_t *)ztm->_session)->_local_zid;
_z_transport_message_t jsm = _z_t_msg_make_join(Z_WHATAMI_PEER, Z_TRANSPORT_LEASE, zid, next_sn);

return _z_multicast_send_t_msg(ztm, &jsm);
}

int8_t _zp_multicast_send_keep_alive(_z_transport_multicast_t *ztm) {
int8_t ret = _Z_RES_OK;

Expand Down Expand Up @@ -184,6 +196,11 @@ void *_zp_multicast_lease_task(void *ztm_arg) {
return 0;
}
#else
int8_t _zp_multicast_send_join(_z_transport_multicast_t *ztm) {
_ZP_UNUSED(ztm);
return _Z_ERR_TRANSPORT_NOT_AVAILABLE;
}

int8_t _zp_multicast_send_keep_alive(_z_transport_multicast_t *ztm) {
_ZP_UNUSED(ztm);
return _Z_ERR_TRANSPORT_NOT_AVAILABLE;
Expand Down
38 changes: 0 additions & 38 deletions src/transport/raweth/join.c

This file was deleted.

20 changes: 18 additions & 2 deletions src/transport/raweth/lease.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#include "zenoh-pico/config.h"
#include "zenoh-pico/session/utils.h"
#include "zenoh-pico/transport/common/join.h"
#include "zenoh-pico/transport/raweth/join.h"
#include "zenoh-pico/transport/common/lease.h"
#include "zenoh-pico/transport/raweth/transport.h"
#include "zenoh-pico/transport/raweth/tx.h"
#include "zenoh-pico/utils/logging.h"
Expand Down Expand Up @@ -60,6 +59,18 @@ static _z_zint_t _z_get_next_lease(_z_transport_peer_entry_list_t *peers) {
return ret;
}

int8_t _zp_raweth_send_join(_z_transport_multicast_t *ztm) {
_z_conduit_sn_list_t next_sn;
next_sn._is_qos = false;
next_sn._val._plain._best_effort = ztm->_sn_tx_best_effort;
next_sn._val._plain._reliable = ztm->_sn_tx_reliable;

_z_id_t zid = ((_z_session_t *)ztm->_session)->_local_zid;
_z_transport_message_t jsm = _z_t_msg_make_join(Z_WHATAMI_PEER, Z_TRANSPORT_LEASE, zid, next_sn);

return _z_raweth_send_t_msg(ztm, &jsm);
}

int8_t _zp_raweth_send_keep_alive(_z_transport_multicast_t *ztm) {
int8_t ret = _Z_RES_OK;

Expand Down Expand Up @@ -184,6 +195,11 @@ void *_zp_raweth_lease_task(void *ztm_arg) {
return 0;
}
#else
int8_t _zp_raweth_send_join(_z_transport_multicast_t *ztm) {
_ZP_UNUSED(ztm);
return _Z_ERR_TRANSPORT_NOT_AVAILABLE;
}

int8_t _zp_raweth_send_keep_alive(_z_transport_multicast_t *ztm) {
_ZP_UNUSED(ztm);
return _Z_ERR_TRANSPORT_NOT_AVAILABLE;
Expand Down

0 comments on commit 61439af

Please sign in to comment.