[asterisk-commits] jpdionne: branch group/v6-new r271299 - in /team/group/v6-new: channels/ incl...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 17 16:22:52 CDT 2010
Author: jpdionne
Date: Thu Jun 17 16:22:49 2010
New Revision: 271299
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=271299
Log:
DNS resolution returns addresses according to the family of the udp sip socket.
- bindaddr=[::], the resolved addresses can be IPv6 or IPv4.
- bindaddr=a.b.c.d, the resolved addresses are IPv4 only.
- bindaddr=[i:p:v:6], the resolved addresses are IPv6 only.
Modified:
team/group/v6-new/channels/chan_sip.c
team/group/v6-new/include/asterisk/acl.h
team/group/v6-new/include/asterisk/dnsmgr.h
team/group/v6-new/main/acl.c
team/group/v6-new/main/dnsmgr.c
Modified: team/group/v6-new/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/channels/chan_sip.c?view=diff&rev=271299&r1=271298&r2=271299
==============================================================================
--- team/group/v6-new/channels/chan_sip.c (original)
+++ team/group/v6-new/channels/chan_sip.c Thu Jun 17 16:22:49 2010
@@ -1256,6 +1256,7 @@
static int handle_request_do(struct sip_request *req, struct ast_sockaddr *addr);
static int sip_standard_port(enum sip_transport type, int port);
static int sip_prepare_socket(struct sip_pvt *p);
+static int get_address_family_filter(const struct ast_sockaddr *addr);
/*--- Transmitting responses and requests */
static int sipsock_read(int *id, int fd, short events, void *ignore);
@@ -2857,6 +2858,7 @@
if (!ast_sockaddr_parse(&proxy->ip, proxy->name, 0)) {
/* Ok, not an IP address, then let's check if it's a domain or host */
/* XXX Todo - if we have proxy port, don't do SRV */
+ proxy->ip.ss.ss_family = get_address_family_filter(&bindaddr); /* Filter address family */
if (ast_get_ip_or_srv(&proxy->ip, proxy->name, sip_cfg.srvlookup ? "_sip._udp" : NULL) < 0) {
ast_log(LOG_WARNING, "Unable to locate host '%s'\n", proxy->name);
return FALSE;
@@ -11073,6 +11075,8 @@
if (!mwi->dnsmgr) {
char transport[MAXHOSTNAMELEN];
snprintf(transport, sizeof(transport), "_sip._%s", get_transport(mwi->transport));
+
+ mwi->us.ss.ss_family = get_address_family_filter(&bindaddr); /* Filter address family */
ast_dnsmgr_lookup(mwi->hostname, &mwi->us, &mwi->dnsmgr, sip_cfg.srvlookup ? transport : NULL);
}
@@ -11788,6 +11792,7 @@
char transport[MAXHOSTNAMELEN];
peer = find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0);
snprintf(transport, sizeof(transport), "_sip._%s", get_transport(r->transport)); /* have to use static get_transport function */
+ r->us.ss.ss_family = get_address_family_filter(&bindaddr); /* Filter address family */
ast_dnsmgr_lookup(peer ? peer->tohost : r->hostname, &r->us, &r->dnsmgr, sip_cfg.srvlookup ? transport : NULL);
if (peer) {
peer = unref_peer(peer, "removing peer ref for dnsmgr_lookup");
@@ -23484,6 +23489,17 @@
}
return tcptls_instance;
+}
+
+/*!
+ * \brief Helper for dns resolution to filter by address family.
+ *
+ * \note return 0 if addr is [::] else it returns addr's family.
+ */
+int get_address_family_filter(const struct ast_sockaddr *addr) {
+ if (ast_sockaddr_is_ipv6(addr) && ast_sockaddr_is_any(addr))
+ return 0;
+ return addr->ss.ss_family;
}
/*! \todo Get socket for dialog, prepare if needed, and return file handle */
@@ -25672,6 +25688,7 @@
snprintf(transport, sizeof(transport), "_sip._%s", get_transport(peer->socket.type));
+ peer->addr.ss.ss_family = get_address_family_filter(&bindaddr); /* Filter address family */
if (ast_dnsmgr_lookup(_srvlookup, &peer->addr, &peer->dnsmgr, sip_cfg.srvlookup && !peer->portinuri ? transport : NULL)) {
ast_log(LOG_ERROR, "srvlookup failed for host: %s, on peer %s, removing peer\n", _srvlookup, peer->name);
unref_peer(peer, "getting rid of a peer pointer");
Modified: team/group/v6-new/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/include/asterisk/acl.h?view=diff&rev=271299&r1=271298&r2=271299
==============================================================================
--- team/group/v6-new/include/asterisk/acl.h (original)
+++ team/group/v6-new/include/asterisk/acl.h Thu Jun 17 16:22:49 2010
@@ -142,7 +142,10 @@
* 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] addr The IP address found
+ * \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
Modified: team/group/v6-new/include/asterisk/dnsmgr.h
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/include/asterisk/dnsmgr.h?view=diff&rev=271299&r1=271298&r2=271299
==============================================================================
--- team/group/v6-new/include/asterisk/dnsmgr.h (original)
+++ team/group/v6-new/include/asterisk/dnsmgr.h Thu Jun 17 16:22:49 2010
@@ -66,7 +66,8 @@
* \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
*
Modified: team/group/v6-new/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/main/acl.c?view=diff&rev=271299&r1=271298&r2=271299
==============================================================================
--- team/group/v6-new/main/acl.c (original)
+++ team/group/v6-new/main/acl.c Thu Jun 17 16:22:49 2010
@@ -392,7 +392,7 @@
}
}
- addrs_cnt = ast_sockaddr_resolve(&addrs, value, PARSE_PORT_FORBID, 0);
+ addrs_cnt = ast_sockaddr_resolve(&addrs, value, PARSE_PORT_FORBID, addr->ss.ss_family);
if (addrs_cnt > 0) {
if (addrs_cnt > 1)
ast_log(LOG_WARNING, "Multiple addresses. Using the first only\n");
Modified: team/group/v6-new/main/dnsmgr.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/main/dnsmgr.c?view=diff&rev=271299&r1=271298&r2=271299
==============================================================================
--- team/group/v6-new/main/dnsmgr.c (original)
+++ team/group/v6-new/main/dnsmgr.c Thu Jun 17 16:22:49 2010
@@ -126,11 +126,6 @@
return -1;
if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name))
- return 0;
-
- /* if it's actually an IP address and not a name,
- there's no need for a managed lookup */
- if (ast_sockaddr_parse(result, name, PARSE_PORT_FORBID))
return 0;
ast_verb(4, "doing dnsmgr_lookup for '%s'\n", name);
More information about the asterisk-commits
mailing list