Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor transport layer #279

Merged
merged 26 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba9299f
feat: add modular test
jean-roland Oct 20, 2023
5146607
build: add cmake generator option for build
jean-roland Oct 24, 2023
2aa900c
style: run clang-format
jean-roland Oct 24, 2023
bc5aca7
fix: keep a command with default cmake generator
jean-roland Oct 24, 2023
f3916ec
build: remove unnecessary target
jean-roland Oct 25, 2023
fecb92b
fix: remove old modular test
jean-roland Nov 6, 2023
ca8c11d
build: update actions deps
jean-roland Nov 8, 2023
f349c37
fix: revert codacy workflow changes
jean-roland Nov 8, 2023
98e0c26
feat: add unicast and multicast files
jean-roland Nov 9, 2023
c96dc86
feat: update transport files
jean-roland Nov 9, 2023
abc972c
fix: remove duplicate functions
jean-roland Nov 9, 2023
5ea0a1c
feat: go through transport files for api
jean-roland Nov 9, 2023
3cf9ac5
feat: displace functions in transport files
jean-roland Nov 9, 2023
3991a5e
feat: go through transport files for session
jean-roland Nov 9, 2023
7ee6d1d
refactor: remove unnecessary precompiler directives
jean-roland Nov 9, 2023
c1ba8ff
feat: add transport presence function
jean-roland Nov 10, 2023
9474c76
feat: call presence function in scout
jean-roland Nov 10, 2023
2a29284
feat: limit config tokens on lease
jean-roland Nov 13, 2023
acfc1b5
feat: limit config token on join
jean-roland Nov 13, 2023
b01bf72
feat: limit config token on read
jean-roland Nov 13, 2023
3d03fbc
feat: limit config token in transport tx
jean-roland Nov 13, 2023
7bb8d16
refactor: reorganize transport header
jean-roland Nov 13, 2023
da7c330
refactor: apply header changes to source files
jean-roland Nov 13, 2023
e452b2c
chore: missing line ending
jean-roland Nov 13, 2023
20640af
fix: use int8_t return type
jean-roland Nov 14, 2023
3f93d16
fix: remove transport_is_here functions
jean-roland Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/zenoh-pico/link/config/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "zenoh-pico/collections/intmap.h"
#include "zenoh-pico/collections/string.h"

#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1

#define UDP_CONFIG_ARGC 3

#define UDP_CONFIG_IFACE_KEY 0x01
Expand All @@ -31,6 +29,7 @@
#define UDP_CONFIG_JOIN_KEY 0x03
#define UDP_CONFIG_JOIN_STR "join"

#if Z_FEATURE_LINK_UDP_UNICAST == 1 || Z_FEATURE_LINK_UDP_MULTICAST == 1
#define UDP_CONFIG_MAPPING_BUILD \
_z_str_intmapping_t args[UDP_CONFIG_ARGC]; \
args[0]._key = UDP_CONFIG_IFACE_KEY; \
Expand Down
22 changes: 22 additions & 0 deletions include/zenoh-pico/transport/common/join.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_JOIN_H
#define ZENOH_PICO_TRANSPORT_JOIN_H

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

int8_t _z_send_join(_z_transport_t *zt);

#endif /* ZENOH_PICO_TRANSPORT_JOIN_H */
23 changes: 23 additions & 0 deletions include/zenoh-pico/transport/common/lease.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_LEASE_H
#define ZENOH_PICO_TRANSPORT_LEASE_H

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

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 */
23 changes: 23 additions & 0 deletions include/zenoh-pico/transport/common/read.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_READ_H
#define ZENOH_PICO_TRANSPORT_READ_H

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

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

#endif /* ZENOH_PICO_TRANSPORT_READ_H */
24 changes: 24 additions & 0 deletions include/zenoh-pico/transport/common/rx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_RX_H
#define ZENOH_PICO_TRANSPORT_RX_H

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

/*------------------ Transmission and Reception helpers ------------------*/
int8_t _z_link_recv_t_msg(_z_transport_message_t *t_msg, const _z_link_t *zl);

#endif /* ZENOH_PICO_TRANSPORT_RX_H */
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_LINK_TX_H
#define ZENOH_PICO_TRANSPORT_LINK_TX_H
#ifndef ZENOH_PICO_TRANSPORT_TX_H
#define ZENOH_PICO_TRANSPORT_TX_H

#include "zenoh-pico/link/link.h"
#include "zenoh-pico/net/session.h"
Expand All @@ -26,20 +26,7 @@ void __unsafe_z_finalize_wbuf(_z_wbuf_t *buf, _Bool is_streamed);
int8_t __unsafe_z_serialize_zenoh_fragment(_z_wbuf_t *dst, _z_wbuf_t *src, z_reliability_t reliability, size_t sn);

/*------------------ Transmission and Reception helpers ------------------*/
int8_t _z_unicast_send_z_msg(_z_session_t *zn, _z_zenoh_message_t *z_msg, z_reliability_t reliability,
z_congestion_control_t cong_ctrl);
int8_t _z_multicast_send_z_msg(_z_session_t *zn, _z_zenoh_message_t *z_msg, z_reliability_t reliability,
z_congestion_control_t cong_ctrl);

int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *z_msg, z_reliability_t reliability,
z_congestion_control_t cong_ctrl);
int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *z_msg, z_reliability_t reliability,
z_congestion_control_t cong_ctrl);

int8_t _z_send_t_msg(_z_transport_t *zt, const _z_transport_message_t *t_msg);
int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_message_t *t_msg);
int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_message_t *t_msg);

int8_t _z_link_send_t_msg(const _z_link_t *zl, const _z_transport_message_t *t_msg);

#endif /* ZENOH_PICO_TRANSPORT_LINK_TX_H */
#endif /* ZENOH_PICO_TRANSPORT_TX_H */
25 changes: 25 additions & 0 deletions include/zenoh-pico/transport/multicast.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_MULTICAST_H
#define ZENOH_PICO_MULTICAST_H

#include "zenoh-pico/api/types.h"

bool _zp_is_multicast_here(void);
jean-roland marked this conversation as resolved.
Show resolved Hide resolved

void _zp_multicast_fetch_zid(const _z_transport_t *zt, z_owned_closure_zid_t *callback);
void _zp_multicast_info_session(const _z_transport_t *zt, _z_config_t *ps);

#endif /* ZENOH_PICO_MULTICAST_H */
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_LINK_TASK_JOIN_H
#define ZENOH_PICO_TRANSPORT_LINK_TASK_JOIN_H
#ifndef ZENOH_MULTICAST_JOIN_H
#define ZENOH_MULTICAST_JOIN_H

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

int8_t _z_send_join(_z_transport_t *zt);
int8_t _zp_multicast_send_join(_z_transport_multicast_t *ztm);

#endif /* ZENOH_PICO_TRANSPORT_LINK_TASK_JOIN_H */
#endif /* ZENOH_MULTICAST_JOIN_H */
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_LINK_TASK_LEASE_H
#define ZENOH_PICO_TRANSPORT_LINK_TASK_LEASE_H
#ifndef ZENOH_PICO_MULTICAST_LEASE_H
#define ZENOH_PICO_MULTICAST_LEASE_H

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

int8_t _z_send_keep_alive(_z_transport_t *zt);
int8_t _zp_unicast_send_keep_alive(_z_transport_unicast_t *ztu);
int8_t _zp_multicast_send_keep_alive(_z_transport_multicast_t *ztm);

void *_zp_lease_task(void *zt_arg); // The argument is void* to avoid incompatible pointer types in tasks
void *_zp_unicast_lease_task(void *ztu_arg); // The argument is void* to avoid incompatible pointer types in tasks
int _zp_multicast_start_lease_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task);
jean-roland marked this conversation as resolved.
Show resolved Hide resolved
int _zp_multicast_stop_lease_task(_z_transport_t *zt);
jean-roland marked this conversation as resolved.
Show resolved Hide resolved
void *_zp_multicast_lease_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks

#endif /* ZENOH_PICO_TRANSPORT_LINK_TASK_LEASE_H */
#endif /* ZENOH_PICO_MULTICAST_LEASE_H */
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_LINK_TASK_READ_H
#define ZENOH_PICO_TRANSPORT_LINK_TASK_READ_H
#ifndef ZENOH_PICO_MULTICAST_READ_H
#define ZENOH_PICO_MULTICAST_READ_H

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

int8_t _z_read(_z_transport_t *zt);
int8_t _zp_unicast_read(_z_transport_unicast_t *ztu);
int8_t _zp_multicast_read(_z_transport_multicast_t *ztm);

void *_zp_read_task(void *zt_arg); // The argument is void* to avoid incompatible pointer types in tasks
void *_zp_unicast_read_task(void *ztu_arg); // The argument is void* to avoid incompatible pointer types in tasks
int _zp_multicast_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task);
jean-roland marked this conversation as resolved.
Show resolved Hide resolved
int _zp_multicast_stop_read_task(_z_transport_t *zt);
jean-roland marked this conversation as resolved.
Show resolved Hide resolved
void *_zp_multicast_read_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks

#endif /* ZENOH_PICO_TRANSPORT_LINK_TASK_READ_H */
#endif /* ZENOH_PICO_TRANSPORT_LINK_TASK_READ_H */
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,14 @@
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_TRANSPORT_LINK_RX_H
#define ZENOH_PICO_TRANSPORT_LINK_RX_H
#ifndef ZENOH_PICO_MULTICAST_RX_H
#define ZENOH_PICO_MULTICAST_RX_H

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

/*------------------ Transmission and Reception helpers ------------------*/
int8_t _z_unicast_recv_t_msg(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg);
int8_t _z_multicast_recv_t_msg(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr);

int8_t _z_link_recv_t_msg(_z_transport_message_t *t_msg, const _z_link_t *zl);

int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg);
int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr);

int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg);
int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg,
_z_bytes_t *addr);

#endif /* ZENOH_PICO_TRANSPORT_LINK_RX_H */
#endif /* ZENOH_PICO_TRANSPORT_LINK_RX_H */
29 changes: 29 additions & 0 deletions include/zenoh-pico/transport/multicast/transport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_MULTICAST_TRANSPORT_H
#define ZENOH_PICO_MULTICAST_TRANSPORT_H

#include "zenoh-pico/api/types.h"

int8_t _z_multicast_transport_create(_z_transport_t *zt, _z_link_t *zl,
_z_transport_multicast_establish_param_t *param);
int8_t _z_multicast_open_peer(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl,
const _z_id_t *local_zid);
int8_t _z_multicast_open_client(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl,
const _z_id_t *local_zid);
int8_t _z_multicast_send_close(_z_transport_multicast_t *ztm, uint8_t reason, _Bool link_only);
int8_t _z_multicast_transport_close(_z_transport_multicast_t *ztm, uint8_t reason);
void _z_multicast_transport_clear(_z_transport_t *zt);
#endif /* ZENOH_PICO_MULTICAST_TRANSPORT_H */
27 changes: 27 additions & 0 deletions include/zenoh-pico/transport/multicast/tx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_MULTICAST_TX_H
#define ZENOH_PICO_MULTICAST_TX_H

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

int8_t _z_multicast_send_z_msg(_z_session_t *zn, _z_zenoh_message_t *z_msg, z_reliability_t reliability,
z_congestion_control_t cong_ctrl);
int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *z_msg, z_reliability_t reliability,
z_congestion_control_t cong_ctrl);
int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_message_t *t_msg);

#endif /* ZENOH_PICO_MULTICAST_TX_H */
20 changes: 0 additions & 20 deletions include/zenoh-pico/transport/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,8 @@ typedef struct {
uint8_t _seq_num_res;
} _z_transport_multicast_establish_param_t;

int8_t _z_transport_unicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_unicast_establish_param_t *param);
int8_t _z_transport_multicast(_z_transport_t *zt, _z_link_t *zl, _z_transport_multicast_establish_param_t *param);

int8_t _z_transport_unicast_open_client(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl,
const _z_id_t *local_zid);
int8_t _z_transport_multicast_open_client(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl,
const _z_id_t *local_zid);
int8_t _z_transport_unicast_open_peer(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl,
const _z_id_t *local_zid);
int8_t _z_transport_multicast_open_peer(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl,
const _z_id_t *local_zid);

int8_t _z_transport_close(_z_transport_t *zt, uint8_t reason);
int8_t _z_transport_unicast_close(_z_transport_unicast_t *ztu, uint8_t reason);
int8_t _z_transport_multicast_close(_z_transport_multicast_t *ztm, uint8_t reason);

void _z_transport_unicast_clear(_z_transport_unicast_t *ztu);
void _z_transport_multicast_clear(_z_transport_multicast_t *ztm);

void _z_transport_clear(_z_transport_t *zt);
void _z_transport_free(_z_transport_t **zt);
void _z_transport_unicast_free(_z_transport_unicast_t **ztu);
void _z_transport_multicast_free(_z_transport_multicast_t **ztm);

#endif /* INCLUDE_ZENOH_PICO_TRANSPORT_TRANSPORT_H */
24 changes: 24 additions & 0 deletions include/zenoh-pico/transport/unicast.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//

#ifndef ZENOH_PICO_UNICAST_H
#define ZENOH_PICO_UNICAST_H

#include "zenoh-pico/api/types.h"

bool _zp_is_unicast_here(void);
jean-roland marked this conversation as resolved.
Show resolved Hide resolved
void _zp_unicast_fetch_zid(const _z_transport_t *zt, z_owned_closure_zid_t *callback);
void _zp_unicast_info_session(const _z_transport_t *zt, _z_config_t *ps);

#endif /* ZENOH_PICO_UNICAST_H */
Loading
Loading