[asterisk-commits] simon.perreault: branch group/v6-new r272524 - /team/group/v6-new/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 25 08:36:58 CDT 2010


Author: simon.perreault
Date: Fri Jun 25 08:36:55 2010
New Revision: 272524

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=272524
Log:
Converted chan_mgcp to new IPv6-enabled API using casts.

Modified:
    team/group/v6-new/channels/chan_mgcp.c

Modified: team/group/v6-new/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/channels/chan_mgcp.c?view=diff&rev=272524&r1=272523&r2=272524
==============================================================================
--- team/group/v6-new/channels/chan_mgcp.c (original)
+++ team/group/v6-new/channels/chan_mgcp.c Fri Jun 25 08:36:55 2010
@@ -1769,8 +1769,18 @@
 				if ((g->addr.sin_addr.s_addr != sin->sin_addr.s_addr) ||
 					(g->addr.sin_port != sin->sin_port)) {
 					memcpy(&g->addr, sin, sizeof(g->addr));
-					if (ast_ouraddrfor(&g->addr.sin_addr, &g->ourip))
-						memcpy(&g->ourip, &__ourip, sizeof(g->ourip));
+					{
+						struct ast_sockaddr tmp1, tmp2;
+						struct sockaddr_in tmp3 = {0,};
+
+						tmp3.sin_addr = g->ourip;
+						tmp1 = ast_sockaddr_from_sin(g->addr);
+						tmp2 = ast_sockaddr_from_sin(tmp3);
+						if (ast_ouraddrfor(&tmp1, &tmp2))
+							memcpy(&g->ourip, &__ourip, sizeof(g->ourip));
+						ast_sockaddr_to_sin(&tmp2, &tmp3);
+						g->ourip = tmp3.sin_addr;
+					}
 					ast_verb(3, "Registered MGCP gateway '%s' at %s port %d\n", g->name, ast_inet_ntoa(g->addr.sin_addr), ntohs(g->addr.sin_port));
 				}
 			/* not dynamic, check if the name matches */
@@ -3978,22 +3988,32 @@
 				/* Non-dynamic.  Make sure we become that way if we're not */
 				AST_SCHED_DEL(sched, gw->expire);
 				gw->dynamic = 0;
-				if (ast_get_ip(&gw->addr, v->value)) {
-					if (!gw_reload) {
-						ast_mutex_destroy(&gw->msgs_lock);
-						ast_free(gw);
+				{
+					struct ast_sockaddr tmp;
+
+					tmp = ast_sockaddr_from_sin(gw->addr);
+					if (ast_get_ip(&tmp, v->value)) {
+						if (!gw_reload) {
+							ast_mutex_destroy(&gw->msgs_lock);
+							ast_free(gw);
+						}
+						return NULL;
 					}
-					return NULL;
+					ast_sockaddr_to_sin(&tmp, &gw->addr);
 				}
 			}
 		} else if (!strcasecmp(v->name, "defaultip")) {
-			if (ast_get_ip(&gw->defaddr, v->value)) {
+			struct ast_sockaddr tmp;
+
+			tmp = ast_sockaddr_from_sin(gw->defaddr);
+			if (ast_get_ip(&tmp, v->value)) {
 				if (!gw_reload) {
 					ast_mutex_destroy(&gw->msgs_lock);
 					ast_free(gw);
 				}
 				return NULL;
 			}
+			ast_sockaddr_to_sin(&tmp, &gw->defaddr);
 		} else if (!strcasecmp(v->name, "permit") ||
 			!strcasecmp(v->name, "deny")) {
 			gw->ha = ast_append_ha(v->name, v->value, gw->ha, NULL);
@@ -4336,8 +4356,19 @@
 		if (gw->addr.sin_addr.s_addr && !ntohs(gw->addr.sin_port)) {
 			gw->addr.sin_port = htons(DEFAULT_MGCP_GW_PORT);
 		}
-		if (gw->addr.sin_addr.s_addr && ast_ouraddrfor(&gw->addr.sin_addr, &gw->ourip)) {
-			memcpy(&gw->ourip, &__ourip, sizeof(gw->ourip));
+		{
+			struct ast_sockaddr tmp1, tmp2;
+			struct sockaddr_in tmp3 = {0,};
+
+			tmp3.sin_addr = gw->ourip;
+			tmp1 = ast_sockaddr_from_sin(gw->addr);
+			tmp2 = ast_sockaddr_from_sin(tmp3);
+			if (gw->addr.sin_addr.s_addr && ast_ouraddrfor(&tmp1, &tmp2)) {
+				memcpy(&gw->ourip, &__ourip, sizeof(gw->ourip));
+			} else {
+				ast_sockaddr_to_sin(&tmp2, &tmp3);
+				gw->ourip = tmp3.sin_addr;
+			}
 		}
 	}
 




More information about the asterisk-commits mailing list