Mistake on this page?
Report an issue in GitHub or email us
bridgeif.h
Go to the documentation of this file.
1 /**
2  * @file
3  * lwIP netif implementing an IEEE 802.1D MAC Bridge
4  */
5 
6 /*
7  * Copyright (c) 2017 Simon Goldschmidt.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  * derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30  * OF SUCH DAMAGE.
31  *
32  * This file is part of the lwIP TCP/IP stack.
33  *
34  * Author: Simon Goldschmidt <goldsimon@gmx.de>
35  *
36  */
37 #ifndef LWIP_HDR_NETIF_BRIDGEIF_H
38 #define LWIP_HDR_NETIF_BRIDGEIF_H
39 
40 #include "netif/bridgeif_opts.h"
41 
42 #include "lwip/err.h"
43 #include "lwip/prot/ethernet.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 struct netif;
50 
51 #if (BRIDGEIF_MAX_PORTS < 0) || (BRIDGEIF_MAX_PORTS >= 64)
52 #error BRIDGEIF_MAX_PORTS must be [1..63]
53 #elif BRIDGEIF_MAX_PORTS < 8
54 typedef u8_t bridgeif_portmask_t;
55 #elif BRIDGEIF_MAX_PORTS < 16
56 typedef u16_t bridgeif_portmask_t;
57 #elif BRIDGEIF_MAX_PORTS < 32
58 typedef u32_t bridgeif_portmask_t;
59 #elif BRIDGEIF_MAX_PORTS < 64
60 typedef u64_t bridgeif_portmask_t;
61 #endif
62 
63 #define BR_FLOOD ((bridgeif_portmask_t)-1)
64 
65 /** @ingroup bridgeif
66  * Initialisation data for @ref bridgeif_init.
67  * An instance of this type must be passed as parameter 'state' to @ref netif_add
68  * when the bridge is added.
69  */
70 typedef struct bridgeif_initdata_s {
71  /** MAC address of the bridge (cannot use the netif's addresses) */
72  struct eth_addr ethaddr;
73  /** Maximum number of ports in the bridge (ports are stored in an array, this
74  influences memory allocated for netif->state of the bridge netif). */
75  u8_t max_ports;
76  /** Maximum number of dynamic/learning entries in the bridge's forwarding database.
77  In the default implementation, this controls memory consumption only. */
79  /** Maximum number of static forwarding entries. Influences memory consumption! */
82 
83 /** @ingroup bridgeif
84  * Use this for constant initialization of a bridgeif_initdat_t
85  * (ethaddr must be passed as ETH_ADDR())
86  */
87 #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}
88 /** @ingroup bridgeif
89  * Use this for constant initialization of a bridgeif_initdat_t
90  * (each byte of ethaddr must be passed)
91  */
92 #define BRIDGEIF_INITDATA2(max_ports, max_fdb_dynamic_entries, max_fdb_static_entries, e0, e1, e2, e3, e4, e5) {{e0, e1, e2, e3, e4, e5}, max_ports, max_fdb_dynamic_entries, max_fdb_static_entries}
93 
94 err_t bridgeif_init(struct netif *netif);
95 err_t bridgeif_add_port(struct netif *bridgeif, struct netif *portif);
96 err_t bridgeif_fdb_add(struct netif *bridgeif, const struct eth_addr *addr, bridgeif_portmask_t ports);
97 err_t bridgeif_fdb_remove(struct netif *bridgeif, const struct eth_addr *addr);
98 
99 /* FDB interface, can be replaced by own implementation */
100 void bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx);
101 bridgeif_portmask_t bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr);
102 void* bridgeif_fdb_init(u16_t max_fdb_entries);
103 
104 #if BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT
105 #ifndef BRIDGEIF_DECL_PROTECT
106 /* define bridgeif protection to sys_arch_protect... */
107 #include "lwip/sys.h"
108 #define BRIDGEIF_DECL_PROTECT(lev) SYS_ARCH_DECL_PROTECT(lev)
109 #define BRIDGEIF_READ_PROTECT(lev) SYS_ARCH_PROTECT(lev)
110 #define BRIDGEIF_READ_UNPROTECT(lev) SYS_ARCH_UNPROTECT(lev)
111 #define BRIDGEIF_WRITE_PROTECT(lev)
112 #define BRIDGEIF_WRITE_UNPROTECT(lev)
113 #endif
114 #else /* BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT */
115 #include "lwip/tcpip.h"
116 #define BRIDGEIF_DECL_PROTECT(lev)
117 #define BRIDGEIF_READ_PROTECT(lev)
118 #define BRIDGEIF_READ_UNPROTECT(lev)
119 #define BRIDGEIF_WRITE_PROTECT(lev)
120 #define BRIDGEIF_WRITE_UNPROTECT(lev)
121 #endif /* BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT */
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif /* LWIP_HDR_NETIF_BRIDGEIF_H */
Functions to sync with TCPIP thread.
OS abstraction layer.
struct bridgeif_initdata_s bridgeif_initdata_t
Initialisation data for bridgeif_init.
u8_t max_ports
Maximum number of ports in the bridge (ports are stored in an array, this influences memory allocated...
Definition: bridgeif.h:75
lwIP netif implementing an IEEE 802.1D MAC Bridge
Initialisation data for bridgeif_init.
Definition: bridgeif.h:70
lwIP Error codes
Generic data structure used for all lwIP network interfaces.
u16_t max_fdb_dynamic_entries
Maximum number of dynamic/learning entries in the bridge&#39;s forwarding database.
Definition: bridgeif.h:78
Ethernet protocol definitions.
struct eth_addr ethaddr
MAC address of the bridge (cannot use the netif&#39;s addresses)
Definition: bridgeif.h:72
An Ethernet MAC address.
u16_t max_fdb_static_entries
Maximum number of static forwarding entries.
Definition: bridgeif.h:80
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.