]> git.meshlink.io Git - catta/blob - avahi-core/iface.h
* split off lookup.h and publish.h from core.h
[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 "netlink.h"
35 #include "cache.h"
36 #include "response-sched.h"
37 #include "query-sched.h"
38 #include "probe-sched.h"
39 #include "dns.h"
40 #include "announce.h"
41 #include "browse.h"
42 #include "querier.h"
43
44 #define AVAHI_MAX_MAC_ADDRESS 32
45
46 struct AvahiInterfaceMonitor {
47     AvahiServer *server;
48     AvahiNetlink *netlink;
49     AvahiHashmap *hashmap;
50
51     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
52     AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
53     
54     unsigned query_addr_seq, query_link_seq;
55     
56     enum {
57         LIST_IFACE,
58         LIST_ADDR,
59         LIST_DONE
60     } list;
61 };
62
63 struct AvahiHwInterface {
64     AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
65     AvahiInterfaceMonitor *monitor;
66
67     char *name;
68     AvahiIfIndex index;
69     unsigned flags;
70     unsigned mtu;
71
72     uint8_t mac_address[AVAHI_MAX_MAC_ADDRESS];
73     size_t mac_address_size;
74
75     AvahiSEntryGroup *entry_group;
76
77     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
78 };
79
80 struct AvahiInterface {
81     AVAHI_LLIST_FIELDS(AvahiInterface, interface);
82     AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
83     AvahiInterfaceMonitor *monitor;
84     
85     AvahiHwInterface *hardware;
86     AvahiProtocol protocol;
87     int announcing;
88
89     AvahiCache *cache;
90
91     AvahiQueryScheduler *query_scheduler;
92     AvahiResponseScheduler * response_scheduler;
93     AvahiProbeScheduler *probe_scheduler;
94
95     AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
96     AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
97
98     AvahiHashmap *queriers_by_key;
99     AVAHI_LLIST_HEAD(AvahiQuerier, queriers);
100 };
101
102 struct AvahiInterfaceAddress {
103     AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
104     AvahiInterfaceMonitor *monitor;
105     
106     unsigned char flags;
107     unsigned char scope;
108     unsigned char prefix_len;
109     AvahiAddress address;
110     
111     AvahiSEntryGroup *entry_group;
112     AvahiInterface *interface;
113 };
114
115 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
116 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
117
118 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
119
120 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol);
121 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, int idx);
122
123 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
124 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port);
125
126 int avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, int immediately);
127 int avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately);
128 int avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, int immediately);
129
130 int avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, void* userdata);
131
132 int avahi_interface_relevant(AvahiInterface *i);
133 int avahi_interface_address_relevant(AvahiInterfaceAddress *a);
134
135 int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol);
136
137 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata);
138     
139 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, void* userdata);
140
141 void avahi_update_host_rrs(AvahiInterfaceMonitor *m, int remove_rrs);
142
143 int avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a);
144
145 int avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress *a);
146
147 int avahi_interface_has_address(AvahiInterfaceMonitor *m, AvahiIfIndex iface, const AvahiAddress *a);
148
149 #endif