Lines Matching refs:netif
3 * lwIP netif implementing an IEEE 802.1D MAC Bridge
41 * This file implements an IEEE 802.1D bridge by using a multilayer netif approach
42 * (one hardware-independent netif for the bridge that uses hardware netifs for its ports).
44 * On receive, the port netif calls into the bridge (via its netif->input function) and
45 * the bridge selects the port(s) (and/or its netif->input function) to pass the received pbuf to.
48 * - add the port netifs just like you would when using them as dedicated netif without a bridge
58 * - add the bridge netif (with IPv4 config):
59 * struct netif bridge_netif;
62 * which controls where the forwarding is done (netif low level input context vs. tcpip_thread)
63 * - set up all ports netifs and the bridge netif
65 * - When adding a port netif, NETIF_FLAG_ETHARP flag will be removed from a port
66 * to prevent ETHARP working on that port netif (we only want one IP per bridge not per port).
67 * - When adding a port netif, its input function is changed to call into the bridge.
82 #include "netif/bridgeif.h"
83 #include "lwip/netif.h"
100 struct netif *port_netif;
111 struct netif *netif;
122 /* netif data index to get the bridge on input */
135 bridgeif_fdb_add(struct netif *bridgeif, const struct eth_addr *addr, bridgeif_portmask_t ports)
140 LWIP_ASSERT("invalid netif", bridgeif != NULL);
168 bridgeif_fdb_remove(struct netif *bridgeif, const struct eth_addr *addr)
173 LWIP_ASSERT("invalid netif", bridgeif != NULL);
222 * (bridge netif or one of the port netifs), in which case the frame
230 if (!memcmp(br->netif->hwaddr, addr, sizeof(struct eth_addr))) {
235 struct netif *portif = br->ports[i].port_netif;
254 struct netif *portif = br->ports[dstport_idx].port_netif;
298 bridgeif_output(struct netif *netif, struct pbuf *p)
301 bridgeif_private_t *br = (bridgeif_private_t *)netif->state;
307 MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
310 MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts);
313 MIB2_STATS_NETIF_INC(netif, ifoutucastpkts);
322 /** The actual bridge input function. Port netif's input is changed to call
326 bridgeif_input(struct pbuf *p, struct netif *netif)
333 if (p == NULL || netif == NULL) {
336 port = (bridgeif_port_t *)netif_get_client_data(netif, bridgeif_netif_client_id);
342 rx_idx = netif_get_index(netif);
361 if (br->netif->input(p, br->netif) != ERR_OK) {
375 return br->netif->input(p, br->netif);
393 bridgeif_tcpip_input(struct pbuf *p, struct netif *netif)
395 return tcpip_inpkt(p, netif, bridgeif_input);
407 * @param netif the lwip network interface structure for this ethernetif
413 bridgeif_init(struct netif *netif)
420 LWIP_ASSERT("netif != NULL", (netif != NULL));
421 LWIP_ASSERT("bridgeif needs an input callback", (netif->input != NULL));
423 if (netif->input == tcpip_input) {
432 init_data = (bridgeif_initdata_t *)netif->state;
447 br->netif = netif;
465 netif->hostname = "lwip";
469 * Initialize the snmp variables and counters inside the struct netif.
473 MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, 0);
475 netif->state = br;
476 netif->name[0] = IFNAME0;
477 netif->name[1] = IFNAME1;
483 netif->output = etharp_output;
486 netif->output_ip6 = ethip6_output;
488 netif->linkoutput = bridgeif_output;
491 netif->hwaddr_len = ETH_HWADDR_LEN;
494 memcpy(netif->hwaddr, &br->ethaddr, ETH_HWADDR_LEN);
497 netif->mtu = 1500;
501 netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP | NETIF_FLAG_MLD6 | NETIF_FLAG_LINK_UP;
509 if (netif->mld_mac_filter != NULL) {
512 netif->mld_mac_filter(netif, &ip6_allnodes_ll, NETIF_ADD_MAC_FILTER);
524 bridgeif_add_port(struct netif *bridgeif, struct netif *portif)
555 /* store pointer to bridge in netif */
557 /* remove ETHARP flag to prevent sending report events on netif-up */