Browse code

- ipv6 fixes ( backported after testing on HEAD) - version no. is now 0.8.11rc1 (release candidate 1)

Andrei Pelinescu-Onciul authored on 10/07/2003 15:56:59
Showing 3 changed files
... ...
@@ -40,7 +40,7 @@ export makefile_defs
40 40
 VERSION = 0
41 41
 PATCHLEVEL = 8
42 42
 SUBLEVEL =   11
43
-EXTRAVERSION = pre40
43
+EXTRAVERSION = rc1
44 44
 
45 45
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
46 46
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -48,6 +48,10 @@
48 48
  *              => ip:port;transport=proto (andrei)
49 49
  * 2003-04-12  added FL_FORCE_RPORT support (andrei)
50 50
  * 2003-04-13  updated warning builder -- fixed (andrei)
51
+ * 2003-07-10  check_via_address knows now how to compare with ipv6 address
52
+ *              references (e.g [::1]) (andrei)
53
+ *             build_req_fomr_sip_req no longer adds 1 for ipv6 via parameter
54
+ *              position calculations ([] are part of host.s now) (andrei)
51 55
  *
52 56
  */
53 57
 /* Via special params:
... ...
@@ -148,15 +152,25 @@ static int check_via_address(struct ip_addr* ip, str *name,
148 152
 	struct hostent* he;
149 153
 	int i;
150 154
 	char* s;
155
+	int len;
151 156
 
152 157
 	/* maybe we are lucky and name it's an ip */
153 158
 	s=ip_addr2a(ip);
154 159
 	if (s){
155
-		DBG("check_address(%s, %.*s, %d)\n", 
160
+		DBG("check_via_address(%s, %.*s, %d)\n", 
156 161
 			s, name->len, name->s, resolver);
162
+		len=strlen(s);
157 163
 
158 164
 	#ifdef USE_IPV6
159
-		if ((ip->af==AF_INET6) && (strncasecmp(name->s, s, name->len)==0))
165
+		/* check if name->s is an ipv6 address or an ipv6 address ref. */
166
+		if ((ip->af==AF_INET6) &&
167
+				(	((len==name->len)&&(strncasecmp(name->s, s, name->len)==0))
168
+					||
169
+					((len==(name->len-2))&&(name->s[0]=='[')&&
170
+						(name->s[name->len-1]==']')&&
171
+						(strncasecmp(name->s+1, s, len)==0))
172
+				)
173
+		   )
160 174
 			return 0;
161 175
 		else
162 176
 	#endif
... ...
@@ -164,13 +178,13 @@ static int check_via_address(struct ip_addr* ip, str *name,
164 178
 			if (strncmp(name->s, s, name->len)==0) 
165 179
 				return 0;
166 180
 	}else{
167
-		LOG(L_CRIT, "check_address: BUG: could not convert ip address\n");
181
+		LOG(L_CRIT, "check_via_address: BUG: could not convert ip address\n");
168 182
 		return -1;
169 183
 	}
170 184
 
171 185
 	if (port==0) port=SIP_PORT;
172 186
 	if (resolver&DO_DNS){
173
-		DBG("check_address: doing dns lookup\n");
187
+		DBG("check_via_address: doing dns lookup\n");
174 188
 		/* try all names ips */
175 189
 		he=sip_resolvehost(name, &port, 0); /* FIXME proto? */
176 190
 		if (he && ip->af==he->h_addrtype){
... ...
@@ -181,7 +195,7 @@ static int check_via_address(struct ip_addr* ip, str *name,
181 195
 		}
182 196
 	}
183 197
 	if (resolver&DO_REV_DNS){
184
-		DBG("check_address: doing rev. dns lookup\n");
198
+		DBG("check_via_address: doing rev. dns lookup\n");
185 199
 		/* try reverse dns */
186 200
 		he=rev_resolvehost(ip);
187 201
 		if (he && (strncmp(he->h_name, name->s, name->len)==0))
... ...
@@ -1243,9 +1257,12 @@ skip_clen:
1243 1257
 				/*size+=strlen(msg->via1->hdr.s+size+1)+1;*/
1244 1258
 				size += msg->via1->port_str.len + 1; /* +1 for ':'*/
1245 1259
 			}
1260
+#if 0
1261
+			/* no longer necessary, now hots.s contains [] */
1246 1262
 		#ifdef USE_IPV6
1247 1263
 			if(send_sock->address.af==AF_INET6) size+=1; /* +1 for ']'*/
1248 1264
 		#endif
1265
+#endif
1249 1266
 	}
1250 1267
 	/* if received needs to be added, add anchor after host and add it, or 
1251 1268
 	 * overwrite the previous one if already present */
... ...
@@ -67,7 +67,7 @@ enum {
67 67
 	L_PARAM, F_PARAM, P_PARAM,
68 68
 	L_VIA, F_VIA,
69 69
 	F_COMMENT, P_COMMENT,
70
-	F_IP6HOST, P_IP6HOST,
70
+	F_IP6HOST, P_IP6HOST, 
71 71
 	F_CRLF,
72 72
 	F_LF,
73 73
 	F_CR,
... ...
@@ -1332,13 +1332,10 @@ parse_again:
1332 1332
 					case F_COMMENT:
1333 1333
 					case P_COMMENT:
1334 1334
 						break;
1335
-					case F_IP6HOST: /*eat the spaces*/
1336
-						break;
1335
+					case F_IP6HOST: /*no spaces allowed*/
1337 1336
 					case P_IP6HOST:
1338
-						/*mark end of host*/
1339
-						vb->host.len=tmp-vb->host.s;
1340
-						state=L_PORT; 
1341
-						break;
1337
+						LOG(L_ERR, "ERROR:parse_via: bad ipv6 reference\n");
1338
+						goto error;
1342 1339
 					case F_CRLF:
1343 1340
 					case F_LF:
1344 1341
 					case F_CR:
... ...
@@ -1446,9 +1443,8 @@ parse_again:
1446 1443
 				switch(state){
1447 1444
 					case F_HOST:
1448 1445
 					case F_IP6HOST:
1449
-						LOG(L_ERR,"ERROR:parse_via:"
1450
-							" no host found\n");
1451
-						goto error;
1446
+						state=P_IP6HOST;
1447
+						break;
1452 1448
 					case P_IP6HOST:
1453 1449
 						break;
1454 1450
 					case P_HOST:
... ...
@@ -1712,6 +1708,7 @@ parse_again:
1712 1708
 			case '[':
1713 1709
 				switch(state){
1714 1710
 					case F_HOST:
1711
+						vb->host.s=tmp; /* mark start here (include [])*/
1715 1712
 						state=F_IP6HOST;
1716 1713
 						break;
1717 1714
 					case F_COMMENT:/*everything is allowed in a comment*/
... ...
@@ -1736,7 +1733,7 @@ parse_again:
1736 1733
 				switch(state){
1737 1734
 					case P_IP6HOST:
1738 1735
 						/*mark the end*/
1739
-						vb->host.len=tmp-vb->host.s;
1736
+						vb->host.len=(tmp-vb->host.s)+1; /* include "]" */
1740 1737
 						state=L_PORT;
1741 1738
 						break;
1742 1739
 					case F_CRLF:
... ...
@@ -1851,7 +1848,6 @@ parse_again:
1851 1848
 						break;
1852 1849
 					case F_IP6HOST:
1853 1850
 						state=P_IP6HOST;
1854
-						vb->host.s=tmp;
1855 1851
 						break;
1856 1852
 					case P_IP6HOST:
1857 1853
 						break;