sys/net: replace netif_addr_to/from_str with l2util_addr…
This commit is contained in:
parent
5d6754e7a9
commit
dbf6b1e25c
@ -99,5 +99,9 @@ ifneq (,$(filter openwsn_debugpins,$(USEMODULE)))
|
|||||||
FEATURES_REQUIRED += periph_gpio_irq
|
FEATURES_REQUIRED += periph_gpio_irq
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter shell_commands,$(USEMODULE)))
|
||||||
|
USEMODULE += l2util
|
||||||
|
endif
|
||||||
|
|
||||||
# This port currently requires setting ISR_STACKSIZE
|
# This port currently requires setting ISR_STACKSIZE
|
||||||
FEATURES_BLACKLIST += arch_esp32 arch_esp8266 arch_riscv arch_avr8
|
FEATURES_BLACKLIST += arch_esp32 arch_esp8266 arch_riscv arch_avr8
|
||||||
|
|||||||
@ -62,6 +62,7 @@
|
|||||||
#if IS_USED(MODULE_GNRC_NETIF_PKTQ)
|
#if IS_USED(MODULE_GNRC_NETIF_PKTQ)
|
||||||
#include "net/gnrc/netif/pktq/type.h"
|
#include "net/gnrc/netif/pktq/type.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "net/l2util.h"
|
||||||
#include "net/ndp.h"
|
#include "net/ndp.h"
|
||||||
#include "net/netdev.h"
|
#include "net/netdev.h"
|
||||||
#include "net/netopt.h"
|
#include "net/netopt.h"
|
||||||
@ -568,7 +569,7 @@ int gnrc_netif_set_from_netdev(gnrc_netif_t *netif,
|
|||||||
/**
|
/**
|
||||||
* @brief Converts a hardware address to a human readable string.
|
* @brief Converts a hardware address to a human readable string.
|
||||||
*
|
*
|
||||||
* @note Compatibility wrapper for @see netif_addr_to_str
|
* @note Compatibility wrapper for @see l2util_addr_to_str
|
||||||
*
|
*
|
||||||
* @details The format will be like `xx:xx:xx:xx` where `xx` are the bytes
|
* @details The format will be like `xx:xx:xx:xx` where `xx` are the bytes
|
||||||
* of @p addr in hexadecimal representation.
|
* of @p addr in hexadecimal representation.
|
||||||
@ -585,14 +586,14 @@ int gnrc_netif_set_from_netdev(gnrc_netif_t *netif,
|
|||||||
*/
|
*/
|
||||||
static inline char *gnrc_netif_addr_to_str(const uint8_t *addr, size_t addr_len, char *out)
|
static inline char *gnrc_netif_addr_to_str(const uint8_t *addr, size_t addr_len, char *out)
|
||||||
{
|
{
|
||||||
return netif_addr_to_str(addr, addr_len, out);
|
return l2util_addr_to_str(addr, addr_len, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses a string of colon-separated hexadecimals to a hardware
|
* @brief Parses a string of colon-separated hexadecimals to a hardware
|
||||||
* address.
|
* address.
|
||||||
*
|
*
|
||||||
* @note Compatibility wrapper for @see netif_addr_from_str
|
* @note Compatibility wrapper for @see l2util_addr_from_str
|
||||||
*
|
*
|
||||||
* @details The input format must be like `xx:xx:xx:xx` where `xx` will be the
|
* @details The input format must be like `xx:xx:xx:xx` where `xx` will be the
|
||||||
* bytes of @p addr in hexadecimal representation.
|
* bytes of @p addr in hexadecimal representation.
|
||||||
@ -610,7 +611,7 @@ static inline char *gnrc_netif_addr_to_str(const uint8_t *addr, size_t addr_len,
|
|||||||
*/
|
*/
|
||||||
static inline size_t gnrc_netif_addr_from_str(const char *str, uint8_t *out)
|
static inline size_t gnrc_netif_addr_from_str(const char *str, uint8_t *out)
|
||||||
{
|
{
|
||||||
return netif_addr_from_str(str, out);
|
return l2util_addr_from_str(str, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "net/ieee802154.h"
|
#include "net/ieee802154.h"
|
||||||
#include "net/ipv6/addr.h"
|
#include "net/ipv6/addr.h"
|
||||||
|
#include "net/l2util.h"
|
||||||
#include "net/netif.h"
|
#include "net/netif.h"
|
||||||
|
|
||||||
#include "openwsn.h"
|
#include "openwsn.h"
|
||||||
@ -107,17 +108,17 @@ int _openwsn_ifconfig(char *arg)
|
|||||||
|
|
||||||
addr = idmanager_getMyID(ADDR_16B);
|
addr = idmanager_getMyID(ADDR_16B);
|
||||||
printf("\tHWaddr: %s ",
|
printf("\tHWaddr: %s ",
|
||||||
netif_addr_to_str(addr->addr_16b, sizeof(addr->addr_16b),
|
l2util_addr_to_str(addr->addr_16b, sizeof(addr->addr_16b),
|
||||||
addr_str));
|
addr_str));
|
||||||
|
|
||||||
addr = idmanager_getMyID(ADDR_PANID);
|
addr = idmanager_getMyID(ADDR_PANID);
|
||||||
printf("NID: %s\n\n",
|
printf("NID: %s\n\n",
|
||||||
netif_addr_to_str(addr->panid, sizeof(addr->panid),
|
l2util_addr_to_str(addr->panid, sizeof(addr->panid),
|
||||||
addr_str));
|
addr_str));
|
||||||
|
|
||||||
addr = idmanager_getMyID(ADDR_64B);
|
addr = idmanager_getMyID(ADDR_64B);
|
||||||
printf("\t\tLong HWaddr: %s\n",
|
printf("\t\tLong HWaddr: %s\n",
|
||||||
netif_addr_to_str(addr->addr_64b, sizeof(addr->addr_64b),
|
l2util_addr_to_str(addr->addr_64b, sizeof(addr->addr_64b),
|
||||||
addr_str));
|
addr_str));
|
||||||
|
|
||||||
if (IS_USED(MODULE_OPENWSN_IPV6)) {
|
if (IS_USED(MODULE_OPENWSN_IPV6)) {
|
||||||
@ -155,7 +156,7 @@ int _openwsn_ifconfig(char *arg)
|
|||||||
else {
|
else {
|
||||||
icmpv6rpl_getPreferredParentEui64(&neighbor);
|
icmpv6rpl_getPreferredParentEui64(&neighbor);
|
||||||
printf("\t\tRPL parent: %s\n",
|
printf("\t\tRPL parent: %s\n",
|
||||||
netif_addr_to_str(neighbor.addr_64b,
|
l2util_addr_to_str(neighbor.addr_64b,
|
||||||
sizeof(neighbor.addr_64b),
|
sizeof(neighbor.addr_64b),
|
||||||
addr_str));
|
addr_str));
|
||||||
}
|
}
|
||||||
@ -164,7 +165,7 @@ int _openwsn_ifconfig(char *arg)
|
|||||||
if (neighbors_isNeighborWithHigherDAGrank(i)) {
|
if (neighbors_isNeighborWithHigherDAGrank(i)) {
|
||||||
neighbors_getNeighborEui64(&neighbor, ADDR_64B, i);
|
neighbors_getNeighborEui64(&neighbor, ADDR_64B, i);
|
||||||
printf("\t\t\t%s\n",
|
printf("\t\t\t%s\n",
|
||||||
netif_addr_to_str(neighbor.addr_64b,
|
l2util_addr_to_str(neighbor.addr_64b,
|
||||||
sizeof(neighbor.addr_64b),
|
sizeof(neighbor.addr_64b),
|
||||||
addr_str));
|
addr_str));
|
||||||
}
|
}
|
||||||
@ -192,7 +193,7 @@ static int _neighbors_cmd(char *arg)
|
|||||||
|
|
||||||
for (int i = 0; i < MAXNUMNEIGHBORS; i++) {
|
for (int i = 0; i < MAXNUMNEIGHBORS; i++) {
|
||||||
neighbors_getNeighborEui64(&neighbor, ADDR_64B, i);
|
neighbors_getNeighborEui64(&neighbor, ADDR_64B, i);
|
||||||
netif_addr_to_str(neighbor.addr_64b, sizeof(neighbor.addr_64b),
|
l2util_addr_to_str(neighbor.addr_64b, sizeof(neighbor.addr_64b),
|
||||||
hwaddr_str);
|
hwaddr_str);
|
||||||
if (memcmp(hwaddr_str, "00:00:00:00:00:00:00:00",
|
if (memcmp(hwaddr_str, "00:00:00:00:00:00:00:00",
|
||||||
IEEE802154_LONG_ADDRESS_LEN_STR_MAX)) {
|
IEEE802154_LONG_ADDRESS_LEN_STR_MAX)) {
|
||||||
@ -224,7 +225,7 @@ static int _cell_list_cmd(char *arg)
|
|||||||
switch (schedule_vars.scheduleBuf[i].type) {
|
switch (schedule_vars.scheduleBuf[i].type) {
|
||||||
case CELLTYPE_TX:
|
case CELLTYPE_TX:
|
||||||
printf("neigh: %s, slot: %03i, chan: %02i, type: TX\n",
|
printf("neigh: %s, slot: %03i, chan: %02i, type: TX\n",
|
||||||
netif_addr_to_str(
|
l2util_addr_to_str(
|
||||||
schedule_vars.scheduleBuf[i].neighbor.addr_64b,
|
schedule_vars.scheduleBuf[i].neighbor.addr_64b,
|
||||||
IEEE802154_LONG_ADDRESS_LEN, hwaddr_str),
|
IEEE802154_LONG_ADDRESS_LEN, hwaddr_str),
|
||||||
schedule_vars.scheduleBuf[i].slotOffset,
|
schedule_vars.scheduleBuf[i].slotOffset,
|
||||||
@ -237,7 +238,7 @@ static int _cell_list_cmd(char *arg)
|
|||||||
break;
|
break;
|
||||||
case CELLTYPE_TXRX:
|
case CELLTYPE_TXRX:
|
||||||
printf("neigh: %s, slot: %03i, chan: %02i, type: RXTX\n",
|
printf("neigh: %s, slot: %03i, chan: %02i, type: RXTX\n",
|
||||||
netif_addr_to_str(
|
l2util_addr_to_str(
|
||||||
schedule_vars.scheduleBuf[i].neighbor.addr_64b,
|
schedule_vars.scheduleBuf[i].neighbor.addr_64b,
|
||||||
IEEE802154_LONG_ADDRESS_LEN, hwaddr_str),
|
IEEE802154_LONG_ADDRESS_LEN, hwaddr_str),
|
||||||
schedule_vars.scheduleBuf[i].slotOffset,
|
schedule_vars.scheduleBuf[i].slotOffset,
|
||||||
@ -266,7 +267,7 @@ static int _cell_manage_cmd(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc == 6) {
|
if (argc == 6) {
|
||||||
addr.type = ADDR_64B;
|
addr.type = ADDR_64B;
|
||||||
size_t len = netif_addr_from_str(argv[5], addr.addr_64b);
|
size_t len = l2util_addr_from_str(argv[5], addr.addr_64b);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
puts("Error: invalid address");
|
puts("Error: invalid address");
|
||||||
return -1;
|
return -1;
|
||||||
@ -358,7 +359,7 @@ static int _6top_manage_cmd(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc == 5) {
|
if (argc == 5) {
|
||||||
neigh.type = ADDR_64B;
|
neigh.type = ADDR_64B;
|
||||||
size_t len = netif_addr_from_str(argv[4], neigh.addr_64b);
|
size_t len = l2util_addr_from_str(argv[4], neigh.addr_64b);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
puts("Error: invalid address");
|
puts("Error: invalid address");
|
||||||
return -1;
|
return -1;
|
||||||
@ -445,7 +446,7 @@ static int _6top_cmd(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
neighbor.type = ADDR_64B;
|
neighbor.type = ADDR_64B;
|
||||||
size_t len = netif_addr_from_str(argv[2], neighbor.addr_64b);
|
size_t len = l2util_addr_from_str(argv[2], neighbor.addr_64b);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
puts("Error: invalid address");
|
puts("Error: invalid address");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user