- cp = (u_char *)(ip + 1);
- cnt = (ip->ip_hl << 2) - sizeof (struct ip);
- for (; cnt > 0; cnt -= optlen, cp += optlen) {
- opt = cp[IPOPT_OPTVAL];
- if (opt == IPOPT_EOL)
- break;
- if (opt == IPOPT_NOP)
- optlen = 1;
- else
- optlen = cp[IPOPT_OLEN];
- if (opt == IPOPT_LSRR || opt == IPOPT_SSRR) {
- p = (struct in_addr *)
- (cp + cp[IPOPT_OFFSET] - 1) - 1;
- q = (struct in_addr *)(cp + IPOPT_MINOFF - 1);
- /*
- * First switch the last route entry
- * (first hop for return) with ip_dst
- * (final hop on return).
- */
- bcopy((caddr_t)p, (caddr_t)&t, sizeof(t));
- bcopy((caddr_t)&ip->ip_dst, (caddr_t)p,
- sizeof(struct in_addr));
- ip->ip_dst = t;
- p--;
- /*
- * Then reverse remaining route entries.
- */
- while (p > q) {
- bcopy((caddr_t)p, (caddr_t)&t,
- sizeof(struct in_addr));
- bcopy((caddr_t)q, (caddr_t)p,
- sizeof(struct in_addr));
- bcopy((caddr_t)&t, (caddr_t)q,
- sizeof(struct in_addr));
- p--;
- q++;
- }
- cp[IPOPT_OFFSET] = IPOPT_MINOFF;
- break;
- }
- }
+ int optlen = (ip->ip_hl << 2) - sizeof(struct ip);
+
+ /*
+ * Retrieve any source routing from the incoming packet
+ * and strip out other options. Adjust the IP
+ * and mbuf lengths. The length of the options is added
+ * to the mbuf here, as it was already subtracted
+ * in icmp_input, and ip_stripoptions will subtract it again.
+ * Adjust the mbuf offset to point to the new location
+ * of the icmp header.
+ */
+ opts = ip_srcroute();
+ m = dtom(ip);
+ m->m_off -= optlen;
+ m->m_len += optlen;
+ ip->ip_len -= optlen;
+ ip_stripoptions(ip, (struct mbuf *)0);