Add macro ETH_ADDR() to initialize a struct eth_addr with its 6 bytes and taking care of correct braces

This commit is contained in:
goldsimon 2017-04-11 08:49:15 +02:00
parent 8695e6e6cb
commit 26d3466f50
3 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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);