A001 wrote:Ok.
It's possible to detect which way a packet came to the my ESP8266 UDP server? From AP or STA ?
I want to redirect these packages.
If they came from the AP to UDP server they must be sent to a client.
And vice versa.
Thanks.
Depends on a couple of things.
UDP messages contain a UDP header and an IP header. The IP header includes Source IP Address and Destination IP Address. This is true for all machines.
udp.png
TCP and
directed UDP packet's Destination IP Address coming into your ESP8266 will have the ESP8266's address of the SoftAP or StationAP that they arrive. Unfortunately, if the senders were using broadcasts the destination is 255.255.255.255.
But... you can solve this in different ways. Maybe you know what the source IP addresses ranges... that will be coming in one versus the other. OR you can setup the Listening Ports to be different and know which one they came in on by their Ports.
Now as far as how to dig out those header details, that depends on what library you're using. The lowest level uses lwIP and so do several of the other libraries, but they'll probably have different ways at digging out those details. Kind of a dumpster diving exercise in the code base.
Good Luck.