source: azure_iot_hub_f767zi/trunk/asp_baseplatform/lwip/lwip-2.1.2/src/include/netif/bridgeif.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 5.0 KB
Line 
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
46extern "C" {
47#endif
48
49struct 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
54typedef u8_t bridgeif_portmask_t;
55#elif BRIDGEIF_MAX_PORTS < 16
56typedef u16_t bridgeif_portmask_t;
57#elif BRIDGEIF_MAX_PORTS < 32
58typedef u32_t bridgeif_portmask_t;
59#elif BRIDGEIF_MAX_PORTS < 64
60typedef 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 */
70typedef 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. */
78 u16_t max_fdb_dynamic_entries;
79 /** Maximum number of static forwarding entries. Influences memory consumption! */
80 u16_t max_fdb_static_entries;
81} bridgeif_initdata_t;
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
94err_t bridgeif_init(struct netif *netif);
95err_t bridgeif_add_port(struct netif *bridgeif, struct netif *portif);
96err_t bridgeif_fdb_add(struct netif *bridgeif, const struct eth_addr *addr, bridgeif_portmask_t ports);
97err_t bridgeif_fdb_remove(struct netif *bridgeif, const struct eth_addr *addr);
98
99/* FDB interface, can be replaced by own implementation */
100void bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx);
101bridgeif_portmask_t bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr);
102void* 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 */
Note: See TracBrowser for help on using the repository browser.