]> git.meshlink.io Git - catta/blob - avahi-common/rr.h
da0b2859997e27ef2dd922e145492730c811dd85
[catta] / avahi-common / rr.h
1 #ifndef foorrhfoo
2 #define foorrhfoo
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 #include <avahi-common/strlst.h>
28 #include <avahi-common/address.h>
29
30 enum {
31     AVAHI_DNS_TYPE_A = 0x01,
32     AVAHI_DNS_TYPE_NS = 0x02,
33     AVAHI_DNS_TYPE_CNAME = 0x05,
34     AVAHI_DNS_TYPE_SOA = 0x06,
35     AVAHI_DNS_TYPE_PTR = 0x0C,
36     AVAHI_DNS_TYPE_HINFO = 0x0D,
37     AVAHI_DNS_TYPE_MX = 0x0F,
38     AVAHI_DNS_TYPE_TXT = 0x10,
39     AVAHI_DNS_TYPE_AAAA = 0x1C,
40     AVAHI_DNS_TYPE_SRV = 0x21,
41     AVAHI_DNS_TYPE_ANY = 0xFF
42 };
43
44 enum {
45     AVAHI_DNS_CLASS_IN = 0x01,
46     AVAHI_DNS_CLASS_ANY = 0xFF,
47     AVAHI_DNS_CACHE_FLUSH = 0x8000,
48     AVAHI_DNS_UNICAST_RESPONSE = 0x8000
49 };
50
51 #define AVAHI_DEFAULT_TTL (120*60)
52
53 typedef struct {
54     guint ref;
55     gchar *name;
56     guint16 class;
57     guint16 type;
58 } AvahiKey;
59
60 typedef struct  {
61     guint ref;
62     AvahiKey *key;
63     
64     guint32 ttl;
65
66     union {
67         struct {
68             gpointer data;
69             guint16 size;
70         } generic;
71
72         struct {
73             guint16 priority;
74             guint16 weight;
75             guint16 port;
76             gchar *name;
77         } srv;
78
79         struct {
80             gchar *name;
81         } ptr; /* and cname */
82
83         struct {
84             gchar *cpu;
85             gchar *os;
86         } hinfo;
87
88         struct {
89             AvahiStringList *string_list;
90         } txt;
91
92         struct {
93             AvahiIPv4Address address;
94         } a;
95
96         struct {
97             AvahiIPv6Address address;
98         } aaaa;
99
100     } data;
101     
102 } AvahiRecord;
103
104 AvahiKey *avahi_key_new(const gchar *name, guint16 class, guint16 type);
105 AvahiKey *avahi_key_ref(AvahiKey *k);
106 void avahi_key_unref(AvahiKey *k);
107
108 gboolean avahi_key_equal(const AvahiKey *a, const AvahiKey *b);  /* Treat AVAHI_DNS_CLASS_ANY like any other type */
109 gboolean avahi_key_pattern_match(const AvahiKey *pattern, const AvahiKey *k); /* If pattern.type is AVAHI_DNS_CLASS_ANY, k.type is ignored */
110
111 gboolean avahi_key_is_pattern(const AvahiKey *k);
112
113 guint avahi_key_hash(const AvahiKey *k);
114
115 AvahiRecord *avahi_record_new(AvahiKey *k);
116 AvahiRecord *avahi_record_new_full(const gchar *name, guint16 class, guint16 type);
117 AvahiRecord *avahi_record_ref(AvahiRecord *r);
118 void avahi_record_unref(AvahiRecord *r);
119
120 const gchar *avahi_dns_class_to_string(guint16 class);
121 const gchar *avahi_dns_type_to_string(guint16 type);
122
123 gchar *avahi_key_to_string(const AvahiKey *k); /* g_free() the result! */
124 gchar *avahi_record_to_string(const AvahiRecord *r);  /* g_free() the result! */
125
126 gboolean avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b);
127
128 AvahiRecord *avahi_record_copy(AvahiRecord *r);
129
130 /* returns a maximum estimate for the space that is needed to store
131  * this key in a DNS packet */
132 guint avahi_key_get_estimate_size(AvahiKey *k);
133
134 /* ditto */
135 guint avahi_record_get_estimate_size(AvahiRecord *r);
136
137 gint avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b);
138
139 gboolean avahi_record_is_goodbye(AvahiRecord *r);
140
141 #endif