5 This file is part of avahi.
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.
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.
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
23 typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
24 typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
25 typedef struct AvahiInterface AvahiInterface;
26 typedef struct AvahiHwInterface AvahiHwInterface;
28 #include <avahi-common/llist.h>
29 #include <avahi-common/address.h>
33 #include "response-sched.h"
34 #include "query-sched.h"
35 #include "probe-sched.h"
42 #include "iface-linux.h"
43 #elif defined(HAVE_PF_ROUTE)
44 #include "iface-pfroute.h"
46 typedef struct AvahiInterfaceMonitorOSDep AvahiInterfaceMonitorOSDep;
47 struct AvahiInterfaceMonitorOSDep {
49 unsigned query_addr_seq, query_link_seq;
59 #define AVAHI_MAC_ADDRESS_MAX 32
61 struct AvahiInterfaceMonitor {
63 AvahiHashmap *hashmap;
65 AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
66 AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
69 AvahiInterfaceMonitorOSDep osdep;
72 struct AvahiHwInterface {
73 AvahiInterfaceMonitor *monitor;
75 AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
83 uint8_t mac_address[AVAHI_MAC_ADDRESS_MAX];
84 size_t mac_address_size;
86 AvahiSEntryGroup *entry_group;
88 AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
91 struct AvahiInterface {
92 AvahiInterfaceMonitor *monitor;
93 AvahiHwInterface *hardware;
95 AVAHI_LLIST_FIELDS(AvahiInterface, interface);
96 AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
98 AvahiProtocol protocol;
100 AvahiAddress local_mcast_address;
105 AvahiQueryScheduler *query_scheduler;
106 AvahiResponseScheduler * response_scheduler;
107 AvahiProbeScheduler *probe_scheduler;
109 AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
110 AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
112 AvahiHashmap *queriers_by_key;
113 AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
116 struct AvahiInterfaceAddress {
117 AvahiInterfaceMonitor *monitor;
118 AvahiInterface *interface;
120 AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
122 AvahiAddress address;
127 AvahiSEntryGroup *entry_group;
130 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
131 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
133 int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
134 void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
135 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
137 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
138 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
139 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
141 void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
142 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
143 void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
145 /* AvahiHwInterface */
147 AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
148 void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
150 void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
151 void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
153 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
157 AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
158 void avahi_interface_free(AvahiInterface *i, int send_goodbye);
160 void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
161 void avahi_interface_check_relevant(AvahiInterface *i);
162 int avahi_interface_is_relevant(AvahiInterface *i);
164 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
165 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
167 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately, unsigned *ret_id);
168 int avahi_interface_withraw_query(AvahiInterface *i, unsigned id);
169 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
170 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
172 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
173 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
174 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
176 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
178 /* AvahiInterfaceAddress */
180 AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
181 void avahi_interface_address_free(AvahiInterfaceAddress *a);
183 void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
184 int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
186 AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);
188 AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a);