Changeset 39e141f


Ignore:
Timestamp:
04/21/06 10:28:36 (15 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

Files:
6 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
  • lib/libtrace_int.h

    r97e39a7 r39e141f  
    8282#endif
    8383
     84#ifndef HAVE_STRNCASECMP
     85# ifndef HAVE__STRNICMP
     86int strncasecmp(const char *str1, const char *str2, size_t n);
     87# else
     88# define strncasecmp _strnicmp
     89# endif
     90#endif
     91
     92#ifndef HAVE_SNPRINTF
     93# ifndef HAVE_SPRINTF_S
     94int snprintf(char *str, size_t size, const char *format, ...);
     95# else
     96# define snprintf sprintf_s
     97# endif
     98#endif
    8499
    85100#include "wag.h"
  • lib/libtraceio-stdio.c

    redb18ce r39e141f  
     1#include "libtrace.h"
     2#include "libtrace_int.h"
    13#include "libtraceio.h"
    24#include <sys/types.h> /* for ssize_t/off_t */
  • lib/protocols.c

    r97e39a7 r39e141f  
    242242#define SW_IP_OFFMASK 0xff1f
    243243
    244 void *trace_get_payload_from_ip(libtrace_ip_t *ipptr, uint8_t *prot,
     244DLLEXPORT void *trace_get_payload_from_ip(libtrace_ip_t *ipptr, uint8_t *prot,
    245245                uint32_t *remaining)
    246246{
     
    307307}
    308308
    309 void *trace_get_transport(libtrace_packet_t *packet,
     309DLLEXPORT void *trace_get_transport(libtrace_packet_t *packet,
    310310                uint8_t *proto,
    311311                uint32_t *remaining
     
    363363}
    364364
    365 libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet) {
     365DLLEXPORT libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet) {
    366366        uint8_t proto;
    367367        libtrace_tcp_t *tcp;
     
    375375}
    376376
    377 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
     377DLLEXPORT libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
    378378{
    379379        struct libtrace_tcp *tcpptr = 0;
     
    387387}
    388388
    389 libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet) {
     389DLLEXPORT libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet) {
    390390        uint8_t proto;
    391391        libtrace_udp_t *udp;
     
    399399}
    400400
    401 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
     401DLLEXPORT libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
    402402{
    403403        struct libtrace_udp *udpptr = 0;
     
    411411}
    412412
    413 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet) {
     413DLLEXPORT libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet) {
    414414        uint8_t proto;
    415415        libtrace_icmp_t *icmp;
     
    423423}
    424424
    425 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
     425DLLEXPORT libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
    426426{
    427427        libtrace_icmp_t *icmpptr = 0;
     
    435435}
    436436
    437 void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining)
     437DLLEXPORT void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining)
    438438{
    439439        if (remaining) {
     
    445445}
    446446
    447 void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining)
     447DLLEXPORT void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining)
    448448{
    449449        unsigned int dlen = tcp->doff*4;
     
    456456}
    457457
    458 void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *remaining)
     458DLLEXPORT void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *remaining)
    459459{
    460460        if (remaining) {
     
    473473/* Return the client port
    474474 */
    475 uint16_t trace_get_source_port(const libtrace_packet_t *packet)
     475DLLEXPORT uint16_t trace_get_source_port(const libtrace_packet_t *packet)
    476476{
    477477        struct ports_t *port =
     
    486486
    487487/* Same as get_source_port except use the destination port */
    488 uint16_t trace_get_destination_port(const libtrace_packet_t *packet)
     488DLLEXPORT uint16_t trace_get_destination_port(const libtrace_packet_t *packet)
    489489{
    490490        struct ports_t *port =
     
    530530}
    531531
    532 uint8_t *trace_get_destination_mac(libtrace_packet_t *packet) {
     532DLLEXPORT uint8_t *trace_get_destination_mac(libtrace_packet_t *packet) {
    533533        void *link = trace_get_link(packet);
    534534        libtrace_80211_t *wifi;
     
    562562}
    563563
    564 struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
     564DLLEXPORT struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
    565565                struct sockaddr *addr)
    566566{
     
    616616}
    617617
    618 struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
     618DLLEXPORT struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
    619619                struct sockaddr *addr)
    620620{
     
    688688 * @author Perry Lorier
    689689 */
    690 int trace_get_next_option(unsigned char **ptr,int *len,
     690DLLEXPORT int trace_get_next_option(unsigned char **ptr,int *len,
    691691                        unsigned char *type,
    692692                        unsigned char *optlen,
  • lib/trace.c

    r9e46ee7 r39e141f  
    203203 * and then prints out the help() function registered with each input module
    204204 */
    205 void trace_help() {
     205DLLEXPORT void trace_help() {
    206206        struct libtrace_format_t *tmp;
    207207        printf("libtrace %s\n",PACKAGE_VERSION);
     
    221221 *
    222222 */
    223 SIMPLE_FUNCTION
     223DLLEXPORT SIMPLE_FUNCTION
    224224char *trace_get_output_format(const struct libtrace_out_t *libtrace) {
    225225        char * format = libtrace->format->name;
     
    252252 * and an error is output to stdout.
    253253 */
    254 struct libtrace_t *trace_create(const char *uri) {
     254DLLEXPORT struct libtrace_t *trace_create(const char *uri) {
    255255        struct libtrace_t *libtrace =
    256256                        (struct libtrace_t *)malloc(sizeof(struct libtrace_t));
     
    328328 * libtrace_packet_t's that are not associated with a libtrace_t structure.
    329329 */
    330 struct libtrace_t * trace_create_dead (const char *uri) {
     330DLLEXPORT struct libtrace_t * trace_create_dead (const char *uri) {
    331331        struct libtrace_t *libtrace = (struct libtrace_t *)
    332332                                        malloc(sizeof(struct libtrace_t));
     
    375375 */
    376376       
    377 libtrace_out_t *trace_create_output(const char *uri) {
     377DLLEXPORT libtrace_out_t *trace_create_output(const char *uri) {
    378378        libtrace_out_t *libtrace =
    379379                        (libtrace_out_t*)malloc(sizeof(struct libtrace_out_t));
     
    446446 * the trace.  it may fail.
    447447 */
    448 int trace_start(struct libtrace_t *libtrace)
     448DLLEXPORT int trace_start(struct libtrace_t *libtrace)
    449449{
    450450        assert(libtrace);
     
    460460}
    461461
    462 int trace_start_output(libtrace_out_t *libtrace)
     462DLLEXPORT int trace_start_output(libtrace_out_t *libtrace)
    463463{
    464464        assert(libtrace);
     
    474474}
    475475
    476 int trace_pause(libtrace_t *libtrace)
     476DLLEXPORT int trace_pause(libtrace_t *libtrace)
    477477{
    478478        assert(libtrace);
     
    484484}
    485485
    486 int trace_config(libtrace_t *libtrace,
     486DLLEXPORT int trace_config(libtrace_t *libtrace,
    487487                trace_option_t option,
    488488                void *value)
     
    519519 * @author Shane Alcock
    520520 */
    521 int trace_config_output(struct libtrace_out_t *libtrace,
     521DLLEXPORT int trace_config_output(struct libtrace_out_t *libtrace,
    522522                trace_option_output_t option,
    523523                void *value) {
     
    531531 *
    532532 */
    533 void trace_destroy(struct libtrace_t *libtrace) {
     533DLLEXPORT void trace_destroy(struct libtrace_t *libtrace) {
    534534        assert(libtrace);
    535535        if (libtrace->started && libtrace->format->pause_input)
     
    543543
    544544
    545 void trace_destroy_dead(struct libtrace_t *libtrace) {
     545DLLEXPORT void trace_destroy_dead(struct libtrace_t *libtrace) {
    546546        assert(libtrace);
    547547        free(libtrace);
     
    553553 * @author Shane Alcock
    554554 * */
    555 void trace_destroy_output(struct libtrace_out_t *libtrace) {
     555DLLEXPORT void trace_destroy_output(struct libtrace_out_t *libtrace) {
    556556        assert(libtrace);
    557557        libtrace->format->fin_output(libtrace);
     
    560560}
    561561
    562 libtrace_packet_t *trace_create_packet() {
     562DLLEXPORT libtrace_packet_t *trace_create_packet() {
    563563        libtrace_packet_t *packet =
    564564                (libtrace_packet_t*)calloc(1,sizeof(libtrace_packet_t));
     
    567567}
    568568
    569 libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet) {
     569DLLEXPORT libtrace_packet_t *trace_copy_packet(const libtrace_packet_t *packet) {
    570570        libtrace_packet_t *dest =
    571571                (libtrace_packet_t *)malloc(sizeof(libtrace_packet_t));
     
    590590 * sideeffect: sets packet to NULL
    591591 */
    592 void trace_destroy_packet(struct libtrace_packet_t **packet) {
     592DLLEXPORT void trace_destroy_packet(struct libtrace_packet_t **packet) {
    593593        if ((*packet)->buf_control == TRACE_CTRL_PACKET) {
    594594                free((*packet)->buffer);
     
    605605 *
    606606 */
    607 int trace_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) {
     607DLLEXPORT int trace_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) {
    608608
    609609        assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n");
     
    652652 * @author Shane Alcock
    653653 * */
    654 int trace_write_packet(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet) {
     654DLLEXPORT int trace_write_packet(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet) {
    655655        assert(libtrace);
    656656        assert(packet);
     
    666666}
    667667
    668 void *trace_get_link(const struct libtrace_packet_t *packet) {
     668DLLEXPORT void *trace_get_link(const struct libtrace_packet_t *packet) {
    669669        return (void *)packet->payload;
    670670}
     
    686686 * @author Daniel Lawson
    687687 */
    688 uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {
     688DLLEXPORT uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {
    689689        uint64_t timestamp = 0;
    690690        double seconds = 0.0;
     
    717717 * @author Perry Lorier
    718718 */
    719 struct timeval trace_get_timeval(const libtrace_packet_t *packet) {
     719DLLEXPORT struct timeval trace_get_timeval(const libtrace_packet_t *packet) {
    720720        struct timeval tv;
    721721        uint64_t ts = 0;
     
    755755 * @author Perry Lorier
    756756 */
    757 double trace_get_seconds(const struct libtrace_packet_t *packet) {
     757DLLEXPORT double trace_get_seconds(const struct libtrace_packet_t *packet) {
    758758        double seconds = 0.0;
    759759        uint64_t ts = 0;
     
    778778}
    779779
    780 size_t trace_get_capture_length(const libtrace_packet_t *packet) {
     780DLLEXPORT size_t trace_get_capture_length(const libtrace_packet_t *packet) {
    781781
    782782        assert(packet->size<65536);
     
    797797 * not be the same as the Capture Len.
    798798 */
    799 size_t trace_get_wire_length(const libtrace_packet_t *packet){
     799DLLEXPORT size_t trace_get_wire_length(const libtrace_packet_t *packet){
    800800        assert(packet->size>0 && packet->size<65536);
    801801
     
    815815 * captured packet in memory, and the captured length of the packet
    816816 */
    817 SIMPLE_FUNCTION
     817DLLEXPORT SIMPLE_FUNCTION
    818818size_t trace_get_framing_length(const libtrace_packet_t *packet) {
    819819        if (packet->trace->format->get_framing_length) {
     
    830830 * @author Daniel Lawson
    831831 */
    832 libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet ) {
     832DLLEXPORT libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet ) {
    833833        if (packet->trace->format->get_link_type) {
    834834                return packet->trace->format->get_link_type(packet);
     
    849849 * @author Perry Lorier
    850850 */
    851 struct libtrace_eventobj_t trace_event(struct libtrace_t *trace,
     851DLLEXPORT struct libtrace_eventobj_t trace_event(struct libtrace_t *trace,
    852852                struct libtrace_packet_t *packet) {
    853853        struct libtrace_eventobj_t event = {TRACE_EVENT_IOWAIT,0,0.0,0};
     
    876876 * @author Daniel Lawson
    877877 */
    878 struct libtrace_filter_t *trace_bpf_setfilter(const char *filterstring) {
     878DLLEXPORT struct libtrace_filter_t *trace_bpf_setfilter(const char *filterstring) {
    879879#if HAVE_BPF
    880880        struct libtrace_filter_t *filter = (struct libtrace_filter_t*)
     
    944944}
    945945
    946 int trace_bpf_filter(struct libtrace_filter_t *filter,
     946DLLEXPORT int trace_bpf_filter(struct libtrace_filter_t *filter,
    947947                        const struct libtrace_packet_t *packet) {
    948948#if HAVE_BPF
     
    978978 * @author Daniel Lawson
    979979 */
    980 int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction) {
     980DLLEXPORT int8_t trace_set_direction(struct libtrace_packet_t *packet, int8_t direction) {
    981981        assert(packet);
    982982        assert(packet->size>0 && packet->size<65536);
     
    996996 * @author Daniel Lawson
    997997 */
    998 int8_t trace_get_direction(const struct libtrace_packet_t *packet) {
     998DLLEXPORT int8_t trace_get_direction(const struct libtrace_packet_t *packet) {
    999999        assert(packet);
    10001000        assert(packet->size>0 && packet->size<65536);
     
    10201020 * @author Daniel Lawson
    10211021 */
    1022 int8_t trace_get_server_port(uint8_t protocol UNUSED, uint16_t source, uint16_t dest) {
     1022DLLEXPORT int8_t trace_get_server_port(uint8_t protocol UNUSED, uint16_t source, uint16_t dest) {
    10231023        /*
    10241024         * * If the ports are equal, return DEST
     
    11301130 * @author Daniel Lawson
    11311131 */
    1132 size_t trace_set_capture_length(struct libtrace_packet_t *packet, size_t size) {
     1132DLLEXPORT size_t trace_set_capture_length(struct libtrace_packet_t *packet, size_t size) {
    11331133        assert(packet);
    11341134        assert(packet->size>0 && packet->size<65536);
     
    11451145}
    11461146
    1147 const char * trace_parse_uri(const char *uri, char **format) {
     1147DLLEXPORT const char * trace_parse_uri(const char *uri, char **format) {
    11481148        const char *uridata = 0;
    11491149       
     
    11731173}
    11741174       
    1175 libtrace_err_t trace_get_err(libtrace_t *trace)
     1175DLLEXPORT libtrace_err_t trace_get_err(libtrace_t *trace)
    11761176{
    11771177        libtrace_err_t err = trace->err;
     
    11811181}
    11821182
    1183 bool trace_is_err(libtrace_t *trace)
     1183DLLEXPORT bool trace_is_err(libtrace_t *trace)
    11841184{
    11851185        return trace->err.err_num != 0;
    11861186}
    11871187
    1188 void trace_perror(libtrace_t *trace,const char *msg,...)
     1188DLLEXPORT void trace_perror(libtrace_t *trace,const char *msg,...)
    11891189{
    11901190        char buf[256];
     
    12021202}
    12031203
    1204 libtrace_err_t trace_get_err_output(libtrace_out_t *trace)
     1204DLLEXPORT libtrace_err_t trace_get_err_output(libtrace_out_t *trace)
    12051205{
    12061206        libtrace_err_t err = trace->err;
     
    12101210}
    12111211
    1212 bool trace_is_err_output(libtrace_out_t *trace)
     1212DLLEXPORT bool trace_is_err_output(libtrace_out_t *trace)
    12131213{
    12141214        return trace->err.err_num != 0;
    12151215}
    12161216
    1217 void trace_perror_output(libtrace_out_t *trace,const char *msg,...)
     1217DLLEXPORT void trace_perror_output(libtrace_out_t *trace,const char *msg,...)
    12181218{
    12191219        char buf[256];
     
    12301230}
    12311231
    1232 int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts)
     1232DLLEXPORT int trace_seek_erf_timestamp(libtrace_t *trace, uint64_t ts)
    12331233{
    12341234        if (trace->format->seek_erf) {
     
    12641264}
    12651265
    1266 int trace_seek_seconds(libtrace_t *trace, double seconds)
     1266DLLEXPORT int trace_seek_seconds(libtrace_t *trace, double seconds)
    12671267{
    12681268        if (trace->format->seek_seconds) {
     
    12891289}
    12901290
    1291 int trace_seek_timeval(libtrace_t *trace, struct timeval tv)
     1291DLLEXPORT int trace_seek_timeval(libtrace_t *trace, struct timeval tv)
    12921292{
    12931293        if (trace->format->seek_timeval) {
     
    13111311}
    13121312
    1313 char *trace_ether_ntoa(const uint8_t *addr, char *buf)
     1313DLLEXPORT char *trace_ether_ntoa(const uint8_t *addr, char *buf)
    13141314{
    13151315        char *buf2 = buf;
     
    13231323}
    13241324
    1325 uint8_t *trace_ether_aton(const char *buf, uint8_t *addr)
     1325DLLEXPORT uint8_t *trace_ether_aton(const char *buf, uint8_t *addr)
    13261326{
    13271327        uint8_t *buf2 = addr;
  • tools/tracemerge/tracemerge.c

    r6b0560b r39e141f  
    6868        live=calloc((argc-optind),sizeof(bool));
    6969        for(i=0;i<argc-optind;++i) {
    70                 struct libtrace_t *f;
     70                libtrace_t *f;
    7171                libtrace_packet_t *p;
    7272                f=trace_create(argv[i+optind]);
Note: See TracChangeset for help on using the changeset viewer.