[asterisk-commits] jpeeler: branch jpeeler/sip-dnsmgr r111596 - in /team/jpeeler/sip-dnsmgr: cha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 27 21:01:42 CDT 2008
Author: jpeeler
Date: Thu Mar 27 21:01:41 2008
New Revision: 111596
URL: http://svn.digium.com/view/asterisk?view=rev&rev=111596
Log:
bleh, change of dns srv record port number is not reflected, save work anyway
Modified:
team/jpeeler/sip-dnsmgr/channels/chan_sip.c
team/jpeeler/sip-dnsmgr/main/dnsmgr.c
Modified: team/jpeeler/sip-dnsmgr/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/sip-dnsmgr/channels/chan_sip.c?view=diff&rev=111596&r1=111595&r2=111596
==============================================================================
--- team/jpeeler/sip-dnsmgr/channels/chan_sip.c (original)
+++ team/jpeeler/sip-dnsmgr/channels/chan_sip.c Thu Mar 27 21:01:41 2008
@@ -4079,9 +4079,11 @@
if (peer) {
int res = create_addr_from_peer(dialog, peer);
+ ast_log(LOG_DEBUG, "Peer found\n");
unref_peer(peer);
return res;
} else {
+ ast_log(LOG_DEBUG, "Peer NOT found\n");
/* Setup default parameters for this dialog's socket. Currently we only support regular UDP SIP as the default */
dialog->socket.type = SIP_TRANSPORT_UDP;
dialog->socket.port = bindaddr.sin_port;
@@ -4099,7 +4101,8 @@
/* This address should be updated using dnsmgr */
if (sin) {
memcpy(&dialog->sa.sin_addr, &sin->sin_addr, sizeof(dialog->sa.sin_addr));
- portno = htons(sin->sin_port);
+ portno = ntohs(sin->sin_port);
+ ast_log(LOG_DEBUG, "DNS manager address showing portno=%d\n", portno);
} else {
/* Let's see if we can find the host in DNS. First try DNS SRV records,
@@ -4130,6 +4133,8 @@
dialog->sa.sin_port = htons(portno);
dialog->recv = dialog->sa;
+
+ ast_log(LOG_DEBUG, "Wow... trying again, port=%d\n", ntohs(dialog->sa.sin_port));
return 0;
}
@@ -9223,7 +9228,9 @@
ast_log(LOG_DEBUG, "hostname: %s portno:%d sin_family:%d\n", r->hostname, r->portno, r->us.sin_family);
ast_dnsmgr_lookup_srv(r->hostname, &r->us.sin_addr, &r->us.sin_port, &r->dnsmgr, service);
ast_log(LOG_DEBUG, "after dnsmgr lookup port=%d\n", htons(r->us.sin_port));
- }
+ } else {
+ ast_log(LOG_DEBUG, "DNS manager detected, r->us.sin_addr=%s r->us.sin_port=%d\n", ast_inet_ntoa(r->us.sin_addr), ntohs(r->us.sin_port));
+ }
if (r->call) { /* We have a registration */
if (!auth) {
Modified: team/jpeeler/sip-dnsmgr/main/dnsmgr.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/sip-dnsmgr/main/dnsmgr.c?view=diff&rev=111596&r1=111595&r2=111596
==============================================================================
--- team/jpeeler/sip-dnsmgr/main/dnsmgr.c (original)
+++ team/jpeeler/sip-dnsmgr/main/dnsmgr.c Thu Mar 27 21:01:41 2008
@@ -115,6 +115,7 @@
strcpy(entry->name, name);
strcpy(entry->service, service);
memcpy(&entry->last, result, sizeof(entry->last));
+ //ast_log(LOG_DEBUG, "address of entry->last=%p",
entry->last_portno = *portno;
entry->dnssrv = 1;
@@ -199,7 +200,7 @@
char buf[INET_ADDRSTRLEN];
hp = ast_gethostbyname(realhostname, &ahp);
*result_portno = htons((unsigned int)real_portno);
- ast_log(LOG_DEBUG, "name=%s realhostname=%s result_portno=%d hp->h_addr=%s\n", name, realhostname, *result_portno, inet_ntop(AF_INET, hp->h_addr, buf, sizeof(buf)));
+ ast_log(LOG_DEBUG, "name=%s realhostname=%s result_portno=%d hp->h_addr=%s\n", name, realhostname, ntohs(*result_portno), inet_ntop(AF_INET, hp->h_addr, buf, sizeof(buf)));
//result_addr->sin_port = *result_portno;
} else {
hp = ast_gethostbyname(name, &ahp);
@@ -246,16 +247,25 @@
if (srv_ret > 0) {
if ((hp = ast_gethostbyname(realhostname, &ahp))) {
memcpy(&tmp, hp->h_addr, sizeof(tmp));
- if (tmp.s_addr != entry->last.s_addr) {
+ if (tmp.s_addr != entry->last.s_addr || real_portno != ntohs(entry->last_portno)) {
+
+ if (tmp.s_addr != entry->last.s_addr)
+ ast_log(LOG_DEBUG, "tmp != entry\n");
+ if (real_portno != ntohs(entry->last_portno))
+ ast_log(LOG_DEBUG, "real_portno != entry->last_portno\n");
+
+
+
ast_copy_string(iabuf, ast_inet_ntoa(entry->last), sizeof(iabuf));
ast_copy_string(iabuf2, ast_inet_ntoa(tmp), sizeof(iabuf2));
- ast_log(LOG_NOTICE, "host '%s' changed from %s to %s\n",
- entry->name, iabuf, iabuf2);
+ ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s:%d to %s:%d\n",
+ entry->name, iabuf, ntohs(entry->last_portno), iabuf2, real_portno);
memcpy(entry->result, hp->h_addr, sizeof(entry->result));
memcpy(&entry->last, hp->h_addr, sizeof(entry->last));
entry->result_portno = htons((unsigned int)real_portno);
entry->last_portno = htons((unsigned int)real_portno);
+ ast_log(LOG_DEBUG, "Verifying that new port has been accounted for, new port = %d\n", ntohs(entry->last_portno));
changed = entry->changed = 1;
}
}
More information about the asterisk-commits
mailing list