Hello,
I'm attempting to bind multiple IP addresses to a single Ethernet port using different struct netif logical interfaces. My current implementation involves disabling one interface for it to work.
Seeking guidance or resources on the correct approach. Any insights appreciated.
Thanks,
int main(void) {
struct netif netif1, netif2;
int ret;
ip4_addr_t netif1_ipaddr, netif1_netmask, netif1_gw;
ip4_addr_t netif2_ipaddr, netif2_netmask, netif2_gw;
ethernetif_config_t enet_config = {.phyHandle = &phyHandle,
.phyAddr = EXAMPLE_PHY_ADDRESS,
.phyOps = EXAMPLE_PHY_OPS,
.phyResource = EXAMPLE_PHY_RESOURCE,
};
BOARD_ConfigMPU();
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
BOARD_InitModuleClock();
SCB_DisableDCache();
IOMUXC_SelectENETClock();
BOARD_InitBothEnetPins_test();
BOARD_ENET_PHY1_RESET;
EnableIRQ(ENET_1G_MAC0_Tx_Rx_1_IRQn);
EnableIRQ(ENET_1G_MAC0_Tx_Rx_2_IRQn);
MDIO_Init();
g_phy_resource.read = MDIO_Read;
g_phy_resource.write = MDIO_Write;
time_init();
CRYPTO_InitHardware();
lwip_init();
// Add the first logical interface with its IP configuration
IP4_ADDR(&netif1_ipaddr, 192, 168, 0, 102);
IP4_ADDR(&netif1_netmask, 255, 255, 255, 0);
IP4_ADDR(&netif1_gw, 192, 168, 0, 100);
netif_add(&netif1, &netif1_ipaddr, &netif1_netmask, &netif1_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input);
netif_set_default(&netif1);
netif_set_up(&netif1);
// Add the second logical interface with its IP configuration
IP4_ADDR(&netif2_ipaddr, 192, 168, 0, 111);
IP4_ADDR(&netif2_netmask, 255, 255, 255, 0);
IP4_ADDR(&netif2_gw, 192, 168, 0, 100);
netif_add(&netif2, &netif2_ipaddr, &netif2_netmask, &netif2_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input);
netif_set_up(&netif2);
while (1) {
// Poll both netifs for incoming frames
ethernetif_input(&netif1);
ethernetif_input(&netif2);
sys_check_timeouts(); // Handle all system timeouts for all core protocols
}
return -1;
}
Mapping multiple IP addresses to a single Ethernet interface in LWIP can be useful in systems that need to handle different network identities or services through one physical connection. The key is ensuring the IP configuration, routing, and ARP handling are properly managed so each address responds correctly without conflicts. When designing embedded networking solutions, it also helps to understand the available hardware options and Explore Networking Products that support flexible network setups and reliable communication. Proper testing with different network scenarios can help identify issues related to packet handling and interface configuration.
Hello, It's been quite some time since you posted the issue but did had any luck figuring this out?
I am currently trying the same thing with a TI TMS570LC43 launchpad and lwIP 1.4.1 version