]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-bootp.c
DHCP: Fix a comment about formats for (un)signed longs/shorts data
[tcpdump] / print-bootp.c
index f84b77cad25dcabf0a3026dae193f943e8edde8d..d84ba6f8b48f8cc6fea36eeceb13733c20eefb57 100644 (file)
@@ -21,9 +21,7 @@
 
 /* \summary: BOOTP and IPv4 DHCP printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -147,7 +145,7 @@ struct bootp {
 #define        TAG_NIS_P_DOMAIN        ((uint8_t)  64)
 #define        TAG_NIS_P_SERVERS       ((uint8_t)  65)
 #define        TAG_MOBILE_HOME         ((uint8_t)  68)
-#define        TAG_SMPT_SERVER         ((uint8_t)  69)
+#define        TAG_SMTP_SERVER         ((uint8_t)  69)
 #define        TAG_POP3_SERVER         ((uint8_t)  70)
 #define        TAG_NNTP_SERVER         ((uint8_t)  71)
 #define        TAG_WWW_SERVER          ((uint8_t)  72)
@@ -193,6 +191,8 @@ struct bootp {
 /* RFC 3442 */
 #define TAG_CLASSLESS_STATIC_RT        ((uint8_t) 121)
 #define TAG_CLASSLESS_STA_RT_MS        ((uint8_t) 249)
+/* RFC8572 */
+#define TAG_SZTP_REDIRECT      ((uint8_t) 143)
 /* RFC 5859 - TFTP Server Address Option for DHCPv4 */
 #define        TAG_TFTP_SERVER_ADDRESS ((uint8_t) 150)
 /* https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml */
@@ -210,8 +210,8 @@ struct bootp {
 #define        TAG_CLIENT_GUID         ((uint8_t)  97)
 #define        TAG_LDAP_URL            ((uint8_t)  95)
 /* RFC 4833, TZ codes */
-#define        TAG_TZ_PCODE            ((uint8_t) 100)
-#define        TAG_TZ_TCODE            ((uint8_t) 101)
+#define        TAG_TZ_PCODE            ((uint8_t) 100)
+#define        TAG_TZ_TCODE            ((uint8_t) 101)
 #define        TAG_NETINFO_PARENT      ((uint8_t) 112)
 #define        TAG_NETINFO_PARENT_TAG  ((uint8_t) 113)
 #define        TAG_URL                 ((uint8_t) 114)
@@ -394,9 +394,9 @@ trunc:
  * The first character specifies the format to print:
  *     i - ip address (32 bits)
  *     p - ip address pairs (32 bits + 32 bits)
- *     l - long (32 bits)
- *     L - unsigned long (32 bits)
- *     s - short (16 bits)
+ *     l - unsigned longs (32 bits)
+ *     L - longs (32 bits)
+ *     s - unsigned shorts (16 bits)
  *     b - period-separated decimal bytes (variable length)
  *     x - colon-separated hex bytes (variable length)
  *     a - ASCII string (variable length)
@@ -461,7 +461,7 @@ static const struct tok tag2str[] = {
        { TAG_NIS_P_DOMAIN,     "sN+D" },
        { TAG_NIS_P_SERVERS,    "iN+S" },
        { TAG_MOBILE_HOME,      "iMH" },
-       { TAG_SMPT_SERVER,      "iSMTP" },
+       { TAG_SMTP_SERVER,      "iSMTP" },
        { TAG_POP3_SERVER,      "iPOP3" },
        { TAG_NNTP_SERVER,      "iNNTP" },
        { TAG_WWW_SERVER,       "iWWW" },
@@ -499,6 +499,8 @@ static const struct tok tag2str[] = {
 /* RFC 3442 */
        { TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" },
        { TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" },
+/* RFC 8572 */
+       { TAG_SZTP_REDIRECT,    "$SZTP-Redirect" },
 /* RFC 5859 - TFTP Server Address Option for DHCPv4 */
        { TAG_TFTP_SERVER_ADDRESS, "iTFTP-Server-Address" },
 /* https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml#options */
@@ -515,8 +517,8 @@ static const struct tok tag2str[] = {
        { TAG_CLIENT_NDI,       "bNDI" },       /* XXX 'b' */
        { TAG_CLIENT_GUID,      "bGUID" },      /* XXX 'b' */
        { TAG_LDAP_URL,         "aLDAP" },
-       { TAG_TZ_PCODE,         "aPOSIX-TZ" },
-       { TAG_TZ_TCODE,         "aTZ-Name" },
+       { TAG_TZ_PCODE,         "aPOSIX-TZ" },
+       { TAG_TZ_TCODE,         "aTZ-Name" },
        { TAG_NETINFO_PARENT,   "iNI" },
        { TAG_NETINFO_PARENT_TAG, "aNITAG" },
        { TAG_URL,              "aURL" },
@@ -715,7 +717,7 @@ rfc1048_print(netdissect_options *ndo,
                        break;
 
                case 's':
-                       /* shorts */
+                       /* unsigned shorts */
                        while (len >= 2) {
                                if (!first)
                                        ND_PRINT(",");
@@ -999,6 +1001,41 @@ rfc1048_print(netdissect_options *ndo,
                                break;
                            }
 
+
+                       case TAG_SZTP_REDIRECT:
+                               /* as per https://datatracker.ietf.org/doc/html/rfc8572#section-8.3
+                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
+                                |        uri-length             |          URI                  |
+                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
+
+                                * uri-length: 2 octets long; specifies the length of the URI data.
+                                * URI: URI of the SZTP bootstrap server.
+                                */
+                               while (len >= 2) {
+                                       uint16_t suboptlen2;
+
+                                       suboptlen2 = GET_BE_U_2(bp);
+                                       bp += 2;
+                                       len -= 2;
+                                       ND_PRINT("\n\t      ");
+                                       ND_PRINT("length %u: ", suboptlen2);
+                                       if (len < suboptlen2) {
+                                               ND_PRINT("length goes past end of option");
+                                               bp += len;
+                                               len = 0;
+                                               break;
+                                       }
+                                       ND_PRINT("\"");
+                                       nd_printjn(ndo, bp, suboptlen2);
+                                       ND_PRINT("\"");
+                                       len -= suboptlen2;
+                                       bp += suboptlen2;
+                               }
+                               if (len != 0) {
+                                       ND_PRINT("[ERROR: length < 2 bytes]");
+                               }
+                               break;
+
                        default:
                                ND_PRINT("[unknown special tag %u, size %u]",
                                          tag, len);