static if_t *add_if_info(char *name) { new_port_init (idx); strncpy(IF_DESCR(idx + 1), name, IFNAMSIZ); fetch_and_update_if_info (IF_INFO(idx + 1)); return IF_INFO(idx + 1); }
void process_pkt (void *pkt, int len, uint16_t port) { struct ether_hdr *eth = (struct ether_hdr *)pkt; struct pbuf *p = NULL; int vlanid = 1; if ((IF_OPER_STATUS(port) == IF_DOWN) || (IF_ADMIN_STATUS(port) == IF_DOWN)) { return; } if (IS_MAC_UCAST_MAC (eth->smac.addr)) { mac_address_update (eth->smac, (uint32_t)port, 1); #if 0 if (unknown_umac (eth->dmac)) { /*flood the packet*/ } #endif } if (is_dest_stp_group_address (eth->dmac)) { stp_rcv_bpdu (pkt, port, vlanid, len); return; } #ifdef CONFIG_OPENSWITCH_TCP_IP p = allocate_and_cpy_buf_2_pbuf (pkt, len); if (p) ethernet_input (p, IF_INFO (port)); #endif free (pkt); }
/* proceed to next network interface */ netif = netif->next; } } #endif #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ int set_ip_address (uint32_t ifindex, uint32_t ipaddress, uint32_t ipmask) { ip_addr_t ipaddr, netmask; ipaddr.addr = ipaddress; netmask.addr = ipmask; if_set_addr (IF_INFO(ifindex), &ipaddr, &netmask, &ipaddr); return 0; }