Changeset a9d0e40


Ignore:
Timestamp:
11/28/17 17:37:51 (4 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, dpdk-ndag, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
6452c2c
Parents:
9726d0e
git-author:
Shane Alcock <salcock@…> (11/28/17 17:34:41)
git-committer:
Shane Alcock <salcock@…> (11/28/17 17:37:51)
Message:

trace_prepare_packet is now an external API function

Previously it was for internal use only, but I now have a use
case where it makes sense to have access to it externally
(specifically: "casting" DAG buffer pointers to libtrace packets
so I can dynamically snap them without having the overhead of
the whole of libtrace).

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    r2c457ec ra9d0e40  
    17931793DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
    17941794
     1795/** Converts the data provided in buffer into a valid libtrace packet
     1796 *
     1797 * @param trace         An input trace of the same format as the "packet"
     1798 *                      contained in the buffer
     1799 * @param packet        The libtrace packet to prepare
     1800 * @param buffer        A buffer containing the packet data, including the
     1801 *                      capture format header
     1802 * @param rt_type       The RT type for the packet that is being prepared
     1803 * @param flags         Used to specify options for the preparation function,
     1804 *                      e.g. who owns the packet buffer
     1805 *
     1806 * @return -1 if an error occurs, 0 otherwise
     1807 *
     1808 * Packet preparation is a tricky concept - the idea is to take the data
     1809 * pointed to by 'buffer' and treat it as a packet record of the same capture
     1810 * format as that used by the input trace. The provided libtrace packet then
     1811 * has its internal pointers and values set to describe the packet record in
     1812 * the buffer.
     1813 *
     1814 * The primary use of this function is to allow the RT packet reader to
     1815 * easily and safely convert packets from the RT format back into the format
     1816 * that they were originally captured with., essentially removing the RT
     1817 * encapsulation.
     1818 *
     1819 * This function is now available via the exported API, as it can have some
     1820 * uses outside of internal libtrace contexts. However, we strongly advise
     1821 * that you avoid using this function unless you really know what you are
     1822 * doing.
     1823 */
     1824DLLEXPORT int trace_prepare_packet(libtrace_t *trace, libtrace_packet_t *packet,
     1825                void *buffer, libtrace_rt_types_t rt_type, uint32_t flags);
     1826
     1827/** Flags for prepare_packet functions */
     1828enum {
     1829        /** The buffer memory has been allocated by libtrace and should be
     1830         * freed when the packet is destroyed. */
     1831        TRACE_PREP_OWN_BUFFER           =1,
     1832
     1833        /** The buffer memory is externally-owned and must not be freed by
     1834         * libtrace when the packet is destroyed. */
     1835        TRACE_PREP_DO_NOT_OWN_BUFFER    =0
     1836};
     1837
     1838
    17951839/** Event types
    17961840 * see \ref libtrace_eventobj_t and \ref trace_event
  • lib/libtrace_int.h

    rea75ec2 ra9d0e40  
    427427void trace_clear_cache(libtrace_packet_t *packet);
    428428
    429 /** Converts the data provided in buffer into a valid libtrace packet
    430  *
    431  * @param trace         An input trace of the same format as the "packet"
    432  *                      contained in the buffer
    433  * @param packet        The libtrace packet to prepare
    434  * @param buffer        A buffer containing the packet data, including the
    435  *                      capture format header
    436  * @param rt_type       The RT type for the packet that is being prepared
    437  * @param flags         Used to specify options for the preparation function,
    438  *                      e.g. who owns the packet buffer
    439  *
    440  * @return -1 if an error occurs, 0 otherwise
    441  *
    442  * Packet preparation is a tricky concept - the idea is to take the data
    443  * pointed to by 'buffer' and treat it as a packet record of the same capture
    444  * format as that used by the input trace. The provided libtrace packet then
    445  * has its internal pointers and values set to describe the packet record in
    446  * the buffer.
    447  *
    448  * The primary use of this function is to allow the RT packet reader to
    449  * easily and safely convert packets from the RT format back into the format
    450  * that they were originally captured with., essentially removing the RT
    451  * encapsulation.
    452  *
    453  * We've decided not to make this function available via the exported API
    454  * because there are several issues that can arise if it is not used very
    455  * carefully and it is not very useful outside of internal contexts anyway.
    456  */
    457 int trace_prepare_packet(libtrace_t *trace, libtrace_packet_t *packet,
    458                 void *buffer, libtrace_rt_types_t rt_type, uint32_t flags);
    459 
    460 /** Flags for prepare_packet functions */
    461 enum {
    462         /** The buffer memory has been allocated by libtrace and should be
    463          * freed when the packet is destroyed. */
    464         TRACE_PREP_OWN_BUFFER           =1,
    465        
    466         /** The buffer memory is externally-owned and must not be freed by
    467          * libtrace when the packet is destroyed. */
    468         TRACE_PREP_DO_NOT_OWN_BUFFER    =0
    469 };
    470 
    471429
    472430#ifndef PF_RULESET_NAME_SIZE
Note: See TracChangeset for help on using the changeset viewer.