Changeset 31709e8d for lib/libtrace.h


Ignore:
Timestamp:
10/14/05 15:25:46 (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:
06a68c5
Parents:
5395ce6
Message:

Added SIMPLE_FUNCTION tag to hint to the compiler that if the function
is called twice, the result may be cached.

Fixed several documentation warnings

Fixed several "const" issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    r5395ce6 r31709e8d  
    4141extern "C" {
    4242#endif
     43
     44/* Function does not depend on anything but it's
     45 * parameters, used to hint gcc's optimisations
     46 */
     47#define SIMPLE_FUNCTION __attribute__((pure))
     48
    4349/** @file
    4450 *
     
    180186      u_int16_t mtu;
    181187    } frag;                     /**< path mtu discovery */
    182   } un;
     188  } un;                         /**< Union for payloads of various icmp codes */
    183189} __attribute__ ((__packed__));
    184190
     
    212218/** Gets the output format for a given output trace
    213219 *
    214  * @params libtrace     the output trace to get the name of the format fo
     220 * @param libtrace      the output trace to get the name of the format fo
    215221 * @returns callee-owned null-terminated char* containing the output format
    216222 *
    217223 */
    218 char *trace_get_output_format(struct libtrace_out_t *libtrace);
     224SIMPLE_FUNCTION
     225char *trace_get_output_format(const struct libtrace_out_t *libtrace);
    219226
    220227/** Prints error information
     
    222229 * Prints out a descriptive error message for the currently set trace_err value
    223230 */
    224 void trace_perror(char *caller);
     231void trace_perror(const char *caller);
    225232
    226233/** Create a trace file from a URI
    227234 *
    228  * @params char * containing a valid libtrace URI
     235 * @param uri containing a valid libtrace URI
    229236 * @returns opaque pointer to a libtrace_t
    230237 *
     
    248255 *  and trace_errno is set. Use trace_perror() to get more information
    249256 */
    250 struct libtrace_t *trace_create(char *uri);
     257struct libtrace_t *trace_create(const char *uri);
    251258
    252259/** Creates a "dummy" trace file that has only the format type set.
     
    258265 * that are not associated with a libtrace_t structure.
    259266 */
    260 struct libtrace_t *trace_create_dead(char *uri);
     267struct libtrace_t *trace_create_dead(const char *uri);
    261268
    262269/** Creates a trace output file from a URI.
     
    275282 *  and trace_errno is set. Use trace_perror() to get more information
    276283 */
    277 struct libtrace_out_t *trace_output_create(char *uri);
    278 
    279 /* Parses an output options string and calls the appropriate function to deal with output options.
     284struct libtrace_out_t *trace_output_create(const char *uri);
     285
     286/** Parses an output options string and calls the appropriate function to deal with output options.
    280287 *
    281288 * @param libtrace      the output trace object to apply the options to
     
    292299void trace_destroy(struct libtrace_t *trace);
    293300
     301/** Close a trace file, freeing up any resources it may have been using
     302 * @param trace         trace file to be destroyed
     303 */
    294304void trace_destroy_dead(struct libtrace_t *trace);
    295305
    296306/** Close a trace output file, freeing up any resources it may have been using
    297307 *
    298  * @param libtrace      the output trace file to be destroyed
     308 * @param trace         the output trace file to be destroyed
    299309 *
    300310 * @author Shane Alcock
     
    317327 * @returns the number of bytes written out, if zero or negative then an error has occured.
    318328 */
    319 int trace_write_packet(struct libtrace_out_t *trace, struct libtrace_packet_t *packet);
     329int trace_write_packet(struct libtrace_out_t *trace, const struct libtrace_packet_t *packet);
    320330
    321331/** get a pointer to the link layer
     
    327337 * this is
    328338 */
     339SIMPLE_FUNCTION
    329340void *trace_get_link(const struct libtrace_packet_t *packet);
    330341
     
    334345 * @returns a pointer to the IP header, or NULL if there is not an IP packet
    335346 */
     347SIMPLE_FUNCTION
    336348struct libtrace_ip *trace_get_ip(const struct libtrace_packet_t *packet);
    337349
     
    341353 * @returns a pointer to the TCP header, or NULL if there is not a TCP packet
    342354 */
     355SIMPLE_FUNCTION
    343356struct libtrace_tcp *trace_get_tcp(const struct libtrace_packet_t *packet);
    344357
     
    353366 * @author Perry Lorier
    354367 */
     368SIMPLE_FUNCTION
    355369struct libtrace_tcp *trace_get_tcp_from_ip(const struct libtrace_ip *ip,int *skipped);
    356370
     
    360374 * @returns a pointer to the UDP header, or NULL if this is not a UDP packet
    361375 */
     376SIMPLE_FUNCTION
    362377struct libtrace_udp *trace_get_udp(const struct libtrace_packet_t *packet);
    363378
     
    370385 * Skipped may be NULL, in which case it will be ignored by this function.
    371386 */
     387SIMPLE_FUNCTION
    372388struct libtrace_udp *trace_get_udp_from_ip(const struct libtrace_ip *ip,int *skipped);
    373389
     
    377393 * @returns a pointer to the ICMP header, or NULL if this is not a ICMP packet
    378394 */
     395SIMPLE_FUNCTION
    379396struct libtrace_icmp *trace_get_icmp(const struct libtrace_packet_t *packet);
    380397
     
    387404 * Skipped may be NULL, in which case it will be ignored by this function
    388405 */
     406SIMPLE_FUNCTION
    389407struct libtrace_icmp *trace_get_icmp_from_ip(const struct libtrace_ip *ip,int *skipped);
    390408
     
    419437 * @author Daniel Lawson
    420438 */
     439SIMPLE_FUNCTION
    421440uint64_t trace_get_erf_timestamp(const struct libtrace_packet_t *packet);
    422441
     
    428447 * @author Perry Lorier
    429448 */
     449SIMPLE_FUNCTION
    430450struct timeval trace_get_timeval(const struct libtrace_packet_t *packet);
    431451
     
    437457 * @author Perry Lorier
    438458 */
     459SIMPLE_FUNCTION
    439460double trace_get_seconds(const struct libtrace_packet_t *packet);
    440461
     
    450471 *  This is sometimes called the "snaplen".
    451472 */
    452 
     473SIMPLE_FUNCTION
    453474int trace_get_capture_length(const struct libtrace_packet_t *packet);
    454475
     
    461482 * not be the same as the Capture Len.
    462483 */
    463 
     484SIMPLE_FUNCTION
    464485int trace_get_wire_length(const struct libtrace_packet_t *packet);
    465486
     
    488509 * @author Daniel Lawson
    489510 */
    490 
     511SIMPLE_FUNCTION
    491512inline libtrace_linktype_t trace_get_link_type(const struct libtrace_packet_t *packet);
    492513
     
    497518 * @author Perry Lorier
    498519 */
     520SIMPLE_FUNCTION
    499521uint8_t *trace_get_destination_mac(const struct libtrace_packet_t *packet);
    500522
     
    504526 * @author Perry Lorier
    505527 */
     528SIMPLE_FUNCTION
    506529uint8_t *trace_get_source_mac(const struct libtrace_packet_t *packet);
    507530
    508531/** Truncate the packet at the suggested length
    509532 * @param packet        the packet opaque pointer
    510  * @param len           the new length of the packet
     533 * @param size          the new length of the packet
    511534 * @returns the new length of the packet, or the original length of the
    512535 * packet if unchanged
     
    532555 * @author Daniel Lawson
    533556 */
     557SIMPLE_FUNCTION
    534558int8_t trace_get_direction(const struct libtrace_packet_t *packet);
    535559
    536560/** Event types
    537  * see \ref libtrace_eventobj_t
     561 * see \ref libtrace_eventobj_t and \ref trace_event
    538562 */
    539563typedef enum {
     
    559583 *
    560584 * Type can be:
    561  *  TRACE_EVENT_IOWAIT  Waiting on I/O on <fd>
    562  *  TRACE_EVENT_SLEEP   Next event in <seconds>
    563  *  TRACE_EVENT_PACKET  Packet arrived in <buffer> with size <size>
     585 *  TRACE_EVENT_IOWAIT  Waiting on I/O on fd
     586 *  TRACE_EVENT_SLEEP   Next event in seconds
     587 *  TRACE_EVENT_PACKET  Packet arrived in buffer with size size
    564588 *  TRACE_EVENT_TERMINATE Trace terminated (perhaps with an error condition)
    565589 */
     
    576600 * filter is actually used
    577601 */
     602SIMPLE_FUNCTION
    578603struct libtrace_filter_t *trace_bpf_setfilter(const char *filterstring);
    579604
     
    590615
    591616
    592 typedef enum {USE_DEST, USE_SOURCE} serverport_t;
     617/** Which port is the server port */
     618typedef enum {
     619        USE_DEST,       /**< Destination port is the server port */
     620        USE_SOURCE      /**< Source port is the server port */
     621} serverport_t;
    593622
    594623/** Get the source port
     
    598627 * @author Perry Lorier
    599628 */
     629SIMPLE_FUNCTION
    600630uint16_t trace_get_source_port(const struct libtrace_packet_t *packet);
    601631
     
    606636 * @author Perry Lorier
    607637 */
     638SIMPLE_FUNCTION
    608639uint16_t trace_get_destination_port(const struct libtrace_packet_t *packet);
    609640
     
    616647 * @author Daniel Lawson
    617648 */
     649SIMPLE_FUNCTION
    618650int8_t trace_get_server_port(uint8_t protocol, uint16_t source, uint16_t dest);
    619651
     
    625657 * @author Shane Alcock
    626658 */
    627 char *trace_parse_uri(char *uri, char **format);
     659SIMPLE_FUNCTION
     660char *trace_parse_uri(const char *uri, char **format);
    628661#ifdef __cplusplus
    629662} // extern "C"
Note: See TracChangeset for help on using the changeset viewer.