-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from jean-roland/ft_raweth_transport
Add raweth transport (implementation)
- Loading branch information
Showing
33 changed files
with
1,699 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// 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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_LINK_CONFIG_RAWETH_H | ||
#define ZENOH_PICO_LINK_CONFIG_RAWETH_H | ||
|
||
#include "zenoh-pico/collections/intmap.h" | ||
#include "zenoh-pico/collections/string.h" | ||
#include "zenoh-pico/config.h" | ||
#include "zenoh-pico/link/link.h" | ||
|
||
#if Z_FEATURE_RAWETH_TRANSPORT == 1 | ||
|
||
#define RAWETH_SCHEMA "reth" | ||
|
||
int8_t _z_endpoint_raweth_valid(_z_endpoint_t *endpoint); | ||
|
||
int8_t _z_new_link_raweth(_z_link_t *zl, _z_endpoint_t endpoint); | ||
|
||
#endif /* Z_FEATURE_RAWETH_TRANSPORT */ | ||
#endif /* ZENOH_PICO_LINK_CONFIG_RAWETH_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// 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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_SYSTEM_LINK_RAWETH_H | ||
#define ZENOH_PICO_SYSTEM_LINK_RAWETH_H | ||
|
||
#include <stdint.h> | ||
|
||
#include "zenoh-pico/collections/string.h" | ||
#include "zenoh-pico/system/platform.h" | ||
|
||
#if Z_FEATURE_RAWETH_TRANSPORT == 1 | ||
|
||
// Ethernet types (big endian) | ||
#define _ZP_ETH_TYPE_VLAN 0x0081 | ||
|
||
// Address Sizes | ||
#define _ZP_MAC_ADDR_LENGTH 6 | ||
|
||
// Max frame size | ||
#define _ZP_MAX_ETH_FRAME_SIZE 1500 | ||
|
||
// Ethernet header structure type | ||
typedef struct { | ||
uint8_t dmac[_ZP_MAC_ADDR_LENGTH]; // Destination mac address | ||
uint8_t smac[_ZP_MAC_ADDR_LENGTH]; // Source mac address | ||
uint16_t ethtype; // Ethertype of frame | ||
} _zp_eth_header_t; | ||
|
||
typedef struct { | ||
uint8_t dmac[_ZP_MAC_ADDR_LENGTH]; // Destination mac address | ||
uint8_t smac[_ZP_MAC_ADDR_LENGTH]; // Source mac address | ||
uint16_t vlan_type; // Vlan ethtype | ||
uint16_t tag; // Vlan tag | ||
uint16_t ethtype; // Ethertype of frame | ||
} _zp_eth_vlan_header_t; | ||
|
||
typedef struct { | ||
const char *_interface; | ||
_z_sys_net_socket_t _sock; | ||
uint16_t _vlan; | ||
uint16_t ethtype; | ||
uint8_t _dmac[_ZP_MAC_ADDR_LENGTH]; | ||
uint8_t _smac[_ZP_MAC_ADDR_LENGTH]; | ||
_Bool _has_vlan; | ||
} _z_raweth_socket_t; | ||
|
||
int8_t _z_get_smac_raweth(_z_raweth_socket_t *resock); | ||
int8_t _z_open_raweth(_z_sys_net_socket_t *sock, const char *interface); | ||
size_t _z_send_raweth(const _z_sys_net_socket_t *sock, const void *buff, size_t buff_len); | ||
size_t _z_receive_raweth(const _z_sys_net_socket_t *sock, void *buff, size_t buff_len, _z_bytes_t *addr); | ||
int8_t _z_close_raweth(_z_sys_net_socket_t *sock); | ||
|
||
#endif | ||
|
||
#endif /* ZENOH_PICO_SYSTEM_LINK_RAWETH_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// 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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_RAWETH_CONFIG_H | ||
#define ZENOH_PICO_RAWETH_CONFIG_H | ||
|
||
#include <stdbool.h> | ||
|
||
#include "zenoh-pico/protocol/core.h" | ||
#include "zenoh-pico/system/link/raweth.h" | ||
#include "zenoh-pico/transport/transport.h" | ||
#include "zenoh-pico/utils/result.h" | ||
|
||
#if Z_FEATURE_RAWETH_TRANSPORT == 1 | ||
|
||
typedef struct { | ||
_z_keyexpr_t _keyexpr; | ||
uint16_t _vlan; // vlan tag (pcp + dei + id), big endian | ||
uint8_t _dmac[_ZP_MAC_ADDR_LENGTH]; | ||
_Bool _has_vlan; | ||
} _zp_raweth_cfg_entry; | ||
|
||
typedef struct { | ||
uint8_t _mac[_ZP_MAC_ADDR_LENGTH]; | ||
} _zp_raweth_cfg_whitelist_val; | ||
|
||
// Ethertype to use in frame | ||
extern const uint16_t _ZP_RAWETH_CFG_ETHTYPE; | ||
|
||
// Interface to use | ||
extern const char *_ZP_RAWETH_CFG_INTERFACE; | ||
|
||
// Source mac address | ||
extern const uint8_t _ZP_RAWETH_CFG_SMAC[_ZP_MAC_ADDR_LENGTH]; | ||
|
||
// Main config array | ||
extern const _zp_raweth_cfg_entry _ZP_RAWETH_CFG_ARRAY[]; | ||
|
||
// Mac address rx whitelist array | ||
extern const _zp_raweth_cfg_whitelist_val _ZP_RAWETH_CFG_WHITELIST[]; | ||
|
||
// Array size | ||
extern const size_t _ZP_RAWETH_CFG_SIZE; | ||
extern const size_t _ZP_RAWETH_CFG_WHITELIST_SIZE; | ||
|
||
#endif // Z_FEATURE_RAWETH_TRANSPORT == 1 | ||
#endif // ZENOH_PICO_RAWETH_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_RAWETH_JOIN_H | ||
#define ZENOH_RAWETH_JOIN_H | ||
|
||
#include "zenoh-pico/transport/transport.h" | ||
|
||
int8_t _zp_raweth_send_join(_z_transport_multicast_t *ztm); | ||
|
||
#endif /* ZENOH_RAWETH_JOIN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_RAWETH_LEASE_H | ||
#define ZENOH_PICO_RAWETH_LEASE_H | ||
|
||
#include "zenoh-pico/transport/transport.h" | ||
|
||
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); | ||
void *_zp_raweth_lease_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks | ||
|
||
#endif /* ZENOH_PICO_RAWETH_LEASE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_RAWETH_READ_H | ||
#define ZENOH_PICO_RAWETH_READ_H | ||
|
||
#include "zenoh-pico/transport/transport.h" | ||
|
||
int8_t _zp_raweth_read(_z_transport_multicast_t *ztm); | ||
int8_t _zp_raweth_start_read_task(_z_transport_t *zt, _z_task_attr_t *attr, _z_task_t *task); | ||
int8_t _zp_raweth_stop_read_task(_z_transport_t *zt); | ||
void *_zp_raweth_read_task(void *ztm_arg); // The argument is void* to avoid incompatible pointer types in tasks | ||
|
||
#endif /* ZENOH_PICO_RAWETH_READ_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_RAWETH_RX_H | ||
#define ZENOH_PICO_RAWETH_RX_H | ||
|
||
#include "zenoh-pico/transport/transport.h" | ||
|
||
int8_t _z_raweth_recv_t_msg(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr); | ||
int8_t _z_raweth_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr); | ||
|
||
#endif /* ZENOH_PICO_RAWETH_RX_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// 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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_RAWETH_TRANSPORT_H | ||
#define ZENOH_PICO_RAWETH_TRANSPORT_H | ||
|
||
#include "zenoh-pico/api/types.h" | ||
|
||
int8_t _z_raweth_transport_create(_z_transport_t *zt, _z_link_t *zl, _z_transport_multicast_establish_param_t *param); | ||
int8_t _z_raweth_open_peer(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl, | ||
const _z_id_t *local_zid); | ||
int8_t _z_raweth_open_client(_z_transport_multicast_establish_param_t *param, const _z_link_t *zl, | ||
const _z_id_t *local_zid); | ||
int8_t _z_raweth_send_close(_z_transport_multicast_t *ztm, uint8_t reason, _Bool link_only); | ||
int8_t _z_raweth_transport_close(_z_transport_multicast_t *ztm, uint8_t reason); | ||
void _z_raweth_transport_clear(_z_transport_t *zt); | ||
#endif /* ZENOH_PICO_RAWETH_TRANSPORT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// 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, <[email protected]> | ||
// | ||
|
||
#ifndef ZENOH_PICO_RAWETH_TX_H | ||
#define ZENOH_PICO_RAWETH_TX_H | ||
|
||
#include "zenoh-pico/net/session.h" | ||
#include "zenoh-pico/transport/transport.h" | ||
|
||
int8_t _z_raweth_link_send_t_msg(const _z_link_t *zl, const _z_transport_message_t *t_msg); | ||
int8_t _z_raweth_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_raweth_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_message_t *t_msg); | ||
|
||
#endif /* ZENOH_PICO_RAWETH_TX_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.