Changeset 4af54d1 for lib/libtrace.h


Ignore:
Timestamp:
03/26/06 17:15:32 (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:
c2f71ad
Parents:
c219603
Message:

Split protocol decode logic into a seperate file, cleaned up some of the
protocol decode logic. Started IPv6 support, added some
trace_get_payload_from_* helper functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    r9c4b5e3 r4af54d1  
    176176    struct in_addr ip_src;              /**< source address */
    177177    struct in_addr ip_dst;              /**< dest address */
    178 } libtrace_ip_t
    179 ;
     178} libtrace_ip_t;
     179
     180/** IPv6 header structure */
     181typedef PACKED struct libtrace_ip6
     182{
     183#if BYTE_ORDER == LITTLE_ENDIAN
     184    unsigned int flow:4;                /**< Flow label */
     185    unsigned int tclass:8;              /**< Traffic class */
     186    unsigned int version:4;             /**< IP Version (6) */
     187#elif BYTE_ORDER == BIG_ENDIAN
     188    unsigned int version:4;             /**< IP Version (6) */
     189    unsigned int tclass:8;              /**< Traffic class */
     190    unsigned int flow:4;                /**< Flow label */
     191#else
     192#   error "Adjust your <bits/endian.h> defines"
     193#endif
     194    uint16_t peln;                      /**< Payload length */
     195    uint8_t nxthdr;                     /**< Next header */
     196    uint8_t hlim;                       /**< Hop limit */
     197    struct in6_addr ip_src;             /**< source address */
     198    struct in6_addr ip_dst;             /**< dest address */
     199} libtrace_ip6_t;
    180200
    181201/** Structure for dealing with TCP packets */
     
    293313 u_int16_t ether_type;          /**< ether type */
    294314} __attribute__ ((packed)) libtrace_pos;
     315
     316/** 802.11 header */
     317typedef struct libtrace_80211_t {
     318        unsigned int      protocol:2;
     319        unsigned int      type:2;
     320        unsigned int      subtype:4;
     321        unsigned int      to_ds:1;              /**< Packet to Distribution Service */
     322        unsigned int      from_ds:1;            /**< Packet from Distribution Service */
     323        unsigned int      more_frag:1;          /**< Packet has more fragments */
     324        unsigned int      retry:1;              /**< Packet is a retry */
     325        unsigned int      power:1;
     326        unsigned int      more_data:1;
     327        unsigned int      wep:1;
     328        unsigned int      order:1;
     329        unsigned int     duration;
     330        uint8_t      mac1[6];
     331        uint8_t      mac2[6];
     332        uint8_t      mac3[6];
     333        uint16_t     SeqCtl;
     334        uint8_t      mac4[6];
     335} libtrace_80211_t;
     336
     337
    295338/*@}*/
    296339
     
    621664void *trace_get_transport(const libtrace_packet_t *packet);
    622665
    623 /** Gets a pointer to the transport layer header (if any) given a pointer to the
    624  * IP header
     666/** Gets a pointer to the payload given a pointer to the IP header
    625667 * @param ip            The IP Header
    626668 * @param[out] skipped  An output variable of the number of bytes skipped
     
    629671 *
    630672 * Skipped can be NULL, in which case it will be ignored
    631  */
    632 void *trace_get_transport_from_ip(const libtrace_ip_t *ip, int *skipped);
     673 * @note This was called trace_get_transport_from_ip in libtrace2
     674 */
     675void *trace_get_payload_from_ip(libtrace_ip_t *ip, int *skipped);
     676
     677/** Gets a pointer to the payload given a pointer to a tcp header
     678 * @param tcp           The tcp Header
     679 * @param[out] skipped  An output variable of the number of bytes skipped
     680 *
     681 * @return a pointer to the transport layer header, or NULL if there is no header
     682 *
     683 * Skipped can be NULL, in which case it will be ignored
     684 * @note This was called trace_get_transport_from_ip in libtrace2
     685 */
     686void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, int *skipped);
     687
     688/** Gets a pointer to the payload given a pointer to a udp header
     689 * @param udp           The udp Header
     690 * @param[out] skipped  An output variable of the number of bytes skipped
     691 *
     692 * @return a pointer to the transport layer header, or NULL if there is no header
     693 *
     694 * Skipped can be NULL, in which case it will be ignored
     695 * @note This was called trace_get_transport_from_ip in libtrace2
     696 */
     697void *trace_get_payload_from_udp(libtrace_udp_t *udp, int *skipped);
     698
     699/** Gets a pointer to the payload given a pointer to a icmp header
     700 * @param icmp          The udp Header
     701 * @param[out] skipped  An output variable of the number of bytes skipped
     702 *
     703 * @return a pointer to the transport layer header, or NULL if there is no header
     704 *
     705 * Skipped can be NULL, in which case it will be ignored
     706 * @note This was called trace_get_transport_from_ip in libtrace2
     707 */
     708void *trace_get_payload_from_udp(libtrace_udp_t *udp, int *skipped);
    633709
    634710/** get a pointer to the TCP header (if any)
     
    651727 */
    652728SIMPLE_FUNCTION
    653 libtrace_tcp_t *trace_get_tcp_from_ip(const libtrace_ip_t *ip,int *skipped);
     729libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip,int *skipped);
    654730
    655731/** get a pointer to the UDP header (if any)
     
    659735 */
    660736SIMPLE_FUNCTION
    661 libtrace_udp_t *trace_get_udp(const libtrace_packet_t *packet);
     737libtrace_udp_t *trace_get_udp(libtrace_packet_t *packet);
    662738
    663739/** get a pointer to the UDP header (if any) given a pointer to the IP header
     
    670746 */
    671747SIMPLE_FUNCTION
    672 libtrace_udp_t *trace_get_udp_from_ip(const libtrace_ip_t *ip,int *skipped);
     748libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,int *skipped);
    673749
    674750/** get a pointer to the ICMP header (if any)
     
    689765 */
    690766SIMPLE_FUNCTION
    691 libtrace_icmp_t *trace_get_icmp_from_ip(const libtrace_ip_t *ip,int *skipped);
     767libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,int *skipped);
    692768/*@}*/
    693769
Note: See TracChangeset for help on using the changeset viewer.