Added better debug for what kind of netbios packet we got.
authorSamba Release Account <samba-bugs@samba.org>
Fri, 7 Mar 1997 17:28:41 +0000 (17:28 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Fri, 7 Mar 1997 17:28:41 +0000 (17:28 +0000)
jra@cygnus.com

source/libsmb/nmblib.c

index c70311f99787ab944a4cd4483056391e5ccbd37b..a0f93331d95f6dce8e04e66f2e5c33271201f820 100644 (file)
@@ -30,6 +30,34 @@ extern pstring scope;
 extern pstring myname;
 extern struct in_addr ipzero;
 
+static struct opcode_names {
+    const char *nmb_opcode_name;
+    int opcode;
+} nmb_header_opcode_names[] = {
+      { "Query",           0 },
+      {"Registration",      5 },
+      {"Release",           6 },
+      {"WACK",              7 },
+      {"refresh",           8 },
+      {0, -1 }
+};
+
+/****************************************************************************
+ * Lookup a nmb opcode name.
+ ****************************************************************************/
+
+const char *lookup_opcode_name( int opcode )
+{
+  struct opcode_names *op_namep;
+  int i;
+
+  for(i = 0; nmb_header_opcode_names[i].nmb_opcode_name != 0; i++) {
+    op_namep = &nmb_header_opcode_names[i];
+    if(opcode == op_namep->opcode)
+      return op_namep->nmb_opcode_name;
+  }
+  return "<unknown opcode>";
+}
 
 /****************************************************************************
   print out a res_rec structure
@@ -79,9 +107,11 @@ void debug_nmb_packet(struct packet_struct *p)
 {
   struct nmb_packet *nmb = &p->packet.nmb;
   
-  DEBUG(4,("nmb packet from %s header: id=%d opcode=%d response=%s\n",
+  DEBUG(4,("nmb packet from %s header: id=%d opcode=%s(%d) response=%s\n",
           inet_ntoa(p->ip),
-          nmb->header.name_trn_id,nmb->header.opcode,BOOLSTR(nmb->header.response)));
+          nmb->header.name_trn_id,
+           lookup_opcode_name(nmb->header.opcode),
+           nmb->header.opcode,BOOLSTR(nmb->header.response)));
   DEBUG(4,("    header: flags: bcast=%s rec_avail=%s rec_des=%s trunc=%s auth=%s\n",
           BOOLSTR(nmb->header.nm_flags.bcast),
           BOOLSTR(nmb->header.nm_flags.recursion_available),