`libnetdude` Manual
Prev |  | Next

# libnd_filter_registry

## Name

libnd_filter_registry --

## Synopsis

    enum        LND_FilterRegObserverOp;
    void        (*LND_FilterRegFunc)            (LND_Filter *filter,
                                                 void *user_data);
    void        libnd_filter_registry_init      (void);
    void        libnd_filter_registry_add       (LND_Filter *filter);
    void        libnd_filter_registry_del       (LND_Filter *filter);
    void        libnd_filter_registry_foreach   (LND_FilterRegFunc callback,
                                                 void *user_data);
    LND_FilterRegObserver* libnd_filter_registry_observer_new
                                                (void);
    void        libnd_filter_registry_observer_free
                                                (LND_FilterRegObserver *ob);
    void        libnd_filter_registry_add_observer
                                                (LND_FilterRegObserver *ob);
    void        libnd_filter_registry_del_observer
                                                (LND_FilterRegObserver *ob);
    void        libnd_filter_registry_tell_observers
                                                (LND_Filter *filter,
                                                 LND_FilterRegObserverOp op);

## Description

## Details

### enum LND_FilterRegObserverOp

    typedef enum {
      LND_FILTER_ADDED             = (1 << 0),
      LND_FILTER_DELETED           = (1 << 1)
    } LND_FilterRegObserverOp;

### LND_FilterRegFunc ()

    void        (*LND_FilterRegFunc)            (LND_Filter *filter,
                                                 void *user_data);

This is the signature for callbacks passed to `libnd_filter_registry_foreach()`.

`filter` :

  filter passed in.

`user_data` :

  user data.

### libnd_filter_registry_init ()

    void        libnd_filter_registry_init      (void);

The filter registry is Netdude's central repository for currently known packet filters. These can be implemented in any way desired, the typical example is a BPF filter. This function sets up the necessary data structures and is called when the library is initialized.

### libnd_filter_registry_add ()

    void        libnd_filter_registry_add       (LND_Filter *filter);

In order to register a filter in the registry, use this function. It checks if the filter is already registered and in that case, simply returns.

`filter` :

  the added filter.

### libnd_filter_registry_del ()

    void        libnd_filter_registry_del       (LND_Filter *filter);

Removes a filter from the registry.

`filter` :

  filter to remove.

### libnd_filter_registry_foreach ()

    void        libnd_filter_registry_foreach   (LND_FilterRegFunc callback,
                                                 void *user_data);

The function calls `callback` for every trace currently registered and passes it as first argument. The second argument is the user data, which is simply passed through.

`callback` :

  a function of type LND_FilterRegFunc

`user_data` :

  arbitrary data passed through to the callback

### libnd_filter_registry_observer_new ()

    LND_FilterRegObserver* libnd_filter_registry_observer_new
                                                (void);

Returns :

### libnd_filter_registry_observer_free ()

    void        libnd_filter_registry_observer_free
                                                (LND_FilterRegObserver *ob);

The function releases all memory associated with `ob`.

`ob` :

  observer to delete.

### libnd_filter_registry_add_observer ()

    void        libnd_filter_registry_add_observer
                                                (LND_FilterRegObserver *ob);

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

`ob` :

  new observer to register.

### libnd_filter_registry_del_observer ()

    void        libnd_filter_registry_del_observer
                                                (LND_FilterRegObserver *ob);

The function stops filter registry updates from being reported to `ob`. It does not release `ob`'s memory, use `libnd_filter_registry_observer_free()` for that.

`ob` :

  observer to drop.

### libnd_filter_registry_tell_observers ()

    void        libnd_filter_registry_tell_observers
                                                (LND_Filter *filter,
                                                 LND_FilterRegObserverOp op);

`filter` :

`op` :

Prev | Home | Next
libnd_filter_factory | Up | libnd_globals