BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / netiso / esis.c
index 242766b..efa0360 100644 (file)
@@ -1,3 +1,38 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ *     @(#)esis.c      7.19 (Berkeley) 6/27/91
+ */
+
 /***********************************************************
                Copyright IBM Corporation 1987
 
 /***********************************************************
                Copyright IBM Corporation 1987
 
@@ -24,10 +59,6 @@ SOFTWARE.
 /*
  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
  */
 /*
  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
  */
-/*     @(#)esis.c      7.15 (Berkeley) 7/24/90 */
-#ifndef lint
-static char *rcsid = "$Header: esis.c,v 4.10 88/09/15 18:57:03 hagens Exp $";
-#endif
 
 #ifdef ISO
 
 
 #ifdef ISO
 
@@ -37,11 +68,9 @@ static char *rcsid = "$Header: esis.c,v 4.10 88/09/15 18:57:03 hagens Exp $";
 #include "mbuf.h"
 #include "domain.h"
 #include "protosw.h"
 #include "mbuf.h"
 #include "domain.h"
 #include "protosw.h"
-#include "user.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "errno.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "errno.h"
-#include "kernel.h"
 
 #include "../net/if.h"
 #include "../net/if_dl.h"
 
 #include "../net/if.h"
 #include "../net/if_dl.h"
@@ -57,6 +86,7 @@ static char *rcsid = "$Header: esis.c,v 4.10 88/09/15 18:57:03 hagens Exp $";
 #include "clnp_stat.h"
 #include "esis.h"
 #include "argo_debug.h"
 #include "clnp_stat.h"
 #include "esis.h"
 #include "argo_debug.h"
+#include "kernel.h"
 
 /*
  *     Global variables to esis implementation
 
 /*
  *     Global variables to esis implementation
@@ -68,6 +98,7 @@ static char *rcsid = "$Header: esis.c,v 4.10 88/09/15 18:57:03 hagens Exp $";
  *
  */
 struct rawcb   esis_pcb;
  *
  */
 struct rawcb   esis_pcb;
+int                            esis_config(), snpac_age();
 int                            esis_sendspace = 2048;
 int                            esis_recvspace = 2048;
 short                  esis_holding_time = ESIS_HT;
 int                            esis_sendspace = 2048;
 int                            esis_recvspace = 2048;
 short                  esis_holding_time = ESIS_HT;
@@ -101,7 +132,6 @@ esis_init()
 {
        extern struct clnl_protosw clnl_protox[256];
        int     esis_input(), isis_input();
 {
        extern struct clnl_protosw clnl_protox[256];
        int     esis_input(), isis_input();
-       int     esis_config(), snpac_age();
 #ifdef ISO_X25ESIS
        int     x25esis_input();
 #endif ISO_X25ESIS
 #ifdef ISO_X25ESIS
        int     x25esis_input();
 #endif ISO_X25ESIS
@@ -140,7 +170,7 @@ struct mbuf         *control;       /* optional control */
        struct rawcb *rp = sotorawcb(so);
        int error = 0;
 
        struct rawcb *rp = sotorawcb(so);
        int error = 0;
 
-       if (suser(u.u_cred, &u.u_acflag)) {
+       if ((so->so_state & SS_PRIV) == 0) {
                error = EACCES;
                goto release;
        }
                error = EACCES;
                goto release;
        }
@@ -722,13 +752,18 @@ esis_config()
        /* 
         *      Report configuration for each interface that 
         *      - is UP
        /* 
         *      Report configuration for each interface that 
         *      - is UP
-        *      - is not loopback
+        *      - has BROADCAST capability
         *      - has an ISO address
         */
         *      - has an ISO address
         */
+       /* Todo: a better way would be to construct the esh or ish
+        * once and copy it out for all devices, possibly calling
+        * a method in the iso_ifaddr structure to encapsulate and
+        * transmit it.  This could work to advantage for non-broadcast media
+        */
        
        for (ifp = ifnet; ifp; ifp = ifp->if_next) {
                if ((ifp->if_flags & IFF_UP) &&
        
        for (ifp = ifnet; ifp; ifp = ifp->if_next) {
                if ((ifp->if_flags & IFF_UP) &&
-                       ((ifp->if_flags & IFF_LOOPBACK) == 0)) {
+                   (ifp->if_flags & IFF_BROADCAST)) {
                        /* search for an ISO address family */
                        struct ifaddr   *ia;
 
                        /* search for an ISO address family */
                        struct ifaddr   *ia;
 
@@ -968,7 +1003,7 @@ struct mbuf *m;
                goto release;
        }
        ifp = ifa->ifa_ifp;
                goto release;
        }
        ifp = ifa->ifa_ifp;
-       sn_len = ifp->if_addrlen;
+       sn_len = sdl->sdl_alen;
        IFDEBUG(D_ISISOUTPUT)
                u_char *cp = (u_char *)LLADDR(sdl), *cplim = cp + sn_len;
                printf("isis_output: ifp 0x%x (%s%d), to: ",
        IFDEBUG(D_ISISOUTPUT)
                u_char *cp = (u_char *)LLADDR(sdl), *cplim = cp + sn_len;
                printf("isis_output: ifp 0x%x (%s%d), to: ",