]> git.meshlink.io Git - catta/blob - avahi-core/iface.h
from now on we enforce a strict whitespace regime
[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 typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
26 typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
27 typedef struct AvahiInterface AvahiInterface;
28 typedef struct AvahiHwInterface AvahiHwInterface;
29
30 #include <avahi-common/llist.h>
31 #include <avahi-common/address.h>
32
33 #include "internal.h"
34 #include "cache.h"
35 #include "response-sched.h"
36 #include "query-sched.h"
37 #include "probe-sched.h"
38 #include "dns.h"
39 #include "announce.h"
40 #include "browse.h"
41 #include "querier.h"
42
43 #ifdef HAVE_NETLINK
44 #include "iface-linux.h"
45 #elif defined(HAVE_PF_ROUTE)
46 #include "iface-pfroute.h"
47 #else
48 typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
49 struct AvahiInterfaceMonitorOSDep {
50
51     unsigned query_addr_seq, query_link_seq;
52
53     enum {
54         LIST_IFACE,
55         LIST_ADDR,
56         LIST_DONE
57     } list;
58 };
59 #endif
60
61 #define AVAHI_MAC_ADDRESS_MAX 32
62
63 struct AvahiInterfaceMonitor {
64     AvahiServer *server;
65     AvahiHashmap *hashmap;
66
67     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
68     AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
69
70     int list_complete;
71     AvahiInterfaceMonitorOSDep osdep;
72 };
73
74 struct AvahiHwInterface {
75     AvahiInterfaceMonitor *monitor;
76
77     AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
78
79     char *name;
80     AvahiIfIndex index;
81     int flags_ok;
82
83     unsigned mtu;
84
85     uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX];
86     size_t mac_address_size;
87
88     AvahiSEntryGroup *entry_group;
89
90     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
91 };
92
93 struct AvahiInterface {
94     AvahiInterfaceMonitor *monitor;
95     AvahiHwInterface *hardware;
96
97     AVAHI_LLIST_FIELDS(AvahiInterface, interface);
98     AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
99
100     AvahiProtocol protocol;
101     int announcing;
102     AvahiAddress local_mcast_address;
103     int mcast_joined;
104
105     AvahiCache *cache;
106
107     AvahiQueryScheduler *query_scheduler;
108     AvahiResponseScheduler * response_scheduler;
109     AvahiProbeScheduler *probe_scheduler;
110
111     AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
112     AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
113
114     AvahiHashmap *queriers_by_key;
115     AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
116 };
117
118 struct AvahiInterfaceAddress {
119     AvahiInterfaceMonitor *monitor;
120     AvahiInterface *interface;
121
122     AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
123
124     AvahiAddress address;
125     unsigned prefix_len;
126
127     int global_scope;
128
129     AvahiSEntryGroup *entry_group;
130 };
131
132 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
133 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
134
135 int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
136 void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
137 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
138
139 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
140 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
141 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
142
143 void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
144 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
145 void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
146
147 /* AvahiHwInterface */
148
149 AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
150 void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
151
152 void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
153 void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
154
155 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
156
157 /* AvahiInterface */
158
159 AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
160 void avahi_interface_free(AvahiInterface *i, int send_goodbye);
161
162 void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
163 void avahi_interface_check_relevant(AvahiInterface *i);
164 int avahi_interface_is_relevant(AvahiInterface *i);
165
166 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
167 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
168
169 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately, unsigned *ret_id);
170 int avahi_interface_withraw_query(AvahiInterface *i, unsigned id);
171 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
172 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
173
174 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
175 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
176 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
177
178 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
179
180 /* AvahiInterfaceAddress */
181
182 AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
183 void avahi_interface_address_free(AvahiInterfaceAddress *a);
184
185 void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
186 int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
187
188 AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);
189
190 AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a);
191
192 #endif