1 /* 2 * Copyright (c) Computing Centre, University of British Columbia, 1985 3 * Copyright (C) Computer Science Department IV, 4 * University of Erlangen-Nuremberg, Germany, 1990, 1991, 1992 5 * Copyright (c) 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by the 9 * Laboratory for Computation Vision and the Computer Science Department 10 * of the the University of British Columbia and the Computer Science 11 * Department (IV) of the University of Erlangen-Nuremberg, Germany. 12 * 13 * %sccs.include.redist.c% 14 * 15 * @(#)pk_var.h 8.1 (Berkeley) 06/10/93 16 */ 17 18 /* 19 * 20 * X.25 Logical Channel Descriptor 21 * 22 */ 23 24 struct pklcd { 25 struct pklcd_q { 26 struct pklcd_q *q_forw; /* debugging chain */ 27 struct pklcd_q *q_back; /* debugging chain */ 28 } lcd_q; 29 int (*lcd_upper)(); /* switch to socket vs datagram vs ...*/ 30 caddr_t lcd_upnext; /* reference for lcd_upper() */ 31 int (*lcd_send)(); /* if X.25 front end, direct connect */ 32 caddr_t lcd_downnext; /* reference for lcd_send() */ 33 short lcd_lcn; /* Logical channel number */ 34 short lcd_state; /* Logical Channel state */ 35 short lcd_timer; /* Various timer values */ 36 short lcd_dg_timer; /* to reclaim idle datagram circuits */ 37 bool lcd_intrconf_pending; /* Interrupt confirmation pending */ 38 octet lcd_intrdata; /* Octet of incoming intr data */ 39 char lcd_retry; /* Timer retry count */ 40 char lcd_rsn; /* Seq no of last received packet */ 41 char lcd_ssn; /* Seq no of next packet to send */ 42 char lcd_output_window; /* Output flow control window */ 43 char lcd_input_window; /* Input flow control window */ 44 char lcd_last_transmitted_pr;/* Last Pr value transmitted */ 45 bool lcd_rnr_condition; /* Remote in busy condition */ 46 bool lcd_window_condition; /* Output window size exceeded */ 47 bool lcd_reset_condition; /* True, if waiting reset confirm */ 48 bool lcd_rxrnr_condition; /* True, if we have sent rnr */ 49 char lcd_packetsize; /* Maximum packet size */ 50 char lcd_windowsize; /* Window size - both directions */ 51 octet lcd_closed_user_group; /* Closed user group specification */ 52 char lcd_flags; /* copy of sockaddr_x25 op_flags */ 53 struct mbuf *lcd_facilities; /* user supplied facilities for cr */ 54 struct mbuf *lcd_template; /* Address of response packet */ 55 struct socket *lcd_so; /* Socket addr for connection */ 56 struct sockaddr_x25 *lcd_craddr;/* Calling address pointer */ 57 struct sockaddr_x25 *lcd_ceaddr;/* Called address pointer */ 58 time_t lcd_stime; /* time circuit established */ 59 long lcd_txcnt; /* Data packet transmit count */ 60 long lcd_rxcnt; /* Data packet receive count */ 61 short lcd_intrcnt; /* Interrupt packet transmit count */ 62 struct pklcd *lcd_listen; /* Next lcd on listen queue */ 63 struct pkcb *lcd_pkp; /* Network this lcd is attached to */ 64 struct mbuf *lcd_cps; /* Complete Packet Sequence reassembly*/ 65 long lcd_cpsmax; /* Max length for CPS */ 66 struct sockaddr_x25 lcd_faddr; /* Remote Address (Calling) */ 67 struct sockaddr_x25 lcd_laddr; /* Local Address (Called) */ 68 struct sockbuf lcd_sb; /* alternate for datagram service */ 69 }; 70 71 /* 72 * Per network information, allocated dynamically 73 * when a new network is configured. 74 */ 75 76 struct pkcb { 77 struct pkcb_q { 78 struct pkcb_q *q_forw; 79 struct pkcb_q *q_backw; 80 } pk_q; 81 short pk_state; /* packet level status */ 82 short pk_maxlcn; /* local copy of xc_maxlcn */ 83 int (*pk_lloutput) (); /* link level output procedure */ 84 caddr_t (*pk_llctlinput) (); /* link level ctloutput procedure */ 85 caddr_t pk_llnext; /* handle for next level down */ 86 struct x25config *pk_xcp; /* network specific configuration */ 87 struct x25_ifaddr *pk_ia; /* backpointer to ifaddr */ 88 struct pklcd **pk_chan; /* actual size == xc_maxlcn+1 */ 89 short pk_dxerole; /* DXE role of PLE over LLC2 */ 90 short pk_restartcolls; /* counting RESTART collisions til resolved */ 91 struct rtentry *pk_rt; /* back pointer to route */ 92 struct rtentry *pk_llrt; /* pointer to reverse mapping */ 93 u_short pk_refcount; /* ref count */ 94 }; 95 96 #define FOR_ALL_PKCBS(p) for((p) = (struct pkcb *)(pkcb_q.q_forw); \ 97 (pkcb_q.q_forw != &pkcb_q) && ((struct pkcb_q *)(p) != &pkcb_q); \ 98 (p) = (struct pkcb *)((p) -> pk_q.q_forw)) 99 100 #define PQEMPTY (pkcb_q.q_forw == &pkcb_q) 101 102 /* 103 * Interface address, x25 version. Exactly one of these structures is 104 * allocated for each interface with an x25 address. 105 * 106 * The ifaddr structure conatins the protocol-independent part 107 * of the structure, and is assumed to be first. 108 */ 109 struct x25_ifaddr { 110 struct ifaddr ia_ifa; /* protocol-independent info */ 111 #define ia_ifp ia_ifa.ifa_ifp 112 #define ia_flags ia_ifa.ifa_flags 113 struct x25config ia_xc; /* network specific configuration */ 114 struct pkcb *ia_pkcb; 115 #define ia_maxlcn ia_xc.xc_maxlcn 116 int (*ia_start) (); /* connect, confirm method */ 117 struct sockaddr_x25 ia_dstaddr; /* reserve space for route dst */ 118 }; 119 120 /* 121 * ``Link-Level'' extension to Routing Entry for upper level 122 * packet switching via X.25 virtual circuits. 123 */ 124 struct llinfo_x25 { 125 struct llinfo_x25 *lx_next; /* chain together in linked list */ 126 struct llinfo_x25 *lx_prev; /* chain together in linked list */ 127 struct rtentry *lx_rt; /* back pointer to route */ 128 struct pklcd *lx_lcd; /* local connection block */ 129 struct x25_ifaddr *lx_ia; /* may not be same as rt_ifa */ 130 int lx_state; /* can't trust lcd->lcd_state */ 131 int lx_flags; 132 int lx_timer; /* for idle timeout */ 133 int lx_family; /* for dispatch */ 134 }; 135 136 /* States for lx_state */ 137 #define LXS_NEWBORN 0 138 #define LXS_RESOLVING 1 139 #define LXS_FREE 2 140 #define LXS_CONNECTING 3 141 #define LXS_CONNECTED 4 142 #define LXS_DISCONNECTING 5 143 #define LXS_LISTENING 6 144 145 /* flags */ 146 #define LXF_VALID 0x1 /* Circuit is live, etc. */ 147 #define LXF_RTHELD 0x2 /* this lcb references rtentry */ 148 #define LXF_LISTEN 0x4 /* accepting incoming calls */ 149 150 /* 151 * Definitions for accessing bitfields/bitslices inside X.25 structs 152 */ 153 154 155 struct x25bitslice { 156 unsigned int bs_mask; 157 unsigned int bs_shift; 158 }; 159 160 #define calling_addrlen 0 161 #define called_addrlen 1 162 #define q_bit 2 163 #define d_bit 3 164 #define fmt_identifier 4 165 #define lc_group_number 1 166 #define p_r 5 167 #define m_bit 6 168 #define p_s 7 169 #define zilch 8 170 171 #define X25GBITS(Arg, Index) (((Arg) & x25_bitslice[(Index)].bs_mask) >> x25_bitslice[(Index)].bs_shift) 172 #define X25SBITS(Arg, Index, Val) (Arg) |= (((Val) << x25_bitslice[(Index)].bs_shift) & x25_bitslice[(Index)].bs_mask) 173 #define X25CSBITS(Arg, Index, Val) (Arg) = (((Val) << x25_bitslice[(Index)].bs_shift) & x25_bitslice[(Index)].bs_mask) 174 175 extern struct x25bitslice x25_bitslice[]; 176 177 178 #define ISOFIFTTYPE(i,t) ((i)->if_type == (t)) 179 #define ISISO8802(i) ((ISOFIFTTYPE(i, IFT_ETHER) || \ 180 ISOFIFTTYPE(i, IFT_ISO88023) || \ 181 ISOFIFTTYPE(i, IFT_ISO88024) || \ 182 ISOFIFTTYPE(i, IFT_ISO88025) || \ 183 ISOFIFTTYPE(i, IFT_ISO88026) || \ 184 ISOFIFTTYPE(i, IFT_P10) || \ 185 ISOFIFTTYPE(i, IFT_P80) || \ 186 ISOFIFTTYPE(i, IFT_FDDI))) 187 188 /* 189 * miscellenous debugging info 190 */ 191 struct mbuf_cache { 192 int mbc_size; 193 int mbc_num; 194 int mbc_oldsize; 195 struct mbuf **mbc_cache; 196 }; 197 198 #if defined(KERNEL) && defined(CCITT) 199 extern struct pkcb_q pkcb_q; 200 struct pklcd *pk_listenhead; 201 struct pklcd *pk_attach(); 202 203 extern char *pk_name[], *pk_state[]; 204 int pk_t20, pk_t21, pk_t22, pk_t23; 205 #endif 206