Skip to content

Format Module API

salcock edited this page Sep 8, 2014 · 1 revision

Format modules follow a simple API. The general rules are that they return 0 on success, and -1 and set trace error on failure.

Documentation about what functions they implement is found in libtrace_int.h.

Some functions are optional and can be set to NULL in the format module, but all format modules should provide at least the following:

  • get_link_type
  • one of the get_timestamp functions (get_seconds, get_erf_timestamp, get_timeval, get_timespec)
  • get_capture_length
  • get_wire_length
  • get_framing_length
  • event API call (this can be trace_event_device or trace_event_trace if no custom behaviour is needed)
  • set_capture_length

Formats that allow reading will also need to provide:

  • init_input
  • start_input
  • fin_input
  • read_packet

Formats that allow writing will also need to provide:

  • init_output
  • start_output
  • fin_output
  • write_packet

config_input and config_output are highly recommended as well, but not strictly necessary.

Notes:

  • libtrace will automatically "pause" an input if it is not already paused before calling the "close" method.
Clone this wiki locally