Changeset 39e141f for lib/libtrace.h


Ignore:
Timestamp:
04/21/06 10:28:36 (16 years ago)
Author:
Perry Lorier <perry@…>
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
Message:

Merge windows portability fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    r97e39a7 r39e141f  
    6767    typedef unsigned    __int32 uint32_t;
    6868    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
    6983#endif
    7084
     
    7791#    define false 0
    7892#    define true 1
     93#    if !defined(ssize_t)
     94     /* XXX: Not 64-bit safe! */
     95#    define ssize_t int
     96#    endif   
    7997#else
    8098#    include <netinet/in.h>
     
    374392 * and then prints out the help() function registered with each input module
    375393 */
    376 void trace_help();
     394DLLEXPORT void trace_help();
    377395
    378396/** Gets the output format for a given output trace
     
    382400 *
    383401 */
    384 SIMPLE_FUNCTION
     402DLLEXPORT SIMPLE_FUNCTION
    385403char *trace_get_output_format(const libtrace_out_t *libtrace);
    386404
     
    417435 *  configuration state, you must call trace_start to start the capture.
    418436 */
    419 libtrace_t *trace_create(const char *uri);
     437DLLEXPORT libtrace_t *trace_create(const char *uri);
    420438
    421439/** Creates a "dummy" trace file that has only the format type set.
     
    427445 * libtrace_packet_t's that are not associated with a libtrace_t structure.
    428446 */
    429 libtrace_t *trace_create_dead(const char *uri);
     447DLLEXPORT libtrace_t *trace_create_dead(const char *uri);
    430448
    431449/** Creates a trace output file from a URI.
     
    444462 *  and trace_errno is set. Use trace_perror() to get more information
    445463 */
    446 libtrace_out_t *trace_create_output(const char *uri);
     464DLLEXPORT libtrace_out_t *trace_create_output(const char *uri);
    447465
    448466/** Start the capture
     
    453471 * all the config options.  This may fail.
    454472 */
    455 int trace_start(libtrace_t *libtrace);
     473DLLEXPORT int trace_start(libtrace_t *libtrace);
    456474
    457475/** Pause the capture
     
    463481 * will be discarded.  To resume capture, call trace_start().
    464482 */
    465 int trace_pause(libtrace_t *libtrace);
     483DLLEXPORT int trace_pause(libtrace_t *libtrace);
    466484
    467485/** Start an output trace
     
    472490 * creates the file.
    473491 */
    474 int trace_start_output(libtrace_out_t *libtrace);
     492DLLEXPORT int trace_start_output(libtrace_out_t *libtrace);
    475493
    476494/** Valid trace capture options */
     
    488506 * This should be called after trace_create, and before trace_start
    489507 */
    490 int trace_config(libtrace_t *libtrace,
     508DLLEXPORT int trace_config(libtrace_t *libtrace,
    491509                trace_option_t option,
    492510                void *value);
     
    508526 * trace_start_output
    509527 */
    510 int trace_config_output(libtrace_out_t *libtrace,
     528DLLEXPORT int trace_config_output(libtrace_out_t *libtrace,
    511529                trace_option_output_t option,
    512530                void *value
     
    516534 *
    517535 */
    518 void trace_destroy(libtrace_t *trace);
     536DLLEXPORT void trace_destroy(libtrace_t *trace);
    519537
    520538/** Close a trace file, freeing up any resources it may have been using
    521539 * @param trace         trace file to be destroyed
    522540 */
    523 void trace_destroy_dead(libtrace_t *trace);
     541DLLEXPORT void trace_destroy_dead(libtrace_t *trace);
    524542
    525543/** Close a trace output file, freeing up any resources it may have been using
     
    528546 * @author Shane Alcock
    529547 */
    530 void trace_destroy_output(libtrace_out_t *trace);
     548DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
    531549
    532550/** Check (and clear) the current error state of an input trace
     
    536554 * to "no error".
    537555 */
    538 libtrace_err_t trace_get_err(libtrace_t *trace);
     556DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace);
    539557
    540558/** Return if there is an error
     
    542560 * This does not clear the error status, and only returns true or false.
    543561 */
    544 bool trace_is_err(libtrace_t *trace);
     562DLLEXPORT bool trace_is_err(libtrace_t *trace);
    545563
    546564/** Output an error message to stderr and clear the error status.
     
    549567 * This function does clear the error status.
    550568 */
    551 void trace_perror(libtrace_t *trace, const char *msg,...);
     569DLLEXPORT void trace_perror(libtrace_t *trace, const char *msg,...);
    552570
    553571/** Check (and clear) the current error state of an output trace
     
    557575 * to "no error".
    558576 */
    559 libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
     577DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace);
    560578
    561579/** Return if there is an error
     
    563581 * This does not clear the error status, and only returns true or false.
    564582 */
    565 bool trace_is_err_output(libtrace_out_t *trace);
     583DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace);
    566584
    567585/** Output an error message to stderr and clear the error status.
     
    570588 * This function does clear the error status.
    571589 */
    572 void trace_perror_output(libtrace_out_t *trace, const char *msg,...);
     590DLLEXPORT void trace_perror_output(libtrace_out_t *trace, const char *msg,...);
    573591
    574592
     
    585603 * @return a pointer to an initialised libtrace_packet_t object
    586604 */
    587 libtrace_packet_t *trace_create_packet();
     605DLLEXPORT libtrace_packet_t *trace_create_packet();
    588606
    589607/** Copy a packet
     
    597615 * memory.
    598616 */
    599 libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
     617DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet);
    600618
    601619/** Destroy a packet object
     
    603621 * sideeffect: sets packet to NULL
    604622 */
    605 void trace_destroy_packet(libtrace_packet_t **packet);
     623DLLEXPORT void trace_destroy_packet(libtrace_packet_t **packet);
    606624
    607625
     
    615633 * this function
    616634 */
    617 int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
     635DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
    618636
    619637/** Event types
     
    650668 *  TRACE_EVENT_TERMINATE Trace terminated (perhaps with an error condition)
    651669 */
    652 libtrace_eventobj_t trace_event(libtrace_t *trace,
     670DLLEXPORT libtrace_eventobj_t trace_event(libtrace_t *trace,
    653671                libtrace_packet_t *packet);
    654672
     
    660678 * @return the number of bytes written out, if zero or negative then an error has occured.
    661679 */
    662 int trace_write_packet(libtrace_out_t *trace, const libtrace_packet_t *packet);
     680DLLEXPORT int trace_write_packet(libtrace_out_t *trace, const libtrace_packet_t *packet);
    663681/*@}*/
    664682
     
    677695 * this is
    678696 */
    679 SIMPLE_FUNCTION
     697DLLEXPORT SIMPLE_FUNCTION
    680698void *trace_get_link(const libtrace_packet_t *packet);
    681699
     
    696714 * @note proto may be NULL if proto is unneeded.
    697715 */
    698 void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto,
     716DLLEXPORT void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto,
    699717                uint32_t *remaining);
    700718
     
    715733 * @note This is similar to trace_get_transport_from_ip in libtrace2
    716734 */
    717 void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
     735DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
    718736                uint32_t *remaining);
    719737
     
    731749 * @note This is similar to trace_get_transport_from_ip in libtrace2
    732750 */
    733 void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining);
     751DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining);
    734752
    735753/** Gets a pointer to the payload given a pointer to a udp header
     
    746764 * @note This is similar trace_get_transport_from_ip in libtrace2
    747765 */
    748 void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
     766DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
    749767
    750768/** Gets a pointer to the payload given a pointer to a icmp header
     
    761779 * @note This is similar to trace_get_payload_from_icmp in libtrace2
    762780 */
    763 void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *skipped);
     781DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *skipped);
    764782
    765783/** get a pointer to the TCP header (if any)
     
    768786 * @return a pointer to the TCP header, or NULL if there is not a TCP packet
    769787 */
    770 SIMPLE_FUNCTION
     788DLLEXPORT SIMPLE_FUNCTION
    771789libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
    772790
     
    784802 * @note The last parameter has changed from libtrace2
    785803 */
    786 SIMPLE_FUNCTION
     804DLLEXPORT SIMPLE_FUNCTION
    787805libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
    788806
     
    792810 * @return a pointer to the UDP header, or NULL if this is not a UDP packet
    793811 */
    794 SIMPLE_FUNCTION
     812DLLEXPORT SIMPLE_FUNCTION
    795813libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
    796814
     
    808826 * @note Beware the change from libtrace2 from skipped to remaining
    809827 */
    810 SIMPLE_FUNCTION
     828DLLEXPORT SIMPLE_FUNCTION
    811829libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
    812830
     
    816834 * @return a pointer to the ICMP header, or NULL if this is not a ICMP packet
    817835 */
    818 SIMPLE_FUNCTION
     836DLLEXPORT SIMPLE_FUNCTION
    819837libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
    820838
     
    832850 * @note Beware the change from libtrace2 from skipped to remaining
    833851 */
    834 SIMPLE_FUNCTION
     852DLLEXPORT SIMPLE_FUNCTION
    835853libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
    836854
     
    840858 * destination MAC)
    841859 */
    842 SIMPLE_FUNCTION
     860DLLEXPORT SIMPLE_FUNCTION
    843861uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
    844862
     
    856874 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address
    857875 */
    858 SIMPLE_FUNCTION
     876DLLEXPORT SIMPLE_FUNCTION
    859877struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
    860878                struct sockaddr *addr);
     
    866884 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address
    867885 */
    868 SIMPLE_FUNCTION
     886DLLEXPORT SIMPLE_FUNCTION
    869887struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
    870888                struct sockaddr *addr);
     
    889907 * @note Beware of fragmented packets.
    890908 */
    891 int trace_get_next_option(unsigned char **ptr,int *len,
     909DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
    892910                        unsigned char *type,
    893911                        unsigned char *optlen,
     
    907925 * @author Daniel Lawson
    908926 */
    909 SIMPLE_FUNCTION
     927DLLEXPORT SIMPLE_FUNCTION
    910928uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet);
    911929
     
    917935 * @author Perry Lorier
    918936 */
    919 SIMPLE_FUNCTION
     937DLLEXPORT SIMPLE_FUNCTION
    920938struct timeval trace_get_timeval(const libtrace_packet_t *packet);
    921939
     
    927945 * @author Perry Lorier
    928946 */
    929 SIMPLE_FUNCTION
     947DLLEXPORT SIMPLE_FUNCTION
    930948double trace_get_seconds(const libtrace_packet_t *packet);
    931949
     
    939957 * @note This function may be extremely slow.
    940958 */
    941 int trace_seek_seconds(libtrace_t *trace, double seconds);
     959DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds);
    942960
    943961/** Seek within a trace
     
    950968 * @note This function may be extremely slow.
    951969 */
    952 int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
     970DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv);
    953971
    954972/** Seek within a trace
     
    961979 * @note This function may be extremely slow.
    962980 */
    963 int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
     981DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts);
    964982
    965983/*@}*/
     
    9841002 * + sizeof(tcp_header).
    9851003 */
    986 SIMPLE_FUNCTION
     1004DLLEXPORT SIMPLE_FUNCTION
    9871005size_t trace_get_capture_length(const libtrace_packet_t *packet);
    9881006
     
    9941012 * @note trace_getwire_length \em{includes} FCS.
    9951013 */
    996 SIMPLE_FUNCTION
     1014DLLEXPORT SIMPLE_FUNCTION
    9971015size_t trace_get_wire_length(const libtrace_packet_t *packet);
    9981016
     
    10051023 * captured packet in memory, and the captured length of the packet
    10061024 */
    1007 SIMPLE_FUNCTION
     1025DLLEXPORT SIMPLE_FUNCTION
    10081026size_t trace_get_framing_length(const libtrace_packet_t *packet);
    10091027
     
    10141032 * length of the packet if unchanged
    10151033 */
    1016 size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
     1034DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size);
    10171035
    10181036/*@}*/
     
    10441062 * @author Daniel Lawson
    10451063 */
    1046 SIMPLE_FUNCTION
     1064DLLEXPORT SIMPLE_FUNCTION
    10471065libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
    10481066
     
    10531071 * @author Daniel Lawson
    10541072 */
    1055 int8_t trace_set_direction(libtrace_packet_t *packet, int8_t direction);
     1073DLLEXPORT int8_t trace_set_direction(libtrace_packet_t *packet, int8_t direction);
    10561074
    10571075/** Get the direction flag, if it has one
     
    10641082 * @author Daniel Lawson
    10651083 */
    1066 SIMPLE_FUNCTION
     1084DLLEXPORT SIMPLE_FUNCTION
    10671085int8_t trace_get_direction(const libtrace_packet_t *packet);
    10681086
     
    10801098 * filter is actually used
    10811099 */
    1082 SIMPLE_FUNCTION
     1100DLLEXPORT SIMPLE_FUNCTION
    10831101libtrace_filter_t *trace_bpf_setfilter(const char *filterstring);
    10841102
     
    10931111 * in the future.
    10941112 */
    1095 int trace_bpf_filter(libtrace_filter_t *filter,
     1113DLLEXPORT int trace_bpf_filter(libtrace_filter_t *filter,
    10961114                const libtrace_packet_t *packet);
    10971115/*@}*/
     
    11161134 * however it is bit compatible so that a cast will work.
    11171135 */
    1118 char *trace_ether_ntoa(const uint8_t *addr, char *buf);
     1136DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf);
    11191137
    11201138/** Convert a string to an ethernet address
     
    11311149 * however it is bit compatible so that a cast will work.
    11321150 */
    1133 uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
     1151DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr);
    11341152
    11351153/*@}*/
     
    11481166 * @author Perry Lorier
    11491167 */
    1150 SIMPLE_FUNCTION
     1168DLLEXPORT SIMPLE_FUNCTION
    11511169uint16_t trace_get_source_port(const libtrace_packet_t *packet);
    11521170
     
    11571175 * @author Perry Lorier
    11581176 */
    1159 SIMPLE_FUNCTION
     1177DLLEXPORT SIMPLE_FUNCTION
    11601178uint16_t trace_get_destination_port(const libtrace_packet_t *packet);
    11611179
     
    11681186 * @author Daniel Lawson
    11691187 */
    1170 SIMPLE_FUNCTION
     1188DLLEXPORT SIMPLE_FUNCTION
    11711189int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
    11721190
     
    11781196 * @author Shane Alcock
    11791197 */
    1180 const char *trace_parse_uri(const char *uri, char **format);
     1198DLLEXPORT const char *trace_parse_uri(const char *uri, char **format);
    11811199
    11821200/** RT protocol base format identifiers
Note: See TracChangeset for help on using the changeset viewer.