source: mainline/uspace/srv/net/dnsrsrv/dns_std.h@ 19a4f73

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 19a4f73 was 31e9fe0, checked in by Jiri Svoboda <jiri@…>, 12 years ago

Dnsrsrv server and dnsres utility.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2012 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup dnsres
30 * @{
31 */
32/**
33 * @file DNS Standard definitions.
34 *
35 * From RFC 1035 Domain Names - Implementation and Specification
36 */
37
38#ifndef DNS_STD_H
39#define DNS_STD_H
40
41#include <stdint.h>
42
43/** From 2.3.4. Size Limits */
44enum dns_limits {
45 DNS_LABEL_MAX_SIZE = 63,
46 DNS_NAME_MAX_SIZE = 255,
47 DNS_UDP_MSG_MAX_SIZE = 512
48};
49
50typedef enum dns_qtype {
51 DTYPE_A = 1,
52 DTYPE_NS = 2,
53 DTYPE_MD = 3,
54 DTYPE_MF = 4,
55 DTYPE_CNAME = 5,
56 DTYPE_SOA = 6,
57 DTYPE_MB = 7,
58 DTYPE_MG = 8,
59 DTYPE_MR = 9,
60 DTYPE_NULL = 10,
61 DTYPE_WKS = 11,
62 DTYPE_PTR = 12,
63 DTYPE_HINFO = 13,
64 DTYPE_MINFO = 14,
65 DTYPE_MX = 15,
66 DTYPE_TXT = 16,
67 DQTYPE_AXFR = 252,
68 DQTYPE_MAILB = 253,
69 DQTYPE_MAILA = 254,
70 DQTYPE_ALL = 255
71} dns_type_t, dns_qtype_t;
72
73typedef enum dns_qclass {
74 /** Internet */
75 DC_IN = 1,
76 /** CSNET */
77 DC_CS = 2,
78 /** CHAOS */
79 DC_CH = 3,
80 /** Hesiod */
81 DC_HS = 4,
82 /** Any class */
83 DQC_ANY = 255
84} dns_class_t, dns_qclass_t;
85
86typedef struct {
87 /** Identifier assigned by the query originator */
88 uint16_t id;
89 /** QR, Opcode, AA, TC,RD, RA, Z, Rcode */
90 uint16_t opbits;
91 /** Number of entries in query section */
92 uint16_t qd_count;
93 /** Number of RRs in the answer section */
94 uint16_t an_count;
95 /** Number of name server RRs in the authority records section */
96 uint16_t ns_count;
97 /** Number of RRs in the additional records section */
98 uint16_t ar_count;
99} dns_header_t;
100
101/** Bits in dns_header_t.opbits.
102 *
103 * Note that bit numbers in RFC 1035 are reversed (0 is the most significant)
104 * but we use the standard notation (0 is the least significant).
105 */
106enum dns_opbits {
107 OPB_QR = 15,
108 OPB_OPCODE_h = 14,
109 OPB_OPCODE_l = 11,
110 OPB_AA = 10,
111 OPB_TC = 9,
112 OPB_RD = 8,
113 OPB_RA = 7,
114 OPB_Z_h = 6,
115 OPB_Z_l = 4,
116 OPB_RCODE_h = 3,
117 OPB_RCODE_l = 0
118};
119
120typedef enum dns_query_response {
121 QR_QUERY = 0,
122 QR_RESPONSE = 1
123} dns_query_response_t;
124
125typedef enum dns_opcode {
126 OPC_QUERY = 0,
127 OPC_IQUERY = 1,
128 OPC_STATUS = 2
129} dns_opcode_t;
130
131typedef enum dns_rcode {
132 RC_OK = 0,
133 RC_FMT_ERR = 1,
134 RC_SRV_FAIL = 2,
135 RC_NAME_ERR = 3,
136 RC_NOT_IMPL = 4,
137 RC_REFUSED = 5
138} dns_rcode_t;
139
140#endif
141
142/** @}
143 */
Note: See TracBrowser for help on using the repository browser.