bring up to revision 7 for tahoe release
[unix-history] / usr / src / sys / netns / ns_error.c
index ec872a0..4e5cbfd 100644 (file)
@@ -1,9 +1,15 @@
 /*
 /*
- * Copyright (c) 1982 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1984, 1988 Regents of the University of California.
+ * All rights reserved.
  *
  *
- *     @(#)ns_error.c  6.5 (Berkeley) %G%
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ *
+ *      @(#)ns_error.c 7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 int    ns_errprintfs = 0;
 #endif
 
 int    ns_errprintfs = 0;
 #endif
 
+ns_err_x(c)
+{
+       register u_short *w, *lim, *base = ns_errstat.ns_es_codes;
+       u_short x = c;
+
+       /*
+        * zero is a legit error code, handle specially
+        */
+       if (x == 0)
+               return (0);
+       lim = base + NS_ERR_MAX - 1;
+       for (w = base + 1; w < lim; w++) {
+               if (*w == 0)
+                       *w = x;
+               if (*w == x)
+                       break;
+       }
+       return (w - base);
+}
+
 /*
  * Generate an error packet of type error
  * in response to bad packet.
 /*
  * Generate an error packet of type error
  * in response to bad packet.
@@ -140,7 +166,6 @@ ns_err_input(m)
        register struct ns_epidp *epidp = mtod(m, struct ns_epidp *);
        register int i;
        int type, code, param;
        register struct ns_epidp *epidp = mtod(m, struct ns_epidp *);
        register int i;
        int type, code, param;
-       extern struct ns_addr if_makeaddr();
 
        /*
         * Locate ns_err structure in mbuf, and check
 
        /*
         * Locate ns_err structure in mbuf, and check
@@ -234,16 +259,18 @@ free:
        m_freem(m);
 }
 
        m_freem(m);
 }
 
+#ifdef notdef
 u_long
 nstime()
 {
 u_long
 nstime()
 {
-       int s = spl6();
+       int s = splclock();
        u_long t;
 
        t = (time.tv_sec % (24*60*60)) * 1000 + time.tv_usec / 1000;
        splx(s);
        return (htonl(t));
 }
        u_long t;
 
        t = (time.tv_sec % (24*60*60)) * 1000 + time.tv_usec / 1000;
        splx(s);
        return (htonl(t));
 }
+#endif
 
 ns_echo(idp)
 register struct idp *idp;
 
 ns_echo(idp)
 register struct idp *idp;
@@ -266,8 +293,9 @@ register struct idp *idp;
 
        if (idp->idp_sum != 0xffff) {
                idp->idp_sum = 0;
 
        if (idp->idp_sum != 0xffff) {
                idp->idp_sum = 0;
-               idp->idp_sum = ns_cksum(m, (((ntohs(idp->idp_len) - 1)|1)+1));
+               idp->idp_sum = ns_cksum(m,
+                   (int)(((ntohs(idp->idp_len) - 1)|1)+1));
        }
        }
-       (void) ns_output(m, 0, NS_FORWARDING);
+       (void) ns_output(m, (struct route *)0, NS_FORWARDING);
        return(0);
 }
        return(0);
 }