The Pedigree Project 0.1
prot/dns.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
25/*
26 * Port to lwIP from uIP
27 * by Jim Pettinato April 2007
28 *
29 * security fixes and more by Simon Goldschmidt
30 *
31 * uIP version Copyright (c) 2002-2003, Adam Dunkels.
32 * All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. The name of the author may not be used to endorse or promote
43 * products derived from this software without specific prior
44 * written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
47 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
48 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
50 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
52 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
53 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
54 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
55 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59#ifndef LWIP_HDR_PROT_DNS_H
60#define LWIP_HDR_PROT_DNS_H
61
62#include "lwip/arch.h"
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
69#ifndef DNS_SERVER_PORT
70#define DNS_SERVER_PORT 53
71#endif
72
73/* DNS field TYPE used for "Resource Records" */
74#define DNS_RRTYPE_A 1 /* a host address */
75#define DNS_RRTYPE_NS 2 /* an authoritative name server */
76#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */
77#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */
78#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */
79#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */
80#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */
81#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */
82#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */
83#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */
84#define DNS_RRTYPE_WKS 11 /* a well known service description */
85#define DNS_RRTYPE_PTR 12 /* a domain name pointer */
86#define DNS_RRTYPE_HINFO 13 /* host information */
87#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */
88#define DNS_RRTYPE_MX 15 /* mail exchange */
89#define DNS_RRTYPE_TXT 16 /* text strings */
90#define DNS_RRTYPE_AAAA 28 /* IPv6 address */
91#define DNS_RRTYPE_SRV 33 /* service location */
92#define DNS_RRTYPE_ANY 255 /* any type */
93
94/* DNS field CLASS used for "Resource Records" */
95#define DNS_RRCLASS_IN 1 /* the Internet */
96#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
97#define DNS_RRCLASS_CH 3 /* the CHAOS class */
98#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
99#define DNS_RRCLASS_ANY 255 /* any class */
100#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
101
102/* DNS protocol flags */
103#define DNS_FLAG1_RESPONSE 0x80
104#define DNS_FLAG1_OPCODE_STATUS 0x10
105#define DNS_FLAG1_OPCODE_INVERSE 0x08
106#define DNS_FLAG1_OPCODE_STANDARD 0x00
107#define DNS_FLAG1_AUTHORATIVE 0x04
108#define DNS_FLAG1_TRUNC 0x02
109#define DNS_FLAG1_RD 0x01
110#define DNS_FLAG2_RA 0x80
111#define DNS_FLAG2_ERR_MASK 0x0f
112#define DNS_FLAG2_ERR_NONE 0x00
113#define DNS_FLAG2_ERR_NAME 0x03
114
115#define DNS_HDR_GET_OPCODE(hdr) ((((hdr)->flags1) >> 3) & 0xF)
116
117#ifdef PACK_STRUCT_USE_INCLUDES
118# include "arch/bpstruct.h"
119#endif
122struct dns_hdr {
123 PACK_STRUCT_FIELD(u16_t id);
124 PACK_STRUCT_FLD_8(u8_t flags1);
125 PACK_STRUCT_FLD_8(u8_t flags2);
126 PACK_STRUCT_FIELD(u16_t numquestions);
127 PACK_STRUCT_FIELD(u16_t numanswers);
128 PACK_STRUCT_FIELD(u16_t numauthrr);
129 PACK_STRUCT_FIELD(u16_t numextrarr);
130} PACK_STRUCT_STRUCT;
132#ifdef PACK_STRUCT_USE_INCLUDES
133# include "arch/epstruct.h"
134#endif
135#define SIZEOF_DNS_HDR 12
136
137
138/* Multicast DNS definitions */
139
141#ifndef DNS_MQUERY_PORT
142#define DNS_MQUERY_PORT 5353
143#endif
144
145/* IPv4 group for multicast DNS queries: 224.0.0.251 */
146#ifndef DNS_MQUERY_IPV4_GROUP_INIT
147#define DNS_MQUERY_IPV4_GROUP_INIT IPADDR4_INIT_BYTES(224,0,0,251)
148#endif
149
150/* IPv6 group for multicast DNS queries: FF02::FB */
151#ifndef DNS_MQUERY_IPV6_GROUP_INIT
152#define DNS_MQUERY_IPV6_GROUP_INIT IPADDR6_INIT_HOST(0xFF020000,0,0,0xFB)
153#endif
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* LWIP_HDR_PROT_DNS_H */
#define PACK_STRUCT_END
Definition arch.h:270
#define PACK_STRUCT_BEGIN
Definition arch.h:261
#define PACK_STRUCT_FLD_8(x)
Definition arch.h:301
#define PACK_STRUCT_FIELD(x)
Definition arch.h:292