BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / netinet / ip_icmp.c
index 9be9c3f..69815bd 100644 (file)
@@ -1,10 +1,36 @@
 /*
 /*
- * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
+ * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
  * All rights reserved.
  *
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)ip_icmp.c   7.14 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ip_icmp.c   7.15 (Berkeley) 4/20/91
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -35,6 +61,8 @@
 int    icmpprintfs = 0;
 #endif
 
 int    icmpprintfs = 0;
 #endif
 
+extern struct protosw inetsw[];
+
 /*
  * Generate an error packet of type error
  * in response to bad packet ip.
 /*
  * Generate an error packet of type error
  * in response to bad packet ip.
@@ -65,7 +93,6 @@ icmp_error(n, type, code, dest)
        if (oip->ip_off &~ (IP_MF|IP_DF))
                goto freeit;
        if (oip->ip_p == IPPROTO_ICMP && type != ICMP_REDIRECT &&
        if (oip->ip_off &~ (IP_MF|IP_DF))
                goto freeit;
        if (oip->ip_p == IPPROTO_ICMP && type != ICMP_REDIRECT &&
-         dtom(oip)->m_len >= oiplen + ICMP_MINLEN &&
          n->m_len >= oiplen + ICMP_MINLEN &&
          !ICMP_INFOTYPE(((struct icmp *)((caddr_t)oip + oiplen))->icmp_type)) {
                icmpstat.icps_oldicmp++;
          n->m_len >= oiplen + ICMP_MINLEN &&
          !ICMP_INFOTYPE(((struct icmp *)((caddr_t)oip + oiplen))->icmp_type)) {
                icmpstat.icps_oldicmp++;
@@ -113,7 +140,6 @@ icmp_error(n, type, code, dest)
        bcopy((caddr_t)oip, (caddr_t)nip, oiplen);
        nip->ip_len = m->m_len;
        nip->ip_hl = sizeof(struct ip) >> 2;
        bcopy((caddr_t)oip, (caddr_t)nip, oiplen);
        nip->ip_len = m->m_len;
        nip->ip_hl = sizeof(struct ip) >> 2;
-       nip->ip_hl = sizeof(struct ip) >> 2;
        nip->ip_p = IPPROTO_ICMP;
        icmp_reflect(m);
 
        nip->ip_p = IPPROTO_ICMP;
        icmp_reflect(m);
 
@@ -375,11 +401,6 @@ icmp_reflect(m)
        ip->ip_ttl = MAXTTL;
 
        if (optlen > 0) {
        ip->ip_ttl = MAXTTL;
 
        if (optlen > 0) {
-               register u_char *cp;
-               struct mbuf *m = dtom(ip);
-               int opt, cnt, off;
-               u_int len;
-
                register u_char *cp;
                int opt, cnt;
                u_int len;
                register u_char *cp;
                int opt, cnt;
                u_int len;
@@ -442,7 +463,6 @@ icmp_reflect(m)
                bcopy((caddr_t)ip + optlen, (caddr_t)(ip + 1),
                         (unsigned)(m->m_len - sizeof(struct ip)));
        }
                bcopy((caddr_t)ip + optlen, (caddr_t)(ip + 1),
                         (unsigned)(m->m_len - sizeof(struct ip)));
        }
-
        icmp_send(m, opts);
        if (opts)
                (void)m_free(opts);
        icmp_send(m, opts);
        if (opts)
                (void)m_free(opts);