- len = len0; /* get the original length */
- if (off & 0x3fff) {
- /*
- * if this isn't the first frag, we're missing the
- * next level protocol header. print the ip addr.
- */
- if (off & 0x1fff)
- (void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
-#ifndef IP_MF
-#define IP_MF 0x2000
-#endif /* IP_MF */
-#ifndef IP_DF
-#define IP_DF 0x4000
-#endif /* IP_DF */
- (void)printf(" (frag %d:%u@%d%s)", ntohs(ip->ip_id), len,
- (off & 0x1fff) * 8,
- (off & IP_MF)? "+" : "");
-
- } else if (off & IP_DF)
- (void)printf(" (DF)");
-
- if (ip->ip_tos) {
- (void)printf(" [tos 0x%x", (int)ip->ip_tos);
- /* ECN bits */
- if (ip->ip_tos & 0x03) {
- switch (ip->ip_tos & 0x03) {
- case 1:
- (void)printf(",ECT(1)");
- break;
- case 2:
- (void)printf(",ECT(0)");
- break;
- case 3:
- (void)printf(",CE");
- }
+ ipend = bp + ipds->len;
+ if (ipend < ndo->ndo_snapend)
+ ndo->ndo_snapend = ipend;
+
+ ipds->len -= hlen;
+
+ ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
+
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "(tos 0x%x", (int)ipds->ip->ip_tos));
+ /* ECN bits */
+ if (ipds->ip->ip_tos & 0x03) {
+ switch (ipds->ip->ip_tos & 0x03) {
+ case 1:
+ ND_PRINT((ndo, ",ECT(1)"));
+ break;
+ case 2:
+ ND_PRINT((ndo, ",ECT(0)"));
+ break;
+ case 3:
+ ND_PRINT((ndo, ",CE"));
+ }
+ }
+
+ if (ipds->ip->ip_ttl >= 1)
+ ND_PRINT((ndo, ", ttl %u", ipds->ip->ip_ttl));
+
+ /*
+ * for the firewall guys, print id, offset.
+ * On all but the last stick a "+" in the flags portion.
+ * For unfragmented datagrams, note the don't fragment flag.
+ */
+
+ ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
+ EXTRACT_16BITS(&ipds->ip->ip_id),
+ (ipds->off & 0x1fff) * 8,
+ bittok2str(ip_frag_values, "none", ipds->off&0xe000),
+ tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
+ ipds->ip->ip_p));
+
+ ND_PRINT((ndo, ", length %u", EXTRACT_16BITS(&ipds->ip->ip_len)));
+
+ if ((hlen - sizeof(struct ip)) > 0) {
+ ND_PRINT((ndo, ", options ("));
+ ip_optprint(ndo, (const u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
+ ND_PRINT((ndo, ")"));
+ }
+
+ if (!ndo->ndo_Kflag && (const u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
+ vec[0].ptr = (const uint8_t *)(const void *)ipds->ip;
+ vec[0].len = hlen;
+ sum = in_cksum(vec, 1);
+ if (sum != 0) {
+ ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
+ ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
+ in_cksum_shouldbe(ip_sum, sum)));