Do Something with interface tracing & fix ctlinput routines.
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sat, 7 Sep 1985 09:35:12 +0000 (01:35 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sat, 7 Sep 1985 09:35:12 +0000 (01:35 -0800)
SCCS-vsn: sys/netns/ns_input.c 6.10
SCCS-vsn: sys/netns/idp_usrreq.c 6.8
SCCS-vsn: sys/netns/spp_usrreq.c 6.11

usr/src/sys/netns/idp_usrreq.c
usr/src/sys/netns/ns_input.c
usr/src/sys/netns/spp_usrreq.c

index 212758a..bc76b41 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *      @(#)idp_usrreq.c       6.7 (Berkeley) %G%
+ *      @(#)idp_usrreq.c       6.8 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -21,6 +21,7 @@
 
 #include "ns.h"
 #include "ns_pcb.h"
 
 #include "ns.h"
 #include "ns_pcb.h"
+#include "ns_if.h"
 #include "idp.h"
 #include "idp_var.h"
 #include "ns_error.h"
 #include "idp.h"
 #include "idp_var.h"
 #include "ns_error.h"
@@ -34,21 +35,31 @@ struct      sockaddr_ns idp_ns = { AF_NS };
 /*
  *  This may also be called for raw listeners.
  */
 /*
  *  This may also be called for raw listeners.
  */
-idp_input(m, nsp)
+idp_input(m, nsp, ifp)
        struct mbuf *m;
        register struct nspcb *nsp;
        struct mbuf *m;
        register struct nspcb *nsp;
+       struct ifnet *ifp;
 {
        register struct idp *idp = mtod(m, struct idp *);
 
 {
        register struct idp *idp = mtod(m, struct idp *);
 
-       if (nsp==0) {
+       if (nsp==0)
                panic("No nspcb");
                panic("No nspcb");
-       }
-
        /*
         * Construct sockaddr format source address.
         * Stuff source address and datagram in user buffer.
         */
        idp_ns.sns_addr = idp->idp_sna;
        /*
         * Construct sockaddr format source address.
         * Stuff source address and datagram in user buffer.
         */
        idp_ns.sns_addr = idp->idp_sna;
+       if (ns_netof(idp->idp_sna)==0) {
+               register struct ifaddr *ia;
+
+               for (ia = ifp->if_addrlist; ia; ia->ifa_next) {
+                       if (ia->ifa_addr.sa_family == AF_NS) {
+                               idp_ns.sns_addr.x_net =
+                                       IA_SNS(ia)->sns_addr.x_net;
+                               break;
+                       }
+               }
+       }
        nsp->nsp_rpt = idp->idp_pt;
        if ( ! (nsp->nsp_flags & NSP_RAWIN) ) {
                m->m_len -= sizeof (struct idp);
        nsp->nsp_rpt = idp->idp_pt;
        if ( ! (nsp->nsp_flags & NSP_RAWIN) ) {
                m->m_len -= sizeof (struct idp);
index 37243af..969b635 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ns_input.c  6.9 (Berkeley) %G%
+ *     @(#)ns_input.c  6.10 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -95,7 +95,7 @@ next:
         */
        for (nsp = nsrawpcb.nsp_next; nsp != &nsrawpcb; nsp = nsp->nsp_next) {
                struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL);
         */
        for (nsp = nsrawpcb.nsp_next; nsp != &nsrawpcb; nsp = nsp->nsp_next) {
                struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL);
-               if (m1) idp_input(m1, nsp);
+               if (m1) idp_input(m1, nsp, ifp);
        }
 
        idp = mtod(m, struct idp *);
        }
 
        idp = mtod(m, struct idp *);
@@ -189,14 +189,14 @@ next:
                        switch (idp->idp_pt) {
 
                            case NSPROTO_SPP:
                        switch (idp->idp_pt) {
 
                            case NSPROTO_SPP:
-                                   spp_input(m,nsp);
+                                   spp_input(m, nsp, ifp);
                                    goto next;
 
                            case NSPROTO_ERROR:
                                    ns_err_input(m);
                                    goto next;
                        }
                                    goto next;
 
                            case NSPROTO_ERROR:
                                    ns_err_input(m);
                                    goto next;
                        }
-               idp_input(m,nsp);
+               idp_input(m, nsp, ifp);
        } else {
                ns_error(m, NS_ERR_NOSOCK, 0);
        }
        } else {
                ns_error(m, NS_ERR_NOSOCK, 0);
        }
@@ -233,11 +233,19 @@ idp_ctlinput(cmd, arg)
        if (nsctlerrmap[cmd] == 0)
                return;         /* XXX */
        type = NS_ERR_UNREACH_HOST;
        if (nsctlerrmap[cmd] == 0)
                return;         /* XXX */
        type = NS_ERR_UNREACH_HOST;
-       if (cmd == PRC_IFDOWN)
-               ns = &((struct sockaddr_ns *)arg)->sns_addr;
-       else if (cmd == PRC_HOSTDEAD || cmd == PRC_HOSTUNREACH)
-               ns = (struct ns_addr *)arg;
-       else {
+       switch (cmd) {
+               struct sockaddr_ns *sns;
+
+       case PRC_IFDOWN:
+       case PRC_HOSTDEAD:
+       case PRC_HOSTUNREACH:
+               sns = (struct sockaddr_ns *)arg;
+               if (sns->sns_family != AF_INET)
+                       return;
+               ns = &sns->sns_addr;
+               break;
+
+       default:
                errp = (struct ns_errp *)arg;
                ns = &errp->ns_err_idp.idp_dna;
                type = errp->ns_err_num;
                errp = (struct ns_errp *)arg;
                ns = &errp->ns_err_idp.idp_dna;
                type = errp->ns_err_num;
index 8ede46f..8dc00ea 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)spp_usrreq.c        6.10 (Berkeley) %G%
+ *     @(#)spp_usrreq.c        6.11 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"