1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/openwsn: add OPENWSN_NETIF_ID

This commit is contained in:
Francisco Molina 2020-12-03 09:40:57 +01:00
parent 32058e9ad9
commit e64c91190a
No known key found for this signature in database
GPG Key ID: 3E94EAC3DBDEEDA8
2 changed files with 14 additions and 5 deletions

View File

@ -33,6 +33,15 @@ extern "C" {
#define OPENWSN_PANID (0xCAFE)
#endif
/**
* @brief Default NID for OpenWSN network
*
* @note Only one netif is currently possible in OpenWSN.
*/
#ifndef CONFIG_OPENWSN_NETIF_ID
#define CONFIG_OPENWSN_NETIF_ID (0x0001)
#endif
/**
* @brief Initializes OpenWSN thread
*

View File

@ -145,12 +145,12 @@ int sock_udp_create(sock_udp_t *sock, const sock_udp_ep_t *local,
/* if set netifs should match the only one available in OpenWSN*/
if ((local != NULL) &&
(local->netif != SOCK_ADDR_ANY_NETIF) &&
(local->netif != openwsn_get_netif())) {
(local->netif != CONFIG_OPENWSN_NETIF_ID)) {
return -EINVAL;
}
if ((remote != NULL) &&
(remote->netif != SOCK_ADDR_ANY_NETIF) &&
(remote->netif != openwsn_get_netif())) {
(remote->netif != CONFIG_OPENWSN_NETIF_ID)) {
return -EINVAL;
}
@ -243,9 +243,9 @@ ssize_t sock_udp_send_aux(sock_udp_t *sock, const void *data, size_t len,
/* if set netifs should match the only one available in OpenWSN*/
if ((sock != NULL) &&
(((sock->gen_sock.local.netif != SOCK_ADDR_ANY_NETIF) &&
(sock->gen_sock.local.netif != openwsn_get_netif())) ||
(sock->gen_sock.local.netif != CONFIG_OPENWSN_NETIF_ID)) ||
((remote->netif != SOCK_ADDR_ANY_NETIF) &&
(remote->netif != openwsn_get_netif())))) {
(remote->netif != CONFIG_OPENWSN_NETIF_ID)))) {
return -EINVAL;
}
dst_addr.type = ADDR_128B;
@ -442,7 +442,7 @@ ssize_t sock_udp_recv_buf_aux(sock_udp_t *sock, void **data, void **buf_ctx,
/* copy source port and address to end point */
ep.family = AF_INET6;
ep.port = pkt->l4_sourcePortORicmpv6Type;
ep.netif = openwsn_get_netif();
ep.netif = CONFIG_OPENWSN_NETIF_ID;
memcpy(&ep.addr, pkt->l3_sourceAdd.addr_128b, LENGTH_ADDR128b);
if (remote != NULL) {