diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/acl.h | 16 | ||||
-rw-r--r-- | include/asterisk/config.h | 10 | ||||
-rw-r--r-- | include/asterisk/dnsmgr.h | 10 | ||||
-rw-r--r-- | include/asterisk/netsock2.h | 523 | ||||
-rw-r--r-- | include/asterisk/rtp_engine.h | 46 | ||||
-rw-r--r-- | include/asterisk/tcptls.h | 9 |
6 files changed, 578 insertions, 36 deletions
diff --git a/include/asterisk/acl.h b/include/asterisk/acl.h index c8916a68a..2c4f62051 100644 --- a/include/asterisk/acl.h +++ b/include/asterisk/acl.h @@ -29,6 +29,7 @@ extern "C" { #endif #include "asterisk/network.h" +#include "asterisk/netsock2.h" #include "asterisk/io.h" #define AST_SENSE_DENY 0 @@ -124,12 +125,12 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin); * of getting an entire hostent structure, you instead are given * only the IP address inserted into a sockaddr_in structure. * - * \param[out] sin The IP address is written into sin->sin_addr + * \param[out] addr The IP address is written into sin->sin_addr * \param value The hostname to look up * \retval 0 Success * \retval -1 Failure */ -int ast_get_ip(struct sockaddr_in *sin, const char *value); +int ast_get_ip(struct ast_sockaddr *addr, const char *value); /*! * \brief Get the IP address given a hostname and optional service @@ -141,14 +142,17 @@ int ast_get_ip(struct sockaddr_in *sin, const char *value); * an SRV lookup will be done for "_sip._udp.example.com". If service is NULL, * then this function acts exactly like a call to ast_get_ip. * - * \param[out] sin The IP address is written into sin->sin_addr + * \param addr The IP address found. The address family is used as an input parameter to + * filter the returned adresses. if it is 0, both IPv4 and IPv6 addresses + * can be returned. + * * \param value The hostname to look up * \param service A specific service provided by the host. A NULL service results * in an A-record lookup instead of an SRV lookup * \retval 0 Success * \retval -1 Failure */ -int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *service); +int ast_get_ip_or_srv(struct ast_sockaddr *addr, const char *value, const char *service); /*! * \brief Get our local IP address when contacting a remote host @@ -164,7 +168,7 @@ int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *se * \retval -1 Failure * \retval 0 Success */ -int ast_ouraddrfor(struct in_addr *them, struct in_addr *us); +int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us); /*! * \brief Find an IP address associated with a specific interface @@ -219,7 +223,7 @@ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original); * \retval 0 Success * \retval -1 Failure */ -int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr); +int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr); /*! * \brief Convert a string to the appropriate COS value diff --git a/include/asterisk/config.h b/include/asterisk/config.h index 47de72573..fdaeb0e3e 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -592,6 +592,14 @@ enum ast_parse_flags { PARSE_INT16 = 0x0004, PARSE_UINT16 = 0x0005, #endif + + /* Returns a struct ast_sockaddr, with optional default value + * (passed by reference) and port handling (accept, ignore, + * require, forbid). The format is 'ipaddress[:port]'. IPv6 address + * literals need square brackets around them if a port is specified. + */ + PARSE_ADDR = 0x000e, + /* Returns a struct sockaddr_in, with optional default value * (passed by reference) and port handling (accept, ignore, * require, forbid). The format is 'host.name[:port]' @@ -614,7 +622,7 @@ enum ast_parse_flags { PARSE_IN_RANGE = 0x0020, /* accept values inside a range */ PARSE_OUT_RANGE = 0x0040, /* accept values outside a range */ - /* Port handling, for sockaddr_in. accept/ignore/require/forbid + /* Port handling, for ast_sockaddr. accept/ignore/require/forbid * port number after the hostname or address. */ PARSE_PORT_MASK = 0x0300, /* 0x000: accept port if present */ diff --git a/include/asterisk/dnsmgr.h b/include/asterisk/dnsmgr.h index bf960536d..2c96d8e40 100644 --- a/include/asterisk/dnsmgr.h +++ b/include/asterisk/dnsmgr.h @@ -27,7 +27,7 @@ extern "C" { #endif -#include "asterisk/network.h" +#include "asterisk/netsock2.h" #include "asterisk/srv.h" /*! @@ -51,8 +51,9 @@ struct ast_dnsmgr_entry; * * \return a DNS manager entry * \version 1.6.1 result changed from struct in_addr to struct sockaddr_in to store port number + * \version 1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support */ -struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct sockaddr_in *result, const char *service); +struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service); /*! * \brief Free a DNS manager entry @@ -67,7 +68,8 @@ void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry); * \brief Allocate and initialize a DNS manager entry * * \param name the hostname - * \param result where to store the IP address as the DNS manager refreshes it + * \param result where to store the IP address as the DNS manager refreshes it. The address family + * is used as an input parameter to filter the returned adresses. if it is 0, both IPv4 * and IPv6 addresses can be returned. * \param dnsmgr Where to store the allocate DNS manager entry * \param service * @@ -79,7 +81,7 @@ void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry); * \retval non-zero failure * \version 1.6.1 result changed from struct in_addr to struct aockaddr_in to store port number */ -int ast_dnsmgr_lookup(const char *name, struct sockaddr_in *result, struct ast_dnsmgr_entry **dnsmgr, const char *service); +int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service); /*! * \brief Force a refresh of a dnsmgr entry diff --git a/include/asterisk/netsock2.h b/include/asterisk/netsock2.h new file mode 100644 index 000000000..dd4fba97e --- /dev/null +++ b/include/asterisk/netsock2.h @@ -0,0 +1,523 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2010, Digium, Inc. + * + * Viagénie <asteriskv6@viagenie.ca> + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * \brief Network socket handling + */ + +#ifndef _ASTERISK_NETSOCK2_H +#define _ASTERISK_NETSOCK2_H + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +#include <sys/socket.h> + +#include <netinet/in.h> + +/*! + * Values for address families that we support. This is reproduced from socket.h + * because we do not want users to include that file. Only netsock2.c should + * ever include socket.h. + */ +enum { + AST_AF_UNSPEC = 0, + AST_AF_INET = 2, + AST_AF_INET6 = 10, +}; + +/*! + * Socket address structure. The first member is big enough to contain addresses + * of any family. The second member contains the length (in bytes) used in the + * first member. + * + * Some BSDs have the length embedded in sockaddr structs. We ignore them. + * (This is the right thing to do.) + */ +struct ast_sockaddr { + struct sockaddr_storage ss; + socklen_t len; +}; + +/*! + * \since 1.8 + * + * \brief + * Checks if the ast_sockaddr is null. "null" in this sense essentially + * means uninitialized, or having a 0 length. + * + * \param addr Pointer to the ast_sockaddr we wish to check + * \retval 1 \a addr is null + * \retval 0 \a addr is non-null. + */ +static inline int ast_sockaddr_isnull(const struct ast_sockaddr *addr) +{ + return addr->len == 0; +} + +/*! + * \since 1.8 + * + * \brief + * Sets address \a addr to null. + * + * \retval void + */ +static inline void ast_sockaddr_setnull(struct ast_sockaddr *addr) +{ + addr->len = 0; +} + +/*! + * \since 1.8 + * + * \brief + * Copies the data from one ast_sockaddr to another + * + * \param dst The destination ast_sockaddr + * \param src The source ast_sockaddr + * \retval void + */ +static inline void ast_sockaddr_copy(struct ast_sockaddr *dst, + const struct ast_sockaddr *src) +{ + memcpy(dst, src, src->len); + dst->len = src->len; +}; + +/*! + * \since 1.8 + * + * \brief + * Compares two ast_sockaddr structures + * + * \retval -1 \a a is lexicographically smaller than \a b + * \retval 0 \a a is equal to \a b + * \retval 1 \a b is lexicographically smaller than \a a + */ +int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b); + +/*! + * \since 1.8 + * + * \brief + * Compares the addresses of two ast_sockaddr structures. + * + * \retval -1 \a a is lexicographically smaller than \a b + * \retval 0 \a a is equal to \a b + * \retval 1 \a b is lexicographically smaller than \a a + */ +int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b); + +#define AST_SOCKADDR_STR_ADDR (1 << 0) +#define AST_SOCKADDR_STR_PORT (1 << 1) +#define AST_SOCKADDR_STR_BRACKETS (1 << 2) +#define AST_SOCKADDR_STR_HOST AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_BRACKETS +#define AST_SOCKADDR_STR_DEFAULT AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT + +/*! + * \since 1.8 + * + * \brief + * Convert a socket address to a string. + * + * \details + * This will be of the form a.b.c.d:xyz + * for IPv4 and [a:b:c:...:d]:xyz for IPv6. + * + * This function is thread-safe. The returned string is on static + * thread-specific storage. + * + * \param addr The input to be stringified + * \param format one of the following: + * AST_SOCKADDR_STR_DEFAULT: + * a.b.c.d:xyz for IPv4 + * [a:b:c:...:d]:xyz for IPv6. + * AST_SOCKADDR_STR_ADDR: address only + * a.b.c.d for IPv4 + * a:b:c:...:d for IPv6. + * AST_SOCKADDR_STR_HOST: address only, suitable for a URL + * a.b.c.d for IPv4 + * [a:b:c:...:d] for IPv6. + * AST_SOCKADDR_STR_PORT: port only + * \retval "(null)" \a addr is null + * \retval "" An error occurred during processing + * \retval string The stringified form of the address + */ +char *ast_sockaddr_stringify_fmt(const struct ast_sockaddr *addr, int format); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around ast_sockaddr_stringify_fmt() with default format + * + * \return same as ast_sockaddr_stringify_fmt() + */ +static inline char *ast_sockaddr_stringify(const struct ast_sockaddr *addr) +{ + return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT); +} + +/*! + * \since 1.8 + * + * \brief + * Wrapper around ast_sockaddr_stringify_fmt() to return an address only + * + * \return same as ast_sockaddr_stringify_fmt() + */ +static inline char *ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr) +{ + return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR); +} + +/*! + * \since 1.8 + * + * \brief + * Wrapper around ast_sockaddr_stringify_fmt() to return an address only, + * suitable for a URL (with brackets for IPv6). + * + * \return same as ast_sockaddr_stringify_fmt() + */ +static inline char *ast_sockaddr_stringify_host(const struct ast_sockaddr *addr) +{ + return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST); +} + +/*! + * \since 1.8 + * + * \brief + * Wrapper around ast_sockaddr_stringify_fmt() to return a port only + * + * \return same as ast_sockaddr_stringify_fmt() + */ +static inline char *ast_sockaddr_stringify_port(const struct ast_sockaddr *addr) +{ + return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_PORT); +} + +/*! + * \since 1.8 + * + * \brief + * Parse an IPv4 or IPv6 address string. + * + * \details + * Parses a string containing an IPv4 or IPv6 address followed by an optional + * port (separated by a colon) into a struct ast_sockaddr. The allowed formats + * are the following: + * + * a.b.c.d + * a.b.c.d:port + * a:b:c:...:d + * [a:b:c:...:d] + * [a:b:c:...:d]:port + * + * Host names are NOT allowed. + * + * \param[out] addr The resulting ast_sockaddr + * \param str The string to parse + * \param flags If set to zero, a port MAY be present. If set to + * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to + * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a + * port MUST NOT be present. + * + * \retval 1 Success + * \retval 0 Failure + */ +int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags); + +/*! + * \since 1.8 + * + * \brief + * Parses a string with an IPv4 or IPv6 address and place results into an array + * + * \details + * Parses a string containing a host name or an IPv4 or IPv6 address followed + * by an optional port (separated by a colon). The result is returned into a + * array of struct ast_sockaddr. Allowed formats for str are the following: + * + * hostname:port + * host.example.com:port + * a.b.c.d + * a.b.c.d:port + * a:b:c:...:d + * [a:b:c:...:d] + * [a:b:c:...:d]:port + * + * \param[out] addrs The resulting array of ast_sockaddrs + * \param str The string to parse + * \param flags If set to zero, a port MAY be present. If set to + * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to + * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a + * port MUST NOT be present. + * + * \param family Only addresses of the given family will be returned. Use 0 or + * AST_SOCKADDR_UNSPEC to get addresses of all families. + * + * \retval 0 Failure + * \retval non-zero The number of elements in addrs array. + */ +int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, + int flags, int family); + +/*! + * \since 1.8 + * + * \brief + * Get the port number of a socket address. + * + * \warning Do not use this function unless you really know what you are doing. + * And "I want the port number" is not knowing what you are doing. + * + * \retval 0 Address is null + * \retval non-zero The port number of the ast_sockaddr + */ +uint16_t ast_sockaddr_port(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Sets the port number of a socket address. + * + * \warning Do not use this function unless you really know what you are doing. + * And "I want the port number" is not knowing what you are doing. + * + * \param addr Address on which to set the port + * \param port The port you wish to set the address to use + * \retval void + */ +void ast_sockaddr_set_port(struct ast_sockaddr *addr, uint16_t port); + +/*! + * \since 1.8 + * + * \brief + * Get an IPv4 address of an ast_sockaddr + * + * \warning You should rarely need this function. Only use if you know what + * you're doing. + * \return IPv4 address in network byte order + */ +uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Determine if the address is an IPv4 address + * + * \warning You should rarely need this function. Only use if you know what + * you're doing. + * \retval 1 This is an IPv4 address + * \retval 0 This is an IPv6 or IPv4-mapped IPv6 address + */ +int ast_sockaddr_is_ipv4(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Determine if this is an IPv4-mapped IPv6 address + * + * \warning You should rarely need this function. Only use if you know what + * you're doing. + * + * \retval 1 This is an IPv4-mapped IPv6 address. + * \retval 0 This is not an IPv4-mapped IPv6 address. + */ +int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Determine if this is an IPv6 address + * + * \warning You should rarely need this function. Only use if you know what + * you're doing. + * + * \retval 1 This is an IPv6 or IPv4-mapped IPv6 address. + * \retval 0 This is an IPv4 address. + */ +int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Determine if the address type is unspecified, or "any" address. + * + * \details + * For IPv4, this would be the address 0.0.0.0, and for IPv6, + * this would be the address ::. The port number is ignored. + * + * \retval 1 This is an "any" address + * \retval 0 This is not an "any" address + */ +int ast_sockaddr_is_any(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Computes a hash value from the address. The port is ignored. + * + * \retval 0 Unknown address family + * \retval other A 32-bit hash derived from the address + */ +int ast_sockaddr_hash(const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around accept(2) that uses struct ast_sockaddr. + * + * \details + * For parameter and return information, see the man page for + * accept(2). + */ +int ast_accept(int sockfd, struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around bind(2) that uses struct ast_sockaddr. + * + * \details + * For parameter and return information, see the man page for + * bind(2). + */ +int ast_bind(int sockfd, const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around connect(2) that uses struct ast_sockaddr. + * + * \details + * For parameter and return information, see the man page for + * connect(2). + */ +int ast_connect(int sockfd, const struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around getsockname(2) that uses struct ast_sockaddr. + * + * \details + * For parameter and return information, see the man page for + * getsockname(2). + */ +int ast_getsockname(int sockfd, struct ast_sockaddr *addr); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around recvfrom(2) that uses struct ast_sockaddr. + * + * \details + * For parameter and return information, see the man page for + * recvfrom(2). + */ +ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags, + struct ast_sockaddr *src_addr); + +/*! + * \since 1.8 + * + * \brief + * Wrapper around sendto(2) that uses ast_sockaddr. + * + * \details + * For parameter and + * return information, see the man page for sendto(2) + */ +ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, + const struct ast_sockaddr *dest_addr); + +/*! + * \since 1.8 + * + * \brief + * Set type of service + * + * \details + * Set ToS ("Type of Service for IPv4 and "Traffic Class for IPv6) and + * CoS (Linux's SO_PRIORITY) + * + * \param sockfd File descriptor for socket on which to set the parameters + * \param tos The type of service for the socket + * \param cos The cost of service for the socket + * \param desc A text description of the socket in question. + * \retval 0 Success + * \retval -1 Error, with errno set to an appropriate value + */ +int ast_set_qos(int sockfd, int tos, int cos, const char *desc); + +/*! + * These are backward compatibility functions that may be used by subsystems + * that have not yet been converted to IPv6. They will be removed when all + * subsystems are IPv6-ready. + */ +/*@{*/ + +/*! + * \since 1.8 + * + * \brief + * Converts a struct ast_sockaddr to a struct sockaddr_in. + * + * \param addr The ast_sockaddr to convert + * \param[out] sin The resulting sockaddr_in struct + * \retval nonzero Success + * \retval zero Failure + */ +int ast_sockaddr_to_sin(const struct ast_sockaddr *addr, + struct sockaddr_in *sin); + +/*! + * \since 1.8 + * + * \brief + * Converts a struct sockaddr_in to a struct ast_sockaddr. + * + * \param sin The sockaddr_in to convert + * \return an ast_sockaddr structure + */ +void ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct sockaddr_in *sin); + +/*@}*/ + +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif + +#endif /* _ASTERISK_NETSOCK2_H */ diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h index cccf06a96..0a2fe7726 100644 --- a/include/asterisk/rtp_engine.h +++ b/include/asterisk/rtp_engine.h @@ -71,7 +71,7 @@ extern "C" { #include "asterisk/astobj2.h" #include "asterisk/frame.h" -#include "asterisk/netsock.h" +#include "asterisk/netsock2.h" #include "asterisk/sched.h" #include "asterisk/res_srtp.h" @@ -313,7 +313,7 @@ struct ast_rtp_engine { /*! Module this RTP engine came from, used for reference counting */ struct ast_module *mod; /*! Callback for setting up a new RTP instance */ - int (*new)(struct ast_rtp_instance *instance, struct sched_context *sched, struct sockaddr_in *sin, void *data); + int (*new)(struct ast_rtp_instance *instance, struct sched_context *sched, struct ast_sockaddr *sa, void *data); /*! Callback for destroying an RTP instance */ int (*destroy)(struct ast_rtp_instance *instance); /*! Callback for writing out a frame */ @@ -339,9 +339,9 @@ struct ast_rtp_engine { /*! Callback for setting packetization preferences */ void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref); /*! Callback for setting the remote address that RTP is to be sent to */ - void (*remote_address_set)(struct ast_rtp_instance *instance, struct sockaddr_in *sin); + void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa); /*! Callback for setting an alternate remote address */ - void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct sockaddr_in *sin); + void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa); /*! Callback for changing DTMF mode */ int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode); /*! Callback for retrieving statistics */ @@ -369,7 +369,7 @@ struct ast_rtp_engine { /*! Callback to indicate that packets will now flow */ int (*activate)(struct ast_rtp_instance *instance); /*! Callback to request that the RTP engine send a STUN BIND request */ - void (*stun_request)(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username); + void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username); /*! Callback to get the transcodeable formats supported */ int (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk); /*! Linked list information */ @@ -519,7 +519,7 @@ int ast_rtp_glue_unregister(struct ast_rtp_glue *glue); * * \param engine_name Name of the engine to use for the RTP instance * \param sched Scheduler context that the RTP engine may want to use - * \param sin Address we want to bind to + * \param sa Address we want to bind to * \param data Unique data for the engine * * \retval non-NULL success @@ -533,14 +533,16 @@ int ast_rtp_glue_unregister(struct ast_rtp_glue *glue); * \endcode * * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given - * in the sin structure. + * in the address structure. * * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use * another depending on it's own configuration. * * \since 1.8 */ -struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, struct sockaddr_in *sin, void *data); +struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name, + struct sched_context *sched, const struct ast_sockaddr *sa, + void *data); /*! * \brief Destroy an RTP instance @@ -663,7 +665,8 @@ struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int r * * \since 1.8 */ -int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address); +int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address); + /*! * \brief Set the address of an an alternate RTP address to receive from @@ -677,7 +680,7 @@ int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struc * Example usage: * * \code - * ast_rtp_instance_set_alt_remote_address(instance, &sin); + * ast_rtp_instance_set_alt_remote_address(instance, &address); * \endcode * * This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin @@ -685,7 +688,7 @@ int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struc * * \since 1.8 */ -int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address); +int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address); /*! * \brief Set the address that we are expecting to receive RTP on @@ -707,7 +710,8 @@ int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, s * * \since 1.8 */ -int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address); +int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, + const struct ast_sockaddr *address); /*! * \brief Get the local address that we are expecting RTP on @@ -721,15 +725,15 @@ int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, struct * Example usage: * * \code - * struct sockaddr_in sin; - * ast_rtp_instance_get_local_address(instance, &sin); + * struct ast_sockaddr address; + * ast_rtp_instance_get_local_address(instance, &address); * \endcode * - * This gets the local address that we are expecting RTP on and stores it in the 'sin' structure. + * This gets the local address that we are expecting RTP on and stores it in the 'address' structure. * * \since 1.8 */ -int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address); +int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address); /*! * \brief Get the address of the remote endpoint that we are sending RTP to @@ -743,16 +747,16 @@ int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct * Example usage: * * \code - * struct sockaddr_in sin; - * ast_rtp_instance_get_remote_address(instance, &sin); + * struct ast_sockaddr address; + * ast_rtp_instance_get_remote_address(instance, &address); * \endcode * * This retrieves the current remote address set on the instance pointed to by instance and puts the value - * into the sin structure. + * into the address structure. * * \since 1.8 */ -int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address); +int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address); /*! * \brief Set the value of an RTP instance extended property @@ -1598,7 +1602,7 @@ int ast_rtp_instance_activate(struct ast_rtp_instance *instance); * * \since 1.8 */ -void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username); +void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username); /*! * \brief Set the RTP timeout value diff --git a/include/asterisk/tcptls.h b/include/asterisk/tcptls.h index ad0438583..2cc2c0fa3 100644 --- a/include/asterisk/tcptls.h +++ b/include/asterisk/tcptls.h @@ -48,6 +48,7 @@ #ifndef _ASTERISK_TCPTLS_H #define _ASTERISK_TCPTLS_H +#include "asterisk/netsock2.h" #include "asterisk/utils.h" #if defined(HAVE_OPENSSL) && (defined(HAVE_FUNOPEN) || defined(HAVE_FOPENCOOKIE)) @@ -120,9 +121,9 @@ struct ast_tls_config { * arguments for the accepting thread */ struct ast_tcptls_session_args { - struct sockaddr_in local_address; - struct sockaddr_in old_address; /*!< copy of the local or remote address depending on if its a client or server session */ - struct sockaddr_in remote_address; + struct ast_sockaddr local_address; + struct ast_sockaddr old_address; /*!< copy of the local or remote address depending on if its a client or server session */ + struct ast_sockaddr remote_address; char hostname[MAXHOSTNAMELEN]; /*!< only necessary for SSL clients so we can compare to common name */ struct ast_tls_config *tls_cfg; /*!< points to the SSL configuration if any */ int accept_fd; @@ -143,7 +144,7 @@ struct ast_tcptls_session_instance { SSL *ssl; /* ssl state */ /* iint (*ssl_setup)(SSL *); */ int client; - struct sockaddr_in remote_address; + struct ast_sockaddr remote_address; struct ast_tcptls_session_args *parent; ast_mutex_t lock; }; |