Browse code

- fixed str2ip6 bug (ipv6 addresses w/o '::' => 0)

Andrei Pelinescu-Onciul authored on 10/10/2002 15:48:39
Showing 1 changed files
... ...
@@ -178,7 +178,6 @@ static inline struct ip_addr* str2ip6(unsigned char* str, unsigned int len)
178 178
 	limit=str+len;
179 179
 	memset(addr_start, 0 , 8*sizeof(unsigned short));
180 180
 	memset(addr_end, 0 , 8*sizeof(unsigned short));
181
-	
182 181
 	for (; str<limit; str++){
183 182
 		if (*str==':'){
184 183
 			no_colons++;
... ...
@@ -206,8 +205,19 @@ static inline struct ip_addr* str2ip6(unsigned char* str, unsigned int len)
206 205
 		addr[i]=htons(addr[i]);
207 206
 		i++; 
208 207
 	}
209
-	rest=8-i-idx1;
210
-	memcpy(addr_start+idx1+rest, addr_end, i*sizeof(unsigned short));
208
+	/* if address contained '::' fix it */
209
+	if (addr==addr_end){
210
+		rest=8-i-idx1;
211
+		memcpy(addr_start+idx1+rest, addr_end, i*sizeof(unsigned short));
212
+	}
213
+/*
214
+	DBG("str2ip6: idx1=%d, rest=%d, no_colons=%d, hex=%x\n",
215
+			idx1, rest, no_colons, hex);
216
+	DBG("str2ip6: address %x:%x:%x:%x:%x:%x:%x:%x\n", 
217
+			addr_start[0], addr_start[1], addr_start[2],
218
+			addr_start[3], addr_start[4], addr_start[5],
219
+			addr_start[6], addr_start[7] );
220
+*/
211 221
 	return &ip;
212 222
 
213 223
 error_too_many_colons: