source: mainline/uspace/srv/net/dnsres/dns_std.h@ d23d911

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

Add DNS resolver stub.

  • Property mode set to 100644
File size: 3.2 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 uint16_t id;
88 uint16_t opbits;
89 uint16_t qd_count;
90 uint16_t an_count;
91 uint16_t ns_count;
92 uint16_t ar_count;
93} dns_header_t;
94
95/** Bits in dns_header_t.opbits.
96 *
97 * Note that bit numbers in RFC 1035 are reversed (0 is the most significant)
98 * but we use the standard notation (0 is the least significant).
99 */
100enum dns_opbits {
101 OPB_QR = 15,
102 QPB_OPCODE_h = 14,
103 QPB_OPCODE_l = 11,
104 QPB_AA = 10,
105 QPB_TC = 9,
106 QPB_RD = 8,
107 QPB_RA = 7,
108 QPB_Z_h = 6,
109 QPB_Z_l = 4,
110 QPB_RCODE_h = 3,
111 QPB_RCODE_l = 0
112};
113
114typedef enum dns_query_response {
115 QR_QUERY = 0,
116 QR_RESPONSE = 1
117} dns_query_response_t;
118
119typedef enum dns_opcode {
120 OPC_QUERY = 0,
121 OPC_IQUERY = 1,
122 OPC_STATUS = 2
123} dns_opcode_t;
124
125typedef enum dns_rcode {
126 RC_OK = 0,
127 RC_FMT_ERR = 1,
128 RC_SRV_FAIL = 2,
129 RC_NAME_ERR = 3,
130 RC_NOT_IMPL = 4,
131 RC_REFUSED = 5
132} dns_rcode_t;
133
134#endif
135
136/** @}
137 */
Note: See TracBrowser for help on using the repository browser.