tcpdump mailing list archives

print-bootp.c: better client fqdn option printing


From: Kevin Steves <stevesk () pobox com>
Date: Sun, 28 Jan 2007 10:27:54 -0800

I started looking at this because the minimum length check was
off by one.

0) fix off by one (4 vs. 3)
1) print flag bits
2) print rcode fields if either is non-zero

Index: bootp.h
===================================================================
RCS file: /tcpdump/master/tcpdump/bootp.h,v
retrieving revision 1.15
diff -u -r1.15 bootp.h
--- bootp.h     1 Jul 2003 19:16:06 -0000       1.15
+++ bootp.h     28 Jan 2007 18:22:30 -0000
@@ -218,3 +218,10 @@
 
 /* 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: print-bootp.c
===================================================================
RCS file: /tcpdump/master/tcpdump/print-bootp.c,v
retrieving revision 1.84
diff -u -r1.84 print-bootp.c
--- print-bootp.c       14 Jan 2007 22:40:40 -0000      1.84
+++ print-bootp.c       28 Jan 2007 18:22:30 -0000
@@ -42,6 +42,7 @@
 
 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 @@
                                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 @@
        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;
+}
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: