1 /* $Id: isdnif.h,v 1.1 1996/01/09 05:50:51 fritz Exp fritz $
2 *
3 * Linux ISDN subsystem
4 *
5 * Definition of the interface between the subsystem and it's lowlevel-drivers.
6 *
7 * Copyright 1994,95,96 by Fritz Elfert (fritz@wuemaus.franken.de)
8 * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * $Log: isdnif.h,v $
25 * Revision 1.1 1996/01/09 05:50:51 fritz
26 * Initial revision
27 *
28 */
29
30 #ifndef isdnif_h
31 #define isdnif_h
32
33 #ifdef STANDALONE
34 #include <linux/k_compat.h>
35 #endif
36
37 /*
38 * Values for general protocol-selection
39 */
40 #define ISDN_PTYPE_UNKNOWN 0 /* Protocol undefined */
41 #define ISDN_PTYPE_1TR6 1 /* german 1TR6-protocol */
42 #define ISDN_PTYPE_EURO 2 /* EDSS1-protocol */
43
44 /*
45 * Values for Layer-2-protocol-selection
46 */
47 #define ISDN_PROTO_L2_X75I 0 /* X75/LAPB with I-Frames */
48 #define ISDN_PROTO_L2_X75UI 1 /* X75/LAPB with UI-Frames */
49 #define ISDN_PROTO_L2_X75BUI 2 /* X75/LAPB with UI-Frames */
50 #define ISDN_PROTO_L2_HDLC 3 /* HDLC */
51
52 /*
53 * Values for Layer-3-protocol-selection
54 */
55 #define ISDN_PROTO_L3_TRANS 0 /* Transparent */
56
57 #ifdef __KERNEL__
58
59 #include <linux/skbuff.h>
60
61 /*
62 * Commands from linklevel to lowlevel
63 *
64 */
65 #define ISDN_CMD_IOCTL 0 /* Perform ioctl */
66 #define ISDN_CMD_DIAL 1 /* Dial out */
67 #define ISDN_CMD_ACCEPTD 2 /* Accept an incoming call on D-Chan. */
68 #define ISDN_CMD_ACCEPTB 3 /* Request B-Channel connect. */
69 #define ISDN_CMD_HANGUP 4 /* Hangup */
70 #define ISDN_CMD_CLREAZ 5 /* Clear EAZ(s) of channel */
71 #define ISDN_CMD_SETEAZ 6 /* Set EAZ(s) of channel */
72 #define ISDN_CMD_GETEAZ 7 /* Get EAZ(s) of channel */
73 #define ISDN_CMD_SETSIL 8 /* Set Service-Indicator-List of channel */
74 #define ISDN_CMD_GETSIL 9 /* Get Service-Indicator-List of channel */
75 #define ISDN_CMD_SETL2 10 /* Set B-Chan. Layer2-Parameter */
76 #define ISDN_CMD_GETL2 11 /* Get B-Chan. Layer2-Parameter */
77 #define ISDN_CMD_SETL3 12 /* Set B-Chan. Layer3-Parameter */
78 #define ISDN_CMD_GETL3 13 /* Get B-Chan. Layer3-Parameter */
79 #define ISDN_CMD_LOCK 14 /* Signal usage by upper levels */
80 #define ISDN_CMD_UNLOCK 15 /* Release usage-lock */
81
82 /*
83 * Status-Values delivered from lowlevel to linklevel via
84 * statcallb().
85 *
86 */
87 #define ISDN_STAT_STAVAIL 256 /* Raw status-data available */
88 #define ISDN_STAT_ICALL 257 /* Incoming call detected */
89 #define ISDN_STAT_RUN 258 /* Signal protocol-code is running */
90 #define ISDN_STAT_STOP 259 /* Signal halt of protocol-code */
91 #define ISDN_STAT_DCONN 260 /* Signal D-Channel connect */
92 #define ISDN_STAT_BCONN 261 /* Signal B-Channel connect */
93 #define ISDN_STAT_DHUP 262 /* Signal D-Channel disconnect */
94 #define ISDN_STAT_BHUP 263 /* Signal B-Channel disconnect */
95 #define ISDN_STAT_CINF 264 /* Charge-Info */
96 #define ISDN_STAT_LOAD 265 /* Signal new lowlevel-driver is loaded */
97 #define ISDN_STAT_UNLOAD 266 /* Signal unload of lowlevel-driver */
98 #define ISDN_STAT_BSENT 267 /* Signal packet sent */
99 #define ISDN_STAT_NODCH 268 /* Signal no D-Channel */
100 #define ISDN_STAT_ADDCH 269 /* Add more Channels */
101 #define ISDN_STAT_CAUSE 270 /* Cause-Message */
102
103 /*
104 * Values for feature-field of interface-struct.
105 */
106 /* Layer 2 */
107 #define ISDN_FEATURE_L2_X75I (0x0001 << ISDN_PROTO_L2_X75I)
108 #define ISDN_FEATURE_L2_X75UI (0x0001 << ISDN_PROTO_L2_X75UI)
109 #define ISDN_FEATURE_L2_X75BUI (0x0001 << ISDN_PROTO_L2_X75BUI)
110 #define ISDN_FEATURE_L2_HDLC (0x0001 << ISDN_PROTO_L2_HDLC)
111
112 /* Layer 3 */
113 #define ISDN_FEATURE_L3_TRANS (0x0100 << ISDN_PROTO_L3_TRANS)
114
115 /* Signaling */
116 #define ISDN_FEATURE_P_UNKNOWN (0x1000 << ISDN_PTYPE_UNKNOWN)
117 #define ISDN_FEATURE_P_1TR6 (0x1000 << ISDN_PTYPE_1TR6)
118 #define ISDN_FEATURE_P_EURO (0x1000 << ISDN_PTYPE_EURO)
119
120 /*
121 * Structure for exchanging above infos
122 *
123 */
124 typedef struct {
125 int driver; /* Lowlevel-Driver-ID */
126 int command; /* Command or Status (see above) */
127 ulong arg; /* Additional Data */
128 char num[50]; /* Additional Data */
129 } isdn_ctrl;
130
131 /*
132 * The interface-struct itself (initialized at load-time of lowlevel-driver)
133 *
134 * See Documentation/isdn/INTERFACE for a description, how the communication
135 * between the ISDN subsystem and it's drivers is done.
136 *
137 */
138 typedef struct {
139 /* Number of channels supported by this driver
140 */
141 int channels;
142
143 /*
144 * Maximum Size of transmit/receive-buffer this driver supports.
145 */
146 int maxbufsize;
147
148 /* Feature-Flags for this driver.
149 * See defines ISDN_FEATURE_... for Values
150 */
151 unsigned long features;
152
153 /*
154 * Needed for calculating
155 * dev->hard_header_len = linklayer header + hl_hdrlen;
156 * Drivers, not supporting sk_buff's should set this to 0.
157 */
158 unsigned short hl_hdrlen;
159
160 /* Receive-Callback
161 * Parameters:
162 * int Driver-ID
163 * int local channel-number (0 ...)
164 * u_char pointer to received data (in Kernel-Space, volatile)
165 * int length of data
166 */
167 void (*rcvcallb)(int, int, u_char*, int);
168
169 /*
170 * Receive-Callback using sk_buff's
171 * Parameters:
172 * int Driver-ID
173 * int local channel-number (0 ...)
174 * struct sk_buff *skb received Data
175 */
176 void (*rcvcallb_skb)(int, int, struct sk_buff *);
177
178 /* Status-Callback
179 * Parameters:
180 * isdn_ctrl*
181 * driver = Driver ID.
182 * command = One of above ISDN_STAT_... constants.
183 * arg = depending on status-type.
184 * num = depending on status-type.
185 */
186 int (*statcallb)(isdn_ctrl*);
187 /* Send command
188 * Parameters:
189 * isdn_ctrl*
190 * driver = Driver ID.
191 * command = One of above ISDN_CMD_... constants.
192 * arg = depending on command.
193 * num = depending on command.
194 */
195 int (*command)(isdn_ctrl*);
196 /* Send Data
197 * Parameters:
198 * int driverId
199 * int local channel-number (0 ...)
200 * u_char pointer to data
201 * int length of data
202 * int Flag: 0 = Call form Kernel-Space (use memcpy,
203 * no schedule allowed)
204 * 1 = Data is in User-Space (use memcpy_fromfs,
205 * may schedule)
206 */
207 int (*writebuf)(int, int, const u_char*, int, int);
208
209 /*
210 * Send data using sk_buff's
211 * Parameters:
212 * int driverId
213 * int local channel-number (0...)
214 * struct sk_buff *skb Data to send
215 */
216 int (*writebuf_skb) (int, int, struct sk_buff *);
217
218 /* Send raw D-Channel-Commands
219 * Parameters:
220 * u_char pointer data
221 * int length of data
222 * int Flag: 0 = Call form Kernel-Space (use memcpy,
223 * no schedule allowed)
224 * 1 = Data is in User-Space (use memcpy_fromfs,
225 * may schedule)
226 */
227 int (*writecmd)(const u_char*, int, int);
228 /* Read raw Status replies
229 * u_char pointer data (volatile)
230 * int length of buffer
231 * int Flag: 0 = Call form Kernel-Space (use memcpy,
232 * no schedule allowed)
233 * 1 = Data is in User-Space (use memcpy_fromfs,
234 * may schedule)
235 */
236 int (*readstat)(u_char*, int, int);
237 char id[20];
238 } isdn_if;
239
240 /*
241 * Function which must be called by lowlevel-driver at loadtime with
242 * the following fields of above struct set:
243 *
244 * channels Number of channels that will be supported.
245 * hl_hdrlen Space to preserve in sk_buff's when sending. Drivers, not
246 * supporting sk_buff's should set this to 0.
247 * command Address of Command-Handler.
248 * features Bitwise coded Features of this driver. (use ISDN_FEATURE_...)
249 * writebuf Address of Send-Command-Handler.
250 * writebuf_skb Address of Skbuff-Send-Handler. (NULL if not supported)
251 * writecmd " " D-Channel " which accepts raw D-Ch-Commands.
252 * readstat " " D-Channel " which delivers raw Status-Data.
253 *
254 * The linklevel-driver fills the following fields:
255 *
256 * channels Driver-ID assigned to this driver. (Must be used on all
257 * subsequent callbacks.
258 * rcvcallb Address of handler for received data.
259 * rcvcallb_skb Address of handler for received Skbuff's. (NULL if not supp.)
260 * statcallb " " " for status-changes.
261 *
262 */
263 extern int register_isdn(isdn_if*);
264
265 #endif /* __KERNEL__ */
266 #endif /* isdnif_h */
267