]> git.meshlink.io Git - catta/blob - avahi-core/iface.h
iface: check for IFA_F_DEPRECATED
[catta] / avahi-core / iface.h
1 #ifndef fooifacehfoo
2 #define fooifacehfoo
3
4 /***
5   This file is part of avahi.
6
7   avahi is free software; you can redistribute it and/or modify it
8   under the terms of the GNU Lesser General Public License as
9   published by the Free Software Foundation; either version 2.1 of the
10   License, or (at your option) any later version.
11
12   avahi is distributed in the hope that it will be useful, but WITHOUT
13   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15   Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public
18   License along with avahi; if not, write to the Free Software
19   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20   USA.
21 ***/
22
23 typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
24 typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
25 typedef struct AvahiInterface AvahiInterface;
26 typedef struct AvahiHwInterface AvahiHwInterface;
27
28 #include <avahi-common/llist.h>
29 #include <avahi-common/address.h>
30
31 #include "internal.h"
32 #include "cache.h"
33 #include "response-sched.h"
34 #include "query-sched.h"
35 #include "probe-sched.h"
36 #include "dns.h"
37 #include "announce.h"
38 #include "browse.h"
39 #include "querier.h"
40
41 #ifdef HAVE_NETLINK
42 #include "iface-linux.h"
43 #elif defined(HAVE_PF_ROUTE)
44 #include "iface-pfroute.h"
45 #else
46 typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
47 struct AvahiInterfaceMonitorOSDep {
48
49     unsigned query_addr_seq, query_link_seq;
50
51     enum {
52         LIST_IFACE,
53         LIST_ADDR,
54         LIST_DONE
55     } list;
56 };
57 #endif
58
59 #define AVAHI_MAC_ADDRESS_MAX 32
60
61 struct AvahiInterfaceMonitor {
62     AvahiServer *server;
63     AvahiHashmap *hashmap;
64
65     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
66     AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
67
68     int list_complete;
69     AvahiInterfaceMonitorOSDep osdep;
70 };
71
72 struct AvahiHwInterface {
73     AvahiInterfaceMonitor *monitor;
74
75     AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
76
77     char *name;
78     AvahiIfIndex index;
79     int flags_ok;
80
81     unsigned mtu;
82
83     uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX];
84     size_t mac_address_size;
85
86     AvahiSEntryGroup *entry_group;
87
88     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
89 };
90
91 struct AvahiInterface {
92     AvahiInterfaceMonitor *monitor;
93     AvahiHwInterface *hardware;
94
95     AVAHI_LLIST_FIELDS(AvahiInterface, interface);
96     AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
97
98     AvahiProtocol protocol;
99     int announcing;
100     AvahiAddress local_mcast_address;
101     int mcast_joined;
102
103     AvahiCache *cache;
104
105     AvahiQueryScheduler *query_scheduler;
106     AvahiResponseScheduler * response_scheduler;
107     AvahiProbeScheduler *probe_scheduler;
108
109     AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
110     AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
111
112     AvahiHashmap *queriers_by_key;
113     AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
114 };
115
116 struct AvahiInterfaceAddress {
117     AvahiInterfaceMonitor *monitor;
118     AvahiInterface *interface;
119
120     AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
121
122     AvahiAddress address;
123     unsigned prefix_len;
124
125     int global_scope;
126     int deprecated;
127
128     AvahiSEntryGroup *entry_group;
129 };
130
131 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
132 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
133
134 int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
135 void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
136 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
137
138 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
139 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
140 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
141
142 void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
143 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
144 void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
145
146 /* AvahiHwInterface */
147
148 AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
149 void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
150
151 void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
152 void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
153
154 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
155
156 /* AvahiInterface */
157
158 AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
159 void avahi_interface_free(AvahiInterface *i, int send_goodbye);
160
161 void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
162 void avahi_interface_check_relevant(AvahiInterface *i);
163 int avahi_interface_is_relevant(AvahiInterface *i);
164
165 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
166 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
167
168 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately, unsigned *ret_id);
169 int avahi_interface_withraw_query(AvahiInterface *i, unsigned id);
170 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
171 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
172
173 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
174 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
175 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
176
177 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
178
179 /* AvahiInterfaceAddress */
180
181 AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
182 void avahi_interface_address_free(AvahiInterfaceAddress *a);
183
184 void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
185 int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
186
187 AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);
188
189 AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a);
190
191 #endif