| 231 | | tResource("IPv6 number can not have more than one double colons."); |
| 232 | | } |
| 233 | | |
| 234 | | uPos=sscanf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8); |
| 235 | | //All first position cases, i.e. 2,3,4,5 and 6 word cases |
| 236 | | if(uPos==1) |
| 237 | | { |
| 238 | | uPos=sscanf(cParam1,"%x::%x:%x:%x:%x:%x:%x",&h1, &h3,&h4,&h5,&h6,&h7,&h8); |
| 239 | | if(uPos==2) |
| 240 | | uPos=sscanf(cParam1,"%x:%x::%x:%x:%x:%x:%x",&h1,&h2, &h4,&h5,&h6,&h7,&h8); |
| 241 | | } |
| 242 | | |
| 243 | | } |
| 244 | | |
| 245 | | //Leading 0's. Done via sprintf below. |
| 246 | | |
| 247 | | //First checks |
| | 227 | tResource("<blink>IPv6 number can not have more than one double colon!</blink>"); |
| | 228 | } |
| | 229 | } |
| | 230 | |
| | 231 | //Now for the hard work |
| | 232 | for(i=0;cParam1[i];i++) |
| | 233 | { |
| | 234 | if(cParam1[i]==':') |
| | 235 | uColonCount++; |
| | 236 | if(cParam1[i]!=':' && !isxdigit(cParam1[i])) |
| | 237 | { |
| | 238 | guMode=uMode; |
| | 239 | tResource("<blink>IPv6 number can only have hexadecimal digits and colons!</blink>"); |
| | 240 | } |
| | 241 | } |
| | 242 | |
| | 243 | switch(uColonCount) |
| | 244 | { |
| | 245 | case 0: |
| | 246 | case 1: |
| | 247 | guMode=uMode; |
| | 248 | tResource("<blink>IPv6 too few colons: Min is 2!</blink>"); |
| | 249 | break; |
| | 250 | |
| | 251 | case 2: |
| | 252 | uRead=sscanf(cParam1,"%x::%x",&h1,&h8); |
| | 253 | if(uRead!=2) |
| | 254 | { |
| | 255 | guMode=uMode; |
| | 256 | tResource("<blink>IPv6 sscanf case 2 error!</blink>"); |
| | 257 | } |
| | 258 | break; |
| | 259 | |
| | 260 | case 3: |
| | 261 | uRead=sscanf(cParam1,"%x::%x:%x",&h1,&h7,&h8); |
| | 262 | if(uRead!=3) |
| | 263 | { |
| | 264 | uRead=sscanf(cParam1,"%x:%x::%x",&h1,&h2,&h8); |
| | 265 | if(uRead!=3) |
| | 266 | { |
| | 267 | guMode=uMode; |
| | 268 | tResource("<blink>IPv6 sscanf case 3 error!</blink>"); |
| | 269 | } |
| | 270 | } |
| | 271 | break; |
| | 272 | |
| | 273 | case 4: |
| | 274 | uRead=sscanf(cParam1,"%x::%x:%x:%x",&h1,&h6,&h7,&h8); |
| | 275 | if(uRead!=4) |
| | 276 | { |
| | 277 | uRead=sscanf(cParam1,"%x:%x::%x:%x",&h1,&h2,&h7,&h8); |
| | 278 | if(uRead!=4) |
| | 279 | { |
| | 280 | uRead=sscanf(cParam1,"%x:%x:%x::%x",&h1,&h2,&h3,&h8); |
| | 281 | if(uRead!=4) |
| | 282 | { |
| | 283 | guMode=uMode; |
| | 284 | tResource("<blink>IPv6 sscanf case 4 error!</blink>"); |
| | 285 | } |
| | 286 | } |
| | 287 | } |
| | 288 | break; |
| | 289 | |
| | 290 | case 5: |
| | 291 | uRead=sscanf(cParam1,"%x::%x:%x:%x:%x",&h1,&h5,&h6,&h7,&h8); |
| | 292 | if(uRead!=5) |
| | 293 | { |
| | 294 | uRead=sscanf(cParam1,"%x:%x::%x:%x:%x",&h1,&h2,&h6,&h7,&h8); |
| | 295 | if(uRead!=5) |
| | 296 | { |
| | 297 | uRead=sscanf(cParam1,"%x:%x:%x::%x:%x",&h1,&h2,&h3,&h7,&h8); |
| | 298 | if(uRead!=5) |
| | 299 | { |
| | 300 | uRead=sscanf(cParam1,"%x:%x:%x:%x::%x",&h1,&h2,&h3,&h4,&h8); |
| | 301 | if(uRead!=5) |
| | 302 | { |
| | 303 | guMode=uMode; |
| | 304 | tResource("<blink>IPv6 sscanf case 5 error!</blink>"); |
| | 305 | } |
| | 306 | } |
| | 307 | } |
| | 308 | } |
| | 309 | break; |
| | 310 | |
| | 311 | case 6: |
| | 312 | uRead=sscanf(cParam1,"%x::%x:%x:%x:%x:%x",&h1,&h4,&h5,&h6,&h7,&h8); |
| | 313 | if(uRead!=6) |
| | 314 | { |
| | 315 | uRead=sscanf(cParam1,"%x:%x::%x:%x:%x:%x",&h1,&h2,&h5,&h6,&h7,&h8); |
| | 316 | if(uRead!=6) |
| | 317 | { |
| | 318 | uRead=sscanf(cParam1,"%x:%x:%x::%x:%x:%x",&h1,&h2,&h3,&h6,&h7,&h8); |
| | 319 | if(uRead!=6) |
| | 320 | { |
| | 321 | uRead=sscanf(cParam1,"%x:%x:%x:%x::%x:%x",&h1,&h2,&h3,&h4,&h7,&h8); |
| | 322 | if(uRead!=6) |
| | 323 | { |
| | 324 | uRead=sscanf(cParam1,"%x:%x:%x:%x:%x::%x", |
| | 325 | &h1,&h2,&h3,&h4,&h5,&h8); |
| | 326 | if(uRead!=6) |
| | 327 | { |
| | 328 | guMode=uMode; |
| | 329 | tResource("<blink>IPv6 sscanf case 6 error!</blink>"); |
| | 330 | } |
| | 331 | } |
| | 332 | } |
| | 333 | } |
| | 334 | } |
| | 335 | break; |
| | 336 | |
| | 337 | case 7: |
| | 338 | uRead=sscanf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8); |
| | 339 | if(uRead!=7) |
| | 340 | { |
| | 341 | guMode=uMode; |
| | 342 | tResource("<blink>IPv6 sscanf case 7 error!</blink>"); |
| | 343 | } |
| | 344 | |
| | 345 | default: |
| | 346 | guMode=uMode; |
| | 347 | tResource("<blink>IPv6 too many colons: Max is 7!</blink>"); |
| | 348 | |
| | 349 | } |
| | 350 | |
| | 351 | //First basic checks for AAAA hosts |