[svn-commits] seanbright: branch seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_se...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Feb 29 16:35:13 CST 2012
Author: seanbright
Date: Wed Feb 29 16:35:09 2012
New Revision: 357654
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=357654
Log:
Add ast_sockaddr_get_wildcard_addrs() - name, functionality, and existance
subject to change barring review.
Modified:
team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/include/asterisk/netsock2.h
team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/main/netsock2.c
Modified: team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/include/asterisk/netsock2.h
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/include/asterisk/netsock2.h?view=diff&rev=357654&r1=357653&r2=357654
==============================================================================
--- team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/include/asterisk/netsock2.h (original)
+++ team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/include/asterisk/netsock2.h Wed Feb 29 16:35:09 2012
@@ -358,6 +358,28 @@
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags);
/*!
+ * \since 11
+ *
+ * \brief
+ * Returns a list of local IPv4 and IPv6 wildcard addresses.
+ *
+ * \details
+ * Given an address family, returns a list wildcard addresses suitable for
+ * passing to ast_bind(). If AST_AF_UNSPEC is passed, IPv4 addresses are only
+ * returned if IPv4 is configured on the current host, and IPv6 addresses are
+ * only returned if IPv6 is configured on the current host.
+ *
+ * \details
+ * \param[out] addrs The resulting array of ast_sockaddrs
+ * \param family Only addresses of the given family will be returned. Use 0 or
+ * AST_AF_UNSPEC to get addresses of all families.
+ *
+ * \retval 1 Success
+ * \retval 0 Failure
+ */
+int ast_sockaddr_get_wildcard_addrs(struct ast_sockaddr **addrs, int family);
+
+/*!
* \since 1.8
*
* \brief
Modified: team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/main/netsock2.c?view=diff&rev=357654&r1=357653&r2=357654
==============================================================================
--- team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/main/netsock2.c (original)
+++ team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/main/netsock2.c Wed Feb 29 16:35:09 2012
@@ -239,6 +239,41 @@
return 1;
}
+int ast_sockaddr_get_wildcard_addrs(struct ast_sockaddr **addrs, int family)
+{
+ struct addrinfo hints, *res, *ai;
+ int e, i, res_cnt;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+ hints.ai_family = family;
+ hints.ai_socktype = SOCK_DGRAM;
+
+ if ((e = getaddrinfo(NULL, NULL, &hints, &res))) {
+ ast_log(LOG_ERROR, "getaddrinfo(NULL, NULL, ...): %s\n",
+ gai_strerror(e));
+ return 0;
+ }
+
+ for (ai = res, res_cnt = 0; ai; ai = ai->ai_next) {
+ res_cnt++;
+ }
+
+ if ((*addrs = ast_malloc(res_cnt * sizeof(struct ast_sockaddr))) == NULL) {
+ res_cnt = 0;
+ goto cleanup;
+ }
+
+ for (ai = res, i = 0; ai; ai = ai->ai_next, i++) {
+ (*addrs)[i].len = ai->ai_addrlen;
+ memcpy(&(*addrs)[i].ss, ai->ai_addr, ai->ai_addrlen);
+ }
+
+cleanup:
+ freeaddrinfo(res);
+ return res_cnt;
+}
+
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str,
int flags, int family)
{
More information about the svn-commits
mailing list