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 /* Packet rate limiting */
89 struct timeval ratelimit_begin;
90 unsigned ratelimit_counter;
92 AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
95 struct AvahiInterface {
96 AvahiInterfaceMonitor *monitor;
97 AvahiHwInterface *hardware;
99 AVAHI_LLIST_FIELDS(AvahiInterface, interface);
100 AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
102 AvahiProtocol protocol;
104 AvahiAddress local_mcast_address;
109 AvahiQueryScheduler *query_scheduler;
110 AvahiResponseScheduler * response_scheduler;
111 AvahiProbeScheduler *probe_scheduler;
113 AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
114 AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
116 AvahiHashmap *queriers_by_key;
117 AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
120 struct AvahiInterfaceAddress {
121 AvahiInterfaceMonitor *monitor;
122 AvahiInterface *interface;
124 AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
126 AvahiAddress address;
132 AvahiSEntryGroup *entry_group;
135 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
136 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
138 int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
139 void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
140 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
142 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
143 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
144 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
146 void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
147 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
148 void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
150 /* AvahiHwInterface */
152 AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
153 void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
155 void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
156 void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
158 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
162 AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
163 void avahi_interface_free(AvahiInterface *i, int send_goodbye);
165 void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
166 void avahi_interface_check_relevant(AvahiInterface *i);
167 int avahi_interface_is_relevant(AvahiInterface *i);
169 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
170 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
172 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately, unsigned *ret_id);
173 int avahi_interface_withraw_query(AvahiInterface *i, unsigned id);
174 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
175 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
177 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
178 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
179 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
181 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
183 /* AvahiInterfaceAddress */
185 AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
186 void avahi_interface_address_free(AvahiInterfaceAddress *a);
188 void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
189 int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
191 AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);
193 AvahiIfIndex avahi_find_interface_for_address(AvahiInterfaceMonitor *m, const AvahiAddress *a);