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

Add support for raweth locator #303

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

jean-roland
Copy link
Contributor

For ease of use, we can now specify in the locator, the source mac address and the interface a raweth socket will use to communicate.

E.g: reth/01:02:03:04:05:06#iface=eth0

If any of this information is invalid or missing, e.g: reth/0, the socket will fall back to the values defined in zenoh-pico/src/transport/raweth/config.c.

In addition, initially a put of a keyexpr not specified in the config mapping would be dropped, now it's sent to the default config address (first entry) with a log.

memcpy(&self->_socket._raweth._smac, addr, _ZP_MAC_ADDR_LENGTH);
z_free(addr);
} else {
memcpy(&self->_socket._raweth._smac, _ZP_RAWETH_CFG_SMAC, _ZP_MAC_ADDR_LENGTH);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule
@@ -161,4 +205,19 @@
_ZP_UNUSED(endpoint);
return _Z_ERR_TRANSPORT_NOT_AVAILABLE;
}

size_t _z_raweth_config_strlen(const _z_str_intmap_t *s) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
return NULL;
}

int8_t _z_raweth_config_from_str(_z_str_intmap_t *strint, const char *s) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
return _z_str_intmap_to_str(s, RAWETH_CONFIG_ARGC, args);
}

int8_t _z_raweth_config_from_str(_z_str_intmap_t *strint, const char *s) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
_ZP_UNUSED(s);
return 0;
}
char *_z_raweth_config_to_str(const _z_str_intmap_t *s) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
memcpy(&self->_socket._raweth._smac, _ZP_RAWETH_CFG_SMAC, _ZP_MAC_ADDR_LENGTH);
if (_z_valid_address_raweth(self->_endpoint._locator._address)) {
uint8_t *addr = _z_parse_address_raweth(self->_endpoint._locator._address);
memcpy(&self->_socket._raweth._smac, addr, _ZP_MAC_ADDR_LENGTH);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule
_Z_DEBUG("Key '%s' wasn't found in config mapping, sending to default address\n", keyexpr->_suffix);
}
// Store data into socket
memcpy(&sock->_dmac, &_ZP_RAWETH_CFG_ARRAY[idx]._dmac, _ZP_MAC_ADDR_LENGTH);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule
uint16_t vlan = _ZP_RAWETH_CFG_ARRAY[idx]._vlan;
sock->_has_vlan = _ZP_RAWETH_CFG_ARRAY[idx]._has_vlan;
if (sock->_has_vlan) {
memcpy(&sock->_vlan, &vlan, sizeof(vlan));

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule
_Z_RES_OK) {
continue;
}
return i;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
memcpy(&sock->_dmac, &_ZP_RAWETH_CFG_ARRAY[idx]._dmac, _ZP_MAC_ADDR_LENGTH);
uint16_t vlan = _ZP_RAWETH_CFG_ARRAY[idx]._vlan;
sock->_has_vlan = _ZP_RAWETH_CFG_ARRAY[idx]._has_vlan;
if (sock->_has_vlan) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
@Mallets Mallets merged commit 103d716 into eclipse-zenoh:master Dec 20, 2023
46 checks passed
@jean-roland jean-roland deleted the ft_raweth_locator branch December 21, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants