[asterisk-commits] branch north/chan_skinny-fixup r34695 - /team/north/chan_skinny-fixup/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Jun 18 15:20:09 MST 2006


Author: north
Date: Sun Jun 18 17:20:09 2006
New Revision: 34695

URL: http://svn.digium.com/view/asterisk?rev=34695&view=rev
Log:
Some more address fixes.

Thanks to Simon Lockhart,
for giving me an idea on how to get the IP the device is connecting to us on

Modified:
    team/north/chan_skinny-fixup/channels/chan_skinny.c

Modified: team/north/chan_skinny-fixup/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/north/chan_skinny-fixup/channels/chan_skinny.c?rev=34695&r1=34694&r2=34695&view=diff
==============================================================================
--- team/north/chan_skinny-fixup/channels/chan_skinny.c (original)
+++ team/north/chan_skinny-fixup/channels/chan_skinny.c Sun Jun 18 17:20:09 2006
@@ -1813,8 +1813,6 @@
 		d->lastlineinstance = 1;
 		while(v) {
 			if (!strcasecmp(v->name, "host")) {
-				/* In Dec '04, this option was made useless, since ast_getaddrfor now only supports SIP */
-				/* XXX We should probably document this fact or remove this functionality. */
 				if (ast_get_ip(&d->addr, v->value)) {
 					free(d);
 					return NULL;
@@ -1958,9 +1956,11 @@
 			ast_log(LOG_ERROR, "A Skinny device must have at least one line!\n");
 			return NULL;
 		}
-		if (d->addr.sin_addr.s_addr && !ntohs(d->addr.sin_port)) {
+		if (/*d->addr.sin_addr.s_addr && */!ntohs(d->addr.sin_port)) {
 			d->addr.sin_port = htons(DEFAULT_SKINNY_PORT);
 		}
+#if 0
+		/* I don't think we need this anymore at all, since d->ourip is set in skinny_register now */
 		if (d->addr.sin_addr.s_addr) {
 			/* XXX See note above, in 'host' option. */
 			if (ast_ouraddrfor(&d->addr.sin_addr, &d->ourip)) {
@@ -1969,6 +1969,7 @@
 		} else {
 			d->ourip = __ourip;
 		}
+#endif
 	}
 	return d;
 }
@@ -1976,6 +1977,8 @@
 static int skinny_register(skinny_req *req, struct skinnysession *s)
 {
 	struct skinny_device *d;
+	struct sockaddr_in sin;
+	socklen_t slen;
 
 	ast_mutex_lock(&devicelock);
 	for (d = devices; d; d = d->next) {
@@ -1988,6 +1991,13 @@
 			}
 			d->registered = 1;
 			d->session = s;
+
+			slen = sizeof(sin);
+			if (getsockname(s->fd, (struct sockaddr *)&sin, &slen)) {
+				ast_log(LOG_WARNING, "Cannot get socket name\n");
+				sin.sin_addr = __ourip;
+			}
+			d->ourip = sin.sin_addr;
 			break;
 		}
 	}



More information about the asterisk-commits mailing list