Bug 194758 - Need an API to obtain original destination port of locally forwarded UDP packet
Summary: Need an API to obtain original destination port of locally forwarded UDP packet
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Adrian Chadd
URL:
Keywords: feature
Depends on:
Blocks:
 
Reported: 2014-11-02 14:59 UTC by hoomanfazaeli
Modified: 2019-02-01 17:27 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hoomanfazaeli 2014-11-02 14:59:30 UTC
For UDP packets forwarded to a local daemon with a rule like below:

ipfw add 10 fwd localhost,7000 udp from any to any in recv em1

The daemon may obtain the original destination address of forwarded packets
using recvmsg(2) and IP_RECVDSTADDR socket option. However, there is no
API to obtain the original destination _port_.

One possible solution is to add a new socket option, say IP_RECVDSTSOADDR.
If set on a datagram socket, ip_savecontorl/ip6_savecontrol_v4 would record 
the datagram's destination address and port as a 'sockaddr_in[6]' structure.