* Don't build wiretap if it isn't configured.
[obnox/wireshark/wip.git] / packet-nbns.c
index 90dbda7ee3db5b72c5145ef67544206f2e1b30a5..43be706505ed9e15c567ca956c51f3d3e5e0f253 100644 (file)
@@ -3,7 +3,7 @@
  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
  * Much stuff added by Guy Harris <guy@netapp.com>
  *
- * $Id: packet-nbns.c,v 1.2 1998/10/14 19:34:59 guy Exp $
+ * $Id: packet-nbns.c,v 1.7 1998/11/17 04:28:58 gerald Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -30,7 +30,6 @@
 #endif
 
 #include <gtk/gtk.h>
-#include <pcap.h>
 
 #include <stdio.h>
 #include <memory.h>
@@ -193,8 +192,8 @@ get_nbns_name_type_class(const u_char *nbns_data_ptr, const u_char *pd,
                /* This one is; canonicalize its name. */
                pnbname = canonicalize_netbios_name(nbname);
        } else {
-               sprintf(nbname, "Illegal NetBIOS name (%d bytes long)",
-                   pnbname - nbname);
+               sprintf(nbname, "Illegal NetBIOS name (%ld bytes long)",
+                   (long)(pnbname - nbname));
                goto bad;
        }
        if (cname == '.') {
@@ -230,6 +229,7 @@ dissect_nbns_query(const u_char *nbns_data_ptr, const u_char *pd, int offset,
        char *type_name;
        const u_char *dptr;
        const u_char *data_start;
+       GtkWidget *q_tree, *tq;
 
        data_start = dptr = pd + offset;
 
@@ -237,15 +237,21 @@ dissect_nbns_query(const u_char *nbns_data_ptr, const u_char *pd, int offset,
            &name_len, &type, &class);
        dptr += len;
 
-       add_item_to_tree(nbns_tree, offset, name_len, "Name: %s", name);
+       type_name = nbns_type_name(type);
+       class_name = dns_class_name(class);
+
+       tq = add_item_to_tree(nbns_tree, offset, len, "%s: type %s, class %s", 
+           name, type_name, class_name);
+       q_tree = gtk_tree_new();
+       add_subtree(tq, q_tree, ETT_NBNS_QD);
+
+       add_item_to_tree(q_tree, offset, name_len, "Name: %s", name);
        offset += name_len;
 
-       type_name = nbns_type_name(type);
-       add_item_to_tree(nbns_tree, offset, 2, "Type: %s", type_name);
+       add_item_to_tree(q_tree, offset, 2, "Type: %s", type_name);
        offset += 2;
 
-       class_name = dns_class_name(class);
-       add_item_to_tree(nbns_tree, offset, 2, "Class: %s", class_name);
+       add_item_to_tree(q_tree, offset, 2, "Class: %s", class_name);
        offset += 2;
        
        return dptr - data_start;
@@ -329,8 +335,8 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
                                        break;
                                }
                                add_item_to_tree(rr_tree, offset, 4,
-                                   "Addr: %d.%d.%d.%d",
-                                   *dptr, *(dptr+1), *(dptr+2), *(dptr+3));
+                                   "Addr: %s",
+                                   ip_to_str((guint8 *)dptr));
                                dptr += 4;
                                offset += 4;
                                data_len -= 4;
@@ -397,9 +403,8 @@ dissect_nbns_answer(const u_char *nbns_data_ptr, const u_char *pd, int offset,
                                break;
                        }
                        add_item_to_tree(rr_tree, offset, 6,
-                           "Unit ID: %02x:%02x:%02x:%02x:%02x:%02x",
-                           *dptr, *(dptr + 1), *(dptr + 2),
-                           *(dptr + 3), *(dptr + 4), *(dptr + 5));
+                           "Unit ID: %s",
+                           ether_to_str((guint8 *)dptr));
                        dptr += 6;
                        offset += 6;
                        data_len -= 6;
@@ -692,13 +697,14 @@ dissect_nbns(const u_char *pd, int offset, frame_data *fd, GtkTree *tree)
        header.nscount = pntohs(&pd[offset+8]);
        header.arcount = pntohs(&pd[offset+10]);
 
-       if (fd->win_info[COL_NUM]) {
-               strcpy(fd->win_info[COL_PROTOCOL], "NBNS (UDP)");
+       if (check_col(fd, COL_PROTOCOL))
+               col_add_str(fd, COL_PROTOCOL, "NBNS (UDP)");
+       if (check_col(fd, COL_INFO)) {
                if (header.opcode <= 15) {
-                       sprintf(fd->win_info[COL_INFO], "%s %s",
+                       col_add_fstr(fd, COL_INFO, "%s %s",
                            opcode[header.opcode], header.r ? "reply" : "request");
                } else {
-                       sprintf(fd->win_info[COL_INFO], "Unknown operation (%d) %s",
+                       col_add_fstr(fd, COL_INFO, "Unknown operation (%d) %s",
                            header.opcode, header.r ? "reply" : "request");
                }
        }