diff options
author | Guy Harris <gharris@sonic.net> | 2022-08-01 14:25:42 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-08-01 14:25:42 -0700 |
commit | 7c17b91f769ae3a2cef64f35d61a28fdf08220ae (patch) | |
tree | 19d93753e15be90071e4ea1acab8d9ed67f02293 /fmtutils.h | |
parent | 137e5c5ac9dd878ebe2e85ee18014378399ad7c4 (diff) |
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..
Diffstat (limited to 'fmtutils.h')
-rw-r--r-- | fmtutils.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -34,6 +34,8 @@ #ifndef fmtutils_h #define fmtutils_h +#include <stdarg.h> /* we declare varargs functions */ + #include "pcap/funcattrs.h" #ifdef __cplusplus @@ -44,10 +46,14 @@ void pcap_fmt_set_encoding(unsigned int); void pcap_fmt_errmsg_for_errno(char *, size_t, int, PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); +void pcap_vfmt_errmsg_for_errno(char *, size_t, int, + PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0); #ifdef _WIN32 void pcap_fmt_errmsg_for_win32_err(char *, size_t, DWORD, PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); +void pcap_vfmt_errmsg_for_win32_err(char *, size_t, DWORD, + PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0); #endif #ifdef __cplusplus |