Changeset 9a36e6d
- Timestamp:
- 08/01/05 16:48:53 (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:
- 37a39b7
- Parents:
- 1fc2f6a
- Location:
- lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile.am
r1fc2f6a r9a36e6d 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 rtserver.c rtserver.h3 libtrace_la_SOURCES = trace.c fifo.c fifo.h common.h format_template.c format_erf.c format_pcap.c format_wag.c rtserver.c rtserver.h 4 4 libtrace_la_CFLAGS = @ADD_INCLS@ 5 5 libtrace_la_LIBADD = @ADD_LIBS@ @LTLIBOBJS@ -
lib/format_erf.c
r1fc2f6a r9a36e6d 555 555 ethptr = ((uint8_t *)packet->buffer + 556 556 dag_record_size + 2); 557 return ethptr;557 return (void *)ethptr; 558 558 } 559 559 -
lib/trace.c
r1fc2f6a r9a36e6d 334 334 struct libtrace_t *trace_create(char *uri) { 335 335 struct libtrace_t *libtrace = malloc(sizeof(struct libtrace_t)); 336 struct hostent *he;337 struct sockaddr_in remote;338 struct sockaddr_un unix_sock;339 #if HAVE_PCAP340 char errbuf[PCAP_ERRBUF_SIZE];341 #endif342 336 343 337 if(init_trace(&libtrace,uri) == 0) { … … 445 439 } 446 440 447 static int trace_read(struct libtrace_t *libtrace, void *buffer, size_t len) {448 int numbytes;449 static short lctr = 0;450 struct dag_record_t *recptr = 0;451 int rlen;452 assert(libtrace);453 assert(len >= 0);454 455 if (buffer == 0)456 buffer = malloc(len);457 458 while(1) {459 switch(libtrace->sourcetype) {460 case SOCKET:461 case RT:462 463 #ifndef MSG_NOSIGNAL464 #define MSG_NOSIGNAL 0465 #endif466 // read from the network467 if ((numbytes=recv(libtrace->input.fd,468 buffer,469 len,470 MSG_NOSIGNAL)) == -1) {471 if (errno == EINTR) {472 // ignore EINTR in case473 // a caller is using signals474 continue;475 }476 perror("recv");477 return -1;478 }479 break;480 case DEVICE:481 if (libtrace->format->read) {482 libtrace->format->read(libtrace,buffer,len);483 } else {484 if ((numbytes=read(libtrace->input.fd,485 buffer,486 len)) == -1) {487 perror("read");488 return -1;489 }490 }491 break;492 default:493 #if HAVE_ZLIB494 if ((numbytes=gzread(libtrace->input.file,495 buffer,496 len)) == -1) {497 perror("gzread");498 return -1;499 }500 #else501 if ((numbytes=fread(buffer,len,1,libtrace->input.file)) == 0 ) {502 if(feof(libtrace->input.file)) {503 return 0;504 }505 if(ferror(libtrace->input.file)) {506 perror("fread");507 return -1;508 }509 return 0;510 }511 #endif512 }513 break;514 }515 return numbytes;516 517 }518 519 #if HAVE_PCAP520 void trace_pcap_handler(u_char *user, const struct pcap_pkthdr *pcaphdr, const u_char *pcappkt) {521 struct libtrace_packet_t *packet = (struct libtrace_packet_t *)user;522 void *buffer = packet->buffer;523 int numbytes = 0;524 525 memcpy(buffer,pcaphdr,sizeof(struct pcap_pkthdr));526 numbytes = pcaphdr->len;527 memcpy(buffer + sizeof(struct pcap_pkthdr),pcappkt,numbytes);528 529 packet->size = numbytes + sizeof(struct pcap_pkthdr);530 531 }532 #endif533 441 /** Read one packet from the trace into buffer 534 442 * … … 884 792 timestamp = ((((uint64_t)ts.tv_sec) << 32) + \ 885 793 (((uint64_t)ts.tv_usec * UINT_MAX)/1000000)); 886 } 794 } 887 795 return timestamp; 888 796 } … … 1246 1154 */ 1247 1155 int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction) { 1248 1249 1156 assert(packet); 1250 1157 if (packet->trace->format->set_direction) { 1251 1158 return packet->trace->format->set_direction(packet,direction); … … 1264 1171 */ 1265 1172 int8_t trace_get_direction(const struct libtrace_packet_t *packet) { 1266 1267 1173 assert(packet); 1268 1269 1174 if (packet->trace->format->get_direction) { 1270 1175 return packet->trace->format->get_direction(packet); 1271 1176 } 1272 1177 return -1; 1273 1274 1178 } 1275 1179 … … 1440 1344 */ 1441 1345 size_t trace_set_capture_length(struct libtrace_packet_t *packet, size_t size) { 1442 dag_record_t *erfptr;1443 #if HAVE_PCAP1444 struct pcap_pkthdr *pcaphdr;1445 #endif1446 1447 1346 assert(packet); 1448 1347 -
lib/wag.h
r6e60e50 r9a36e6d 31 31 #define _WAG_H_ 32 32 33 struct wag_event_t { 34 uint32_t length; 35 uint32_t timestamp_hi; 36 uint32_t timestamp_lo; 37 uint32_t type; 38 uint32_t seq_num; 39 uint8_t payload[1]; 33 // Generic field breakdowns 34 struct wag_frame_hdr { 35 uint16_t magic; 36 uint16_t size; 37 uint16_t type; 38 uint16_t subtype; 40 39 }; 41 40 42 struct wag_data_event_t { 43 uint32_t rx_params; 44 uint32_t rx_rssi; 45 uint32_t frame_length; 46 uint8_t data[1]; 41 struct wag_timestamp { 42 uint32_t secs; 43 uint32_t subsecs; 44 }; 45 46 // Received packet frame fields 47 struct wag_stream_info { 48 uint16_t unused_1; 49 uint16_t unused_2; 50 uint16_t unused_3; 51 uint16_t packets_lost; 52 }; 53 54 struct wag_plcp_hdr { 55 uint8_t signal; 56 uint8_t service; 57 uint16_t length; 58 }; 59 60 struct wag_rxparams { 61 uint8_t rssi; 62 uint8_t rxstatus; 63 uint16_t length; 64 struct wag_plcp_hdr plcp; 65 }; 66 67 struct wag_data_frame { 68 struct wag_frame_hdr hdr; 69 struct wag_stream_info strinfo; 70 struct wag_timestamp ts; 71 struct wag_rxparams rxinfo; 72 char data[1]; 73 }; 74 75 // Transmit packet frame fields 76 struct wag_txparams { 77 uint8_t gain; 78 uint8_t mode; 79 uint16_t length; 80 uint32_t unused_1; 81 }; 82 83 struct wag_tx_data_frame { 84 struct wag_frame_hdr hdr; 85 uint32_t unused_1; 86 uint32_t unused_2; 87 struct wag_txparams txinfo; 88 char data[1]; 47 89 }; 48 90
Note: See TracChangeset
for help on using the changeset viewer.