Changeset a9d0e40 for lib/

11/28/17 17:37:51 (4 years ago)
Shane Alcock <salcock@…>
cachetimestamps, develop, dpdk-ndag, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Shane Alcock <salcock@…> (11/28/17 17:34:41)
Shane Alcock <salcock@…> (11/28/17 17:37:51)

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).

1 edited


  • lib/

    r2c457ec ra9d0e40  
    17931793DLLEXPORT int trace_read_packet(libtrace_t *trace, libtrace_packet_t *packet);
     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);
     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,
     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
    17951839/** Event types
    17961840 * see \ref libtrace_eventobj_t and \ref trace_event
Note: See TracChangeset for help on using the changeset viewer.