multiple netifs in no_sys environment

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple netifs in no_sys environment

steffen_storck
Hello

I am new to the lwip stack and I need your help for a little exotic problem:

My pc has the ip address 192.168.24.100 and wants to send to 172.20.0.30
which is not in the same network. I added the default gateway to the pc
192.168.24.40 which is the ip address of an Infineon chip with the lwip
stack implemented.

At the lwip stack I added two netifs, one (default) with 192.168.24.40 and a
second one with 172.20.0.30. So when the pc sends a message to 172….. I want
to process this telegram In the stack with the input() function is passed to
the netif.

Is there a way to do so?

Best regards and thank you in advance.

Steffen




--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: multiple netifs in no_sys environment

Sergio R. Caprile
The lwIP stack will not work as a router unless you actually write the
routing code yourself. Since in your scenario the non-local address is
the device netif address, that should work. If it were some other host
in that very same network (172...) connected to the lwIP device, it
would not (unless you write the code).
How to do it: you just setup two netifs. I would set the 192... to
default. Try the echo server and it should work.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: multiple netifs in no_sys environment

steffen_storck
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Thank your for your answer.

I made it work by defining  the LWIP_ARP_FILTER_NETIF_FN function in netif_input() to determine which netif to use for sending and further checks.

Thanks again.

Code of the filter function looks like this


struct netif *netif_filter(void *p, struct netif *netif, unsigned short type)
{
uint32_t addr;

switch(type)
{
case ETHTYPE_IP:
if(((struct pbuf*) p)->len < ETH_IP_DESTINATION_IP_POS + sizeof(addr)) return netif;
memcpy(&addr, (uint8_t*) (((struct pbuf*) p)->payload)+ (ETH_IP_DESTINATION_IP_POS + ETH_PAD_SIZE), sizeof(addr));
break;

case ETHTYPE_ARP:
if(((struct pbuf*) p)->len < ETH_ARP_DESTINATION_IP_POS + sizeof(addr)) return netif;
memcpy(&addr, (uint8_t*) (((struct pbuf*) p)->payload)+(ETH_ARP_DESTINATION_IP_POS + ETH_PAD_SIZE), sizeof(addr));
break;

default:
return netif;
}


if(addr^netif->ip_addr.addr)
{
for(uint32_t i=0; i<xnetif_count; i++)
{
struct netif *const ptr = xnetif+i;
if(!(addr^ptr->ip_addr.addr)) return ptr;
}
}

return netif;
}


- -----Ursprüngliche Nachricht-----
Von: lwip-users <lwip-users-bounces+steffen.storck=[hidden email]> Im Auftrag von Sergio R. Caprile
Gesendet: Montag, 29. April 2019 14:59
An: [hidden email]
Betreff: Re: [lwip-users] multiple netifs in no_sys environment

The lwIP stack will not work as a router unless you actually write the
routing code yourself. Since in your scenario the non-local address is
the device netif address, that should work. If it were some other host
in that very same network (172...) connected to the lwIP device, it
would not (unless you write the code).
How to do it: you just setup two netifs. I would set the 192... to
default. Try the echo server and it should work.

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

________________________________


SEW-EURODRIVE GmbH & Co KG
Kommanditgesellschaft, Sitz: Bruchsal, RG Mannheim HRA 230970
Komplementärin: SEW-EURODRIVE Verwaltungs-GmbH, Sitz: Bruchsal, RG Mannheim HRB 230207

Gesellschafter: Jürgen Blickle, Rainer Blickle
Geschäftsführung: Jürgen Blickle (Vorsitzender), Udo Aull, Dr. Jörg Hermes, Dr. Hans Krattenmacher, Johann Soder, Dr. Jürgen Zanghellini

-----BEGIN PGP SIGNATURE-----
Version: PGP Universal 3.4.2 (Build 502)
Charset: iso-8859-1

wsBVAwUBXPpOeOPdlEjxNdWZAQi9lwgAqYB2fxsbF+bRB0kD0OHvssaKO8Mu6OrC
X6USB64zSf8bTwo1iuG1n8ble9rIUmAhb+iIpFJiHeQqDPsLOB2XHK5ayF7xNBfb
OaW2HlfBthKBowKrhxBaCs6ztbXRjQ9havu7nv407fasyMFdtn99050sKVT9gsFh
JJYl6M/sJPRgKAG5oQruvAjB7rIZzltZaCaD0uxe5cY3PyOETGt9dqL6nu6Bq5u0
Fa8IbpGZsEGAOpq1Rmhj+Xdlfi2ocSkZrhip3BbJeY7PCJiX2REYqyQNl7p079mf
Ifrzg6AFMpvJse9DX0bmG7FzYfMEFMEV2V8JyT0dXw8fxHpHt1j2MA==
=0a9j
-----END PGP SIGNATURE-----

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users