assign SCCS numbers for ``June'' beta tape; not yet tested.
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Fri, 22 Jun 1990 03:29:24 +0000 (19:29 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Fri, 22 Jun 1990 03:29:24 +0000 (19:29 -0800)
SCCS-vsn: sys/netccitt/ccitt_proto.c 7.4
SCCS-vsn: sys/netccitt/hd_input.c 7.3
SCCS-vsn: sys/netccitt/hd_output.c 7.3
SCCS-vsn: sys/netccitt/hd_subr.c 7.3
SCCS-vsn: sys/netccitt/hd_var.h 7.3
SCCS-vsn: sys/netccitt/pk_input.c 7.4
SCCS-vsn: sys/netccitt/pk_output.c 7.4
SCCS-vsn: sys/netccitt/pk_subr.c 7.5
SCCS-vsn: sys/netccitt/pk_usrreq.c 7.6
SCCS-vsn: sys/netccitt/pk_var.h 7.5
SCCS-vsn: sys/netccitt/x25.h 7.4
SCCS-vsn: sys/netccitt/if_x25subr.c 7.5

usr/src/sys/netccitt/ccitt_proto.c
usr/src/sys/netccitt/hd_input.c
usr/src/sys/netccitt/hd_output.c
usr/src/sys/netccitt/hd_subr.c
usr/src/sys/netccitt/hd_var.h
usr/src/sys/netccitt/if_x25subr.c
usr/src/sys/netccitt/pk_input.c
usr/src/sys/netccitt/pk_output.c
usr/src/sys/netccitt/pk_subr.c
usr/src/sys/netccitt/pk_usrreq.c
usr/src/sys/netccitt/pk_var.h

index bbad48f..baf2eed 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ccitt_proto.c       7.3 (Berkeley) %G%
+ *     @(#)ccitt_proto.c       7.4 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
@@ -35,7 +35,7 @@ int   xe_output (), xe_ctlinput (), xe_init(), xe_timer();
 #ifdef HDLC
 int    hd_output (), hd_ctlinput (), hd_init (), hd_timer ();
 #endif
 #ifdef HDLC
 int    hd_output (), hd_ctlinput (), hd_init (), hd_timer ();
 #endif
-int    pk_usrreq (), pk_timer ();
+int    pk_usrreq (), pk_timer (), pk_init ();
 
 struct protosw ccittsw[] = {
 #ifdef XE
 
 struct protosw ccittsw[] = {
 #ifdef XE
@@ -55,7 +55,7 @@ struct protosw ccittsw[] = {
  {     SOCK_STREAM,    DOMAIN,         CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD,
        0,              0,              0,              0,
        pk_usrreq,
  {     SOCK_STREAM,    DOMAIN,         CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD,
        0,              0,              0,              0,
        pk_usrreq,
-       0,              0,              pk_timer,       0,
+       pk_init,        0,              pk_timer,       0,
  }
 };
 
  }
 };
 
index cdb2ab3..85bc0d5 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_input.c  7.2 (Berkeley) %G%
+ *     @(#)hd_input.c  7.3 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
@@ -349,7 +349,7 @@ register struct Hdlc_iframe *frame;
                                hdp->hd_rrtimer = hd_t3;
 
                /* Forward iframe to packet level of X.25. */
                                hdp->hd_rrtimer = hd_t3;
 
                /* Forward iframe to packet level of X.25. */
-               fbuf -> m_off += HDHEADERLN;
+               fbuf -> m_data += HDHEADERLN;
                fbuf -> m_len -= HDHEADERLN;
 #ifdef BSD4_3
                fbuf->m_act = 0;        /* probably not necessary */
                fbuf -> m_len -= HDHEADERLN;
 #ifdef BSD4_3
                fbuf->m_act = 0;        /* probably not necessary */
index 7e40c08..f47739a 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_output.c 7.2 (Berkeley) %G%
+ *     @(#)hd_output.c 7.3 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
  *      by the input and control routines of the HDLC layer.
  */
 
  *      by the input and control routines of the HDLC layer.
  */
 
-hd_output (m, xcp)
-struct x25config *xcp;
+hd_output (m, info)
 register struct mbuf *m;
 register struct mbuf *m;
+caddr_t        info;
 {
 {
-       register struct hdcb *hdp;
-       static struct x25config *lastxcp;
-       static struct hdcb *lasthdp;
+       register struct hdcb *hdp = (struct hdcb *)info;
+       struct x25config *xcp;
 
        if (m == NULL)
                panic ("hd_output");
 
 
        if (m == NULL)
                panic ("hd_output");
 
-       if (xcp == lastxcp)
-               hdp = lasthdp;
-       else {
-               for (hdp = hdcbhead; ; hdp = hdp->hd_next) {
-                       if (hdp == 0) {
-                               printf("hd_output: can't find hdcb for %X\n", xcp);
-                               m_freem (m);
-                               return;
-                       }
-                       if (hdp->hd_xcp == xcp)
-                               break;
-               }
-               lastxcp = xcp;
-               lasthdp = hdp;
-       }
-
        if (hdp->hd_state != ABM) {
                m_freem (m);
                return;
        if (hdp->hd_state != ABM) {
                m_freem (m);
                return;
@@ -73,21 +56,9 @@ register struct mbuf *m;
         * of the first mbuf in the mbuf chain.
         */
 
         * of the first mbuf in the mbuf chain.
         */
 
-       if (m->m_off < MMINOFF + HDHEADERLN) {
-               register struct mbuf *m0;
-
-               m0 = m_get (M_DONTWAIT, MT_DATA);
-               if (m0 == NULL) {
-                       m_freem (m);
-                       return;
-               }
-               m0->m_next = m;
-               m0->m_len = HDHEADERLN;
-               m = m0;
-       } else {
-               m->m_off -= HDHEADERLN;
-               m->m_len += HDHEADERLN;
-       }
+       M_PREPEND(m, M_DONTWAIT, HDHEADERLN);
+       if (m == NULL)
+               return;
 
        hd_append (&hdp->hd_txq, m);
        hd_start (hdp);
 
        hd_append (&hdp->hd_txq, m);
        hd_start (hdp);
@@ -140,8 +111,8 @@ register struct mbuf *buf;
 int poll_bit;
 {
        register struct Hdlc_iframe *iframe;
 int poll_bit;
 {
        register struct Hdlc_iframe *iframe;
-       register struct ifnet *ifp = hdp->hd_ifp;
        struct mbuf *m;
        struct mbuf *m;
+       int s
 
        KILL_TIMER (hdp);
 
 
        KILL_TIMER (hdp);
 
@@ -182,11 +153,34 @@ int poll_bit;
                printf("hdlc: out of mbufs\n");
                return;
        }
                printf("hdlc: out of mbufs\n");
                return;
        }
-       (*ifp -> if_output) (ifp, m, (struct sockaddr *)hdp->hd_xcp);
-
+       (*hdp->hd_output)(hdp, m);
        SET_TIMER (hdp);
 }
 
        SET_TIMER (hdp);
 }
 
+hd_ifoutput(hdp, m)
+register struct hdcb *hdp;
+register struct mbuf *m;
+{
+       /*
+        * Queue message on interface, and start output if interface
+        * not yet active.
+        */
+       register struct ifnet *ifp = hdp->hdp_ifp;
+       int s = splimp();
+       if (IF_QFULL(&ifp->if_snd)) {
+               IF_DROP(&ifp->if_snd);
+               printf("%s%d: HDLC says OK to send but queue full, may hang\n",
+                       ifp->if_name, ifp->if_unit);
+               m_freem(m);
+       } else {
+               IF_ENQUEUE(&ifp->if_snd, m);
+               if ((ifp->if_flags & IFF_OACTIVE) == 0)
+                       (*ifp->if_start)(ifp);
+       }
+       splx(s);
+}
+
+
 /* 
  *  This routine gets control when the timer expires because we have not
  *  received an acknowledgement for a iframe.
 /* 
  *  This routine gets control when the timer expires because we have not
  *  received an acknowledgement for a iframe.
index a2a3cd0..0dad2ab 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_subr.c   7.2 (Berkeley) %G%
+ *     @(#)hd_subr.c   7.3 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
@@ -260,9 +260,7 @@ register int frametype, pf;
                uframe -> pf = pf;
 
        hd_trace (hdp, TX, frame);
                uframe -> pf = pf;
 
        hd_trace (hdp, TX, frame);
-       (*hdp -> hd_ifp -> if_output) (hdp -> hd_ifp, buf,
-               (struct sockaddr *)hdp->hd_xcp);
-
+       (*hdp->hd_output)(hdp, buf);
 }
 
 struct mbuf *
 }
 
 struct mbuf *
index 701e675..89e940c 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_var.h    7.2 (Berkeley) %G%
+ *     @(#)hd_var.h    7.3 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -45,6 +45,8 @@ struct        hdcb {
 #define KILL_TIMER(hdp)                hdp->hd_timer = 0
        char    hd_dontcopy;    /* if-driver doesn't free I-frames */
        struct  ifnet *hd_ifp;  /* device's network visible interface */
 #define KILL_TIMER(hdp)                hdp->hd_timer = 0
        char    hd_dontcopy;    /* if-driver doesn't free I-frames */
        struct  ifnet *hd_ifp;  /* device's network visible interface */
+       struct  ifaddr *hd_ifa; /* device's X.25 network address */
+       int     (*hd_output)(); /* separate entry for HDLC direct output */
        struct  x25config *hd_xcp;      /* copy of &hdp->hd_if->if_addr */
 
        /* link statistics */
        struct  x25config *hd_xcp;      /* copy of &hdp->hd_if->if_addr */
 
        /* link statistics */
index eb54226..56bfbeb 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)if_x25subr.c        7.4 (Berkeley) %G%
+ *     @(#)if_x25subr.c        7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -102,19 +102,18 @@ register struct   rtentry *rt;
                rtx->rtx_lcd = lcp;
                rtx->rtx_rt = rt;
                rtx->rtx_ia = ia;
                rtx->rtx_lcd = lcp;
                rtx->rtx_rt = rt;
                rtx->rtx_ia = ia;
-               lcp->lcd_upq.pq_next = (caddr_t)rtx;
-               lcp->lcd_upq.pq_put = x25_ifinput;
+               lcp->lcd_upnext = (caddr_t)rtx;
+               lcp->lcd_upper = x25_ifinput;
        }
        }
-       pq = &lcp->lcd_downq;
        switch (rtx->rtx_state) {
 
        case XRS_CONNECTED:
                lcd->lcd_dg_timer = ia->ia_xc.xc_dg_idletimo;
                /* FALLTHROUGH */
        case XRS_CONNECTING:
        switch (rtx->rtx_state) {
 
        case XRS_CONNECTED:
                lcd->lcd_dg_timer = ia->ia_xc.xc_dg_idletimo;
                /* FALLTHROUGH */
        case XRS_CONNECTING:
-               if (pq->pq_space < 0)
+               if (sbspace(&lcp->lcd_sb) < 0)
                        senderr(ENOBUFS);
                        senderr(ENOBUFS);
-               pq->pq_put(pq, m);
+               lcp->lcd_send(lcp, m);
                break;
 
        case XRS_NEWBORN:
                break;
 
        case XRS_NEWBORN:
@@ -122,7 +121,6 @@ register struct     rtentry *rt;
                    ia->xc_if.if_type == IFT_DDN &&
                    rt->rt_gateway->sa_family != AF_CCITT)
                        x25_ddnip_to_ccitt(dst, rt->rt_gateway);
                    ia->xc_if.if_type == IFT_DDN &&
                    rt->rt_gateway->sa_family != AF_CCITT)
                        x25_ddnip_to_ccitt(dst, rt->rt_gateway);
-               pq->pq_space = 2048;  /* XXX: bogus pq before if_start called */
                lcp->lcd_flags |= X25_DG_CIRCUIT;
                rtx->rtx_state = XRS_FREE;
                if (rt->rt_gateway->sa_family != AF_CCITT) {
                lcp->lcd_flags |= X25_DG_CIRCUIT;
                rtx->rtx_state = XRS_FREE;
                if (rt->rt_gateway->sa_family != AF_CCITT) {
@@ -139,21 +137,14 @@ register struct   rtentry *rt;
                        rtx->rtx_state = XRS_RESOLVING;
                        /* FALLTHROUGH */
        case XRS_RESOLVING:
                        rtx->rtx_state = XRS_RESOLVING;
                        /* FALLTHROUGH */
        case XRS_RESOLVING:
-                       if (pq->pq_space < 0)
+                       if (sbspace(&lcp->lcd_sb) < 0)
                                senderr(ENOBUFS);
                                senderr(ENOBUFS);
-                       pq->pq_space -= m->m_pkthdr.len;
-                       if (pq->pq_data == 0)
-                               pq->pq_data = m;
-                       else {
-                               for (m = pq->pq_data; m->m_nextpkt; )
-                                       m = m->m_nextpkt;
-                               m->m_nextpkt = m0;
-                       }
+                       sbappendrecord(&lcp->lcd_sb, m);
                        break;
                }
                /* FALLTHROUGH */
        case XRS_FREE:
                        break;
                }
                /* FALLTHROUGH */
        case XRS_FREE:
-               lcp->lcd_downq.pq_data = m;
+               sbappendrecord(&lcp->lcd_sb, m);
                lcp->lcd_pkcb = &(rtx->rtx_ia->ia_pkcb);
                pk_connect(lcp, (struct mbuf *)0,
                                (struct sockaddr_x25 *)rt->rt_gateway);
                lcp->lcd_pkcb = &(rtx->rtx_ia->ia_pkcb);
                pk_connect(lcp, (struct mbuf *)0,
                                (struct sockaddr_x25 *)rt->rt_gateway);
@@ -211,7 +202,7 @@ struct ifnet *ifp;
                                register struct rtextension_x25 *rtx;
                                pk_disconnect(lcp);
                                rtx = (struct rtextension_x25 *)
                                register struct rtextension_x25 *rtx;
                                pk_disconnect(lcp);
                                rtx = (struct rtextension_x25 *)
-                                               lcp->lcp_upq.pq_next;
+                                               lcp->lcp_upnext;
                                if (rtx)
                                        rtx->rtx_state = XRS_DISCONNECTING;
                            }
                                if (rtx)
                                        rtx->rtx_state = XRS_DISCONNECTING;
                            }
@@ -221,14 +212,12 @@ struct ifnet *ifp;
 /*
  * Process a x25 packet as datagram;
  */
 /*
  * Process a x25 packet as datagram;
  */
-x25_ifinput(pq, m)
-struct pq *pq;
+x25_ifinput(lcp, m)
+struct pklcd *lcp;
 struct mbuf *m;
 {
 struct mbuf *m;
 {
-       struct rtentry *rt = (struct rtentry *)pq->pq_next;
-       struct pklcd *xl = (struct pklcd *)rt->rt_llinfo;
-       register struct ifnet *ifp = &xl->xl_xc.xc_if;
-       register struct llc *l;
+       struct rtextension *rtx = (struct rtentry *)lcp->lcd_upnext;
+       register struct ifnet *ifp = &rtx->rtx_rt->rt_ifp;
        int s;
 
        ifp->if_lastchange = time;
        int s;
 
        ifp->if_lastchange = time;
@@ -350,7 +339,7 @@ struct sockaddr *dst;
        register struct x25_ifaddr *ia;
        register struct sockaddr *sa2;
        struct mbuf *m, *mold;
        register struct x25_ifaddr *ia;
        register struct sockaddr *sa2;
        struct mbuf *m, *mold;
-       int x25_ifrtree();
+       int x25_ifrtfree();
 
        if (rtx == 0)
                return;
 
        if (rtx == 0)
                return;
@@ -364,7 +353,7 @@ struct sockaddr *dst;
        case caseof(XRS_CONNECTING, RTM_DELETE):
        case caseof(XRS_CONNECTING, RTM_CHANGE):
                pk_disconnect(lcp);
        case caseof(XRS_CONNECTING, RTM_DELETE):
        case caseof(XRS_CONNECTING, RTM_CHANGE):
                pk_disconnect(lcp);
-               lcp->lcd_upq.pq_unblock = x25_ifrtfree;
+               lcp->lcd_upper = x25_ifrtfree;
                rt->rt_refcnt++;
                break;
 
                rt->rt_refcnt++;
                break;
 
@@ -375,12 +364,8 @@ struct sockaddr *dst;
                break;
 
        case caseof(XRS_RESOLVING, RTM_DELETE):
                break;
 
        case caseof(XRS_RESOLVING, RTM_DELETE):
-               for (m = lcp->lcd_downq.pq_data; m;) {
-                       mold = m;
-                       m = m->m_nextpkt;
-                       m_freem(mold);
-               }
-               m_free(dtom(rtx->rtx_lcd));
+               sbflush(&(rtx->rtx_lcd->lcd_sb));
+               free((caddr_t)rtx->rtx_lcd, M_PCB);
                rtx->rtx_lcd = 0;
                break;
 
                rtx->rtx_lcd = 0;
                break;
 
@@ -394,7 +379,7 @@ struct sockaddr *dst;
        sa2 = SA(rt->rt_key);
        if (cmd == RTM_CHANGE) {
                if (sa->sa_family == AF_CCITT) {
        sa2 = SA(rt->rt_key);
        if (cmd == RTM_CHANGE) {
                if (sa->sa_family == AF_CCITT) {
-                       sa->sa_rfamily = sa2->sa_family;
+                       sa->x25_opts.op_speed = sa2->sa_family;
                        (void) rtrequest(RTM_DELETE, SA(sa), sa2,
                               SA(0), RTF_HOST, (struct rtentry **)0);
                }
                        (void) rtrequest(RTM_DELETE, SA(sa), sa2,
                               SA(0), RTF_HOST, (struct rtentry **)0);
                }
@@ -402,12 +387,13 @@ struct sockaddr *dst;
                cmd = RTM_ADD;
        }
        if (sa->sa_family == AF_CCITT) {
                cmd = RTM_ADD;
        }
        if (sa->sa_family == AF_CCITT) {
-               sa->sa_rfamily = sa2->sa_family;
+               sa->x25_opts.op_speed = sa2->sa_family;
                (void) rtrequest(cmd, SA(sa), sa2, SA(0), RTF_HOST,
                                                        (struct rtentry **)0);
                (void) rtrequest(cmd, SA(sa), sa2, SA(0), RTF_HOST,
                                                        (struct rtentry **)0);
-               sa->sa_rfamily = 0;
+               sa->x25_opts.op_speed = 0;
        }
 }
        }
 }
+
 static struct sockaddr sin = {sizeof(sin), AF_INET};
 /*
  * This is a utility routine to be called by x25 devices when a
 static struct sockaddr sin = {sizeof(sin), AF_INET};
 /*
  * This is a utility routine to be called by x25 devices when a
@@ -487,12 +473,12 @@ register struct x25com *ia;
                 * This uses the X25 routing table to do inverse
                 * lookup of x25 address to sockaddr.
                 */
                 * This uses the X25 routing table to do inverse
                 * lookup of x25 address to sockaddr.
                 */
-               dst->sa_rfamily = af;
+               dst->x25_opts.op_speed = af;
                if (rt = rtalloc1(dst, 0)) {
                        sa = rt->rt_gateway;
                        rt->rt_refcnt--;
                }
                if (rt = rtalloc1(dst, 0)) {
                        sa = rt->rt_gateway;
                        rt->rt_refcnt--;
                }
-               dst->sa_rfamily = 0;
+               dst->x25_opts.op_speed = 0;
        }
        /* 
         * Call to rtalloc1 will create rtentry for reverse path
        }
        /* 
         * Call to rtalloc1 will create rtentry for reverse path
@@ -502,3 +488,14 @@ register struct x25com *ia;
        if (sa && rt = rtalloc1(sa, 1))
                rt->rt_refcnt--;
 }
        if (sa && rt = rtalloc1(sa, 1))
                rt->rt_refcnt--;
 }
+
+struct radix_tree_head *x25_rnhead;
+
+pk_init()
+{
+       /*
+        * warning, sizeof (struct sockaddr_x25) > 32,
+        * but contains no data of interest beyond 32
+        */
+       rn_inithead(&x25_rnhead, 16, AF_CCITT);
+}
index 361905c..32e6455 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_input.c  7.3 (Berkeley) %G%
+ *     @(#)pk_input.c  7.4 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
@@ -239,12 +239,12 @@ struct x25config *xcp;
                        break;
                }
 
                        break;
                }
 
-               m -> m_off += PKHEADERLN;
+               m -> m_data += PKHEADERLN;
                m -> m_len -= PKHEADERLN;
                if (lcp -> lcd_flags & X25_MQBIT) {
                        octet *t;
 
                m -> m_len -= PKHEADERLN;
                if (lcp -> lcd_flags & X25_MQBIT) {
                        octet *t;
 
-                       m -> m_off -= 1;
+                       m -> m_data -= 1;
                        m -> m_len += 1;
                        t = mtod (m, octet *);
                        *t = 0x00;
                        m -> m_len += 1;
                        t = mtod (m, octet *);
                        *t = 0x00;
@@ -525,7 +525,8 @@ struct x25_packet *xp;
                        errstr = "server malfunction";
                        break;
                }
                        errstr = "server malfunction";
                        break;
                }
-               lcp -> lcd_upq.pq_put = lcp -> lcd_upq.pq_put;
+               lcp -> lcd_upper = l -> lcd_upper;
+               lcp -> lcd_upnext = l -> lcd_upnext;
                lcp -> lcd_lcn = lcn;
                lcp -> lcd_state = RECEIVED_CALL;
                lcp -> lcd_craddr = sa;
                lcp -> lcd_lcn = lcn;
                lcp -> lcd_state = RECEIVED_CALL;
                lcp -> lcd_craddr = sa;
@@ -533,9 +534,11 @@ struct x25_packet *xp;
                        ~X25_REVERSE_CHARGE;
                pk_assoc (pkp, lcp, sa);
                lcp -> lcd_template = pk_template (lcp -> lcd_lcn, X25_CALL_ACCEPTED);
                        ~X25_REVERSE_CHARGE;
                pk_assoc (pkp, lcp, sa);
                lcp -> lcd_template = pk_template (lcp -> lcd_lcn, X25_CALL_ACCEPTED);
-               pk_output (lcp);
-               if (so)
+               if (so) {
+                       pk_output (lcp);
                        soisconnected (so);
                        soisconnected (so);
+               } else if (lcp->lcd_upper)
+                       (*lcp->lcd_upper)(lcp);
                return;
        }
 
                return;
        }
 
index 0059aa3..6c939dd 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_output.c 7.3 (Berkeley) %G%
+ *     @(#)pk_output.c 7.4 (Berkeley) %G%
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
@@ -144,7 +144,7 @@ register struct pklcd *lcp;
                pk_trace (pkp -> pk_xcp, xp, "P-Out");
 
                /* Pass the packet on down to the link layer */
                pk_trace (pkp -> pk_xcp, xp, "P-Out");
 
                /* Pass the packet on down to the link layer */
-               (*pkp -> pk_lloutput) (m, pkp -> pk_xcp);
+               (*pkp -> pk_lloutput) (m, pkp -> llnext);
        }
 }
 
        }
 }
 
@@ -157,8 +157,9 @@ struct mbuf *
 nextpk (lcp)
 struct pklcd *lcp;
 {
 nextpk (lcp)
 struct pklcd *lcp;
 {
-       register struct socket *so = lcp -> lcd_so;
-       register struct mbuf *m = 0, *n;
+       register struct mbuf *m, *n;
+       struct socket *so = lcp -> lcd_so;
+       register struct sockbuf *sb = & (so ? so -> so_snd : lcp -> lcd_sb);
 
        if (lcp -> lcd_template) {
                m = dtom (lcp -> lcd_template);
 
        if (lcp -> lcd_template) {
                m = dtom (lcp -> lcd_template);
@@ -168,27 +169,13 @@ struct pklcd *lcp;
                                lcp -> lcd_reset_condition)
                        return (NULL);
 
                                lcp -> lcd_reset_condition)
                        return (NULL);
 
-               if (so == 0) {
-                       if ((m = lcp->lcd_downq.pq_data) == 0)
-                               return (NULL);
-                       lcp->lcd_downq.pq_data = m->m_nextpkt;
-                       lcp->lcd_downq.pq_space += m->m_pkthdr.len;
-                       m->m_nextpkt = 0;
-                               return (m);
-               }
-
-               if ((m = so -> so_snd.sb_mb) == 0)
+               if ((m = sb -> sb_mb) == 0)
                        return (NULL);
 
                        return (NULL);
 
-               n = m;
-               while (n) {
-                       sbfree (&so -> so_snd, n);
-                       n = n -> m_next;
-               }
-
-               so->so_snd.sb_mb = m->m_act;
+               sb -> sb_mb = m -> m_nextpkt;
                m->m_act = 0;
                m->m_act = 0;
+               for (n = m; n; n = n -> m_next)
+                       sbfree (sb, n);
        }
        }
-
        return (m);
 }
        return (m);
 }
index cbd2728..82e30d8 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_subr.c   7.4 (Berkeley) %G%
+ *     @(#)pk_subr.c   7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -53,14 +53,13 @@ struct socket *so;
                bzero((caddr_t)lcp, sizeof(*lcp));
                if (so) {
                        error = soreserve (so, pk_sendspace, pk_recvspace);
                bzero((caddr_t)lcp, sizeof(*lcp));
                if (so) {
                        error = soreserve (so, pk_sendspace, pk_recvspace);
-                       so -> so_snd.sb_mbmax = pk_sendspace;
                        lcp -> lcd_so = so;
                        if (so -> so_options & SO_ACCEPTCONN)
                                lcp -> lcd_state = LISTEN;
                        else
                                lcp -> lcd_state = READY;
                        lcp -> lcd_so = so;
                        if (so -> so_options & SO_ACCEPTCONN)
                                lcp -> lcd_state = LISTEN;
                        else
                                lcp -> lcd_state = READY;
-               }
-
+               } else
+                       sbreserve (&lcp -> lcd_sb, pk_sendpace);
        }
        if (so) {
                so -> so_pcb = (caddr_t) lcp;
        }
        if (so) {
                so -> so_pcb = (caddr_t) lcp;
@@ -593,8 +592,8 @@ unsigned pr;
 
        if (so && ((so -> so_snd.sb_flags & SB_WAIT) || so -> so_snd.sb_sel))
                sowwakeup (so);
 
        if (so && ((so -> so_snd.sb_flags & SB_WAIT) || so -> so_snd.sb_sel))
                sowwakeup (so);
-       if (lcp -> lcd_downq.pq_unblock)
-               (*lcp -> lcd_downq.pq_unblock)(lcp);
+       if (lcp -> lcd_upper)
+               (*lcp -> lcd_upper)(lcp, 0);
 
        return (PACKET_OK);
 }
 
        return (PACKET_OK);
 }
index dd1147d..019bb97 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_usrreq.c 7.5 (Berkeley) %G%
+ *     @(#)pk_usrreq.c 7.6 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -263,7 +263,7 @@ register struct pklcd *lcp;
 {
        extern int pk_send();
 
 {
        extern int pk_send();
 
-       lcp -> lcp_downq.pq_put = pk_send;
+       lcp -> lcp_send = pk_send;
        return (pk_output(lcp));
 }
 
        return (pk_output(lcp));
 }
 
@@ -486,7 +486,7 @@ register struct mbuf *m;
        if (lcp -> lcd_so)
                sbappendrecord (&lcp -> lcd_so -> so_snd, m0);
        else
        if (lcp -> lcd_so)
                sbappendrecord (&lcp -> lcd_so -> so_snd, m0);
        else
-               pq_appendrecord (&lcp -> lcd_downq, m0);
+               sbappendrecord (&lcp -> lcd_sb, m0);
        lcp -> lcd_template = 0;
        lcp -> lcd_txcnt++;
        pk_output (lcp);
        lcp -> lcd_template = 0;
        lcp -> lcd_txcnt++;
        pk_output (lcp);
index f831fe6..127c1a4 100644 (file)
@@ -9,23 +9,9 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_var.h    7.4 (Berkeley) %G%
+ *     @(#)pk_var.h    7.5 (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 */
-};
 
 /*
  *
 
 /*
  *
@@ -34,7 +20,9 @@ struct        pq      {
  */
 
 struct pklcd {
  */
 
 struct pklcd {
-       struct  pq lcd_downq, lcd_upq;  /* protocol glue for datagram service */
+       int     (*lcd_send)();          /* if X.25 front end, direct connect */
+       int     (*lcd_upper)();         /* switch to socket vs datagram vs ...*/
+       caddr_t lcd_upnext;             /* reference for lcd_upper() */
        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 */
@@ -66,6 +54,7 @@ struct pklcd {
        struct  pkcb *lcd_pkp;          /* Network this lcd is attached to */
        struct  sockaddr_x25 lcd_faddr  /* Remote Address (Calling) */
        struct  sockaddr_x25 lcd_laddr  /* Local Address (Called) */
        struct  pkcb *lcd_pkp;          /* Network this lcd is attached to */
        struct  sockaddr_x25 lcd_faddr  /* Remote Address (Calling) */
        struct  sockaddr_x25 lcd_laddr  /* Local Address (Called) */
+       struct  sockbuf lcd_sb;         /* alternate for datagram service */
 };
 
 #define X25_DG_CIRCUIT 0x10            /* lcd_flag: used for datagrams */
 };
 
 #define X25_DG_CIRCUIT 0x10            /* lcd_flag: used for datagrams */
@@ -80,6 +69,7 @@ struct        pkcb {
        struct  pkcb *pk_next;
        struct  x25_ifaddr *pk_ia;      /* backpointer to ifaddr */
        int     (*pk_lloutput) ();      /* link level output procedure */
        struct  pkcb *pk_next;
        struct  x25_ifaddr *pk_ia;      /* backpointer to ifaddr */
        int     (*pk_lloutput) ();      /* link level output procedure */
+       caddr_t pk_llnext;              /* handle for next level down */
        int     (*pk_start) ();         /* connect, confirm method */
        struct  x25config *pk_xcp;      /* network specific configuration */
        short   pk_state;               /* packet level status */
        int     (*pk_start) ();         /* connect, confirm method */
        struct  x25config *pk_xcp;      /* network specific configuration */
        short   pk_state;               /* packet level status */