2 * Routines for NetBIOS-over-TCP packet disassembly (the name dates back
3 * to when it had only NBNS)
4 * Gilbert Ramirez <gram@xiexie.org>
5 * Much stuff added by Guy Harris <guy@alum.mit.edu>
7 * $Id: packet-nbns.c,v 1.44 2000/08/07 03:20:53 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@zing.org>
11 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
42 #include "packet-dns.h"
43 #include "packet-netbios.h"
44 #include "packet-smb.h"
46 static int proto_nbns = -1;
47 static int hf_nbns_response = -1;
48 static int hf_nbns_query = -1;
49 static int hf_nbns_transaction_id = -1;
50 static int hf_nbns_count_questions = -1;
51 static int hf_nbns_count_answers = -1;
52 static int hf_nbns_count_auth_rr = -1;
53 static int hf_nbns_count_add_rr = -1;
55 static gint ett_nbns = -1;
56 static gint ett_nbns_qd = -1;
57 static gint ett_nbns_flags = -1;
58 static gint ett_nbns_nb_flags = -1;
59 static gint ett_nbns_name_flags = -1;
60 static gint ett_nbns_rr = -1;
61 static gint ett_nbns_qry = -1;
62 static gint ett_nbns_ans = -1;
64 static int proto_nbdgm = -1;
65 static int hf_nbdgm_type = -1;
66 static int hf_nbdgm_fragment = -1;
67 static int hf_nbdgm_first = -1;
68 static int hf_nbdgm_node_type = -1;
69 static int hf_nbdgm_datagram_id = -1;
70 static int hf_nbdgm_src_ip = -1;
71 static int hf_nbdgm_src_port = -1;
73 static gint ett_nbdgm = -1;
75 static int proto_nbss = -1;
76 static int hf_nbss_type = -1;
77 static int hf_nbss_flags = -1;
79 static gint ett_nbss = -1;
80 static gint ett_nbss_flags = -1;
82 /* See RFC 1001 and 1002 for information on the first three, and see
84 http://www.cifs.com/specs/draft-leach-cifs-v1-spec-01.txt
86 Appendix B, and various messages on the CIFS mailing list such as
88 http://discuss.microsoft.com/SCRIPTS/WA-MSD.EXE?A2=ind9811A&L=cifs&P=R386
90 for information on the fourth. */
91 #define UDP_PORT_NBNS 137
92 #define UDP_PORT_NBDGM 138
93 #define TCP_PORT_NBSS 139
94 #define TCP_PORT_CIFS 445
96 /* Packet structure taken from RFC 1002. See also RFC 1001.
97 * Opcode, flags, and rcode treated as "flags", similarly to DNS,
98 * to make it easier to lift the dissection code from "packet-dns.c". */
100 /* Offsets of fields in the NBNS header. */
108 /* Length of NBNS header. */
109 #define NBNS_HDRLEN 12
112 #define T_NB 32 /* NetBIOS name service RR */
113 #define T_NBSTAT 33 /* NetBIOS node status RR */
115 /* Bit fields in the flags */
116 #define F_RESPONSE (1<<15) /* packet is response */
117 #define F_OPCODE (0xF<<11) /* query opcode */
118 #define F_AUTHORITATIVE (1<<10) /* response is authoritative */
119 #define F_TRUNCATED (1<<9) /* response is truncated */
120 #define F_RECDESIRED (1<<8) /* recursion desired */
121 #define F_RECAVAIL (1<<7) /* recursion available */
122 #define F_BROADCAST (1<<4) /* broadcast/multicast packet */
123 #define F_RCODE (0xF<<0) /* reply code */
126 #define OPCODE_QUERY (0<<11) /* standard query */
127 #define OPCODE_REGISTRATION (5<<11) /* registration */
128 #define OPCODE_RELEASE (6<<11) /* release name */
129 #define OPCODE_WACK (7<<11) /* wait for acknowledgement */
130 #define OPCODE_REFRESH (8<<11) /* refresh registration */
131 #define OPCODE_REFRESHALT (9<<11) /* refresh registration (alternate opcode) */
132 #define OPCODE_MHREGISTRATION (15<<11) /* multi-homed registration */
135 #define RCODE_NOERROR (0<<0)
136 #define RCODE_FMTERROR (1<<0)
137 #define RCODE_SERVFAIL (2<<0)
138 #define RCODE_NAMEERROR (3<<0)
139 #define RCODE_NOTIMPL (4<<0)
140 #define RCODE_REFUSED (5<<0)
141 #define RCODE_ACTIVE (6<<0)
142 #define RCODE_CONFLICT (7<<0)
144 /* Values for the "NB_FLAGS" field of RR data. From RFC 1001 and 1002,
145 * except for NB_FLAGS_ONT_H_NODE, which was discovered by looking at
147 #define NB_FLAGS_ONT (3<<(15-2)) /* bits for node type */
148 #define NB_FLAGS_ONT_B_NODE (0<<(15-2)) /* B-mode node */
149 #define NB_FLAGS_ONT_P_NODE (1<<(15-2)) /* P-mode node */
150 #define NB_FLAGS_ONT_M_NODE (2<<(15-2)) /* M-mode node */
151 #define NB_FLAGS_ONT_H_NODE (3<<(15-2)) /* H-mode node */
153 #define NB_FLAGS_G (1<<(15-0)) /* group name */
155 /* Values for the "NAME_FLAGS" field of a NODE_NAME entry in T_NBSTAT
156 * RR data. From RFC 1001 and 1002, except for NAME_FLAGS_ONT_H_NODE,
157 * which was discovered by looking at packet traces. */
158 #define NAME_FLAGS_PRM (1<<(15-6)) /* name is permanent node name */
160 #define NAME_FLAGS_ACT (1<<(15-5)) /* name is active */
162 #define NAME_FLAGS_CNF (1<<(15-4)) /* name is in conflict */
164 #define NAME_FLAGS_DRG (1<<(15-3)) /* name is being deregistered */
166 #define NAME_FLAGS_ONT (3<<(15-2)) /* bits for node type */
167 #define NAME_FLAGS_ONT_B_NODE (0<<(15-2)) /* B-mode node */
168 #define NAME_FLAGS_ONT_P_NODE (1<<(15-2)) /* P-mode node */
169 #define NAME_FLAGS_ONT_M_NODE (2<<(15-2)) /* M-mode node */
171 #define NAME_FLAGS_G (1<<(15-0)) /* group name */
173 static const value_string opcode_vals[] = {
174 { OPCODE_QUERY, "Name query" },
175 { OPCODE_REGISTRATION, "Registration" },
176 { OPCODE_RELEASE, "Release" },
177 { OPCODE_WACK, "Wait for acknowledgment" },
178 { OPCODE_REFRESH, "Refresh" },
179 { OPCODE_REFRESHALT, "Refresh (alternate opcode)" },
180 { OPCODE_MHREGISTRATION, "Multi-homed registration" },
185 nbns_type_name (int type)
198 get_nbns_name(const u_char *pd, int offset, int nbns_data_offset,
199 char *name_ret, int *name_type_ret)
203 char nbname[NETBIOS_NAME_LEN];
204 char *pname, *pnbname, cname, cnbname;
207 name_len = get_dns_name(pd, offset, nbns_data_offset, name,
210 /* OK, now undo the first-level encoding. */
212 pnbname = &nbname[0];
214 /* Every two characters of the first level-encoded name
215 * turn into one character in the decoded name. */
218 break; /* no more characters */
220 break; /* scope ID follows */
221 if (cname < 'A' || cname > 'Z') {
224 "Illegal NetBIOS name (character not between A and Z in first-level encoding)");
228 cnbname = cname << 4;
232 if (cname == '\0' || cname == '.') {
233 /* No more characters in the name - but we're in
234 * the middle of a pair. Not legal. */
236 "Illegal NetBIOS name (odd number of bytes)");
239 if (cname < 'A' || cname > 'Z') {
242 "Illegal NetBIOS name (character not between A and Z in first-level encoding)");
249 /* Do we have room to store the character? */
250 if (pnbname < &nbname[NETBIOS_NAME_LEN]) {
251 /* Yes - store the character. */
255 /* We bump the pointer even if it's past the end of the
256 name, so we keep track of how long the name is. */
260 /* NetBIOS names are supposed to be exactly 16 bytes long. */
261 if (pnbname - nbname != NETBIOS_NAME_LEN) {
263 sprintf(nbname, "Illegal NetBIOS name (%ld bytes long)",
264 (long)(pnbname - nbname));
268 /* This one is; make its name printable. */
269 name_type = process_netbios_name(nbname, name_ret);
270 name_ret += strlen(name_ret);
271 sprintf(name_ret, "<%02x>", name_type);
274 /* We have a scope ID, starting at "pname"; append that to
275 * the decoded host name. */
276 strcpy(name_ret, pname);
278 if (name_type_ret != NULL)
279 *name_type_ret = name_type;
283 if (name_type_ret != NULL)
285 strcpy (name_ret, nbname);
291 get_nbns_name_type_class(const u_char *pd, int offset, int nbns_data_offset,
292 char *name_ret, int *name_len_ret, int *name_type_ret, int *type_ret,
299 name_len = get_nbns_name(pd, offset, nbns_data_offset, name_ret,
303 if (!BYTES_ARE_IN_FRAME(offset, 2)) {
304 /* We ran past the end of the captured data in the packet. */
307 type = pntohs(&pd[offset]);
310 if (!BYTES_ARE_IN_FRAME(offset, 2)) {
311 /* We ran past the end of the captured data in the packet. */
314 class = pntohs(&pd[offset]);
318 *name_len_ret = name_len;
324 add_name_and_type(proto_tree *tree, int offset, int len, char *tag,
325 char *name, int name_type)
327 if (name_type != -1) {
328 proto_tree_add_text(tree, NullTVB, offset, len, "%s: %s (%s)",
329 tag, name, netbios_name_type_descr(name_type));
331 proto_tree_add_text(tree, NullTVB, offset, len, "%s: %s",
337 dissect_nbns_query(const u_char *pd, int offset, int nbns_data_offset,
338 frame_data *fd, proto_tree *nbns_tree)
341 char name[(NETBIOS_NAME_LEN - 1)*4 + MAXDNAME];
349 const u_char *data_start;
353 data_start = dptr = pd + offset;
355 len = get_nbns_name_type_class(pd, offset, nbns_data_offset, name,
356 &name_len, &name_type, &type, &class);
358 /* We ran past the end of the data in the packet. */
363 type_name = nbns_type_name(type);
364 class_name = dns_class_name(class);
367 col_append_fstr(fd, COL_INFO, " %s %s", type_name, name);
368 if (nbns_tree != NULL) {
369 tq = proto_tree_add_text(nbns_tree, NullTVB, offset, len,
370 "%s: type %s, class %s", name, type_name, class_name);
371 q_tree = proto_item_add_subtree(tq, ett_nbns_qd);
373 add_name_and_type(q_tree, offset, name_len, "Name", name,
377 proto_tree_add_text(q_tree, NullTVB, offset, 2, "Type: %s", type_name);
380 proto_tree_add_text(q_tree, NullTVB, offset, 2, "Class: %s", class_name);
384 return dptr - data_start;
388 nbns_add_nbns_flags(proto_tree *nbns_tree, int offset, u_short flags,
392 proto_tree *field_tree;
394 static const value_string rcode_vals[] = {
395 { RCODE_NOERROR, "No error" },
396 { RCODE_FMTERROR, "Request was invalidly formatted" },
397 { RCODE_SERVFAIL, "Server failure" },
398 { RCODE_NAMEERROR, "Requested name does not exist" },
399 { RCODE_NOTIMPL, "Request is not implemented" },
400 { RCODE_REFUSED, "Request was refused" },
401 { RCODE_ACTIVE, "Name is owned by another node" },
402 { RCODE_CONFLICT, "Name is in conflict" },
406 strcpy(buf, val_to_str(flags & F_OPCODE, opcode_vals,
407 "Unknown operation"));
408 if (flags & F_RESPONSE && !is_wack) {
409 strcat(buf, " response");
411 strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
414 tf = proto_tree_add_text(nbns_tree, NullTVB, offset, 2,
415 "Flags: 0x%04x (%s)", flags, buf);
416 field_tree = proto_item_add_subtree(tf, ett_nbns_flags);
417 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
418 decode_boolean_bitfield(flags, F_RESPONSE,
419 2*8, "Response", "Query"));
420 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
421 decode_enumerated_bitfield(flags, F_OPCODE,
422 2*8, opcode_vals, "%s"));
423 if (flags & F_RESPONSE) {
424 proto_tree_add_text(field_tree, NullTVB, offset, 2,
426 decode_boolean_bitfield(flags, F_AUTHORITATIVE,
428 "Server is an authority for domain",
429 "Server isn't an authority for domain"));
431 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
432 decode_boolean_bitfield(flags, F_TRUNCATED,
434 "Message is truncated",
435 "Message is not truncated"));
436 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
437 decode_boolean_bitfield(flags, F_RECDESIRED,
439 "Do query recursively",
440 "Don't do query recursively"));
441 if (flags & F_RESPONSE) {
442 proto_tree_add_text(field_tree, NullTVB, offset, 2,
444 decode_boolean_bitfield(flags, F_RECAVAIL,
446 "Server can do recursive queries",
447 "Server can't do recursive queries"));
449 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
450 decode_boolean_bitfield(flags, F_BROADCAST,
453 "Not a broadcast packet"));
454 if (flags & F_RESPONSE && !is_wack) {
455 proto_tree_add_text(field_tree, NullTVB, offset, 2,
457 decode_enumerated_bitfield(flags, F_RCODE,
464 nbns_add_nb_flags(proto_tree *rr_tree, int offset, u_short flags)
467 proto_tree *field_tree;
469 static const value_string nb_flags_ont_vals[] = {
470 { NB_FLAGS_ONT_B_NODE, "B-node" },
471 { NB_FLAGS_ONT_P_NODE, "P-node" },
472 { NB_FLAGS_ONT_M_NODE, "M-node" },
473 { NB_FLAGS_ONT_H_NODE, "H-node" },
477 strcpy(buf, val_to_str(flags & NB_FLAGS_ONT, nb_flags_ont_vals,
480 if (flags & NB_FLAGS_G)
481 strcat(buf, "group");
483 strcat(buf, "unique");
484 tf = proto_tree_add_text(rr_tree, NullTVB, offset, 2, "Flags: 0x%x (%s)", flags,
486 field_tree = proto_item_add_subtree(tf, ett_nbns_nb_flags);
487 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
488 decode_boolean_bitfield(flags, NB_FLAGS_G,
492 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
493 decode_enumerated_bitfield(flags, NB_FLAGS_ONT,
494 2*8, nb_flags_ont_vals, "%s"));
498 nbns_add_name_flags(proto_tree *rr_tree, int offset, u_short flags)
501 proto_item *field_tree;
503 static const value_string name_flags_ont_vals[] = {
504 { NAME_FLAGS_ONT_B_NODE, "B-node" },
505 { NAME_FLAGS_ONT_P_NODE, "P-node" },
506 { NAME_FLAGS_ONT_M_NODE, "M-node" },
510 strcpy(buf, val_to_str(flags & NAME_FLAGS_ONT, name_flags_ont_vals,
513 if (flags & NAME_FLAGS_G)
514 strcat(buf, "group");
516 strcat(buf, "unique");
517 if (flags & NAME_FLAGS_DRG)
518 strcat(buf, ", being deregistered");
519 if (flags & NAME_FLAGS_CNF)
520 strcat(buf, ", in conflict");
521 if (flags & NAME_FLAGS_ACT)
522 strcat(buf, ", active");
523 if (flags & NAME_FLAGS_PRM)
524 strcat(buf, ", permanent node name");
525 tf = proto_tree_add_text(rr_tree, NullTVB, offset, 2, "Name flags: 0x%x (%s)",
527 field_tree = proto_item_add_subtree(tf, ett_nbns_name_flags);
528 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
529 decode_boolean_bitfield(flags, NAME_FLAGS_G,
533 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
534 decode_enumerated_bitfield(flags, NAME_FLAGS_ONT,
535 2*8, name_flags_ont_vals, "%s"));
536 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
537 decode_boolean_bitfield(flags, NAME_FLAGS_DRG,
539 "Name is being deregistered",
540 "Name is not being deregistered"));
541 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
542 decode_boolean_bitfield(flags, NAME_FLAGS_CNF,
544 "Name is in conflict",
545 "Name is not in conflict"));
546 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
547 decode_boolean_bitfield(flags, NAME_FLAGS_ACT,
550 "Name is not active"));
551 proto_tree_add_text(field_tree, NullTVB, offset, 2, "%s",
552 decode_boolean_bitfield(flags, NAME_FLAGS_PRM,
554 "Permanent node name",
555 "Not permanent node name"));
559 dissect_nbns_answer(const u_char *pd, int offset, int nbns_data_offset,
560 frame_data *fd, proto_tree *nbns_tree, int opcode)
563 char name[(NETBIOS_NAME_LEN - 1)*4 + MAXDNAME + 64];
572 const u_char *data_start;
578 char name_str[(NETBIOS_NAME_LEN - 1)*4 + 1];
580 char nbname[16+4+1]; /* 4 for [<last char>] */
583 data_start = dptr = pd + offset;
586 len = get_nbns_name_type_class(pd, offset, nbns_data_offset, name,
587 &name_len, &name_type, &type, &class);
589 /* We ran past the end of the data in the packet. */
595 type_name = nbns_type_name(type);
596 class_name = dns_class_name(class);
598 if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
599 /* We ran past the end of the captured data in the packet. */
606 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
607 /* We ran past the end of the captured data in the packet. */
610 data_len = pntohs(dptr);
615 case T_NB: /* "NB" record */
617 if (opcode != OPCODE_WACK) {
618 col_append_fstr(fd, COL_INFO, " %s %s",
619 type_name, ip_to_str((guint8 *)(dptr + 2)));
622 if (nbns_tree == NULL)
624 trr = proto_tree_add_text(nbns_tree, NullTVB, offset,
625 (dptr - data_start) + data_len,
626 "%s: type %s, class %s",
627 name, type_name, class_name);
629 strcat(name, netbios_name_type_descr(name_type));
631 rr_tree = add_rr_to_tree(trr, ett_nbns_rr, offset, name,
632 name_len, type_name, class_name, ttl, data_len);
633 while (data_len > 0) {
634 if (opcode == OPCODE_WACK) {
635 /* WACK response. This doesn't contain the
636 * same type of RR data as other T_NB
638 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
639 /* We ran past the end of the captured
640 data in the packet. */
644 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
645 data_len, "(incomplete entry)");
648 flags = pntohs(dptr);
650 nbns_add_nbns_flags(rr_tree, cur_offset,
655 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
656 /* We ran past the end of the captured
657 data in the packet. */
661 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
662 data_len, "(incomplete entry)");
665 flags = pntohs(dptr);
667 nbns_add_nb_flags(rr_tree, cur_offset, flags);
671 if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
672 /* We ran past the end of the captured
673 data in the packet. */
677 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
678 data_len, "(incomplete entry)");
681 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 4,
683 ip_to_str((guint8 *)dptr));
691 case T_NBSTAT: /* "NBSTAT" record */
693 col_append_fstr(fd, COL_INFO, " %s", type_name);
694 if (nbns_tree == NULL)
696 trr = proto_tree_add_text(nbns_tree, NullTVB, offset,
697 (dptr - data_start) + data_len,
698 "%s: type %s, class %s",
699 name, type_name, class_name);
700 rr_tree = add_rr_to_tree(trr, ett_nbns_rr, offset, name,
701 name_len, type_name, class_name, ttl, data_len);
702 if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
703 /* We ran past the end of the captured
704 data in the packet. */
708 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
709 data_len, "(incomplete entry)");
714 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
715 "Number of names: %u", num_names);
718 while (num_names != 0) {
719 if (!BYTES_ARE_IN_FRAME(cur_offset, NETBIOS_NAME_LEN)) {
720 /* We ran past the end of the captured
721 data in the packet. */
724 if (data_len < NETBIOS_NAME_LEN) {
725 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
726 data_len, "(incomplete entry)");
729 memcpy(nbname, dptr, NETBIOS_NAME_LEN);
730 dptr += NETBIOS_NAME_LEN;
731 name_type = process_netbios_name(nbname,
733 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
734 NETBIOS_NAME_LEN, "Name: %s<%02x> (%s)",
736 netbios_name_type_descr(name_type));
737 cur_offset += NETBIOS_NAME_LEN;
738 data_len -= NETBIOS_NAME_LEN;
740 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
741 /* We ran past the end of the captured
742 data in the packet. */
746 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
747 data_len, "(incomplete entry)");
750 name_flags = pntohs(dptr);
752 nbns_add_name_flags(rr_tree, cur_offset, name_flags);
759 if (!BYTES_ARE_IN_FRAME(cur_offset, 6)) {
760 /* We ran past the end of the captured
761 data in the packet. */
765 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
766 data_len, "(incomplete entry)");
769 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 6,
771 ether_to_str((guint8 *)dptr));
776 if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
777 /* We ran past the end of the captured
778 data in the packet. */
782 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
783 data_len, "(incomplete entry)");
786 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 1,
787 "Jumpers: 0x%x", *dptr);
792 if (!BYTES_ARE_IN_FRAME(cur_offset, 1)) {
793 /* We ran past the end of the captured
794 data in the packet. */
798 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
799 data_len, "(incomplete entry)");
802 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 1,
803 "Test result: 0x%x", *dptr);
808 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
809 /* We ran past the end of the captured
810 data in the packet. */
814 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
815 data_len, "(incomplete entry)");
818 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
819 "Version number: 0x%x", pntohs(dptr));
824 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
825 /* We ran past the end of the captured
826 data in the packet. */
830 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
831 data_len, "(incomplete entry)");
834 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
835 "Period of statistics: 0x%x", pntohs(dptr));
840 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
841 /* We ran past the end of the captured
842 data in the packet. */
846 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
847 data_len, "(incomplete entry)");
850 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
851 "Number of CRCs: %u", pntohs(dptr));
856 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
857 /* We ran past the end of the captured
858 data in the packet. */
862 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
863 data_len, "(incomplete entry)");
866 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
867 "Number of alignment errors: %u", pntohs(dptr));
872 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
873 /* We ran past the end of the captured
874 data in the packet. */
878 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
879 data_len, "(incomplete entry)");
882 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
883 "Number of collisions: %u", pntohs(dptr));
888 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
889 /* We ran past the end of the captured
890 data in the packet. */
894 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
895 data_len, "(incomplete entry)");
898 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
899 "Number of send aborts: %u", pntohs(dptr));
904 if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
905 /* We ran past the end of the captured
906 data in the packet. */
910 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
911 data_len, "(incomplete entry)");
914 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 4,
915 "Number of good sends: %u", pntohl(dptr));
920 if (!BYTES_ARE_IN_FRAME(cur_offset, 4)) {
921 /* We ran past the end of the captured
922 data in the packet. */
926 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
927 data_len, "(incomplete entry)");
930 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 4,
931 "Number of good receives: %u", pntohl(dptr));
936 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
937 /* We ran past the end of the captured
938 data in the packet. */
942 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
943 data_len, "(incomplete entry)");
946 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
947 "Number of retransmits: %u", pntohs(dptr));
952 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
953 /* We ran past the end of the captured
954 data in the packet. */
958 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
959 data_len, "(incomplete entry)");
962 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
963 "Number of no resource conditions: %u", pntohs(dptr));
968 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
969 /* We ran past the end of the captured
970 data in the packet. */
974 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
975 data_len, "(incomplete entry)");
978 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
979 "Number of command blocks: %u", pntohs(dptr));
984 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
985 /* We ran past the end of the captured
986 data in the packet. */
990 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
991 data_len, "(incomplete entry)");
994 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
995 "Number of pending sessions: %u", pntohs(dptr));
1000 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
1001 /* We ran past the end of the captured
1002 data in the packet. */
1006 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
1007 data_len, "(incomplete entry)");
1010 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
1011 "Max number of pending sessions: %u", pntohs(dptr));
1015 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
1016 /* We ran past the end of the captured
1017 data in the packet. */
1021 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
1022 data_len, "(incomplete entry)");
1025 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
1026 "Max total sessions possible: %u", pntohs(dptr));
1031 if (!BYTES_ARE_IN_FRAME(cur_offset, 2)) {
1032 /* We ran past the end of the captured
1033 data in the packet. */
1037 proto_tree_add_text(rr_tree, NullTVB, cur_offset,
1038 data_len, "(incomplete entry)");
1041 proto_tree_add_text(rr_tree, NullTVB, cur_offset, 2,
1042 "Session data packet size: %u", pntohs(dptr));
1051 col_append_fstr(fd, COL_INFO, " %s", type_name);
1052 if (nbns_tree == NULL)
1054 trr = proto_tree_add_text(nbns_tree, NullTVB, offset,
1055 (dptr - data_start) + data_len,
1056 "%s: type %s, class %s",
1057 name, type_name, class_name);
1058 rr_tree = add_rr_to_tree(trr, ett_nbns_rr, offset, name,
1059 name_len, type_name, class_name, ttl, data_len);
1060 proto_tree_add_text(rr_tree, NullTVB, cur_offset, data_len, "Data");
1065 return dptr - data_start;
1069 dissect_query_records(const u_char *pd, int cur_off, int nbns_data_offset,
1070 int count, frame_data *fd, proto_tree *nbns_tree)
1072 int start_off, add_off;
1073 proto_tree *qatree = NULL;
1074 proto_item *ti = NULL;
1076 start_off = cur_off;
1077 if (nbns_tree != NULL) {
1078 ti = proto_tree_add_text(nbns_tree, NullTVB, start_off, 0, "Queries");
1079 qatree = proto_item_add_subtree(ti, ett_nbns_qry);
1081 while (count-- > 0) {
1082 add_off = dissect_nbns_query(pd, cur_off, nbns_data_offset,
1085 /* We ran past the end of the captured data in the
1092 proto_item_set_len(ti, cur_off - start_off);
1094 return cur_off - start_off;
1100 dissect_answer_records(const u_char *pd, int cur_off, int nbns_data_offset,
1101 int count, frame_data *fd, proto_tree *nbns_tree, int opcode, char *name)
1103 int start_off, add_off;
1104 proto_tree *qatree = NULL;
1105 proto_item *ti = NULL;
1107 start_off = cur_off;
1108 if (nbns_tree != NULL) {
1109 ti = proto_tree_add_text(nbns_tree, NullTVB, start_off, 0, name);
1110 qatree = proto_item_add_subtree(ti, ett_nbns_ans);
1112 while (count-- > 0) {
1113 add_off = dissect_nbns_answer(pd, cur_off, nbns_data_offset,
1114 fd, qatree, opcode);
1116 /* We ran past the end of the captured data in the
1123 proto_item_set_len(ti, cur_off - start_off);
1124 return cur_off - start_off;
1128 dissect_nbns(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
1130 int nbns_data_offset;
1131 proto_tree *nbns_tree = NULL;
1133 guint16 id, flags, quest, ans, auth, add;
1136 nbns_data_offset = offset;
1138 if (check_col(fd, COL_PROTOCOL))
1139 col_add_str(fd, COL_PROTOCOL, "NBNS");
1141 if (pi.captured_len < NBNS_HDRLEN) {
1142 col_add_str(fd, COL_INFO, "Short NBNS packet");
1143 old_dissect_data(pd, offset, fd, tree);
1147 /* To do: check for runts, errs, etc. */
1148 id = pntohs(&pd[offset + NBNS_ID]);
1149 flags = pntohs(&pd[offset + NBNS_FLAGS]);
1150 quest = pntohs(&pd[offset + NBNS_QUEST]);
1151 ans = pntohs(&pd[offset + NBNS_ANS]);
1152 auth = pntohs(&pd[offset + NBNS_AUTH]);
1153 add = pntohs(&pd[offset + NBNS_ADD]);
1155 if (check_col(fd, COL_INFO)) {
1156 col_add_fstr(fd, COL_INFO, "%s%s",
1157 val_to_str(flags & F_OPCODE, opcode_vals,
1158 "Unknown operation (%x)"),
1159 (flags & F_RESPONSE) ? " response" : "");
1161 /* Set "fd" to NULL; we pass a NULL "fd" to the query and
1162 answer dissectors, as a way of saying that they shouldn't
1163 add stuff to the COL_INFO column (a call to
1164 "check_col(fd, COL_INFO)" is more expensive than a check
1165 that a pointer isn't NULL). */
1170 ti = proto_tree_add_item(tree, proto_nbns, NullTVB, offset, END_OF_FRAME, FALSE);
1171 nbns_tree = proto_item_add_subtree(ti, ett_nbns);
1173 if (flags & F_RESPONSE) {
1174 proto_tree_add_boolean_hidden(nbns_tree, hf_nbns_response, NullTVB,
1177 proto_tree_add_boolean_hidden(nbns_tree, hf_nbns_query, NullTVB,
1181 proto_tree_add_uint(nbns_tree, hf_nbns_transaction_id, NullTVB,
1182 offset + NBNS_ID, 2, id);
1184 nbns_add_nbns_flags(nbns_tree, offset + NBNS_FLAGS, flags, 0);
1185 proto_tree_add_uint(nbns_tree, hf_nbns_count_questions, NullTVB,
1186 offset + NBNS_QUEST, 2, quest);
1187 proto_tree_add_uint(nbns_tree, hf_nbns_count_answers, NullTVB,
1188 offset + NBNS_ANS, 2, ans);
1189 proto_tree_add_uint(nbns_tree, hf_nbns_count_auth_rr, NullTVB,
1190 offset + NBNS_AUTH, 2, auth);
1191 proto_tree_add_uint(nbns_tree, hf_nbns_count_add_rr, NullTVB,
1192 offset + NBNS_ADD, 2, add);
1195 cur_off = offset + NBNS_HDRLEN;
1198 /* If this is a response, don't add information about the
1199 queries to the summary, just add information about the
1201 cur_off += dissect_query_records(pd, cur_off,
1202 nbns_data_offset, quest,
1203 (!(flags & F_RESPONSE) ? fd : NULL), nbns_tree);
1207 /* If this is a request, don't add information about the
1208 answers to the summary, just add information about the
1210 cur_off += dissect_answer_records(pd, cur_off,
1211 nbns_data_offset, ans,
1212 ((flags & F_RESPONSE) ? fd : NULL), nbns_tree,
1213 flags & F_OPCODE, "Answers");
1217 /* Don't add information about the authoritative name
1218 servers, or the additional records, to the summary. */
1220 cur_off += dissect_answer_records(pd, cur_off,
1222 auth, NULL, nbns_tree,
1224 "Authoritative nameservers");
1227 cur_off += dissect_answer_records(pd, cur_off,
1229 add, NULL, nbns_tree,
1231 "Additional records");
1235 /* NetBIOS datagram packet, from RFC 1002, page 32 */
1236 struct nbdgm_header {
1247 /* For packets with data */
1251 /* For error packets */
1256 dissect_nbdgm(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
1258 proto_tree *nbdgm_tree = NULL;
1260 struct nbdgm_header header;
1263 int max_data = pi.captured_len - offset;
1267 "Direct_unique datagram",
1268 "Direct_group datagram",
1269 "Broadcast datagram",
1271 "Datagram query request",
1272 "Datagram positive query response",
1273 "Datagram negative query response"
1283 static value_string error_codes[] = {
1284 { 0x82, "Destination name not present" },
1285 { 0x83, "Invalid source name format" },
1286 { 0x84, "Invalid destination name format" },
1290 char *yesno[] = { "No", "Yes" };
1292 char name[(NETBIOS_NAME_LEN - 1)*4 + MAXDNAME];
1296 header.msg_type = pd[offset];
1298 flags = pd[offset+1];
1299 header.flags.more = flags & 1;
1300 header.flags.first = (flags & 2) >> 1;
1301 header.flags.node_type = (flags & 12) >> 2;
1303 header.dgm_id = pntohs(&pd[offset+2]);
1304 memcpy(&header.src_ip, &pd[offset+4], 4);
1305 header.src_port = pntohs(&pd[offset+8]);
1307 if (header.msg_type == 0x10 ||
1308 header.msg_type == 0x11 || header.msg_type == 0x12) {
1309 header.dgm_length = pntohs(&pd[offset+10]);
1310 header.pkt_offset = pntohs(&pd[offset+12]);
1312 else if (header.msg_type == 0x13) {
1313 header.error_code = pntohs(&pd[offset+10]);
1316 message_index = header.msg_type - 0x0f;
1317 if (message_index < 1 || message_index > 8) {
1321 if (check_col(fd, COL_PROTOCOL))
1322 col_add_str(fd, COL_PROTOCOL, "NBDS");
1323 if (check_col(fd, COL_INFO)) {
1324 col_add_fstr(fd, COL_INFO, "%s", message[message_index]);
1328 ti = proto_tree_add_item(tree, proto_nbdgm, NullTVB, offset, header.dgm_length, FALSE);
1329 nbdgm_tree = proto_item_add_subtree(ti, ett_nbdgm);
1331 proto_tree_add_uint_format(nbdgm_tree, hf_nbdgm_type, NullTVB,
1335 message[message_index]);
1336 proto_tree_add_boolean_format(nbdgm_tree, hf_nbdgm_fragment, NullTVB,
1339 "More fragments follow: %s",
1340 yesno[header.flags.more]);
1341 proto_tree_add_boolean_format(nbdgm_tree, hf_nbdgm_first, NullTVB,
1344 "This is first fragment: %s",
1345 yesno[header.flags.first]);
1346 proto_tree_add_uint_format(nbdgm_tree, hf_nbdgm_node_type, NullTVB,
1348 header.flags.node_type,
1350 node[header.flags.node_type]);
1352 proto_tree_add_uint(nbdgm_tree, hf_nbdgm_datagram_id, NullTVB,
1353 offset+2, 2, header.dgm_id);
1354 proto_tree_add_ipv4(nbdgm_tree, hf_nbdgm_src_ip, NullTVB,
1355 offset+4, 4, header.src_ip);
1356 proto_tree_add_uint(nbdgm_tree, hf_nbdgm_src_port, NullTVB,
1357 offset+8, 2, header.src_port);
1364 if (header.msg_type == 0x10 ||
1365 header.msg_type == 0x11 || header.msg_type == 0x12) {
1368 proto_tree_add_text(nbdgm_tree, NullTVB, offset, 2,
1369 "Datagram length: %d bytes", header.dgm_length);
1370 proto_tree_add_text(nbdgm_tree, NullTVB, offset+2, 2,
1371 "Packet offset: %d bytes", header.pkt_offset);
1378 len = get_nbns_name(pd, offset, offset, name, &name_type);
1381 add_name_and_type(nbdgm_tree, offset, len,
1382 "Source name", name, name_type);
1387 /* Destination name */
1388 len = get_nbns_name(pd, offset, offset, name, &name_type);
1391 add_name_and_type(nbdgm_tree, offset, len,
1392 "Destination name", name, name_type);
1397 /* here we can pass the packet off to the next protocol */
1398 dissect_smb(pd, offset, fd, tree, max_data);
1400 else if (header.msg_type == 0x13) {
1402 proto_tree_add_text(nbdgm_tree, NullTVB, offset, 1, "Error code: %s",
1403 val_to_str(header.error_code, error_codes, "Unknown (0x%x)"));
1406 else if (header.msg_type == 0x14 ||
1407 header.msg_type == 0x15 || header.msg_type == 0x16) {
1408 /* Destination name */
1409 len = get_nbns_name(pd, offset, offset, name, &name_type);
1412 add_name_and_type(nbdgm_tree, offset, len,
1413 "Destination name", name, name_type);
1419 * NetBIOS Session Service message types.
1421 #define SESSION_MESSAGE 0x00
1422 #define SESSION_REQUEST 0x81
1423 #define POSITIVE_SESSION_RESPONSE 0x82
1424 #define NEGATIVE_SESSION_RESPONSE 0x83
1425 #define RETARGET_SESSION_RESPONSE 0x84
1426 #define SESSION_KEEP_ALIVE 0x85
1428 static const value_string message_types[] = {
1429 { SESSION_MESSAGE, "Session message" },
1430 { SESSION_REQUEST, "Session request" },
1431 { POSITIVE_SESSION_RESPONSE, "Positive session response" },
1432 { NEGATIVE_SESSION_RESPONSE, "Negative session response" },
1433 { RETARGET_SESSION_RESPONSE, "Retarget session response" },
1434 { SESSION_KEEP_ALIVE, "Session keep-alive" },
1439 * NetBIOS Session Service flags.
1441 #define NBSS_FLAGS_E 0x1
1443 static const value_string error_codes[] = {
1444 { 0x80, "Not listening on called name" },
1445 { 0x81, "Not listening for called name" },
1446 { 0x82, "Called name not present" },
1447 { 0x83, "Called name present, but insufficient resources" },
1448 { 0x8F, "Unspecified error" },
1453 * Dissect a single NBSS packet (there may be more than one in a given
1456 * [ Hmmm, in my experience, I have never seen more than one NBSS in a
1457 * single segment, since they mostly contain SMBs which are essentially
1458 * a request response type protocol (RJS). ]
1460 * [ However, under heavy load with many requests multiplexed on one
1461 * session it is not unusual to see multiple requests in one TCP
1462 * segment. Unfortunately, in this case a single session message is
1463 * frequently split over multiple segments, which frustrates decoding
1467 dissect_nbss_packet(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int max_data, int is_cifs)
1469 proto_tree *nbss_tree = NULL;
1471 proto_tree *field_tree;
1477 char name[(NETBIOS_NAME_LEN - 1)*4 + MAXDNAME];
1480 msg_type = pd[offset];
1484 length = pntohl(&pd[offset]) & 0x00FFFFFF;
1486 flags = pd[offset + 1];
1487 length = pntohs(&pd[offset + 2]);
1488 if (flags & NBSS_FLAGS_E)
1493 ti = proto_tree_add_item(tree, proto_nbss, NullTVB, offset, length + 4, FALSE);
1494 nbss_tree = proto_item_add_subtree(ti, ett_nbss);
1496 proto_tree_add_uint_format(nbss_tree, hf_nbss_type, NullTVB,
1500 val_to_str(msg_type, message_types,
1508 proto_tree_add_text(nbss_tree, NullTVB, offset, 3, "Length: %u", length);
1513 tf = proto_tree_add_uint(nbss_tree, hf_nbss_flags, NullTVB, offset, 1, flags);
1514 field_tree = proto_item_add_subtree(tf, ett_nbss_flags);
1515 proto_tree_add_text(field_tree, NullTVB, offset, 1, "%s",
1516 decode_boolean_bitfield(flags, NBSS_FLAGS_E,
1517 8, "Add 65536 to length", "Add 0 to length"));
1522 proto_tree_add_text(nbss_tree, NullTVB, offset, 2, "Length: %u", length);
1530 case SESSION_REQUEST:
1531 len = get_nbns_name(pd, offset, offset, name, &name_type);
1533 add_name_and_type(nbss_tree, offset, len,
1534 "Called name", name, name_type);
1537 len = get_nbns_name(pd, offset, offset, name, &name_type);
1540 add_name_and_type(nbss_tree, offset, len,
1541 "Calling name", name, name_type);
1545 case NEGATIVE_SESSION_RESPONSE:
1547 proto_tree_add_text(nbss_tree, NullTVB, offset, 1,
1549 val_to_str(pd[offset], error_codes, "Unknown (%x)"));
1552 case RETARGET_SESSION_RESPONSE:
1554 proto_tree_add_text(nbss_tree, NullTVB, offset, 4,
1555 "Retarget IP address: %s",
1556 ip_to_str((guint8 *)&pd[offset]));
1561 proto_tree_add_text(nbss_tree, NullTVB, offset, 2,
1562 "Retarget port: %u", pntohs(&pd[offset]));
1566 case SESSION_MESSAGE:
1568 * Here we can pass the packet off to the next protocol.
1571 dissect_smb(pd, offset, fd, tree, max_data - 4);
1580 dissect_nbss(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
1589 msg_type = pd[offset];
1591 if (pi.match_port == TCP_PORT_CIFS) {
1593 * Windows 2000 CIFS clients can dispense completely
1594 * with the NETBIOS encapsulation and directly use CIFS
1595 * over TCP. As would be expected, the framing is
1596 * identical, except that the length is 24 bits instead
1597 * of 17. The only message types used are
1598 * SESSION_MESSAGE and SESSION_KEEP_ALIVE.
1601 length = pntohl(&pd[offset]) & 0x00FFFFFF;
1604 flags = pd[offset + 1];
1605 length = pntohs(&pd[offset + 2]);
1606 if (flags & NBSS_FLAGS_E)
1612 * XXX - we should set this based on both "pi.captured_len"
1615 max_data = pi.captured_len - offset;
1617 /* Hmmm, it may be a continuation message ... */
1621 if (((msg_type != SESSION_REQUEST) &&
1622 (msg_type != POSITIVE_SESSION_RESPONSE) &&
1623 (msg_type != NEGATIVE_SESSION_RESPONSE) &&
1624 (msg_type != RETARGET_SESSION_RESPONSE) &&
1625 (msg_type != SESSION_MESSAGE)) ||
1626 ((msg_type == SESSION_MESSAGE) &&
1627 (memcmp(pd + offset + 4, "\377SMB", 4) != 0))) {
1629 if (check_col(fd, COL_PROTOCOL))
1630 col_add_str(fd, COL_PROTOCOL, "NBSS");
1631 if (check_col(fd, COL_INFO)) {
1632 col_add_fstr(fd, COL_INFO, "NBSS Continuation Message");
1636 proto_tree_add_text(tree, NullTVB, offset, max_data, "Continuation data");
1642 if (check_col(fd, COL_PROTOCOL))
1643 col_add_str(fd, COL_PROTOCOL, "NBSS");
1644 if (check_col(fd, COL_INFO)) {
1645 col_add_fstr(fd, COL_INFO,
1646 val_to_str(msg_type, message_types, "Unknown (%x)"));
1649 while (max_data > 0) {
1650 len = dissect_nbss_packet(pd, offset, fd, tree, max_data, is_cifs);
1658 proto_register_nbt(void)
1661 static hf_register_info hf_nbns[] = {
1662 { &hf_nbns_response,
1663 { "Response", "nbns.response",
1664 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1665 "TRUE if NBNS response" }},
1667 { "Query", "nbns.query",
1668 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1669 "TRUE if NBNS query" }},
1670 { &hf_nbns_transaction_id,
1671 { "Transaction ID", "nbns.id",
1672 FT_UINT16, BASE_HEX, NULL, 0x0,
1673 "Identification of transaction" }},
1674 { &hf_nbns_count_questions,
1675 { "Questions", "nbns.count.queries",
1676 FT_UINT16, BASE_DEC, NULL, 0x0,
1677 "Number of queries in packet" }},
1678 { &hf_nbns_count_answers,
1679 { "Answer RRs", "nbns.count.answers",
1680 FT_UINT16, BASE_DEC, NULL, 0x0,
1681 "Number of answers in packet" }},
1682 { &hf_nbns_count_auth_rr,
1683 { "Authority RRs", "nbns.count.auth_rr",
1684 FT_UINT16, BASE_DEC, NULL, 0x0,
1685 "Number of authoritative records in packet" }},
1686 { &hf_nbns_count_add_rr,
1687 { "Additional RRs", "nbns.count.add_rr",
1688 FT_UINT16, BASE_DEC, NULL, 0x0,
1689 "Number of additional records in packet" }}
1692 static hf_register_info hf_nbdgm[] = {
1694 { "Message Type", "nbdgm.type",
1695 FT_UINT8, BASE_DEC, NULL, 0x0,
1696 "NBDGM message type" }},
1697 { &hf_nbdgm_fragment,
1698 { "Fragmented", "nbdgm.next",
1699 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1700 "TRUE if more fragments follow" }},
1702 { "First fragment", "nbdgm.first",
1703 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1704 "TRUE if first fragment" }},
1705 { &hf_nbdgm_node_type,
1706 { "Node Type", "nbdgm.node_type",
1707 FT_UINT8, BASE_DEC, NULL, 0x0,
1709 { &hf_nbdgm_datagram_id,
1710 { "Datagram ID", "nbdgm.dgram_id",
1711 FT_UINT16, BASE_HEX, NULL, 0x0,
1712 "Datagram identifier" }},
1714 { "Source IP", "nbdgm.src.ip",
1715 FT_IPv4, BASE_NONE, NULL, 0x0,
1716 "Source IPv4 address" }},
1717 { &hf_nbdgm_src_port,
1718 { "Source Port", "nbdgm.src.port",
1719 FT_UINT16, BASE_DEC, NULL, 0x0,
1723 static hf_register_info hf_nbss[] = {
1725 { "Message Type", "nbss.type",
1726 FT_UINT8, BASE_DEC, NULL, 0x0,
1727 "NBSS message type" }},
1729 { "Flags", "nbss.flags",
1730 FT_UINT8, BASE_HEX, NULL, 0x0,
1731 "NBSS message flags" }}
1733 static gint *ett[] = {
1738 &ett_nbns_name_flags,
1747 proto_nbns = proto_register_protocol("NetBIOS Name Service", "nbns");
1748 proto_register_field_array(proto_nbns, hf_nbns, array_length(hf_nbns));
1750 proto_nbdgm = proto_register_protocol("NetBIOS Datagram Service", "nbdgm");
1751 proto_register_field_array(proto_nbdgm, hf_nbdgm, array_length(hf_nbdgm));
1753 proto_nbss = proto_register_protocol("NetBIOS Session Service", "nbss");
1754 proto_register_field_array(proto_nbss, hf_nbss, array_length(hf_nbss));
1756 proto_register_subtree_array(ett, array_length(ett));
1760 proto_reg_handoff_nbt(void)
1762 old_dissector_add("udp.port", UDP_PORT_NBNS, dissect_nbns);
1763 old_dissector_add("udp.port", UDP_PORT_NBDGM, dissect_nbdgm);
1764 old_dissector_add("tcp.port", TCP_PORT_NBSS, dissect_nbss);
1765 old_dissector_add("tcp.port", TCP_PORT_CIFS, dissect_nbss);