LWIP with more IPs on same netif

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
woof62
Level 1
Level 1
10 sign-ins First reply posted First question asked

Hello, 

how can I use more then one IP on a netif?
adding a netif to the same i cannot figure out...
Is there any example for the XMC4700-F144K2048 AA 
In my case I have to use 10.57.0.33 and 10.57.2.33 (mask 255.255.0.0) at the same time!

Thank you for help!!
Wolfgang

0 Likes
1 Solution
sujatapatil
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 100 sign-ins

Hi ,

You can check example code for iot_example_xmc4700 at 

https://www.infineon.com/cms/en/product/promopages/aim-mc/dave_downloads.html

 

Thanks

Sujata

 

View solution in original post

0 Likes
5 Replies
woof62
Level 1
Level 1
10 sign-ins First reply posted First question asked

the onyl way I found at the moment is to copy the default network and adding to the list:

 

void add_2nd_netif(static ip_addr_t *new_ip)
{
  XMC_DEBUG("Adding 2nd IP\n");
  static struct netif netif2, *netif2_add_result;
  static ip_addr_t my_mask2;

  // Copy HW Info
  memcpy(&netif2, netif_default, sizeof(struct netif));
  my_mask2 = netif_default->netmask;
  netif2_add_result = netif_add(&netif2, new_ip, &my_mask2, NULL, NULL, &dummy_init, netif_default->input);

  if (netif2_add_result == NULL)
  {
    XMC_DEBUG("Adding 2nd IP failed: %ld\n", (uint32_t)netif2_add_result);
  }
  else
  {
    // Copy other stuff from
    netif2.output = netif_default->output;
    netif2.linkoutput = netif_default->linkoutput;
    netif2.mtu = 1500U;
    netif2.flags = NETIF_FLAG_ETHARP;

    #if ETH_BROADCAST_EN ==
    netif2.flags |= NETIF_FLAG_BROADCAST;
    #endif

    netif_set_status_callback(&netif2, &netif2_status_cb);
    netif_set_up(&netif2);
  }
}

 

after calling this code I'm able to ping the 2nd IP.

 

0 Likes
sujatapatil
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 100 sign-ins

Hi ,

For one netif we can add  only one IP at a time.  Can i know your requirement to have 2 IP for same interface.

Thanks

Sujata

0 Likes

Well, I have to comunicate with two different nets.
My Problem is now grown: one of the two IP addresses is unknown an will be delivered via DHCP. The 2nd one is static. The method I postet on Jun 27 work only for two static and ONLY for ping...

I need to add a full function netif. I don't know how to handle the callbacks an how to integrate them all to the existig LWIP thread.

 

Thanks all for help!!
Wolfgang

 

0 Likes
sujatapatil
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 100 sign-ins

Hi ,

You can check example code for iot_example_xmc4700 at 

https://www.infineon.com/cms/en/product/promopages/aim-mc/dave_downloads.html

 

Thanks

Sujata

 

0 Likes
sujatapatil
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 100 sign-ins

Hi

I have not heard from you since my response . I assume that this is because the issue is resolved and you are busy with other important work.

If, however, the issue is not resolved, please do let me know and I shall work with you to ensure that the issue is resolved.

I will wait for another two days to hear from you. If I do not hear from you, I shall go ahead and close this case.

You can always reopen this case or create a new case for any other issue. We will be happy to help you in resolving your issues.

Thanks

Sujata

0 Likes