]> git.meshlink.io Git - catta/blob - iface.h
add prioq abstract data type
[catta] / iface.h
1 #ifndef fooifacehfoo
2 #define fooifacehfoo
3
4 #include <glib.h>
5
6 #include "address.h"
7
8 struct _flxInterfaceMonitor;
9 typedef struct _flxInterfaceMonitor flxInterfaceMonitor;
10
11 struct _flxInterfaceAddress;
12 typedef struct _flxInterfaceAddress flxInterfaceAddress;
13
14 struct _flxInterface;
15 typedef struct _flxInterface flxInterface;
16
17 struct _flxInterface {
18     gchar *name;
19     gint index;
20     guint flags;
21
22     guint n_ipv6_addrs, n_ipv4_addrs;
23     
24     flxInterfaceAddress *addresses;
25     flxInterface *next, *prev;
26 };
27
28 struct _flxInterfaceAddress {
29     guchar flags;
30     guchar scope;
31     flxAddress address;
32     
33     flxInterface *interface;
34     flxInterfaceAddress *next, *prev;
35 };
36
37 typedef enum { FLX_INTERFACE_NEW, FLX_INTERFACE_REMOVE, FLX_INTERFACE_CHANGE } flxInterfaceChange;
38
39 flxInterfaceMonitor *flx_interface_monitor_new(GMainContext *c);
40 void flx_interface_monitor_free(flxInterfaceMonitor *m);
41
42 const flxInterface* flx_interface_monitor_get_interface(flxInterfaceMonitor *m, gint index);
43 const flxInterface* flx_interface_monitor_get_first(flxInterfaceMonitor *m);
44
45 void flx_interface_monitor_add_interface_callback(
46     flxInterfaceMonitor *m,
47     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterface *i, gpointer userdata),
48     gpointer userdata);
49
50 void flx_interface_monitor_remove_interface_callback(
51     flxInterfaceMonitor *m,
52     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterface *i, gpointer userdata),
53     gpointer userdata);
54
55 void flx_interface_monitor_add_address_callback(
56     flxInterfaceMonitor *m,
57     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterfaceAddress *a, gpointer userdata),
58     gpointer userdata);
59
60 void flx_interface_monitor_remove_address_callback(
61     flxInterfaceMonitor *m,
62     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterfaceAddress *a, gpointer userdata),
63     gpointer userdata);
64
65 #endif