Changeset d3b2234
- Timestamp:
- 02/23/06 15:22:40 (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:
- 9836f12
- Parents:
- b7d2de5
- Location:
- lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_erf.c
r52f8fc2 rd3b2234 381 381 } 382 382 383 packet->size = size;384 383 DAG.offset += size; 385 384 DAG.diff -= size; … … 431 430 return -1; 432 431 } 433 packet->size = rlen;434 432 if (((dag_record_t *)packet->buffer)->flags.rxerror == 1) { 435 433 packet->payload = NULL; … … 485 483 do { 486 484 struct libtrace_packet_status status; 487 if (tracefifo_out_available(libtrace->fifo) == 0 || read_required) { 485 int size; 486 if (tracefifo_out_available(libtrace->fifo) == 0 487 || read_required) { 488 488 if ((numbytes = rtclient_read( 489 489 libtrace,buf,RP_BUFSIZE))<=0) { … … 502 502 /* Read in packet size */ 503 503 if (tracefifo_out_read(libtrace->fifo, 504 & packet->size, sizeof(uint32_t)) == 0) {504 &size, sizeof(uint32_t)) == 0) { 505 505 tracefifo_out_reset(libtrace->fifo); 506 506 read_required = 1; … … 511 511 if (status.type == 2 /* RT_MSG */) { 512 512 /* Need to skip this packet as it is a message packet */ 513 tracefifo_out_update(libtrace->fifo, packet->size);514 tracefifo_ack_update(libtrace->fifo, packet->size +513 tracefifo_out_update(libtrace->fifo, size); 514 tracefifo_ack_update(libtrace->fifo, size + 515 515 sizeof(uint32_t) + 516 516 sizeof(libtrace_packet_status_t)); … … 520 520 /* read in the full packet */ 521 521 if ((numbytes = tracefifo_out_read(libtrace->fifo, 522 buffer, packet->size)) == 0) {522 buffer, size)) == 0) { 523 523 tracefifo_out_reset(libtrace->fifo); 524 524 read_required = 1; … … 527 527 528 528 /* got in our whole packet, so... */ 529 tracefifo_out_update(libtrace->fifo, packet->size);530 531 tracefifo_ack_update(libtrace->fifo, packet->size +529 tracefifo_out_update(libtrace->fifo,size); 530 531 tracefifo_ack_update(libtrace->fifo,size + 532 532 sizeof(uint32_t) + 533 533 sizeof(libtrace_packet_status_t)); … … 666 666 dag_record_t *erfptr = 0; 667 667 assert(packet); 668 if( (size + erf_get_framing_length(packet)) > packet->size) {668 if(size > trace_get_capture_length(packet)) { 669 669 /* can't make a packet larger */ 670 return (packet->size - erf_get_framing_length(packet));670 return trace_get_capture_length(packet); 671 671 } 672 672 erfptr = (dag_record_t *)packet->header; 673 673 erfptr->rlen = htons(size + erf_get_framing_length(packet)); 674 packet->size = size + erf_get_framing_length(packet); 675 return packet->size; 674 return trace_get_capture_length(packet); 676 675 } 677 676 -
lib/format_helper.c
r8ea5b38 rd3b2234 83 83 trace->event.packet.size= 84 84 trace_read_packet(trace,packet); 85 event.size = trace->event.packet.size; 85 event.size = trace->event.packet.size = \ 86 trace->event.packet.size; 86 87 if (trace->event.packet.size > 0 ) { 87 88 memcpy(trace->event.packet.buffer, … … 128 129 129 130 /* This is the first packet, so just fire away. */ 130 packet->size = trace->event.packet.size;131 131 memcpy(packet->buffer, 132 132 trace->event.packet.buffer, -
lib/format_legacy.c
r52f8fc2 rd3b2234 162 162 return -1; 163 163 } 164 packet->size = 64;165 164 166 165 packet->header = packet->buffer; -
lib/format_pcap.c
rb7d2de5 rd3b2234 250 250 static void trace_pcap_handler(u_char *user, const struct pcap_pkthdr *pcaphdr, const u_char *pcappkt) { 251 251 struct libtrace_packet_t *packet = (struct libtrace_packet_t *)user; 252 int numbytes = 0;253 254 252 /* 255 253 // pcap provides us with the right bits, in it's own buffers. 256 254 // We hijack them. 257 255 */ 258 numbytes = pcaphdr->len;259 256 260 257 if (!packet->buffer || packet->buf_control==TRACE_CTRL_EXTERNAL) { … … 271 268 packet->payload = (void *)pcappkt; 272 269 273 packet->size = numbytes + sizeof(struct pcap_pkthdr);274 275 printf("%i %i %i\n",pcaphdr->caplen,pcaphdr->len,packet->size);276 277 270 assert(pcaphdr->caplen>=0 && pcaphdr->caplen<=65536); 278 271 } … … 289 282 return pcapbytes; 290 283 } 291 return ( packet->size - sizeof(struct pcap_pkthdr));284 return ((struct pcap_pkthdr*)packet->header)->len+sizeof(struct pcap_pkthdr); 292 285 } 293 286 … … 402 395 403 396 404 static int pcap_get_capture_length(const structlibtrace_packet_t *packet) {397 static int pcap_get_capture_length(const libtrace_packet_t *packet) { 405 398 struct pcap_pkthdr *pcapptr = 0; 406 399 pcapptr = (struct pcap_pkthdr *)packet->header; … … 409 402 } 410 403 411 static int pcap_get_wire_length(const structlibtrace_packet_t *packet) {404 static int pcap_get_wire_length(const libtrace_packet_t *packet) { 412 405 struct pcap_pkthdr *pcapptr = 0; 413 406 pcapptr = (struct pcap_pkthdr *)packet->header; … … 415 408 } 416 409 417 static int pcap_get_framing_length(const structlibtrace_packet_t *packet UNUSED) {410 static int pcap_get_framing_length(const libtrace_packet_t *packet UNUSED) { 418 411 return sizeof(struct pcap_pkthdr); 419 412 } 420 413 421 static size_t pcap_set_capture_length( structlibtrace_packet_t *packet,size_t size) {414 static size_t pcap_set_capture_length(libtrace_packet_t *packet,size_t size) { 422 415 struct pcap_pkthdr *pcapptr = 0; 423 416 assert(packet); 424 if ( (size + sizeof(struct pcap_pkthdr)) > packet->size) {417 if (size > trace_get_capture_length(packet)) { 425 418 /* can't make a packet larger */ 426 return (packet->size - sizeof(struct pcap_pkthdr));419 return trace_get_capture_length(packet); 427 420 } 428 421 pcapptr = (struct pcap_pkthdr *)packet->header; 429 422 pcapptr->caplen = size; 430 packet->size = size + sizeof(struct pcap_pkthdr); 431 return packet->size; 423 return trace_get_capture_length(packet); 432 424 } 433 425 -
lib/format_rt.c
r52f8fc2 rd3b2234 416 416 tracefifo_out_update(libtrace->fifo, sizeof(rt_header_t)); 417 417 418 packet->size = pkt_hdr.length + sizeof(rt_header_t);419 418 packet->type = pkt_hdr.type; 420 419 … … 430 429 } 431 430 if (tracefifo_out_read(libtrace->fifo, buffer, 432 p acket->size - sizeof(rt_data_t) - sizeof(rt_header_t))==0)431 pkt_hdr.length-sizeof(rt_data_t))==0) 433 432 { 434 433 tracefifo_out_reset(libtrace->fifo); … … 497 496 498 497 /* got in our whole packet, so... */ 499 tracefifo_out_update(libtrace->fifo,packet->size - sizeof(rt_header_t)); 500 501 tracefifo_ack_update(libtrace->fifo,packet->size); 498 tracefifo_out_update(libtrace->fifo,pkt_hdr.length); 499 500 tracefifo_ack_update(libtrace->fifo,pkt_hdr.length+ 501 sizeof(rt_header_t)); 502 502 return 1; 503 503 } while(1); -
lib/format_wag.c
r52f8fc2 rd3b2234 297 297 298 298 299 packet->size = numbytes;300 299 packet->header = packet->buffer; 301 300 packet->payload=(char*)packet->buffer+trace_get_framing_length(packet); … … 342 341 } 343 342 344 packet->size = framesize;345 343 packet->header = packet->buffer; 346 344 packet->payload=(char*)packet->buffer+trace_get_framing_length(packet); … … 367 365 } 368 366 if ((numbytes = LIBTRACE_WRITE(OUTPUT.file, packet->payload, 369 packet->size - trace_get_framing_length(packet))) == -1) {367 trace_get_capture_length(packet)) == -1)) { 370 368 trace_set_err(errno,"write(%s)",packet->trace->uridata); 371 369 return -1; -
lib/libtrace.h
red7c716 rd3b2234 92 92 /** Structure holding information about a packet */ 93 93 #define LIBTRACE_PACKET_BUFSIZE 65536 94 95 /** The libtrace structure, applications shouldn't be meddling around in here 96 */ 94 97 typedef struct libtrace_packet_t { 95 98 struct libtrace_t *trace; 96 99 void *header; 97 100 void *payload; 101 buf_control_t buf_control; 98 102 void *buffer; 99 size_t size; 100 uint8_t type; /* rt protocol type for the packet*/101 buf_control_t buf_control;103 size_t size; /**< trace_get_framing_length() 104 * +trace_get_capture_length() */ 105 uint8_t type; /**< rt protocol type for the packet */ 102 106 } libtrace_packet_t; 103 107 … … 756 760 * @param packet the packet opaque pointer 757 761 * @param size the new length of the packet 758 * @return the new length of the packet, or the original length of the 759 * packet if unchanged 760 * @author Daniel Lawson 762 * @return the new capture length of the packet, or the original capture 763 * length of the packet if unchanged 761 764 */ 762 765 size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size); -
lib/trace.c
r52f8fc2 rd3b2234 1548 1548 1549 1549 if (packet->trace->format->set_capture_length) { 1550 return packet->trace->format->set_capture_length(packet,size); 1550 int caplen=packet->trace->format->set_capture_length(packet,size); 1551 if (caplen!=-1) { 1552 packet->size=trace_get_framing_length(packet)+caplen; 1553 } 1554 return caplen; 1551 1555 } 1552 1556
Note: See TracChangeset
for help on using the changeset viewer.