source: mainline/uspace/srv/net/dnsrsrv/dns_std.h

Last change on this file was a63966d, checked in by Jakub Jermar <jakub@…>, 7 years ago

Provide doc/doxygroups.h for most apps

  • 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 dnsrsrv
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 DTYPE_AAAA = 28,
68 DQTYPE_AXFR = 252,
69 DQTYPE_MAILB = 253,
70 DQTYPE_MAILA = 254,
71 DQTYPE_ALL = 255
72} dns_type_t, dns_qtype_t;
73
74typedef enum dns_qclass {
75 /** Internet */
76 DC_IN = 1,
77 /** CSNET */
78 DC_CS = 2,
79 /** CHAOS */
80 DC_CH = 3,
81 /** Hesiod */
82 DC_HS = 4,
83 /** Any class */
84 DQC_ANY = 255
85} dns_class_t, dns_qclass_t;
86
87typedef struct {
88 /** Identifier assigned by the query originator */
89 uint16_t id;
90 /** QR, Opcode, AA, TC,RD, RA, Z, Rcode */
91 uint16_t opbits;
92 /** Number of entries in query section */
93 uint16_t qd_count;
94 /** Number of RRs in the answer section */
95 uint16_t an_count;
96 /** Number of name server RRs in the authority records section */
97 uint16_t ns_count;
98 /** Number of RRs in the additional records section */
99 uint16_t ar_count;
100} dns_header_t;
101
102/** Bits in dns_header_t.opbits.
103 *
104 * Note that bit numbers in RFC 1035 are reversed (0 is the most significant)
105 * but we use the standard notation (0 is the least significant).
106 */
107enum dns_opbits {
108 OPB_QR = 15,
109 OPB_OPCODE_h = 14,
110 OPB_OPCODE_l = 11,
111 OPB_AA = 10,
112 OPB_TC = 9,
113 OPB_RD = 8,
114 OPB_RA = 7,
115 OPB_Z_h = 6,
116 OPB_Z_l = 4,
117 OPB_RCODE_h = 3,
118 OPB_RCODE_l = 0
119};
120
121typedef enum dns_query_response {
122 QR_QUERY = 0,
123 QR_RESPONSE = 1
124} dns_query_response_t;
125
126typedef enum dns_opcode {
127 OPC_QUERY = 0,
128 OPC_IQUERY = 1,
129 OPC_STATUS = 2
130} dns_opcode_t;
131
132typedef enum dns_rcode {
133 RC_OK = 0,
134 RC_FMT_ERR = 1,
135 RC_SRV_FAIL = 2,
136 RC_NAME_ERR = 3,
137 RC_NOT_IMPL = 4,
138 RC_REFUSED = 5
139} dns_rcode_t;
140
141#endif
142
143/** @}
144 */
Note: See TracBrowser for help on using the repository browser.