66 |
case 'v': |
case 'v': |
67 |
show_version(); |
show_version(); |
68 |
break; |
break; |
69 |
|
|
70 |
case '?': |
case '?': |
71 |
/*FALLTHROUGH*/ |
/*FALLTHROUGH*/ |
72 |
default: |
default: |
73 |
fprintf(stderr, "%s: illegal option -%c\n\n", progname, optopt); |
fprintf(stderr, "%s: illegal option -%c\n\n", progname, optopt); |
74 |
show_usage(EXIT_FAILURE); |
show_usage(EXIT_FAILURE); |
75 |
break; |
break; |
76 |
} // switch |
} // switch |
77 |
} // while |
} // while |
78 |
argc -= optind; |
argc -= optind; |
79 |
argv += optind; |
argv += optind; |
80 |
|
|
81 |
if (argv[0] == NULL) { |
if (*argv == NULL) { |
82 |
fprintf(stderr, "%s: missing filename\n\n", progname); |
fprintf(stderr, "%s: missing filename\n\n", progname); |
83 |
show_usage(EXIT_FAILURE); |
show_usage(EXIT_FAILURE); |
84 |
} // if |
} // if |
85 |
|
|
86 |
filename = argv[0]; |
while (*argv != NULL) { |
87 |
|
filename = *argv; |
88 |
|
|
89 |
decode_file(); |
decode_file(); |
90 |
|
|
91 |
|
argv++; |
92 |
|
} // while |
93 |
|
|
94 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
95 |
} // main() |
} // main() |
96 |
|
|
97 |
void show_usage(int exitcode) |
void show_usage(int exitcode) |
98 |
{ |
{ |
99 |
fprintf((exitcode == EXIT_SUCCESS) ? stdout : stderr, |
fprintf((exitcode == EXIT_SUCCESS) ? stdout : stderr, |
100 |
"Usage: %s [-f] [-h] [-v] filename\n" |
"Usage: %s [-f] [-h] [-v] filename ...\n" |
101 |
" E.g.: %s darkstat.db\n\n" |
" E.g.: %s darkstat.db\n\n" |
102 |
|
|
103 |
"Options:\n" |
"Options:\n" |
104 |
"-f\tToggle follow strict specification, default is false.\n" |
"-f\tToggle follow strict specification, default is false.\n" |
105 |
"-h\tShow this help message and exit.\n" |
"-h\tShow this help message and exit.\n" |
106 |
"-v\tShow version and copyright and exit.\n", |
"-v\tShow version and copyright and exit.\n", |
107 |
progname, progname); |
progname, progname); |
108 |
|
|
109 |
exit(exitcode); |
exit(exitcode); |
110 |
} // show_usage() |
} // show_usage() |
111 |
|
|
112 |
void show_version(void) |
void show_version(void) |
113 |
{ |
{ |
114 |
puts("darkstattype 1.0"); |
puts("darkstattype 1.0"); |
115 |
puts("$Ximalas$"); |
puts("$Ximalas$"); |
200 |
printf("Section header host_db v1 0x%x\n", sectionheader); |
printf("Section header host_db v1 0x%x\n", sectionheader); |
201 |
decode_host_db_v1(); |
decode_host_db_v1(); |
202 |
} // if |
} // if |
203 |
else if (sectionheader == GRAPH_DB_V1) { |
else if (sectionheader == GRAPH_DB_V1) { |
204 |
print_indentation(); |
print_indentation(); |
205 |
printf("Section header graph_db v1 0x%x\n", sectionheader); |
printf("Section header graph_db v1 0x%x\n", sectionheader); |
206 |
decode_graph_db_v1(); |
decode_graph_db_v1(); |
207 |
} // else if |
} // else if |
208 |
else { |
else { |
209 |
fprintf(stderr, "%s:%s:%ld: unknown section header = 0x%x, neither 0x%x nor 0x%x\n", progname, filename, ftell(file), sectionheader, HOST_DB_V1, GRAPH_DB_V1); |
fprintf(stderr, "%s:%s:%ld: unknown section header = 0x%x, neither 0x%x nor 0x%x\n", progname, filename, ftell(file), sectionheader, HOST_DB_V1, GRAPH_DB_V1); |
210 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
211 |
} // else |
} // else |
212 |
} // for |
} // for |
213 |
|
|
214 |
exdent(); |
exdent(); |
215 |
|
|
216 |
|
if (fclose(file) != 0) { |
217 |
|
fprintf(stderr, "%s: fclose(\"%s\") = %s (%d)\n", progname, filename, strerror(errno), errno); |
218 |
|
exit(EXIT_FAILURE); |
219 |
|
} // if |
220 |
} // decode_file() |
} // decode_file() |
221 |
|
|
222 |
void decode_host_db_v1(void) |
void decode_host_db_v1(void) |
223 |
{ |
{ |
224 |
void decode_host_header_v1(void); |
void decode_host_header_v1(void); |
225 |
void decode_host_header_v2(void); |
void decode_host_header_v2(void); |
226 |
void decode_host_header_v3(void); |
void decode_host_header_v3(void); |
227 |
|
|
228 |
unsigned int hostcount; |
unsigned int hostcount; |
229 |
unsigned int i; |
unsigned int i; |
230 |
|
|
231 |
indent(); |
indent(); |
232 |
|
|
233 |
hostcount = read32u(); |
hostcount = read32u(); |
234 |
|
|
287 |
unsigned long bytesout; |
unsigned long bytesout; |
288 |
unsigned char protosdata; |
unsigned char protosdata; |
289 |
unsigned char tcpdata; |
unsigned char tcpdata; |
290 |
unsigned char udpdata; |
unsigned char udpdata; |
291 |
|
|
292 |
unsigned char i; |
unsigned char i; |
293 |
|
|
294 |
indent(); |
indent(); |
295 |
|
|
296 |
ipv4address[0] = read8u(); |
ipv4address[0] = read8u(); |
297 |
ipv4address[1] = read8u(); |
ipv4address[1] = read8u(); |
298 |
ipv4address[2] = read8u(); |
ipv4address[2] = read8u(); |
299 |
ipv4address[3] = read8u(); |
ipv4address[3] = read8u(); |
300 |
|
|
301 |
print_indentation(); |
print_indentation(); |
302 |
printf("IPv4 address %d.%d.%d.%d\n", |
printf("IPv4 address %u.%u.%u.%u\n", |
303 |
ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]); |
ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]); |
304 |
|
|
305 |
macaddress[0] = read8u(); |
macaddress[0] = read8u(); |
306 |
macaddress[1] = read8u(); |
macaddress[1] = read8u(); |
307 |
macaddress[2] = read8u(); |
macaddress[2] = read8u(); |
308 |
macaddress[3] = read8u(); |
macaddress[3] = read8u(); |
309 |
macaddress[4] = read8u(); |
macaddress[4] = read8u(); |
310 |
macaddress[5] = read8u(); |
macaddress[5] = read8u(); |
311 |
|
|
312 |
print_indentation(); |
print_indentation(); |
313 |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
314 |
|
|
315 |
hostnamelen = read8u(); |
hostnamelen = read8u(); |
316 |
|
|
317 |
print_indentation(); |
print_indentation(); |
318 |
printf("Hostname length %d\n", hostnamelen); |
printf("Hostname length %u\n", hostnamelen); |
319 |
|
|
320 |
for (i = 0; i < hostnamelen; i++) { |
for (i = 0; i < hostnamelen; i++) { |
321 |
hostname[i] = read8u(); |
hostname[i] = read8u(); |
322 |
} // for |
} // for |
323 |
hostname[i] = '\0'; |
hostname[i] = '\0'; |
324 |
|
|
325 |
print_indentation(); |
print_indentation(); |
326 |
printf("Hostname %s\n", hostname); |
printf("Hostname %s\n", hostname); |
327 |
|
|
328 |
bytesin = read64u(); |
bytesin = read64u(); |
329 |
|
|
330 |
print_indentation(); |
print_indentation(); |
331 |
printf("Bytes in %lu\n", bytesin); |
printf("Bytes in %lu\n", bytesin); |
332 |
|
|
333 |
bytesout = read64u(); |
bytesout = read64u(); |
370 |
unsigned long bytesout; |
unsigned long bytesout; |
371 |
unsigned char protosdata; |
unsigned char protosdata; |
372 |
unsigned char tcpdata; |
unsigned char tcpdata; |
373 |
unsigned char udpdata; |
unsigned char udpdata; |
374 |
|
|
375 |
unsigned char i; |
unsigned char i; |
376 |
|
|
377 |
indent(); |
indent(); |
378 |
|
|
379 |
ipv4address[0] = read8u(); |
ipv4address[0] = read8u(); |
380 |
ipv4address[1] = read8u(); |
ipv4address[1] = read8u(); |
381 |
ipv4address[2] = read8u(); |
ipv4address[2] = read8u(); |
382 |
ipv4address[3] = read8u(); |
ipv4address[3] = read8u(); |
383 |
|
|
384 |
print_indentation(); |
print_indentation(); |
385 |
printf("IPv4 address %d.%d.%d.%d\n", |
printf("IPv4 address %u.%u.%u.%u\n", |
386 |
ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]); |
ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]); |
387 |
|
|
388 |
if (follow_specification == true) { |
if (follow_specification == true) { |
389 |
macaddress[0] = read8u(); |
macaddress[0] = read8u(); |
390 |
macaddress[1] = read8u(); |
macaddress[1] = read8u(); |
391 |
macaddress[2] = read8u(); |
macaddress[2] = read8u(); |
392 |
macaddress[3] = read8u(); |
macaddress[3] = read8u(); |
393 |
macaddress[4] = read8u(); |
macaddress[4] = read8u(); |
394 |
macaddress[5] = read8u(); |
macaddress[5] = read8u(); |
395 |
|
|
396 |
print_indentation(); |
print_indentation(); |
397 |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
398 |
|
|
399 |
lastseen = read64s(); |
lastseen = read64s(); |
400 |
|
|
413 |
|
|
414 |
macaddress[0] = read8u(); |
macaddress[0] = read8u(); |
415 |
macaddress[1] = read8u(); |
macaddress[1] = read8u(); |
416 |
macaddress[2] = read8u(); |
macaddress[2] = read8u(); |
417 |
macaddress[3] = read8u(); |
macaddress[3] = read8u(); |
418 |
macaddress[4] = read8u(); |
macaddress[4] = read8u(); |
419 |
macaddress[5] = read8u(); |
macaddress[5] = read8u(); |
420 |
|
|
421 |
print_indentation(); |
print_indentation(); |
422 |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
423 |
} // else |
} // else |
424 |
|
|
425 |
hostnamelen = read8u(); |
hostnamelen = read8u(); |
426 |
|
|
427 |
print_indentation(); |
print_indentation(); |
428 |
printf("Hostname length %d\n", hostnamelen); |
printf("Hostname length %u\n", hostnamelen); |
429 |
|
|
430 |
for (i = 0; i < hostnamelen; i++) { |
for (i = 0; i < hostnamelen; i++) { |
431 |
hostname[i] = read8u(); |
hostname[i] = read8u(); |
432 |
} // for |
} // for |
433 |
hostname[i] = '\0'; |
hostname[i] = '\0'; |
434 |
|
|
435 |
print_indentation(); |
print_indentation(); |
436 |
printf("Hostname %s\n", hostname); |
printf("Hostname %s\n", hostname); |
437 |
|
|
438 |
bytesin = read64u(); |
bytesin = read64u(); |
439 |
|
|
440 |
print_indentation(); |
print_indentation(); |
441 |
printf("Bytes in %lu\n", bytesin); |
printf("Bytes in %lu\n", bytesin); |
442 |
|
|
443 |
bytesout = read64u(); |
bytesout = read64u(); |
459 |
|
|
460 |
decode_tcp_data(); |
decode_tcp_data(); |
461 |
|
|
462 |
if ( (udpdata = read8u()) != 'U') { // missing udp data |
if ( (udpdata = read8u()) != 'U') { // missing udp data |
463 |
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); |
464 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
465 |
} // if |
} // if |
466 |
|
|
467 |
decode_udp_data(); |
decode_udp_data(); |
468 |
|
|
469 |
exdent(); |
exdent(); |
470 |
} // decode_host_header_v2 |
} // decode_host_header_v2 |
471 |
|
|
472 |
void decode_host_header_v3(void) |
void decode_host_header_v3(void) |
473 |
{ |
{ |
474 |
unsigned char addressfamily; |
unsigned char addressfamily; |
475 |
unsigned char ipv4address[4]; |
unsigned char ipv4address[4]; |
476 |
unsigned char ipv6address[16]; |
unsigned short ipv6address[8]; |
477 |
unsigned char macaddress[6]; |
unsigned char macaddress[6]; |
478 |
signed long lastseen; |
signed long lastseen; |
479 |
unsigned char hostnamelen; |
unsigned char hostnamelen; |
480 |
unsigned char hostname[256]; |
unsigned char hostname[256]; |
481 |
unsigned long bytesin; |
unsigned long bytesin; |
482 |
unsigned long bytesout; |
unsigned long bytesout; |
483 |
unsigned char protosdata; |
unsigned char protosdata; |
484 |
unsigned char tcpdata; |
unsigned char tcpdata; |
485 |
unsigned char udpdata; |
unsigned char udpdata; |
486 |
|
|
487 |
unsigned char i; |
unsigned char i; |
488 |
|
|
489 |
indent(); |
indent(); |
490 |
|
|
491 |
if ( (addressfamily = read8u()) == 0x04) { // IPv4 address |
if ( (addressfamily = read8u()) == 0x04) { // IPv4 address |
492 |
print_indentation(); |
print_indentation(); |
493 |
printf("IPv4 address family (0x%02x)\n", addressfamily); |
printf("IPv4 address family (0x%02x)\n", addressfamily); |
494 |
|
|
495 |
ipv4address[0] = read8u(); |
ipv4address[0] = read8u(); |
496 |
ipv4address[1] = read8u(); |
ipv4address[1] = read8u(); |
497 |
ipv4address[2] = read8u(); |
ipv4address[2] = read8u(); |
498 |
ipv4address[3] = read8u(); |
ipv4address[3] = read8u(); |
499 |
|
|
500 |
print_indentation(); |
print_indentation(); |
501 |
printf("IPv4 address %d.%d.%d.%d\n", |
printf("IPv4 address %u.%u.%u.%u\n", |
502 |
ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]); |
ipv4address[0], ipv4address[1], ipv4address[2], ipv4address[3]); |
503 |
} // if |
} // if |
504 |
else if (addressfamily == 0x06) { // IPv6 address |
else if (addressfamily == 0x06) { // IPv6 address |
505 |
print_indentation(); |
print_indentation(); |
506 |
printf("IPv6 address family (0x%02x)\n", addressfamily); |
printf("IPv6 address family (0x%02x)\n", addressfamily); |
507 |
|
|
508 |
ipv6address[ 0] = read8u(); |
ipv6address[0] = read16u(); |
509 |
ipv6address[ 1] = read8u(); |
ipv6address[1] = read16u(); |
510 |
ipv6address[ 2] = read8u(); |
ipv6address[2] = read16u(); |
511 |
ipv6address[ 3] = read8u(); |
ipv6address[3] = read16u(); |
512 |
ipv6address[ 4] = read8u(); |
ipv6address[4] = read16u(); |
513 |
ipv6address[ 5] = read8u(); |
ipv6address[5] = read16u(); |
514 |
ipv6address[ 6] = read8u(); |
ipv6address[6] = read16u(); |
515 |
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(); |
|
516 |
|
|
517 |
print_indentation(); |
print_indentation(); |
518 |
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", |
519 |
ipv6address[ 0], |
ipv6address[0], |
520 |
ipv6address[ 1], |
ipv6address[1], |
521 |
ipv6address[ 2], |
ipv6address[2], |
522 |
ipv6address[ 3], |
ipv6address[3], |
523 |
ipv6address[ 4], |
ipv6address[4], |
524 |
ipv6address[ 5], |
ipv6address[5], |
525 |
ipv6address[ 6], |
ipv6address[6], |
526 |
ipv6address[ 7], |
ipv6address[7]); |
|
ipv6address[ 8], |
|
|
ipv6address[ 9], |
|
|
ipv6address[10], |
|
|
ipv6address[11], |
|
|
ipv6address[12], |
|
|
ipv6address[13], |
|
|
ipv6address[14], |
|
|
ipv6address[15]); |
|
527 |
} // else if |
} // else if |
528 |
else { // unknown address family |
else { // unknown address family |
529 |
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); |
530 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
531 |
} // else |
} // else |
532 |
|
|
533 |
if (follow_specification == true) { |
if (follow_specification == true) { |
534 |
macaddress[0] = read8u(); |
macaddress[0] = read8u(); |
535 |
macaddress[1] = read8u(); |
macaddress[1] = read8u(); |
536 |
macaddress[2] = read8u(); |
macaddress[2] = read8u(); |
537 |
macaddress[3] = read8u(); |
macaddress[3] = read8u(); |
538 |
macaddress[4] = read8u(); |
macaddress[4] = read8u(); |
539 |
macaddress[5] = read8u(); |
macaddress[5] = read8u(); |
540 |
|
|
541 |
print_indentation(); |
print_indentation(); |
558 |
|
|
559 |
macaddress[0] = read8u(); |
macaddress[0] = read8u(); |
560 |
macaddress[1] = read8u(); |
macaddress[1] = read8u(); |
561 |
macaddress[2] = read8u(); |
macaddress[2] = read8u(); |
562 |
macaddress[3] = read8u(); |
macaddress[3] = read8u(); |
563 |
macaddress[4] = read8u(); |
macaddress[4] = read8u(); |
564 |
macaddress[5] = read8u(); |
macaddress[5] = read8u(); |
565 |
|
|
566 |
print_indentation(); |
print_indentation(); |
567 |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", macaddress[0], macaddress[1], macaddress[2], macaddress[3], macaddress[4], macaddress[5]); |
568 |
} // else |
} // else |
569 |
|
|
570 |
hostnamelen = read8u(); |
hostnamelen = read8u(); |
571 |
|
|
572 |
print_indentation(); |
print_indentation(); |
573 |
printf("Hostname length %d\n", hostnamelen); |
printf("Hostname length %u\n", hostnamelen); |
574 |
|
|
575 |
for (i = 0; i < hostnamelen; i++) { |
for (i = 0; i < hostnamelen; i++) { |
576 |
hostname[i] = read8u(); |
hostname[i] = read8u(); |
577 |
} // for |
} // for |
578 |
hostname[i] = '\0'; |
hostname[i] = '\0'; |
579 |
|
|
580 |
print_indentation(); |
print_indentation(); |
581 |
printf("Hostname %s\n", hostname); |
printf("Hostname %s\n", hostname); |
582 |
|
|
583 |
bytesin = read64u(); |
bytesin = read64u(); |
584 |
|
|
585 |
print_indentation(); |
print_indentation(); |
586 |
printf("Bytes in %lu\n", bytesin); |
printf("Bytes in %lu\n", bytesin); |
587 |
|
|
588 |
bytesout = read64u(); |
bytesout = read64u(); |
606 |
|
|
607 |
if ( (udpdata = read8u()) != 'U') { // missing udp data |
if ( (udpdata = read8u()) != 'U') { // missing udp data |
608 |
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); |
609 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
610 |
} // if |
} // if |
611 |
|
|
612 |
decode_udp_data(); |
decode_udp_data(); |
613 |
|
|
614 |
exdent(); |
exdent(); |
615 |
} // decode_host_header_v3 |
} // decode_host_header_v3 |
616 |
|
|
617 |
void decode_protos_data(void) |
void decode_protos_data(void) |
618 |
{ |
{ |
619 |
unsigned char ipprotocount; |
unsigned char ipprotocount; |
620 |
|
|
621 |
unsigned char u; |
unsigned char i; |
622 |
|
|
623 |
ipprotocount = read8u(); |
ipprotocount = read8u(); |
624 |
|
|
625 |
print_indentation(); |
print_indentation(); |
626 |
printf("IP Proto count %d\n", ipprotocount); |
printf("IP Proto count %u\n", ipprotocount); |
627 |
|
|
628 |
indent(); |
indent(); |
629 |
|
|
630 |
for (u = 0; u < ipprotocount; u++) { |
for (i = 0; i < ipprotocount; i++) { |
631 |
unsigned char proto; |
unsigned char proto; |
632 |
unsigned long in; |
unsigned long in; |
633 |
unsigned long out; |
unsigned long out; |
634 |
|
|
635 |
print_indentation(); |
print_indentation(); |
636 |
printf("Protocol #%u of %u:\n", u + 1, ipprotocount); |
printf("Protocol #%u of %u:\n", i + 1, ipprotocount); |
637 |
|
|
638 |
proto = read8u(); |
proto = read8u(); |
639 |
|
|
640 |
indent(); |
indent(); |
641 |
print_indentation(); |
print_indentation(); |
642 |
printf("Protocol 0x%02x\n", proto); |
printf("Protocol 0x%02x\n", proto); |
643 |
|
|
644 |
in = read64u(); |
in = read64u(); |
645 |
|
|
646 |
print_indentation(); |
print_indentation(); |
647 |
printf("In %lu\n", in); |
printf("In %lu\n", in); |
648 |
|
|
649 |
out = read64u(); |
out = read64u(); |
650 |
|
|
651 |
print_indentation(); |
print_indentation(); |
654 |
exdent(); |
exdent(); |
655 |
} // for |
} // for |
656 |
|
|
657 |
exdent(); |
exdent(); |
658 |
} // decode_protos_data(); |
} // decode_protos_data(); |
659 |
|
|
660 |
void decode_tcp_data(void) |
void decode_tcp_data(void) |
661 |
{ |
{ |
662 |
unsigned char tcpprotocount; |
unsigned char tcpprotocount; |
663 |
|
|
664 |
unsigned short i; |
unsigned short i; |
665 |
|
|
666 |
tcpprotocount = read16u(); |
tcpprotocount = read16u(); |
667 |
|
|
668 |
print_indentation(); |
print_indentation(); |
669 |
printf("TCP proto count %d\n", tcpprotocount); |
printf("TCP proto count %u\n", tcpprotocount); |
670 |
|
|
671 |
indent(); |
indent(); |
672 |
|
|
673 |
for (i = 0; i < tcpprotocount; i++) { |
for (i = 0; i < tcpprotocount; i++) { |
674 |
unsigned short port; |
unsigned short port; |
675 |
unsigned long syn; |
unsigned long syn; |
676 |
unsigned long in; |
unsigned long in; |
677 |
unsigned long out; |
unsigned long out; |
678 |
|
|
679 |
port = read16u(); |
port = read16u(); |
680 |
|
|
681 |
print_indentation(); |
print_indentation(); |
682 |
printf("Port %d:\n", port); |
printf("Port %u:\n", port); |
683 |
|
|
684 |
syn = read64u(); |
syn = read64u(); |
685 |
|
|
686 |
indent(); |
indent(); |
687 |
print_indentation(); |
print_indentation(); |
688 |
printf("SYN %lu\n", syn); |
printf("SYN %lu\n", syn); |
689 |
|
|
690 |
in = read64u(); |
in = read64u(); |
691 |
|
|
692 |
print_indentation(); |
print_indentation(); |
693 |
printf("In %lu\n", in); |
printf("In %lu\n", in); |
694 |
|
|
695 |
out = read64u(); |
out = read64u(); |
696 |
|
|
697 |
print_indentation(); |
print_indentation(); |
700 |
exdent(); |
exdent(); |
701 |
} // for |
} // for |
702 |
|
|
703 |
exdent(); |
exdent(); |
704 |
} // decode_tcp_data() |
} // decode_tcp_data() |
705 |
|
|
706 |
void decode_udp_data(void) |
void decode_udp_data(void) |
707 |
{ |
{ |
708 |
unsigned char udpprotocount; |
unsigned char udpprotocount; |
709 |
|
|
710 |
unsigned short i; |
unsigned short i; |
711 |
|
|
712 |
udpprotocount = read16u(); |
udpprotocount = read16u(); |
713 |
|
|
714 |
print_indentation(); |
print_indentation(); |
715 |
printf("UDP proto count %d\n", udpprotocount); |
printf("UDP proto count %u\n", udpprotocount); |
716 |
|
|
717 |
indent(); |
indent(); |
718 |
|
|
719 |
for (i = 0; i < udpprotocount; i++) { |
for (i = 0; i < udpprotocount; i++) { |
720 |
unsigned short port; |
unsigned short port; |
721 |
unsigned long in; |
unsigned long in; |
722 |
unsigned long out; |
unsigned long out; |
723 |
|
|
724 |
port = read16u(); |
port = read16u(); |
725 |
|
|
726 |
print_indentation(); |
print_indentation(); |
727 |
printf("Port %d:\n", port); |
printf("Port %u:\n", port); |
728 |
|
|
729 |
in = read64u(); |
in = read64u(); |
730 |
|
|
731 |
indent(); |
indent(); |
732 |
print_indentation(); |
print_indentation(); |
733 |
printf("In %lu\n", in); |
printf("In %lu\n", in); |
734 |
|
|
735 |
out = read64u(); |
out = read64u(); |
736 |
|
|
737 |
print_indentation(); |
print_indentation(); |
738 |
printf("Out %lu\n", out); |
printf("Out %lu\n", out); |
739 |
|
|
740 |
exdent(); |
exdent(); |
741 |
} // for |
} // for |
742 |
|
|
752 |
lasttime = read64s(); |
lasttime = read64s(); |
753 |
|
|
754 |
indent(); |
indent(); |
755 |
print_indentation(); |
print_indentation(); |
756 |
printf("Last time 0x%lx = %ld = ", lasttime, lasttime); |
printf("Last time 0x%lx = %ld = ", lasttime, lasttime); |
757 |
print_time_t(lasttime); |
print_time_t(lasttime); |
758 |
puts(""); |
puts(""); |
759 |
|
|
760 |
for (i = 0; i < 4; i++) { |
for (i = 0; i < 4; i++) { |
761 |
unsigned char nbars; |
unsigned char nbars; |
762 |
unsigned char idxlastbar; |
unsigned char idxlastbar; |
763 |
|
|
764 |
unsigned int j; |
unsigned int j; |
765 |
|
|
766 |
print_indentation(); |
print_indentation(); |
767 |
printf("Graph #%d of 4:\n", i + 1); |
printf("Graph #%u of 4:\n", i + 1); |
768 |
|
|
769 |
nbars = read8u(); |
nbars = read8u(); |
770 |
|
|
771 |
indent(); |
indent(); |
772 |
print_indentation(); |
print_indentation(); |
773 |
printf("Number of bars %u\n", nbars); |
printf("Number of bars %u\n", nbars); |
774 |
|
|
775 |
idxlastbar = read8u(); |
idxlastbar = read8u(); |
776 |
|
|
777 |
print_indentation(); |
print_indentation(); |
778 |
printf("Index of last bar %u\n", idxlastbar); |
printf("Index of last bar %u\n", idxlastbar); |
779 |
|
|
780 |
indent(); |
indent(); |
781 |
for (j = 0; j < idxlastbar; j++) { |
for (j = 0; j < idxlastbar; j++) { |
782 |
unsigned long in; |
unsigned long in; |