[asterisk-commits] dvossel: branch 1.6.2 r280551 - /branches/1.6.2/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 29 15:42:34 CDT 2010
Author: dvossel
Date: Thu Jul 29 15:42:29 2010
New Revision: 280551
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=280551
Log:
fixes wrong SRV query for TLS connection
(closes issue #17612)
Reported by: marcelloceschia
Patches:
chan-sip_srvQuery.patch uploaded by marcelloceschia (license 1079)
chan-sip_Trunk_srvQuery.patch uploaded by st (license 907)
chan-sip_asterisk18b1_srvQuery.patch uploaded by marcelloceschia (license 1079)
Tested by: marcelloceschia, st, pabelanger
Modified:
branches/1.6.2/channels/chan_sip.c
Modified: branches/1.6.2/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/channels/chan_sip.c?view=diff&rev=280551&r1=280550&r2=280551
==============================================================================
--- branches/1.6.2/channels/chan_sip.c (original)
+++ branches/1.6.2/channels/chan_sip.c Thu Jul 29 15:42:29 2010
@@ -3527,6 +3527,33 @@
return "UNKNOWN";
}
+/*! \brief Return protocol string for srv dns query */
+static inline const char *get_srv_protocol(enum sip_transport t)
+{
+ switch (t) {
+ case SIP_TRANSPORT_UDP:
+ return "udp";
+ case SIP_TRANSPORT_TLS:
+ case SIP_TRANSPORT_TCP:
+ return "tcp";
+ }
+
+ return "udp";
+}
+
+/*! \brief Return service string for srv dns query */
+static inline const char *get_srv_service(enum sip_transport t)
+{
+ switch (t) {
+ case SIP_TRANSPORT_TCP:
+ case SIP_TRANSPORT_UDP:
+ return "sip";
+ case SIP_TRANSPORT_TLS:
+ return "sips";
+ }
+ return "sip";
+}
+
/*! \brief Return transport of dialog.
\note this is based on a false assumption. We don't always use the
outbound proxy for all requests in a dialog. It depends on the
@@ -5316,8 +5343,9 @@
if (!port && sip_cfg.srvlookup) {
char service[MAXHOSTNAMELEN];
int tportno;
-
- snprintf(service, sizeof(service), "_sip._%s.%s", get_transport(dialog->socket.type), peername);
+ snprintf(service, sizeof(service), "_%s._%s.%s",
+ get_srv_service(dialog->socket.type),
+ get_srv_protocol(dialog->socket.type), peername);
srv_ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service);
if (srv_ret > 0) {
hostn = host;
@@ -11041,7 +11069,7 @@
/* If we have no DNS manager let's do a lookup */
if (!mwi->dnsmgr) {
char transport[MAXHOSTNAMELEN];
- snprintf(transport, sizeof(transport), "_sip._%s", get_transport(mwi->transport));
+ snprintf(transport, sizeof(transport), "_%s._%s", get_srv_service(mwi->transport), get_srv_protocol(mwi->transport));
ast_dnsmgr_lookup(mwi->hostname, &mwi->us, &mwi->dnsmgr, sip_cfg.srvlookup ? transport : NULL);
}
@@ -11642,7 +11670,7 @@
if (r->dnsmgr == NULL) {
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 */
+ snprintf(transport, sizeof(transport), "_%s._%s",get_srv_service(r->transport), get_srv_protocol(r->transport)); /* have to use static get_transport function */
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");
@@ -24300,7 +24328,7 @@
*params++ = '\0';
}
- snprintf(transport, sizeof(transport), "_sip._%s", get_transport(peer->socket.type));
+ snprintf(transport, sizeof(transport), "_%s._%s", get_srv_service(peer->socket.type), get_srv_protocol(peer->socket.type));
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);
More information about the asterisk-commits
mailing list