BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 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 | struct netif; |
||
46 | |||
47 | #if (BRIDGEIF_MAX_PORTS < 0) || (BRIDGEIF_MAX_PORTS >= 64) |
||
48 | #error BRIDGEIF_MAX_PORTS must be [1..63] |
||
49 | #elif BRIDGEIF_MAX_PORTS < 8 |
||
50 | typedef u8_t bridgeif_portmask_t; |
||
51 | #elif BRIDGEIF_MAX_PORTS < 16 |
||
52 | typedef u16_t bridgeif_portmask_t; |
||
53 | #elif BRIDGEIF_MAX_PORTS < 32 |
||
54 | typedef u32_t bridgeif_portmask_t; |
||
55 | #elif BRIDGEIF_MAX_PORTS < 64 |
||
56 | typedef u64_t bridgeif_portmask_t; |
||
57 | #endif |
||
58 | |||
59 | #define BR_FLOOD ((bridgeif_portmask_t)-1) |
||
60 | |||
61 | /** @ingroup bridgeif |
||
62 | * Initialisation data for @ref bridgeif_init. |
||
63 | * An instance of this type must be passed as parameter 'state' to @ref netif_add |
||
64 | * when the bridge is added. |
||
65 | */ |
||
66 | typedef struct bridgeif_initdata_s { |
||
67 | /** MAC address of the bridge (cannot use the netif's addresses) */ |
||
68 | struct eth_addr ethaddr; |
||
69 | /** Maximum number of ports in the bridge (ports are stored in an array, this |
||
70 | influences memory allocated for netif->state of the bridge netif). */ |
||
71 | u8_t max_ports; |
||
72 | /** Maximum number of dynamic/learning entries in the bridge's forwarding database. |
||
73 | In the default implementation, this controls memory consumption only. */ |
||
74 | u16_t max_fdb_dynamic_entries; |
||
75 | /** Maximum number of static forwarding entries. Influences memory consumption! */ |
||
76 | u16_t max_fdb_static_entries; |
||
77 | } bridgeif_initdata_t; |
||
78 | |||
79 | /** @ingroup bridgeif |
||
80 | * Use this for constant initialization of a bridgeif_initdat_t |
||
81 | * (ethaddr must be passed as ETH_ADDR()) |
||
82 | */ |
||
83 | #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} |
||
84 | /** @ingroup bridgeif |
||
85 | * Use this for constant initialization of a bridgeif_initdat_t |
||
86 | * (each byte of ethaddr must be passed) |
||
87 | */ |
||
88 | #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} |
||
89 | |||
90 | err_t bridgeif_init(struct netif *netif); |
||
91 | err_t bridgeif_add_port(struct netif *bridgeif, struct netif *portif); |
||
92 | err_t bridgeif_fdb_add(struct netif *bridgeif, const struct eth_addr *addr, bridgeif_portmask_t ports); |
||
93 | err_t bridgeif_fdb_remove(struct netif *bridgeif, const struct eth_addr *addr); |
||
94 | |||
95 | #endif /* LWIP_HDR_NETIF_BRIDGEIF_H */ |