From 26d3466f50306edaeeba1b466d1e0ba926d28774 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 11 Apr 2017 08:49:15 +0200 Subject: [PATCH] Add macro ETH_ADDR() to initialize a struct eth_addr with its 6 bytes and taking care of correct braces --- src/include/lwip/prot/ethernet.h | 4 ++++ src/include/netif/bridgeif.h | 2 +- src/netif/bridgeif.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/include/lwip/prot/ethernet.h b/src/include/lwip/prot/ethernet.h index b7a967f0..9f56ba26 100644 --- a/src/include/lwip/prot/ethernet.h +++ b/src/include/lwip/prot/ethernet.h @@ -55,6 +55,7 @@ extern "C" { # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN +/** An Ethernet MAC address */ struct eth_addr { PACK_STRUCT_FLD_8(u8_t addr[ETH_HWADDR_LEN]); } PACK_STRUCT_STRUCT; @@ -63,6 +64,9 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif +/** Initialize a struct eth_addr with its 6 bytes (takes care of correct braces) */ +#define ETH_ADDR(b0, b1, b2, b3, b4, b5) {{b0, b1, b2, b3, b4, b5}} + #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif diff --git a/src/include/netif/bridgeif.h b/src/include/netif/bridgeif.h index 6ddff40e..01448e4d 100644 --- a/src/include/netif/bridgeif.h +++ b/src/include/netif/bridgeif.h @@ -78,7 +78,7 @@ typedef struct bridgeif_initdata_s { /** @ingroup bridgeif * Use this for constant initialization of a bridgeif_initdat_t - * (ethaddr must be passed as MAKE_ETH_ADDR()) + * (ethaddr must be passed as ETH_ADDR()) */ #define BRIDGEIF_INITDATA1(max_ports, max_fdb_dynamic_entries, max_fdb_static_entries, ethaddr) {ethaddr, max_ports, max_fdb_dynamic_entries, max_fdb_static_entries} /** @ingroup bridgeif diff --git a/src/netif/bridgeif.c b/src/netif/bridgeif.c index a0189883..d677d701 100644 --- a/src/netif/bridgeif.c +++ b/src/netif/bridgeif.c @@ -54,7 +54,7 @@ * - some configuration options controlling the memory consumption (maximum number of ports * and FDB entries) * - e.g. for a bridge MAC address 00-01-02-03-04-05, 2 bridge ports, 1024 FDB entries + 16 static MAC entries: - * bridgeif_initdata_t mybridge_initdata = BRIDGEIF_INITDATA1(2, 1024, 16, MAKE_ETH_ADDR(0, 1, 2, 3, 4, 5)); + * bridgeif_initdata_t mybridge_initdata = BRIDGEIF_INITDATA1(2, 1024, 16, ETH_ADDR(0, 1, 2, 3, 4, 5)); * - add the bridge netif (with IPv4 config): * struct netif bridge_netif; * netif_add(&bridge_netif, &my_ip, &my_netmask, &my_gw, &mybridge_initdata, bridgeif_init, tcpip_input);