BadVPN – Blame information for rev 1

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