I have a device with two network interfaces, en0 and en1. I would like
lwip to consider them as separate network interfaces.
As a test, I have installed two DHCP servers in two networks and I'm
assigning each interface an IP address in the same IP range. This works
perfectly. Each IP address is only visible on the interface to which it
was assigned. No ARP or other traffic mentioning the IP address is
"leaked" to the wrong interface. So far so good.
Next I have tried to set up a TCP server which is bound to only "en0"
using SO_BINDTOSOCKET, but without success. It seems as if that call
doesn't have any effect at all. I can connect to the socket from en1
though I would expect to get a "Connection refused". On the contrary,
connecting from en0 causes a SYN-ACK packet to be send out on en1.
I have found the problem: It seems that lwip_listen() creates a new pcb
but doesn't copy the netbuf_idx field from the original pcb. If
lwip_setsockopt() is called after lwip_listen(), it works as expected.
I will submit a patch which fixes this behaviour, as I think we
shouldn't have to listen on all interfaces first before restricting it
to a single interface.