checkpoint before trying including old pkcb in ifaddr.
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Wed, 16 May 1990 02:28:15 +0000 (18:28 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Wed, 16 May 1990 02:28:15 +0000 (18:28 -0800)
SCCS-vsn: sys/netccitt/pk_var.h 7.2
SCCS-vsn: sys/netccitt/pk_usrreq.c 7.3

usr/src/sys/netccitt/pk_usrreq.c
usr/src/sys/netccitt/pk_var.h

index 86ae4da..fe578b5 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_usrreq.c 7.2 (Berkeley) %G%
+ *     @(#)pk_usrreq.c 7.3 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
@@ -44,27 +44,26 @@ struct      x25_packet *pk_template ();
  *
  */
 
  *
  */
 
-pk_usrreq (so, req, m, nam, rights)
+pk_usrreq (so, req, m, nam, control)
 struct socket *so;
 int req;
 register struct mbuf *m, *nam;
 struct socket *so;
 int req;
 register struct mbuf *m, *nam;
-struct mbuf *rights;
+struct mbuf *control;
 {
        register struct pklcd *lcp = (struct pklcd *) so -> so_pcb;
        register struct x25_packet *xp;
 {
        register struct pklcd *lcp = (struct pklcd *) so -> so_pcb;
        register struct x25_packet *xp;
-       register int s = splnet (), error = 0;
-
-#ifdef BSD4_3
-       if (req == PRU_CONTROL) {
-               error = pk_control(so, (int)m, (caddr_t)nam,
-                       (struct ifnet *)rights);
-               splx (s);
-               return (error);
+       register int error = 0;
+
+       if (req == PRU_CONTROL)
+               return (pk_control(so, (int)m, (caddr_t)nam,
+                       (struct ifnet *)control));
+       if (control && control->m_len) {
+               error = EINVAL;
+               goto release;
        }
        }
-#endif
-       if (rights && rights -> m_len) {
-               splx (s);
-               return (EINVAL);
+       if (lcp == NULL && req != PRU_ATTACH) {
+               error = EINVAL;
+               goto release;
        }
 
 /*
        }
 
 /*
@@ -72,10 +71,7 @@ struct mbuf *rights;
                req, (struct x25_packet *)0);
 */
 
                req, (struct x25_packet *)0);
 */
 
-       if (lcp == NULL && req != PRU_ATTACH) {
-               splx (s);
                return (EINVAL);
                return (EINVAL);
-       }
 
        switch (req) {
        /* 
 
        switch (req) {
        /* 
@@ -250,12 +246,14 @@ struct mbuf *rights;
        default: 
                panic ("pk_usrreq");
        }
        default: 
                panic ("pk_usrreq");
        }
-
-       splx (s);
+release:
+       if (control != NULL)
+               m_freem(control);
+       if (m != NULL)
+               m_freem(m);
        return (error);
 }
 
        return (error);
 }
 
-#ifdef BSD4_3
 /*ARGSUSED*/
 pk_control (so, cmd, data, ifp)
 struct socket *so;
 /*ARGSUSED*/
 pk_control (so, cmd, data, ifp)
 struct socket *so;
@@ -265,8 +263,9 @@ register struct ifnet *ifp;
 {
        register struct ifreq *ifr = (struct ifreq *)data;
        register struct ifaddr *ifa = 0;
 {
        register struct ifreq *ifr = (struct ifreq *)data;
        register struct ifaddr *ifa = 0;
-       register int error, s;
-       struct sockaddr oldaddr;
+       register struct x25_ifaddr *ia = 0;
+       int error, s;
+       unsigned n;
 
        /*
         * Find address for this interface, if it exists.
 
        /*
         * Find address for this interface, if it exists.
@@ -276,11 +275,12 @@ register struct ifnet *ifp;
                        if (ifa->ifa_addr.sa_family == AF_CCITT)
                                break;
 
                        if (ifa->ifa_addr.sa_family == AF_CCITT)
                                break;
 
+       ia = (struct x25_ifaddr *)ifa;
        switch (cmd) {
        case SIOCGIFADDR:
                if (ifa == 0)
                        return (EADDRNOTAVAIL);
        switch (cmd) {
        case SIOCGIFADDR:
                if (ifa == 0)
                        return (EADDRNOTAVAIL);
-               ifr -> ifr_addr = ifa->ifa_addr;
+               ifr->ifr_addr = *(struct sockaddr *)ia->ia_xc;
                return (0);
 
        case SIOCSIFADDR:
                return (0);
 
        case SIOCSIFADDR:
@@ -290,39 +290,51 @@ register struct ifnet *ifp;
                if (ifp == 0)
                        panic("pk_control");
                if (ifa == (struct ifaddr *)0) {
                if (ifp == 0)
                        panic("pk_control");
                if (ifa == (struct ifaddr *)0) {
-                       register struct ifaddr *ia;
                        register struct mbuf *m;
 
                        m = m_getclr(M_WAIT, MT_IFADDR);
                        if (m == (struct mbuf *)NULL)
                                return (ENOBUFS);
                        register struct mbuf *m;
 
                        m = m_getclr(M_WAIT, MT_IFADDR);
                        if (m == (struct mbuf *)NULL)
                                return (ENOBUFS);
-                       ia = mtod(m, struct ifaddr *);
+                       ia = mtod(m, struct x25_ifaddr *);
                        if (ifa = ifp->if_addrlist) {
                                for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
                                        ;
                        if (ifa = ifp->if_addrlist) {
                                for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
                                        ;
-                               ifa->ifa_next = ia;
+                               ifa->ifa_next = &ia->ia_ifa;
                        } else
                        } else
-                               ifp->if_addrlist = ia;
-                       ifa = ia;
+                               ifp->if_addrlist = &ia->ia_ifa;
+                       ifa = &ia->ia_ifa;
                        ifa->ifa_ifp = ifp;
                        ifa->ifa_ifp = ifp;
+                       ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr;
+                       ifa->ifa_netmask = (struct sockaddr *)&ia->ia_sockmask;
                }
                }
-               oldaddr = ifa->ifa_addr;
-               s = splimp();
-               ifa->ifa_addr = ifr->ifr_addr;
+               ia->ia_xcp = (struct x25config *) &(ifr->ifr_addr);
+               if (ia->ia_chan && (ia->ia_maxlcn != ia->xcp->xc_maxlcn)) {
+                       free((caddr_t)ia->ia_chan, M_IFADDR);
+                       ia->ia_ia_chan = 0;
+               }
+               n = ia->ia_maxlcn * sizeof(struct pklcd *);
+               if (ia->ia_chan == 0)
+                   ia->ia_chan = (struct pklcd **) malloc(n, M_IFADDR);
+               if (ia->ia_chan)
+                       bzero((caddr_t)ia->ia_chan, n);
+               else
+                       return (ENOBUFS);
                /*
                 * Give the interface a chance to initialize if this
                 * is its first address, and to validate the address.
                 */
                /*
                 * Give the interface a chance to initialize if this
                 * is its first address, and to validate the address.
                 */
-               if (ifp->if_ioctl && (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ifa))) {
-                       splx(s);
-                       ifa->ifa_addr = oldaddr;
-                       return (error);
-               }
+               s = splimp();
+               if (ifp->if_ioctl)
+                       error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ifa)));
                splx(s);
                splx(s);
+               if (error == 0) {
+                       ia->ia_xc = *ia->ia_xcp;
 #ifndef WATERLOO
 #ifndef WATERLOO
-               (void) pk_accton ();
+                       (void) pk_accton ();
 #endif
 #endif
-               return (0);
+               }
+               ia->ia_xcp = &ia->ia_xc;
+               return (error);
 
        default:
                if (ifp == 0 || ifp->if_ioctl == 0)
 
        default:
                if (ifp == 0 || ifp->if_ioctl == 0)
@@ -330,7 +342,6 @@ register struct ifnet *ifp;
                return ((*ifp->if_ioctl)(ifp, cmd, data));
        }
 }
                return ((*ifp->if_ioctl)(ifp, cmd, data));
        }
 }
-#endif
 
 /*
  * Do an in-place conversion of an "old style"
 
 /*
  * Do an in-place conversion of an "old style"
@@ -434,7 +445,7 @@ register struct mbuf *m;
                        xp -> q_bit = 1;
                xp -> packet_type |= (*cp & 0x40) >> 2;         /* XXX */
                m -> m_len--;
                        xp -> q_bit = 1;
                xp -> packet_type |= (*cp & 0x40) >> 2;         /* XXX */
                m -> m_len--;
-               m -> m_off++;
+               m -> m_data++;
        }
        len = m -> m_len;
        while (m -> m_next) {
        }
        len = m -> m_len;
        while (m -> m_next) {
@@ -446,12 +457,7 @@ register struct mbuf *m;
                return (EMSGSIZE);
        }
 
                return (EMSGSIZE);
        }
 
-#ifdef BSD4_3
        sbappendrecord (&lcp -> lcd_so -> so_snd, m0);
        sbappendrecord (&lcp -> lcd_so -> so_snd, m0);
-#else
-       m -> m_act = (struct mbuf *) 1;
-       sbappend (&lcp -> lcd_so -> so_snd, m0);
-#endif
        lcp -> lcd_template = 0;
        lcp -> lcd_txcnt++;
        pk_output (lcp);
        lcp -> lcd_template = 0;
        lcp -> lcd_txcnt++;
        pk_output (lcp);
index 39120c1..d02d421 100644 (file)
@@ -1,5 +1,31 @@
-/* Copyright (c) University of British Columbia, 1984 */
+/*
+ * Copyright (c) University of British Columbia, 1984
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Laboratory for Computation Vision and the Computer Science Department
+ * of the University of British Columbia.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)pk_var.h    7.2 (Berkeley) %G%
+ */
+
+/*
+ * Protocol-Protocol Packet Buffer.
+ * (Eventually will be replace by system-wide structure).
+ */
 
 
+struct pq      {
+       int     (*pq_put)();    /* How to process data */
+       struct  mbuf *pq_data;  /* Queued data */
+       int     pq_space;       /* For accounting */
+       int     pq_flags;
+       int     (*pq_unblock)();/* called & cleared when unblocking */
+       caddr_t pq_proto;       /* for other service entries */
+       caddr_t pq_next;        /* next q, or route, or pcb */
+};
 
 /*
  *
 
 /*
  *
@@ -8,6 +34,7 @@
  */
 
 struct pklcd {
  */
 
 struct pklcd {
+       struct  pq lcd_downq, lcd_upq;  /* protocol glue for datagram service */
        short   lcd_lcn;                /* Logical channel number */
        short   lcd_state;              /* Logical Channel state */
         bool   lcd_intrconf_pending;   /* Interrupt confirmation pending */
        short   lcd_lcn;                /* Logical channel number */
        short   lcd_state;              /* Logical Channel state */
         bool   lcd_intrconf_pending;   /* Interrupt confirmation pending */
@@ -35,25 +62,43 @@ struct pklcd {
        long    lcd_rxcnt;              /* Data packet receive count */
        short   lcd_intrcnt;            /* Interrupt packet transmit count */
        struct  pklcd *lcd_listen;      /* Next lcd on listen queue */
        long    lcd_rxcnt;              /* Data packet receive count */
        short   lcd_intrcnt;            /* Interrupt packet transmit count */
        struct  pklcd *lcd_listen;      /* Next lcd on listen queue */
-       struct  pkcb *lcd_pkp;          /* network this lcd is attached to */
+       struct  ifaddr *lcd_ifa;        /* network this lcd is attached to */
 };
 
 };
 
+
 /*
 /*
- * Per network information, allocated dynamically
- * when a new network is configured.
+ *     Interface address, x25 version. Exactly one of these structures is 
+ *     allocated for each interface with an x25 address.
+ *
+ *     The ifaddr structure conatins the protocol-independent part
+ *     of the structure, and is assumed to be first.
  */
  */
+struct x25_ifaddr {
+       struct  ifaddr ia_ifa;          /* protocol-independent info */
+#define ia_ifp         ia_ifa.ifa_ifp
+#define        ia_flags        ia_ifa.ifa_flags
+       struct  x25_ifaddr *ia_next;    /* next in list of x25 addresses */
+       struct  sockaddr_x25 ia_addr;   /* reserve space for interface name */
+       struct  sockaddr_x25 ia_sockmask; /* reserve space for netmask */
+       struct  x25config *ia_xcp;      /* network specific configuration */
+       struct  x25config *ia_xc;       /* network specific configuration */
+       short   ia_state;               /* packet level status */
+#define ia_maxlcn ia->ia_xc.xc_maxlcn  /* local copy of xc_maxlcn */
+       struct  pklcd **ia_chan;        /* dispatch vector for ciruits */
+};
 
 
-struct pkcb {
-       struct  pkcb *pk_next;
-       short   pk_state;               /* packet level status */
-       short   pk_maxlcn;              /* local copy of xc_maxlcn */
-       int     (*pk_output) ();        /* link level output procedure */
-       struct  x25config *pk_xcp;      /* network specific configuration */
-       struct  pklcd *pk_chan[1];      /* actual size == xc_maxlcn+1 */
+/*
+ * ``Link-Level'' extension to Routing Entry for upper level
+ * packet switching via X.25 virtual circuits.
+ */
+struct rtext_x25 {
+       struct  pklcd *rtx_lcd;
+       int     rtx_state;
+       struct  rtentry *rtx_rt;
 };
 
 #ifdef KERNEL
 };
 
 #ifdef KERNEL
-struct pkcb *pkcbhead;         /* head of linked list of networks */
+struct x25_ifaddr *x25_ifaddr;         /* head of linked list of networks */
 struct pklcd *pk_listenhead;
 
 char   *pk_name[], *pk_state[];
 struct pklcd *pk_listenhead;
 
 char   *pk_name[], *pk_state[];