Changeset 5699389 for lib/libtrace.h.in


Ignore:
Timestamp:
03/05/13 13:43:48 (8 years ago)
Author:
Shane Alcock <salcock@…>
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:
af27241
Parents:
c5ff469
Message:
  • Added new API functions for getting the source and destination IPs as strings. Dealing with sockaddrs is hard, especially for n00bs.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    r05f2718 r5699389  
    24082408                struct sockaddr *addr);
    24092409
     2410/** Get the source IP address for a packet and convert it into a string
     2411 * @param packet        The packet to extract the source IP address from
     2412 * @param space         A pointer to a character buffer to store the address
     2413 *                      in. If NULL, static storage is used instead.
     2414 * @param spacelen      The size of the buffer passed in via 'space'. Set this
     2415 *                      to zero if you are going to pass in a NULL buffer.
     2416 * @return A pointer to a character buffer containing the string representation
     2417 * of the source IP address. For packets where there is no suitable IP address,
     2418 * the source MAC will be returned instead. Returns NULL if no valid address
     2419 * is available.
     2420 *
     2421 * @note Be wary of the possibility of the address being an IPv6 address - make
     2422 * sure your buffer is large enough!
     2423 *
     2424 * New in libtrace 3.0.17.
     2425 */
     2426DLLEXPORT SIMPLE_FUNCTION
     2427char *trace_get_source_address_string(const libtrace_packet_t *packet,
     2428                char *space, int spacelen);
     2429
    24102430/** Get the destination IP address for a given packet
    24112431 * @param packet        The packet to extract the destination IP address from
     
    24252445                struct sockaddr *addr);
    24262446
     2447/** Get the destination IP address for a packet and convert it into a string
     2448 * @param packet        The packet to extract the destination IP address from
     2449 * @param space         A pointer to a character buffer to store the address
     2450 *                      in. If NULL, static storage is used instead.
     2451 * @param spacelen      The size of the buffer passed in via 'space'. Set this
     2452 *                      to zero if you are going to pass in a NULL buffer.
     2453 * @return A pointer to a character buffer containing the string representation
     2454 * of the destination IP address. For packets where there is no suitable IP
     2455 * address, the destination MAC will be returned instead. Returns NULL if no
     2456 * valid address is available.
     2457 *
     2458 * @note Be wary of the possibility of the address being an IPv6 address - make
     2459 * sure your buffer is large enough!
     2460 *
     2461 * New in libtrace 3.0.17.
     2462 */
     2463DLLEXPORT SIMPLE_FUNCTION
     2464char *trace_get_destination_address_string(const libtrace_packet_t *packet,
     2465                char *space, int spacelen);
    24272466
    24282467/** Parses an IP or TCP option
Note: See TracChangeset for help on using the changeset viewer.