]> git.meshlink.io Git - catta/blob - iface.h
* add support for both ipv4 AND ipv6 reverse lookups
[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     flxInterfaceAddress *addresses;
23     flxInterface *next, *prev;
24 };
25
26 struct _flxInterfaceAddress {
27     guchar flags;
28     guchar scope;
29     flxAddress address;
30     
31     flxInterface *interface;
32     flxInterfaceAddress *next, *prev;
33 };
34
35 typedef enum { FLX_INTERFACE_NEW, FLX_INTERFACE_REMOVE, FLX_INTERFACE_CHANGE } flxInterfaceChange;
36
37 flxInterfaceMonitor *flx_interface_monitor_new(GMainContext *c);
38 void flx_interface_monitor_free(flxInterfaceMonitor *m);
39
40 const flxInterface* flx_interface_monitor_get_interface(flxInterfaceMonitor *m, gint index);
41 const flxInterface* flx_interface_monitor_get_first(flxInterfaceMonitor *m);
42
43 void flx_interface_monitor_add_interface_callback(
44     flxInterfaceMonitor *m,
45     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterface *i, gpointer userdata),
46     gpointer userdata);
47
48 void flx_interface_monitor_remove_interface_callback(
49     flxInterfaceMonitor *m,
50     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterface *i, gpointer userdata),
51     gpointer userdata);
52
53 void flx_interface_monitor_add_address_callback(
54     flxInterfaceMonitor *m,
55     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterfaceAddress *a, gpointer userdata),
56     gpointer userdata);
57
58 void flx_interface_monitor_remove_address_callback(
59     flxInterfaceMonitor *m,
60     void (*cb)(flxInterfaceMonitor *m, flxInterfaceChange change, const flxInterfaceAddress *a, gpointer userdata),
61     gpointer userdata);
62
63 #endif