+ case IPPROTO_VRRP:
+ vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+ break;
+
+ case IPPROTO_PGM:
+ pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ break;
+
+ default:
+ if ((proto = getprotobynumber(ipds->nh)) != NULL)
+ ND_PRINT((ndo, " %s", proto->p_name));
+ else
+ ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
+ ND_PRINT((ndo, " %d", ipds->len));
+ break;
+ }
+}
+
+void
+ip_print_inner(netdissect_options *ndo,
+ const u_char *bp,
+ u_int length, u_int nh,
+ const u_char *bp2)
+{
+ struct ip_print_demux_state ipd;
+
+ ipd.ip = (const struct ip *)bp2;
+ ipd.cp = bp;
+ ipd.len = length;
+ ipd.off = 0;
+ ipd.nh = nh;
+ ipd.advance = 0;
+
+ ip_print_demux(ndo, &ipd);
+}
+
+
+/*
+ * print an IP datagram.
+ */
+void
+ip_print(netdissect_options *ndo,
+ const u_char *bp,
+ u_int length)
+{
+ struct ip_print_demux_state ipd;
+ struct ip_print_demux_state *ipds=&ipd;
+ const u_char *ipend;
+ u_int hlen;
+ u_int16_t sum, ip_sum;
+ struct protoent *proto;
+
+ ipds->ip = (const struct ip *)bp;
+ if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
+ printf("IP%u ", IP_V(ipds->ip));
+ if (IP_V(ipds->ip) == 6)
+ printf(", wrong link-layer encapsulation");
+ }
+ else if (!eflag)
+ printf("IP ");
+
+ if ((u_char *)(ipds->ip + 1) > snapend) {
+ printf("[|ip]");
+ return;
+ }
+ if (length < sizeof (struct ip)) {
+ (void)printf("truncated-ip %u", length);
+ return;
+ }
+ hlen = IP_HL(ipds->ip) * 4;
+ if (hlen < sizeof (struct ip)) {
+ (void)printf("bad-hlen %u", hlen);
+ return;
+ }
+
+ ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
+ if (length < ipds->len)
+ (void)printf("truncated-ip - %u bytes missing! ",
+ ipds->len - length);
+ if (ipds->len < hlen) {
+#ifdef GUESS_TSO
+ if (ipds->len) {
+ (void)printf("bad-len %u", ipds->len);
+ return;
+ }
+ else {
+ /* we guess that it is a TSO send */
+ ipds->len = length;
+ }
+#else
+ (void)printf("bad-len %u", ipds->len);
+ return;
+#endif /* GUESS_TSO */