Retrieving the destination port in an ipfw fwd'ed UDP packet

Gerald McNulty gmnt99 at gmail.com
Tue Feb 5 23:44:48 UTC 2013


I'm trying to get the destination port from a UDP packet that's been ipfw
fwd'ed to my code. Getting the destination IP address works fine with *
setsockopt(...,IP_RECVDSTADDR,...)* and then *recvfrom*, but there doesn't
seem to be a way to get the port.

For TCP I could just use
getsockname(2)<http://man.freebsd.org/getsockname/2>and
getpeername(2) <http://man.freebsd.org/getpeername/2> for all the IP
address info but this only returns the locally bound address and port, not
the actual destination.

Is there an elegant way to get the destination IP port from an ipfw fwd'ed
packet?

Thanks


More information about the freebsd-ipfw mailing list