]> The Tcpdump Group git mirrors - tcpdump/commitdiff
From Kevin Steves: in the client FQDN option:
authorguy <guy>
Mon, 29 Jan 2007 20:55:01 +0000 (20:55 +0000)
committerguy <guy>
Mon, 29 Jan 2007 20:55:01 +0000 (20:55 +0000)
0) fix off by one (4 vs. 3)
1) print flag bits
2) print rcode fields if either is non-zero

bootp.h
print-bootp.c

diff --git a/bootp.h b/bootp.h
index d348379ba91394d6d2a1c523f0a8ea264b69d72d..0ef7a5835792904ea67156d5a8785fa1e74d41dc 100644 (file)
--- a/bootp.h
+++ b/bootp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.15 2003-07-01 19:16:06 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.16 2007-01-29 20:55:01 guy Exp $ (LBL) */
 /*
  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
  *
@@ -218,3 +218,10 @@ struct cmu_vend {
 
 /* v_flags values */
 #define VF_SMASK       1       /* Subnet mask field contains valid data */
+
+/* RFC 4702 DHCP Client FQDN Option */
+
+#define CLIENT_FQDN_FLAGS_S    0x01
+#define CLIENT_FQDN_FLAGS_O    0x02
+#define CLIENT_FQDN_FLAGS_E    0x04
+#define CLIENT_FQDN_FLAGS_N    0x08
index 3e53a6bf26a93db3a0e3521c75da7192da4c9de6..96b51756ca04cdf0768e7306c76070e85923d7cb 100644 (file)
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.84 2007-01-14 22:40:40 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.85 2007-01-29 20:55:01 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -42,6 +42,7 @@ static const char rcsid[] _U_ =
 
 static void rfc1048_print(const u_char *);
 static void cmu_print(const u_char *);
+static char *client_fqdn_flags(u_int flags);
 
 static char tstr[] = " [|bootp]";
 
@@ -586,15 +587,16 @@ rfc1048_print(register const u_char *bp)
                                break;
 
                        case TAG_CLIENT_FQDN:
-                               /* option 81 should be at least 4 bytes long */
-                               if (len < 4)  {
-                                        printf("ERROR: options 81 len %u < 4 bytes", len);
+                               /* option 81 should be at least 3 bytes long */
+                               if (len < 3)  {
+                                       printf("ERROR: option 81 len %u < 3 bytes", len);
                                        break;
                                }
-                               if (*bp++)
-                                       printf("[svrreg]");
                                if (*bp)
-                                       printf("%u/%u/", *bp, *(bp+1));
+                                       printf("[%s] ", client_fqdn_flags(*bp));
+                               bp++;
+                               if (*bp || *(bp+1))
+                                       printf("%u/%u ", *bp, *(bp+1));
                                bp += 2;
                                putchar('"');
                                if (fn_printn(bp, size - 3, snapend)) {
@@ -714,3 +716,22 @@ trunc:
        fputs(tstr, stdout);
 #undef PRINTCMUADDR
 }
+
+static char *
+client_fqdn_flags(u_int flags)
+{
+       static char buf[8+1];
+       int i = 0;
+
+       if (flags & CLIENT_FQDN_FLAGS_S)
+               buf[i++] = 'S';
+       if (flags & CLIENT_FQDN_FLAGS_O)
+               buf[i++] = 'O';
+       if (flags & CLIENT_FQDN_FLAGS_E)
+               buf[i++] = 'E';
+       if (flags & CLIENT_FQDN_FLAGS_N)
+               buf[i++] = 'N';
+       buf[i] = '\0';
+
+       return buf;
+}