summaryrefslogtreecommitdiffstats
path: root/libavahi-core/iface.h
blob: cab4949f166e1d9de1b76961103549e25a5c6ae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef fooifacehfoo
#define fooifacehfoo

#include <glib.h>

typedef struct _AvahiInterfaceMonitor AvahiInterfaceMonitor;
typedef struct _AvahiInterfaceAddress AvahiInterfaceAddress;
typedef struct _AvahiInterface AvahiInterface;
typedef struct _AvahiHwInterface AvahiHwInterface;

#include "address.h"
#include "server.h"
#include "netlink.h"
#include "cache.h"
#include "llist.h"
#include "psched.h"
#include "dns.h"
#include "announce.h"

struct _AvahiInterfaceMonitor {
    AvahiServer *server;
    AvahiNetlink *netlink;
    GHashTable *hash_table;

    AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
    AVAHI_LLIST_HEAD(AvahiHwInterface, hw_interfaces);
    
    guint query_addr_seq, query_link_seq;
    
    enum {
        LIST_IFACE,
        LIST_ADDR,
        LIST_DONE
    } list;
};

struct _AvahiHwInterface {
    AVAHI_LLIST_FIELDS(AvahiHwInterface, hardware);
    AvahiInterfaceMonitor *monitor;

    gchar *name;
    gint index;
    guint flags;
    guint mtu;

    AVAHI_LLIST_HEAD(AvahiInterface, interfaces);
};

struct _AvahiInterface {
    AVAHI_LLIST_FIELDS(AvahiInterface, interface);
    AVAHI_LLIST_FIELDS(AvahiInterface, by_hardware);
    AvahiInterfaceMonitor *monitor;
    
    AvahiHwInterface *hardware;
    guchar protocol;
    gboolean announcing;

    AvahiCache *cache;
    AvahiPacketScheduler *scheduler;

    AVAHI_LLIST_HEAD(AvahiInterfaceAddress, addresses);
    AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
};

struct _AvahiInterfaceAddress {
    AVAHI_LLIST_FIELDS(AvahiInterfaceAddress, address);
    AvahiInterfaceMonitor *monitor;
    
    guchar flags;
    guchar scope;
    AvahiAddress address;
    
    AvahiEntryGroup *entry_group;
    AvahiInterface *interface;
};

AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *server);
void avahi_interface_monitor_free(AvahiInterfaceMonitor *m);

void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m);

AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, gint index, guchar protocol);
AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, gint index);

void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p);

void avahi_interface_post_query(AvahiInterface *i, AvahiKey *k, gboolean immediately);
void avahi_interface_post_probe(AvahiInterface *i, AvahiRecord *p, gboolean immediately);
void avahi_interface_post_response(AvahiInterface *i, const AvahiAddress *a, AvahiRecord *record, gboolean flush_cache, gboolean immediately);

void avahi_dump_caches(AvahiInterfaceMonitor *m, FILE *f);

gboolean avahi_interface_relevant(AvahiInterface *i);
gboolean avahi_interface_address_relevant(AvahiInterfaceAddress *a);

gboolean avahi_interface_match(AvahiInterface *i, gint index, guchar protocol);

typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata);
    
void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, gint index, guchar protocol, AvahiInterfaceMonitorWalkCallback callback, gpointer userdata);

#endif