Changeset 39e141f for lib/libtrace.h
- 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/libtrace.h
r97e39a7 r39e141f 67 67 typedef unsigned __int32 uint32_t; 68 68 typedef unsigned __int64 uint64_t; 69 #ifdef BUILDING_DLL 70 #define DLLEXPORT __declspec(dllexport) 71 #else 72 #define DLLEXPORT __declspec(dllimport) 73 #endif 74 #define DLLLOCAL 75 #else 76 #ifdef HAVE_GCCVISIBILITYPATCH 77 #define DLLEXPORT __attribute__ (visibility("default")) 78 #define DLLLOCAL __attribute__ (visibility("hidden")) 79 #else 80 #define DLLEXPORT 81 #define DLLLOCAL 82 #endif 69 83 #endif 70 84 … … 77 91 # define false 0 78 92 # define true 1 93 # if !defined(ssize_t) 94 /* XXX: Not 64-bit safe! */ 95 # define ssize_t int 96 # endif 79 97 #else 80 98 # include <netinet/in.h> … … 374 392 * and then prints out the help() function registered with each input module 375 393 */ 376 void trace_help();394 DLLEXPORT void trace_help(); 377 395 378 396 /** Gets the output format for a given output trace … … 382 400 * 383 401 */ 384 SIMPLE_FUNCTION402 DLLEXPORT SIMPLE_FUNCTION 385 403 char *trace_get_output_format(const libtrace_out_t *libtrace); 386 404 … … 417 435 * configuration state, you must call trace_start to start the capture. 418 436 */ 419 libtrace_t *trace_create(const char *uri);437 DLLEXPORT libtrace_t *trace_create(const char *uri); 420 438 421 439 /** Creates a "dummy" trace file that has only the format type set. … … 427 445 * libtrace_packet_t's that are not associated with a libtrace_t structure. 428 446 */ 429 libtrace_t *trace_create_dead(const char *uri);447 DLLEXPORT libtrace_t *trace_create_dead(const char *uri); 430 448 431 449 /** Creates a trace output file from a URI. … … 444 462 * and trace_errno is set. Use trace_perror() to get more information 445 463 */ 446 libtrace_out_t *trace_create_output(const char *uri);464 DLLEXPORT libtrace_out_t *trace_create_output(const char *uri); 447 465 448 466 /** Start the capture … … 453 471 * all the config options. This may fail. 454 472 */ 455 int trace_start(libtrace_t *libtrace);473 DLLEXPORT int trace_start(libtrace_t *libtrace); 456 474 457 475 /** Pause the capture … … 463 481 * will be discarded. To resume capture, call trace_start(). 464 482 */ 465 int trace_pause(libtrace_t *libtrace);483 DLLEXPORT int trace_pause(libtrace_t *libtrace); 466 484 467 485 /** Start an output trace … … 472 490 * creates the file. 473 491 */ 474 int trace_start_output(libtrace_out_t *libtrace);492 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace); 475 493 476 494 /** Valid trace capture options */ … … 488 506 * This should be called after trace_create, and before trace_start 489 507 */ 490 int trace_config(libtrace_t *libtrace,508 DLLEXPORT int trace_config(libtrace_t *libtrace, 491 509 trace_option_t option, 492 510 void *value); … … 508 526 * trace_start_output 509 527 */ 510 int trace_config_output(libtrace_out_t *libtrace,528 DLLEXPORT int trace_config_output(libtrace_out_t *libtrace, 511 529 trace_option_output_t option, 512 530 void *value … … 516 534 * 517 535 */ 518 void trace_destroy(libtrace_t *trace);536 DLLEXPORT void trace_destroy(libtrace_t *trace); 519 537 520 538 /** Close a trace file, freeing up any resources it may have been using 521 539 * @param trace trace file to be destroyed 522 540 */ 523 void trace_destroy_dead(libtrace_t *trace);541 DLLEXPORT void trace_destroy_dead(libtrace_t *trace); 524 542 525 543 /** Close a trace output file, freeing up any resources it may have been using … … 528 546 * @author Shane Alcock 529 547 */ 530 void trace_destroy_output(libtrace_out_t *trace);548 DLLEXPORT void trace_destroy_output(libtrace_out_t *trace); 531 549 532 550 /** Check (and clear) the current error state of an input trace … … 536 554 * to "no error". 537 555 */ 538 libtrace_err_t trace_get_err(libtrace_t *trace);556 DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace); 539 557 540 558 /** Return if there is an error … … 542 560 * This does not clear the error status, and only returns true or false. 543 561 */ 544 bool trace_is_err(libtrace_t *trace);562 DLLEXPORT bool trace_is_err(libtrace_t *trace); 545 563 546 564 /** Output an error message to stderr and clear the error status. … … 549 567 * This function does clear the error status. 550 568 */ 551 void trace_perror(libtrace_t *trace, const char *msg,...);569 DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...); 552 570 553 571 /** Check (and clear) the current error state of an output trace … … 557 575 * to "no error". 558 576 */ 559 libtrace_err_t trace_get_err_output(libtrace_out_t *trace);577 DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace); 560 578 561 579 /** Return if there is an error … … 563 581 * This does not clear the error status, and only returns true or false. 564 582 */ 565 bool trace_is_err_output(libtrace_out_t *trace);583 DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace); 566 584 567 585 /** Output an error message to stderr and clear the error status. … … 570 588 * This function does clear the error status. 571 589 */ 572 void trace_perror_output(libtrace_out_t *trace, const char *msg,...);590 DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...); 573 591 574 592 … … 585 603 * @return a pointer to an initialised libtrace_packet_t object 586 604 */ 587 libtrace_packet_t *trace_create_packet();605 DLLEXPORT libtrace_packet_t *trace_create_packet(); 588 606 589 607 /** Copy a packet … … 597 615 * memory. 598 616 */ 599 libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);617 DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet); 600 618 601 619 /** Destroy a packet object … … 603 621 * sideeffect: sets packet to NULL 604 622 */ 605 void trace_destroy_packet(libtrace_packet_t **packet);623 DLLEXPORT void trace_destroy_packet(libtrace_packet_t **packet); 606 624 607 625 … … 615 633 * this function 616 634 */ 617 int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);635 DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet); 618 636 619 637 /** Event types … … 650 668 * TRACE_EVENT_TERMINATE Trace terminated (perhaps with an error condition) 651 669 */ 652 libtrace_eventobj_t trace_event(libtrace_t *trace,670 DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace, 653 671 libtrace_packet_t *packet); 654 672 … … 660 678 * @return the number of bytes written out, if zero or negative then an error has occured. 661 679 */ 662 int trace_write_packet(libtrace_out_t *trace, const libtrace_packet_t *packet);680 DLLEXPORT int trace_write_packet(libtrace_out_t *trace, const libtrace_packet_t *packet); 663 681 /*@}*/ 664 682 … … 677 695 * this is 678 696 */ 679 SIMPLE_FUNCTION697 DLLEXPORT SIMPLE_FUNCTION 680 698 void *trace_get_link(const libtrace_packet_t *packet); 681 699 … … 696 714 * @note proto may be NULL if proto is unneeded. 697 715 */ 698 void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto,716 DLLEXPORT void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto, 699 717 uint32_t *remaining); 700 718 … … 715 733 * @note This is similar to trace_get_transport_from_ip in libtrace2 716 734 */ 717 void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,735 DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto, 718 736 uint32_t *remaining); 719 737 … … 731 749 * @note This is similar to trace_get_transport_from_ip in libtrace2 732 750 */ 733 void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining);751 DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining); 734 752 735 753 /** Gets a pointer to the payload given a pointer to a udp header … … 746 764 * @note This is similar trace_get_transport_from_ip in libtrace2 747 765 */ 748 void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);766 DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining); 749 767 750 768 /** Gets a pointer to the payload given a pointer to a icmp header … … 761 779 * @note This is similar to trace_get_payload_from_icmp in libtrace2 762 780 */ 763 void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *skipped);781 DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *skipped); 764 782 765 783 /** get a pointer to the TCP header (if any) … … 768 786 * @return a pointer to the TCP header, or NULL if there is not a TCP packet 769 787 */ 770 SIMPLE_FUNCTION788 DLLEXPORT SIMPLE_FUNCTION 771 789 libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet); 772 790 … … 784 802 * @note The last parameter has changed from libtrace2 785 803 */ 786 SIMPLE_FUNCTION804 DLLEXPORT SIMPLE_FUNCTION 787 805 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining); 788 806 … … 792 810 * @return a pointer to the UDP header, or NULL if this is not a UDP packet 793 811 */ 794 SIMPLE_FUNCTION812 DLLEXPORT SIMPLE_FUNCTION 795 813 libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet); 796 814 … … 808 826 * @note Beware the change from libtrace2 from skipped to remaining 809 827 */ 810 SIMPLE_FUNCTION828 DLLEXPORT SIMPLE_FUNCTION 811 829 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining); 812 830 … … 816 834 * @return a pointer to the ICMP header, or NULL if this is not a ICMP packet 817 835 */ 818 SIMPLE_FUNCTION836 DLLEXPORT SIMPLE_FUNCTION 819 837 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet); 820 838 … … 832 850 * @note Beware the change from libtrace2 from skipped to remaining 833 851 */ 834 SIMPLE_FUNCTION852 DLLEXPORT SIMPLE_FUNCTION 835 853 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining); 836 854 … … 840 858 * destination MAC) 841 859 */ 842 SIMPLE_FUNCTION860 DLLEXPORT SIMPLE_FUNCTION 843 861 uint8_t *trace_get_destination_mac(libtrace_packet_t *packet); 844 862 … … 856 874 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address 857 875 */ 858 SIMPLE_FUNCTION876 DLLEXPORT SIMPLE_FUNCTION 859 877 struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet, 860 878 struct sockaddr *addr); … … 866 884 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address 867 885 */ 868 SIMPLE_FUNCTION886 DLLEXPORT SIMPLE_FUNCTION 869 887 struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet, 870 888 struct sockaddr *addr); … … 889 907 * @note Beware of fragmented packets. 890 908 */ 891 int trace_get_next_option(unsigned char **ptr,int *len,909 DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len, 892 910 unsigned char *type, 893 911 unsigned char *optlen, … … 907 925 * @author Daniel Lawson 908 926 */ 909 SIMPLE_FUNCTION927 DLLEXPORT SIMPLE_FUNCTION 910 928 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet); 911 929 … … 917 935 * @author Perry Lorier 918 936 */ 919 SIMPLE_FUNCTION937 DLLEXPORT SIMPLE_FUNCTION 920 938 struct timeval trace_get_timeval(const libtrace_packet_t *packet); 921 939 … … 927 945 * @author Perry Lorier 928 946 */ 929 SIMPLE_FUNCTION947 DLLEXPORT SIMPLE_FUNCTION 930 948 double trace_get_seconds(const libtrace_packet_t *packet); 931 949 … … 939 957 * @note This function may be extremely slow. 940 958 */ 941 int trace_seek_seconds(libtrace_t *trace, double seconds);959 DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds); 942 960 943 961 /** Seek within a trace … … 950 968 * @note This function may be extremely slow. 951 969 */ 952 int trace_seek_timeval(libtrace_t *trace, struct timeval tv);970 DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv); 953 971 954 972 /** Seek within a trace … … 961 979 * @note This function may be extremely slow. 962 980 */ 963 int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);981 DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts); 964 982 965 983 /*@}*/ … … 984 1002 * + sizeof(tcp_header). 985 1003 */ 986 SIMPLE_FUNCTION1004 DLLEXPORT SIMPLE_FUNCTION 987 1005 size_t trace_get_capture_length(const libtrace_packet_t *packet); 988 1006 … … 994 1012 * @note trace_getwire_length \em{includes} FCS. 995 1013 */ 996 SIMPLE_FUNCTION1014 DLLEXPORT SIMPLE_FUNCTION 997 1015 size_t trace_get_wire_length(const libtrace_packet_t *packet); 998 1016 … … 1005 1023 * captured packet in memory, and the captured length of the packet 1006 1024 */ 1007 SIMPLE_FUNCTION1025 DLLEXPORT SIMPLE_FUNCTION 1008 1026 size_t trace_get_framing_length(const libtrace_packet_t *packet); 1009 1027 … … 1014 1032 * length of the packet if unchanged 1015 1033 */ 1016 size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);1034 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size); 1017 1035 1018 1036 /*@}*/ … … 1044 1062 * @author Daniel Lawson 1045 1063 */ 1046 SIMPLE_FUNCTION1064 DLLEXPORT SIMPLE_FUNCTION 1047 1065 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet); 1048 1066 … … 1053 1071 * @author Daniel Lawson 1054 1072 */ 1055 int8_t trace_set_direction(libtrace_packet_t *packet, int8_t direction);1073 DLLEXPORT int8_t trace_set_direction(libtrace_packet_t *packet, int8_t direction); 1056 1074 1057 1075 /** Get the direction flag, if it has one … … 1064 1082 * @author Daniel Lawson 1065 1083 */ 1066 SIMPLE_FUNCTION1084 DLLEXPORT SIMPLE_FUNCTION 1067 1085 int8_t trace_get_direction(const libtrace_packet_t *packet); 1068 1086 … … 1080 1098 * filter is actually used 1081 1099 */ 1082 SIMPLE_FUNCTION1100 DLLEXPORT SIMPLE_FUNCTION 1083 1101 libtrace_filter_t *trace_bpf_setfilter(const char *filterstring); 1084 1102 … … 1093 1111 * in the future. 1094 1112 */ 1095 int trace_bpf_filter(libtrace_filter_t *filter,1113 DLLEXPORT int trace_bpf_filter(libtrace_filter_t *filter, 1096 1114 const libtrace_packet_t *packet); 1097 1115 /*@}*/ … … 1116 1134 * however it is bit compatible so that a cast will work. 1117 1135 */ 1118 char *trace_ether_ntoa(const uint8_t *addr, char *buf);1136 DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf); 1119 1137 1120 1138 /** Convert a string to an ethernet address … … 1131 1149 * however it is bit compatible so that a cast will work. 1132 1150 */ 1133 uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);1151 DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr); 1134 1152 1135 1153 /*@}*/ … … 1148 1166 * @author Perry Lorier 1149 1167 */ 1150 SIMPLE_FUNCTION1168 DLLEXPORT SIMPLE_FUNCTION 1151 1169 uint16_t trace_get_source_port(const libtrace_packet_t *packet); 1152 1170 … … 1157 1175 * @author Perry Lorier 1158 1176 */ 1159 SIMPLE_FUNCTION1177 DLLEXPORT SIMPLE_FUNCTION 1160 1178 uint16_t trace_get_destination_port(const libtrace_packet_t *packet); 1161 1179 … … 1168 1186 * @author Daniel Lawson 1169 1187 */ 1170 SIMPLE_FUNCTION1188 DLLEXPORT SIMPLE_FUNCTION 1171 1189 int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest); 1172 1190 … … 1178 1196 * @author Shane Alcock 1179 1197 */ 1180 const char *trace_parse_uri(const char *uri, char **format);1198 DLLEXPORT const char *trace_parse_uri(const char *uri, char **format); 1181 1199 1182 1200 /** RT protocol base format identifiers
Note: See TracChangeset
for help on using the changeset viewer.