/[darkstattype]/trunk/darkstattype.c
ViewVC logotype

Diff of /trunk/darkstattype.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 10 by trond, 2014-03-21T15:40:57Z Revision 12 by trond, 2014-03-21T16:04:33Z
# Line 450  void decode_host_header_v3(void) Line 450  void decode_host_header_v3(void)
450    
451    decode_tcp_data();    decode_tcp_data();
452    
453    if ( (udpdata = read8u()) != 'U') { // missing udp data    if ( (udpdata = read8u()) != 'U') { // missing udp data
454      fprintf(stderr, "%s:%s:%ld: expecting character U, not %c\n", progname, filename, ftell(file), udpdata);      fprintf(stderr, "%s:%s:%ld: expecting character U, not %c\n", progname, filename, ftell(file), udpdata);
455      exit(EXIT_FAILURE);      exit(EXIT_FAILURE);
456    } // if    } // if
457    
458    decode_udp_data();    decode_udp_data();
459    
460    exdent();    exdent();
461  } // decode_host_header_v2  } // decode_host_header_v2
462    
463  void decode_host_header_v3(void)  void decode_host_header_v3(void)
464  {  {
465    unsigned char addressfamily;    unsigned char  addressfamily;
466    unsigned char ipv4address[4];    unsigned char  ipv4address[4];
467    unsigned char ipv6address[16];    unsigned short ipv6address[8];
468    unsigned char macaddress[6];    unsigned char  macaddress[6];
469      signed long lastseen;      signed long  lastseen;
470    unsigned char hostnamelen;    unsigned char  hostnamelen;
471    unsigned char hostname[256];    unsigned char  hostname[256];
472    unsigned long bytesin;    unsigned long  bytesin;
473    unsigned long bytesout;    unsigned long  bytesout;
474    unsigned char protosdata;    unsigned char  protosdata;
475    unsigned char tcpdata;    unsigned char  tcpdata;
476    unsigned char udpdata;    unsigned char  udpdata;
477    
478    unsigned char i;    unsigned char  i;
479    
480    indent();    indent();
481    
482    if ( (addressfamily = read8u()) == 0x04) { // IPv4 address    if ( (addressfamily = read8u()) == 0x04) { // IPv4 address
483      print_indentation();      print_indentation();
484      printf("IPv4 address family (0x%02x)\n", addressfamily);      printf("IPv4 address family (0x%02x)\n", addressfamily);
485    
486      ipv4address[0] = read8u();      ipv4address[0] = read8u();
487      ipv4address[1] = read8u();      ipv4address[1] = read8u();
488      ipv4address[2] = read8u();      ipv4address[2] = read8u();
489      ipv4address[3] = read8u();      ipv4address[3] = read8u();
490    
491      print_indentation();      print_indentation();
492      printf("IPv4 address %d.%d.%d.%d\n",      printf("IPv4 address %d.%d.%d.%d\n",
493             ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]);             ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]);
494    } // if    } // if
495    else if (addressfamily == 0x06) { // IPv6 address    else if (addressfamily == 0x06) { // IPv6 address
496      print_indentation();      print_indentation();
497      printf("IPv6 address family (0x%02x)\n", addressfamily);      printf("IPv6 address family (0x%02x)\n", addressfamily);
498    
499      ipv6address[ 0] = read8u();      ipv6address[0] = read16u();
500      ipv6address[ 1] = read8u();      ipv6address[1] = read16u();
501      ipv6address[ 2] = read8u();      ipv6address[2] = read16u();
502      ipv6address[ 3] = read8u();      ipv6address[3] = read16u();
503      ipv6address[ 4] = read8u();      ipv6address[4] = read16u();
504      ipv6address[ 5] = read8u();      ipv6address[5] = read16u();
505      ipv6address[ 6] = read8u();      ipv6address[6] = read16u();
506      ipv6address[ 7] = read8u();      ipv6address[7] = read16u();
     ipv6address[ 8] = read8u();  
     ipv6address[ 9] = read8u();  
     ipv6address[10] = read8u();  
     ipv6address[11] = read8u();  
     ipv6address[12] = read8u();  
     ipv6address[13] = read8u();  
     ipv6address[14] = read8u();  
     ipv6address[15] = read8u();  
507    
508      print_indentation();      print_indentation();
509      printf("IPv6 address %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",      printf("IPv6 address %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
510             ipv6address[ 0],             ipv6address[0],
511             ipv6address[ 1],             ipv6address[1],
512             ipv6address[ 2],             ipv6address[2],
513             ipv6address[ 3],             ipv6address[3],
514             ipv6address[ 4],             ipv6address[4],
515             ipv6address[ 5],             ipv6address[5],
516             ipv6address[ 6],             ipv6address[6],
517             ipv6address[ 7],             ipv6address[7]);
            ipv6address[ 8],  
            ipv6address[ 9],  
            ipv6address[10],  
            ipv6address[11],  
            ipv6address[12],  
            ipv6address[13],  
            ipv6address[14],  
            ipv6address[15]);  
518    } // else if    } // else if
519    else { // unknown address family    else { // unknown address family
520      fprintf(stderr, "%s:%s:%ld: unknown address family = 0x%x, neither 0x%x nor 0x%x\n", progname, filename, ftell(file), addressfamily, 0x04, 0x06);      fprintf(stderr, "%s:%s:%ld: unknown address family = 0x%x, neither 0x%x nor 0x%x\n", progname, filename, ftell(file), addressfamily, 0x04, 0x06);
521      exit(EXIT_FAILURE);      exit(EXIT_FAILURE);
522    } // else    } // else
523    
524    if (follow_specification == true) {    if (follow_specification == true) {
525      macaddress[0] = read8u();      macaddress[0] = read8u();
526      macaddress[1] = read8u();      macaddress[1] = read8u();
527      macaddress[2] = read8u();      macaddress[2] = read8u();
528      macaddress[3] = read8u();      macaddress[3] = read8u();
529      macaddress[4] = read8u();      macaddress[4] = read8u();
530      macaddress[5] = read8u();      macaddress[5] = read8u();
531    
532      print_indentation();      print_indentation();


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

svn@ximalas.info
ViewVC Help
Powered by ViewVC 1.3.0-dev