summaryrefslogtreecommitdiffstats
path: root/iface.h
blob: 207c0b2f1e30ad02f3e52c542077c24fc61b268b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef fooifacehfoo
#define fooifacehfoo

#include <glib.h>

struct _flxInterfaceMonitor;
typedef struct _flxInterfaceMonitor flxInterfaceMonitor;

struct _flxInterfaceAddress;
typedef struct _flxInterfaceAddress flxInterfaceAddress;

struct _flxInterface;
typedef struct _flxInterface flxInterface;

#include "address.h"
#include "server.h"
#include "netlink.h"
#include "cache.h"
#include "llist.h"

struct _flxInterfaceMonitor {
    flxServer *server;
    flxNetlink *netlink;
    GHashTable *hash_table;

    FLX_LLIST_HEAD(flxInterface, interfaces);
    
    guint query_addr_seq, query_link_seq;
    
    enum { LIST_IFACE, LIST_ADDR, LIST_DONE } list;
};

struct _flxInterface {
    flxInterfaceMonitor *monitor;
    gchar *name;
    gint index;
    guint flags;

    FLX_LLIST_HEAD(flxInterfaceAddress, addresses);
    FLX_LLIST_FIELDS(flxInterface, interface);

    guint n_ipv6_addrs, n_ipv4_addrs;
    flxCache *ipv4_cache, *ipv6_cache;
};

struct _flxInterfaceAddress {
    guchar flags;
    guchar scope;
    flxAddress address;
    
    flxInterface *interface;

    FLX_LLIST_FIELDS(flxInterfaceAddress, address);

    gint rr_id;
};

flxInterfaceMonitor *flx_interface_monitor_new(flxServer *server);
void flx_interface_monitor_free(flxInterfaceMonitor *m);

flxInterface* flx_interface_monitor_get_interface(flxInterfaceMonitor *m, gint index);
flxInterface* flx_interface_monitor_get_first(flxInterfaceMonitor *m);

int flx_interface_is_relevant(flxInterface *i);
int flx_address_is_relevant(flxInterfaceAddress *a);

void flx_interface_send_query(flxInterface *i, guchar protocol, flxKey *k);

void flx_dump_caches(flxServer *s, FILE *f);

#endif