1 /****************************************************************************
2 ** File: dns.h
3 **
4 ** Author: Mike Borella
5 **
6 ** Structure of the first 12 bytes of DNS packets
7 **
8 ** $Id: dns.h,v 1.9 2000/08/30 20:23:04 mborella Exp $
9 **
10 ** This program is free software; you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation; either version 2 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ** GNU Library General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 **
24 ****************************************************************************/
25 
26 #ifndef DNS_H
27 #define DNS_H
28 
29 #include "global.h"
30 #include "local.h"
31 
32 typedef struct dns_header
33 {
34   u_int16_t id;
35 #if defined (WORDS_BIGENDIAN)
36   u_int16_t flag_qr:1,
37             flag_opcode:4,
38             flag_aa:1,
39             flag_tc:1,
40             flag_rd:1,
41             flag_ra:1,
42             flag_zero:3,
43             flag_rcode:4;
44 #else
45   u_int16_t flag_rcode:4,
46             flag_zero:3,
47             flag_ra:1,
48             flag_rd:1,
49             flag_tc:1,
50             flag_aa:1,
51             flag_opcode:4,
52             flag_qr:1;
53 #endif
54   u_int16_t number_questions;
55   u_int16_t number_answers;
56   u_int16_t number_authority;
57   u_int16_t number_additional;
58 } dns_header_t;
59 
60 /*
61  * Query/response flag
62  */
63 
64 #define DNS_QRFLAG_QUERY        0
65 #define DNS_QRFLAG_RESPONSE     1
66 
67 /*
68  * Opcode flag
69  */
70 
71 #define DNS_OPCODEFLAG_STANDARD     0
72 #define DNS_OPCODEFLAG_INVERSE      1
73 #define DNS_OPCODEFLAG_STATUS       2
74 
75 /*
76  * Rcode (return code) flag
77  */
78 
79 #define DNS_RCODEFLAG_NOERROR        0
80 #define DNS_RCODEFLAG_FORMATERROR    1
81 #define DNS_RCODEFLAG_SERVERERROR    2
82 #define DNS_RCODEFLAG_NAMEERROR      3
83 #define DNS_RCODEFLAG_NOTIMPLEMENTED 4
84 #define DNS_RCODEFLAG_SERVICEREFUSED 5
85 
86 /*
87  * Query type
88  */
89 
90 #define DNS_QUERYTYPE_A              1
91 #define DNS_QUERYTYPE_NS             2
92 #define DNS_QUERYTYPE_CNAME          5
93 #define DNS_QUERYTYPE_SOA            6
94 #define DNS_QUERYTYPE_PTR            12
95 #define DNS_QUERYTYPE_HINFO          13
96 #define DNS_QUERYTYPE_MX             15
97 #define DNS_QUERYTYPE_AAAA           28
98 #define DNS_QUERYTYPE_AXFR           252
99 #define DNS_QUERYTYPE_ANY            255
100 
101 /*
102  * Query class
103  */
104 
105 #define DNS_QUERYCLASS_IP            1
106 
107 void dump_dns(packet_t *);
108 
109 #endif
110 
111