]> git.meshlink.io Git - catta/blob - avahi-core/iface.h
warn if not netlink replacement is found when building
[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 "server.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 #else
46 #error "No network configuration notification system available"
47 #endif
48
49 #define AVAHI_MAX_MAC_ADDRESS 32
50
51 struct AvahiInterfaceMonitor {
52     AvahiServer *server;
53     AvahiHashmap *hashmap;
54
55     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
56     AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
57
58     int list_complete;
59     AvahiInterfaceMonitorOSDep osdep;
60 };
61
62 struct AvahiHwInterface {
63     AvahiInterfaceMonitor *monitor;
64
65     AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
66
67     char *name;
68     AvahiIfIndex index;
69     int flags_ok;
70     
71     unsigned mtu;
72
73     uint8_t mac_address[AVAHI_MAX_MAC_ADDRESS];
74     size_t mac_address_size;
75
76     AvahiSEntryGroup *entry_group;
77
78     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
79 };
80
81 struct AvahiInterface {
82     AvahiInterfaceMonitor *monitor;
83     AvahiHwInterface *hardware;
84
85     AVAHI_LLIST_FIELDS(AvahiInterface, interface);
86     AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
87     
88     AvahiProtocol protocol;
89     int announcing;
90
91     AvahiCache *cache;
92
93     AvahiQueryScheduler *query_scheduler;
94     AvahiResponseScheduler * response_scheduler;
95     AvahiProbeScheduler *probe_scheduler;
96
97     AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
98     AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
99
100     AvahiHashmap *queriers_by_key;
101     AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
102 };
103
104 struct AvahiInterfaceAddress {
105     AvahiInterfaceMonitor *monitor;
106     AvahiInterface *interface;
107
108     AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
109
110     AvahiAddress address;
111     unsigned prefix_len;
112
113     int global_scope;
114     
115     AvahiSEntryGroup *entry_group;
116 };
117
118 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
119 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
120
121 int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m);
122 void avahi_interface_monitor_free_osdep(AvahiInterfaceMonitor *m);
123 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
124
125 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
126 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
127 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
128
129 void avahi_interface_monitor_update_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
130 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
131 void avahi_interface_monitor_check_relevant(AvahiInterfaceMonitor *m);
132
133 /* AvahiHwInterface */
134
135 AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex idx);
136 void avahi_hw_interface_free(AvahiHwInterface *hw, int send_goodbye);
137
138 void avahi_hw_interface_update_rrs(AvahiHwInterface *hw, int remove_rrs);
139 void avahi_hw_interface_check_relevant(AvahiHwInterface *hw);
140
141 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
142
143 /* AvahiInterface */
144
145 AvahiInterface* avahi_interface_new(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, AvahiProtocol protocol);
146 void avahi_interface_free(AvahiInterface *i, int send_goodbye);
147
148 void avahi_interface_update_rrs(AvahiInterface *i, int remove_rrs);
149 void avahi_interface_check_relevant(AvahiInterface *i);
150 int avahi_interface_is_relevant(AvahiInterface *i);
151
152 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
153 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
154
155 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately);
156 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
157 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
158
159 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
160 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
161 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
162
163 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
164
165 /* AvahiInterfaceAddress */
166
167 AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *addr, unsigned prefix_len);
168 void avahi_interface_address_free(AvahiInterfaceAddress *a);
169
170 void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs);
171 int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a);
172
173 AvahiInterfaceAddress* avahi_interface_monitor_get_address(AvahiInterfaceMonitor *m, AvahiInterface *i, const AvahiAddress *raddr);
174
175 #endif