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