opnsense-src/share/examples/find_interface
Franco Fichtner cd6ee62847 src: clean-cut move to 10.2-RELEASE
Start fresh on master, only apply needed patches on top now.

Upstream commit:	56279fdef34eb28a4655b489b992c651bd8379fc
Taken from:		FreeBSD
2015-08-14 14:15:00 +02:00
..
find_interface.c src: initial commit based on FreeBSD-10.0 2014-11-09 09:30:14 +01:00
Makefile src: clean-cut move to 10.2-RELEASE 2015-08-14 14:15:00 +02:00
README src: initial commit based on FreeBSD-10.0 2014-11-09 09:30:14 +01:00

This is a simple program which demonstrates how to query the kernel
routing mechanism using only a UDP socket.  Pass it a hostname on
the command line (sorry, it doesn't parse dotted decimal) and it will
print out an IP address which names the interface over which UDP
packets intended for that destination would be sent.
A more sophisticated program might use the list obtained from SIOCGIFCONF
to match the address with an interface name, but applications programmers
much more often need to know the address of the interface rather than
the name.