Changeset 9231fe5 for lib/libtrace.h


Ignore:
Timestamp:
04/07/06 00:17: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:
d320b63
Parents:
a842286
Message:

Minor cleanups in format_rt
Shuffled protocols.c around for better vlan support
Cleaned up IPv6 support to be more generic (less duplicated code)
added trace_get_{source,destination}_address

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    ra842286 r9231fe5  
    651651 */
    652652SIMPLE_FUNCTION
    653 libtrace_ip_t *trace_get_ip(const libtrace_packet_t *packet);
     653libtrace_ip_t *trace_get_ip(libtrace_packet_t *packet);
    654654
    655655/** Gets a pointer to the transport layer header (if any)
     
    661661 * @note proto may be NULL if proto is unneeded.
    662662 */
    663 void *trace_get_transport(const libtrace_packet_t *packet, uint8_t *proto);
     663void *trace_get_transport(libtrace_packet_t *packet, uint8_t *proto,
     664                uint32_t *remaining);
    664665
    665666/** Gets a pointer to the payload given a pointer to the IP header
    666667 * @param ip            The IP Header
    667668 * @param[out] proto    An output variable of the IP protocol
    668  * @param[out] skipped  An output variable of the number of bytes skipped
    669  *
    670  * @return a pointer to the transport layer header, or NULL if there is no header
    671  *
    672  * Skipped can be NULL, in which case it will be ignored
    673  * @note This was called trace_get_transport_from_ip in libtrace2
     669 * @param[in,out] remaining Updated with the number of bytes remaining
     670 *
     671 * @return a pointer to the transport layer header, or NULL if header isn't present.
     672 *
     673 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     674 * of bytes captured of the IP header and beyond.  It will be updated after this
     675 * function to the number of bytes remaining after the IP header (and any IP options)
     676 * have been removed.
     677 *
     678 * proto may be NULL if not needed.
     679 *
     680 * @note This is similar to trace_get_transport_from_ip in libtrace2
    674681 */
    675682void *trace_get_payload_from_ip(libtrace_ip_t *ip, uint8_t *proto,
    676                 int *skipped);
     683                uint32_t *remaining);
    677684
    678685/** Gets a pointer to the payload given a pointer to a tcp header
    679686 * @param tcp           The tcp Header
    680  * @param[out] skipped  An output variable of the number of bytes skipped
    681  *
    682  * @return a pointer to the transport layer header, or NULL if there is no header
    683  *
    684  * Skipped can be NULL, in which case it will be ignored
    685  * @note This was called trace_get_transport_from_ip in libtrace2
    686  */
    687 void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, int *skipped);
     687 * @param[in,out] remaining Updated with the number of bytes remaining
     688 *
     689 * @return a pointer to the tcp payload, or NULL if the payload isn't present.
     690 *
     691 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     692 * of bytes captured of the TCP header and beyond.  It will be updated after this
     693 * function to the number of bytes remaining after the TCP header (and any TCP options)
     694 * have been removed.
     695 *
     696 * @note This is similar to trace_get_transport_from_ip in libtrace2
     697 */
     698void *trace_get_payload_from_tcp(libtrace_tcp_t *tcp, uint32_t *remaining);
    688699
    689700/** Gets a pointer to the payload given a pointer to a udp header
    690701 * @param udp           The udp Header
    691  * @param[out] skipped  An output variable of the number of bytes skipped
    692  *
    693  * @return a pointer to the transport layer header, or NULL if there is no header
    694  *
    695  * Skipped can be NULL, in which case it will be ignored
    696  * @note This was called trace_get_transport_from_ip in libtrace2
    697  */
    698 void *trace_get_payload_from_udp(libtrace_udp_t *udp, int *skipped);
     702 * @param[in,out] remaining Updated with the number of bytes remaining
     703 *
     704 * @return a pointer to the udp payload, or NULL if the payload isn't present.
     705 *
     706 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     707 * of bytes captured of the TCP header and beyond.  It will be updated after this
     708 * function to the number of bytes remaining after the TCP header (and any TCP options)
     709 * have been removed.
     710 *
     711 * @note This is similar trace_get_transport_from_ip in libtrace2
     712 */
     713void *trace_get_payload_from_udp(libtrace_udp_t *udp, uint32_t *remaining);
    699714
    700715/** Gets a pointer to the payload given a pointer to a icmp header
    701  * @param icmp          The udp Header
    702  * @param[out] skipped  An output variable of the number of bytes skipped
    703  *
    704  * @return a pointer to the transport layer header, or NULL if there is no header
    705  *
    706  * Skipped can be NULL, in which case it will be ignored
    707  * @note This was called trace_get_transport_from_ip in libtrace2
    708  */
    709 void *trace_get_payload_from_udp(libtrace_udp_t *udp, int *skipped);
     716 * @param icmp          The icmp Header
     717 * @param[in,out] remaining Updated with the number of bytes remaining
     718 *
     719 * @return a pointer to the icmp payload, or NULL if the payload isn't present.
     720 *
     721 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     722 * of bytes captured of the TCP header and beyond.  It will be updated after this
     723 * function to the number of bytes remaining after the TCP header (and any TCP options)
     724 * have been removed.
     725 *
     726 * @note This is similar to trace_get_payload_from_icmp in libtrace2
     727 */
     728void *trace_get_payload_from_icmp(libtrace_icmp_t *icmp, uint32_t *skipped);
    710729
    711730/** get a pointer to the TCP header (if any)
     
    715734 */
    716735SIMPLE_FUNCTION
    717 libtrace_tcp_t *trace_get_tcp(const libtrace_packet_t *packet);
     736libtrace_tcp_t *trace_get_tcp(libtrace_packet_t *packet);
    718737
    719738/** get a pointer to the TCP header (if any) given a pointer to the IP header
    720739 * @param ip            The IP header
    721  * @param[out] skipped  An output variable of the number of bytes skipped
     740 * @param[in,out] remaining Updated with the number of bytes remaining
    722741 *
    723742 * @return a pointer to the TCP header, or NULL if this is not a TCP packet
    724743 *
    725  * Skipped can be NULL, in which case it will be ignored by the program.
    726  *
    727  * @author Perry Lorier
    728  */
    729 SIMPLE_FUNCTION
    730 libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip,int *skipped);
     744 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     745 * of bytes captured of the TCP header and beyond.  It will be updated after this
     746 * function to the number of bytes remaining after the TCP header (and any TCP options)
     747 * have been removed.
     748 *
     749 * @note The last parameter has changed from libtrace2
     750 */
     751SIMPLE_FUNCTION
     752libtrace_tcp_t *trace_get_tcp_from_ip(libtrace_ip_t *ip, uint32_t *remaining);
    731753
    732754/** get a pointer to the UDP header (if any)
     
    740762/** get a pointer to the UDP header (if any) given a pointer to the IP header
    741763 * @param       ip      The IP header
    742  * @param[out]  skipped An output variable of the number of bytes skipped
     764 * @param[in,out] remaining Updated with the number of bytes remaining
    743765 *
    744766 * @return a pointer to the UDP header, or NULL if this is not an UDP packet
    745767 *
    746  * Skipped may be NULL, in which case it will be ignored by this function.
    747  */
    748 SIMPLE_FUNCTION
    749 libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,int *skipped);
     768 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     769 * of bytes captured of the TCP header and beyond.  It will be updated after this
     770 * function to the number of bytes remaining after the TCP header (and any TCP options)
     771 * have been removed.
     772 *
     773 * @note Beware the change from libtrace2 from skipped to remaining
     774 */
     775SIMPLE_FUNCTION
     776libtrace_udp_t *trace_get_udp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
    750777
    751778/** get a pointer to the ICMP header (if any)
     
    755782 */
    756783SIMPLE_FUNCTION
    757 libtrace_icmp_t *trace_get_icmp(const libtrace_packet_t *packet);
     784libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet);
    758785
    759786/** get a pointer to the ICMP header (if any) given a pointer to the IP header
    760787 * @param ip            The IP header
    761  * @param[out] skipped  An output variable of the number of bytes skipped
     788 * @param[in,out] remaining Updated with the number of bytes remaining
    762789 *
    763790 * @return a pointer to the ICMP header, or NULL if this is not an ICMP packet
    764791 *
    765  * Skipped may be NULL, in which case it will be ignored by this function
    766  */
    767 SIMPLE_FUNCTION
    768 libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,int *skipped);
     792 * Remaining may be NULL.  If Remaining is not NULL it must point to the number
     793 * of bytes captured of the TCP header and beyond.  It will be updated after this
     794 * function to the number of bytes remaining after the TCP header (and any TCP options)
     795 * have been removed.
     796 *
     797 * @note Beware the change from libtrace2 from skipped to remaining
     798 */
     799SIMPLE_FUNCTION
     800libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip,uint32_t *remaining);
     801
     802/** Get the destination MAC addres
     803 * @param packet        the packet opaque pointer
     804 * @return a pointer to the destination mac, (or NULL if there is no
     805 * destination MAC)
     806 */
     807SIMPLE_FUNCTION
     808uint8_t *trace_get_destination_mac(libtrace_packet_t *packet);
     809
     810/** Get the source MAC addres
     811 * @param packet        the packet opaque pointer
     812 * @return a pointer to the source mac, (or NULL if there is no source MAC)
     813 */
     814SIMPLE_FUNCTION
     815uint8_t *trace_get_source_mac(libtrace_packet_t *packet);
     816
     817/** Get the source addres
     818 * @param packet        the packet opaque pointer
     819 * @param addr          a pointer to a sockaddr to store the address in, or NULL to use
     820 *                      static storage.
     821 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address
     822 */
     823SIMPLE_FUNCTION
     824struct sockaddr *trace_get_source_address(const libtrace_packet_t *packet,
     825                struct sockaddr *addr);
     826
     827/** Get the source addres
     828 * @param packet        the packet opaque pointer
     829 * @param addr          a pointer to a sockaddr to store the address in, or NULL to use
     830 *                      static storage.
     831 * @return NULL if there is no source address, or a sockaddr holding a v4 or v6 address
     832 */
     833SIMPLE_FUNCTION
     834struct sockaddr *trace_get_destination_address(const libtrace_packet_t *packet,
     835                struct sockaddr *addr);
     836
    769837/*@}*/
    770838
     
    9441012libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet);
    9451013
    946 /** Get the destination MAC addres
    947  * @param packet        the packet opaque pointer
    948  * @return a pointer to the destination mac, (or NULL if there is no
    949  * destination MAC)
    950  * @author Perry Lorier
    951  */
    952 SIMPLE_FUNCTION
    953 uint8_t *trace_get_destination_mac(const libtrace_packet_t *packet);
    954 
    955 /** Get the source MAC addres
    956  * @param packet        the packet opaque pointer
    957  * @return a pointer to the source mac, (or NULL if there is no source MAC)
    958  * @author Perry Lorier
    959  */
    960 SIMPLE_FUNCTION
    961 uint8_t *trace_get_source_mac(const libtrace_packet_t *packet);
    962 
    9631014/** Set the direction flag, if it has one
    9641015 * @param packet        the packet opaque pointer
Note: See TracChangeset for help on using the changeset viewer.