Changeset 05f2718
- Timestamp:
- 02/27/13 14:02:17 (9 years ago)
- 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:
- 954577b9
- Parents:
- 0801187
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h.in
rdc6072d r05f2718 1918 1918 uint32_t *remaining); 1919 1919 1920 /** Gets a pointer to the payload following a ICMPv6 header 1921 * @param icmp A pointer to the ICMPv6 header 1922 * @param[in,out] remaining Updated with the number of captured bytes remaining 1923 * 1924 * @return A pointer to the ICMPv6 payload, or NULL if the ICMPv6 header is 1925 * truncated. 1926 * 1927 * When calling this function, remaining must contain the number of captured 1928 * bytes remaining in the packet starting from the ICMPv6 header (including the 1929 * ICMP header itself). remaining will be updated to contain the number of 1930 * bytes remaining after the ICMPv6 header has been skipped. 1931 * 1932 * If the ICMPv6 header is complete but there are zero bytes of payload after 1933 * the header, a pointer to where the payload would be is returned and 1934 * remaining will be set to 0. If the ICMPv6 header is incomplete, NULL will be 1935 * returned and remaining will be set to 0. Therefore, it is important to check 1936 * the value of remaining after calling this function. 1937 * 1938 * @note In the case of some ICMPv6 messages, the payload may be the IP header 1939 * from the packet that triggered the ICMP message. 1940 * 1941 */ 1942 DLLEXPORT void *trace_get_payload_from_icmp6(libtrace_icmp6_t *icmp, 1943 uint32_t *remaining); 1944 1920 1945 /** Get a pointer to the TCP header (if present) 1921 1946 * @param packet The packet to get the TCP header from … … 2019 2044 DLLEXPORT SIMPLE_FUNCTION 2020 2045 libtrace_icmp_t *trace_get_icmp(libtrace_packet_t *packet); 2046 2047 /** Get a pointer to the ICMPv6 header (if present) 2048 * @param packet The packet to get the ICMPv6 header from 2049 * 2050 * @return A pointer to the ICMPv6 header, or NULL if there is not a complete 2051 * ICMP header present in the packet. 2052 * 2053 * This is a short-cut function enabling quick and easy access to the ICMPv6 2054 * header if that is all you care about. However, we recommend the use of the 2055 * more generic trace_get_transport() function instead. 2056 * 2057 * @note Unlike trace_get_transport(), this function will return NULL if the 2058 * ICMPv6 header is incomplete or truncated. 2059 */ 2060 DLLEXPORT SIMPLE_FUNCTION 2061 libtrace_icmp6_t *trace_get_icmp6(libtrace_packet_t *packet); 2021 2062 2022 2063 /** Get a pointer to the ICMP header following an IPv4 header (if present) -
lib/protocols_transport.c
rdc6072d r05f2718 294 294 } 295 295 296 DLLEXPORT libtrace_icmp6_t *trace_get_icmp6(libtrace_packet_t *packet) { 297 uint8_t proto; 298 uint32_t rem = 0; 299 libtrace_icmp6_t *icmp; 300 301 icmp=(libtrace_icmp6_t*)trace_get_transport(packet,&proto,&rem); 302 303 if (!icmp || proto != TRACE_IPPROTO_ICMPV6) 304 return NULL; 305 306 /* Make sure we return a full ICMP header as the caller has no way of 307 * telling how much of the packet is remaining */ 308 if (rem < sizeof(libtrace_icmp6_t)) 309 return NULL; 310 311 return icmp; 312 } 313 296 314 DLLEXPORT libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip, uint32_t *remaining) 297 315 { … … 343 361 } 344 362 363 DLLEXPORT void *trace_get_payload_from_icmp6(libtrace_icmp6_t *icmp, uint32_t *remaining) 364 { 365 if (remaining) { 366 if (*remaining < sizeof(libtrace_icmp6_t)) { 367 *remaining = 0; 368 return NULL; 369 } 370 *remaining-=sizeof(libtrace_icmp6_t); 371 } 372 return (char*)icmp+sizeof(libtrace_icmp6_t); 373 } 374 345 375 /* Return the source port 346 376 */
Note: See TracChangeset
for help on using the changeset viewer.