]> The Tcpdump Group git mirrors - libpcap/commit
rpcap: fix sock_open() issues.
authorGuy Harris <[email protected]>
Mon, 1 Aug 2022 21:25:42 +0000 (14:25 -0700)
committerGuy Harris <[email protected]>
Mon, 1 Aug 2022 21:25:42 +0000 (14:25 -0700)
commit7c17b91f769ae3a2cef64f35d61a28fdf08220ae
tree19d93753e15be90071e4ea1acab8d9ed67f02293
parent137e5c5ac9dd878ebe2e85ee18014378399ad7c4
rpcap: fix sock_open() issues.

When connecting as a client, don't create one socket, using the address
family of the first entry in the address list, and use that for all
entries; on most if not all platforms, an AF_INET socket can't be used
to connect to an IPv6 address and an AF_INET6 socket can't be used to
connect to an IPv4 address.  Instead, construct a table of the entries
in the address list, sort it by address family, and cycle through the
entries.  If there is no socket yet, create it based on the current
entry's address family; if there is a socket, but it's for a different
address family than the current entry's address family, close it and
open a new one.

If connecting fails for all addresses, don't just construct a long
barely-readable error message consisting of the full errors for each
failure.  Instead, construct one that, for each error code, has a list
of the addresses that got that error code; if all the failures had the
same error code, just show the host name, not the complete list of
addresses.

Clean up some error handling routines - fix names, allow some to take a
printf-style argument list, etc..
fmtutils.c
fmtutils.h
pcap-rpcap.c
rpcapd/daemon.c
rpcapd/rpcapd.c
sockutils.c
sockutils.h