checkpoint save
[oweals/gnunet.git] / src / dns / dnsparser.h
1 /*
2       This file is part of GNUnet
3       (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 2, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file dns/dnsparser.h
23  * @brief helper library to parse DNS packets. 
24  * @author Philipp Toelke
25  * @author Christian Grothoff
26  * @author Martin Schanzenbach
27  */
28 GNUNET_NETWORK_STRUCT_BEGIN
29
30 /* FIXME: replace this one with the one from tcpip_tun.h!? */
31 /**
32  * Head of a any DNS message.
33  */
34 struct GNUNET_TUN_DnsHeader
35 {
36   /**
37    * Request/response ID. (NBO)
38    */
39   uint16_t id GNUNET_PACKED;
40
41   /**
42    * Flags for the operation.
43    */
44   struct GNUNET_DNSPARSER_Flags flags; 
45
46   /**
47    * number of questions (NBO)
48    */
49   uint16_t query_count GNUNET_PACKED;
50
51   /**
52    * number of answers (NBO)
53    */
54   uint16_t answer_rcount GNUNET_PACKED;
55
56   /**
57    * number of authority-records (NBO)
58    */
59   uint16_t authority_rcount GNUNET_PACKED;
60
61   /**
62    * number of additional records (NBO)
63    */
64   uint16_t additional_rcount GNUNET_PACKED;
65 };
66
67
68 /**
69  * DNS query prefix.
70  */
71 struct query_line
72 {
73   /**
74    * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
75    */
76   uint16_t type GNUNET_PACKED;
77
78   /**
79    * Desired class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
80    */
81   uint16_t class GNUNET_PACKED;
82 };
83
84
85 /**
86  * General DNS record prefix.
87  */
88 struct record_line
89 {
90   /**
91    * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
92    */
93   uint16_t type GNUNET_PACKED;
94
95   /**
96    * Record class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
97    */
98   uint16_t class GNUNET_PACKED;
99
100   /**
101    * Expiration for the record (in seconds). (NBO)
102    */
103   uint32_t ttl GNUNET_PACKED;
104
105   /**
106    * Number of bytes of data that follow. (NBO)
107    */
108   uint16_t data_len GNUNET_PACKED;
109 };
110
111
112 /**
113  * Payload of DNS SOA record (header).
114  */
115 struct soa_data
116 {
117   /**
118    * The version number of the original copy of the zone.   (NBO)
119    */
120   uint32_t serial GNUNET_PACKED;
121   
122   /**
123    * Time interval before the zone should be refreshed. (NBO)
124    */
125   uint32_t refresh GNUNET_PACKED;
126   
127   /**
128    * Time interval that should elapse before a failed refresh should
129    * be retried. (NBO)
130    */
131   uint32_t retry GNUNET_PACKED;
132  
133   /**
134    * Time value that specifies the upper limit on the time interval
135    * that can elapse before the zone is no longer authoritative. (NBO)
136    */
137   uint32_t expire GNUNET_PACKED;
138
139   /**
140    * The bit minimum TTL field that should be exported with any RR
141    * from this zone. (NBO)
142    */
143   uint32_t minimum GNUNET_PACKED;
144 };
145
146
147 /**
148  * Payload of DNS SRV record (header).
149  */
150 struct srv_data
151 {
152
153   /**
154    * Preference for this entry (lower value is higher preference).  Clients
155    * will contact hosts from the lowest-priority group first and fall back
156    * to higher priorities if the low-priority entries are unavailable. (NBO)
157    */
158   uint16_t prio GNUNET_PACKED;
159
160   /**
161    * Relative weight for records with the same priority.  Clients will use
162    * the hosts of the same (lowest) priority with a probability proportional
163    * to the weight given. (NBO)
164    */
165   uint16_t weight GNUNET_PACKED;
166
167   /**
168    * TCP or UDP port of the service. (NBO)
169    */
170   uint16_t port GNUNET_PACKED;
171
172   /* followed by 'target' name */
173 };
174
175 /**
176  * Payload of GNS VPN record
177  */
178 struct vpn_data
179 {
180   /**
181    * The protocol to use
182    */
183   uint16_t proto;
184
185   /**
186    * The peer to contact
187    */
188   struct GNUNET_HashCode peer;
189
190   /* followed by the servicename */
191 };
192
193 GNUNET_NETWORK_STRUCT_END