Changeset a464de7
- Timestamp:
- 12/04/12 17:11:00 (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:
- 6ba84d9
- Parents:
- b4c3f61
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile.am
r528eb6e ra464de7 7 7 extra_DIST = format_template.c 8 8 NATIVEFORMATS=format_linux.c 9 10 if HAVE_BPF_CAPTURE11 9 BPFFORMATS=format_bpf.c 12 else13 BPFFORMATS=14 endif15 10 16 11 if HAVE_DAG -
lib/format_bpf.c
rfd87898 ra464de7 68 68 */ 69 69 70 struct bpf_timeval { 71 uint32_t tv_sec; 72 uint32_t tv_usec; 73 }; 74 75 struct libtrace_bpf_hdr { 76 struct bpf_timeval bh_tstamp; /* timestamp */ 77 uint32_t bh_caplen; /* capture length */ 78 uint32_t bh_datalen; /* wire length */ 79 uint16_t bh_hdrlen; /* header length (incl padding) */ 80 }; 81 82 #define BPFHDR(x) ((struct libtrace_bpf_hdr *)((x)->header)) 83 84 #if HAVE_DECL_BIOCSETIF 70 85 /* "Global" data that is stored for each BPF input trace */ 71 86 struct libtrace_format_data_t { … … 95 110 #define FORMATIN(x) ((struct libtrace_format_data_t*)((x->format_data))) 96 111 97 #define BPFHDR(x) ((struct bpf_hdr *)((x)->header))98 112 99 113 /* Attempts to determine if a given filename could refer to a BPF interface */ … … 340 354 } 341 355 356 #endif /* HAVE_DECL_BIOCSETIF */ 357 342 358 /* Converts a buffer containing a recently read BPF packet record into a 343 359 * libtrace packet */ 344 static int bpf_prepare_packet(libtrace_t *libtrace, libtrace_packet_t *packet, 360 static int bpf_prepare_packet(libtrace_t *libtrace UNUSED, 361 libtrace_packet_t *packet, 345 362 void *buffer, libtrace_rt_types_t rt_type, uint32_t flags) { 346 363 … … 368 385 packet->payload=(char *)buffer + BPFHDR(packet)->bh_hdrlen; 369 386 387 /* 370 388 if (libtrace->format_data == NULL) { 371 389 if (bpf_init_input(libtrace)) 372 390 return -1; 373 391 } 392 */ 374 393 375 394 return 0; 376 395 } 396 397 #if HAVE_DECL_BIOCSETIF 377 398 378 399 /* Reads the next packet record from a BPF interface and writes it into a … … 434 455 } 435 456 457 #endif /* HAVE_DECL_BIOCSETIF */ 458 436 459 /* Returns the linktype for the interface that we are capturing from */ 437 460 static libtrace_linktype_t bpf_get_link_type(const libtrace_packet_t *packet) { … … 485 508 } 486 509 510 #if HAVE_DECL_BIOCSETIF 487 511 /* Returns the file descriptor that the capture interface is operating on */ 488 512 static int bpf_get_fd(const libtrace_t *trace) { … … 540 564 NULL 541 565 }; 566 #else /* HAVE_DECL_BIOCSETIF */ 567 /* Prints some slightly useful help text for the BPF capture format */ 568 static void bpf_help() { 569 printf("bpf format module: $Revision$\n"); 570 printf("Not supported on this host\n"); 571 return; 572 } 573 static struct libtrace_format_t bpf = { 574 "bpf", 575 "$Id$", 576 TRACE_FORMAT_BPF, 577 NULL, /* probe filename */ 578 NULL, /* probe magic */ 579 NULL, /* init_input */ 580 NULL, /* config_input */ 581 NULL, /* start_input */ 582 NULL, /* pause_input */ 583 NULL, /* init_output */ 584 NULL, /* config_output */ 585 NULL, /* start_ouput */ 586 NULL, /* fin_input */ 587 NULL, /* fin_output */ 588 NULL, /* read_packet */ 589 bpf_prepare_packet, /* prepare_packet */ 590 NULL, /* fin_packet */ 591 NULL, /* write_packet */ 592 bpf_get_link_type, /* get_link_type */ 593 bpf_get_direction, /* get_direction */ 594 NULL, /* set_direction */ 595 NULL, /* get_erf_timestamp */ 596 bpf_get_timeval, /* get_timeval */ 597 NULL, /* get_timespec */ 598 NULL, /* get_seconds */ 599 NULL, /* seek_erf */ 600 NULL, /* seek_timeval */ 601 NULL, /* seek_seconds */ 602 bpf_get_capture_length, /* get_capture_length */ 603 bpf_get_wire_length, /* get_wire_length */ 604 bpf_get_framing_length, /* get_framing_length */ 605 NULL, /* set_capture_length */ 606 NULL,/* get_received_packets */ 607 NULL, /* get_filtered_packets */ 608 NULL,/* get_dropped_packets */ 609 NULL, /* get_captured_packets */ 610 NULL, /* get_fd */ 611 NULL, /* trace_event */ 612 bpf_help, /* help */ 613 NULL 614 }; 615 #endif /* HAVE_DECL_BIOCSETIF */ 542 616 543 617 void bpf_constructor() { -
lib/trace.c
r528eb6e ra464de7 140 140 pcap_constructor(); 141 141 #endif 142 #if HAVE_DECL_BIOCSETIF143 142 bpf_constructor(); 144 #endif145 143 pcapfile_constructor(); 146 144 rt_constructor();
Note: See TracChangeset
for help on using the changeset viewer.