- Timestamp:
- 03/06/13 13:28:51 (9 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 68b7f29
- Parents:
- af27241
- Location:
- lib
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile.am
ra464de7 rc909fad 34 34 libtrace_int.h lt_inttypes.h \ 35 35 linktypes.c link_wireless.c \ 36 checksum.c checksum.h \ 36 37 protocols_pktmeta.c protocols_l2.c protocols_l3.c \ 37 38 protocols_transport.c protocols.h protocols_ospf.c \ -
lib/format_bpf.c
ra464de7 rc909fad 516 516 /* Prints some slightly useful help text for the BPF capture format */ 517 517 static void bpf_help() { 518 printf("bpf format module: $Revision $\n");518 printf("bpf format module: $Revision: 1782 $\n"); 519 519 printf("Supported input URIs:\n"); 520 520 printf("\tbpf:\n"); … … 567 567 /* Prints some slightly useful help text for the BPF capture format */ 568 568 static void bpf_help() { 569 printf("bpf format module: $Revision $\n");569 printf("bpf format module: $Revision: 1782 $\n"); 570 570 printf("Not supported on this host\n"); 571 571 return; -
lib/format_dag24.c
r44028d4 rc909fad 506 506 /* Prints some semi-useful help text about the DAG format module */ 507 507 static void dag_help(void) { 508 printf("dag format module: $Revision $\n");508 printf("dag format module: $Revision: 1715 $\n"); 509 509 printf("Supported input URIs:\n"); 510 510 printf("\tdag:/dev/dagn\n"); -
lib/format_dag25.c
rc5a4210 rc909fad 1159 1159 /* Prints some semi-useful help text about the DAG format module */ 1160 1160 static void dag_help(void) { 1161 printf("dag format module: $Revision $\n");1161 printf("dag format module: $Revision: 1755 $\n"); 1162 1162 printf("Supported input URIs:\n"); 1163 1163 printf("\tdag:/dev/dagn\n"); -
lib/format_erf.c
re90d5a8 rc909fad 748 748 749 749 static void erf_help(void) { 750 printf("erf format module: $Revision $\n");750 printf("erf format module: $Revision: 1752 $\n"); 751 751 printf("Supported input URIs:\n"); 752 752 printf("\terf:/path/to/file\t(uncompressed)\n"); -
lib/format_legacy.c
rfefd34b rc909fad 467 467 468 468 static void legacypos_help(void) { 469 printf("legacypos format module: $Revision $\n");469 printf("legacypos format module: $Revision: 1753 $\n"); 470 470 printf("Supported input URIs:\n"); 471 471 printf("\tlegacypos:/path/to/file\t(uncompressed)\n"); … … 478 478 479 479 static void legacyatm_help(void) { 480 printf("legacyatm format module: $Revision $\n");480 printf("legacyatm format module: $Revision: 1753 $\n"); 481 481 printf("Supported input URIs:\n"); 482 482 printf("\tlegacyatm:/path/to/file\t(uncompressed)\n"); … … 489 489 490 490 static void legacyeth_help(void) { 491 printf("legacyeth format module: $Revision $\n");491 printf("legacyeth format module: $Revision: 1753 $\n"); 492 492 printf("Supported input URIs:\n"); 493 493 printf("\tlegacyeth:/path/to/file\t(uncompressed)\n"); … … 500 500 501 501 static void legacynzix_help(void) { 502 printf("legacynzix format module: $Revision $\n");502 printf("legacynzix format module: $Revision: 1753 $\n"); 503 503 printf("Supported input URIs:\n"); 504 504 printf("\tlegacynzix:/path/to/file\t(uncompressed)\n"); -
lib/format_linux.c
r0801187 rc909fad 1482 1482 #ifdef HAVE_NETPACKET_PACKET_H 1483 1483 static void linuxnative_help(void) { 1484 printf("linuxnative format module: $Revision $\n");1484 printf("linuxnative format module: $Revision: 1793 $\n"); 1485 1485 printf("Supported input URIs:\n"); 1486 1486 printf("\tint:eth0\n"); … … 1493 1493 1494 1494 static void linuxring_help(void) { 1495 printf("linuxring format module: $Revision $\n");1495 printf("linuxring format module: $Revision: 1793 $\n"); 1496 1496 printf("Supported input URIs:\n"); 1497 1497 printf("\tring:eth0\n"); … … 1590 1590 #else 1591 1591 static void linuxnative_help(void) { 1592 printf("linuxnative format module: $Revision $\n");1592 printf("linuxnative format module: $Revision: 1793 $\n"); 1593 1593 printf("Not supported on this host\n"); 1594 1594 } 1595 1595 static void linuxring_help(void) { 1596 printf("linuxring format module: $Revision $\n");1596 printf("linuxring format module: $Revision: 1793 $\n"); 1597 1597 printf("Not supported on this host\n"); 1598 1598 } -
lib/format_pcap.c
rc0506ea rc909fad 737 737 738 738 static void pcap_help(void) { 739 printf("pcap format module: $Revision $\n");739 printf("pcap format module: $Revision: 1729 $\n"); 740 740 printf("Supported input URIs:\n"); 741 741 printf("\tpcap:/path/to/file\n"); … … 749 749 750 750 static void pcapint_help(void) { 751 printf("pcapint format module: $Revision $\n");751 printf("pcapint format module: $Revision: 1729 $\n"); 752 752 printf("Supported input URIs:\n"); 753 753 printf("\tpcapint:interface\n"); -
lib/format_pcapfile.c
r64d4398 rc909fad 683 683 684 684 static void pcapfile_help(void) { 685 printf("pcapfile format module: $Revision $\n");685 printf("pcapfile format module: $Revision: 1768 $\n"); 686 686 printf("Supported input URIs:\n"); 687 687 printf("\tpcapfile:/path/to/file\n"); -
lib/format_tsh.c
r191f2de rc909fad 218 218 219 219 static void tsh_help(void) { 220 printf("tsh format module: $Revision $\n");220 printf("tsh format module: $Revision: 1611 $\n"); 221 221 printf("Supported input URIs:\n"); 222 222 printf("\ttsh:/path/to/file\t(uncompressed)\n"); -
lib/libtrace.h.in
r5699389 rc909fad 1673 1673 uint16_t *ethertype, uint32_t *remaining); 1674 1674 1675 /** Calculates the expected IP checksum for a packet. 1676 * @param packet The libtrace packet to calculate the checksum for 1677 * @param[out] csum The checksum that is calculated by this function. This 1678 * may not be NULL. 1679 * 1680 * @return A pointer to the original checksum field within the IP 1681 * header. If the checksum field is not present in the packet, NULL is returned. 1682 * 1683 * @note The return value points to the checksum that exists within the current 1684 * packet. The value in csum is the value that the checksum should be, given 1685 * the current packet contents. 1686 * 1687 * @note This function involves the use of a memcpy, so be careful about 1688 * calling it excessively if performance is a concern for you. 1689 * 1690 * New in libtrace 3.0.17 1691 */ 1692 DLLEXPORT uint16_t *trace_checksum_layer3(libtrace_packet_t *packet, 1693 uint16_t *csum); 1694 1695 /** Calculates the expected checksum for the transport header in a packet. 1696 * @param packet The libtrace packet to calculate the checksum for 1697 * @param[out] csum The checksum that is calculated by this function. This 1698 * may not be NULL. 1699 * 1700 * @return A pointer to the original checksum field within the transport 1701 * header. If the checksum field is not present in the packet, NULL is returned. 1702 * 1703 * @note The return value points to the checksum that exists within the current 1704 * packet. The value in csum is the value that the checksum should be, given 1705 * the current packet contents. 1706 * 1707 * @note This function involves the use of a memcpy, so be careful about 1708 * calling it excessively if performance is a concern for you. 1709 * 1710 * @note Because transport checksums are calculated across the entire payload, 1711 * truncated packets will result in NULL being returned. 1712 * 1713 * This function will determine the appropriate checksum for whatever transport 1714 * layer header is present in the provided packet. At this stage, this only 1715 * currently works for TCP, UDP and ICMP packets. 1716 * 1717 * Be wary of TCP checksum offloading if you are examining the checksum of 1718 * packets captured on the same host that generated them! 1719 * 1720 * New in libtrace 3.0.17 1721 */ 1722 DLLEXPORT uint16_t *trace_checksum_transport(libtrace_packet_t *packet, 1723 uint16_t *csum); 1724 1675 1725 /** Gets a pointer to the transport layer header (if any) 1676 1726 * @param packet The libtrace packet to find the transport header for -
lib/protocols_l3.c
r5699389 rc909fad 36 36 #include "libtrace.h" 37 37 #include "protocols.h" 38 #include "checksum.h" 38 39 #include <assert.h> 39 40 #include <stdlib.h> … … 676 677 } 677 678 679 DLLEXPORT uint16_t *trace_checksum_layer3(libtrace_packet_t *packet, 680 uint16_t *csum) { 681 682 void *l3; 683 uint16_t ethertype; 684 uint32_t remaining; 685 uint16_t *csum_ptr; 686 687 uint8_t safety[65536]; 688 689 if (csum == NULL) 690 return NULL; 691 692 l3 = trace_get_layer3(packet, ðertype, &remaining); 693 694 if (l3 == NULL) 695 return NULL; 696 697 if (ethertype == TRACE_ETHERTYPE_IP) { 698 libtrace_ip_t *ip = (libtrace_ip_t *)l3; 699 if (remaining < sizeof(libtrace_ip_t)) 700 return NULL; 701 702 csum_ptr = &ip->ip_sum; 703 704 /* I hate memcpys, but this is the only truly safe way to 705 * do this without modifying the packet. I'm trying to be 706 * careful about not creating any more thread-safety issues 707 * than there already are :) */ 708 memcpy(safety, ip, ip->ip_hl * sizeof(uint32_t)); 709 710 /* Set the checksum to zero, so we can do the calculation */ 711 ip = (libtrace_ip_t *)safety; 712 ip->ip_sum = 0; 713 714 *csum = checksum_buffer(safety, ip->ip_hl * sizeof(uint32_t)); 715 716 /* Remember to byteswap appropriately */ 717 *csum = ntohs(*csum); 718 719 return csum_ptr; 720 } 721 722 return NULL; 723 } 724 -
lib/protocols_transport.c
r05f2718 rc909fad 35 35 #include "libtrace.h" 36 36 #include "protocols.h" 37 #include "checksum.h" 37 38 #include <assert.h> 38 39 #include <stdlib.h> 39 40 #include <stdio.h> // fprintf 41 #include <string.h> 40 42 41 43 /* This file contains all the protocol decoding functions for transport layer … … 419 421 } 420 422 421 423 DLLEXPORT uint16_t *trace_checksum_transport(libtrace_packet_t *packet, 424 uint16_t *csum) { 425 426 void *header = NULL; 427 uint16_t ethertype; 428 uint32_t remaining; 429 uint32_t sum = 0; 430 uint8_t proto = 0; 431 uint16_t *csum_ptr = NULL; 432 int plen = 0; 433 434 uint8_t safety[65536]; 435 uint8_t *ptr = safety; 436 437 header = trace_get_layer3(packet, ðertype, &remaining); 438 439 if (header == NULL) 440 return NULL; 441 442 if (ethertype == TRACE_ETHERTYPE_IP) { 443 libtrace_ip_t *ip = (libtrace_ip_t *)header; 444 445 if (remaining < sizeof(libtrace_ip_t)) 446 return NULL; 447 448 sum = ipv4_pseudo_checksum(ip); 449 450 } else if (ethertype == TRACE_ETHERTYPE_IPV6) { 451 libtrace_ip6_t *ip = (libtrace_ip6_t *)header; 452 453 if (remaining < sizeof(libtrace_ip6_t)) 454 return 0; 455 456 sum = ipv6_pseudo_checksum(ip); 457 458 } 459 460 header = trace_get_transport(packet, &proto, &remaining); 461 462 if (proto == TRACE_IPPROTO_TCP) { 463 libtrace_tcp_t *tcp = (libtrace_tcp_t *)header; 464 header = trace_get_payload_from_tcp(tcp, &remaining); 465 466 csum_ptr = &tcp->check; 467 468 memcpy(ptr, tcp, tcp->doff * 4); 469 470 tcp = (libtrace_tcp_t *)ptr; 471 tcp->check = 0; 472 473 ptr += (tcp->doff * 4); 474 } 475 476 else if (proto == TRACE_IPPROTO_UDP) { 477 478 libtrace_udp_t *udp = (libtrace_udp_t *)header; 479 header = trace_get_payload_from_udp(udp, &remaining); 480 481 csum_ptr = &udp->check; 482 memcpy(ptr, udp, sizeof(libtrace_udp_t)); 483 484 udp = (libtrace_udp_t *)ptr; 485 udp->check = 0; 486 487 ptr += sizeof(libtrace_udp_t); 488 } 489 490 else if (proto == TRACE_IPPROTO_ICMP) { 491 /* ICMP doesn't use the pseudo header */ 492 sum = 0; 493 494 libtrace_icmp_t *icmp = (libtrace_icmp_t *)header; 495 header = trace_get_payload_from_icmp(icmp, &remaining); 496 497 csum_ptr = &icmp->checksum; 498 memcpy(ptr, icmp, sizeof(libtrace_icmp_t)); 499 500 icmp = (libtrace_icmp_t *)ptr; 501 icmp->checksum = 0; 502 503 ptr += sizeof(libtrace_icmp_t); 504 505 } 506 else { 507 return NULL; 508 } 509 510 sum += add_checksum(safety, (uint16_t)(ptr - safety)); 511 512 plen = trace_get_payload_length(packet); 513 if (plen < 0) 514 return NULL; 515 516 if (remaining < (uint32_t)plen) 517 return NULL; 518 519 if (header == NULL) 520 return NULL; 521 522 sum += add_checksum(header, (uint16_t)plen); 523 *csum = ntohs(finish_checksum(sum)); 524 //assert(0); 525 526 return csum_ptr; 527 }
Note: See TracChangeset
for help on using the changeset viewer.