diff options
Diffstat (limited to 'include/asterisk/netsock2.h')
-rw-r--r-- | include/asterisk/netsock2.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/asterisk/netsock2.h b/include/asterisk/netsock2.h index a039d1bc6..90122f6c0 100644 --- a/include/asterisk/netsock2.h +++ b/include/asterisk/netsock2.h @@ -51,6 +51,18 @@ enum ast_transport { }; /*! + * \brief + * Isolate a 32-bit section of an IPv6 address + * + * An IPv6 address can be divided into 4 32-bit chunks. This gives + * easy access to one of these chunks. + * + * \param sin6 A pointer to a struct sockaddr_in6 + * \param index Which 32-bit chunk to operate on. Must be in the range 0-3. + */ +#define V6_WORD(sin6, index) ((uint32_t *)&((sin6)->sin6_addr))[(index)] + +/*! * \brief Socket address structure. * * \details @@ -400,6 +412,23 @@ int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family); /*! + * \brief + * Apply a netmask to an address and store the result in a separate structure. + * + * When dealing with IPv6 addresses, one cannot apply a netmask with a simple + * logical AND operation. Futhermore, the incoming address may be an IPv4 + * address and needs to be mapped properly before attempting to apply a rule. + * + * \param addr The IP address to apply the mask to. + * \param netmask The netmask configured in the host access rule. + * \param result The resultant address after applying the netmask to the given address + * \retval 0 Successfully applied netmask + * \retval -1 Failed to apply netmask + */ +int ast_sockaddr_apply_netmask(const struct ast_sockaddr *addr, const struct ast_sockaddr *netmask, + struct ast_sockaddr *result); + +/*! * \since 1.8 * * \brief |