X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fipaddr%2Fng_ipaddr.h;h=f8409de99288e7f6b666e1f18c0a63c10b4ec8ad;hp=1f209ef9fb734ab4ac05b7d488c2a5ea1ebe7c4f;hb=3de972e0bdbb5da7b13db5628e5373e3ec57cf51;hpb=03628dbeaf40a9de34b3eb6d5bf6dd34eed8248c diff --git a/src/ipaddr/ng_ipaddr.h b/src/ipaddr/ng_ipaddr.h index 1f209ef9..f8409de9 100644 --- a/src/ipaddr/ng_ipaddr.h +++ b/src/ipaddr/ng_ipaddr.h @@ -4,6 +4,7 @@ #ifndef NG_IPADDR_HDR #define NG_IPADDR_HDR + #include "portab.h" /** @@ -12,6 +13,7 @@ */ #include +#include #include #include @@ -47,6 +49,7 @@ typedef struct NG_IP_ADDR_DONTUSE ng_ipaddr_t; static inline int ng_ipaddr_af(const ng_ipaddr_t *a) { + assert(a != NULL); #ifdef WANT_IPV6 return a->sa.sa_family; #else @@ -59,6 +62,7 @@ ng_ipaddr_af(const ng_ipaddr_t *a) static inline socklen_t ng_ipaddr_salen(const ng_ipaddr_t *a) { + assert(a != NULL); #ifdef WANT_IPV6 assert(a->sa.sa_family == AF_INET || a->sa.sa_family == AF_INET6); if (a->sa.sa_family == AF_INET6) @@ -75,11 +79,14 @@ ng_ipaddr_getport(const ng_ipaddr_t *a) #ifdef WANT_IPV6 int af = a->sa.sa_family; + assert(a != NULL); assert(af == AF_INET || af == AF_INET6); if (af == AF_INET6) return ntohs(a->sin6.sin6_port); #endif /* WANT_IPV6 */ + + assert(a != NULL); assert(a->sin4.sin_family == AF_INET); return ntohs(a->sin4.sin_port); } @@ -109,12 +116,15 @@ GLOBAL bool ng_ipaddr_tostr_r PARAMS((const ng_ipaddr_t *addr, char *dest)); static inline const char* ng_ipaddr_tostr(const ng_ipaddr_t *addr) { + assert(addr != NULL); return inet_ntoa(addr->sin4.sin_addr); } static inline bool ng_ipaddr_tostr_r(const ng_ipaddr_t *addr, char *d) { + assert(addr != NULL); + assert(d != NULL); strlcpy(d, inet_ntoa(addr->sin4.sin_addr), NG_INET_ADDRSTRLEN); return true; }