formatting cleanup (checking by torek for sklower)
[unix-history] / usr / src / sys / netns / ns_input.c
index 040280c..e0b12ec 100644 (file)
@@ -2,19 +2,9 @@
  * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)ns_input.c  7.5 (Berkeley) %G%
+ *     @(#)ns_input.c  7.8 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -48,6 +38,7 @@ union ns_host ns_zerohost;
 union ns_host  ns_broadhost;
 union ns_net   ns_zeronet;
 union ns_net   ns_broadnet;
 union ns_host  ns_broadhost;
 union ns_net   ns_zeronet;
 union ns_net   ns_broadnet;
+struct sockaddr_ns ns_netmask, ns_hostmask;
 
 static u_short allones[] = {-1, -1, -1};
 
 
 static u_short allones[] = {-1, -1, -1};
 
@@ -70,6 +61,11 @@ ns_init()
        nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb;
        nsintrq.ifq_maxlen = nsqmaxlen;
        ns_pexseq = time.tv_usec;
        nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb;
        nsintrq.ifq_maxlen = nsqmaxlen;
        ns_pexseq = time.tv_usec;
+       ns_netmask.sns_len = 6;
+       ns_netmask.sns_addr.x_net = ns_broadnet;
+       ns_hostmask.sns_len = 12;
+       ns_hostmask.sns_addr.x_net = ns_broadnet;
+       ns_hostmask.sns_addr.x_host = ns_broadhost;
 }
 
 /*
 }
 
 /*
@@ -82,8 +78,6 @@ nsintr()
        register struct idp *idp;
        register struct mbuf *m;
        register struct nspcb *nsp;
        register struct idp *idp;
        register struct mbuf *m;
        register struct nspcb *nsp;
-       struct ifnet *ifp;
-       struct mbuf *m0;
        register int i;
        int len, s, error;
        char oddpacketp;
        register int i;
        int len, s, error;
        char oddpacketp;
@@ -222,7 +216,7 @@ u_char nsctlerrmap[PRC_NCMDS] = {
        0,              0,              0,              0
 };
 
        0,              0,              0,              0
 };
 
-idp_donosocks = 1;
+int idp_donosocks = 1;
 
 idp_ctlinput(cmd, arg)
        int cmd;
 
 idp_ctlinput(cmd, arg)
        int cmd;
@@ -247,7 +241,7 @@ idp_ctlinput(cmd, arg)
        case PRC_HOSTDEAD:
        case PRC_HOSTUNREACH:
                sns = (struct sockaddr_ns *)arg;
        case PRC_HOSTDEAD:
        case PRC_HOSTUNREACH:
                sns = (struct sockaddr_ns *)arg;
-               if (sns->sns_family != AF_INET)
+               if (sns->sns_family != AF_NS)
                        return;
                ns = &sns->sns_addr;
                break;
                        return;
                ns = &sns->sns_addr;
                break;
@@ -412,6 +406,7 @@ struct route *ro;
        bzero((caddr_t)ro, sizeof (*ro));
        dst = (struct sockaddr_ns *)&ro->ro_dst;
 
        bzero((caddr_t)ro, sizeof (*ro));
        dst = (struct sockaddr_ns *)&ro->ro_dst;
 
+       dst->sns_len = sizeof(*dst);
        dst->sns_family = AF_NS;
        dst->sns_addr = *src;
        dst->sns_addr.x_port = 0;
        dst->sns_family = AF_NS;
        dst->sns_addr = *src;
        dst->sns_addr.x_port = 0;
@@ -428,15 +423,13 @@ register struct route *ro;
 {
        if (ro->ro_rt) {RTFREE(ro->ro_rt);}
 }
 {
        if (ro->ro_rt) {RTFREE(ro->ro_rt);}
 }
-static union ns_net
-ns_zeronet;
 
 ns_watch_output(m, ifp)
 struct mbuf *m;
 struct ifnet *ifp;
 {
        register struct nspcb *nsp;
 
 ns_watch_output(m, ifp)
 struct mbuf *m;
 struct ifnet *ifp;
 {
        register struct nspcb *nsp;
-       register struct ifaddr *ia;
+       register struct ifaddr *ifa;
        /*
         * Give any raw listeners a crack at the packet
         */
        /*
         * Give any raw listeners a crack at the packet
         */
@@ -452,11 +445,10 @@ struct ifnet *ifp;
                        idp->idp_sna.x_net = ns_zeronet;
                        idp->idp_sna.x_host = ns_thishost;
                        if (ifp && (ifp->if_flags & IFF_POINTOPOINT))
                        idp->idp_sna.x_net = ns_zeronet;
                        idp->idp_sna.x_host = ns_thishost;
                        if (ifp && (ifp->if_flags & IFF_POINTOPOINT))
-                           for(ia = ifp->if_addrlist; ia;
-                                               ia = ia->ifa_next) {
-                               if (ia->ifa_addr.sa_family==AF_NS) {
-                                   idp->idp_sna = 
-                                       satons_addr(ia->ifa_dstaddr);
+                           for(ifa = ifp->if_addrlist; ifa;
+                                               ifa = ifa->ifa_next) {
+                               if (ifa->ifa_addr->sa_family==AF_NS) {
+                                   idp->idp_sna = IA_SNS(ifa)->sns_addr;
                                    break;
                                }
                            }
                                    break;
                                }
                            }