]> git.meshlink.io Git - catta/blob - avahi-core/iface.h
Add support for server state change callbacks
[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 #include <glib.h>
26
27 typedef struct AvahiInterfaceMonitor AvahiInterfaceMonitor;
28 typedef struct AvahiInterfaceAddress AvahiInterfaceAddress;
29 typedef struct AvahiInterface AvahiInterface;
30 typedef struct AvahiHwInterface AvahiHwInterface;
31
32 #include "address.h"
33 #include "server.h"
34 #include "netlink.h"
35 #include "cache.h"
36 #include "llist.h"
37 #include "response-sched.h"
38 #include "query-sched.h"
39 #include "probe-sched.h"
40 #include "dns.h"
41 #include "announce.h"
42
43 struct AvahiInterfaceMonitor {
44     AvahiServer *server;
45     AvahiNetlink *netlink;
46     GHashTable *hash_table;
47
48     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
49     AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
50     
51     guint query_addr_seq, query_link_seq;
52     
53     enum {
54         LIST_IFACE,
55         LIST_ADDR,
56         LIST_DONE
57     } list;
58 };
59
60 struct AvahiHwInterface {
61     AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
62     AvahiInterfaceMonitor *monitor;
63
64     gchar *name;
65     gint index;
66     guint flags;
67     guint mtu;
68
69     AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
70 };
71
72 struct AvahiInterface {
73     AVAHI_LLIST_FIELDS(AvahiInterface, interface);
74     AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
75     AvahiInterfaceMonitor *monitor;
76     
77     AvahiHwInterface *hardware;
78     guchar protocol;
79     gboolean announcing;
80
81     AvahiCache *cache;
82     AvahiQueryScheduler *query_scheduler;
83     AvahiResponseScheduler * response_scheduler;
84     AvahiProbeScheduler *probe_scheduler;
85
86     AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
87     AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
88 };
89
90 struct AvahiInterfaceAddress {
91     AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
92     AvahiInterfaceMonitor *monitor;
93     
94     guchar flags;
95     guchar scope;
96     AvahiAddress address;
97     
98     AvahiEntryGroup *entry_group;
99     AvahiInterface *interface;
100 };
101
102 AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
103 void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);
104
105 void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);
106
107 AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, gint index, guchar protocol);
108 AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, gint index);
109
110 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);
111 void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, guint16 port);
112
113 gboolean avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, gboolean immediately);
114 gboolean avahi_interface_post_response(AvahiInterface *i, AvahiRecord *record, gboolean flush_cache, const AvahiAddress *querier, gboolean immediately);
115 gboolean avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, gboolean immediately);
116
117 void avahi_dump_caches(AvahiInterfaceMonitor *m, FILE *f);
118
119 gboolean avahi_interface_relevant(AvahiInterface *i);
120 gboolean avahi_interface_address_relevant(AvahiInterfaceAddress *a);
121
122 gboolean avahi_interface_match(AvahiInterface *i, gint index, guchar protocol);
123
124 typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata);
125     
126 void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, gint index, guchar protocol, AvahiInterfaceMonitorWalkCallback callback, gpointer userdata);
127
128 void avahi_update_host_rrs(AvahiInterfaceMonitor *m, gboolean remove);
129
130 #endif