]> git.meshlink.io Git - catta/blob - avahi-core/iface.h
implement new main loop abstraction layer
[catta] / avahi-core / iface.h
1 #ifndef fooifacehfoo
2 #define fooifacehfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <glib.h>
26
27 typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
28 typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
29 typedef struct AvahiInterface AvahiInterface;
30 typedef struct AvahiHwInterface AvahiHwInterface;
31
32 #include <avahi-common/llist.h>
33 #include <avahi-common/address.h>
34 #include "server.h"
35 #include "netlink.h"
36 #include "cache.h"
37 #include "response-sched.h"
38 #include "query-sched.h"
39 #include "probe-sched.h"
40 #include "dns.h"
41 #include "announce.h"
42
43 #define AVAHI_MAX_MAC_ADDRESS 32
44
45 struct AvahiInterfaceMonitor {
46     AvahiServer *server;
47     AvahiNetlink *netlink;
48     GHashTable *hash_table;
49
50     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
51     AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
52     
53     guint query_addr_seq, query_link_seq;
54     
55     enum {
56         LIST_IFACE,
57         LIST_ADDR,
58         LIST_DONE
59     } list;
60 };
61
62 struct AvahiHwInterface {
63     AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
64     AvahiInterfaceMonitor *monitor;
65
66     gchar *name;
67     AvahiIfIndex index;
68     guint flags;
69     guint mtu;
70
71     guint8 mac_address[AVAHI_MAX_MAC_ADDRESS];
72     guint mac_address_size;
73
74     AvahiEntryGroup *entry_group;
75
76     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
77 };
78
79 struct AvahiInterface {
80     AVAHI_LLIST_FIELDS(AvahiInterface, interface);
81     AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
82     AvahiInterfaceMonitor *monitor;
83     
84     AvahiHwInterface *hardware;
85     AvahiProtocol protocol;
86     gboolean announcing;
87
88     AvahiCache *cache;
89     AvahiQueryScheduler *query_scheduler;
90     AvahiResponseScheduler * response_scheduler;
91     AvahiProbeScheduler *probe_scheduler;
92
93     AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
94     AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
95 };
96
97 struct AvahiInterfaceAddress {
98     AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
99     AvahiInterfaceMonitor *monitor;
100     
101     guchar flags;
102     guchar scope;
103     guchar prefix_len;
104     AvahiAddress address;
105     
106     AvahiEntryGroup *entry_group;
107     AvahiInterface *interface;
108 };
109
110 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
111 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
112
113 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
114
115 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
116 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, gint idx);
117
118 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
119 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, guint16 port);
120
121 gboolean avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, gboolean immediately);
122 gboolean avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, gboolean flush_cache, const AvahiAddress *querier, gboolean immediately);
123 gboolean avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, gboolean immediately);
124
125 void avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, gpointer userdata);
126
127 gboolean avahi_interface_relevant(AvahiInterface *i);
128 gboolean avahi_interface_address_relevant(AvahiInterfaceAddress *a);
129
130 gboolean avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
131
132 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata);
133     
134 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, gpointer userdata);
135
136 void avahi_update_host_rrs(AvahiInterfaceMonitor *m, gboolean remove_rrs);
137
138 gboolean avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
139
140 gboolean avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
141
142
143 #endif