+static void
+ip_printts(register const u_char *cp, u_int length)
+{
+ register u_int ptr = cp[2] - 1;
+ register u_int len = 0;
+ int hoplen;
+ char *type;
+
+ printf(" TS{");
+ hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
+ if ((length - 4) & (hoplen-1))
+ printf("[bad length %d]", length);
+ if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
+ printf("[bad ptr %d]", cp[2]);
+ switch (cp[3]&0xF) {
+ case IPOPT_TS_TSONLY:
+ printf("TSONLY");
+ break;
+ case IPOPT_TS_TSANDADDR:
+ printf("TS+ADDR");
+ break;
+ /*
+ * prespecified should really be 3, but some ones might send 2
+ * instead, and the IPOPT_TS_PRESPEC constant can apparently
+ * have both values, so we have to hard-code it here.
+ */
+
+ case 2:
+ printf("PRESPEC2.0");
+ break;
+ case 3: /* IPOPT_TS_PRESPEC */
+ printf("PRESPEC");
+ break;
+ default:
+ printf("[bad ts type %d]", cp[3]&0xF);
+ goto done;
+ }
+
+ type = " ";
+ for (len = 4; len < length; len += hoplen) {
+ if (ptr == len)
+ type = " ^ ";
+ printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
+ hoplen!=8 ? "" : ipaddr_string(&cp[len]));
+ type = " ";
+ }
+
+done:
+ printf("%s", ptr == len ? " ^ " : "");
+
+ if (cp[3]>>4)
+ printf(" [%d hops not recorded]} ", cp[3]>>4);
+ else
+ printf("}");
+}
+