BSD 4_4 release
[unix-history] / usr / src / sys / netccitt / pk_var.h
index 9f31746..beda05d 100644 (file)
@@ -1,18 +1,46 @@
-/*
- * Copyright (c) University of British Columbia, 1984
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+/* 
+ * Copyright (c) Computing Centre, University of British Columbia, 1985 
+ * Copyright (C) Computer Science Department IV, 
+ *              University of Erlangen-Nuremberg, Germany, 1990, 1991, 1992
+ * Copyright (c) 1992, 1993
+ *     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 the University of British Columbia and the Computer Science
+ * Department (IV) of the University of Erlangen-Nuremberg, Germany.
  *
  *
- * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- * %sccs.include.redist.c%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  *
- *     @(#)pk_var.h    7.10 (Berkeley) %G%
+ *     @(#)pk_var.h    8.1 (Berkeley) 6/10/93
  */
 
  */
 
-
 /*
  *
  *  X.25 Logical Channel Descriptor
 /*
  *
  *  X.25 Logical Channel Descriptor
@@ -72,17 +100,31 @@ struct pklcd {
  */
 
 struct pkcb {
  */
 
 struct pkcb {
-       struct  pkcb *pk_next;
-       struct  x25_ifaddr *pk_ia;      /* backpointer to ifaddr */
+       struct pkcb_q {
+               struct pkcb_q *q_forw;
+               struct pkcb_q *q_backw;
+       } pk_q;
+       short   pk_state;               /* packet level status */
+       short   pk_maxlcn;              /* local copy of xc_maxlcn */
        int     (*pk_lloutput) ();      /* link level output procedure */
        int     (*pk_lloutput) ();      /* link level output procedure */
+       caddr_t (*pk_llctlinput) ();    /* link level ctloutput procedure */
        caddr_t pk_llnext;              /* handle for next level down */
        caddr_t pk_llnext;              /* handle for next level down */
-       int     (*pk_start) ();         /* connect, confirm method */
        struct  x25config *pk_xcp;      /* network specific configuration */
        struct  x25config *pk_xcp;      /* network specific configuration */
-       short   pk_state;               /* packet level status */
-       struct  x25config pk_xc;        /* network specific configuration */
+       struct  x25_ifaddr *pk_ia;      /* backpointer to ifaddr */
        struct  pklcd **pk_chan;        /* actual size == xc_maxlcn+1 */
        struct  pklcd **pk_chan;        /* actual size == xc_maxlcn+1 */
-#define        pk_maxlcn pk_xc.xc_maxlcn       /* local copy of xc_maxlcn */
+       short   pk_dxerole;             /* DXE role of PLE over LLC2 */
+       short   pk_restartcolls;        /* counting RESTART collisions til resolved */
+       struct  rtentry *pk_rt;         /* back pointer to route */
+       struct  rtentry *pk_llrt;       /* pointer to reverse mapping */
+       u_short pk_refcount;            /* ref count */
 };
 };
+
+#define FOR_ALL_PKCBS(p) for((p) = (struct pkcb *)(pkcb_q.q_forw); \
+                            (pkcb_q.q_forw != &pkcb_q) && ((struct pkcb_q *)(p) != &pkcb_q); \
+                            (p) = (struct pkcb *)((p) -> pk_q.q_forw))
+
+#define        PQEMPTY         (pkcb_q.q_forw == &pkcb_q)
+
 /*
  *     Interface address, x25 version. Exactly one of these structures is 
  *     allocated for each interface with an x25 address.
 /*
  *     Interface address, x25 version. Exactly one of these structures is 
  *     allocated for each interface with an x25 address.
@@ -92,14 +134,13 @@ struct     pkcb {
  */
 struct x25_ifaddr {
        struct  ifaddr ia_ifa;          /* protocol-independent info */
  */
 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  pkcb    ia_pkcb;        /* per network information */
-#define ia_maxlcn      ia_pkcb.pk_maxlcn
-#define ia_chan                ia_pkcb.pk_chan
-#define ia_xc          ia_pkcb.pk_xc
-#define ia_xcp         ia_pkcb.pk_xcp
-       struct  sockaddr_x25 ia_sockmask; /* reserve space for netmask */
+#define ia_ifp ia_ifa.ifa_ifp
+#define        ia_flags ia_ifa.ifa_flags
+       struct  x25config ia_xc;        /* network specific configuration */
+       struct  pkcb *ia_pkcb;
+#define ia_maxlcn ia_xc.xc_maxlcn
+       int     (*ia_start) ();         /* connect, confirm method */
+       struct  sockaddr_x25 ia_dstaddr; /* reserve space for route dst */
 };
 
 /*
 };
 
 /*
@@ -122,8 +163,8 @@ struct llinfo_x25 {
 #define LXS_NEWBORN            0
 #define LXS_RESOLVING          1
 #define LXS_FREE               2
 #define LXS_NEWBORN            0
 #define LXS_RESOLVING          1
 #define LXS_FREE               2
-#define LXS_CONNECTED          3
-#define LXS_CONNECTING         4
+#define LXS_CONNECTING         3
+#define LXS_CONNECTED          4
 #define LXS_DISCONNECTING      5
 #define LXS_LISTENING          6
 
 #define LXS_DISCONNECTING      5
 #define LXS_LISTENING          6
 
@@ -132,6 +173,44 @@ struct llinfo_x25 {
 #define LXF_RTHELD     0x2             /* this lcb references rtentry */
 #define LXF_LISTEN     0x4             /* accepting incoming calls */
 
 #define LXF_RTHELD     0x2             /* this lcb references rtentry */
 #define LXF_LISTEN     0x4             /* accepting incoming calls */
 
+/*
+ * Definitions for accessing bitfields/bitslices inside X.25 structs
+ */
+
+
+struct x25bitslice {
+       unsigned int bs_mask;
+       unsigned int bs_shift;
+};
+
+#define        calling_addrlen 0
+#define        called_addrlen  1
+#define        q_bit           2
+#define        d_bit           3
+#define        fmt_identifier  4
+#define        lc_group_number 1
+#define        p_r             5
+#define        m_bit           6
+#define        p_s             7
+#define        zilch           8
+
+#define        X25GBITS(Arg, Index)    (((Arg) & x25_bitslice[(Index)].bs_mask) >> x25_bitslice[(Index)].bs_shift)
+#define        X25SBITS(Arg, Index, Val)       (Arg) |= (((Val) << x25_bitslice[(Index)].bs_shift) & x25_bitslice[(Index)].bs_mask)
+#define        X25CSBITS(Arg, Index, Val)      (Arg) = (((Val) << x25_bitslice[(Index)].bs_shift) & x25_bitslice[(Index)].bs_mask)
+
+extern struct x25bitslice x25_bitslice[];
+
+
+#define ISOFIFTTYPE(i,t) ((i)->if_type == (t))
+#define ISISO8802(i) ((ISOFIFTTYPE(i, IFT_ETHER) || \
+                      ISOFIFTTYPE(i, IFT_ISO88023) || \
+                      ISOFIFTTYPE(i, IFT_ISO88024) || \
+                      ISOFIFTTYPE(i, IFT_ISO88025) || \
+                      ISOFIFTTYPE(i, IFT_ISO88026) || \
+                      ISOFIFTTYPE(i, IFT_P10) || \
+                      ISOFIFTTYPE(i, IFT_P80) || \
+                      ISOFIFTTYPE(i, IFT_FDDI)))
+
 /*
  * miscellenous debugging info
  */
 /*
  * miscellenous debugging info
  */
@@ -143,7 +222,7 @@ struct mbuf_cache {
 };
 
 #if defined(KERNEL) && defined(CCITT)
 };
 
 #if defined(KERNEL) && defined(CCITT)
-struct pkcb *pkcbhead;         /* head of linked list of networks */
+extern struct pkcb_q pkcb_q;
 struct pklcd *pk_listenhead;
 struct pklcd *pk_attach();
 
 struct pklcd *pk_listenhead;
 struct pklcd *pk_attach();