Use getsockname(2) for finding out socket address family

Use this for portability. SO_DOMAIN seems to be a Linuxism.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Include <sys/socket.h> for AF_INET*.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Use SYS_ from <sys/syscall.h>.

__NR_ are not portable.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Define LIBC_SYSCALL_ for FreeBSD.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Find out if we really need libdl.

Some systems (like FreeBSD) have dlopen(3) and friends in libc and don't
need -ldl.

Removing the AC_CHECK_LIB for -ldl. Can't see the need for that, nor the
'have_libdl' outcome.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Use AC_CHECK_FUNC rather than AC_LINK_IFELSE.

It does the same thing, only with less eye pain.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>