7 This file is part of avahi.
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.
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.
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
25 typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
26 typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
27 typedef struct AvahiInterface AvahiInterface;
28 typedef struct AvahiHwInterface AvahiHwInterface;
30 #include <avahi-common/llist.h>
31 #include <avahi-common/address.h>
35 #include "response-sched.h"
36 #include "query-sched.h"
37 #include "probe-sched.h"
44 #include "iface-linux.h"
47 #define AVAHI_MAX_MAC_ADDRESS 32
49 struct AvahiInterfaceMonitor {
51 AvahiHashmap *hashmap;
53 AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
54 AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
57 AvahiInterfaceMonitorOSDep osdep;
60 struct AvahiHwInterface {
61 AvahiInterfaceMonitor *monitor;
63 AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
71 uint8_t mac_address[AVAHI_MAX_MAC_ADDRESS];
72 size_t mac_address_size;
74 AvahiSEntryGroup *entry_group;
76 AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
79 struct AvahiInterface {
80 AvahiInterfaceMonitor *monitor;
81 AvahiHwInterface *hardware;
83 AVAHI_LLIST_FIELDS(AvahiInterface, interface);
84 AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
86 AvahiProtocol protocol;
91 AvahiQueryScheduler *query_scheduler;
92 AvahiResponseScheduler * response_scheduler;
93 AvahiProbeScheduler *probe_scheduler;
95 AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
96 AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
98 AvahiHashmap *queriers_by_key;
99 AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
102 struct AvahiInterfaceAddress {
103 AvahiInterfaceMonitor *monitor;
104 AvahiInterface *interface;
106 AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
108 AvahiAddress address;
113 AvahiSEntryGroup *entry_group;
116 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
117 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
119 int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
120 void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
121 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
123 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
124 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
125 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
127 void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
128 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
129 void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
131 /* AvahiHwInterface */
133 AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
134 void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
136 void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
137 void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
139 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
143 AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
144 void avahi_interface_free(AvahiInterface *i, int send_goodbye);
146 void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
147 void avahi_interface_check_relevant(AvahiInterface *i);
148 int avahi_interface_is_relevant(AvahiInterface *i);
150 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
151 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
153 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately);
154 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
155 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
157 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
158 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
159 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
161 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
163 /* AvahiInterfaceAddress */
165 AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
166 void avahi_interface_address_free(AvahiInterfaceAddress *a);
168 void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
169 int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
171 AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);