Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
bridgeif.h
00001 /** 00002 * @file 00003 * lwIP netif implementing an IEEE 802.1D MAC Bridge 00004 */ 00005 00006 /* 00007 * Copyright (c) 2017 Simon Goldschmidt. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Simon Goldschmidt <goldsimon@gmx.de> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_NETIF_BRIDGEIF_H 00038 #define LWIP_HDR_NETIF_BRIDGEIF_H 00039 00040 #include "netif/bridgeif_opts.h" 00041 00042 #include "lwip/err.h" 00043 #include "lwip/prot/ethernet.h" 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 struct netif; 00050 00051 #if (BRIDGEIF_MAX_PORTS < 0) || (BRIDGEIF_MAX_PORTS >= 64) 00052 #error BRIDGEIF_MAX_PORTS must be [1..63] 00053 #elif BRIDGEIF_MAX_PORTS < 8 00054 typedef u8_t bridgeif_portmask_t; 00055 #elif BRIDGEIF_MAX_PORTS < 16 00056 typedef u16_t bridgeif_portmask_t; 00057 #elif BRIDGEIF_MAX_PORTS < 32 00058 typedef u32_t bridgeif_portmask_t; 00059 #elif BRIDGEIF_MAX_PORTS < 64 00060 typedef u64_t bridgeif_portmask_t; 00061 #endif 00062 00063 #define BR_FLOOD ((bridgeif_portmask_t)-1) 00064 00065 /** @ingroup bridgeif 00066 * Initialisation data for @ref bridgeif_init. 00067 * An instance of this type must be passed as parameter 'state' to @ref netif_add 00068 * when the bridge is added. 00069 */ 00070 typedef struct bridgeif_initdata_s { 00071 /** MAC address of the bridge (cannot use the netif's addresses) */ 00072 struct eth_addr ethaddr; 00073 /** Maximum number of ports in the bridge (ports are stored in an array, this 00074 influences memory allocated for netif->state of the bridge netif). */ 00075 u8_t max_ports; 00076 /** Maximum number of dynamic/learning entries in the bridge's forwarding database. 00077 In the default implementation, this controls memory consumption only. */ 00078 u16_t max_fdb_dynamic_entries; 00079 /** Maximum number of static forwarding entries. Influences memory consumption! */ 00080 u16_t max_fdb_static_entries; 00081 } bridgeif_initdata_t; 00082 00083 /** @ingroup bridgeif 00084 * Use this for constant initialization of a bridgeif_initdat_t 00085 * (ethaddr must be passed as ETH_ADDR()) 00086 */ 00087 #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} 00088 /** @ingroup bridgeif 00089 * Use this for constant initialization of a bridgeif_initdat_t 00090 * (each byte of ethaddr must be passed) 00091 */ 00092 #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} 00093 00094 err_t bridgeif_init(struct netif *netif); 00095 err_t bridgeif_add_port(struct netif *bridgeif, struct netif *portif); 00096 err_t bridgeif_fdb_add(struct netif *bridgeif, const struct eth_addr *addr, bridgeif_portmask_t ports); 00097 err_t bridgeif_fdb_remove(struct netif *bridgeif, const struct eth_addr *addr); 00098 00099 /* FDB interface, can be replaced by own implementation */ 00100 void bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx); 00101 bridgeif_portmask_t bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr); 00102 void* bridgeif_fdb_init(u16_t max_fdb_entries); 00103 00104 #if BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT 00105 #ifndef BRIDGEIF_DECL_PROTECT 00106 /* define bridgeif protection to sys_arch_protect... */ 00107 #include "lwip/sys.h" 00108 #define BRIDGEIF_DECL_PROTECT(lev) SYS_ARCH_DECL_PROTECT(lev) 00109 #define BRIDGEIF_READ_PROTECT(lev) SYS_ARCH_PROTECT(lev) 00110 #define BRIDGEIF_READ_UNPROTECT(lev) SYS_ARCH_UNPROTECT(lev) 00111 #define BRIDGEIF_WRITE_PROTECT(lev) 00112 #define BRIDGEIF_WRITE_UNPROTECT(lev) 00113 #endif 00114 #else /* BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT */ 00115 #include "lwip/tcpip.h" 00116 #define BRIDGEIF_DECL_PROTECT(lev) 00117 #define BRIDGEIF_READ_PROTECT(lev) 00118 #define BRIDGEIF_READ_UNPROTECT(lev) 00119 #define BRIDGEIF_WRITE_PROTECT(lev) 00120 #define BRIDGEIF_WRITE_UNPROTECT(lev) 00121 #endif /* BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT */ 00122 00123 #ifdef __cplusplus 00124 } 00125 #endif 00126 00127 #endif /* LWIP_HDR_NETIF_BRIDGEIF_H */
Generated on Tue Jul 12 2022 13:54:03 by
