]> git.meshlink.io Git - catta/blob - avahi-common/rr.h
* update default TTL generation to match RFC
[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 /** The default TTL for RRs which contain a host name of some kind. */
52 #define AVAHI_DEFAULT_TTL_HOST_NAME (120)
53
54 /** The default TTL for all other records. */
55 #define AVAHI_DEFAULT_TTL (75*60)
56
57 typedef struct {
58     guint ref;
59     gchar *name;
60     guint16 class;
61     guint16 type;
62 } AvahiKey;
63
64 typedef struct  {
65     guint ref;
66     AvahiKey *key;
67     
68     guint32 ttl;
69
70     union {
71         struct {
72             gpointer data;
73             guint16 size;
74         } generic;
75
76         struct {
77             guint16 priority;
78             guint16 weight;
79             guint16 port;
80             gchar *name;
81         } srv;
82
83         struct {
84             gchar *name;
85         } ptr; /* and cname */
86
87         struct {
88             gchar *cpu;
89             gchar *os;
90         } hinfo;
91
92         struct {
93             AvahiStringList *string_list;
94         } txt;
95
96         struct {
97             AvahiIPv4Address address;
98         } a;
99
100         struct {
101             AvahiIPv6Address address;
102         } aaaa;
103
104     } data;
105     
106 } AvahiRecord;
107
108 AvahiKey *avahi_key_new(const gchar *name, guint16 class, guint16 type);
109 AvahiKey *avahi_key_ref(AvahiKey *k);
110 void avahi_key_unref(AvahiKey *k);
111
112 gboolean avahi_key_equal(const AvahiKey *a, const AvahiKey *b);  /* Treat AVAHI_DNS_CLASS_ANY like any other type */
113 gboolean avahi_key_pattern_match(const AvahiKey *pattern, const AvahiKey *k); /* If pattern.type is AVAHI_DNS_CLASS_ANY, k.type is ignored */
114
115 gboolean avahi_key_is_pattern(const AvahiKey *k);
116
117 guint avahi_key_hash(const AvahiKey *k);
118
119 AvahiRecord *avahi_record_new(AvahiKey *k, guint32 ttl);
120 AvahiRecord *avahi_record_new_full(const gchar *name, guint16 class, guint16 type, guint32 ttl);
121 AvahiRecord *avahi_record_ref(AvahiRecord *r);
122 void avahi_record_unref(AvahiRecord *r);
123
124 const gchar *avahi_dns_class_to_string(guint16 class);
125 const gchar *avahi_dns_type_to_string(guint16 type);
126
127 gchar *avahi_key_to_string(const AvahiKey *k); /* g_free() the result! */
128 gchar *avahi_record_to_string(const AvahiRecord *r);  /* g_free() the result! */
129
130 gboolean avahi_record_equal_no_ttl(const AvahiRecord *a, const AvahiRecord *b);
131
132 AvahiRecord *avahi_record_copy(AvahiRecord *r);
133
134 /* returns a maximum estimate for the space that is needed to store
135  * this key in a DNS packet */
136 guint avahi_key_get_estimate_size(AvahiKey *k);
137
138 /* ditto */
139 guint avahi_record_get_estimate_size(AvahiRecord *r);
140
141 gint avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b);
142
143 gboolean avahi_record_is_goodbye(AvahiRecord *r);
144
145 #endif