Не понял всеравно какой командой узнать адр назначения пакета а дальше уж понятно
You set the IP_PKTINFO option using setsockopt and then use recvmsg and get a in_pktinfo structure in the msg_control member of struct msghdr. the in_pktinfo has a field with the destination address of the packet.
use the recvfrom (check on the man pages) call to receive the data. This will give you a sockaddr pointer containing the data about the incoming connection. The sockaddr structure contains a sa_data member which is simply a 14 byte char array. Somewhere in this array is the data you need.
use the recvfrom (check on the man pages) call to receive the data. This will give you a sockaddr pointer containing the data about the incoming connection. The sockaddr structure contains a sa_data member which is simply a 14 byte char array. Somewhere in this array is the data you need.