Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netiso allow delivery of routing protocol pdus to `raw' ...



details:   https://anonhg.NetBSD.org/src/rev/b6f87327c6d5
branches:  trunk
changeset: 480283:b6f87327c6d5
user:      chopps <chopps%NetBSD.org@localhost>
date:      Sat Jan 08 20:39:45 2000 +0000

description:
allow delivery of routing protocol pdus to `raw' sockets even when the
interface has no iso address

diffstat:

 sys/netiso/clnp_input.c |  31 ++++++++++++++++++-------------
 sys/netiso/esis.c       |  21 +++++++++++++++++----
 2 files changed, 35 insertions(+), 17 deletions(-)

diffs (125 lines):

diff -r 9a329c5b05b5 -r b6f87327c6d5 sys/netiso/clnp_input.c
--- a/sys/netiso/clnp_input.c   Sat Jan 08 17:15:18 2000 +0000
+++ b/sys/netiso/clnp_input.c   Sat Jan 08 20:39:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clnp_input.c,v 1.18 1999/04/14 16:26:42 chopps Exp $   */
+/*     $NetBSD: clnp_input.c,v 1.19 2000/01/08 20:39:45 chopps Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -182,16 +182,6 @@
        if ((m->m_flags & M_PKTHDR) == 0 || m->m_pkthdr.rcvif == 0) {
                m_freem(m);
                goto next;
-       } else {
-               register struct ifaddr *ifa;
-               for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; ifa != 0;
-                    ifa = ifa->ifa_list.tqe_next)
-                       if (ifa->ifa_addr->sa_family == AF_ISO)
-                               break;
-               if (ifa == 0) {
-                       m_freem(m);
-                       goto next;
-               }
        }
        bzero((caddr_t) & sh, sizeof(sh));
        sh.snh_flags = m->m_flags & (M_MCAST | M_BCAST);
@@ -220,6 +210,11 @@
                m->m_len -= sizeof(struct fddi_header);
                m->m_pkthdr.len -= sizeof(struct fddi_header);
                break;
+       case IFT_PTPSERIAL:
+               /* nothing extra to get from the mbuf */
+               bzero((caddr_t)sh.snh_dhost, sizeof(sh.snh_dhost));
+               bzero((caddr_t)sh.snh_shost, sizeof(sh.snh_shost));
+               break;
        default:
                break;
        }
@@ -306,6 +301,7 @@
 #endif
 {
        struct snpa_hdr *shp;   /* subnetwork header */
+       struct ifaddr *ifa;
        register struct clnp_fixed *clnp;       /* ptr to fixed part of
                                                 * header */
        struct sockaddr_iso source;     /* source address of pkt */
@@ -330,6 +326,17 @@
        shp = va_arg(ap, struct snpa_hdr *);
        va_end(ap);
 
+       /*
+        * make sure this interface has a ISO address
+        */
+       for (ifa = shp->snh_ifp->if_addrlist.tqh_first; ifa != 0;
+            ifa = ifa->ifa_list.tqe_next)
+               if (ifa->ifa_addr->sa_family == AF_ISO)
+                       break;
+       if (ifa == 0) {
+               clnp_discard(m, ADDR_DESTUNREACH);
+               return;
+       }
 
 #ifdef ARGO_DEBUG
        if (argo_debug[D_INPUT]) {
@@ -547,12 +554,10 @@
                        clnp_er_input(m, &src, oidxp->cni_er_reason);
                }
                break;
-
        case CLNP_DT:
                (*isosw[clnp_protox[ISOPROTO_TP]].pr_input)(m, &source, &target,
                                             clnp->cnf_hdr_len, need_afrin);
                break;
-
        case CLNP_RAW:
        case CLNP_ECR:
 #ifdef ARGO_DEBUG
diff -r 9a329c5b05b5 -r b6f87327c6d5 sys/netiso/esis.c
--- a/sys/netiso/esis.c Sat Jan 08 17:15:18 2000 +0000
+++ b/sys/netiso/esis.c Sat Jan 08 20:39:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: esis.c,v 1.21 1999/04/14 16:26:42 chopps Exp $ */
+/*     $NetBSD: esis.c,v 1.22 2000/01/08 20:39:45 chopps Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -279,12 +279,21 @@
        struct snpa_hdr *shp;   /* subnetwork header */
        register struct esis_fixed *pdu = mtod(m0, struct esis_fixed *);
        register int    type;
+       struct ifaddr *ifa;
        va_list ap;
 
        va_start(ap, m0);
        shp = va_arg(ap, struct snpa_hdr *);
        va_end(ap);
 
+       for (ifa = shp->snh_ifp->if_addrlist.tqh_first; ifa != 0;
+            ifa = ifa->ifa_list.tqe_next)
+               if (ifa->ifa_addr->sa_family == AF_ISO)
+                       break;
+       /* if we have no iso address just send it to the sockets */
+       if (ifa == 0)
+               goto bad;
+
        /*
         *      check checksum if necessary
         */
@@ -1142,9 +1151,13 @@
        bzero((caddr_t) & siso, sizeof(siso));
        siso.siso_family = AF_ISO;      /* This convention may be useful for
                                         * X.25 */
-       siso.siso_data[0] = AFI_SNA;
-       siso.siso_nlen = sn_len + 1;
-       bcopy(LLADDR(sdl), siso.siso_data + 1, sn_len);
+       if (sn_len == 0)
+               siso.siso_nlen = 0;
+       else {
+               siso.siso_data[0] = AFI_SNA;
+               siso.siso_nlen = sn_len + 1;
+               bcopy(LLADDR(sdl), siso.siso_data + 1, sn_len);
+       }
        error = (ifp->if_output) (ifp, m, sisotosa(&siso), 0);
        if (error) {
 #ifdef ARGO_DEBUG



Home | Main Index | Thread Index | Old Index