`libnetdude` Manual
Prev |  | Next

# libnd_tp

## Name

libnd_tp --

## Synopsis

    enum        LND_TracePartObserverOp;
    LND_TracePart* libnd_tp_new                 (LND_TPM *tpm,
                                                 LND_TracePart *parent,
                                                 off_t start_offset);
    void        libnd_tp_free                   (LND_TracePart *tp);
    gboolean    libnd_tp_set_input_file         (LND_TracePart *tp,
                                                 const char *filename);
    gboolean    libnd_tp_set_output_file        (LND_TracePart *tp,
                                                 const char *filename);
    LND_TracePart* libnd_tp_find_part_after_offset
                                                (const LND_TracePart *tp,
                                                 off_t offset,
                                                 const LND_TracePart *tp_dontuse);
    void        libnd_tp_write_packet           (LND_TracePart *tp,
                                                 const LND_Packet *packet);
    void        libnd_tp_set_dirty              (LND_TracePart *tp,
                                                 gboolean dirty);
    void        libnd_tp_init_packets           (LND_TracePart *tp);
    void        libnd_tp_insert_packets         (LND_TracePart *tp,
                                                 LND_Packet *packet,
                                                 int index);
    LND_Packet* libnd_tp_remove_packet          (LND_TracePart *tp,
                                                 int index);
    void        libnd_tp_sync                   (LND_TracePart *tp);
    LND_Packet* libnd_tp_clear_packetlists      (LND_TracePart *tp);
    void        libnd_tp_move_packet            (LND_TracePart *tp,
                                                 int from_index,
                                                 int to_index);
    LND_Packet* libnd_tp_packet_get_nth         (const LND_TracePart *tp,
                                                 int n);
    void        libnd_tp_clear_selection        (LND_TracePart *tp);
    void        libnd_tp_full_selection         (LND_TracePart *tp);
    LND_Packet* libnd_tp_select_packet          (LND_TracePart *tp,
                                                 int index);
    LND_Packet* libnd_tp_unselect_packet        (LND_TracePart *tp,
                                                 int index);
    guint       libnd_tp_get_sel_size           (LND_TracePart *tp);
    void        libnd_tp_sel_delete             (LND_TracePart *tp);
    void        libnd_tp_sel_filter             (LND_TracePart *tp);
    void        libnd_tp_sel_unfilter           (LND_TracePart *tp);
    LND_TracePartObserver* libnd_tp_observer_new
                                                (void);
    void        libnd_tp_observer_free          (LND_TracePartObserver *ob);
    void        libnd_tp_add_observer           (LND_TracePartObserver *ob);
    void        libnd_tp_del_observer           (LND_TracePartObserver *ob);
    void        libnd_tp_tell_observers         (LND_TracePart *trace,
                                                 LND_TracePartObserverOp op,
                                                 void *data);

## Description

## Details

### enum LND_TracePartObserverOp

    typedef enum {
      LND_TP_PACKET_SEL        = (1 << 0), /* Packet at certain index got selected */
      LND_TP_PACKET_UNSEL      = (1 << 1), /* Packet at certain index got deselected */
      LND_TP_SEL_CLR           = (1 << 2), /* All packets got deselected */
      LND_TP_SEL_ALL           = (1 << 3), /* All in-mem packets of trace part got selected */
      LND_TP_SEL_DEL           = (1 << 4), /* Selected in-mem packets got deleted */
      LND_TP_DIRTY_STATE       = (1 << 5), /* Trace part's dirty state got changed */
    } LND_TracePartObserverOp;

### libnd_tp_new ()

    LND_TracePart* libnd_tp_new                 (LND_TPM *tpm,
                                                 LND_TracePart *parent,
                                                 off_t start_offset);

The function creates and returns a new trace part, sitting on top of `parent`, starting at `start_offset`. For the base part, the parent is `NULL`.

`tpm` :

  TPM for this part.

`parent` :

  trace part that this new part starts upon.

`start_offset` :

  offset into `parent` where new part starts.

Returns :

  new trace part, or `NULL` on error.

### libnd_tp_free ()

    void        libnd_tp_free                   (LND_TracePart *tp);

The function releases the memory occupied by the trace part pointed to by `tp`.

`tp` :

  trace part to free.

### libnd_tp_set_input_file ()

    gboolean    libnd_tp_set_input_file         (LND_TracePart *tp,
                                                 const char *filename);

This function specifies the input trace file for `tp`. For a TPM's base trace, this is the original input trace.

`tp` :

  trace part to set input for.

`filename` :

  filename of the input trace part.

Returns :

  `TRUE` when successful, `FALSE` otherwise.

### libnd_tp_set_output_file ()

    gboolean    libnd_tp_set_output_file        (LND_TracePart *tp,
                                                 const char *filename);

The function sets the output trace file name for `tp` to `filename`. This means that when `tp`'s packets are written out to disk, `filename` will be used.

`tp` :

  trace part to set output for.

`filename` :

  name of output trace file.

Returns :

### libnd_tp_find_part_after_offset ()

    LND_TracePart* libnd_tp_find_part_after_offset
                                                (const LND_TracePart *tp,
                                                 off_t offset,
                                                 const LND_TracePart *tp_dontuse);

In a scenario of multiple trace parts piled onto each other, the function finds the first trace part that sits upon the given one, starting at or after the offset given. If you want to make sure that a certain trace part is not selected (like the most recent one used), pass it as `tp_last`.

`tp` :

  trace part to query.

`offset` :

  offset after which to look.

`tp_dontuse` :

  last trace part, must not be used. Can be `NULL`.

Returns :

  found trace part, or `NULL` if no such part exists.

### libnd_tp_write_packet ()

    void        libnd_tp_write_packet           (LND_TracePart *tp,
                                                 const LND_Packet *packet);

The function dumps the single given `packet` to the output trace file currently associated with `tp`.

`tp` :

  trace part whose output trace to use.

`packet` :

  packet to dump.

### libnd_tp_set_dirty ()

    void        libnd_tp_set_dirty              (LND_TracePart *tp,
                                                 gboolean dirty);

The function sets the modification status of `tp` to `dirty`.

`tp` :

  trace part to mark.

`dirty` :

  modification status to set to.

### libnd_tp_init_packets ()

    void        libnd_tp_init_packets           (LND_TracePart *tp);

The function initializes all packets belonging to `tp` and loaded into memory (using libnd_tpm_load_packets()).

`tp` :

  part whose loaded packets to initialize.

### libnd_tp_insert_packets ()

    void        libnd_tp_insert_packets         (LND_TracePart *tp,
                                                 LND_Packet *packet,
                                                 int index);

The function adds the chain of packets starting at `packet` to `tp` at `index`. The chain of packets is followed until a packet's next pointer is `NULL`, so make sure that last next pointer is correct. If `index` is < 0 or larger than the number of packets currently in the trace part, the packet is added at the end. Counting starts at zero, and the index is the index the packet will have when it is inserted. No limit checking is done; a trace part can grow arbitrarily large this way.

`tp` :

  part to add packet to.

`packet` :

  first of a chain of packets to add.

`index` :

  where to insert `packet`.

### libnd_tp_remove_packet ()

    LND_Packet* libnd_tp_remove_packet          (LND_TracePart *tp,
                                                 int index);

The function removes the packet at `index` in `tp` from `tp` and returns the packet.

`tp` :

  trace part.

`index` :

  index of the packet in the trace part.

Returns :

  removed packet, or `NULL` on error.

### libnd_tp_sync ()

    void        libnd_tp_sync                   (LND_TracePart *tp);

The function writes all packets the trace part has currently loaded into memory out to disk, using the currently existing output trace. After that, the input trace file is adjusted so that when packets are read from `tp`, the trace part that this function wrote packets into is used.

`tp` :

  trace part to sync.

### libnd_tp_clear_packetlists ()

    LND_Packet* libnd_tp_clear_packetlists      (LND_TracePart *tp);

The function resets the internal loaded packet and selected packet lists.

`tp` :

  trace part to reset.

Returns :

  first of the currently loaded packets (no longer associated with `tp`!).

### libnd_tp_move_packet ()

    void        libnd_tp_move_packet            (LND_TracePart *tp,
                                                 int from_index,
                                                 int to_index);

This function moves a single packet around in the trace part.

`tp` :

  trace part.

`from_index` :

  index of packet to move.

`to_index` :

  index to move packet to.

### libnd_tp_packet_get_nth ()

    LND_Packet* libnd_tp_packet_get_nth         (const LND_TracePart *tp,
                                                 int n);

This function returns the nth packet of the trace part, if possible, `NULL` otherwise.

`tp` :

  trace part.

`n` :

  index of packet to return.

Returns :

  packet.

### libnd_tp_clear_selection ()

    void        libnd_tp_clear_selection        (LND_TracePart *tp);

The function clears the selection of any in-memory packets of the trace part pointed to by `tp`.

`tp` :

  trace part to clear selection of.

### libnd_tp_full_selection ()

    void        libnd_tp_full_selection         (LND_TracePart *tp);

The function selectes all in-memory packets of the trace part pointed to by `tp`.

`tp` :

  trace part to select packets of.

### libnd_tp_select_packet ()

    LND_Packet* libnd_tp_select_packet          (LND_TracePart *tp,
                                                 int index);

The function selects the indicated packet and marks it as the currently selected one.

`tp` :

  trace part.

`index` :

  index of packet to select.

Returns :

  selected packet.

### libnd_tp_unselect_packet ()

    LND_Packet* libnd_tp_unselect_packet        (LND_TracePart *tp,
                                                 int index);

The function unselects the indicated packet in the trace part.

`tp` :

  trace part.

`index` :

  index of packet to unselect.

Returns :

  unselected packet.

### libnd_tp_get_sel_size ()

    guint       libnd_tp_get_sel_size           (LND_TracePart *tp);

The function returns the number of packets currently selected in `tp`.

`tp` :

  trace part.

Returns :

  number of packets.

### libnd_tp_sel_delete ()

    void        libnd_tp_sel_delete             (LND_TracePart *tp);

The function deletes the selected packets from `tp`.

`tp` :

  trace part.

### libnd_tp_sel_filter ()

    void        libnd_tp_sel_filter             (LND_TracePart *tp);

The currently selected packets are filtered.

`tp` :

  trace part.

### libnd_tp_sel_unfilter ()

    void        libnd_tp_sel_unfilter           (LND_TracePart *tp);

The function unfilters packets in the current selection.

`tp` :

  trace part.

### libnd_tp_observer_new ()

    LND_TracePartObserver* libnd_tp_observer_new
                                                (void);

The function allocates a new, empty trace observer. You should then fill in callbacks for the events you're interested in, and register the thing using libnd_tp_add_observer().

Returns :

  new observer.

### libnd_tp_observer_free ()

    void        libnd_tp_observer_free          (LND_TracePartObserver *ob);

The function releases all memory associated with `ob`.

`ob` :

  observer to delete.

### libnd_tp_add_observer ()

    void        libnd_tp_add_observer           (LND_TracePartObserver *ob);

The function registers the new observer for notifications about future changes to traces.

`ob` :

  new observer to register.

### libnd_tp_del_observer ()

    void        libnd_tp_del_observer           (LND_TracePartObserver *ob);

The function stops trace operations from being reported to `ob`. It does not release `ob`'s memory, use libnd_tp_observer_free() for that.

`ob` :

  observer to drop.

### libnd_tp_tell_observers ()

    void        libnd_tp_tell_observers         (LND_TracePart *trace,
                                                 LND_TracePartObserverOp op,
                                                 void *data);

`trace` :

`op` :

`data` :

Prev | Home | Next
libnd_timestamp | Up | libnd_tpm