version 1.1.1.1, 2021/03/17 00:07:30
|
version 1.1.1.2, 2023/09/27 11:18:58
|
Line 5
|
Line 5
|
|
|
void *sockaddr_addr_offset(const void *x) |
void *sockaddr_addr_offset(const void *x) |
{ |
{ |
if( x == NULL ) | if ( x == NULL ) |
return NULL; |
return NULL; |
|
|
if( ((struct sockaddr *)(x))->sa_family == AF_INET ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET ) |
{ |
{ |
return ((void *)(x) + offsetof(struct sockaddr_in, sin_addr)); |
return ((void *)(x) + offsetof(struct sockaddr_in, sin_addr)); |
}else | } else |
if( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) |
{ |
{ |
return ((void *)(x) + offsetof(struct sockaddr_in6, sin6_addr)); |
return ((void *)(x) + offsetof(struct sockaddr_in6, sin6_addr)); |
} |
} |
Line 22 void *sockaddr_addr_offset(const void *x)
|
Line 22 void *sockaddr_addr_offset(const void *x)
|
|
|
unsigned int sockaddr_addr_size(const void *x) |
unsigned int sockaddr_addr_size(const void *x) |
{ |
{ |
if( x == NULL ) | if ( x == NULL ) |
return 0; |
return 0; |
if( ((struct sockaddr *)(x))->sa_family == AF_INET ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET ) |
{ |
{ |
return sizeof(struct in_addr); |
return sizeof(struct in_addr); |
}else | } else |
if( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) |
{ |
{ |
return sizeof(struct in6_addr); |
return sizeof(struct in6_addr); |
} |
} |
Line 38 unsigned int sockaddr_addr_size(const void *x)
|
Line 38 unsigned int sockaddr_addr_size(const void *x)
|
|
|
unsigned int sockaddr_size(const void *x) |
unsigned int sockaddr_size(const void *x) |
{ |
{ |
if( x == NULL ) | if ( x == NULL ) |
return 0; |
return 0; |
if( ((struct sockaddr *)(x))->sa_family == AF_INET ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET ) |
{ |
{ |
return sizeof(struct sockaddr_in); |
return sizeof(struct sockaddr_in); |
}else | } else |
if( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) |
{ |
{ |
return sizeof(struct sockaddr_in6); |
return sizeof(struct sockaddr_in6); |
} |
} |
Line 53 unsigned int sockaddr_size(const void *x)
|
Line 53 unsigned int sockaddr_size(const void *x)
|
|
|
in_port_t *sockaddr_port_offset(const void *x) |
in_port_t *sockaddr_port_offset(const void *x) |
{ |
{ |
if( x == NULL ) | if ( x == NULL ) |
return NULL; |
return NULL; |
|
|
if( ((struct sockaddr *)(x))->sa_family == AF_INET ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET ) |
{ |
{ |
return ((void *)(x) + offsetof(struct sockaddr_in, sin_port)); |
return ((void *)(x) + offsetof(struct sockaddr_in, sin_port)); |
}else | } else |
if( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) | if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 ) |
{ |
{ |
return ((void *)(x) + offsetof(struct sockaddr_in6, sin6_port)); |
return ((void *)(x) + offsetof(struct sockaddr_in6, sin6_port)); |
} |
} |