]> git.meshlink.io Git - catta/blob - iface.h
fix typo of prioq-test in the clean target of Makefile
[catta] / iface.h
1 #ifndef fooifacehfoo
2 #define fooifacehfoo
3
4 #include <glib.h>
5
6 typedef struct _flxInterfaceMonitor flxInterfaceMonitor;
7 typedef struct _flxInterfaceAddress flxInterfaceAddress;
8 typedef struct _flxInterface flxInterface;
9 typedef struct _flxHwInterface flxHwInterface;
10
11 #include "address.h"
12 #include "server.h"
13 #include "netlink.h"
14 #include "cache.h"
15 #include "llist.h"
16 #include "psched.h"
17 #include "dns.h"
18 #include "announce.h"
19
20 struct _flxInterfaceMonitor {
21     flxServer *server;
22     flxNetlink *netlink;
23     GHashTable *hash_table;
24
25     FLX_LLIST_HEAD(flxInterface, interfaces);
26     FLX_LLIST_HEAD(flxHwInterface, hw_interfaces);
27     
28     guint query_addr_seq, query_link_seq;
29     
30     enum {
31         LIST_IFACE,
32         LIST_ADDR,
33         LIST_DONE
34     } list;
35 };
36
37 struct _flxHwInterface {
38     FLX_LLIST_FIELDS(flxHwInterface, hardware);
39     flxInterfaceMonitor *monitor;
40
41     gchar *name;
42     gint index;
43     guint flags;
44     guint mtu;
45
46     FLX_LLIST_HEAD(flxInterface, interfaces);
47 };
48
49 struct _flxInterface {
50     FLX_LLIST_FIELDS(flxInterface, interface);
51     FLX_LLIST_FIELDS(flxInterface, by_hardware);
52     flxInterfaceMonitor *monitor;
53     
54     flxHwInterface *hardware;
55     guchar protocol;
56     gboolean announcing;
57
58     flxCache *cache;
59     flxPacketScheduler *scheduler;
60
61     FLX_LLIST_HEAD(flxInterfaceAddress, addresses);
62     FLX_LLIST_HEAD(flxAnnouncement, announcements);
63 };
64
65 struct _flxInterfaceAddress {
66     FLX_LLIST_FIELDS(flxInterfaceAddress, address);
67     flxInterfaceMonitor *monitor;
68     
69     guchar flags;
70     guchar scope;
71     flxAddress address;
72     
73     flxEntryGroup *entry_group;
74     flxInterface *interface;
75 };
76
77 flxInterfaceMonitor *flx_interface_monitor_new(flxServer *server);
78 void flx_interface_monitor_free(flxInterfaceMonitor *m);
79
80 void flx_interface_monitor_sync(flxInterfaceMonitor *m);
81
82 flxInterface* flx_interface_monitor_get_interface(flxInterfaceMonitor *m, gint index, guchar protocol);
83 flxHwInterface* flx_interface_monitor_get_hw_interface(flxInterfaceMonitor *m, gint index);
84
85 void flx_interface_send_packet(flxInterface *i, flxDnsPacket *p);
86
87 void flx_interface_post_query(flxInterface *i, flxKey *k, gboolean immediately);
88 void flx_interface_post_probe(flxInterface *i, flxRecord *p, gboolean immediately);
89 void flx_interface_post_response(flxInterface *i, const flxAddress *a, flxRecord *record, gboolean flush_cache, gboolean immediately);
90
91 void flx_dump_caches(flxInterfaceMonitor *m, FILE *f);
92
93 gboolean flx_interface_relevant(flxInterface *i);
94 gboolean flx_interface_address_relevant(flxInterfaceAddress *a);
95
96 gboolean flx_interface_match(flxInterface *i, gint index, guchar protocol);
97
98 typedef void (*flxInterfaceMonitorWalkCallback)(flxInterfaceMonitor *m, flxInterface *i, gpointer userdata);
99     
100 void flx_interface_monitor_walk(flxInterfaceMonitor *m, gint index, guchar protocol, flxInterfaceMonitorWalkCallback callback, gpointer userdata);
101
102 #endif