diff --git a/include/Makefile.am b/include/Makefile.am index 884f3b3..747c5b8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,8 +1,8 @@ noinst_HEADERS = noinst_HEADERS += signal.h noinst_HEADERS += unistd.h +noinst_HEADERS += netinet/in.h noinst_HEADERS += sys/types.h -noinst_HEADERS += sys/socket.h noinst_HEADERS += sys/time.h noinst_HEADERS += imsg.h noinst_HEADERS += string.h diff --git a/include/netinet/in.h b/include/netinet/in.h new file mode 100644 index 0000000..a7bc481 --- /dev/null +++ b/include/netinet/in.h @@ -0,0 +1,24 @@ +/* + * Public domain + * netinet/in.h compatibility shim + */ + +#include_next + +#ifndef SA_LEN +static inline socklen_t sockaddr_len(void *a) +{ + struct sockaddr *sa = a; + switch (sa->sa_family) { + case AF_INET: + return sizeof(struct sockaddr_in); + case AF_INET6: + return sizeof(struct sockaddr_in6); + case AF_UNSPEC: + return sizeof(struct sockaddr); + default: + return 0; + } +} +#define SA_LEN(X) sockaddr_len(X) +#endif diff --git a/include/sys/socket.h b/include/sys/socket.h deleted file mode 100644 index 3eb7338..0000000 --- a/include/sys/socket.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Public domain - * sys/socket.h compatibility shim - */ - -#include_next - -#ifndef SA_LEN -#define SA_LEN(X) \ - (((struct sockaddr*)(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \ - ((struct sockaddr*)(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr)) -#endif