Changes for kernel and Busybox
[tomato.git] / release / src / router / dnsmasq / src / dns_protocol.h
blob456a997d01f3d5b38e6ae523db3d40c2dc7a45dd
1 /* dnsmasq is Copyright (c) 2000-2011 Simon Kelley
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 dated June, 1991, or
6 (at your option) version 3 dated 29 June, 2007.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #define IN6ADDRSZ 16
18 #define INADDRSZ 4
20 #define PACKETSZ 512 /* maximum packet size */
21 #define MAXDNAME 1025 /* maximum presentation domain name */
22 #define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
23 #define MAXLABEL 63 /* maximum length of domain label */
25 #define NOERROR 0 /* no error */
26 #define FORMERR 1 /* format error */
27 #define SERVFAIL 2 /* server failure */
28 #define NXDOMAIN 3 /* non existent domain */
29 #define NOTIMP 4 /* not implemented */
30 #define REFUSED 5 /* query refused */
32 #define QUERY 0 /* opcode */
34 #define C_IN 1 /* the arpa internet */
35 #define C_CHAOS 3 /* for chaos net (MIT) */
36 #define C_ANY 255 /* wildcard match */
38 #define T_A 1
39 #define T_NS 2
40 #define T_CNAME 5
41 #define T_SOA 6
42 #define T_PTR 12
43 #define T_MX 15
44 #define T_TXT 16
45 #define T_SIG 24
46 #define T_AAAA 28
47 #define T_SRV 33
48 #define T_NAPTR 35
49 #define T_OPT 41
50 #define T_TKEY 249
51 #define T_TSIG 250
52 #define T_MAILB 253
53 #define T_ANY 255
55 struct dns_header {
56 u16 id;
57 u8 hb3,hb4;
58 u16 qdcount,ancount,nscount,arcount;
61 #define HB3_QR 0x80
62 #define HB3_OPCODE 0x78
63 #define HB3_AA 0x04
64 #define HB3_TC 0x02
65 #define HB3_RD 0x01
67 #define HB4_RA 0x80
68 #define HB4_AD 0x20
69 #define HB4_CD 0x10
70 #define HB4_RCODE 0x0f
72 #define OPCODE(x) (((x)->hb3 & HB3_OPCODE) >> 3)
73 #define RCODE(x) ((x)->hb4 & HB4_RCODE)
74 #define SET_RCODE(x, code) (x)->hb4 = ((x)->hb4 & ~HB4_RCODE) | code
76 #define GETSHORT(s, cp) { \
77 unsigned char *t_cp = (unsigned char *)(cp); \
78 (s) = ((u16)t_cp[0] << 8) \
79 | ((u16)t_cp[1]) \
80 ; \
81 (cp) += 2; \
84 #define GETLONG(l, cp) { \
85 unsigned char *t_cp = (unsigned char *)(cp); \
86 (l) = ((u32)t_cp[0] << 24) \
87 | ((u32)t_cp[1] << 16) \
88 | ((u32)t_cp[2] << 8) \
89 | ((u32)t_cp[3]) \
90 ; \
91 (cp) += 4; \
94 #define PUTSHORT(s, cp) { \
95 u16 t_s = (u16)(s); \
96 unsigned char *t_cp = (unsigned char *)(cp); \
97 *t_cp++ = t_s >> 8; \
98 *t_cp = t_s; \
99 (cp) += 2; \
102 #define PUTLONG(l, cp) { \
103 u32 t_l = (u32)(l); \
104 unsigned char *t_cp = (unsigned char *)(cp); \
105 *t_cp++ = t_l >> 24; \
106 *t_cp++ = t_l >> 16; \
107 *t_cp++ = t_l >> 8; \
108 *t_cp = t_l; \
109 (cp) += 4; \