this version compiles; completely untested
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Fri, 31 Aug 1990 09:48:45 +0000 (01:48 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Fri, 31 Aug 1990 09:48:45 +0000 (01:48 -0800)
SCCS-vsn: sys/netccitt/ccitt_proto.c 7.5
SCCS-vsn: sys/netccitt/hd_debug.c 7.3
SCCS-vsn: sys/netccitt/hd_input.c 7.4
SCCS-vsn: sys/netccitt/hd_output.c 7.4
SCCS-vsn: sys/netccitt/hd_subr.c 7.4
SCCS-vsn: sys/netccitt/hd_timer.c 7.3
SCCS-vsn: sys/netccitt/pk.h 7.3
SCCS-vsn: sys/netccitt/pk_acct.c 7.3
SCCS-vsn: sys/netccitt/pk_debug.c 7.3
SCCS-vsn: sys/netccitt/pk_input.c 7.5
SCCS-vsn: sys/netccitt/pk_output.c 7.5
SCCS-vsn: sys/netccitt/pk_subr.c 7.6
SCCS-vsn: sys/netccitt/pk_timer.c 7.3
SCCS-vsn: sys/netccitt/pk_usrreq.c 7.7
SCCS-vsn: sys/netccitt/pk_var.h 7.6
SCCS-vsn: sys/netccitt/x25.h 7.4
SCCS-vsn: sys/netccitt/if_x25subr.c 7.6

17 files changed:
usr/src/sys/netccitt/ccitt_proto.c
usr/src/sys/netccitt/hd_debug.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_timer.c
usr/src/sys/netccitt/if_x25subr.c
usr/src/sys/netccitt/pk.h
usr/src/sys/netccitt/pk_acct.c
usr/src/sys/netccitt/pk_debug.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_timer.c
usr/src/sys/netccitt/pk_usrreq.c
usr/src/sys/netccitt/pk_var.h
usr/src/sys/netccitt/x25.h

index baf2eed..e8781f7 100644 (file)
@@ -9,14 +9,15 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ccitt_proto.c       7.4 (Berkeley) %G%
+ *     @(#)ccitt_proto.c       7.5 (Berkeley) %G%
  */
  */
+#define HDLC
+#include "param.h"
+#include "socket.h"
+#include "protosw.h"
+#include "domain.h"
 
 
-#include "../h/param.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/domain.h"
-#include "../netccitt/x25.h"
+#include "x25.h"
 
 /*
  *     Definitions of protocols supported in the CCITT domain.
 
 /*
  *     Definitions of protocols supported in the CCITT domain.
@@ -35,7 +36,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 (), pk_init ();
+int    pk_usrreq (), pk_timer (), pk_init (), pk_ctloutput ();
 
 struct protosw ccittsw[] = {
 #ifdef XE
 
 struct protosw ccittsw[] = {
 #ifdef XE
@@ -53,7 +54,7 @@ struct protosw ccittsw[] = {
  },
 #endif
  {     SOCK_STREAM,    DOMAIN,         CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD,
  },
 #endif
  {     SOCK_STREAM,    DOMAIN,         CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD,
-       0,              0,              0,              0,
+       0,              0,              0,              pk_ctloutput,
        pk_usrreq,
        pk_init,        0,              pk_timer,       0,
  }
        pk_usrreq,
        pk_init,        0,              pk_timer,       0,
  }
index 33d0088..0087e42 100644 (file)
@@ -9,24 +9,24 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_debug.c  7.2 (Berkeley) %G%
+ *     @(#)hd_debug.c  7.3 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/domain.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/errno.h"
-#include "../h/time.h"
-#include "../h/kernel.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "domain.h"
+#include "socket.h"
+#include "protosw.h"
+#include "errno.h"
+#include "time.h"
+#include "kernel.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/hdlc.h"
-#include "../netccitt/hd_var.h"
-#include "../netccitt/x25.h"
+#include "hdlc.h"
+#include "hd_var.h"
+#include "x25.h"
 
 #ifdef HDLCDEBUG
 #define NTRACE         32
 
 #ifdef HDLCDEBUG
 #define NTRACE         32
index 85bc0d5..8d7e37f 100644 (file)
@@ -9,24 +9,24 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_input.c  7.3 (Berkeley) %G%
+ *     @(#)hd_input.c  7.4 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/domain.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/errno.h"
-#include "../h/time.h"
-#include "../h/kernel.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "domain.h"
+#include "socket.h"
+#include "protosw.h"
+#include "errno.h"
+#include "time.h"
+#include "kernel.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/hdlc.h"
-#include "../netccitt/hd_var.h"
-#include "../netccitt/x25.h"
+#include "hdlc.h"
+#include "hd_var.h"
+#include "x25.h"
 
 /*
  *      HDLC INPUT INTERFACE
 
 /*
  *      HDLC INPUT INTERFACE
index f47739a..cda58af 100644 (file)
@@ -9,23 +9,24 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_output.c 7.3 (Berkeley) %G%
+ *     @(#)hd_output.c 7.4 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/domain.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/errno.h"
-#include "../h/time.h"
-#include "../h/kernel.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "domain.h"
+#include "socket.h"
+#include "protosw.h"
+#include "errno.h"
+#include "time.h"
+#include "kernel.h"
+
 #include "../net/if.h"
 
 #include "../net/if.h"
 
-#include "../netccitt/hdlc.h"
-#include "../netccitt/hd_var.h"
-#include "../netccitt/x25.h"
+#include "hdlc.h"
+#include "hd_var.h"
+#include "x25.h"
 
 /*
  *      HDLC OUTPUT INTERFACE
 
 /*
  *      HDLC OUTPUT INTERFACE
@@ -112,7 +113,6 @@ int poll_bit;
 {
        register struct Hdlc_iframe *iframe;
        struct mbuf *m;
 {
        register struct Hdlc_iframe *iframe;
        struct mbuf *m;
-       int s
 
        KILL_TIMER (hdp);
 
 
        KILL_TIMER (hdp);
 
@@ -165,7 +165,7 @@ register struct mbuf *m;
         * Queue message on interface, and start output if interface
         * not yet active.
         */
         * Queue message on interface, and start output if interface
         * not yet active.
         */
-       register struct ifnet *ifp = hdp->hdp_ifp;
+       register struct ifnet *ifp = hdp->hd_ifp;
        int s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
        int s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
index 0dad2ab..097abf3 100644 (file)
@@ -9,24 +9,24 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_subr.c   7.3 (Berkeley) %G%
+ *     @(#)hd_subr.c   7.4 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/domain.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/errno.h"
-#include "../h/time.h"
-#include "../h/kernel.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "domain.h"
+#include "socket.h"
+#include "protosw.h"
+#include "errno.h"
+#include "time.h"
+#include "kernel.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/hdlc.h"
-#include "../netccitt/hd_var.h"
-#include "../netccitt/x25.h"
+#include "hdlc.h"
+#include "hd_var.h"
+#include "x25.h"
 
 hd_init ()
 {
 
 hd_init ()
 {
@@ -42,12 +42,12 @@ caddr_t addr;
        register struct hdcb *hdp;
        register struct ifaddr *ifa;
 
        register struct hdcb *hdp;
        register struct ifaddr *ifa;
 
-       if (xcp->xc_family != AF_CCITT)
+       if (xcp->xc_addr.x25_family != AF_CCITT)
                return (EAFNOSUPPORT);
        if (xcp->xc_lptype != HDLCPROTO_LAPB)
                return (EPROTONOSUPPORT);
        for (ifa = ifa_ifwithaddr ((struct sockaddr *)xcp); ifa; ifa = ifa->ifa_next)
                return (EAFNOSUPPORT);
        if (xcp->xc_lptype != HDLCPROTO_LAPB)
                return (EPROTONOSUPPORT);
        for (ifa = ifa_ifwithaddr ((struct sockaddr *)xcp); ifa; ifa = ifa->ifa_next)
-               if (ifa->ifa_addr.sa_family == AF_CCITT)
+               if (ifa->ifa_addr->sa_family == AF_CCITT)
                        break;
        if (ifa == 0 || (ifp = ifa->ifa_ifp) == 0)
                panic ("hd_ctlinput");
                        break;
        if (ifa == 0 || (ifp = ifa->ifa_ifp) == 0)
                panic ("hd_ctlinput");
index ab9c6ba..4d62f5d 100644 (file)
@@ -9,24 +9,24 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hd_timer.c  7.2 (Berkeley) %G%
+ *     @(#)hd_timer.c  7.3 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/domain.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/errno.h"
-#include "../h/time.h"
-#include "../h/kernel.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "domain.h"
+#include "socket.h"
+#include "protosw.h"
+#include "errno.h"
+#include "time.h"
+#include "kernel.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/hdlc.h"
-#include "../netccitt/hd_var.h"
-#include "../netccitt/x25.h"
+#include "hdlc.h"
+#include "hd_var.h"
+#include "x25.h"
 
 /*
  * these can be patched with adb if the
 
 /*
  * these can be patched with adb if the
index 56bfbeb..8c36981 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)if_x25subr.c        7.5 (Berkeley) %G%
+ *     @(#)if_x25subr.c        7.6 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 #include "mbuf.h"
 #include "protosw.h"
 #include "socket.h"
 #include "mbuf.h"
 #include "protosw.h"
 #include "socket.h"
+#include "socketvar.h"
 #include "ioctl.h"
 #include "errno.h"
 #include "syslog.h"
 
 #include "../net/if.h"
 #include "ioctl.h"
 #include "errno.h"
 #include "syslog.h"
 
 #include "../net/if.h"
+#include "../net/if_types.h"
 #include "../net/netisr.h"
 #include "../net/route.h"
 
 #include "x25.h"
 #include "../net/netisr.h"
 #include "../net/route.h"
 
 #include "x25.h"
-#include "x25error.h"
+#include "x25err.h"
+#include "pk.h"
 #include "pk_var.h"
 
 #include "machine/mtpr.h"
 #include "pk_var.h"
 
 #include "machine/mtpr.h"
 
 extern struct ifnet loif;
 
 
 extern struct ifnet loif;
 
+union imp_addr {
+       struct in_addr  ip;
+       struct imp {
+               u_char          s_net;
+               u_char          s_host;
+               u_char          s_lh;
+               u_char          s_impno;
+       }                   imp;
+};
+
 #define senderr(x) {error = x; goto bad;}
 /*
  * X.25 output routine.
 #define senderr(x) {error = x; goto bad;}
 /*
  * X.25 output routine.
@@ -56,14 +69,13 @@ struct      sockaddr *dst;
 register struct        rtentry *rt;
 {
        register struct mbuf *m;
 register struct        rtentry *rt;
 {
        register struct mbuf *m;
-       register struct rtextension_x25 *rtx;
+       register struct llinfo_x25 *lx;
        register struct pq *pq;
        struct pklcd *lcp;
        struct x25_ifaddr *ia;
        struct mbuf    *prev;
        int             s, error = 0, flags = 0;
        union imp_addr  imp_addr;
        register struct pq *pq;
        struct pklcd *lcp;
        struct x25_ifaddr *ia;
        struct mbuf    *prev;
        int             s, error = 0, flags = 0;
        union imp_addr  imp_addr;
-       int flags = 0;
 
        if ((ifp->if_flags & IFF_UP) == 0)
                return (ENETDOWN);
 
        if ((ifp->if_flags & IFF_UP) == 0)
                return (ENETDOWN);
@@ -72,14 +84,14 @@ register struct     rtentry *rt;
                if ((rt = rtalloc1(dst, 1)) == 0)
                        return (EHOSTUNREACH);
                rt->rt_refcnt++;
                if ((rt = rtalloc1(dst, 1)) == 0)
                        return (EHOSTUNREACH);
                rt->rt_refcnt++;
-               flags = XRF_RTHELD;
+               flags = LXF_RTHELD;
        }
        /*
         * Sanity checks.
         */
        if ((rt->rt_ifp != ifp) ||
            (rt->rt_flags & (RTF_CLONING | RTF_GATEWAY)) ||
        }
        /*
         * Sanity checks.
         */
        if ((rt->rt_ifp != ifp) ||
            (rt->rt_flags & (RTF_CLONING | RTF_GATEWAY)) ||
-           ((rtx = (struct rtextension_x25 *)rt->rt_llinfo) == 0)) {
+           ((lx = (struct llinfo_x25 *)rt->rt_llinfo) == 0)) {
                printf("Inconsistent call to x25_output, should panic\n");
                senderr(ENETUNREACH);
        }
                printf("Inconsistent call to x25_output, should panic\n");
                senderr(ENETUNREACH);
        }
@@ -93,59 +105,59 @@ register struct    rtentry *rt;
        }
        ia = (struct x25_ifaddr *)ifa;
     }
        }
        ia = (struct x25_ifaddr *)ifa;
     }
-       if (rtx->rtx_lcd == 0) {
+       if (lx->lx_lcd == 0) {
                int x25_ifinput();
 
                lcp = pk_attach((struct socket *)0);
                if (lcp == 0)
                        senderr(ENOBUFS);
                int x25_ifinput();
 
                lcp = pk_attach((struct socket *)0);
                if (lcp == 0)
                        senderr(ENOBUFS);
-               rtx->rtx_lcd = lcp;
-               rtx->rtx_rt = rt;
-               rtx->rtx_ia = ia;
-               lcp->lcd_upnext = (caddr_t)rtx;
+               lx->lx_lcd = lcp;
+               lx->lx_rt = rt;
+               lx->lx_ia = ia;
+               lcp->lcd_upnext = (caddr_t)lx;
                lcp->lcd_upper = x25_ifinput;
        }
                lcp->lcd_upper = x25_ifinput;
        }
-       switch (rtx->rtx_state) {
+       switch (lx->lx_state) {
 
 
-       case XRS_CONNECTED:
-               lcd->lcd_dg_timer = ia->ia_xc.xc_dg_idletimo;
+       case LXS_CONNECTED:
+               lcp->lcd_dg_timer = ia->ia_xc.xc_dg_idletimo;
                /* FALLTHROUGH */
                /* FALLTHROUGH */
-       case XRS_CONNECTING:
+       case LXS_CONNECTING:
                if (sbspace(&lcp->lcd_sb) < 0)
                        senderr(ENOBUFS);
                lcp->lcd_send(lcp, m);
                break;
 
                if (sbspace(&lcp->lcd_sb) < 0)
                        senderr(ENOBUFS);
                lcp->lcd_send(lcp, m);
                break;
 
-       case XRS_NEWBORN:
+       case LXS_NEWBORN:
                if (dst->sa_family == AF_INET &&
                if (dst->sa_family == AF_INET &&
-                   ia->xc_if.if_type == IFT_DDN &&
+                   ia->ia_ifp->if_type == IFT_X25DDN &&
                    rt->rt_gateway->sa_family != AF_CCITT)
                        x25_ddnip_to_ccitt(dst, rt->rt_gateway);
                lcp->lcd_flags |= X25_DG_CIRCUIT;
                    rt->rt_gateway->sa_family != AF_CCITT)
                        x25_ddnip_to_ccitt(dst, rt->rt_gateway);
                lcp->lcd_flags |= X25_DG_CIRCUIT;
-               rtx->rtx_state = XRS_FREE;
+               lx->lx_state = LXS_FREE;
                if (rt->rt_gateway->sa_family != AF_CCITT) {
                        /*
                         * Need external resolution of dst
                         */
                        if ((rt->rt_flags & RTF_XRESOLVE) == 0)
                                senderr(ENETUNREACH);
                if (rt->rt_gateway->sa_family != AF_CCITT) {
                        /*
                         * Need external resolution of dst
                         */
                        if ((rt->rt_flags & RTF_XRESOLVE) == 0)
                                senderr(ENETUNREACH);
-                       rtx->rtx_flags |= flags;
+                       lx->lx_flags |= flags;
                        flags = 0;
                        rt_missmsg(RTM_RESOLVE, dst,
                            (struct sockaddr *)0, (struct sockaddr *)0,
                            (struct sockaddr *)0, 0, 0);
                        flags = 0;
                        rt_missmsg(RTM_RESOLVE, dst,
                            (struct sockaddr *)0, (struct sockaddr *)0,
                            (struct sockaddr *)0, 0, 0);
-                       rtx->rtx_state = XRS_RESOLVING;
+                       lx->lx_state = LXS_RESOLVING;
                        /* FALLTHROUGH */
                        /* FALLTHROUGH */
-       case XRS_RESOLVING:
+       case LXS_RESOLVING:
                        if (sbspace(&lcp->lcd_sb) < 0)
                                senderr(ENOBUFS);
                        sbappendrecord(&lcp->lcd_sb, m);
                        break;
                }
                /* FALLTHROUGH */
                        if (sbspace(&lcp->lcd_sb) < 0)
                                senderr(ENOBUFS);
                        sbappendrecord(&lcp->lcd_sb, m);
                        break;
                }
                /* FALLTHROUGH */
-       case XRS_FREE:
+       case LXS_FREE:
                sbappendrecord(&lcp->lcd_sb, m);
                sbappendrecord(&lcp->lcd_sb, m);
-               lcp->lcd_pkcb = &(rtx->rtx_ia->ia_pkcb);
+               lcp->lcd_pkp = &(lx->lx_ia->ia_pkcb);
                pk_connect(lcp, (struct mbuf *)0,
                                (struct sockaddr_x25 *)rt->rt_gateway);
                break;
                pk_connect(lcp, (struct mbuf *)0,
                                (struct sockaddr_x25 *)rt->rt_gateway);
                break;
@@ -170,7 +182,7 @@ register struct     rtentry *rt;
                        m_freem(m);
        }
 out:
                        m_freem(m);
        }
 out:
-       if (flags & XRF_RTHELD)
+       if (flags & LXF_RTHELD)
                RTFREE(rt);
        return (error);
 }
                RTFREE(rt);
        return (error);
 }
@@ -197,14 +209,14 @@ struct ifnet *ifp;
                     --lcpp >= pkcb->pk_chan;)
                        if ((lcp = *lcpp) &&
                            lcp->lcd_state == DATA_TRANSFER &&
                     --lcpp >= pkcb->pk_chan;)
                        if ((lcp = *lcpp) &&
                            lcp->lcd_state == DATA_TRANSFER &&
-                           (lcp->lcd_flags & X25_DG_CICRUIT) &&
+                           (lcp->lcd_flags & X25_DG_CIRCUIT) &&
                            (--(lcp->lcd_dg_timer) <= 0)) {
                            (--(lcp->lcd_dg_timer) <= 0)) {
-                               register struct rtextension_x25 *rtx;
+                               register struct llinfo_x25 *lx;
                                pk_disconnect(lcp);
                                pk_disconnect(lcp);
-                               rtx = (struct rtextension_x25 *)
-                                               lcp->lcp_upnext;
-                               if (rtx)
-                                       rtx->rtx_state = XRS_DISCONNECTING;
+                               lx = (struct llinfo_x25 *)
+                                               lcp->lcd_upnext;
+                               if (lx)
+                                       lx->lx_state = LXS_DISCONNECTING;
                            }
        splx(s);
 }
                            }
        splx(s);
 }
@@ -216,13 +228,16 @@ x25_ifinput(lcp, m)
 struct pklcd *lcp;
 struct mbuf *m;
 {
 struct pklcd *lcp;
 struct mbuf *m;
 {
-       struct rtextension *rtx = (struct rtentry *)lcp->lcd_upnext;
-       register struct ifnet *ifp = &rtx->rtx_rt->rt_ifp;
+       struct llinfo_x25 *lx = (struct llinfo_x25 *)lcp->lcd_upnext;
+       struct rtentry *rt = lx->lx_rt;
+       register struct ifnet *ifp = rt->rt_ifp;
+       struct ifqueue *inq;
+       extern struct timeval time;
        int s;
 
        ifp->if_lastchange = time;
 
        int s;
 
        ifp->if_lastchange = time;
 
-       switch (rt_dst(rt)->sa_family) {
+       switch ((rt_key(rt))->sa_family) {
 #ifdef INET
        case AF_INET:
                schednetisr(NETISR_IP);
 #ifdef INET
        case AF_INET:
                schednetisr(NETISR_IP);
@@ -260,16 +275,6 @@ struct mbuf *m;
        }
        splx(s);
 }
        }
        splx(s);
 }
-
-union imp_addr {
-       struct in_addr  ip;
-       struct imp {
-               u_char          s_net;
-               u_char          s_host;
-               u_char          s_lh;
-               u_char          s_impno;
-       }                   imp;
-};
 static struct sockaddr_x25 blank_x25 = {sizeof blank_x25, AF_CCITT};
 /*
  * IP to X25 address routine copyright ACC, used by permission.
 static struct sockaddr_x25 blank_x25 = {sizeof blank_x25, AF_CCITT};
 /*
  * IP to X25 address routine copyright ACC, used by permission.
@@ -279,11 +284,11 @@ struct sockaddr_in *src;
 register struct sockaddr_x25 *dst;
 {
        union imp_addr imp_addr;
 register struct sockaddr_x25 *dst;
 {
        union imp_addr imp_addr;
-       int             imp_no, imp_port;
-       char *x25addr = dst->x25_x25addr;
+       int             imp_no, imp_port, temp;
+       char *x25addr = dst->x25_addr;
 
 
 
 
-       imp_addr.ip = src->sin_addr.s_addr;
+       imp_addr.ip = src->sin_addr;
        *dst = blank_x25;
        if ((imp_addr.imp.s_net & 0x80) == 0x00) {      /* class A */
            imp_no = imp_addr.imp.s_impno;
        *dst = blank_x25;
        if ((imp_addr.imp.s_net & 0x80) == 0x00) {      /* class A */
            imp_no = imp_addr.imp.s_impno;
@@ -333,7 +338,7 @@ x25_ifrtchange(cmd, rt, dst)
 register struct rtentry *rt;
 struct sockaddr *dst;
 {
 register struct rtentry *rt;
 struct sockaddr *dst;
 {
-       register struct rtextension_x25 *rtx = (struct pklcd *)rt->rt_llinfo;
+       register struct llinfo_x25 *lx = (struct llinfo_x25 *)rt->rt_llinfo;
        register struct sockaddr_x25 *sa =(struct sockaddr_x25 *)rt->rt_gateway;
        register struct pklcd *lcp;
        register struct x25_ifaddr *ia;
        register struct sockaddr_x25 *sa =(struct sockaddr_x25 *)rt->rt_gateway;
        register struct pklcd *lcp;
        register struct x25_ifaddr *ia;
@@ -341,44 +346,44 @@ struct sockaddr *dst;
        struct mbuf *m, *mold;
        int x25_ifrtfree();
 
        struct mbuf *m, *mold;
        int x25_ifrtfree();
 
-       if (rtx == 0)
+       if (lx == 0)
                return;
                return;
-       ia = rtx->rtx_ia;
-       lcp = rtx->rtx_lcd;
+       ia = lx->lx_ia;
+       lcp = lx->lx_lcd;
 
 
-       switch (caseof(xl->xl_state, cmd)) {
+       switch (caseof(lx->lx_state, cmd)) {
 
 
-       case caseof(XRS_CONNECTED, RTM_DELETE):
-       case caseof(XRS_CONNECTED, RTM_CHANGE):
-       case caseof(XRS_CONNECTING, RTM_DELETE):
-       case caseof(XRS_CONNECTING, RTM_CHANGE):
+       case caseof(LXS_CONNECTED, RTM_DELETE):
+       case caseof(LXS_CONNECTED, RTM_CHANGE):
+       case caseof(LXS_CONNECTING, RTM_DELETE):
+       case caseof(LXS_CONNECTING, RTM_CHANGE):
                pk_disconnect(lcp);
                lcp->lcd_upper = x25_ifrtfree;
                rt->rt_refcnt++;
                break;
 
                pk_disconnect(lcp);
                lcp->lcd_upper = x25_ifrtfree;
                rt->rt_refcnt++;
                break;
 
-       case caseof(XRS_CONNECTED, RTM_ADD):
-       case caseof(XRS_CONNECTING, RTM_ADD):
-       case caseof(XRS_RESOLVING, RTM_ADD):
+       case caseof(LXS_CONNECTED, RTM_ADD):
+       case caseof(LXS_CONNECTING, RTM_ADD):
+       case caseof(LXS_RESOLVING, RTM_ADD):
                printf("ifrtchange: impossible transition, should panic\n");
                break;
 
                printf("ifrtchange: impossible transition, should panic\n");
                break;
 
-       case caseof(XRS_RESOLVING, RTM_DELETE):
-               sbflush(&(rtx->rtx_lcd->lcd_sb));
-               free((caddr_t)rtx->rtx_lcd, M_PCB);
-               rtx->rtx_lcd = 0;
+       case caseof(LXS_RESOLVING, RTM_DELETE):
+               sbflush(&(lx->lx_lcd->lcd_sb));
+               free((caddr_t)lx->lx_lcd, M_PCB);
+               lx->lx_lcd = 0;
                break;
 
                break;
 
-       case caseof(XRS_RESOLVING, RTM_CHANGE):
-               lcp->lcd_pkcb = &(ia->ia_pkcb);
+       case caseof(LXS_RESOLVING, RTM_CHANGE):
+               lcp->lcd_pkp = &(ia->ia_pkcb);
                pk_connect(lcp, (struct mbuf *)0, sa);
                break;
        }
                pk_connect(lcp, (struct mbuf *)0, sa);
                break;
        }
-       if (rt->rt_ifp->if_type == IFT_DDN)
+       if (rt->rt_ifp->if_type == IFT_X25DDN)
                return;
                return;
-       sa2 = SA(rt->rt_key);
+       sa2 = rt_key(rt);
        if (cmd == RTM_CHANGE) {
        if (cmd == RTM_CHANGE) {
-               if (sa->sa_family == AF_CCITT) {
+               if (sa->x25_family == AF_CCITT) {
                        sa->x25_opts.op_speed = sa2->sa_family;
                        (void) rtrequest(RTM_DELETE, SA(sa), sa2,
                               SA(0), RTF_HOST, (struct rtentry **)0);
                        sa->x25_opts.op_speed = sa2->sa_family;
                        (void) rtrequest(RTM_DELETE, SA(sa), sa2,
                               SA(0), RTF_HOST, (struct rtentry **)0);
@@ -386,7 +391,7 @@ struct sockaddr *dst;
                sa = (struct sockaddr_x25 *)dst;
                cmd = RTM_ADD;
        }
                sa = (struct sockaddr_x25 *)dst;
                cmd = RTM_ADD;
        }
-       if (sa->sa_family == AF_CCITT) {
+       if (sa->x25_family == AF_CCITT) {
                sa->x25_opts.op_speed = sa2->sa_family;
                (void) rtrequest(cmd, SA(sa), sa2, SA(0), RTF_HOST,
                                                        (struct rtentry **)0);
                sa->x25_opts.op_speed = sa2->sa_family;
                (void) rtrequest(cmd, SA(sa), sa2, SA(0), RTF_HOST,
                                                        (struct rtentry **)0);
@@ -394,19 +399,22 @@ struct sockaddr *dst;
        }
 }
 
        }
 }
 
-static struct sockaddr sin = {sizeof(sin), AF_INET};
+static struct sockaddr_in sin = {sizeof(sin), AF_INET};
 /*
  * This is a utility routine to be called by x25 devices when a
  * call request is honored with the intent of starting datagram forwarding.
  */
 x25_dg_rtinit(dst, ia, af)
 struct sockaddr_x25 *dst;
 /*
  * This is a utility routine to be called by x25 devices when a
  * call request is honored with the intent of starting datagram forwarding.
  */
 x25_dg_rtinit(dst, ia, af)
 struct sockaddr_x25 *dst;
-register struct x25com *ia;
+register struct x25_ifaddr *ia;
 {
        struct sockaddr *sa = 0;
 {
        struct sockaddr *sa = 0;
-       if (ia->xc_if.if_type == IFT_DDN && af == AF_INET) {
+       struct rtentry *rt;
+       struct in_addr my_addr;
+
+       if (ia->ia_ifp->if_type == IFT_X25DDN && af == AF_INET) {
        /*
        /*
-        * Inverse X25 to IPP mapping copyright and courtesy ACC.
+        * Inverse X25 to IP mapping copyright and courtesy ACC.
         */
                int             imp_no, imp_port, temp;
                union imp_addr imp_addr;
         */
                int             imp_no, imp_port, temp;
                union imp_addr imp_addr;
@@ -414,11 +422,12 @@ register struct x25com *ia;
                /*
                 * First determine our IP addr for network
                 */
                /*
                 * First determine our IP addr for network
                 */
-               register struct in_ifaddr *ia;
+               register struct in_ifaddr *ina;
                extern struct in_ifaddr *in_ifaddr;
                extern struct in_ifaddr *in_ifaddr;
-               for (ia = in_ifaddr; ia; ia = ia->ia_next)
-                       if (ia->ia_ifp == &ia->xc_if) {
-                               imp_addr.ip = ia->ia_addr.sin_addr;
+
+               for (ina = in_ifaddr; ina; ina = ina->ia_next)
+                       if (ina->ia_ifp == ia->ia_ifp) {
+                               my_addr = ina->ia_addr.sin_addr;
                                break;
                        }
            }
                                break;
                        }
            }
@@ -451,7 +460,7 @@ register struct x25com *ia;
                  default:
                    return (0L);
                }
                  default:
                    return (0L);
                }
-               imp_addr.ip.s_addr = my_addr;
+               imp_addr.ip = my_addr;
                if ((imp_addr.imp.s_net & 0x80) == 0x00) {
                /* class A */
                    imp_addr.imp.s_host = imp_port;
                if ((imp_addr.imp.s_net & 0x80) == 0x00) {
                /* class A */
                    imp_addr.imp.s_host = imp_port;
@@ -485,7 +494,7 @@ register struct x25com *ia;
         * to callee by virtue of cloning magic and will allocate
         * space for local control block.
         */
         * to callee by virtue of cloning magic and will allocate
         * space for local control block.
         */
-       if (sa && rt = rtalloc1(sa, 1))
+       if (sa && (rt = rtalloc1(sa, 1)))
                rt->rt_refcnt--;
 }
 
                rt->rt_refcnt--;
 }
 
index 9ae645c..3a0911c 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk.h        7.2 (Berkeley) %G%
+ *     @(#)pk.h        7.3 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -89,7 +89,7 @@ typedef u_char octet;
 struct x25_calladdr {
        octet ORDER2(called_addrlen:4, calling_addrlen:4);
        octet address_field[MAXADDRLN];
 struct x25_calladdr {
        octet ORDER2(called_addrlen:4, calling_addrlen:4);
        octet address_field[MAXADDRLN];
-}
+};
 
 struct x25_packet {
        octet ORDER3(lc_group_number:4, fmt_identifier:3, q_bit:1);
 
 struct x25_packet {
        octet ORDER3(lc_group_number:4, fmt_identifier:3, q_bit:1);
index ddeff55..848f646 100644 (file)
@@ -9,44 +9,31 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_acct.c   7.2 (Berkeley) %G%
+ *     @(#)pk_acct.c   7.3 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#ifdef NFS
+#include "param.h
 #include "systm.h"
 #include "systm.h"
-#include "dir.h"
+#include "time.h"
+#include "proc.h"
 #include "user.h"
 #include "vnode.h"
 #include "user.h"
 #include "vnode.h"
-#include "vfs.h"
 #include "kernel.h"
 #include "kernel.h"
+#include "file.h"
+#include "acct.h"
 #include "uio.h"
 #include "uio.h"
-#else
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/kernel.h"
-#ifdef BSD4_3
-#include "../h/namei.h"
-#else
-#include "../h/nami.h"
-#endif
-#include "../h/uio.h"
-#endif
+#include "socket.h"
+#include "socketvar.h"
 
 
-#include "../netccitt/pk.h"
-#include "../netccitt/pk_var.h"
-#include "../netccitt/x25.h"
-#include "../netccitt/x25acct.h"
+#include "../net/if.h"
 
 
+#include "x25.h"
+#include "pk.h"
+#include "pk_var.h"
+#include "x25acct.h"
 
 
-#ifdef NFS
-struct vnode *pkacctp;
-#else
-struct inode *pkacctp;
-#endif
 
 
+struct vnode *pkacctp;
 /* 
  *  Turn on packet accounting
  */
 /* 
  *  Turn on packet accounting
  */
@@ -54,53 +41,23 @@ struct      inode *pkacctp;
 pk_accton (path)
        char *path;
 {
 pk_accton (path)
        char *path;
 {
-#ifdef NFS
-       register int error;
-       struct vnode *vp;
-#else
-#ifdef BSD4_3
-       struct nameidata *ndp = &u.u_nd;
-#endif
-       register struct inode *ip;
-#endif
-
-#ifdef NFS
-       if (error = lookupname(path, UIO_USERSPACE, FOLLOW_LINK,
-               (struct vnode **)0, &vp))
+       register struct vnode *vp = NULL;
+       register struct nameidata *ndp = &u.u_nd;
+       struct vnode *oacctp = pkacctp;
+       int error;
+
+       ndp -> ni_segflg = UIO_USERSPACE;
+       ndp -> ni_dirp = path;
+       if (error = vn_open (ndp, FREAD|FWRITE, 0))
                return (error);
                return (error);
-       if (vp->v_type != VREG) {
-               VN_RELE(vp);
+       vp = ndp -> ni_vp;
+       if (vp -> v_type != VREG) {
+               vrele (vp);
                return (EACCES);
        }
                return (EACCES);
        }
-       if (vp->v_vfsp->vfs_flag & VFS_RDONLY) {
-               VN_RELE(vp);
-               return (EROFS);
-       }
        pkacctp = vp;
        pkacctp = vp;
-#else
-#ifdef BSD4_3
-       ndp->ni_nameiop = LOOKUP | FOLLOW;
-       ndp->ni_segflg = UIO_USERSPACE;
-       ndp->ni_dirp = path;
-       ip = namei(ndp);
-#else
-       u.u_dirp = path;
-       ip = namei (schar, LOOKUP, 1);
-#endif
-       if (ip == NULL)
-               return (u.u_error);
-
-       if ((ip -> i_mode & IFMT) != IFREG) {
-               iput (ip);
-               return (EACCES);
-       }
-       if (pkacctp)
-               if (pkacctp->i_number != ip->i_number ||
-                   pkacctp->i_dev != ip->i_dev)
-                       irele(pkacctp);
-       pkacctp = ip;
-       iunlock (ip);
-#endif
+       if (oacctp)
+               vrele (oacctp);
        return (0);
 }
 
        return (0);
 }
 
@@ -111,11 +68,7 @@ pk_accton (path)
 pk_acctoff ()
 {
        if (pkacctp) {
 pk_acctoff ()
 {
        if (pkacctp) {
-#ifdef NFS
-               VN_RELE(pkacctp);
-#else
-               irele (pkacctp);
-#endif
+               vrele (pkacctp);
                pkacctp = 0;
        }
 }
                pkacctp = 0;
        }
 }
@@ -127,27 +80,15 @@ pk_acctoff ()
 pk_acct (lcp)
 register struct pklcd *lcp;
 {
 pk_acct (lcp)
 register struct pklcd *lcp;
 {
-#ifdef NFS
        register struct vnode *vp;
        register struct vnode *vp;
-#else
-       register struct inode *ip;
-       off_t siz;
-#endif
        register struct sockaddr_x25 *sa;
        register char *src, *dst;
        register int len;
        register struct sockaddr_x25 *sa;
        register char *src, *dst;
        register int len;
-#ifndef WATERLOO
        register long etime;
        register long etime;
-#endif
        static struct x25acct acbuf;
 
        static struct x25acct acbuf;
 
-#ifdef NFS
        if ((vp = pkacctp) == 0)
        if ((vp = pkacctp) == 0)
-#else
-       if ((ip = pkacctp) == 0)
-#endif
                return;
                return;
-
        bzero ((caddr_t)&acbuf, sizeof (acbuf));
        if (lcp -> lcd_ceaddr != 0)
                sa = lcp -> lcd_ceaddr;
        bzero ((caddr_t)&acbuf, sizeof (acbuf));
        if (lcp -> lcd_ceaddr != 0)
                sa = lcp -> lcd_ceaddr;
@@ -160,12 +101,7 @@ register struct pklcd *lcp;
        if (sa -> x25_opts.op_flags & X25_REVERSE_CHARGE)
                acbuf.x25acct_revcharge = 1;
        acbuf.x25acct_stime = lcp -> lcd_stime;
        if (sa -> x25_opts.op_flags & X25_REVERSE_CHARGE)
                acbuf.x25acct_revcharge = 1;
        acbuf.x25acct_stime = lcp -> lcd_stime;
-#ifdef WATERLOO
        acbuf.x25acct_etime = time.tv_sec - acbuf.x25acct_stime;
        acbuf.x25acct_etime = time.tv_sec - acbuf.x25acct_stime;
-#else
-       etime = time.tv_sec - acbuf.x25acct_stime;
-       acbuf.x25acct_etime = etime > 0xffff ? 0xffff : etime;
-#endif
        acbuf.x25acct_uid = u.u_uid;
        acbuf.x25acct_psize = sa -> x25_opts.op_psize;
        acbuf.x25acct_net = sa -> x25_net;
        acbuf.x25acct_uid = u.u_uid;
        acbuf.x25acct_psize = sa -> x25_opts.op_psize;
        acbuf.x25acct_net = sa -> x25_net;
@@ -186,15 +122,6 @@ register struct pklcd *lcp;
        acbuf.x25acct_txcnt = lcp -> lcd_txcnt;
        acbuf.x25acct_rxcnt = lcp -> lcd_rxcnt;
 
        acbuf.x25acct_txcnt = lcp -> lcd_txcnt;
        acbuf.x25acct_rxcnt = lcp -> lcd_rxcnt;
 
-#ifdef NFS
        (void) vn_rdwr(UIO_WRITE, vp, (caddr_t)&acbuf, sizeof (acbuf),
        (void) vn_rdwr(UIO_WRITE, vp, (caddr_t)&acbuf, sizeof (acbuf),
-               (off_t)0, UIO_SYSSPACE, IO_UNIT|IO_APPEND, (int *)0);
-#else
-       ilock (ip);
-       siz = ip -> i_size;
-       if (rdwri (UIO_WRITE, ip, (caddr_t)&acbuf, sizeof (acbuf),
-           siz, 1, (int *) 0))
-               itrunc (ip, (u_long) siz);
-       iunlock (ip);
-#endif
+               (off_t)0, UIO_SYSSPACE, IO_UNIT|IO_APPEND, u.u_cred, (int *)0);
 }
 }
index 54653f7..014eb19 100644 (file)
@@ -9,20 +9,22 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_debug.c  7.2 (Berkeley) %G%
+ *     @(#)pk_debug.c  7.3 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/socketvar.h"
-#include "../h/errno.h"
-
-#include "../netccitt/x25.h"
-#include "../netccitt/pk.h"
-#include "../netccitt/pk_var.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "socket.h"
+#include "protosw.h"
+#include "socketvar.h"
+#include "errno.h"
+
+#include "../net/if.h"
+
+#include "x25.h"
+#include "pk.h"
+#include "pk_var.h"
 
 char   *pk_state[] = {
        "Listen",       "Ready",        "Received-Call",
 
 char   *pk_state[] = {
        "Listen",       "Ready",        "Received-Call",
index 32e6455..6899f78 100644 (file)
@@ -9,22 +9,22 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_input.c  7.4 (Berkeley) %G%
+ *     @(#)pk_input.c  7.5 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/socketvar.h"
-#include "../h/errno.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "socket.h"
+#include "protosw.h"
+#include "socketvar.h"
+#include "errno.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/x25.h"
-#include "../netccitt/pk.h"
-#include "../netccitt/pk_var.h"
+#include "x25.h"
+#include "pk.h"
+#include "pk_var.h"
 
 /* 
  *  This procedure is called by the link level whenever the link
 
 /* 
  *  This procedure is called by the link level whenever the link
@@ -501,7 +501,8 @@ struct x25_packet *xp;
 
                if (bcmp (sxp -> x25_udata, sa -> x25_udata, sxp->x25_udlen))
                        continue;
 
                if (bcmp (sxp -> x25_udata, sa -> x25_udata, sxp->x25_udlen))
                        continue;
-               if (sxp -> x25_net && sxp -> x25_net != pkp->pk_xcp->xc_net)
+               if (sxp -> x25_net &&
+                   sxp -> x25_net != pkp->pk_xc.xc_addr.x25_net)
                        continue;
                /*
                 * don't accept incoming collect calls unless
                        continue;
                /*
                 * don't accept incoming collect calls unless
@@ -513,7 +514,7 @@ struct x25_packet *xp;
                        break;
                }
                if (l -> lcd_so) {
                        break;
                }
                if (l -> lcd_so) {
-                       if (so = sonewconn (l -> lcd_so, SO_ISCONNETED))
+                       if (so = sonewconn (l -> lcd_so, SS_ISCONNECTED))
                                    lcp = (struct pklcd *) so -> so_pcb;
                } else 
                        lcp = pk_attach((struct socket *) 0);
                                    lcp = (struct pklcd *) so -> so_pcb;
                } else 
                        lcp = pk_attach((struct socket *) 0);
index 6c939dd..ce6473e 100644 (file)
@@ -9,22 +9,22 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_output.c 7.4 (Berkeley) %G%
+ *     @(#)pk_output.c 7.5 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../h/socketvar.h"
-#include "../h/protosw.h"
-#include "../h/errno.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "socket.h"
+#include "socketvar.h"
+#include "protosw.h"
+#include "errno.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/pk.h"
-#include "../netccitt/pk_var.h"
-#include "../netccitt/x25.h"
+#include "x25.h"
+#include "pk.h"
+#include "pk_var.h"
 
 struct mbuf *nextpk ();
 
 
 struct mbuf *nextpk ();
 
@@ -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 -> llnext);
+               (*pkp -> pk_lloutput) (m, pkp -> pk_llnext);
        }
 }
 
        }
 }
 
index 82e30d8..66b071a 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_subr.c   7.5 (Berkeley) %G%
+ *     @(#)pk_subr.c   7.6 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -59,7 +59,7 @@ struct socket *so;
                        else
                                lcp -> lcd_state = READY;
                } else
                        else
                                lcp -> lcd_state = READY;
                } else
-                       sbreserve (&lcp -> lcd_sb, pk_sendpace);
+                       sbreserve (&lcp -> lcd_sb, pk_sendspace);
        }
        if (so) {
                so -> so_pcb = (caddr_t) lcp;
        }
        if (so) {
                so -> so_pcb = (caddr_t) lcp;
@@ -261,7 +261,7 @@ struct mbuf *nam;
                for (pkp = pkcbhead; ; pkp = pkp -> pk_next) {
                        if (pkp == 0)
                                return (ENETUNREACH);
                for (pkp = pkcbhead; ; pkp = pkp -> pk_next) {
                        if (pkp == 0)
                                return (ENETUNREACH);
-                       if (pkp -> pk_xcp -> xc_net == sa -> x25_net)
+                       if (pkp -> pk_xcp -> xc_addr.x25_net == sa -> x25_net)
                                break;
                }
 
                                break;
                }
 
@@ -302,7 +302,7 @@ register struct sockaddr_x25 *sa;
                lcp -> lcd_windowsize = sa -> x25_opts.op_wsize;
        else
                sa -> x25_opts.op_wsize = lcp -> lcd_windowsize;
                lcp -> lcd_windowsize = sa -> x25_opts.op_wsize;
        else
                sa -> x25_opts.op_wsize = lcp -> lcd_windowsize;
-       sa -> x25_net = pkp -> pk_xcp -> xc_net;
+       sa -> x25_net = pkp -> pk_xcp -> xc_addr.x25_net;
        lcp -> lcd_flags = sa -> x25_opts.op_flags;
        lcp -> lcd_stime = time.tv_sec;
 }
        lcp -> lcd_flags = sa -> x25_opts.op_flags;
        lcp -> lcd_stime = time.tv_sec;
 }
@@ -333,7 +333,7 @@ struct mbuf *nam;
                 */
                if (sa -> x25_net == 0 && pkp -> pk_next == 0)
                        break;
                 */
                if (sa -> x25_net == 0 && pkp -> pk_next == 0)
                        break;
-               if (sa -> x25_net == pkp -> pk_xcp -> xc_net)
+               if (sa -> x25_net == pkp -> pk_xcp -> xc_addr.x25_net)
                        break;
        }
 
                        break;
        }
 
@@ -344,7 +344,7 @@ struct mbuf *nam;
        lcp -> lcd_faddr = *sa;
        lcp -> lcd_ceaddr = & lcp->lcd_faddr;
        pk_assoc (pkp, lcp, lcp -> lcd_ceaddr);
        lcp -> lcd_faddr = *sa;
        lcp -> lcd_ceaddr = & lcp->lcd_faddr;
        pk_assoc (pkp, lcp, lcp -> lcd_ceaddr);
-       if (lcp -> so)
+       if (lcp -> lcd_so)
                soisconnecting (lcp -> lcd_so);
        lcp -> lcd_template = pk_template (lcp -> lcd_lcn, X25_CALL);
        pk_callrequest (lcp, lcp -> lcd_ceaddr, pkp -> pk_xcp);
                soisconnecting (lcp -> lcd_so);
        lcp -> lcd_template = pk_template (lcp -> lcd_lcn, X25_CALL);
        pk_callrequest (lcp, lcp -> lcd_ceaddr, pkp -> pk_xcp);
@@ -365,16 +365,13 @@ register struct x25config *xcp;
        register struct mbuf *m = dtom (lcp -> lcd_template);
        unsigned posn = 0;
        octet *cp;
        register struct mbuf *m = dtom (lcp -> lcd_template);
        unsigned posn = 0;
        octet *cp;
-       char addr[sizeof (xcp -> xc_ntn) * 2];
 
        a = (struct x25_calladdr *) &lcp -> lcd_template -> packet_data;
 
        a = (struct x25_calladdr *) &lcp -> lcd_template -> packet_data;
-       a -> calling_addrlen = xcp -> xc_ntnlen;
-       cp = (octet *) xcp -> xc_ntn;
-       from_bcd (addr, &cp, xcp -> xc_ntnlen);
+       a -> calling_addrlen = strlen (xcp -> xc_addr.x25_addr);
        a -> called_addrlen = strlen (sa -> x25_addr);
        cp = (octet *) a -> address_field;
        to_bcd (&cp, (int)a -> called_addrlen, sa -> x25_addr, &posn);
        a -> called_addrlen = strlen (sa -> x25_addr);
        cp = (octet *) a -> address_field;
        to_bcd (&cp, (int)a -> called_addrlen, sa -> x25_addr, &posn);
-       to_bcd (&cp, (int)a -> calling_addrlen, addr, &posn);
+       to_bcd (&cp, (int)a -> calling_addrlen, xcp -> xc_addr.x25_addr, &posn);
        if (posn & 0x01)
                *cp++ &= 0xf0;
 
        if (posn & 0x01)
                *cp++ &= 0xf0;
 
@@ -764,21 +761,8 @@ char *
 format_ntn (xcp)
 register struct x25config *xcp;
 {
 format_ntn (xcp)
 register struct x25config *xcp;
 {
-       register int i;
-       register char *src, *dest;
-       static char ntn[12];
-
-       src = xcp->xc_ntn;
-       dest = ntn;
-       for (i = 0; i < xcp->xc_ntnlen / 2; i++) {
-               *dest++ = ((*src & 0xf0) >> 4) + '0';
-               *dest++ = (*src++ & 0xf) + '0';
-       }
-       if (xcp->xc_ntnlen & 01)
-               dest[-1] = 0;
-       else
-               *dest = 0;
-       return (ntn);
+
+       return (xcp -> xc_addr.x25_addr);
 }
 
 /* VARARGS1 */
 }
 
 /* VARARGS1 */
index e492e86..d1ade45 100644 (file)
@@ -9,21 +9,22 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_timer.c  7.2 (Berkeley) %G%
+ *     @(#)pk_timer.c  7.3 (Berkeley) %G%
  */
 
  */
 
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mbuf.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/socketvar.h"
-#include "../h/errno.h"
+#include "param.h"
+#include "systm.h"
+#include "mbuf.h"
+#include "socket.h"
+#include "protosw.h"
+#include "socketvar.h"
+#include "errno.h"
 
 #include "../net/if.h"
 
 
 #include "../net/if.h"
 
-#include "../netccitt/pk.h"
-#include "../netccitt/pk_var.h"
+#include "x25.h"
+#include "pk.h"
+#include "pk_var.h"
 
 /*
  * Various timer values.  They can be adjusted
 
 /*
  * Various timer values.  They can be adjusted
index 019bb97..aa92376 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_usrreq.c 7.6 (Berkeley) %G%
+ *     @(#)pk_usrreq.c 7.7 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -69,8 +69,6 @@ struct mbuf *control;
                req, (struct x25_packet *)0);
 */
 
                req, (struct x25_packet *)0);
 */
 
-               return (EINVAL);
-
        switch (req) {
        /* 
         *  X.25 attaches to socket via PRU_ATTACH and allocates a logical
        switch (req) {
        /* 
         *  X.25 attaches to socket via PRU_ATTACH and allocates a logical
@@ -83,7 +81,9 @@ struct mbuf *control;
                        /* Socket already connected. */
                        break;
                }
                        /* Socket already connected. */
                        break;
                }
-               error = pk_attach (so);
+               lcp = pk_attach (so);
+               if (lcp == 0)
+                       error = ENOBUFS;
                break;
 
        /* 
                break;
 
        /* 
@@ -263,7 +263,7 @@ register struct pklcd *lcp;
 {
        extern int pk_send();
 
 {
        extern int pk_send();
 
-       lcp -> lcp_send = pk_send;
+       lcp -> lcd_send = pk_send;
        return (pk_output(lcp));
 }
 
        return (pk_output(lcp));
 }
 
@@ -294,13 +294,12 @@ register struct ifnet *ifp;
        case SIOCGIFCONF_X25:
                if (ifa == 0)
                        return (EADDRNOTAVAIL);
        case SIOCGIFCONF_X25:
                if (ifa == 0)
                        return (EADDRNOTAVAIL);
-               ifr->ifr_xc = *(struct sockaddr *)ia->ia_xc;
+               ifr->ifr_xc = ia->ia_xc;
                return (0);
 
        case SIOCSIFCONF_X25:
                return (0);
 
        case SIOCSIFCONF_X25:
-               if (!suser())
-                       return (u.u_error);
-
+               if (error = suser(u.u_cred, &u.u_acflag))
+                       return (error);
                if (ifp == 0)
                        panic("pk_control");
                if (ifa == (struct ifaddr *)0) {
                if (ifp == 0)
                        panic("pk_control");
                if (ifa == (struct ifaddr *)0) {
@@ -318,15 +317,15 @@ register struct ifnet *ifp;
                                ifp->if_addrlist = &ia->ia_ifa;
                        ifa = &ia->ia_ifa;
                        ifa->ifa_netmask = (struct sockaddr *)&ia->ia_sockmask;
                                ifp->if_addrlist = &ia->ia_ifa;
                        ifa = &ia->ia_ifa;
                        ifa->ifa_netmask = (struct sockaddr *)&ia->ia_sockmask;
-                       ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr;
+                       ifa->ifa_addr = (struct sockaddr *)&ia->ia_xc.xc_addr;
                        ia->ia_ifp = ifp;
                        ia->ia_pkcb.pk_ia = ia;
                        ia->ia_pkcb.pk_next = pkcbhead;
                        pkcbhead = &ia->ia_pkcb;
                }
                ia->ia_xcp = &(ifr->ifr_xc);
                        ia->ia_ifp = ifp;
                        ia->ia_pkcb.pk_ia = ia;
                        ia->ia_pkcb.pk_next = pkcbhead;
                        pkcbhead = &ia->ia_pkcb;
                }
                ia->ia_xcp = &(ifr->ifr_xc);
-               if (ia->ia_chan && (ia->ia_maxlcn != ia->xcp->xc_maxlcn)) {
-                       pk_restart(&ia->ia_pkp, X25_RESTART_NETWORK_CONGESTION);
+               if (ia->ia_chan && (ia->ia_maxlcn != ia->ia_xcp->xc_maxlcn)) {
+                       pk_restart(&ia->ia_pkcb, X25_RESTART_NETWORK_CONGESTION);
                        dev_lcp = ia->ia_chan[0];
                        free((caddr_t)ia->ia_chan, M_IFADDR);
                        ia->ia_chan = 0;
                        dev_lcp = ia->ia_chan[0];
                        free((caddr_t)ia->ia_chan, M_IFADDR);
                        ia->ia_chan = 0;
@@ -338,7 +337,7 @@ register struct ifnet *ifp;
                                bzero((caddr_t)ia->ia_chan, n);
                                if (dev_lcp == 0)
                                        dev_lcp = pk_attach((struct socket *)0);
                                bzero((caddr_t)ia->ia_chan, n);
                                if (dev_lcp == 0)
                                        dev_lcp = pk_attach((struct socket *)0);
-                               ia->ia_chan = dev_lcp;
+                               ia->ia_chan[0] = dev_lcp;
                        } else {
                                if (dev_lcp)
                                        pk_close(dev_lcp);
                        } else {
                                if (dev_lcp)
                                        pk_close(dev_lcp);
@@ -352,13 +351,10 @@ register struct ifnet *ifp;
                 */
                s = splimp();
                if (ifp->if_ioctl)
                 */
                s = splimp();
                if (ifp->if_ioctl)
-                       error = (*ifp->if_ioctl)(ifp, SIOCSIFCONF_X25, ifa)));
+                       error = (*ifp->if_ioctl)(ifp, SIOCSIFCONF_X25, ifa);
                splx(s);
                if (error == 0) {
                        ia->ia_xc = *ia->ia_xcp;
                splx(s);
                if (error == 0) {
                        ia->ia_xc = *ia->ia_xcp;
-#ifndef WATERLOO
-                       (void) pk_accton ();
-#endif
                }
                ia->ia_xcp = &ia->ia_xc;
                return (error);
                }
                ia->ia_xcp = &ia->ia_xc;
                return (error);
@@ -370,6 +366,34 @@ register struct ifnet *ifp;
        }
 }
 
        }
 }
 
+pk_ctloutput(cmd, so, level, optname, mp)
+struct socket *so;
+struct mbuf **mp;
+int cmd, level, optname;
+{
+       register struct mbuf *m = *mp;
+       int error;
+
+       if (cmd == PRCO_SETOPT) switch (optname) {
+       case PK_ACCTFILE:
+               if (m == 0)
+                       return (EINVAL);
+               if (m->m_len)
+                       error = pk_accton(mtod(m, char *));
+               else
+                       error = pk_accton((char *)0);
+               (void) m_freem(m);
+               *mp = 0;
+               return (error);
+       }
+       if (*mp) {
+               (void) m_freem(*mp);
+               *mp = 0;
+       }
+       return (EOPNOTSUPP);
+
+}
+
 /*
  * Do an in-place conversion of an "old style"
  * socket address to the new style
 /*
  * Do an in-place conversion of an "old style"
  * socket address to the new style
index 127c1a4..6411d24 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pk_var.h    7.5 (Berkeley) %G%
+ *     @(#)pk_var.h    7.6 (Berkeley) %G%
  */
 
 
  */
 
 
@@ -52,8 +52,8 @@ struct pklcd {
        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 */
        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  sockaddr_x25 lcd_faddr  /* Remote Address (Calling) */
-       struct  sockaddr_x25 lcd_laddr  /* Local Address (Called) */
+       struct  sockaddr_x25 lcd_faddr; /* Remote Address (Calling) */
+       struct  sockaddr_x25 lcd_laddr; /* Local Address (Called) */
        struct  sockbuf lcd_sb;         /* alternate for datagram service */
 };
 
        struct  sockbuf lcd_sb;         /* alternate for datagram service */
 };
 
@@ -91,7 +91,8 @@ struct x25_ifaddr {
        struct  pkcb    ia_pkcb;        /* per network information */
 #define ia_maxlcn      ia_pkcb.pk_maxlcn
 #define ia_chan                ia_pkcb.pk_chan
        struct  pkcb    ia_pkcb;        /* per network information */
 #define ia_maxlcn      ia_pkcb.pk_maxlcn
 #define ia_chan                ia_pkcb.pk_chan
-#define        ia_addr         ia_pkcb.pk_xc.xc_addr
+#define ia_xc          ia_pkcb.pk_xc
+#define ia_xcp         ia_pkcb.pk_xcp
        struct  sockaddr_x25 ia_sockmask; /* reserve space for netmask */
 };
 
        struct  sockaddr_x25 ia_sockmask; /* reserve space for netmask */
 };
 
@@ -99,26 +100,26 @@ struct x25_ifaddr {
  * ``Link-Level'' extension to Routing Entry for upper level
  * packet switching via X.25 virtual circuits.
  */
  * ``Link-Level'' extension to Routing Entry for upper level
  * packet switching via X.25 virtual circuits.
  */
-struct rtextension_x25 {
-       struct  pklcd *rtx_lcd;         /* local connection block */
-       struct  rtentry *rtx_rt;        /* back pointer to route */
-       struct  x25_ifaddr *rtx_ia;     /* may not be same as rt_ifa */
-       int     rtx_state;              /* can't trust lcd->lcd_state */
-       int     rtx_flags;
-       int     rtx_timer;              /* for idle timeout */
+struct llinfo_x25 {
+       struct  pklcd *lx_lcd;          /* local connection block */
+       struct  rtentry *lx_rt;         /* back pointer to route */
+       struct  x25_ifaddr *lx_ia;      /* may not be same as rt_ifa */
+       int     lx_state;               /* can't trust lcd->lcd_state */
+       int     lx_flags;
+       int     lx_timer;               /* for idle timeout */
 };
 
 };
 
-/* States for rtx_state */
-#define XRS_NEWBORN            0
-#define XRS_RESOLVING          1
-#define XRS_FREE               2
-#define XRS_CONNECTED          3
-#define XRS_CONNECTING         4
-#define XRS_DISCONNECTING      5
+/* States for lx_state */
+#define LXS_NEWBORN            0
+#define LXS_RESOLVING          1
+#define LXS_FREE               2
+#define LXS_CONNECTED          3
+#define LXS_CONNECTING         4
+#define LXS_DISCONNECTING      5
 
 /* flags */
 
 /* flags */
-#define XRF_VALID      0x1             /* Circuit is live, etc. */
-#define XRF_RTHELD     0x2             /* this lcb references rtentry */
+#define LXF_VALID      0x1             /* Circuit is live, etc. */
+#define LXF_RTHELD     0x2             /* this lcb references rtentry */
 
 #ifdef KERNEL
 struct pkcb *pkcbhead;         /* head of linked list of networks */
 
 #ifdef KERNEL
 struct pkcb *pkcbhead;         /* head of linked list of networks */
index fc418a4..cb1e0ed 100644 (file)
@@ -29,6 +29,9 @@
 #define HDLCPROTO_UNSET                3
 #define HDLCPROTO_LAPD         4
 
 #define HDLCPROTO_UNSET                3
 #define HDLCPROTO_LAPD         4
 
+/* socket options */
+#define PK_ACCTFILE            1       /* use level = CCITTPROTO_X25 */
+
 /*
  *  X.25 Socket address structure.  It contains the  X.121 or variation of
  *  X.121, facilities information, higher level protocol value (first four
 /*
  *  X.25 Socket address structure.  It contains the  X.121 or variation of
  *  X.121, facilities information, higher level protocol value (first four
@@ -100,7 +103,7 @@ struct      x25config {
                xc_ptrace:1,    /* packet level tracing flag */
                xc_rsvd2:5;
        u_short xc_maxlcn;      /* max logical channels */
                xc_ptrace:1,    /* packet level tracing flag */
                xc_rsvd2:5;
        u_short xc_maxlcn;      /* max logical channels */
-       u_short xc_dg_idletimo; /* timeout for idle datagram circuits.
+       u_short xc_dg_idletimo; /* timeout for idle datagram circuits. */
 };
 
 #ifdef IFNAMSIZ
 };
 
 #ifdef IFNAMSIZ