• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/avahi-0.6.31/avahi-core/
1#ifndef foollmnrlookuphbar
2#define foollmnrlookuphbar
3
4#include <avahi-common/llist.h>
5#include <avahi-common/address.h>
6
7#include "hashmap.h"
8#include "lookup.h"
9#include "rr.h"
10
11#include "llmnr-querier.h"
12
13#define LLMNR_CACHE_ENTRIES_MAX 500
14
15typedef struct AvahiLLMNRLookup AvahiLLMNRLookup;
16typedef struct AvahiLLMNRLookupEngine AvahiLLMNRLookupEngine;
17typedef struct AvahiLLMNRCacheEntry AvahiLLMNRCacheEntry;
18
19/* AvahiLLMNRLookup callback prototype */
20typedef void (*AvahiLLMNRLookupCallback)(
21    AvahiLLMNRLookupEngine *e,
22    AvahiIfIndex idx,
23    AvahiProtocol protocol,
24    AvahiBrowserEvent event,
25    AvahiLookupResultFlags flags,
26    AvahiRecord *r,
27    void *userdata);
28
29/* LLMNR Cache entry */
30struct AvahiLLMNRCacheEntry {
31    AvahiLLMNRLookupEngine *engine;
32
33    /* interface and protocol can't be
34    AVAHI_IF_UNSPEC and AVAHI_PROTO_UNSPEC resp.*/
35    AvahiIfIndex interface;
36    AvahiProtocol protocol;
37
38    AvahiRecord *record;
39
40    struct timeval timestamp;
41    struct timeval expiry;
42
43    AvahiTimeEvent *time_event;
44
45    AVAHI_LLIST_FIELDS(AvahiLLMNRCacheEntry, by_key);
46    AVAHI_LLIST_FIELDS(AvahiLLMNRCacheEntry, cache);
47};
48
49/* LLMNR Lookup object */
50struct AvahiLLMNRLookup {
51    AvahiLLMNRLookupEngine *engine;
52    int dead;
53
54    AvahiKey *key, *cname_key;
55    AvahiTimeEvent *time_event;
56
57    AvahiIfIndex interface;
58    AvahiProtocol protocol;
59
60    AvahiLLMNRLookupCallback callback;
61    void *userdata;
62
63    AVAHI_LLIST_FIELDS(AvahiLLMNRLookup, lookups);
64    AVAHI_LLIST_FIELDS(AvahiLLMNRLookup, by_key);
65
66    int queries_issued;
67
68    AVAHI_LLIST_HEAD(AvahiLLMNRQuery, queries);
69};
70
71
72/* LLMNR lookup engine */
73struct AvahiLLMNRLookupEngine {
74    AvahiServer *s;
75
76    /* For 'AvahiLLMNRQuery' object*/
77    uint16_t next_id;
78
79    /*lookups and queries */
80    AVAHI_LLIST_HEAD(AvahiLLMNRLookup, lookups);
81    AvahiHashmap *lookups_by_key;
82    AvahiHashmap *queries_by_id;
83
84    /* Cache */
85    AVAHI_LLIST_HEAD(AvahiLLMNRCacheEntry, cache);
86    AvahiHashmap *cache_by_key;
87    unsigned n_cache_entries;
88
89    int cleanup_dead;
90};
91
92/*** Engine functions ***/
93
94AvahiLLMNRLookupEngine* avahi_llmnr_lookup_engine_new(AvahiServer *sl);
95void avahi_llmnr_lookup_engine_free(AvahiLLMNRLookupEngine *e);
96void avahi_llmnr_lookup_engine_cleanup(AvahiLLMNRLookupEngine *e);
97
98/* when new interface come up, call this function to issue queries */
99void avahi_llmnr_lookup_engine_new_interface(AvahiLLMNRLookupEngine *e, AvahiInterface *i);
100
101/* remove all cache entries from this interface */
102void avahi_llmnr_clear_cache(AvahiLLMNRLookupEngine *e, AvahiInterface *i);
103
104/*** AvahiLLMNRLookup functions ***/
105
106AvahiLLMNRLookup* avahi_llmnr_lookup_new(
107    AvahiLLMNRLookupEngine *e,
108    AvahiIfIndex interface,
109    AvahiProtocol protocol,
110    AvahiKey *key,
111    AvahiLLMNRLookupCallback callback,
112    void *userdata);
113
114void avahi_llmnr_lookup_free(AvahiLLMNRLookup *l);
115
116/*** Cache functions ***/
117void avahi_llmnr_cache_dump(AvahiLLMNRLookupEngine *e, AvahiDumpCallback callback, void *userdata);
118
119unsigned avahi_scan_llmnr_cache(
120    AvahiLLMNRLookupEngine *e,
121    AvahiIfIndex idx,
122    AvahiProtocol protocol,
123    AvahiKey *key,
124    AvahiLLMNRLookupCallback callback,
125    void *userdata
126);
127#endif /* foollmnrlookuphbar */
128