Changeset 68667ee for lib/libtrace.h


Ignore:
Timestamp:
02/23/05 11:45:44 (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:
b06e535
Parents:
cb8c1b9
Message:

Merged in a whole heap of useful features

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    r488432b r68667ee  
    248248struct libtrace_tcp *trace_get_tcp(struct libtrace_packet_t *packet);
    249249
     250/** get a pointer to the TCP header (if any) given a pointer to the IP header
     251 * @param ip            The IP header
     252 * @param[out] skipped  An output variable of the number of bytes skipped
     253 *
     254 * @returns a pointer to the TCP header, or NULL if this is not a TCP packet
     255 *
     256 * Skipped can be NULL, in which case it will be ignored by the program.
     257 *
     258 * @author Perry Lorier
     259 */
     260struct libtrace_tcp *trace_get_tcp_from_ip(struct libtrace_ip *ip,int *skipped);
     261
    250262/** get a pointer to the UDP header (if any)
    251263 * @param packet        the packet opaque pointer
     
    255267struct libtrace_udp *trace_get_udp(struct libtrace_packet_t *packet);
    256268
     269/** get a pointer to the UDP header (if any) given a pointer to the IP header
     270 * @param       ip      The IP header
     271 * @param[out]  skipped An output variable of the number of bytes skipped
     272 *
     273 * @returns a pointer to the UDP header, or NULL if this is not an UDP packet
     274 *
     275 * Skipped may be NULL, in which case it will be ignored by this function.
     276 */
     277struct libtrace_udp *trace_get_udp_from_ip(struct libtrace_ip *ip,int *skipped);
     278
    257279/** get a pointer to the ICMP header (if any)
    258280 * @param packet        the packet opaque pointer
     
    261283 */
    262284struct libtrace_icmp *trace_get_icmp(struct libtrace_packet_t *packet);
     285
     286/** get a pointer to the ICMP header (if any) given a pointer to the IP header
     287 * @param ip            The IP header
     288 * @param[out] skipped  An output variable of the number of bytes skipped
     289 *
     290 * @returns a pointer to the ICMP header, or NULL if this is not an ICMP packet
     291 *
     292 * Skipped may be NULL, in which case it will be ignored by this function
     293 */
     294struct libtrace_icmp *trace_get_icmp_from_ip(struct libtrace_ip *ip,int *skipped);
     295
     296/** parse an ip or tcp option
     297 * @param[in,out] ptr   the pointer to the current option
     298 * @param[in,out] len   the length of the remaining buffer
     299 * @param[out] type     the type of the option
     300 * @param[out] optlen   the length of the option
     301 * @param[out] data     the data of the option
     302 *
     303 * @returns bool true if there is another option (and the fields are filled in)
     304 *               or false if this was the last option.
     305 *
     306 * This updates ptr to point to the next option after this one, and updates
     307 * len to be the number of bytes remaining in the options area.  Type is updated
     308 * to be the code of this option, and data points to the data of this option,
     309 * with optlen saying how many bytes there are.
     310 *
     311 * @note Beware of fragmented packets.
     312 */
     313int trace_get_next_option(unsigned char **ptr,int *len,
     314                        unsigned char *type,
     315                        unsigned char *optlen,
     316                        unsigned char **data);
     317
    263318
    264319/** Get the current time in DAG time format
     
    269324 * @author Daniel Lawson
    270325 */
    271 uint64_t trace_get_erf_timestamp(struct libtrace_packet_t *packet);
     326uint64_t trace_get_erf_timestamp(const struct libtrace_packet_t *packet);
    272327
    273328/** Get the current time in struct timeval
     
    278333 * @author Perry Lorier
    279334 */
    280 struct timeval trace_get_timeval(struct libtrace_packet_t *packet);
     335struct timeval trace_get_timeval(const struct libtrace_packet_t *packet);
    281336
    282337/** Get the current time in floating point seconds
     
    286341 * @author Perry Lorier
    287342 */
    288 double trace_get_seconds(struct libtrace_packet_t *packet);
     343double trace_get_seconds(const struct libtrace_packet_t *packet);
    289344
    290345/** Get the size of the packet in the trace
     
    300355 */
    301356
    302 int trace_get_capture_length(struct libtrace_packet_t *packet);
     357int trace_get_capture_length(const struct libtrace_packet_t *packet);
    303358
    304359/** Get the size of the packet as it was seen on the wire.
     
    311366 */
    312367
    313 int trace_get_wire_length(struct libtrace_packet_t *packet);
     368int trace_get_wire_length(const struct libtrace_packet_t *packet);
    314369
    315370/** Link layer types
     
    330385 */
    331386
    332 inline libtrace_linktype_t trace_get_link_type(struct libtrace_packet_t *packet);
     387inline libtrace_linktype_t trace_get_link_type(const struct libtrace_packet_t *packet);
    333388
    334389/** Get the destination MAC addres
     
    338393 * @author Perry Lorier
    339394 */
    340 uint8_t *trace_get_destination_mac(struct libtrace_packet_t *packet);
     395uint8_t *trace_get_destination_mac(const struct libtrace_packet_t *packet);
    341396
    342397/** Get the source MAC addres
     
    345400 * @author Perry Lorier
    346401 */
    347 uint8_t *trace_get_source_mac(struct libtrace_packet_t *packet);
     402uint8_t *trace_get_source_mac(const, struct libtrace_packet_t *packet);
    348403
    349404/** Truncate the packet at the suggested length
     
    369424 * @author Daniel Lawson
    370425 */
    371 int8_t trace_get_direction(struct libtrace_packet_t *packet);
     426int8_t trace_get_direction(const struct libtrace_packet_t *packet);
    372427
    373428/** Event types */
     
    378433} libtrace_event_t;
    379434
     435/** structure returned by libtrace_event explaining what the current event is */
    380436struct libtrace_eventobj_t {
    381         libtrace_event_t type;
    382         int fd;
    383         double seconds;
     437        libtrace_event_t type; /**< event type (iowait,sleep,packet */
     438        int fd;                /**< if IOWAIT, the fd to sleep on */
     439        double seconds;        /**< if SLEEP, the amount of time to sleep for */
    384440};
    385441
Note: See TracChangeset for help on using the changeset viewer.