1998-09-16 02:39:15 +00:00
|
|
|
/* packet-dns.c
|
|
|
|
* Routines for DNS packet disassembly
|
|
|
|
*
|
2000-04-26 12:01:50 +00:00
|
|
|
* $Id: packet-dns.c,v 1.43 2000/04/26 12:01:50 itojun Exp $
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <memory.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#include <glib.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "packet.h"
|
2000-03-21 05:15:12 +00:00
|
|
|
#include "resolv.h"
|
1998-10-14 19:35:00 +00:00
|
|
|
#include "packet-dns.h"
|
2000-03-21 05:15:12 +00:00
|
|
|
#include "packet-ip.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
static int proto_dns = -1;
|
1999-10-16 15:08:11 +00:00
|
|
|
static int hf_dns_response = -1;
|
|
|
|
static int hf_dns_query = -1;
|
|
|
|
static int hf_dns_flags = -1;
|
|
|
|
static int hf_dns_transaction_id = -1;
|
|
|
|
static int hf_dns_count_questions = -1;
|
|
|
|
static int hf_dns_count_answers = -1;
|
|
|
|
static int hf_dns_count_auth_rr = -1;
|
|
|
|
static int hf_dns_count_add_rr = -1;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint ett_dns = -1;
|
|
|
|
static gint ett_dns_qd = -1;
|
|
|
|
static gint ett_dns_rr = -1;
|
|
|
|
static gint ett_dns_qry = -1;
|
|
|
|
static gint ett_dns_ans = -1;
|
|
|
|
static gint ett_dns_flags = -1;
|
1999-11-27 08:59:28 +00:00
|
|
|
static gint ett_t_key_flags = -1;
|
1999-11-16 11:44:20 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
/* DNS structs and definitions */
|
|
|
|
|
2000-04-04 06:17:30 +00:00
|
|
|
/* Port used for DNS. */
|
|
|
|
#define UDP_PORT_DNS 53
|
|
|
|
|
1999-01-04 09:13:46 +00:00
|
|
|
/* Offsets of fields in the DNS header. */
|
|
|
|
#define DNS_ID 0
|
|
|
|
#define DNS_FLAGS 2
|
|
|
|
#define DNS_QUEST 4
|
1999-10-07 07:44:29 +00:00
|
|
|
#define DNS_ANS 6
|
1999-01-04 09:13:46 +00:00
|
|
|
#define DNS_AUTH 8
|
1999-10-07 07:44:29 +00:00
|
|
|
#define DNS_ADD 10
|
1999-01-04 09:13:46 +00:00
|
|
|
|
|
|
|
/* Length of DNS header. */
|
|
|
|
#define DNS_HDRLEN 12
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
/* type values */
|
|
|
|
#define T_A 1 /* host address */
|
1999-03-22 23:31:05 +00:00
|
|
|
#define T_NS 2 /* authoritative name server */
|
|
|
|
#define T_MD 3 /* mail destination (obsolete) */
|
|
|
|
#define T_MF 4 /* mail forwarder (obsolete) */
|
1998-09-16 02:39:15 +00:00
|
|
|
#define T_CNAME 5 /* canonical name */
|
|
|
|
#define T_SOA 6 /* start of authority zone */
|
1999-03-22 23:31:05 +00:00
|
|
|
#define T_MB 7 /* mailbox domain name (experimental) */
|
|
|
|
#define T_MG 8 /* mail group member (experimental) */
|
|
|
|
#define T_MR 9 /* mail rename domain name (experimental) */
|
|
|
|
#define T_NULL 10 /* null RR (experimental) */
|
1998-09-16 02:39:15 +00:00
|
|
|
#define T_WKS 11 /* well known service */
|
|
|
|
#define T_PTR 12 /* domain name pointer */
|
|
|
|
#define T_HINFO 13 /* host information */
|
1999-03-22 23:31:05 +00:00
|
|
|
#define T_MINFO 14 /* mailbox or mail list information */
|
1998-09-16 02:39:15 +00:00
|
|
|
#define T_MX 15 /* mail routing information */
|
|
|
|
#define T_TXT 16 /* text strings */
|
1999-03-22 23:31:05 +00:00
|
|
|
#define T_RP 17 /* responsible person (RFC 1183) */
|
|
|
|
#define T_AFSDB 18 /* AFS data base location (RFC 1183) */
|
|
|
|
#define T_X25 19 /* X.25 address (RFC 1183) */
|
|
|
|
#define T_ISDN 20 /* ISDN address (RFC 1183) */
|
|
|
|
#define T_RT 21 /* route-through (RFC 1183) */
|
|
|
|
#define T_NSAP 22 /* OSI NSAP (RFC 1706) */
|
|
|
|
#define T_NSAP_PTR 23 /* PTR equivalent for OSI NSAP (RFC 1348 - obsolete) */
|
|
|
|
#define T_SIG 24 /* digital signature (RFC 2065) */
|
|
|
|
#define T_KEY 25 /* public key (RFC 2065) */
|
|
|
|
#define T_PX 26 /* pointer to X.400/RFC822 mapping info (RFC 1664) */
|
|
|
|
#define T_GPOS 27 /* geographical position (RFC 1712) */
|
|
|
|
#define T_AAAA 28 /* IPv6 address (RFC 1886) */
|
|
|
|
#define T_LOC 29 /* geographical location (RFC 1876) */
|
|
|
|
#define T_NXT 30 /* "next" name (RFC 2065) */
|
|
|
|
#define T_EID 31 /* ??? (Nimrod?) */
|
|
|
|
#define T_NIMLOC 32 /* ??? (Nimrod?) */
|
|
|
|
#define T_SRV 33 /* service location (RFC 2052) */
|
|
|
|
#define T_ATMA 34 /* ??? */
|
|
|
|
#define T_NAPTR 35 /* naming authority pointer (RFC 2168) */
|
2000-04-26 12:01:50 +00:00
|
|
|
#define T_A6 38 /* IPv6 address with indirection (draft-ietf-ipngwg-dns-lookups-07) */
|
2000-03-30 01:33:10 +00:00
|
|
|
#define T_OPT 41 /* OPT pseudo-RR (RFC 2671) */
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-01-04 09:13:46 +00:00
|
|
|
/* Bit fields in the flags */
|
|
|
|
#define F_RESPONSE (1<<15) /* packet is response */
|
|
|
|
#define F_OPCODE (0xF<<11) /* query opcode */
|
|
|
|
#define F_AUTHORITATIVE (1<<10) /* response is authoritative */
|
|
|
|
#define F_TRUNCATED (1<<9) /* response is truncated */
|
|
|
|
#define F_RECDESIRED (1<<8) /* recursion desired */
|
|
|
|
#define F_RECAVAIL (1<<7) /* recursion available */
|
2000-04-26 12:01:50 +00:00
|
|
|
#define F_AUTHENTIC (1<<5) /* authentic data (RFC2535) */
|
|
|
|
#define F_CHECKDISABLE (1<<4) /* checking disabled (RFC2535) */
|
1999-01-04 09:13:46 +00:00
|
|
|
#define F_RCODE (0xF<<0) /* reply code */
|
|
|
|
|
|
|
|
/* Opcodes */
|
|
|
|
#define OPCODE_QUERY (0<<11) /* standard query */
|
|
|
|
#define OPCODE_IQUERY (1<<11) /* inverse query */
|
|
|
|
#define OPCODE_STATUS (2<<11) /* server status request */
|
|
|
|
|
|
|
|
/* Reply codes */
|
|
|
|
#define RCODE_NOERROR (0<<0)
|
|
|
|
#define RCODE_FMTERROR (1<<0)
|
|
|
|
#define RCODE_SERVFAIL (2<<0)
|
|
|
|
#define RCODE_NAMEERROR (3<<0)
|
|
|
|
#define RCODE_NOTIMPL (4<<0)
|
|
|
|
#define RCODE_REFUSED (5<<0)
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-03-22 23:31:05 +00:00
|
|
|
/* See RFC 1035 for all RR types for which no RFC is listed. */
|
1998-09-16 02:39:15 +00:00
|
|
|
static char *
|
1999-11-27 08:59:28 +00:00
|
|
|
dns_type_name (u_int type)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
2000-03-30 01:33:10 +00:00
|
|
|
char *type_names[] = {
|
1999-03-22 23:31:05 +00:00
|
|
|
"unused",
|
|
|
|
"A",
|
|
|
|
"NS",
|
|
|
|
"MD",
|
|
|
|
"MF",
|
|
|
|
"CNAME",
|
|
|
|
"SOA",
|
|
|
|
"MB",
|
|
|
|
"MG",
|
|
|
|
"MR",
|
|
|
|
"NULL",
|
|
|
|
"WKS",
|
|
|
|
"PTR",
|
|
|
|
"HINFO",
|
|
|
|
"MINFO",
|
|
|
|
"MX",
|
|
|
|
"TXT",
|
|
|
|
"RP", /* RFC 1183 */
|
|
|
|
"AFSDB", /* RFC 1183 */
|
|
|
|
"X25", /* RFC 1183 */
|
|
|
|
"ISDN", /* RFC 1183 */
|
|
|
|
"RT", /* RFC 1183 */
|
|
|
|
"NSAP", /* RFC 1706 */
|
|
|
|
"NSAP-PTR", /* RFC 1348 */
|
|
|
|
"SIG", /* RFC 2065 */
|
|
|
|
"KEY", /* RFC 2065 */
|
|
|
|
"PX", /* RFC 1664 */
|
|
|
|
"GPOS", /* RFC 1712 */
|
|
|
|
"AAAA", /* RFC 1886 */
|
|
|
|
"LOC", /* RFC 1876 */
|
|
|
|
"NXT", /* RFC 2065 */
|
|
|
|
"EID",
|
|
|
|
"NIMLOC",
|
|
|
|
"SRV", /* RFC 2052 */
|
|
|
|
"ATMA",
|
2000-03-30 01:33:10 +00:00
|
|
|
"NAPTR", /* RFC 2168 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2000-04-26 12:01:50 +00:00
|
|
|
"A6", /* draft-ietf-ipngwg-dns-lookups-07 */
|
2000-03-30 01:33:10 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
"OPT" /* RFC 2671 */
|
1998-09-16 02:39:15 +00:00
|
|
|
};
|
|
|
|
|
2000-03-30 01:33:10 +00:00
|
|
|
if (type < sizeof(type_names)/sizeof(type_names[0]))
|
|
|
|
return type_names[type] ? type_names[type] : "unknown";
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
/* special cases */
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
/* non standard */
|
|
|
|
case 100:
|
|
|
|
return "UINFO";
|
|
|
|
case 101:
|
|
|
|
return "UID";
|
|
|
|
case 102:
|
|
|
|
return "GID";
|
|
|
|
case 103:
|
|
|
|
return "UNSPEC";
|
|
|
|
|
|
|
|
/* queries */
|
|
|
|
case 251:
|
1999-03-22 23:31:05 +00:00
|
|
|
return "IXFR"; /* RFC 1995 */
|
1998-09-16 02:39:15 +00:00
|
|
|
case 252:
|
|
|
|
return "AXFR";
|
|
|
|
case 253:
|
|
|
|
return "MAILB";
|
|
|
|
case 254:
|
|
|
|
return "MAILA";
|
|
|
|
case 255:
|
|
|
|
return "ANY";
|
|
|
|
}
|
1999-11-27 08:59:28 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-22 23:31:05 +00:00
|
|
|
static char *
|
1999-11-27 08:59:28 +00:00
|
|
|
dns_long_type_name (u_int type)
|
1999-03-22 23:31:05 +00:00
|
|
|
{
|
2000-03-30 01:33:10 +00:00
|
|
|
char *type_names[] = {
|
1999-03-22 23:31:05 +00:00
|
|
|
"unused",
|
|
|
|
"Host address",
|
|
|
|
"Authoritative name server",
|
|
|
|
"Mail destination",
|
|
|
|
"Mail forwarder",
|
|
|
|
"Canonical name for an alias",
|
|
|
|
"Start of zone of authority",
|
|
|
|
"Mailbox domain name",
|
|
|
|
"Mail group member",
|
|
|
|
"Mail rename domain name",
|
|
|
|
"Null resource record",
|
|
|
|
"Well-known service description",
|
|
|
|
"Domain name pointer",
|
|
|
|
"Host information",
|
|
|
|
"Mailbox or mail list information",
|
|
|
|
"Mail exchange",
|
|
|
|
"Text strings",
|
|
|
|
"Responsible person", /* RFC 1183 */
|
|
|
|
"AFS data base location", /* RFC 1183 */
|
|
|
|
"X.25 address", /* RFC 1183 */
|
|
|
|
"ISDN number", /* RFC 1183 */
|
|
|
|
"Route through", /* RFC 1183 */
|
|
|
|
"OSI NSAP", /* RFC 1706 */
|
|
|
|
"OSI NSAP name pointer", /* RFC 1348 */
|
|
|
|
"Signature", /* RFC 2065 */
|
|
|
|
"Public key", /* RFC 2065 */
|
|
|
|
"Pointer to X.400/RFC822 mapping info", /* RFC 1664 */
|
|
|
|
"Geographical position", /* RFC 1712 */
|
|
|
|
"IPv6 address", /* RFC 1886 */
|
|
|
|
"Location", /* RFC 1876 */
|
|
|
|
"Next", /* RFC 2065 */
|
|
|
|
"EID",
|
|
|
|
"NIMLOC",
|
|
|
|
"Service location", /* RFC 2052 */
|
|
|
|
"ATMA",
|
2000-03-30 01:33:10 +00:00
|
|
|
"Naming authority pointer", /* RFC 2168 */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2000-04-26 12:01:50 +00:00
|
|
|
"IPv6 address with indirection", /* draft-ietf-ipngwg-dns-lookups-07 */
|
2000-03-30 01:33:10 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
"EDNS0 option" /* RFC 2671 */
|
1999-03-22 23:31:05 +00:00
|
|
|
};
|
|
|
|
static char unkbuf[7+1+2+1+4+1+1+10+1+1]; /* "Unknown RR type (%d)" */
|
|
|
|
|
2000-03-30 01:33:10 +00:00
|
|
|
if (type < sizeof(type_names)/sizeof(type_names[0]))
|
|
|
|
return type_names[type] ? type_names[type] : "unknown";
|
1999-03-22 23:31:05 +00:00
|
|
|
|
|
|
|
/* special cases */
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
/* non standard */
|
|
|
|
case 100:
|
|
|
|
return "UINFO";
|
|
|
|
case 101:
|
|
|
|
return "UID";
|
|
|
|
case 102:
|
|
|
|
return "GID";
|
|
|
|
case 103:
|
|
|
|
return "UNSPEC";
|
|
|
|
|
|
|
|
/* queries */
|
|
|
|
case 251:
|
|
|
|
return "Request for incremental zone transfer"; /* RFC 1995 */
|
|
|
|
case 252:
|
|
|
|
return "Request for full zone transfer";
|
|
|
|
case 253:
|
|
|
|
return "Request for mailbox-related records";
|
|
|
|
case 254:
|
|
|
|
return "Request for mail agent resource records";
|
|
|
|
case 255:
|
|
|
|
return "Request for all records";
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(unkbuf, "Unknown RR type (%d)", type);
|
|
|
|
return unkbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-14 19:35:00 +00:00
|
|
|
char *
|
1998-09-16 02:39:15 +00:00
|
|
|
dns_class_name(int class)
|
|
|
|
{
|
|
|
|
char *class_name;
|
|
|
|
|
|
|
|
switch (class) {
|
|
|
|
case 1:
|
|
|
|
class_name = "inet";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
class_name = "chaos";
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
class_name = "hesiod";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
class_name = "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
return class_name;
|
|
|
|
}
|
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
int
|
1999-10-07 07:44:29 +00:00
|
|
|
get_dns_name(const u_char *pd, int offset, int dns_data_offset,
|
|
|
|
char *name, int maxname)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
1999-10-07 07:44:29 +00:00
|
|
|
const u_char *dp = pd + offset;
|
|
|
|
const u_char *dptr = dp;
|
1999-05-27 05:35:08 +00:00
|
|
|
char *np = name;
|
|
|
|
int len = -1;
|
2000-04-12 06:59:28 +00:00
|
|
|
int chars_processed = 0;
|
|
|
|
int data_size = pi.len - dns_data_offset;
|
1999-05-27 05:35:08 +00:00
|
|
|
u_int component_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
maxname--; /* reserve space for the trailing '\0' */
|
1999-10-07 07:44:29 +00:00
|
|
|
for (;;) {
|
|
|
|
if (!BYTES_ARE_IN_FRAME(offset, 1))
|
|
|
|
goto overflow;
|
|
|
|
component_len = *dp++;
|
|
|
|
offset++;
|
|
|
|
if (component_len == 0)
|
|
|
|
break;
|
2000-04-12 06:59:28 +00:00
|
|
|
chars_processed++;
|
1999-05-27 05:35:08 +00:00
|
|
|
switch (component_len & 0xc0) {
|
|
|
|
|
|
|
|
case 0x00:
|
|
|
|
/* Label */
|
|
|
|
if (np != name) {
|
|
|
|
/* Not the first component - put in a '.'. */
|
|
|
|
if (maxname > 0) {
|
|
|
|
*np++ = '.';
|
|
|
|
maxname--;
|
|
|
|
}
|
|
|
|
}
|
1999-10-07 07:44:29 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(offset, component_len))
|
|
|
|
goto overflow;
|
1999-05-27 05:35:08 +00:00
|
|
|
while (component_len > 0) {
|
|
|
|
if (maxname > 0) {
|
|
|
|
*np++ = *dp;
|
|
|
|
maxname--;
|
|
|
|
}
|
|
|
|
component_len--;
|
|
|
|
dp++;
|
1999-10-07 07:44:29 +00:00
|
|
|
offset++;
|
2000-04-12 06:59:28 +00:00
|
|
|
chars_processed++;
|
1999-05-27 05:35:08 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
case 0x40:
|
|
|
|
case 0x80:
|
|
|
|
goto error; /* error */
|
|
|
|
|
|
|
|
case 0xc0:
|
|
|
|
/* Pointer. */
|
1999-10-07 07:44:29 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(offset, 1))
|
|
|
|
goto overflow;
|
|
|
|
offset = dns_data_offset + (((component_len & ~0xc0) << 8) | (*dp++));
|
2000-04-12 06:59:28 +00:00
|
|
|
chars_processed++;
|
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
/* If "len" is negative, we are still working on the original name,
|
|
|
|
not something pointed to by a pointer, and so we should set "len"
|
|
|
|
to the length of the original name. */
|
|
|
|
if (len < 0)
|
|
|
|
len = dp - dptr;
|
2000-04-12 06:59:28 +00:00
|
|
|
|
|
|
|
if (offset >= pi.len) {
|
|
|
|
strcpy(name, "<Name contains a pointer that goes past the end of the packet>");
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we've looked at every character in the message, this pointer
|
|
|
|
will make us look at some character again, which means we're
|
|
|
|
looping. */
|
|
|
|
if (chars_processed >= data_size) {
|
|
|
|
strcpy(name, "<Name contains a pointer that loops>");
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
dp = pd + offset;
|
1999-05-27 05:35:08 +00:00
|
|
|
break; /* now continue processing from there */
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
1999-05-27 05:35:08 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
*np = '\0';
|
|
|
|
/* If "len" is negative, we haven't seen a pointer, and thus haven't
|
|
|
|
set the length, so set it. */
|
|
|
|
if (len < 0)
|
|
|
|
len = dp - dptr;
|
|
|
|
/* Zero-length name means "root server" */
|
|
|
|
if (*name == '\0')
|
|
|
|
strcpy(name, "<Root>");
|
1998-09-16 02:39:15 +00:00
|
|
|
return len;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
|
|
|
overflow:
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
strcpy(name, "<Name goes past end of captured data in packet>");
|
1999-10-07 09:21:38 +00:00
|
|
|
/* If "len" is negative, we haven't seen a pointer, and thus haven't
|
|
|
|
set the length, so set it. */
|
|
|
|
if (len < 0)
|
|
|
|
len = dp - dptr;
|
|
|
|
return len;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
1999-10-07 07:44:29 +00:00
|
|
|
get_dns_name_type_class(const u_char *pd, int offset, int dns_data_offset,
|
|
|
|
char *name_ret, int *name_len_ret, int *type_ret, int *class_ret)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
int name_len;
|
|
|
|
int type;
|
|
|
|
int class;
|
|
|
|
char name[MAXDNAME];
|
1999-10-07 07:44:29 +00:00
|
|
|
int start_offset = offset;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
name_len = get_dns_name(pd, offset, dns_data_offset, name, sizeof(name));
|
1999-10-07 09:21:38 +00:00
|
|
|
offset += name_len;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(offset, 2)) {
|
1999-10-07 07:44:29 +00:00
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
type = pntohs(&pd[offset]);
|
|
|
|
offset += 2;
|
|
|
|
|
1999-10-07 09:21:38 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(offset, 2)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return -1;
|
|
|
|
}
|
1999-10-07 07:44:29 +00:00
|
|
|
class = pntohs(&pd[offset]);
|
|
|
|
offset += 2;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
strcpy (name_ret, name);
|
|
|
|
*type_ret = type;
|
|
|
|
*class_ret = class;
|
1998-10-14 19:35:00 +00:00
|
|
|
*name_len_ret = name_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
len = offset - start_offset;
|
1998-09-16 02:39:15 +00:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
1999-09-21 07:15:38 +00:00
|
|
|
static double
|
1999-10-07 07:44:29 +00:00
|
|
|
rfc1867_size(u_char val)
|
1999-09-21 07:15:38 +00:00
|
|
|
{
|
|
|
|
double size;
|
|
|
|
guint32 exponent;
|
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
size = (val & 0xF0) >> 4;
|
|
|
|
exponent = (val & 0x0F);
|
1999-09-21 07:15:38 +00:00
|
|
|
while (exponent != 0) {
|
|
|
|
size *= 10;
|
|
|
|
exponent--;
|
|
|
|
}
|
|
|
|
return size / 100; /* return size in meters, not cm */
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
rfc1867_angle(const u_char *dptr, const char *nsew)
|
|
|
|
{
|
|
|
|
guint32 angle;
|
|
|
|
char direction;
|
|
|
|
guint32 degrees, minutes, secs, tsecs;
|
|
|
|
static char buf[10+1+3+1 + 2+1+3+1 + 2+1+3+1+3+1 + 1 + 1];
|
|
|
|
|
|
|
|
angle = pntohl(dptr);
|
|
|
|
|
|
|
|
if (angle < 0x80000000U) {
|
|
|
|
angle = 0x80000000U - angle;
|
|
|
|
direction = nsew[1];
|
|
|
|
} else {
|
|
|
|
angle = angle - 0x80000000U;
|
|
|
|
direction = nsew[0];
|
|
|
|
}
|
|
|
|
tsecs = angle % 1000;
|
|
|
|
angle = angle / 1000;
|
|
|
|
secs = angle % 60;
|
|
|
|
angle = angle / 60;
|
|
|
|
minutes = angle % 60;
|
|
|
|
degrees = angle / 60;
|
|
|
|
sprintf(buf, "%u deg %u min %u.%03u sec %c", degrees, minutes, secs,
|
|
|
|
tsecs, direction);
|
|
|
|
return buf;
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
static int
|
1999-10-07 07:44:29 +00:00
|
|
|
dissect_dns_query(const u_char *pd, int offset, int dns_data_offset,
|
1999-11-07 21:00:40 +00:00
|
|
|
frame_data *fd, proto_tree *dns_tree)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char name[MAXDNAME];
|
1998-10-14 19:35:00 +00:00
|
|
|
int name_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
int type;
|
|
|
|
int class;
|
|
|
|
char *class_name;
|
|
|
|
char *type_name;
|
1999-03-22 23:31:05 +00:00
|
|
|
char *long_type_name;
|
1998-10-14 19:35:00 +00:00
|
|
|
const u_char *dptr;
|
|
|
|
const u_char *data_start;
|
1999-03-23 03:14:46 +00:00
|
|
|
proto_tree *q_tree;
|
|
|
|
proto_item *tq;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1998-10-14 19:35:00 +00:00
|
|
|
data_start = dptr = pd + offset;
|
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
len = get_dns_name_type_class(pd, offset, dns_data_offset, name, &name_len,
|
1998-10-14 19:35:00 +00:00
|
|
|
&type, &class);
|
1999-10-07 07:44:29 +00:00
|
|
|
if (len < 0) {
|
|
|
|
/* We ran past the end of the data in the packet. */
|
|
|
|
return 0;
|
1999-10-07 02:26:45 +00:00
|
|
|
}
|
1999-10-07 07:44:29 +00:00
|
|
|
dptr += len;
|
1999-10-07 02:26:45 +00:00
|
|
|
|
1998-10-15 06:40:51 +00:00
|
|
|
type_name = dns_type_name(type);
|
|
|
|
class_name = dns_class_name(class);
|
1999-03-22 23:31:05 +00:00
|
|
|
long_type_name = dns_long_type_name(type);
|
1998-10-15 06:40:51 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (fd != NULL)
|
|
|
|
col_append_fstr(fd, COL_INFO, " %s %s", type_name, name);
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
tq = proto_tree_add_text(dns_tree, offset, len, "%s: type %s, class %s",
|
1998-10-15 06:40:51 +00:00
|
|
|
name, type_name, class_name);
|
1999-11-16 11:44:20 +00:00
|
|
|
q_tree = proto_item_add_subtree(tq, ett_dns_qd);
|
1998-10-15 06:40:51 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(q_tree, offset, name_len, "Name: %s", name);
|
|
|
|
offset += name_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(q_tree, offset, 2, "Type: %s", long_type_name);
|
|
|
|
offset += 2;
|
1998-10-14 19:35:00 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(q_tree, offset, 2, "Class: %s", class_name);
|
|
|
|
offset += 2;
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1998-10-14 19:35:00 +00:00
|
|
|
return dptr - data_start;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
proto_tree *
|
|
|
|
add_rr_to_tree(proto_item *trr, int rr_type, int offset, const char *name,
|
1998-10-14 19:35:00 +00:00
|
|
|
int namelen, const char *type_name, const char *class_name, u_int ttl,
|
|
|
|
u_short data_len)
|
|
|
|
{
|
1999-03-23 03:14:46 +00:00
|
|
|
proto_tree *rr_tree;
|
1998-10-14 19:35:00 +00:00
|
|
|
|
1999-07-07 22:52:57 +00:00
|
|
|
rr_tree = proto_item_add_subtree(trr, rr_type);
|
|
|
|
proto_tree_add_text(rr_tree, offset, namelen, "Name: %s", name);
|
1998-10-14 19:35:00 +00:00
|
|
|
offset += namelen;
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "Type: %s", type_name);
|
1998-10-14 19:35:00 +00:00
|
|
|
offset += 2;
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "Class: %s", class_name);
|
1998-10-14 19:35:00 +00:00
|
|
|
offset += 2;
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(rr_tree, offset, 4, "Time to live: %s",
|
1999-01-28 21:29:36 +00:00
|
|
|
time_secs_to_str(ttl));
|
1998-10-14 19:35:00 +00:00
|
|
|
offset += 4;
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "Data length: %u", data_len);
|
1998-10-14 19:35:00 +00:00
|
|
|
return rr_tree;
|
|
|
|
}
|
|
|
|
|
2000-03-30 01:52:40 +00:00
|
|
|
static proto_tree *
|
2000-03-30 01:33:10 +00:00
|
|
|
add_opt_rr_to_tree(proto_item *trr, int rr_type, int offset, const char *name,
|
|
|
|
int namelen, const char *type_name, int class, u_int ttl, u_short data_len)
|
|
|
|
{
|
|
|
|
proto_tree *rr_tree;
|
|
|
|
|
|
|
|
rr_tree = proto_item_add_subtree(trr, rr_type);
|
|
|
|
proto_tree_add_text(rr_tree, offset, namelen, "Name: %s", name);
|
|
|
|
offset += namelen;
|
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "Type: %s", type_name);
|
|
|
|
offset += 2;
|
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "UDP payload size: %u",
|
|
|
|
class & 0xffff);
|
|
|
|
offset += 2;
|
|
|
|
proto_tree_add_text(rr_tree, offset, 1, "Higher bits in extended RCODE: 0x%x",
|
|
|
|
(ttl >> 24) & 0xff0);
|
|
|
|
offset++;
|
|
|
|
proto_tree_add_text(rr_tree, offset, 1, "EDNS0 version: %u",
|
|
|
|
(ttl >> 16) & 0xff);
|
|
|
|
offset++;
|
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "Must be zero: 0x%x", ttl & 0xffff);
|
|
|
|
offset += 2;
|
|
|
|
proto_tree_add_text(rr_tree, offset, 2, "Data length: %u", data_len);
|
|
|
|
return rr_tree;
|
|
|
|
}
|
|
|
|
|
1999-11-27 08:59:28 +00:00
|
|
|
/*
|
|
|
|
* SIG and KEY RR algorithms.
|
|
|
|
*/
|
|
|
|
#define DNS_ALGO_MD5 1 /* MD5/RSA */
|
|
|
|
#define DNS_ALGO_EDATE 253 /* Expiration date */
|
|
|
|
#define DNS_ALGO_PRIVATE 254 /* Private use */
|
|
|
|
|
|
|
|
static const value_string algo_vals[] = {
|
|
|
|
{ DNS_ALGO_MD5, "MD5/RSA" },
|
|
|
|
{ DNS_ALGO_EDATE, "Expiration date" },
|
|
|
|
{ DNS_ALGO_PRIVATE, "Private use" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
static int
|
1999-10-07 07:44:29 +00:00
|
|
|
dissect_dns_answer(const u_char *pd, int offset, int dns_data_offset,
|
1999-11-07 21:00:40 +00:00
|
|
|
frame_data *fd, proto_tree *dns_tree)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char name[MAXDNAME];
|
1998-10-14 19:35:00 +00:00
|
|
|
int name_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
int type;
|
|
|
|
int class;
|
|
|
|
char *class_name;
|
|
|
|
char *type_name;
|
1999-03-22 23:31:05 +00:00
|
|
|
char *long_type_name;
|
1998-09-16 02:39:15 +00:00
|
|
|
const u_char *dptr;
|
1999-10-07 07:44:29 +00:00
|
|
|
int cur_offset;
|
1998-09-16 02:39:15 +00:00
|
|
|
const u_char *data_start;
|
|
|
|
u_int ttl;
|
|
|
|
u_short data_len;
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_tree *rr_tree = NULL;
|
|
|
|
proto_item *trr = NULL;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
data_start = dptr = pd + offset;
|
1999-10-07 07:44:29 +00:00
|
|
|
cur_offset = offset;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
len = get_dns_name_type_class(pd, offset, dns_data_offset, name, &name_len,
|
1998-10-14 19:35:00 +00:00
|
|
|
&type, &class);
|
1999-10-07 07:44:29 +00:00
|
|
|
if (len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
1999-10-07 02:26:45 +00:00
|
|
|
}
|
1999-10-07 07:44:29 +00:00
|
|
|
dptr += len;
|
|
|
|
cur_offset += len;
|
1999-10-07 02:26:45 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
type_name = dns_type_name(type);
|
|
|
|
class_name = dns_class_name(class);
|
1999-03-22 23:31:05 +00:00
|
|
|
long_type_name = dns_long_type_name(type);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
1998-10-14 19:35:00 +00:00
|
|
|
ttl = pntohl(dptr);
|
|
|
|
dptr += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
cur_offset += 4;
|
1998-10-14 19:35:00 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
1998-10-14 19:35:00 +00:00
|
|
|
data_len = pntohs(dptr);
|
|
|
|
dptr += 2;
|
1999-10-07 07:44:29 +00:00
|
|
|
cur_offset += 2;
|
1998-10-14 19:35:00 +00:00
|
|
|
|
2000-03-21 06:21:37 +00:00
|
|
|
if (fd != NULL)
|
|
|
|
col_append_fstr(fd, COL_INFO, " %s", type_name);
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
trr = proto_tree_add_notext(dns_tree, offset,
|
|
|
|
(dptr - data_start) + data_len);
|
2000-03-30 01:33:10 +00:00
|
|
|
if (type != T_OPT) {
|
|
|
|
rr_tree = add_rr_to_tree(trr, ett_dns_rr, offset, name, name_len,
|
2000-03-21 06:21:37 +00:00
|
|
|
long_type_name, class_name, ttl, data_len);
|
2000-03-30 01:33:10 +00:00
|
|
|
} else {
|
|
|
|
rr_tree = add_opt_rr_to_tree(trr, ett_dns_rr, offset, name, name_len,
|
|
|
|
long_type_name, class, ttl, data_len);
|
|
|
|
}
|
2000-03-21 06:21:37 +00:00
|
|
|
}
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
switch (type) {
|
2000-03-21 06:21:37 +00:00
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
case T_A:
|
2000-03-21 06:21:37 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Address goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
2000-03-21 06:21:37 +00:00
|
|
|
if (fd != NULL)
|
|
|
|
col_append_fstr(fd, COL_INFO, " %s", ip_to_str((guint8 *)dptr));
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, addr %s",
|
1998-09-16 02:39:15 +00:00
|
|
|
name, type_name, class_name,
|
1998-10-14 22:37:02 +00:00
|
|
|
ip_to_str((guint8 *)dptr));
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Addr: %s",
|
|
|
|
ip_to_str((guint8 *)dptr));
|
1999-10-07 07:44:29 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
case T_NS:
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
|
|
|
char ns_name[MAXDNAME];
|
1998-10-14 19:35:00 +00:00
|
|
|
int ns_name_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
ns_name_len = get_dns_name(pd, cur_offset, dns_data_offset, ns_name, sizeof(ns_name));
|
2000-03-21 06:21:37 +00:00
|
|
|
if (ns_name_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Nameserver name goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %s", ns_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, ns %s",
|
1998-10-14 19:35:00 +00:00
|
|
|
name, type_name, class_name, ns_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, ns_name_len, "Name server: %s",
|
1999-10-07 07:44:29 +00:00
|
|
|
ns_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
case T_CNAME:
|
1999-03-22 23:31:05 +00:00
|
|
|
{
|
|
|
|
char cname[MAXDNAME];
|
|
|
|
int cname_len;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
cname_len = get_dns_name(pd, cur_offset, dns_data_offset, cname, sizeof(cname));
|
2000-03-21 06:21:37 +00:00
|
|
|
if (cname_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Primary name goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %s", cname);
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, cname %s",
|
1999-03-22 23:31:05 +00:00
|
|
|
name, type_name, class_name, cname);
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, cname_len, "Primary name: %s",
|
1999-10-07 07:44:29 +00:00
|
|
|
cname);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-05-27 05:35:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_SOA:
|
|
|
|
{
|
|
|
|
char mname[MAXDNAME];
|
|
|
|
int mname_len;
|
|
|
|
char rname[MAXDNAME];
|
|
|
|
int rname_len;
|
|
|
|
guint32 serial;
|
|
|
|
guint32 refresh;
|
|
|
|
guint32 retry;
|
|
|
|
guint32 expire;
|
|
|
|
guint32 minimum;
|
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
mname_len = get_dns_name(pd, cur_offset, dns_data_offset, mname, sizeof(mname));
|
2000-03-21 06:21:37 +00:00
|
|
|
if (mname_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <mname goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
1999-10-07 07:44:29 +00:00
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %s", mname);
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, mname %s",
|
1999-05-27 05:35:08 +00:00
|
|
|
name, type_name, class_name, mname);
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, mname_len, "Primary name server: %s",
|
|
|
|
mname);
|
|
|
|
cur_offset += mname_len;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
2000-03-21 06:21:37 +00:00
|
|
|
rname_len = get_dns_name(pd, cur_offset, dns_data_offset, rname, sizeof(rname));
|
1999-11-07 21:00:40 +00:00
|
|
|
if (rname_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, rname_len, "Responsible authority's mailbox: %s",
|
|
|
|
rname);
|
|
|
|
cur_offset += rname_len;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
serial = pntohl(&pd[cur_offset]);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Serial number: %u",
|
|
|
|
serial);
|
|
|
|
cur_offset += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
refresh = pntohl(&pd[cur_offset]);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Refresh interval: %s",
|
|
|
|
time_secs_to_str(refresh));
|
|
|
|
cur_offset += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
retry = pntohl(&pd[cur_offset]);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Retry interval: %s",
|
|
|
|
time_secs_to_str(retry));
|
|
|
|
cur_offset += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
expire = pntohl(&pd[cur_offset]);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Expiration limit: %s",
|
|
|
|
time_secs_to_str(expire));
|
|
|
|
cur_offset += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
minimum = pntohl(&pd[cur_offset]);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Minimum TTL: %s",
|
|
|
|
time_secs_to_str(minimum));
|
1999-10-07 07:44:29 +00:00
|
|
|
}
|
1999-03-22 23:31:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-05-27 05:35:08 +00:00
|
|
|
case T_PTR:
|
1999-03-22 23:31:05 +00:00
|
|
|
{
|
|
|
|
char pname[MAXDNAME];
|
|
|
|
int pname_len;
|
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
pname_len = get_dns_name(pd, cur_offset, dns_data_offset, pname, sizeof(pname));
|
2000-03-21 06:21:37 +00:00
|
|
|
if (pname_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Domain name goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %s", pname);
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, ptr %s",
|
1999-03-22 23:31:05 +00:00
|
|
|
name, type_name, class_name, pname);
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, pname_len, "Domain name: %s",
|
1999-10-07 07:44:29 +00:00
|
|
|
pname);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-03-22 23:31:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1999-09-21 07:15:38 +00:00
|
|
|
|
2000-03-21 05:15:12 +00:00
|
|
|
case T_WKS:
|
|
|
|
{
|
|
|
|
int rr_len = data_len;
|
|
|
|
guint8 protocol;
|
|
|
|
guint8 bits;
|
2000-03-21 06:21:37 +00:00
|
|
|
int mask;
|
2000-03-21 05:15:12 +00:00
|
|
|
int port_num;
|
|
|
|
int i;
|
|
|
|
char bitnames[128+1];
|
|
|
|
char portnumstring[10+1];
|
|
|
|
|
2000-03-21 06:21:37 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Address goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
2000-03-21 05:15:12 +00:00
|
|
|
}
|
2000-03-21 06:21:37 +00:00
|
|
|
if (fd != NULL)
|
|
|
|
col_append_fstr(fd, COL_INFO, " %s", ip_to_str((guint8 *)dptr));
|
2000-03-21 05:15:12 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, addr %s",
|
2000-03-21 05:15:12 +00:00
|
|
|
name, type_name, class_name,
|
|
|
|
ip_to_str((guint8 *)dptr));
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Addr: %s",
|
|
|
|
ip_to_str((guint8 *)dptr));
|
|
|
|
cur_offset += 4;
|
|
|
|
rr_len -= 4;
|
|
|
|
|
2000-03-21 06:21:37 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
2000-03-21 05:15:12 +00:00
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, END_OF_FRAME,
|
|
|
|
"<Protocol goes past end of captured data in packet>");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
protocol = pd[cur_offset];
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Protocol: %s",
|
|
|
|
ipprotostr(protocol));
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
|
|
|
|
port_num = 0;
|
|
|
|
while (rr_len != 0) {
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, END_OF_FRAME,
|
|
|
|
"<Bit map goes past end of captured data in packet>");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
bits = pd[cur_offset];
|
|
|
|
if (bits != 0) {
|
2000-03-21 06:21:37 +00:00
|
|
|
mask = 1<<7;
|
2000-03-21 05:15:12 +00:00
|
|
|
bitnames[0] = '\0';
|
2000-03-21 06:21:37 +00:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
if (bits & mask) {
|
2000-03-21 05:15:12 +00:00
|
|
|
if (bitnames[0] != '\0')
|
|
|
|
strcat(bitnames, ", ");
|
|
|
|
switch (protocol) {
|
|
|
|
|
|
|
|
case IP_PROTO_TCP:
|
|
|
|
strcat(bitnames, get_tcp_port(port_num));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IP_PROTO_UDP:
|
|
|
|
strcat(bitnames, get_udp_port(port_num));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
sprintf(portnumstring, "%u", port_num);
|
|
|
|
strcat(bitnames, portnumstring);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-03-21 06:21:37 +00:00
|
|
|
mask >>= 1;
|
2000-03-21 05:15:12 +00:00
|
|
|
port_num++;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1,
|
|
|
|
"Bits: 0x%02x (%s)", bits, bitnames);
|
|
|
|
} else
|
|
|
|
port_num += 8;
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-12 22:43:32 +00:00
|
|
|
case T_HINFO:
|
|
|
|
{
|
|
|
|
int cpu_offset;
|
|
|
|
int cpu_len;
|
|
|
|
int os_offset;
|
|
|
|
int os_len;
|
|
|
|
|
|
|
|
cpu_offset = cur_offset;
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cpu_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-11-12 22:43:32 +00:00
|
|
|
"%s: type %s, class %s, <CPU goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
cpu_len = pd[cpu_offset];
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cpu_offset + 1, cpu_len)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-11-12 22:43:32 +00:00
|
|
|
"%s: type %s, class %s, <CPU goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
os_offset = cpu_offset + 1 + cpu_len;
|
|
|
|
if (!BYTES_ARE_IN_FRAME(os_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-11-12 22:43:32 +00:00
|
|
|
"%s: type %s, class %s, CPU %.*s, <OS goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name, cpu_len, &pd[cpu_offset + 1]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
os_len = pd[os_offset];
|
|
|
|
if (!BYTES_ARE_IN_FRAME(os_offset + 1, os_len)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, CPU %.*s, <OS goes past end of captured data in packet>",
|
1999-11-12 22:43:32 +00:00
|
|
|
name, type_name, class_name, cpu_len, &pd[cpu_offset + 1]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %.*s %.*s", cpu_len,
|
1999-11-12 22:43:32 +00:00
|
|
|
&pd[cpu_offset + 1], os_len, &pd[os_offset + 1]);
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-11-12 22:43:32 +00:00
|
|
|
"%s: type %s, class %s, CPU %.*s, OS %.*s",
|
|
|
|
name, type_name, class_name,
|
|
|
|
cpu_len, &pd[cpu_offset + 1], os_len, &pd[os_offset + 1]);
|
|
|
|
proto_tree_add_text(rr_tree, cpu_offset, 1 + cpu_len, "CPU: %.*s",
|
|
|
|
cpu_len, &pd[cpu_offset + 1]);
|
|
|
|
proto_tree_add_text(rr_tree, os_offset, 1 + os_len, "OS: %.*s",
|
|
|
|
os_len, &pd[os_offset + 1]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-09-21 07:15:38 +00:00
|
|
|
case T_MX:
|
|
|
|
{
|
1999-10-07 07:44:29 +00:00
|
|
|
guint16 preference = 0;
|
1999-09-21 07:15:38 +00:00
|
|
|
char mx_name[MAXDNAME];
|
|
|
|
int mx_name_len;
|
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
|
1999-11-10 06:01:21 +00:00
|
|
|
/* We ran past the end of the captured data in the packet. */
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-10-07 07:44:29 +00:00
|
|
|
"%s: type %s, class %s, <preference goes past end of captured data in packet>",
|
1999-11-10 06:01:21 +00:00
|
|
|
name, type_name, class_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-11-10 06:01:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
preference = pntohs(&pd[cur_offset]);
|
|
|
|
mx_name_len = get_dns_name(pd, cur_offset + 2, dns_data_offset, mx_name, sizeof(mx_name));
|
|
|
|
if (mx_name_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-11-10 06:01:21 +00:00
|
|
|
"%s: type %s, class %s, preference %u, <mx goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name, preference);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-11-10 06:01:21 +00:00
|
|
|
return 0;
|
1999-10-07 07:44:29 +00:00
|
|
|
}
|
1999-11-10 06:01:21 +00:00
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %u %s", preference, mx_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-07 05:57:13 +00:00
|
|
|
proto_item_set_text(trr,
|
1999-11-10 06:01:21 +00:00
|
|
|
"%s: type %s, class %s, preference %u, mx %s",
|
|
|
|
name, type_name, class_name, preference, mx_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 2, "Preference: %u", preference);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset + 2, mx_name_len, "Mail exchange: %s",
|
1999-10-07 07:44:29 +00:00
|
|
|
mx_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-09-21 07:15:38 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-11-27 07:46:44 +00:00
|
|
|
|
2000-03-21 05:15:12 +00:00
|
|
|
case T_TXT:
|
|
|
|
{
|
|
|
|
int rr_len = data_len;
|
|
|
|
int txt_offset;
|
|
|
|
int txt_len;
|
|
|
|
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s", name, type_name, class_name);
|
|
|
|
|
|
|
|
txt_offset = cur_offset;
|
|
|
|
while (rr_len != 0) {
|
|
|
|
if (!BYTES_ARE_IN_FRAME(txt_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
2000-03-21 05:15:12 +00:00
|
|
|
proto_tree_add_text(rr_tree, txt_offset, END_OF_FRAME,
|
|
|
|
"<String goes past end of captured data in packet>");
|
2000-03-21 06:21:37 +00:00
|
|
|
return 0;
|
2000-03-21 05:15:12 +00:00
|
|
|
}
|
2000-03-21 06:21:37 +00:00
|
|
|
txt_len = pd[txt_offset];
|
|
|
|
if (!BYTES_ARE_IN_FRAME(txt_offset + 1, txt_len)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
2000-03-21 05:15:12 +00:00
|
|
|
proto_tree_add_text(rr_tree, txt_offset, END_OF_FRAME,
|
|
|
|
"<String goes past end of captured data in packet>");
|
2000-03-21 06:21:37 +00:00
|
|
|
return 0;
|
2000-03-21 05:15:12 +00:00
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, txt_offset, 1 + txt_len,
|
|
|
|
"Text: %.*s", txt_len, &pd[txt_offset + 1]);
|
2000-03-21 06:21:37 +00:00
|
|
|
txt_offset += 1 + txt_len;
|
|
|
|
rr_len -= 1 + txt_len;
|
2000-03-21 05:15:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-27 08:59:28 +00:00
|
|
|
case T_SIG:
|
|
|
|
{
|
|
|
|
int rr_len = data_len;
|
|
|
|
struct timeval unixtime;
|
|
|
|
char signer_name[MAXDNAME];
|
|
|
|
int signer_name_len;
|
|
|
|
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s", name, type_name, class_name);
|
1999-11-27 08:59:28 +00:00
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 2, "Type covered: %s (%s)",
|
|
|
|
dns_type_name(pntohs(&pd[cur_offset])),
|
|
|
|
dns_long_type_name(pntohs(&pd[cur_offset])));
|
|
|
|
cur_offset += 2;
|
|
|
|
rr_len -= 2;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Algorithm: %s",
|
|
|
|
val_to_str(pd[cur_offset], algo_vals,
|
|
|
|
"Unknown (0x%02X)"));
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Labels: %u",
|
|
|
|
pd[cur_offset]);
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Original TTL: %s",
|
|
|
|
time_secs_to_str(pntohl(&pd[cur_offset])));
|
|
|
|
cur_offset += 4;
|
|
|
|
rr_len -= 4;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
unixtime.tv_sec = pntohl(&pd[cur_offset]);
|
|
|
|
unixtime.tv_usec = 0;
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Signature expiration: %s",
|
|
|
|
abs_time_to_str(&unixtime));
|
|
|
|
cur_offset += 4;
|
|
|
|
rr_len -= 4;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
unixtime.tv_sec = pntohl(&pd[cur_offset]);
|
|
|
|
unixtime.tv_usec = 0;
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Time signed: %s",
|
|
|
|
abs_time_to_str(&unixtime));
|
|
|
|
cur_offset += 4;
|
|
|
|
rr_len -= 4;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 2, "Key footprint: 0x%04x",
|
|
|
|
pntohs(&pd[cur_offset]));
|
|
|
|
cur_offset += 2;
|
|
|
|
rr_len -= 2;
|
|
|
|
|
|
|
|
signer_name_len = get_dns_name(pd, cur_offset, dns_data_offset, signer_name, sizeof(signer_name));
|
|
|
|
if (signer_name_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, signer_name_len,
|
|
|
|
"Signer's name: %s", signer_name);
|
|
|
|
cur_offset += signer_name_len;
|
|
|
|
rr_len -= signer_name_len;
|
|
|
|
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, rr_len, "Signature");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_KEY:
|
|
|
|
{
|
|
|
|
int rr_len = data_len;
|
|
|
|
guint16 flags;
|
|
|
|
proto_item *tf;
|
|
|
|
proto_tree *flags_tree;
|
|
|
|
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s", name, type_name, class_name);
|
1999-11-27 08:59:28 +00:00
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
flags = pntohs(&pd[cur_offset]);
|
|
|
|
tf = proto_tree_add_text(rr_tree, cur_offset, 2, "Flags: 0x%04X", flags);
|
|
|
|
flags_tree = proto_item_add_subtree(tf, ett_t_key_flags);
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x8000,
|
|
|
|
2*8, "Key prohibited for authentication",
|
|
|
|
"Key allowed for authentication"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x4000,
|
|
|
|
2*8, "Key prohibited for confidentiality",
|
|
|
|
"Key allowed for confidentiality"));
|
|
|
|
if ((flags & 0xC000) != 0xC000) {
|
|
|
|
/* We have a key */
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x2000,
|
|
|
|
2*8, "Key is experimental or optional",
|
|
|
|
"Key is required"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x0400,
|
|
|
|
2*8, "Key is associated with a user",
|
|
|
|
"Key is not associated with a user"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x0200,
|
|
|
|
2*8, "Key is associated with the named entity",
|
|
|
|
"Key is not associated with the named entity"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x0100,
|
|
|
|
2*8, "This is the zone key for the specified zone",
|
|
|
|
"This is not a zone key"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x0080,
|
|
|
|
2*8, "Key is valid for use with IPSEC",
|
|
|
|
"Key is not valid for use with IPSEC"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, 0x0040,
|
|
|
|
2*8, "Key is valid for use with MIME security multiparts",
|
|
|
|
"Key is not valid for use with MIME security multiparts"));
|
|
|
|
proto_tree_add_text(flags_tree, cur_offset, 2, "%s",
|
|
|
|
decode_numeric_bitfield(flags, 0x000F,
|
|
|
|
2*8, "Signatory = %u"));
|
|
|
|
}
|
|
|
|
cur_offset += 2;
|
|
|
|
rr_len -= 2;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Protocol: %u",
|
|
|
|
pd[cur_offset]);
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Algorithm: %s",
|
|
|
|
val_to_str(pd[cur_offset], algo_vals,
|
|
|
|
"Unknown (0x%02X)"));
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, rr_len, "Public key");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-11-27 07:46:44 +00:00
|
|
|
case T_AAAA:
|
2000-03-21 06:21:37 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 16)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Address goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-27 07:46:44 +00:00
|
|
|
if (fd != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %s",
|
1999-11-27 07:46:44 +00:00
|
|
|
ip6_to_str((struct e_in6_addr *)dptr));
|
|
|
|
}
|
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, addr %s",
|
1999-11-27 07:46:44 +00:00
|
|
|
name, type_name, class_name,
|
|
|
|
ip6_to_str((struct e_in6_addr *)dptr));
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 16, "Addr: %s",
|
|
|
|
ip6_to_str((struct e_in6_addr *)dptr));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-09-21 07:15:38 +00:00
|
|
|
case T_LOC:
|
|
|
|
{
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s", name, type_name, class_name);
|
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
1999-10-07 07:44:29 +00:00
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Version: %u", pd[cur_offset]);
|
|
|
|
if (pd[cur_offset] == 0) {
|
|
|
|
/* Version 0, the only version RFC 1876 discusses. */
|
|
|
|
cur_offset++;
|
|
|
|
|
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Size: %g m",
|
1999-10-07 07:44:29 +00:00
|
|
|
rfc1867_size(pd[cur_offset]));
|
1999-11-07 21:00:40 +00:00
|
|
|
cur_offset++;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Horizontal precision: %g m",
|
1999-10-07 07:44:29 +00:00
|
|
|
rfc1867_size(pd[cur_offset]));
|
1999-11-07 21:00:40 +00:00
|
|
|
cur_offset++;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1, "Vertical precision: %g m",
|
1999-10-07 07:44:29 +00:00
|
|
|
rfc1867_size(pd[cur_offset]));
|
1999-11-07 21:00:40 +00:00
|
|
|
cur_offset++;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Latitude: %s",
|
1999-10-07 07:44:29 +00:00
|
|
|
rfc1867_angle(&pd[cur_offset], "NS"));
|
1999-11-07 21:00:40 +00:00
|
|
|
cur_offset += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Longitude: %s",
|
1999-10-07 07:44:29 +00:00
|
|
|
rfc1867_angle(&pd[cur_offset], "EW"));
|
1999-11-07 21:00:40 +00:00
|
|
|
cur_offset += 4;
|
1999-10-07 07:44:29 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 4, "Altitude: %g m",
|
1999-10-07 07:44:29 +00:00
|
|
|
(pntohl(&pd[cur_offset]) - 10000000)/100.0);
|
1999-11-07 21:00:40 +00:00
|
|
|
} else
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, data_len, "Data");
|
|
|
|
}
|
1999-09-21 07:15:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1999-03-22 23:31:05 +00:00
|
|
|
|
1999-11-27 08:59:28 +00:00
|
|
|
case T_NXT:
|
|
|
|
{
|
|
|
|
int rr_len = data_len;
|
|
|
|
char next_domain_name[MAXDNAME];
|
|
|
|
int next_domain_name_len;
|
|
|
|
int rr_type;
|
|
|
|
guint8 bits;
|
|
|
|
int mask;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
next_domain_name_len = get_dns_name(pd, cur_offset, dns_data_offset,
|
|
|
|
next_domain_name, sizeof(next_domain_name));
|
2000-03-21 06:21:37 +00:00
|
|
|
if (next_domain_name_len < 0) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s, <Next domain name goes past end of captured data in packet>",
|
|
|
|
name, type_name, class_name);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-27 08:59:28 +00:00
|
|
|
if (fd != NULL)
|
2000-03-21 06:21:37 +00:00
|
|
|
col_append_fstr(fd, COL_INFO, " %s", next_domain_name);
|
1999-11-27 08:59:28 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr, "%s: type %s, class %s, next domain name %s",
|
1999-11-27 08:59:28 +00:00
|
|
|
name, type_name, class_name, next_domain_name);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, next_domain_name_len,
|
|
|
|
"Next domain name: %s", next_domain_name);
|
|
|
|
cur_offset += next_domain_name_len;
|
|
|
|
rr_len -= next_domain_name_len;
|
|
|
|
rr_type = 0;
|
|
|
|
while (rr_len != 0) {
|
2000-03-21 06:21:37 +00:00
|
|
|
if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
|
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, END_OF_FRAME,
|
|
|
|
"<Bit map goes past end of captured data in packet>");
|
|
|
|
return 0;
|
|
|
|
}
|
1999-11-27 08:59:28 +00:00
|
|
|
bits = pd[cur_offset];
|
2000-03-21 06:21:37 +00:00
|
|
|
mask = 1<<7;
|
1999-11-27 08:59:28 +00:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
if (bits & mask) {
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, 1,
|
|
|
|
"RR type in bit map: %s (%s)",
|
|
|
|
dns_type_name(rr_type),
|
|
|
|
dns_long_type_name(rr_type));
|
|
|
|
}
|
|
|
|
mask >>= 1;
|
|
|
|
rr_type++;
|
|
|
|
}
|
|
|
|
cur_offset += 1;
|
|
|
|
rr_len -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2000-03-30 01:33:10 +00:00
|
|
|
case T_OPT:
|
|
|
|
if (dns_tree != NULL) {
|
|
|
|
proto_item_set_text(trr, "%s: type %s", name, type_name);
|
|
|
|
proto_tree_add_text(rr_tree, cur_offset, data_len, "Data");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-03-22 23:31:05 +00:00
|
|
|
/* TODO: parse more record types */
|
|
|
|
|
1998-10-14 19:35:00 +00:00
|
|
|
default:
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree != NULL) {
|
2000-03-21 06:21:37 +00:00
|
|
|
proto_item_set_text(trr,
|
|
|
|
"%s: type %s, class %s", name, type_name, class_name);
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree_add_text(rr_tree, cur_offset, data_len, "Data");
|
|
|
|
}
|
1999-11-27 08:59:28 +00:00
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
1998-10-14 19:35:00 +00:00
|
|
|
dptr += data_len;
|
|
|
|
|
|
|
|
return dptr - data_start;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-10-07 07:44:29 +00:00
|
|
|
dissect_query_records(const u_char *pd, int cur_off, int dns_data_offset,
|
1999-11-07 21:00:40 +00:00
|
|
|
int count, frame_data *fd, proto_tree *dns_tree)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
1999-10-07 02:26:45 +00:00
|
|
|
int start_off, add_off;
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree *qatree = NULL;
|
|
|
|
proto_item *ti = NULL;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
start_off = cur_off;
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree) {
|
|
|
|
ti = proto_tree_add_text(dns_tree, start_off, 0, "Queries");
|
1999-11-16 11:44:20 +00:00
|
|
|
qatree = proto_item_add_subtree(ti, ett_dns_qry);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-10-07 02:26:45 +00:00
|
|
|
while (count-- > 0) {
|
1999-11-07 21:00:40 +00:00
|
|
|
add_off = dissect_dns_query(pd, cur_off, dns_data_offset, fd, qatree);
|
1999-10-07 02:26:45 +00:00
|
|
|
if (add_off <= 0) {
|
1999-10-07 07:44:29 +00:00
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
break;
|
1999-10-07 02:26:45 +00:00
|
|
|
}
|
|
|
|
cur_off += add_off;
|
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
if (ti)
|
|
|
|
proto_item_set_len(ti, cur_off - start_off);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
return cur_off - start_off;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-10-07 07:44:29 +00:00
|
|
|
dissect_answer_records(const u_char *pd, int cur_off, int dns_data_offset,
|
1999-11-07 21:00:40 +00:00
|
|
|
int count, frame_data *fd, proto_tree *dns_tree, char *name)
|
1998-09-16 02:39:15 +00:00
|
|
|
{
|
1999-10-07 02:26:45 +00:00
|
|
|
int start_off, add_off;
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree *qatree = NULL;
|
|
|
|
proto_item *ti = NULL;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
start_off = cur_off;
|
1999-11-07 21:00:40 +00:00
|
|
|
if (dns_tree) {
|
|
|
|
ti = proto_tree_add_text(dns_tree, start_off, 0, name);
|
1999-11-16 11:44:20 +00:00
|
|
|
qatree = proto_item_add_subtree(ti, ett_dns_ans);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1999-10-07 02:26:45 +00:00
|
|
|
while (count-- > 0) {
|
1999-11-07 21:00:40 +00:00
|
|
|
add_off = dissect_dns_answer(pd, cur_off, dns_data_offset, fd, qatree);
|
1999-10-07 02:26:45 +00:00
|
|
|
if (add_off <= 0) {
|
1999-10-07 07:44:29 +00:00
|
|
|
/* We ran past the end of the captured data in the packet. */
|
|
|
|
break;
|
1999-10-07 02:26:45 +00:00
|
|
|
}
|
|
|
|
cur_off += add_off;
|
|
|
|
}
|
1999-11-07 21:00:40 +00:00
|
|
|
if (ti)
|
|
|
|
proto_item_set_len(ti, cur_off - start_off);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
return cur_off - start_off;
|
|
|
|
}
|
|
|
|
|
2000-04-04 06:17:30 +00:00
|
|
|
static void
|
1999-10-07 07:44:29 +00:00
|
|
|
dissect_dns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
|
|
|
{
|
|
|
|
int dns_data_offset;
|
1999-11-07 21:00:40 +00:00
|
|
|
proto_tree *dns_tree = NULL, *field_tree;
|
1999-03-23 03:14:46 +00:00
|
|
|
proto_item *ti, *tf;
|
1998-09-16 02:39:15 +00:00
|
|
|
guint16 id, flags, quest, ans, auth, add;
|
1999-01-04 09:13:46 +00:00
|
|
|
char buf[128+1];
|
1998-09-16 02:39:15 +00:00
|
|
|
int cur_off;
|
1999-01-04 09:13:46 +00:00
|
|
|
static const value_string opcode_vals[] = {
|
|
|
|
{ OPCODE_QUERY, "Standard query" },
|
|
|
|
{ OPCODE_IQUERY, "Inverse query" },
|
|
|
|
{ OPCODE_STATUS, "Server status request" },
|
|
|
|
{ 0, NULL } };
|
|
|
|
static const value_string rcode_vals[] = {
|
|
|
|
{ RCODE_NOERROR, "No error" },
|
|
|
|
{ RCODE_FMTERROR, "Format error" },
|
|
|
|
{ RCODE_SERVFAIL, "Server failure" },
|
|
|
|
{ RCODE_NAMEERROR, "Name error" },
|
|
|
|
{ RCODE_NOTIMPL, "Not implemented" },
|
|
|
|
{ RCODE_REFUSED, "Refused" },
|
|
|
|
{ 0, NULL } };
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
dns_data_offset = offset;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-10-07 07:44:29 +00:00
|
|
|
if (check_col(fd, COL_PROTOCOL))
|
1999-12-29 10:36:13 +00:00
|
|
|
col_add_str(fd, COL_PROTOCOL, "DNS");
|
1999-10-07 07:44:29 +00:00
|
|
|
|
|
|
|
if (pi.captured_len < DNS_HDRLEN) {
|
|
|
|
col_add_str(fd, COL_INFO, "Short DNS packet");
|
|
|
|
dissect_data(pd, offset, fd, tree);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* To do: check for errs, etc. */
|
1999-01-04 09:13:46 +00:00
|
|
|
id = pntohs(&pd[offset + DNS_ID]);
|
|
|
|
flags = pntohs(&pd[offset + DNS_FLAGS]);
|
|
|
|
quest = pntohs(&pd[offset + DNS_QUEST]);
|
|
|
|
ans = pntohs(&pd[offset + DNS_ANS]);
|
|
|
|
auth = pntohs(&pd[offset + DNS_AUTH]);
|
|
|
|
add = pntohs(&pd[offset + DNS_ADD]);
|
1999-11-07 21:00:40 +00:00
|
|
|
|
1999-01-04 09:13:46 +00:00
|
|
|
if (check_col(fd, COL_INFO)) {
|
1999-12-29 10:36:13 +00:00
|
|
|
strcpy(buf, val_to_str(flags & F_OPCODE, opcode_vals, "Unknown operation (%x)"));
|
|
|
|
if (flags & F_RESPONSE) {
|
|
|
|
strcat(buf, " response");
|
|
|
|
if ((flags & F_RCODE) != RCODE_NOERROR) {
|
|
|
|
strcat(buf, ", ");
|
|
|
|
strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
|
|
|
|
"Unknown error (%x)"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
col_add_str(fd, COL_INFO, buf);
|
1999-11-07 21:00:40 +00:00
|
|
|
} else {
|
|
|
|
/* Set "fd" to NULL; we pass a NULL "fd" to the query and answer
|
|
|
|
dissectors, as a way of saying that they shouldn't add stuff
|
|
|
|
to the COL_INFO column (a call to "check_col(fd, COL_INFO)"
|
|
|
|
is more expensive than a check that a pointer isn't NULL). */
|
|
|
|
fd = NULL;
|
1999-01-04 09:13:46 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2000-03-12 04:48:32 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_dns, offset, 4,
|
1999-12-07 00:22:11 +00:00
|
|
|
"Domain Name System (%s)", (flags & F_RESPONSE) ? "response" : "query");
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
dns_tree = proto_item_add_subtree(ti, ett_dns);
|
1999-10-16 15:08:11 +00:00
|
|
|
|
|
|
|
if (flags & F_RESPONSE)
|
|
|
|
proto_tree_add_item_hidden(dns_tree, hf_dns_response, offset, 4, 1);
|
|
|
|
else
|
|
|
|
proto_tree_add_item_hidden(dns_tree, hf_dns_query, offset, 4, 1);
|
|
|
|
|
|
|
|
proto_tree_add_item(dns_tree, hf_dns_transaction_id,
|
|
|
|
offset + DNS_ID, 2, id);
|
1999-01-04 09:13:46 +00:00
|
|
|
|
1999-01-05 09:01:42 +00:00
|
|
|
strcpy(buf, val_to_str(flags & F_OPCODE, opcode_vals, "Unknown operation"));
|
1999-01-04 09:13:46 +00:00
|
|
|
if (flags & F_RESPONSE) {
|
|
|
|
strcat(buf, " response");
|
|
|
|
strcat(buf, ", ");
|
|
|
|
strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
|
1999-01-05 09:01:42 +00:00
|
|
|
"Unknown error"));
|
1999-01-04 09:13:46 +00:00
|
|
|
}
|
2000-03-12 04:48:32 +00:00
|
|
|
tf = proto_tree_add_uint_format(dns_tree, hf_dns_flags,
|
1999-10-16 15:08:11 +00:00
|
|
|
offset + DNS_FLAGS, 2,
|
|
|
|
flags,
|
|
|
|
"Flags: 0x%04x (%s)",
|
|
|
|
flags, buf);
|
1999-11-16 11:44:20 +00:00
|
|
|
field_tree = proto_item_add_subtree(tf, ett_dns_flags);
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_boolean_bitfield(flags, F_RESPONSE,
|
|
|
|
2*8, "Response", "Query"));
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_enumerated_bitfield(flags, F_OPCODE,
|
|
|
|
2*8, opcode_vals, "%s"));
|
|
|
|
if (flags & F_RESPONSE) {
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_boolean_bitfield(flags, F_AUTHORITATIVE,
|
|
|
|
2*8,
|
|
|
|
"Server is an authority for domain",
|
|
|
|
"Server isn't an authority for domain"));
|
|
|
|
}
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_boolean_bitfield(flags, F_TRUNCATED,
|
|
|
|
2*8,
|
|
|
|
"Message is truncated",
|
|
|
|
"Message is not truncated"));
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_boolean_bitfield(flags, F_RECDESIRED,
|
|
|
|
2*8,
|
|
|
|
"Do query recursively",
|
|
|
|
"Don't do query recursively"));
|
|
|
|
if (flags & F_RESPONSE) {
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_boolean_bitfield(flags, F_RECAVAIL,
|
|
|
|
2*8,
|
|
|
|
"Server can do recursive queries",
|
|
|
|
"Server can't do recursive queries"));
|
2000-04-26 12:01:50 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, F_AUTHENTIC,
|
|
|
|
2*8,
|
|
|
|
"Answer/authority portion was autenticated by the server",
|
|
|
|
"Answer/authority portion was not autenticated by the server"));
|
|
|
|
}
|
|
|
|
if ((flags & F_RESPONSE) == 0) {
|
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
|
|
|
decode_boolean_bitfield(flags, F_CHECKDISABLE,
|
|
|
|
2*8,
|
|
|
|
"Non-authenticated data is acceptable",
|
|
|
|
"Non-authenticated data is unacceptable"));
|
|
|
|
}
|
|
|
|
if (flags & F_RESPONSE) {
|
1999-07-07 22:52:57 +00:00
|
|
|
proto_tree_add_text(field_tree, offset + DNS_FLAGS, 2, "%s",
|
1999-01-04 09:13:46 +00:00
|
|
|
decode_enumerated_bitfield(flags, F_RCODE,
|
|
|
|
2*8, rcode_vals, "%s"));
|
|
|
|
}
|
1999-10-16 15:08:11 +00:00
|
|
|
proto_tree_add_item(dns_tree, hf_dns_count_questions,
|
|
|
|
offset + DNS_QUEST, 2, quest);
|
|
|
|
proto_tree_add_item(dns_tree, hf_dns_count_answers,
|
|
|
|
offset + DNS_ANS, 2, ans);
|
|
|
|
proto_tree_add_item(dns_tree, hf_dns_count_auth_rr,
|
|
|
|
offset + DNS_AUTH, 2, auth);
|
|
|
|
proto_tree_add_item(dns_tree, hf_dns_count_add_rr,
|
|
|
|
offset + DNS_ADD, 2, add);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
|
|
|
cur_off = offset + DNS_HDRLEN;
|
|
|
|
|
|
|
|
if (quest > 0) {
|
|
|
|
/* If this is a response, don't add information about the queries
|
|
|
|
to the summary, just add information about the answers. */
|
|
|
|
cur_off += dissect_query_records(pd, cur_off, dns_data_offset, quest,
|
|
|
|
(!(flags & F_RESPONSE) ? fd : NULL),
|
1998-10-14 19:35:00 +00:00
|
|
|
dns_tree);
|
1999-11-07 21:00:40 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (ans > 0) {
|
|
|
|
/* If this is a request, don't add information about the answers
|
|
|
|
to the summary, just add information about the queries. */
|
|
|
|
cur_off += dissect_answer_records(pd, cur_off, dns_data_offset, ans,
|
|
|
|
((flags & F_RESPONSE) ? fd : NULL),
|
|
|
|
dns_tree, "Answers");
|
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-11-07 21:00:40 +00:00
|
|
|
if (tree) {
|
|
|
|
/* Don't add information about the authoritative name servers, or the
|
|
|
|
additional records, to the summary. */
|
1998-09-16 02:39:15 +00:00
|
|
|
if (auth > 0)
|
1999-10-07 07:44:29 +00:00
|
|
|
cur_off += dissect_answer_records(pd, cur_off, dns_data_offset, auth,
|
1999-11-07 21:00:40 +00:00
|
|
|
NULL, dns_tree, "Authoritative nameservers");
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
if (add > 0)
|
1999-10-07 07:44:29 +00:00
|
|
|
cur_off += dissect_answer_records(pd, cur_off, dns_data_offset, add,
|
1999-11-07 21:00:40 +00:00
|
|
|
NULL, dns_tree, "Additional records");
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
1999-07-29 05:47:07 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_dns(void)
|
|
|
|
{
|
1999-10-16 15:08:11 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_dns_response,
|
|
|
|
{ "Response", "dns.response",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"TRUE if DNS response" }},
|
|
|
|
{ &hf_dns_query,
|
|
|
|
{ "Query", "dns.query",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"TRUE if DNS query" }},
|
|
|
|
{ &hf_dns_flags,
|
|
|
|
{ "Flags", "dns.flags",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x0,
|
|
|
|
"" }},
|
|
|
|
{ &hf_dns_transaction_id,
|
|
|
|
{ "Transaction ID", "dns.id",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x0,
|
|
|
|
"Identification of transaction" }},
|
|
|
|
{ &hf_dns_count_questions,
|
|
|
|
{ "Questions", "dns.count.queries",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Number of queries in packet" }},
|
|
|
|
{ &hf_dns_count_answers,
|
|
|
|
{ "Answer RRs", "dns.count.answers",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Number of answers in packet" }},
|
|
|
|
{ &hf_dns_count_auth_rr,
|
|
|
|
{ "Authority RRs", "dns.count.auth_rr",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Number of authoritative records in packet" }},
|
|
|
|
{ &hf_dns_count_add_rr,
|
|
|
|
{ "Additional RRs", "dns.count.add_rr",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Number of additional records in packet" }}
|
|
|
|
};
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_dns,
|
|
|
|
&ett_dns_qd,
|
|
|
|
&ett_dns_rr,
|
|
|
|
&ett_dns_qry,
|
|
|
|
&ett_dns_ans,
|
|
|
|
&ett_dns_flags,
|
1999-11-27 08:59:28 +00:00
|
|
|
&ett_t_key_flags,
|
1999-11-16 11:44:20 +00:00
|
|
|
};
|
1999-10-16 15:08:11 +00:00
|
|
|
|
|
|
|
proto_dns = proto_register_protocol("Domain Name Service", "dns");
|
|
|
|
proto_register_field_array(proto_dns, hf, array_length(hf));
|
1999-11-16 11:44:20 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
1999-07-29 05:47:07 +00:00
|
|
|
}
|
2000-04-04 06:17:30 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_dns(void)
|
|
|
|
{
|
|
|
|
dissector_add("udp.port", UDP_PORT_DNS, dissect_dns);
|
|
|
|
}
|