- Timestamp:
- 09/19/06 10:44:02 (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:
- e5222e1
- Parents:
- 3eff1c8
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_rt.c
r85a79b0 re502f76 223 223 } 224 224 225 return rt_connect(libtrace);225 return 0; 226 226 } 227 227 … … 232 232 start_msg.length = 0; 233 233 234 if (rt_connect(libtrace) == -1) 235 return -1; 234 236 235 237 /* Need to send start message to server */ … … 240 242 } 241 243 244 return 0; 245 } 246 247 static int rt_pause_input(libtrace_t *libtrace) { 248 close(RT_INFO->input_fd); 242 249 return 0; 243 250 } … … 478 485 static int rt_read_packet_versatile(libtrace_t *libtrace, 479 486 libtrace_packet_t *packet,int blocking) { 480 rt_header_t rt_hdr;487 static rt_header_t rt_hdr; 481 488 static rt_header_t *pkt_hdr = 0; 482 int pkt_size = 0; 483 uint32_t seqno; 484 485 if (pkt_hdr == 0) 489 490 if (pkt_hdr == 0) { 491 /* first time through */ 486 492 pkt_hdr = malloc(sizeof(rt_header_t)); 493 rt_hdr.type = RT_LAST; 494 } 487 495 488 496 if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { … … 491 499 } 492 500 493 494 /* FIXME: Better error handling required */ 495 if (rt_read(libtrace, (void **)&pkt_hdr, sizeof(rt_header_t),blocking) != 496 sizeof(rt_header_t)) { 497 return -1; 498 } 499 500 /* Need to salvage these in case the next rt_read overwrites the 501 * buffer they came from! */ 502 packet->type = pkt_hdr->type; 503 pkt_size = pkt_hdr->length; 504 packet->size = pkt_hdr->length; 505 seqno = pkt_hdr->sequence; 501 /* RT_LAST means that the next bytes received should be a 502 * rt header - I know it's hax and maybe I'll fix it later on */ 503 if (rt_hdr.type == RT_LAST) { 504 505 /* FIXME: Better error handling required */ 506 if (rt_read(libtrace, (void **)&pkt_hdr, 507 sizeof(rt_header_t),blocking) != 508 sizeof(rt_header_t)) { 509 return -1; 510 } 511 512 /* Need to salvage these in case the next rt_read overwrites 513 * the buffer they came from! */ 514 rt_hdr.type = pkt_hdr->type; 515 rt_hdr.length = pkt_hdr->length; 516 rt_hdr.sequence = pkt_hdr->sequence; 517 } 518 packet->type = rt_hdr.type; 519 packet->size = rt_hdr.length; 506 520 507 521 if (packet->type >= RT_DATA_SIMPLE) { 508 if (rt_read(libtrace, &packet->buffer, pkt_size,1) != pkt_size) { 509 printf("Error receiving packet\n"); 522 if (rt_read(libtrace, &packet->buffer, rt_hdr.length,blocking) != rt_hdr.length) { 510 523 return -1; 511 524 } 512 525 packet->header = packet->buffer; 513 526 527 if (RT_INFO->reliable > 0) { 528 if (rt_send_ack(libtrace, rt_hdr.sequence) 529 == -1) 530 { 531 return -1; 532 } 533 } 534 535 514 536 if (rt_set_format(libtrace, packet) < 0) { 515 537 return -1; 516 538 } 517 539 rt_set_payload(packet); 518 if (RT_INFO->reliable > 0) {519 if (rt_send_ack(libtrace, seqno)520 == -1)521 {522 return -1;523 }524 }525 540 } else { 526 541 switch(packet->type) { 527 542 case RT_STATUS: 528 543 if (rt_read(libtrace, &packet->buffer, 529 pkt_size,1) != 530 pkt_size) { 531 printf("Error receiving status packet\n"); 544 rt_hdr.length, blocking) != 545 rt_hdr.length) { 532 546 return -1; 533 547 } … … 538 552 case RT_DUCK_2_5: 539 553 if (rt_read(libtrace, &packet->buffer, 540 pkt_size, 1) != 541 pkt_size) { 542 printf("Error receiving DUCK packet\n"); 554 rt_hdr.length, blocking) != 555 rt_hdr.length) { 543 556 return -1; 544 557 } … … 559 572 case RT_KEYCHANGE: 560 573 break; 574 case RT_LOSTCONN: 575 break; 561 576 default: 562 577 printf("Bad rt type for client receipt: %d\n", … … 566 581 } 567 582 /* Return the number of bytes read from the stream */ 583 rt_hdr.type = RT_LAST; 568 584 return packet->size; 569 585 } … … 636 652 } 637 653 else { 638 printf("packet error\n");654 //printf("packet error\n"); 639 655 event.type = TRACE_EVENT_PACKET; 640 656 } … … 670 686 NULL, /* config_input */ 671 687 rt_start_input, /* start_input */ 688 rt_pause_input, /* pause */ 672 689 NULL, /* init_output */ 673 690 NULL, /* config_output */ 674 691 NULL, /* start_output */ 675 NULL, /* pause_output */676 692 rt_fin_input, /* fin_input */ 677 693 NULL, /* fin_output */ -
lib/rt_protocol.h
rd8fea2b re502f76 54 54 RT_DUCK_2_4 =13, /**< Dag 2.4 Duck */ 55 55 RT_DUCK_2_5 =14, /**< Dag 2.5 Duck */ 56 RT_LOSTCONN =15, /**< Lost connection to server */ 56 57 57 58 RT_DATA_ERF =RT_DATA_SIMPLE + TRACE_FORMAT_ERF, -
lib/trace.c
rd694056 re502f76 117 117 static char *xstrndup(const char *src,size_t n) 118 118 { 119 char *ret=( restrictchar*)malloc(n+1);119 char *ret=(char*)malloc(n+1); 120 120 if (ret==NULL) { 121 121 fprintf(stderr,"Out of memory");
Note: See TracChangeset
for help on using the changeset viewer.