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