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