Changeset 1b67314
- Timestamp:
- 03/25/05 16:17:26 (16 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:
- d86b8d7
- Parents:
- 05e83dc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
r05e83dc r1b67314 620 620 } 621 621 622 #if HAVE_PCAP 623 void trace_pcap_handler(u_char *user, const struct pcap_pkthdr *pcaphdr, const u_char *pcappkt) { 624 struct libtrace_packet_t *packet = (struct libtrace_packet_t *)user; 625 void *buffer = packet->buffer; 626 int numbytes = 0; 627 628 memcpy(buffer,pcaphdr,sizeof(struct pcap_pkthdr)); 629 numbytes = pcaphdr->len; 630 memcpy(buffer + sizeof(struct pcap_pkthdr),pcappkt,numbytes); 631 632 packet->size = numbytes + sizeof(struct pcap_pkthdr); 633 634 } 635 #endif 622 636 /** Read one packet from the trace into buffer 623 637 * … … 659 673 * works differently under freebsd! */ 660 674 //if ((pcappkt = pcap_next(libtrace->input.pcap, &pcaphdr)) == NULL) { 675 /* 661 676 if ((pcapbytes = pcap_next_ex(libtrace->input.pcap, 662 677 &pcaphdr, 663 678 &pcappkt)) < 0 ) { 679 */ 680 while ((pcapbytes = pcap_dispatch(libtrace->input.pcap, 681 1, /* number of packets */ 682 &trace_pcap_handler, 683 (u_char *)packet)) == 0); 684 685 if (pcapbytes < 0 ) { 664 686 return -1; 665 687 } 666 if (pcapbytes == 0) { 667 return 0; 668 } 669 memcpy(buffer,&pcaphdr,sizeof(struct pcap_pkthdr)); 670 numbytes = pcaphdr->len; 671 memcpy(buffer + sizeof(struct pcap_pkthdr),pcappkt,numbytes); 688 return (packet->size - sizeof(struct pcap_pkthdr)); 689 //memcpy(buffer,&pcaphdr,sizeof(struct pcap_pkthdr)); 690 //numbytes = pcaphdr->len; 691 //memcpy(buffer + sizeof(struct pcap_pkthdr),pcappkt,numbytes); 672 692 673 packet->size = numbytes + sizeof(struct pcap_pkthdr);674 return numbytes;693 //packet->size = numbytes + sizeof(struct pcap_pkthdr); 694 //return numbytes; 675 695 } 676 696 #endif
Note: See TracChangeset
for help on using the changeset viewer.