|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * Copyright (c) Computing Centre, University of British Columbia, 1985
24: * Copyright (C) Computer Science Department IV,
25: * University of Erlangen-Nuremberg, Germany, 1990, 1991, 1992
26: * Copyright (c) 1992, 1993
27: * The Regents of the University of California. All rights reserved.
28: *
29: * This code is derived from software contributed to Berkeley by the
30: * Laboratory for Computation Vision and the Computer Science Department
31: * of the the University of British Columbia and the Computer Science
32: * Department (IV) of the University of Erlangen-Nuremberg, Germany.
33: *
34: * Redistribution and use in source and binary forms, with or without
35: * modification, are permitted provided that the following conditions
36: * are met:
37: * 1. Redistributions of source code must retain the above copyright
38: * notice, this list of conditions and the following disclaimer.
39: * 2. Redistributions in binary form must reproduce the above copyright
40: * notice, this list of conditions and the following disclaimer in the
41: * documentation and/or other materials provided with the distribution.
42: * 3. All advertising materials mentioning features or use of this software
43: * must display the following acknowledgement:
44: * This product includes software developed by the University of
45: * California, Berkeley and its contributors.
46: * 4. Neither the name of the University nor the names of its contributors
47: * may be used to endorse or promote products derived from this software
48: * without specific prior written permission.
49: *
50: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60: * SUCH DAMAGE.
61: *
62: * @(#)pk_var.h 8.1 (Berkeley) 6/10/93
63: */
64:
65: /*
66: *
67: * X.25 Logical Channel Descriptor
68: *
69: */
70:
71: struct pklcd {
72: struct pklcd_q {
73: struct pklcd_q *q_forw; /* debugging chain */
74: struct pklcd_q *q_back; /* debugging chain */
75: } lcd_q;
76: int (*lcd_upper)(); /* switch to socket vs datagram vs ...*/
77: caddr_t lcd_upnext; /* reference for lcd_upper() */
78: int (*lcd_send)(); /* if X.25 front end, direct connect */
79: caddr_t lcd_downnext; /* reference for lcd_send() */
80: short lcd_lcn; /* Logical channel number */
81: short lcd_state; /* Logical Channel state */
82: short lcd_timer; /* Various timer values */
83: short lcd_dg_timer; /* to reclaim idle datagram circuits */
84: bool lcd_intrconf_pending; /* Interrupt confirmation pending */
85: octet lcd_intrdata; /* Octet of incoming intr data */
86: char lcd_retry; /* Timer retry count */
87: char lcd_rsn; /* Seq no of last received packet */
88: char lcd_ssn; /* Seq no of next packet to send */
89: char lcd_output_window; /* Output flow control window */
90: char lcd_input_window; /* Input flow control window */
91: char lcd_last_transmitted_pr;/* Last Pr value transmitted */
92: bool lcd_rnr_condition; /* Remote in busy condition */
93: bool lcd_window_condition; /* Output window size exceeded */
94: bool lcd_reset_condition; /* True, if waiting reset confirm */
95: bool lcd_rxrnr_condition; /* True, if we have sent rnr */
96: char lcd_packetsize; /* Maximum packet size */
97: char lcd_windowsize; /* Window size - both directions */
98: octet lcd_closed_user_group; /* Closed user group specification */
99: char lcd_flags; /* copy of sockaddr_x25 op_flags */
100: struct mbuf *lcd_facilities; /* user supplied facilities for cr */
101: struct mbuf *lcd_template; /* Address of response packet */
102: struct socket *lcd_so; /* Socket addr for connection */
103: struct sockaddr_x25 *lcd_craddr;/* Calling address pointer */
104: struct sockaddr_x25 *lcd_ceaddr;/* Called address pointer */
105: time_t lcd_stime; /* time circuit established */
106: long lcd_txcnt; /* Data packet transmit count */
107: long lcd_rxcnt; /* Data packet receive count */
108: short lcd_intrcnt; /* Interrupt packet transmit count */
109: struct pklcd *lcd_listen; /* Next lcd on listen queue */
110: struct pkcb *lcd_pkp; /* Network this lcd is attached to */
111: struct mbuf *lcd_cps; /* Complete Packet Sequence reassembly*/
112: long lcd_cpsmax; /* Max length for CPS */
113: struct sockaddr_x25 lcd_faddr; /* Remote Address (Calling) */
114: struct sockaddr_x25 lcd_laddr; /* Local Address (Called) */
115: struct sockbuf lcd_sb; /* alternate for datagram service */
116: };
117:
118: /*
119: * Per network information, allocated dynamically
120: * when a new network is configured.
121: */
122:
123: struct pkcb {
124: struct pkcb_q {
125: struct pkcb_q *q_forw;
126: struct pkcb_q *q_backw;
127: } pk_q;
128: short pk_state; /* packet level status */
129: short pk_maxlcn; /* local copy of xc_maxlcn */
130: int (*pk_lloutput) (); /* link level output procedure */
131: caddr_t (*pk_llctlinput) (); /* link level ctloutput procedure */
132: caddr_t pk_llnext; /* handle for next level down */
133: struct x25config *pk_xcp; /* network specific configuration */
134: struct x25_ifaddr *pk_ia; /* backpointer to ifaddr */
135: struct pklcd **pk_chan; /* actual size == xc_maxlcn+1 */
136: short pk_dxerole; /* DXE role of PLE over LLC2 */
137: short pk_restartcolls; /* counting RESTART collisions til resolved */
138: struct rtentry *pk_rt; /* back pointer to route */
139: struct rtentry *pk_llrt; /* pointer to reverse mapping */
140: u_short pk_refcount; /* ref count */
141: };
142:
143: #define FOR_ALL_PKCBS(p) for((p) = (struct pkcb *)(pkcb_q.q_forw); \
144: (pkcb_q.q_forw != &pkcb_q) && ((struct pkcb_q *)(p) != &pkcb_q); \
145: (p) = (struct pkcb *)((p) -> pk_q.q_forw))
146:
147: #define PQEMPTY (pkcb_q.q_forw == &pkcb_q)
148:
149: /*
150: * Interface address, x25 version. Exactly one of these structures is
151: * allocated for each interface with an x25 address.
152: *
153: * The ifaddr structure conatins the protocol-independent part
154: * of the structure, and is assumed to be first.
155: */
156: struct x25_ifaddr {
157: struct ifaddr ia_ifa; /* protocol-independent info */
158: #define ia_ifp ia_ifa.ifa_ifp
159: #define ia_flags ia_ifa.ifa_flags
160: struct x25config ia_xc; /* network specific configuration */
161: struct pkcb *ia_pkcb;
162: #define ia_maxlcn ia_xc.xc_maxlcn
163: int (*ia_start) (); /* connect, confirm method */
164: struct sockaddr_x25 ia_dstaddr; /* reserve space for route dst */
165: };
166:
167: /*
168: * ``Link-Level'' extension to Routing Entry for upper level
169: * packet switching via X.25 virtual circuits.
170: */
171: struct llinfo_x25 {
172: struct llinfo_x25 *lx_next; /* chain together in linked list */
173: struct llinfo_x25 *lx_prev; /* chain together in linked list */
174: struct rtentry *lx_rt; /* back pointer to route */
175: struct pklcd *lx_lcd; /* local connection block */
176: struct x25_ifaddr *lx_ia; /* may not be same as rt_ifa */
177: int lx_state; /* can't trust lcd->lcd_state */
178: int lx_flags;
179: int lx_timer; /* for idle timeout */
180: int lx_family; /* for dispatch */
181: };
182:
183: /* States for lx_state */
184: #define LXS_NEWBORN 0
185: #define LXS_RESOLVING 1
186: #define LXS_FREE 2
187: #define LXS_CONNECTING 3
188: #define LXS_CONNECTED 4
189: #define LXS_DISCONNECTING 5
190: #define LXS_LISTENING 6
191:
192: /* flags */
193: #define LXF_VALID 0x1 /* Circuit is live, etc. */
194: #define LXF_RTHELD 0x2 /* this lcb references rtentry */
195: #define LXF_LISTEN 0x4 /* accepting incoming calls */
196:
197: /*
198: * Definitions for accessing bitfields/bitslices inside X.25 structs
199: */
200:
201:
202: struct x25bitslice {
203: unsigned int bs_mask;
204: unsigned int bs_shift;
205: };
206:
207: #define calling_addrlen 0
208: #define called_addrlen 1
209: #define q_bit 2
210: #define d_bit 3
211: #define fmt_identifier 4
212: #define lc_group_number 1
213: #define p_r 5
214: #define m_bit 6
215: #define p_s 7
216: #define zilch 8
217:
218: #define X25GBITS(Arg, Index) (((Arg) & x25_bitslice[(Index)].bs_mask) >> x25_bitslice[(Index)].bs_shift)
219: #define X25SBITS(Arg, Index, Val) (Arg) |= (((Val) << x25_bitslice[(Index)].bs_shift) & x25_bitslice[(Index)].bs_mask)
220: #define X25CSBITS(Arg, Index, Val) (Arg) = (((Val) << x25_bitslice[(Index)].bs_shift) & x25_bitslice[(Index)].bs_mask)
221:
222: extern struct x25bitslice x25_bitslice[];
223:
224:
225: #define ISOFIFTTYPE(i,t) ((i)->if_type == (t))
226: #define ISISO8802(i) ((ISOFIFTTYPE(i, IFT_ETHER) || \
227: ISOFIFTTYPE(i, IFT_ISO88023) || \
228: ISOFIFTTYPE(i, IFT_ISO88024) || \
229: ISOFIFTTYPE(i, IFT_ISO88025) || \
230: ISOFIFTTYPE(i, IFT_ISO88026) || \
231: ISOFIFTTYPE(i, IFT_P10) || \
232: ISOFIFTTYPE(i, IFT_P80) || \
233: ISOFIFTTYPE(i, IFT_FDDI)))
234:
235: /*
236: * miscellenous debugging info
237: */
238: struct mbuf_cache {
239: int mbc_size;
240: int mbc_num;
241: int mbc_oldsize;
242: struct mbuf **mbc_cache;
243: };
244:
245: #if defined(KERNEL) && defined(CCITT)
246: extern struct pkcb_q pkcb_q;
247: struct pklcd *pk_listenhead;
248: struct pklcd *pk_attach();
249:
250: extern char *pk_name[], *pk_state[];
251: int pk_t20, pk_t21, pk_t22, pk_t23;
252: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.