Changeset 7050c10 for lib/format_erf.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.