- Timestamp:
- 07/29/05 13:28:29 (17 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:
- 74c7660
- Parents:
- 4dedc28
- Location:
- lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile.am
r4dedc28 r7050c10 1 1 lib_LTLIBRARIES = libtrace.la 2 2 include_HEADERS = libtrace.h dagformat.h wag.h 3 libtrace_la_SOURCES = trace.c fifo.c fifo.h common.h format_template.c format_erf.c format_pcap.c format_rtclient.c3 libtrace_la_SOURCES = trace.c fifo.c fifo.h common.h format_template.c format_erf.c format_pcap.c 4 4 libtrace_la_CFLAGS = @ADD_INCLS@ 5 5 libtrace_la_LIBADD = @ADD_LIBS@ @LTLIBOBJS@ -
lib/format.h
r4dedc28 r7050c10 161 161 int (*init_output)(struct libtrace_out_t *libtrace); 162 162 int (*fin_input)(struct libtrace_t *libtrace); 163 int (*fin_output)(struct libtrace_out_t *libtrace); 163 164 int (*read)(struct libtrace_t *libtrace, void *buffer, size_t len); 164 165 int (*read_packet)(struct libtrace_t *libtrace, struct libtrace_packet_t *packet); -
lib/format_erf.c
r4dedc28 r7050c10 58 58 #endif 59 59 static int dag_init_input(struct libtrace_t *libtrace) { 60 #ifdef HAVE_DAG 60 61 struct stat buf; 61 62 if (stat(libtrace->conn_info.path,&buf) == -1) { … … 87 88 return 0; 88 89 } 90 #endif 89 91 } 90 92 … … 195 197 196 198 static int dag_fin_input(struct libtrace_t *libtrace) { 199 #ifdef HAVE_DAG 197 200 dag_stop(libtrace->input.fd); 201 #endif 198 202 } 199 203 … … 210 214 } 211 215 212 static int erf_read(struct libtrace_t *libtrace, void *buffer, size_t len) { 216 static int dag_read(struct libtrace_t *libtrace, void *buffer, size_t len) { 217 #if HAVE_DAG 218 int numbytes; 219 static short lctr = 0; 220 struct dag_record_t *erfptr = 0; 221 int rlen; 222 223 if (buffer == 0) 224 buffer = malloc(len); 225 226 libtrace->dag.bottom = libtrace->dag.top; 227 libtrace->dag.top = dag_offset( 228 libtrace->input.fd, 229 &(libtrace->dag.bottom), 230 0); 231 libtrace->dag.diff = libtrace->dag.top - 232 libtrace->dag.bottom; 233 234 numbytes=libtrace->dag.diff; 235 libtrace->dag.offset = 0; 236 return numbytes; 237 #else 213 238 return -1; 239 #endif 214 240 } 215 241 216 242 static int dag_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) { 243 #if HAVE_DAG 217 244 int numbytes; 218 245 int size; … … 224 251 225 252 if (libtrace->dag.diff == 0) { 226 if ((numbytes = trace_read(libtrace,buf,RP_BUFSIZE)) <= 0)253 if ((numbytes = dag_read(libtrace,buf,RP_BUFSIZE)) <= 0) 227 254 return numbytes; 228 255 } … … 248 275 249 276 return (size); 250 277 #else 278 return -1; 279 #endif 251 280 } 252 281 … … 327 356 do { 328 357 if (fifo_out_available(libtrace->fifo) == 0 || read_required) { 329 if ((numbytes = trace_read(358 if ((numbytes = rtclient_read( 330 359 libtrace,buf,RP_BUFSIZE))<=0) { 331 360 return numbytes; … … 335 364 read_required = 0; 336 365 } 366 // Read status byte 337 367 if (fifo_out_read(libtrace->fifo, 338 368 &packet->status, sizeof(int)) == 0) { … … 342 372 fifo_out_update(libtrace->fifo,sizeof(int)); 343 373 374 // read in the ERF header 344 375 if ((numbytes = fifo_out_read(libtrace->fifo, buffer, 345 376 sizeof(dag_record_t))) == 0) { … … 358 389 } 359 390 360 // got in our howle packet, so...391 // got in our whole packet, so... 361 392 fifo_out_update(libtrace->fifo,size); 362 393 … … 378 409 ethptr = ((uint8_t *)packet->buffer + 379 410 dag_record_size + 2); 411 return ethptr; 380 412 } 381 413 … … 388 420 default: assert(0); 389 421 } 422 return erfptr->type; 390 423 } 391 424 … … 421 454 } 422 455 423 static size_t erf_ truncate_packet(struct libtrace_packet_t *packet, const size_t size) {456 static size_t erf_set_capture_length(struct libtrace_packet_t *packet, const size_t size) { 424 457 dag_record_t *erfptr = 0; 425 458 assert(packet); … … 437 470 "erf", 438 471 "$Id$", 439 erf_init_input, 440 NULL, 441 erf_fin_input, 442 NULL, 443 erf_read_packet, 444 NULL, 445 erf_get_link, 446 erf_get_link_type, 447 erf_get_direction, 448 erf_set_direction, 449 erf_get_erf_timestamp, 450 NULL, 451 NULL, 452 erf_get_capture_length, 453 erf_get_wire_length, 454 erf_truncate_packet 472 erf_init_input, /* init_input */ 473 NULL, /* init_output */ 474 erf_fin_input, /* fin_input */ 475 NULL, /* fin_output */ 476 NULL, /* read */ 477 erf_read_packet, /* read_packet */ 478 NULL, /* write_packet */ 479 erf_get_link, /* get_link */ 480 erf_get_link_type, /* get_link_type */ 481 erf_get_direction, /* get_direction */ 482 erf_set_direction, /* set_direction */ 483 erf_get_erf_timestamp, /* get_erf_timestamp */ 484 NULL, /* get_timeval */ 485 NULL, /* get_seconds */ 486 erf_get_capture_length, /* get_capture_length */ 487 erf_get_wire_length, /* get_wire_length */ 488 erf_set_capture_length /* set_capture_length */ 455 489 }; 456 490 … … 458 492 "dag", 459 493 "$Id$", 460 dag_init_input, 461 NULL, 462 dag_fin_input, 463 NULL, 464 dag_read_packet, 465 NULL, 466 erf_get_link, 467 erf_get_link_type, 468 erf_get_direction, 469 erf_set_direction, 470 erf_get_erf_timestamp, 471 NULL, 472 NULL, 473 erf_get_capture_length, 474 erf_get_wire_length, 475 erf_truncate_packet 494 dag_init_input, /* init_input */ 495 NULL, /* init_output */ 496 dag_fin_input, /* fin_input */ 497 NULL, /* fin_output */ 498 dag_read, /* read */ 499 dag_read_packet, /* read_packet */ 500 NULL, /* write_packet */ 501 erf_get_link, /* get_link */ 502 erf_get_link_type, /* get_link_type */ 503 erf_get_direction, /* get_direction */ 504 erf_set_direction, /* set_direction */ 505 erf_get_erf_timestamp, /* get_erf_timestamp */ 506 NULL, /* get_timeval */ 507 NULL, /* get_seconds */ 508 erf_get_capture_length, /* get_capture_length */ 509 erf_get_wire_length, /* get_wire_length */ 510 erf_set_capture_length /* set_capture_length */ 476 511 }; 477 512 … … 479 514 "rtclient", 480 515 "$Id$", 481 rtclient_init_input, 482 NULL, 483 rtclient_fin_input, 484 rtclient_read, 485 rtclient_read_packet, 486 NULL, 487 erf_get_link, 488 erf_get_link_type, 489 erf_get_direction, 490 erf_set_direction, 491 erf_get_erf_timestamp, 492 NULL, 493 NULL, 494 erf_get_capture_length, 495 erf_get_wire_length, 496 erf_truncate_packet 516 rtclient_init_input, /* init_input */ 517 NULL, /* init_output */ 518 rtclient_fin_input, /* fin_input */ 519 NULL, /* fin_output */ 520 rtclient_read, /* read */ 521 rtclient_read_packet, /* read_packet */ 522 NULL, /* write_packet */ 523 erf_get_link, /* get_link */ 524 erf_get_link_type, /* get_link_type */ 525 erf_get_direction, /* get_direction */ 526 erf_set_direction, /* set_direction */ 527 erf_get_erf_timestamp, /* get_erf_timestamp */ 528 NULL, /* get_timeval */ 529 NULL, /* get_seconds */ 530 erf_get_capture_length, /* get_capture_length */ 531 erf_get_wire_length, /* get_wire_length */ 532 erf_set_capture_length /* set_capture_length */ 497 533 }; 498 534 … … 500 536 register_format(&erf); 501 537 register_format(&dag); 502 } 538 register_format(&rtclient); 539 } -
lib/format_pcap.c
r4dedc28 r7050c10 242 242 } 243 243 244 static size_t pcap_ truncate_packet(struct libtrace_packet_t *packet,size_t size) {244 static size_t pcap_set_capture_length(struct libtrace_packet_t *packet,size_t size) { 245 245 struct pcap_pkthdr *pcapptr = 0; 246 246 assert(packet); … … 258 258 "pcap", 259 259 "$Id$", 260 pcap_init_input, 261 NULL, 262 pcap_fin_input, 263 NULL, 264 pcap_read_packet, 265 NULL, 266 pcap_get_link, 267 pcap_get_link_type, 268 pcap_get_direction, 269 NULL, 270 NULL, 271 pcap_get_timeval, 272 NULL, 273 pcap_get_capture_length, 274 pcap_get_wire_length, 275 pcap_truncate_packet 260 pcap_init_input, /* init_input */ 261 NULL, /* init_output */ 262 pcap_fin_input, /* fin_input */ 263 NULL, /* fin_output */ 264 NULL, /* read */ 265 pcap_read_packet, /* read_packet */ 266 NULL, /* write_packet */ 267 pcap_get_link, /* get_link */ 268 pcap_get_link_type, /* get_link_type */ 269 pcap_get_direction, /* get_direction */ 270 NULL, /* set_direction */ 271 NULL, /* get_erf_timestamp */ 272 pcap_get_timeval, /* get_timeval */ 273 NULL, /* get_seconds */ 274 pcap_get_capture_length, /* get_capture_length */ 275 pcap_get_wire_length, /* get_wire_length */ 276 pcap_set_capture_length /* set_capture_length */ 276 277 }; 277 278 … … 279 280 "pcapint", 280 281 "$Id$", 281 pcapint_init_input, 282 NULL, 283 pcap_fin_input, 284 NULL, 285 pcap_read_packet, 286 NULL, 287 pcap_get_link, 288 pcap_get_link_type, 289 pcap_get_direction, 290 NULL, 291 NULL, 292 pcap_get_timeval, 293 NULL, 294 pcap_get_capture_length, 295 pcap_get_wire_length, 296 pcap_truncate_packet 282 pcapint_init_input, /* init_input */ 283 NULL, /* init_output */ 284 pcap_fin_input, /* fin_input */ 285 NULL, /* fin_output */ 286 NULL, /* read */ 287 pcap_read_packet, /* read_packet */ 288 NULL, /* write_packet */ 289 pcap_get_link, /* get_link */ 290 pcap_get_link_type, /* get_link_type */ 291 pcap_get_direction, /* get_direction */ 292 NULL, /* set_direction */ 293 NULL, /* get_erf_timestamp */ 294 pcap_get_timeval, /* get_timeval */ 295 NULL, /* get_seconds */ 296 pcap_get_capture_length, /* get_capture_length */ 297 pcap_get_wire_length, /* get_wire_length */ 298 pcap_set_capture_length /* set_capture_length */ 297 299 }; 298 300 -
lib/format_template.c
r4dedc28 r7050c10 42 42 43 43 static int template_fin_input(struct libtrace_t *libtrace) { 44 return -1; 45 } 46 47 static int template_fin_output(struct libtrace_out_t *libtrace) { 44 48 return -1; 45 49 } … … 93 97 } 94 98 95 static size_t template_ truncate_packet(const struct libtrace_packet_t *packet,size_t size) {99 static size_t template_set_capture_length(const struct libtrace_packet_t *packet,size_t size) { 96 100 return -1; 97 101 } … … 100 104 "template", 101 105 "$Id$", 102 template_init_input, 103 template_init_output, 104 template_fin_input, 105 template_read, 106 template_read_packet, 107 template_write_packet, 108 template_get_link, 109 template_get_link_type, 110 template_get_direction, 111 template_set_direction, 112 template_get_erf_timestamp, 113 template_get_timeval, 114 template_get_seconds, 115 template_get_capture_length, 116 template_get_wire_length, 117 template_truncate_packet 106 template_init_input, /* init_input */ 107 template_init_output, /* init_output */ 108 template_fin_input, /* fin_input */ 109 template_fin_output, /* fin_output */ 110 template_read, /* read */ 111 template_read_packet, /* read_packet */ 112 template_write_packet, /* write_packet */ 113 template_get_link, /* get_link */ 114 template_get_link_type, /* get_link_type */ 115 template_get_direction, /* get_direction */ 116 template_set_direction, /* set_direction */ 117 template_get_erf_timestamp, /* get_erf_timestamp */ 118 template_get_timeval, /* get_timeval */ 119 template_get_seconds, /* get_seconds */ 120 template_get_capture_length, /* get_capture_length */ 121 template_get_wire_length, /* get_wire_length */ 122 template_set_capture_length /* set_capture_length */ 118 123 }; 119 124 -
lib/trace.c
r4dedc28 r7050c10 1604 1604 } 1605 1605 1606 size_t trace_truncate_packet(struct libtrace_packet_t *packet, size_t size) { 1607 return trace_set_capture_length(packet,size); 1608 } 1609 1606 1610 /** Truncate the packet at the suggested length 1607 1611 * @param packet the packet opaque pointer … … 1614 1618 * @author Daniel Lawson 1615 1619 */ 1616 size_t trace_ truncate_packet(struct libtrace_packet_t *packet, size_t size) {1620 size_t trace_set_capture_length(struct libtrace_packet_t *packet, size_t size) { 1617 1621 dag_record_t *erfptr; 1618 1622 #if HAVE_PCAP
Note: See TracChangeset
for help on using the changeset viewer.