mapping multiple * IP addresses to one Ethernet interface (LWIP)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mapping multiple * IP addresses to one Ethernet interface (LWIP)

1,082 Views
medali___
Contributor I

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;

}

0 Kudos
Reply
0 Replies