[asterisk-commits] rizzo: branch rizzo/astobj2 r75564 - /team/rizzo/astobj2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 18 08:24:33 CDT 2007


Author: rizzo
Date: Wed Jul 18 08:24:33 2007
New Revision: 75564

URL: http://svn.digium.com/view/asterisk?view=rev&rev=75564
Log:
simplify the parsing of via: using ast_parse_arg()


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=75564&r1=75563&r2=75564
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Jul 18 08:24:33 2007
@@ -9927,9 +9927,7 @@
 static void check_via(struct sip_pvt *p, struct sip_request *req)
 {
 	char via[256];
-	char *c, *pt;
-	struct hostent *hp;
-	struct ast_hostent ahp;
+	char *c;
 
 	ast_copy_string(via, get_header(req, "Via"), sizeof(via));
 
@@ -9949,24 +9947,20 @@
 
 	c = strchr(via, ' ');
 	if (c) {
+		struct sockaddr_in sa;
 		*c = '\0';
 		c = ast_skip_blanks(c+1);
 		if (strcasecmp(via, "SIP/2.0/UDP")) {
 			ast_log(LOG_WARNING, "Don't know how to respond via '%s'\n", via);
 			return;
 		}
-		pt = strchr(c, ':');
-		if (pt)
-			*pt++ = '\0';	/* remember port pointer */
-		hp = ast_gethostbyname(c, &ahp);
-		if (!hp) {
+		bzero(&sa, sizeof(sa));
+		sa.sin_port = htons(STANDARD_SIP_PORT);
+		if (ast_parse_arg(c, PARSE_INADDR, &sa)) {
 			ast_log(LOG_WARNING, "'%s' is not a valid host\n", c);
 			return;
 		}
-		memset(&p->sa, 0, sizeof(p->sa));
-		p->sa.sin_family = AF_INET;
-		memcpy(&p->sa.sin_addr, hp->h_addr, sizeof(p->sa.sin_addr));
-		p->sa.sin_port = htons(pt ? atoi(pt) : STANDARD_SIP_PORT);
+		p->sa = sa;
 
 		if (sip_debug_test_pvt(p)) {
 			const struct sockaddr_in *dst = sip_real_dst(p);




More information about the asterisk-commits mailing list