Changeset 39e141f for lib/trace.c
- Timestamp:
- 04/21/06 10:28:36 (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:
- 222d8f5
- Parents:
- d0906e7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
r9e46ee7 r39e141f 203 203 * and then prints out the help() function registered with each input module 204 204 */ 205 void trace_help() {205 DLLEXPORT void trace_help() { 206 206 struct libtrace_format_t *tmp; 207 207 printf("libtrace %s\n",PACKAGE_VERSION); … … 221 221 * 222 222 */ 223 SIMPLE_FUNCTION223 DLLEXPORT SIMPLE_FUNCTION 224 224 char *trace_get_output_format(const struct libtrace_out_t *libtrace) { 225 225 char * format = libtrace->format->name; … … 252 252 * and an error is output to stdout. 253 253 */ 254 struct libtrace_t *trace_create(const char *uri) {254 DLLEXPORT struct libtrace_t *trace_create(const char *uri) { 255 255 struct libtrace_t *libtrace = 256 256 (struct libtrace_t *)malloc(sizeof(struct libtrace_t)); … … 328 328 * libtrace_packet_t's that are not associated with a libtrace_t structure. 329 329 */ 330 struct libtrace_t * trace_create_dead (const char *uri) {330 DLLEXPORT struct libtrace_t * trace_create_dead (const char *uri) { 331 331 struct libtrace_t *libtrace = (struct libtrace_t *) 332 332 malloc(sizeof(struct libtrace_t)); … … 375 375 */ 376 376 377 libtrace_out_t *trace_create_output(const char *uri) {377 DLLEXPORT libtrace_out_t *trace_create_output(const char *uri) { 378 378 libtrace_out_t *libtrace = 379 379 (libtrace_out_t*)malloc(sizeof(struct libtrace_out_t)); … … 446 446 * the trace. it may fail. 447 447 */ 448 int trace_start(struct libtrace_t *libtrace)448 DLLEXPORT int trace_start(struct libtrace_t *libtrace) 449 449 { 450 450 assert(libtrace); … … 460 460 } 461 461 462 int trace_start_output(libtrace_out_t *libtrace)462 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace) 463 463 { 464 464 assert(libtrace); … … 474 474 } 475 475 476 int trace_pause(libtrace_t *libtrace)476 DLLEXPORT int trace_pause(libtrace_t *libtrace) 477 477 { 478 478 assert(libtrace); … … 484 484 } 485 485 486 int trace_config(libtrace_t *libtrace,486 DLLEXPORT int trace_config(libtrace_t *libtrace, 487 487 trace_option_t option, 488 488 void *value) … … 519 519 * @author Shane Alcock 520 520 */ 521 int trace_config_output(struct libtrace_out_t *libtrace,521 DLLEXPORT int trace_config_output(struct libtrace_out_t *libtrace, 522 522 trace_option_output_t option, 523 523 void *value) { … … 531 531 * 532 532 */ 533 void trace_destroy(struct libtrace_t *libtrace) {533 DLLEXPORT void trace_destroy(struct libtrace_t *libtrace) { 534 534 assert(libtrace); 535 535 if (libtrace->started && libtrace->format->pause_input) … … 543 543 544 544 545 void trace_destroy_dead(struct libtrace_t *libtrace) {545 DLLEXPORT void trace_destroy_dead(struct libtrace_t *libtrace) { 546 546 assert(libtrace); 547 547 free(libtrace); … … 553 553 * @author Shane Alcock 554 554 * */ 555 void trace_destroy_output(struct libtrace_out_t *libtrace) {555 DLLEXPORT void trace_destroy_output(struct libtrace_out_t *libtrace) { 556 556 assert(libtrace); 557 557 libtrace->format->fin_output(libtrace); … … 560 560 } 561 561 562 libtrace_packet_t *trace_create_packet() {562 DLLEXPORT libtrace_packet_t *trace_create_packet() { 563 563 libtrace_packet_t *packet = 564 564 (libtrace_packet_t*)calloc(1,sizeof(libtrace_packet_t)); … … 567 567 } 568 568 569 libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet) {569 DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet) { 570 570 libtrace_packet_t *dest = 571 571 (libtrace_packet_t *)malloc(sizeof(libtrace_packet_t)); … … 590 590 * sideeffect: sets packet to NULL 591 591 */ 592 void trace_destroy_packet(struct libtrace_packet_t **packet) {592 DLLEXPORT void trace_destroy_packet(struct libtrace_packet_t **packet) { 593 593 if ((*packet)->buf_control == TRACE_CTRL_PACKET) { 594 594 free((*packet)->buffer); … … 605 605 * 606 606 */ 607 int trace_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) {607 DLLEXPORT int trace_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { 608 608 609 609 assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n"); … … 652 652 * @author Shane Alcock 653 653 * */ 654 int trace_write_packet(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet) {654 DLLEXPORT int trace_write_packet(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet) { 655 655 assert(libtrace); 656 656 assert(packet); … … 666 666 } 667 667 668 void *trace_get_link(const struct libtrace_packet_t *packet) {668 DLLEXPORT void *trace_get_link(const struct libtrace_packet_t *packet) { 669 669 return (void *)packet->payload; 670 670 } … … 686 686 * @author Daniel Lawson 687 687 */ 688 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {688 DLLEXPORT uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) { 689 689 uint64_t timestamp = 0; 690 690 double seconds = 0.0; … … 717 717 * @author Perry Lorier 718 718 */ 719 struct timeval trace_get_timeval(const libtrace_packet_t *packet) {719 DLLEXPORT struct timeval trace_get_timeval(const libtrace_packet_t *packet) { 720 720 struct timeval tv; 721 721 uint64_t ts = 0; … … 755 755 * @author Perry Lorier 756 756 */ 757 double trace_get_seconds(const struct libtrace_packet_t *packet) {757 DLLEXPORT double trace_get_seconds(const struct libtrace_packet_t *packet) { 758 758 double seconds = 0.0; 759 759 uint64_t ts = 0; … … 778 778 } 779 779 780 size_t trace_get_capture_length(const libtrace_packet_t *packet) {780 DLLEXPORT size_t trace_get_capture_length(const libtrace_packet_t *packet) { 781 781 782 782 assert(packet->size<65536); … … 797 797 * not be the same as the Capture Len. 798 798 */ 799 size_t trace_get_wire_length(const libtrace_packet_t *packet){799 DLLEXPORT size_t trace_get_wire_length(const libtrace_packet_t *packet){ 800 800 assert(packet->size>0 && packet->size<65536); 801 801 … … 815 815 * captured packet in memory, and the captured length of the packet 816 816 */ 817 SIMPLE_FUNCTION817 DLLEXPORT SIMPLE_FUNCTION 818 818 size_t trace_get_framing_length(const libtrace_packet_t *packet) { 819 819 if (packet->trace->format->get_framing_length) { … … 830 830 * @author Daniel Lawson 831 831 */ 832 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet ) {832 DLLEXPORT libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet ) { 833 833 if (packet->trace->format->get_link_type) { 834 834 return packet->trace->format->get_link_type(packet); … … 849 849 * @author Perry Lorier 850 850 */ 851 struct libtrace_eventobj_t trace_event(struct libtrace_t *trace,851 DLLEXPORT struct libtrace_eventobj_t trace_event(struct libtrace_t *trace, 852 852 struct libtrace_packet_t *packet) { 853 853 struct libtrace_eventobj_t event = {TRACE_EVENT_IOWAIT,0,0.0,0}; … … 876 876 * @author Daniel Lawson 877 877 */ 878 struct libtrace_filter_t *trace_bpf_setfilter(const char *filterstring) {878 DLLEXPORT struct libtrace_filter_t *trace_bpf_setfilter(const char *filterstring) { 879 879 #if HAVE_BPF 880 880 struct libtrace_filter_t *filter = (struct libtrace_filter_t*) … … 944 944 } 945 945 946 int trace_bpf_filter(struct libtrace_filter_t *filter,946 DLLEXPORT int trace_bpf_filter(struct libtrace_filter_t *filter, 947 947 const struct libtrace_packet_t *packet) { 948 948 #if HAVE_BPF … … 978 978 * @author Daniel Lawson 979 979 */ 980 int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction) {980 DLLEXPORT int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction) { 981 981 assert(packet); 982 982 assert(packet->size>0 && packet->size<65536); … … 996 996 * @author Daniel Lawson 997 997 */ 998 int8_t trace_get_direction(const struct libtrace_packet_t *packet) {998 DLLEXPORT int8_t trace_get_direction(const struct libtrace_packet_t *packet) { 999 999 assert(packet); 1000 1000 assert(packet->size>0 && packet->size<65536); … … 1020 1020 * @author Daniel Lawson 1021 1021 */ 1022 int8_t trace_get_server_port(uint8_t protocol UNUSED, uint16_t source, uint16_t dest) {1022 DLLEXPORT int8_t trace_get_server_port(uint8_t protocol UNUSED, uint16_t source, uint16_t dest) { 1023 1023 /* 1024 1024 * * If the ports are equal, return DEST … … 1130 1130 * @author Daniel Lawson 1131 1131 */ 1132 size_t trace_set_capture_length(struct libtrace_packet_t *packet, size_t size) {1132 DLLEXPORT size_t trace_set_capture_length(struct libtrace_packet_t *packet, size_t size) { 1133 1133 assert(packet); 1134 1134 assert(packet->size>0 && packet->size<65536); … … 1145 1145 } 1146 1146 1147 const char * trace_parse_uri(const char *uri, char **format) {1147 DLLEXPORT const char * trace_parse_uri(const char *uri, char **format) { 1148 1148 const char *uridata = 0; 1149 1149 … … 1173 1173 } 1174 1174 1175 libtrace_err_t trace_get_err(libtrace_t *trace)1175 DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace) 1176 1176 { 1177 1177 libtrace_err_t err = trace->err; … … 1181 1181 } 1182 1182 1183 bool trace_is_err(libtrace_t *trace)1183 DLLEXPORT bool trace_is_err(libtrace_t *trace) 1184 1184 { 1185 1185 return trace->err.err_num != 0; 1186 1186 } 1187 1187 1188 void trace_perror(libtrace_t *trace,const char *msg,...)1188 DLLEXPORT void trace_perror(libtrace_t *trace,const char *msg,...) 1189 1189 { 1190 1190 char buf[256]; … … 1202 1202 } 1203 1203 1204 libtrace_err_t trace_get_err_output(libtrace_out_t *trace)1204 DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace) 1205 1205 { 1206 1206 libtrace_err_t err = trace->err; … … 1210 1210 } 1211 1211 1212 bool trace_is_err_output(libtrace_out_t *trace)1212 DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace) 1213 1213 { 1214 1214 return trace->err.err_num != 0; 1215 1215 } 1216 1216 1217 void trace_perror_output(libtrace_out_t *trace,const char *msg,...)1217 DLLEXPORT void trace_perror_output(libtrace_out_t *trace,const char *msg,...) 1218 1218 { 1219 1219 char buf[256]; … … 1230 1230 } 1231 1231 1232 int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts)1232 DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts) 1233 1233 { 1234 1234 if (trace->format->seek_erf) { … … 1264 1264 } 1265 1265 1266 int trace_seek_seconds(libtrace_t *trace, double seconds)1266 DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds) 1267 1267 { 1268 1268 if (trace->format->seek_seconds) { … … 1289 1289 } 1290 1290 1291 int trace_seek_timeval(libtrace_t *trace, struct timeval tv)1291 DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv) 1292 1292 { 1293 1293 if (trace->format->seek_timeval) { … … 1311 1311 } 1312 1312 1313 char *trace_ether_ntoa(const uint8_t *addr, char *buf)1313 DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf) 1314 1314 { 1315 1315 char *buf2 = buf; … … 1323 1323 } 1324 1324 1325 uint8_t *trace_ether_aton(const char *buf, uint8_t *addr)1325 DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr) 1326 1326 { 1327 1327 uint8_t *buf2 = addr;
Note: See TracChangeset
for help on using the changeset viewer.