Commit ad86f434 authored by Pekka Pessi's avatar Pekka Pessi
Browse files

Added SU_ADDRLEN() macro.

darcs-hash:20060223211932-65a35-1a0c9f266cab3375cadce6c59451769066bc94c2.gz
parent 47edc062
...@@ -306,6 +306,22 @@ const char *inet_ntop(int af, void const *src, char *dst, size_t size); ...@@ -306,6 +306,22 @@ const char *inet_ntop(int af, void const *src, char *dst, size_t size);
(void *)&(su)->su_sa.sa_data) (void *)&(su)->su_sa.sa_data)
#endif #endif
/**@HI Get length of address field.
*
* The macro SU_ADDRLEN() returns length of the address field (sin_data,
* sin_addr or sin_addr6, depending on the address family).
*/
#if SU_HAVE_IN6
#define SU_ADDRLEN(su) \
((su)->su_family == AF_INET ? sizeof((su)->su_sin.sin_addr) : \
((su)->su_family == AF_INET6 ? sizeof((su)->su_sin6.sin6_addr) : \
sizeof((su)->su_sa.sa_data)))
#else
#define SU_ADDRLEN(su) \
((su)->su_family == AF_INET ? sizeof((su)->su_sin.sin_addr) : \
sizeof((su)->su_sa.sa_data))
#endif
/**@HI Test if su_sockaddr_t is INADDR_ANY or IN6ADDR_ANY. */ /**@HI Test if su_sockaddr_t is INADDR_ANY or IN6ADDR_ANY. */
#if SU_HAVE_IN6 #if SU_HAVE_IN6
#define SU_HAS_INADDR_ANY(su) \ #define SU_HAS_INADDR_ANY(su) \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment