- /*
- * The value that should have gone into the checksum field
- * is the negative of the value gotten by summing up everything
- * *but* the checksum field.
- *
- * We can compute that by subtracting the value of the checksum
- * field from the sum of all the data in the packet, and then
- * computing the negative of that value.
- *
- * "sum" is the value of the checksum field, and "computed_sum"
- * is the negative of the sum of all the data in the packets,
- * so that's -(-computed_sum - sum), or (sum + computed_sum).
- *
- * All the arithmetic in question is one's complement, so the
- * addition must include an end-around carry; we do this by
- * doing the arithmetic in 32 bits (with no sign-extension),
- * and then adding the upper 16 bits of the sum, which contain
- * the carry, to the lower 16 bits of the sum, and then do it
- * again in case *that* sum produced a carry.
- *
- * As RFC 1071 notes, the checksum can be computed without
- * byte-swapping the 16-bit words; summing 16-bit words
- * on a big-endian machine gives a big-endian checksum, which
- * can be directly stuffed into the big-endian checksum fields
- * in protocol headers, and summing words on a little-endian
- * machine gives a little-endian checksum, which must be
- * byte-swapped before being stuffed into a big-endian checksum
- * field.
- *
- * "computed_sum" is a network-byte-order value, so we must put
- * it in host byte order before subtracting it from the
- * host-byte-order value from the header; the adjusted checksum
- * will be in host byte order, which is what we'll return.
- */
- shouldbe = sum;
- shouldbe += ntohs(computed_sum);
- shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
- shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
- return shouldbe;
+ case IPPROTO_EGP:
+ egp_print(ipds->cp, ipds->len);
+ break;
+
+ case IPPROTO_OSPF:
+ ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ break;
+
+ case IPPROTO_IGMP:
+ igmp_print(ipds->cp, ipds->len);
+ break;
+
+ case IPPROTO_IPV4:
+ /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
+ ip_print(ndo, ipds->cp, ipds->len);
+ if (! vflag) {
+ ND_PRINT((ndo, " (ipip-proto-4)"));
+ return;
+ }
+ break;
+
+#ifdef INET6
+ case IPPROTO_IPV6:
+ /* ip6-in-ip encapsulation */
+ ip6_print(ndo, ipds->cp, ipds->len);
+ break;
+#endif /*INET6*/
+
+ case IPPROTO_RSVP:
+ rsvp_print(ipds->cp, ipds->len);
+ break;
+
+ case IPPROTO_GRE:
+ /* do it */
+ gre_print(ipds->cp, ipds->len);
+ break;
+
+ case IPPROTO_MOBILE:
+ mobile_print(ipds->cp, ipds->len);
+ break;
+
+ case IPPROTO_PIM:
+ vec[0].ptr = ipds->cp;
+ vec[0].len = ipds->len;
+ pim_print(ipds->cp, ipds->len, in_cksum(vec, 1));
+ break;
+
+ case IPPROTO_VRRP:
+ if (packettype == PT_CARP) {
+ if (vflag)
+ (void)printf("carp %s > %s: ",
+ ipaddr_string(&ipds->ip->ip_src),
+ ipaddr_string(&ipds->ip->ip_dst));
+ carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+ } else {
+ if (vflag)
+ (void)printf("vrrp %s > %s: ",
+ ipaddr_string(&ipds->ip->ip_src),
+ ipaddr_string(&ipds->ip->ip_dst));
+ 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;
+ }