Hi Simon,
OK ... good or not, I've tested that in the JTAG debugger and it works. Unless
you have a better idea for that:
I need to implement a proxy between a WAN and a LAN connection. On the LAN side
there are up to 50 devices which needs to be addressed via the WAN (which does
only work by using different ports for the incoming direction). The device have
IP addresses like this:
192.168.0.100 - Device 1
192.168.0.101 - Device 2
192.168.0.102 - Device 3
...
192.168.0.149 - Device 50
So on the WAN side I need to "listen" to 50 TCP ports:
8000 - Connection to device 1
8001 - Connection to device 2
...
8049 - Connection to device 50
There must be only *one* concurrent connection at a time.
The issue: A TCP listener "costs" me 300 Bytes of RAM in my FreeRTOS (plus
additional memory for MAX_NETCONNS in LwIP). Would be 15k ... no chance with
1k5 left to open 50 listener sockets.
So the only workaround: Open ONE listener on port 8000. Before a packet goes
into the LwIP handler I need to check if this is TCP and if it's addressed to
one of the ports in the "incoming" range (8000-8049).
If the port matches and my proxy has no active connection, I need to add a code
into my LwIP NAT file (which is hooked before the packet is passed onto LwIP)
to rewrite "port_local" to the port, which is the one where the packet is
addressed to. LwIP will then accept the TCP connection and proceeds with the
connection.
So - that will of course happen inside the LwIP thread (in my hooked nat.c) and
not "out of control" in another thread.
As mentioned, I did this several times "by hand" in the debugger. Breakpoint on
incoming packet, change the local_port in the debugger watch, then continue the
execution. Works like a charm.
It's *my only way* to implement this (except you have any other "zero RAM"
ideas for that). So if I'm really not getting ideas here how to access that, I
guess I need to try around for even more hours ...
Von: "goldsi...@gmx.de" <goldsi...@gmx.de>
An: Mailing list for lwIP users <lwip-users@nongnu.org>
Gesendet: 16.11.2016 20:13
Betreff: Re: [lwip-users] Directly accessing tcp.local_port in a netconn
Hey Marco,
Marco Jakobs wrote:
due to very limited resources I need to do a strange thing ;-)
I need to change the listener port of one single TCP listening
connection "on the fly" in its idle state.
Really? Very limited resources, using netconn and this should help?
Keeping that aside, for the thread using netconns, the pcb is never
"idle": it's listening. You're producing
race conditions here. This is a bad example for this list!
Keeping even that aside, accessing a struct's member should be
prevented and *is* prevented by the
lwip headers, so struct tcp_pcb is unknown to your code (and it's good
like that!)
Simon
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users