Changeset b5cd711
- Timestamp:
- 08/26/05 11:22:23 (15 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:
- 53f8305
- Parents:
- 1974620
- Location:
- lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile.am
ra8ba977 rb5cd711 1 1 lib_LTLIBRARIES = libtrace.la 2 include_HEADERS = libtrace.h dagformat.h wag.h 2 include_HEADERS = libtrace.h dagformat.h wag.h 3 3 libtrace_la_SOURCES = trace.c fifo.c fifo.h common.h format_template.c format_erf.c format_pcap.c format_wag.c format_helper.c format_helper.h rtserver.c rtserver.h parse_cmd.c parse_cmd.h libtrace_int.h 4 4 libtrace_la_CFLAGS = @ADD_INCLS@ -
lib/dagformat.h
r299e9a0 rb5cd711 62 62 } __attribute__((packed)) dag_record_t; 63 63 64 65 typedef struct duck_inf 66 { 67 unsigned long Command, Config, Clock_Inc, Clock_Wrap, DDS_Rate; 68 unsigned long Crystal_Freq; 69 unsigned long Synth_Freq, Sync_Rate; 70 unsigned long long Last_Ticks; 71 unsigned long Resyncs; 72 unsigned long Bad_Diffs, Bad_Offs, Bad_Pulses; 73 unsigned long Worst_Error, Worst_Off; 74 unsigned long Off_Limit, Off_Damp; 75 unsigned long Pulses, Single_Pulses_Missing, Longest_Pulse_Missing; 76 unsigned long Health, Sickness; 77 long Error, Offset; 78 long Stat_Start, Stat_End; /* these are really time_t's */ 79 unsigned long Set_Duck_Field; 80 } duck_inf; 81 64 82 #define dag_record_size 16 65 83 -
lib/fifo.c
r23c13e8 rb5cd711 57 57 enum which_t { IN, OUT, ACK }; 58 58 59 struct fifo_t {59 struct tracefifo_t { 60 60 size_t length; 61 61 size_t datamap[3]; … … 66 66 67 67 68 static char * fifo_stat_buffer = 0;69 70 static void increment_pointer(struct fifo_t *fifo, enum which_t which, int amount);71 static void set_pointer(struct fifo_t *fifo, enum which_t which, int location);72 static size_t fifo_compare(structfifo_t *fifo, enum which_t first, enum which_t second);73 static int fifo_read_generic(structfifo_t *fifo, void *buffer, size_t len, enum which_t which, char update);74 75 struct fifo_t *create_fifo(size_t size)68 static char *tracefifo_stat_buffer = 0; 69 70 static void increment_pointer(struct tracefifo_t *fifo, enum which_t which, int amount); 71 static void set_pointer(struct tracefifo_t *fifo, enum which_t which, int location); 72 static size_t tracefifo_compare(struct tracefifo_t *fifo, enum which_t first, enum which_t second); 73 static int tracefifo_read_generic(struct tracefifo_t *fifo, void *buffer, size_t len, enum which_t which, char update); 74 75 struct tracefifo_t *create_tracefifo(size_t size) 76 76 { 77 77 /* Set up our fifo 78 78 */ 79 struct fifo_t *fifo = malloc(sizeof(structfifo_t));79 struct tracefifo_t *fifo = malloc(sizeof(struct tracefifo_t)); 80 80 assert(size > 0); 81 81 82 if ( fifo_stat_buffer == 0)83 fifo_stat_buffer = (char *)malloc(513);82 if (tracefifo_stat_buffer == 0) 83 tracefifo_stat_buffer = (char *)malloc(513); 84 84 fifo->length = size; 85 85 … … 95 95 } 96 96 97 void destroy_ fifo(structfifo_t *fifo)98 { 99 assert(fifo); 100 //free( fifo_stat_buffer);97 void destroy_tracefifo(struct tracefifo_t *fifo) 98 { 99 assert(fifo); 100 //free(tracefifo_stat_buffer); 101 101 free(fifo->base); 102 102 free(fifo); 103 103 } 104 104 105 static void increment_pointer(struct fifo_t *fifo, enum which_t which, int amount) {105 static void increment_pointer(struct tracefifo_t *fifo, enum which_t which, int amount) { 106 106 assert(fifo); 107 107 assert(which == IN || which == OUT || which == ACK); … … 115 115 } 116 116 117 void fifo_flush(structfifo_t *fifo) {117 void tracefifo_flush(struct tracefifo_t *fifo) { 118 118 // do nothing 119 119 return; 120 120 } 121 121 122 static void set_pointer(struct fifo_t *fifo, enum which_t which, int location) {122 static void set_pointer(struct tracefifo_t *fifo, enum which_t which, int location) { 123 123 assert(fifo); 124 124 assert(which == IN || which == OUT || which == ACK); … … 130 130 } 131 131 132 static size_t fifo_compare(structfifo_t *fifo, enum which_t first, enum which_t second) {132 static size_t tracefifo_compare(struct tracefifo_t *fifo, enum which_t first, enum which_t second) { 133 133 assert(fifo); 134 134 assert(first == IN || first == OUT || first == ACK); … … 145 145 } 146 146 147 size_t fifo_free(structfifo_t *fifo) {148 assert(fifo); 149 return (fifo->length - fifo_compare(fifo,IN,ACK));147 size_t tracefifo_free(struct tracefifo_t *fifo) { 148 assert(fifo); 149 return (fifo->length - tracefifo_compare(fifo,IN,ACK)); 150 150 } 151 151 152 size_t fifo_length(structfifo_t *fifo) {152 size_t tracefifo_length(struct tracefifo_t *fifo) { 153 153 assert(fifo); 154 154 return fifo->length; 155 155 } 156 156 157 size_t fifo_out_available(structfifo_t *fifo) {158 assert(fifo); 159 return fifo_compare(fifo,IN,OUT);160 } 161 162 size_t fifo_ack_available(structfifo_t *fifo) {163 assert(fifo); 164 return fifo_compare(fifo,OUT,ACK);165 } 166 167 void fifo_stat_int(struct fifo_t *fifo,fifo_state_t *state)157 size_t tracefifo_out_available(struct tracefifo_t *fifo) { 158 assert(fifo); 159 return tracefifo_compare(fifo,IN,OUT); 160 } 161 162 size_t tracefifo_ack_available(struct tracefifo_t *fifo) { 163 assert(fifo); 164 return tracefifo_compare(fifo,OUT,ACK); 165 } 166 167 void tracefifo_stat_int(struct tracefifo_t *fifo, tracefifo_state_t *state) 168 168 { 169 169 assert(fifo); … … 174 174 state->ack = fifo->datamap[ACK]; 175 175 state->length = fifo->length; 176 state->used = fifo_compare(fifo,IN,ACK);177 178 } 179 char * fifo_stat_str(structfifo_t *fifo, char *desc, int delta)176 state->used = tracefifo_compare(fifo,IN,ACK); 177 178 } 179 char *tracefifo_stat_str(struct tracefifo_t *fifo, char *desc, int delta) 180 180 { 181 181 char *scan = 0; 182 182 assert(fifo); 183 183 184 bzero( fifo_stat_buffer,513);185 scan = fifo_stat_buffer;184 bzero(tracefifo_stat_buffer,513); 185 scan = tracefifo_stat_buffer; 186 186 if (desc) 187 187 scan += sprintf(scan,"%s\t",desc); … … 191 191 if (delta > 0) 192 192 scan += sprintf(scan,"delta: %d\t", delta); 193 scan += sprintf(scan,"Size: %d", fifo_compare(fifo,IN,ACK));193 scan += sprintf(scan,"Size: %d", tracefifo_compare(fifo,IN,ACK)); 194 194 scan += sprintf(scan,"\n"); 195 return fifo_stat_buffer;196 } 197 void fifo_stat(structfifo_t *fifo, char *desc, int delta)198 { 199 assert(fifo); 200 201 printf("%s", fifo_stat_str(fifo,desc,delta));195 return tracefifo_stat_buffer; 196 } 197 void tracefifo_stat(struct tracefifo_t *fifo, char *desc, int delta) 198 { 199 assert(fifo); 200 201 printf("%s",tracefifo_stat_str(fifo,desc,delta)); 202 202 } 203 203 … … 206 206 * starting at the pointer corresponding to which - if thats bogus data then its not 207 207 * the fault of this function */ 208 static int fifo_read_generic(structfifo_t *fifo, void *buffer, size_t len, enum which_t which, char update) {208 static int tracefifo_read_generic(struct tracefifo_t *fifo, void *buffer, size_t len, enum which_t which, char update) { 209 209 size_t oldptr; 210 210 int lenleft; … … 232 232 } 233 233 234 int fifo_write(structfifo_t *fifo, void *buffer, size_t len) {234 int tracefifo_write(struct tracefifo_t *fifo, void *buffer, size_t len) { 235 235 int lenleft; 236 236 int size; … … 239 239 assert(len >= 0); 240 240 241 if ( fifo_free(fifo) < len) {241 if (tracefifo_free(fifo) < len) { 242 242 return 0; 243 243 } … … 257 257 258 258 259 int fifo_out_read(structfifo_t *fifo, void *buffer, size_t len) {259 int tracefifo_out_read(struct tracefifo_t *fifo, void *buffer, size_t len) { 260 260 assert(fifo); 261 261 assert(buffer); 262 262 assert(len >= 0); 263 if ( fifo_compare(fifo,IN,OUT) < len) {264 return 0; 265 } 266 return fifo_read_generic(fifo,buffer,len,OUT,0);267 } 268 269 int fifo_ack_read(structfifo_t *fifo, void *buffer, size_t len) {263 if (tracefifo_compare(fifo,IN,OUT) < len) { 264 return 0; 265 } 266 return tracefifo_read_generic(fifo,buffer,len,OUT,0); 267 } 268 269 int tracefifo_ack_read(struct tracefifo_t *fifo, void *buffer, size_t len) { 270 270 assert(fifo); 271 271 assert(buffer); 272 272 assert(len >= 0); 273 if ( fifo_compare(fifo,OUT,ACK) < len) {274 return 0; 275 } 276 return fifo_read_generic(fifo,buffer,len,ACK,0);277 } 278 279 int fifo_out_update(structfifo_t *fifo, size_t len){280 assert(fifo); 281 assert(len >= 0); 282 if ( fifo_compare(fifo,IN,OUT) < len) {273 if (tracefifo_compare(fifo,OUT,ACK) < len) { 274 return 0; 275 } 276 return tracefifo_read_generic(fifo,buffer,len,ACK,0); 277 } 278 279 int tracefifo_out_update(struct tracefifo_t *fifo, size_t len){ 280 assert(fifo); 281 assert(len >= 0); 282 if (tracefifo_compare(fifo,IN,OUT) < len) { 283 283 return 0; 284 284 } … … 287 287 } 288 288 289 int fifo_ack_update(structfifo_t *fifo, size_t len){290 assert(fifo); 291 assert(len >= 0); 292 if ( fifo_compare(fifo,OUT,ACK) < len) {289 int tracefifo_ack_update(struct tracefifo_t *fifo, size_t len){ 290 assert(fifo); 291 assert(len >= 0); 292 if (tracefifo_compare(fifo,OUT,ACK) < len) { 293 293 return 0; 294 294 } … … 297 297 } 298 298 299 void fifo_out_reset(structfifo_t *fifo) {299 void tracefifo_out_reset(struct tracefifo_t *fifo) { 300 300 /* 301 301 * This will reset the sent pointer back to the ack pointer. This -
lib/fifo.h
ra79ddbe rb5cd711 33 33 #define _FIFO_H_ 34 34 35 struct fifo_t;35 struct tracefifo_t; 36 36 37 typedef struct fifo_state {37 typedef struct tracefifo_state { 38 38 long long int in; 39 39 long long int out; … … 41 41 long long int length; 42 42 long long int used; 43 } fifo_state_t;43 } tracefifo_state_t; 44 44 45 45 46 struct fifo_t *create_fifo(size_t size);47 void destroy_ fifo(structfifo_t *fifo);46 struct tracefifo_t *create_tracefifo(size_t size); 47 void destroy_tracefifo(struct tracefifo_t *fifo); 48 48 49 49 50 void fifo_stat(structfifo_t *fifo, char *desc, int delta);51 char * fifo_stat_str(structfifo_t *fifo, char *desc, int delta);52 void fifo_stat_int(struct fifo_t *fifo,fifo_state_t *state);50 void tracefifo_stat(struct tracefifo_t *fifo, char *desc, int delta); 51 char *tracefifo_stat_str(struct tracefifo_t *fifo, char *desc, int delta); 52 void tracefifo_stat_int(struct tracefifo_t *fifo, tracefifo_state_t *state); 53 53 54 size_t fifo_out_available(structfifo_t *fifo);55 size_t fifo_ack_available(structfifo_t *fifo);56 size_t fifo_free(structfifo_t *fifo);57 size_t fifo_length(structfifo_t *fifo);54 size_t tracefifo_out_available(struct tracefifo_t *fifo); 55 size_t tracefifo_ack_available(struct tracefifo_t *fifo); 56 size_t tracefifo_free(struct tracefifo_t *fifo); 57 size_t tracefifo_length(struct tracefifo_t *fifo); 58 58 59 int fifo_write(structfifo_t *fifo, void *buffer, size_t len);59 int tracefifo_write(struct tracefifo_t *fifo, void *buffer, size_t len); 60 60 61 int fifo_out_read(structfifo_t *fifo, void *buffer, size_t len);62 int fifo_ack_read(structfifo_t *fifo, void *buffer, size_t len);63 int fifo_out_update(structfifo_t *fifo, size_t len);64 int fifo_ack_update(structfifo_t *fifo, size_t len);61 int tracefifo_out_read(struct tracefifo_t *fifo, void *buffer, size_t len); 62 int tracefifo_ack_read(struct tracefifo_t *fifo, void *buffer, size_t len); 63 int tracefifo_out_update(struct tracefifo_t *fifo, size_t len); 64 int tracefifo_ack_update(struct tracefifo_t *fifo, size_t len); 65 65 66 void fifo_out_reset(structfifo_t *fifo);66 void tracefifo_out_reset(struct tracefifo_t *fifo); 67 67 68 void fifo_flush(structfifo_t *fifo);68 void tracefifo_flush(struct tracefifo_t *fifo); 69 69 70 70 -
lib/format_erf.c
r1974620 rb5cd711 572 572 573 573 do { 574 if ( fifo_out_available(libtrace->fifo) == 0 || read_required) {574 if (tracefifo_out_available(libtrace->fifo) == 0 || read_required) { 575 575 if ((numbytes = rtclient_read( 576 576 libtrace,buf,RP_BUFSIZE))<=0) { 577 577 return numbytes; 578 578 } 579 fifo_write(libtrace->fifo,buf,numbytes);579 tracefifo_write(libtrace->fifo,buf,numbytes); 580 580 read_required = 0; 581 581 } 582 582 // Read status byte 583 if ( fifo_out_read(libtrace->fifo,583 if (tracefifo_out_read(libtrace->fifo, 584 584 &packet->status, sizeof(int)) == 0) { 585 585 read_required = 1; 586 586 continue; 587 587 } 588 fifo_out_update(libtrace->fifo,sizeof(int));588 tracefifo_out_update(libtrace->fifo,sizeof(int)); 589 589 590 590 // read in the ERF header 591 if ((numbytes = fifo_out_read(libtrace->fifo, buffer,591 if ((numbytes = tracefifo_out_read(libtrace->fifo, buffer, 592 592 sizeof(dag_record_t))) == 0) { 593 fifo_out_reset(libtrace->fifo);593 tracefifo_out_reset(libtrace->fifo); 594 594 read_required = 1; 595 595 continue; … … 598 598 599 599 // read in the full packet 600 if ((numbytes = fifo_out_read(libtrace->fifo,600 if ((numbytes = tracefifo_out_read(libtrace->fifo, 601 601 buffer, size)) == 0) { 602 fifo_out_reset(libtrace->fifo);602 tracefifo_out_reset(libtrace->fifo); 603 603 read_required = 1; 604 604 continue; … … 606 606 607 607 // got in our whole packet, so... 608 fifo_out_update(libtrace->fifo,size);609 610 fifo_ack_update(libtrace->fifo,size + sizeof(int));608 tracefifo_out_update(libtrace->fifo,size); 609 610 tracefifo_ack_update(libtrace->fifo,size + sizeof(int)); 611 611 612 612 packet->size = numbytes; … … 699 699 700 700 assert(libtrace->fifo); 701 if ( fifo_out_available(libtrace->fifo) == 0 || write_required) {701 if (tracefifo_out_available(libtrace->fifo) == 0 || write_required) { 702 702 // Packet added to fifo 703 if ((numbytes = fifo_write(libtrace->fifo, packet->buffer, packet->size)) == 0) {703 if ((numbytes = tracefifo_write(libtrace->fifo, packet->buffer, packet->size)) == 0) { 704 704 // some error with the fifo 705 perror(" fifo_write");705 perror("tracefifo_write"); 706 706 return -1; 707 707 } … … 710 710 711 711 // Read from fifo and add protocol header 712 if ((numbytes = fifo_out_read(libtrace->fifo, buffer, sizeof(dag_record_t))) == 0) {712 if ((numbytes = tracefifo_out_read(libtrace->fifo, buffer, sizeof(dag_record_t))) == 0) { 713 713 // failure reading in from fifo 714 fifo_out_reset(libtrace->fifo);714 tracefifo_out_reset(libtrace->fifo); 715 715 write_required = 1; 716 716 continue; … … 718 718 size = ntohs(((dag_record_t *)buffer)->rlen); 719 719 assert(size < LIBTRACE_PACKET_BUFSIZE); 720 if ((numbytes = fifo_out_read(libtrace->fifo, buffer, size)) == 0) {720 if ((numbytes = tracefifo_out_read(libtrace->fifo, buffer, size)) == 0) { 721 721 // failure reading in from fifo 722 fifo_out_reset(libtrace->fifo);722 tracefifo_out_reset(libtrace->fifo); 723 723 write_required = 1; 724 724 continue; … … 733 733 734 734 735 fifo_out_update(libtrace->fifo, size);736 fifo_ack_update(libtrace->fifo, size);735 tracefifo_out_update(libtrace->fifo, size); 736 tracefifo_ack_update(libtrace->fifo, size); 737 737 return numbytes; 738 738 } while(1); -
lib/format_wag.c
r1974620 rb5cd711 312 312 313 313 do { 314 if ( fifo_out_available(libtrace->fifo) == 0 || read_required) {314 if (tracefifo_out_available(libtrace->fifo) == 0 || read_required) { 315 315 if ((numbytes = wag_read(libtrace,buf,RP_BUFSIZE)) <= 0) { 316 316 return numbytes; 317 317 } 318 318 assert(libtrace->fifo); 319 fifo_write(libtrace->fifo,buf,numbytes);319 tracefifo_write(libtrace->fifo,buf,numbytes); 320 320 read_required = 0; 321 321 } 322 322 // read in wag_frame_hdr 323 if ((numbytes = fifo_out_read(libtrace->fifo,323 if ((numbytes = tracefifo_out_read(libtrace->fifo, 324 324 buffer, 325 325 sizeof(struct wag_frame_hdr))) 326 326 == 0 ) { 327 fifo_out_reset(libtrace->fifo);327 tracefifo_out_reset(libtrace->fifo); 328 328 read_required = 1; 329 329 continue; … … 337 337 338 338 // read in full packet 339 if((numbytes = fifo_out_read(libtrace->fifo,buffer,size)) == 0) {340 fifo_out_reset(libtrace->fifo);339 if((numbytes = tracefifo_out_read(libtrace->fifo,buffer,size)) == 0) { 340 tracefifo_out_reset(libtrace->fifo); 341 341 read_required = 1; 342 342 continue; … … 344 344 345 345 // have the whole packet 346 fifo_out_update(libtrace->fifo,size);347 fifo_ack_update(libtrace->fifo,size);346 tracefifo_out_update(libtrace->fifo,size); 347 tracefifo_ack_update(libtrace->fifo,size); 348 348 349 349 packet->size = numbytes; -
lib/libtrace_int.h
r1974620 rb5cd711 108 108 struct libtrace_event_t event; 109 109 char *uridata; 110 struct fifo_t *fifo;110 struct tracefifo_t *fifo; 111 111 112 112 }; … … 117 117 118 118 char *uridata; 119 struct fifo_t *fifo;119 struct tracefifo_t *fifo; 120 120 }; 121 121 -
lib/trace.c
r1974620 rb5cd711 302 302 303 303 304 libtrace->fifo = create_ fifo(1048576);304 libtrace->fifo = create_tracefifo(1048576); 305 305 assert( libtrace->fifo); 306 306 … … 376 376 377 377 378 libtrace->fifo = create_ fifo(1048576);378 libtrace->fifo = create_tracefifo(1048576); 379 379 assert( libtrace->fifo); 380 380 … … 417 417 // need to free things! 418 418 free(libtrace->uridata); 419 destroy_ fifo(libtrace->fifo);419 destroy_tracefifo(libtrace->fifo); 420 420 free(libtrace); 421 421 } … … 431 431 libtrace->format->fin_output(libtrace); 432 432 free(libtrace->uridata); 433 destroy_ fifo(libtrace->fifo);433 destroy_tracefifo(libtrace->fifo); 434 434 free(libtrace); 435 435 }
Note: See TracChangeset
for help on using the changeset viewer.