Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
isdnif.h
Go to the documentation of this file.
1 /* $Id: isdnif.h,v 1.43.2.2 2004/01/12 23:08:35 keil Exp $
2  *
3  * Linux ISDN subsystem
4  * Definition of the interface between the subsystem and its low-level drivers.
5  *
6  * Copyright 1994,95,96 by Fritz Elfert ([email protected])
7  * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg
8  *
9  * This software may be used and distributed according to the terms
10  * of the GNU General Public License, incorporated herein by reference.
11  *
12  */
13 #ifndef __ISDNIF_H__
14 #define __ISDNIF_H__
15 
16 
17 #include <linux/skbuff.h>
18 #include <uapi/linux/isdnif.h>
19 
20 /***************************************************************************/
21 /* Extensions made by Werner Cornelius ([email protected]) */
22 /* */
23 /* The proceed command holds a incoming call in a state to leave processes */
24 /* enough time to check whether ist should be accepted. */
25 /* The PROT_IO Command extends the interface to make protocol dependent */
26 /* features available (call diversion, call waiting...). */
27 /* */
28 /* The PROT_IO Command is executed with the desired driver id and the arg */
29 /* parameter coded as follows: */
30 /* The lower 8 bits of arg contain the desired protocol from ISDN_PTYPE */
31 /* definitions. The upper 24 bits represent the protocol specific cmd/stat.*/
32 /* Any additional data is protocol and command specific. */
33 /* This mechanism also applies to the statcallb callback STAT_PROT. */
34 /* */
35 /* This suggested extension permits an easy expansion of protocol specific */
36 /* handling. Extensions may be added at any time without changing the HL */
37 /* driver code and not getting conflicts without certifications. */
38 /* The well known CAPI 2.0 interface handles such extensions in a similar */
39 /* way. Perhaps a protocol specific module may be added and separately */
40 /* loaded and linked to the basic isdn module for handling. */
41 /***************************************************************************/
42 
43 /*****************/
44 /* DSS1 commands */
45 /*****************/
46 #define DSS1_CMD_INVOKE ((0x00 << 8) | ISDN_PTYPE_EURO) /* invoke a supplementary service */
47 #define DSS1_CMD_INVOKE_ABORT ((0x01 << 8) | ISDN_PTYPE_EURO) /* abort a invoke cmd */
48 
49 /*******************************/
50 /* DSS1 Status callback values */
51 /*******************************/
52 #define DSS1_STAT_INVOKE_RES ((0x80 << 8) | ISDN_PTYPE_EURO) /* Result for invocation */
53 #define DSS1_STAT_INVOKE_ERR ((0x81 << 8) | ISDN_PTYPE_EURO) /* Error Return for invocation */
54 #define DSS1_STAT_INVOKE_BRD ((0x82 << 8) | ISDN_PTYPE_EURO) /* Deliver invoke broadcast info */
55 
56 
57 /*********************************************************************/
58 /* structures for DSS1 commands and callback */
59 /* */
60 /* An action is invoked by sending a DSS1_CMD_INVOKE. The ll_id, proc*/
61 /* timeout, datalen and data fields must be set before calling. */
62 /* */
63 /* The return value is a positive hl_id value also delivered in the */
64 /* hl_id field. A value of zero signals no more left hl_id capacitys.*/
65 /* A negative return value signals errors in LL. So if the return */
66 /* value is <= 0 no action in LL will be taken -> request ignored */
67 /* */
68 /* The timeout field must be filled with a positive value specifying */
69 /* the amount of time the INVOKED process waits for a reaction from */
70 /* the network. */
71 /* If a response (either error or result) is received during this */
72 /* intervall, a reporting callback is initiated and the process will */
73 /* be deleted, the hl identifier will be freed. */
74 /* If no response is received during the specified intervall, a error*/
75 /* callback is initiated with timeout set to -1 and a datalen set */
76 /* to 0. */
77 /* If timeout is set to a value <= 0 during INVOCATION the process is*/
78 /* immediately deleted after sending the data. No callback occurs ! */
79 /* */
80 /* A currently waiting process may be aborted with INVOKE_ABORT. No */
81 /* callback will occur when a process has been aborted. */
82 /* */
83 /* Broadcast invoke frames from the network are reported via the */
84 /* STAT_INVOKE_BRD callback. The ll_id is set to 0, the other fields */
85 /* are supplied by the network and not by the HL. */
86 /*********************************************************************/
87 
88 /*****************/
89 /* NI1 commands */
90 /*****************/
91 #define NI1_CMD_INVOKE ((0x00 << 8) | ISDN_PTYPE_NI1) /* invoke a supplementary service */
92 #define NI1_CMD_INVOKE_ABORT ((0x01 << 8) | ISDN_PTYPE_NI1) /* abort a invoke cmd */
93 
94 /*******************************/
95 /* NI1 Status callback values */
96 /*******************************/
97 #define NI1_STAT_INVOKE_RES ((0x80 << 8) | ISDN_PTYPE_NI1) /* Result for invocation */
98 #define NI1_STAT_INVOKE_ERR ((0x81 << 8) | ISDN_PTYPE_NI1) /* Error Return for invocation */
99 #define NI1_STAT_INVOKE_BRD ((0x82 << 8) | ISDN_PTYPE_NI1) /* Deliver invoke broadcast info */
100 
101 typedef struct
102  { ulong ll_id; /* ID supplied by LL when executing */
103  /* a command and returned by HL for */
104  /* INVOKE_RES and INVOKE_ERR */
105  int hl_id; /* ID supplied by HL when called */
106  /* for executing a cmd and delivered */
107  /* for results and errors */
108  /* must be supplied by LL when aborting*/
109  int proc; /* invoke procedure used by CMD_INVOKE */
110  /* returned by callback and broadcast */
111  int timeout; /* timeout for INVOKE CMD in ms */
112  /* -1 in stat callback when timed out */
113  /* error value when error callback */
114  int datalen; /* length of cmd or stat data */
115  u_char *data;/* pointer to data delivered or send */
116  } isdn_cmd_stat;
117 
118 /*
119  * Commands from linklevel to lowlevel
120  *
121  */
122 #define ISDN_CMD_IOCTL 0 /* Perform ioctl */
123 #define ISDN_CMD_DIAL 1 /* Dial out */
124 #define ISDN_CMD_ACCEPTD 2 /* Accept an incoming call on D-Chan. */
125 #define ISDN_CMD_ACCEPTB 3 /* Request B-Channel connect. */
126 #define ISDN_CMD_HANGUP 4 /* Hangup */
127 #define ISDN_CMD_CLREAZ 5 /* Clear EAZ(s) of channel */
128 #define ISDN_CMD_SETEAZ 6 /* Set EAZ(s) of channel */
129 #define ISDN_CMD_GETEAZ 7 /* Get EAZ(s) of channel */
130 #define ISDN_CMD_SETSIL 8 /* Set Service-Indicator-List of channel */
131 #define ISDN_CMD_GETSIL 9 /* Get Service-Indicator-List of channel */
132 #define ISDN_CMD_SETL2 10 /* Set B-Chan. Layer2-Parameter */
133 #define ISDN_CMD_GETL2 11 /* Get B-Chan. Layer2-Parameter */
134 #define ISDN_CMD_SETL3 12 /* Set B-Chan. Layer3-Parameter */
135 #define ISDN_CMD_GETL3 13 /* Get B-Chan. Layer3-Parameter */
136 // #define ISDN_CMD_LOCK 14 /* Signal usage by upper levels */
137 // #define ISDN_CMD_UNLOCK 15 /* Release usage-lock */
138 #define ISDN_CMD_SUSPEND 16 /* Suspend connection */
139 #define ISDN_CMD_RESUME 17 /* Resume connection */
140 #define ISDN_CMD_PROCEED 18 /* Proceed with call establishment */
141 #define ISDN_CMD_ALERT 19 /* Alert after Proceeding */
142 #define ISDN_CMD_REDIR 20 /* Redir a incoming call */
143 #define ISDN_CMD_PROT_IO 21 /* Protocol specific commands */
144 #define CAPI_PUT_MESSAGE 22 /* CAPI message send down or up */
145 #define ISDN_CMD_FAXCMD 23 /* FAX commands to HL-driver */
146 #define ISDN_CMD_AUDIO 24 /* DSP, DTMF, ... settings */
147 
148 /*
149  * Status-Values delivered from lowlevel to linklevel via
150  * statcallb().
151  *
152  */
153 #define ISDN_STAT_STAVAIL 256 /* Raw status-data available */
154 #define ISDN_STAT_ICALL 257 /* Incoming call detected */
155 #define ISDN_STAT_RUN 258 /* Signal protocol-code is running */
156 #define ISDN_STAT_STOP 259 /* Signal halt of protocol-code */
157 #define ISDN_STAT_DCONN 260 /* Signal D-Channel connect */
158 #define ISDN_STAT_BCONN 261 /* Signal B-Channel connect */
159 #define ISDN_STAT_DHUP 262 /* Signal D-Channel disconnect */
160 #define ISDN_STAT_BHUP 263 /* Signal B-Channel disconnect */
161 #define ISDN_STAT_CINF 264 /* Charge-Info */
162 #define ISDN_STAT_LOAD 265 /* Signal new lowlevel-driver is loaded */
163 #define ISDN_STAT_UNLOAD 266 /* Signal unload of lowlevel-driver */
164 #define ISDN_STAT_BSENT 267 /* Signal packet sent */
165 #define ISDN_STAT_NODCH 268 /* Signal no D-Channel */
166 #define ISDN_STAT_ADDCH 269 /* Add more Channels */
167 #define ISDN_STAT_CAUSE 270 /* Cause-Message */
168 #define ISDN_STAT_ICALLW 271 /* Incoming call without B-chan waiting */
169 #define ISDN_STAT_REDIR 272 /* Redir result */
170 #define ISDN_STAT_PROT 273 /* protocol IO specific callback */
171 #define ISDN_STAT_DISPLAY 274 /* deliver a received display message */
172 #define ISDN_STAT_L1ERR 275 /* Signal Layer-1 Error */
173 #define ISDN_STAT_FAXIND 276 /* FAX indications from HL-driver */
174 #define ISDN_STAT_AUDIO 277 /* DTMF, DSP indications */
175 #define ISDN_STAT_DISCH 278 /* Disable/Enable channel usage */
176 
177 /*
178  * Audio commands
179  */
180 #define ISDN_AUDIO_SETDD 0 /* Set DTMF detection */
181 #define ISDN_AUDIO_DTMF 1 /* Rx/Tx DTMF */
182 
183 /*
184  * Values for errcode field
185  */
186 #define ISDN_STAT_L1ERR_SEND 1
187 #define ISDN_STAT_L1ERR_RECV 2
188 
189 /*
190  * Values for feature-field of interface-struct.
191  */
192 /* Layer 2 */
193 #define ISDN_FEATURE_L2_X75I (0x0001 << ISDN_PROTO_L2_X75I)
194 #define ISDN_FEATURE_L2_X75UI (0x0001 << ISDN_PROTO_L2_X75UI)
195 #define ISDN_FEATURE_L2_X75BUI (0x0001 << ISDN_PROTO_L2_X75BUI)
196 #define ISDN_FEATURE_L2_HDLC (0x0001 << ISDN_PROTO_L2_HDLC)
197 #define ISDN_FEATURE_L2_TRANS (0x0001 << ISDN_PROTO_L2_TRANS)
198 #define ISDN_FEATURE_L2_X25DTE (0x0001 << ISDN_PROTO_L2_X25DTE)
199 #define ISDN_FEATURE_L2_X25DCE (0x0001 << ISDN_PROTO_L2_X25DCE)
200 #define ISDN_FEATURE_L2_V11096 (0x0001 << ISDN_PROTO_L2_V11096)
201 #define ISDN_FEATURE_L2_V11019 (0x0001 << ISDN_PROTO_L2_V11019)
202 #define ISDN_FEATURE_L2_V11038 (0x0001 << ISDN_PROTO_L2_V11038)
203 #define ISDN_FEATURE_L2_MODEM (0x0001 << ISDN_PROTO_L2_MODEM)
204 #define ISDN_FEATURE_L2_FAX (0x0001 << ISDN_PROTO_L2_FAX)
205 #define ISDN_FEATURE_L2_HDLC_56K (0x0001 << ISDN_PROTO_L2_HDLC_56K)
206 
207 #define ISDN_FEATURE_L2_MASK (0x0FFFF) /* Max. 16 protocols */
208 #define ISDN_FEATURE_L2_SHIFT (0)
209 
210 /* Layer 3 */
211 #define ISDN_FEATURE_L3_TRANS (0x10000 << ISDN_PROTO_L3_TRANS)
212 #define ISDN_FEATURE_L3_TRANSDSP (0x10000 << ISDN_PROTO_L3_TRANSDSP)
213 #define ISDN_FEATURE_L3_FCLASS2 (0x10000 << ISDN_PROTO_L3_FCLASS2)
214 #define ISDN_FEATURE_L3_FCLASS1 (0x10000 << ISDN_PROTO_L3_FCLASS1)
215 
216 #define ISDN_FEATURE_L3_MASK (0x0FF0000) /* Max. 8 Protocols */
217 #define ISDN_FEATURE_L3_SHIFT (16)
218 
219 /* Signaling */
220 #define ISDN_FEATURE_P_UNKNOWN (0x1000000 << ISDN_PTYPE_UNKNOWN)
221 #define ISDN_FEATURE_P_1TR6 (0x1000000 << ISDN_PTYPE_1TR6)
222 #define ISDN_FEATURE_P_EURO (0x1000000 << ISDN_PTYPE_EURO)
223 #define ISDN_FEATURE_P_NI1 (0x1000000 << ISDN_PTYPE_NI1)
224 
225 #define ISDN_FEATURE_P_MASK (0x0FF000000) /* Max. 8 Protocols */
226 #define ISDN_FEATURE_P_SHIFT (24)
227 
228 typedef struct setup_parm {
229  unsigned char phone[32]; /* Remote Phone-Number */
230  unsigned char eazmsn[32]; /* Local EAZ or MSN */
231  unsigned char si1; /* Service Indicator 1 */
232  unsigned char si2; /* Service Indicator 2 */
233  unsigned char plan; /* Numbering plan */
234  unsigned char screen; /* Screening info */
235 } setup_parm;
236 
237 
238 #ifdef CONFIG_ISDN_TTY_FAX
239 /* T.30 Fax G3 */
240 
241 #define FAXIDLEN 21
242 
243 typedef struct T30_s {
244  /* session parameters */
245  __u8 resolution;
246  __u8 rate;
247  __u8 width;
248  __u8 length;
250  __u8 ecm;
251  __u8 binary;
252  __u8 scantime;
253  __u8 id[FAXIDLEN];
254  /* additional parameters */
255  __u8 phase;
256  __u8 direction;
257  __u8 code;
258  __u8 badlin;
259  __u8 badmul;
260  __u8 bor;
261  __u8 fet;
262  __u8 pollid[FAXIDLEN];
263  __u8 cq;
264  __u8 cr;
265  __u8 ctcrty;
266  __u8 minsp;
267  __u8 phcto;
268  __u8 rel;
269  __u8 nbc;
270  /* remote station parameters */
271  __u8 r_resolution;
272  __u8 r_rate;
273  __u8 r_width;
274  __u8 r_length;
275  __u8 r_compression;
276  __u8 r_ecm;
277  __u8 r_binary;
278  __u8 r_scantime;
279  __u8 r_id[FAXIDLEN];
280  __u8 r_code;
281 } __packed T30_s;
282 
283 #define ISDN_TTY_FAX_CONN_IN 0
284 #define ISDN_TTY_FAX_CONN_OUT 1
285 
286 #define ISDN_TTY_FAX_FCON 0
287 #define ISDN_TTY_FAX_DIS 1
288 #define ISDN_TTY_FAX_FTT 2
289 #define ISDN_TTY_FAX_MCF 3
290 #define ISDN_TTY_FAX_DCS 4
291 #define ISDN_TTY_FAX_TRAIN_OK 5
292 #define ISDN_TTY_FAX_EOP 6
293 #define ISDN_TTY_FAX_EOM 7
294 #define ISDN_TTY_FAX_MPS 8
295 #define ISDN_TTY_FAX_DTC 9
296 #define ISDN_TTY_FAX_RID 10
297 #define ISDN_TTY_FAX_HNG 11
298 #define ISDN_TTY_FAX_DT 12
299 #define ISDN_TTY_FAX_FCON_I 13
300 #define ISDN_TTY_FAX_DR 14
301 #define ISDN_TTY_FAX_ET 15
302 #define ISDN_TTY_FAX_CFR 16
303 #define ISDN_TTY_FAX_PTS 17
304 #define ISDN_TTY_FAX_SENT 18
305 
306 #define ISDN_FAX_PHASE_IDLE 0
307 #define ISDN_FAX_PHASE_A 1
308 #define ISDN_FAX_PHASE_B 2
309 #define ISDN_FAX_PHASE_C 3
310 #define ISDN_FAX_PHASE_D 4
311 #define ISDN_FAX_PHASE_E 5
312 
313 #endif /* TTY_FAX */
314 
315 #define ISDN_FAX_CLASS1_FAE 0
316 #define ISDN_FAX_CLASS1_FTS 1
317 #define ISDN_FAX_CLASS1_FRS 2
318 #define ISDN_FAX_CLASS1_FTM 3
319 #define ISDN_FAX_CLASS1_FRM 4
320 #define ISDN_FAX_CLASS1_FTH 5
321 #define ISDN_FAX_CLASS1_FRH 6
322 #define ISDN_FAX_CLASS1_CTRL 7
323 
324 #define ISDN_FAX_CLASS1_OK 0
325 #define ISDN_FAX_CLASS1_CONNECT 1
326 #define ISDN_FAX_CLASS1_NOCARR 2
327 #define ISDN_FAX_CLASS1_ERROR 3
328 #define ISDN_FAX_CLASS1_FCERROR 4
329 #define ISDN_FAX_CLASS1_QUERY 5
330 
331 typedef struct {
334  __u8 para[50];
335 } aux_s;
336 
337 #define AT_COMMAND 0
338 #define AT_EQ_VALUE 1
339 #define AT_QUERY 2
340 #define AT_EQ_QUERY 3
341 
342 /* CAPI structs */
343 
344 /* this is compatible to the old union size */
345 #define MAX_CAPI_PARA_LEN 50
346 
347 typedef struct {
348  /* Header */
354 
355  /* Parameter */
356  union {
360  } adr;
362 } capi_msg;
363 
364 /*
365  * Structure for exchanging above infos
366  *
367  */
368 typedef struct {
369  int driver; /* Lowlevel-Driver-ID */
370  int command; /* Command or Status (see above) */
371  ulong arg; /* Additional Data */
372  union {
373  ulong errcode; /* Type of error with STAT_L1ERR */
374  int length; /* Amount of bytes sent with STAT_BSENT */
375  u_char num[50]; /* Additional Data */
376  setup_parm setup;/* For SETUP msg */
377  capi_msg cmsg; /* For CAPI like messages */
378  char display[85];/* display message data */
379  isdn_cmd_stat isdn_io; /* ISDN IO-parameter/result */
380  aux_s aux; /* for modem commands/indications */
381 #ifdef CONFIG_ISDN_TTY_FAX
382  T30_s *fax; /* Pointer to ttys fax struct */
383 #endif
384  ulong userdata; /* User Data */
385  } parm;
386 } isdn_ctrl;
387 
388 #define dss1_io isdn_io
389 #define ni1_io isdn_io
390 
391 /*
392  * The interface-struct itself (initialized at load-time of lowlevel-driver)
393  *
394  * See Documentation/isdn/INTERFACE for a description, how the communication
395  * between the ISDN subsystem and its drivers is done.
396  *
397  */
398 typedef struct {
399  struct module *owner;
400 
401  /* Number of channels supported by this driver
402  */
403  int channels;
404 
405  /*
406  * Maximum Size of transmit/receive-buffer this driver supports.
407  */
409 
410  /* Feature-Flags for this driver.
411  * See defines ISDN_FEATURE_... for Values
412  */
413  unsigned long features;
414 
415  /*
416  * Needed for calculating
417  * dev->hard_header_len = linklayer header + hl_hdrlen;
418  * Drivers, not supporting sk_buff's should set this to 0.
419  */
420  unsigned short hl_hdrlen;
421 
422  /*
423  * Receive-Callback using sk_buff's
424  * Parameters:
425  * int Driver-ID
426  * int local channel-number (0 ...)
427  * struct sk_buff *skb received Data
428  */
429  void (*rcvcallb_skb)(int, int, struct sk_buff *);
430 
431  /* Status-Callback
432  * Parameters:
433  * isdn_ctrl*
434  * driver = Driver ID.
435  * command = One of above ISDN_STAT_... constants.
436  * arg = depending on status-type.
437  * num = depending on status-type.
438  */
439  int (*statcallb)(isdn_ctrl*);
440 
441  /* Send command
442  * Parameters:
443  * isdn_ctrl*
444  * driver = Driver ID.
445  * command = One of above ISDN_CMD_... constants.
446  * arg = depending on command.
447  * num = depending on command.
448  */
450 
451  /*
452  * Send data using sk_buff's
453  * Parameters:
454  * int driverId
455  * int local channel-number (0...)
456  * int Flag: Need ACK for this packet.
457  * struct sk_buff *skb Data to send
458  */
459  int (*writebuf_skb) (int, int, int, struct sk_buff *);
460 
461  /* Send raw D-Channel-Commands
462  * Parameters:
463  * u_char pointer data
464  * int length of data
465  * int driverId
466  * int local channel-number (0 ...)
467  */
468  int (*writecmd)(const u_char __user *, int, int, int);
469 
470  /* Read raw Status replies
471  * u_char pointer data (volatile)
472  * int length of buffer
473  * int driverId
474  * int local channel-number (0 ...)
475  */
476  int (*readstat)(u_char __user *, int, int, int);
477 
478  char id[20];
479 } isdn_if;
480 
481 /*
482  * Function which must be called by lowlevel-driver at loadtime with
483  * the following fields of above struct set:
484  *
485  * channels Number of channels that will be supported.
486  * hl_hdrlen Space to preserve in sk_buff's when sending. Drivers, not
487  * supporting sk_buff's should set this to 0.
488  * command Address of Command-Handler.
489  * features Bitwise coded Features of this driver. (use ISDN_FEATURE_...)
490  * writebuf_skb Address of Skbuff-Send-Handler.
491  * writecmd " " D-Channel " which accepts raw D-Ch-Commands.
492  * readstat " " D-Channel " which delivers raw Status-Data.
493  *
494  * The linklevel-driver fills the following fields:
495  *
496  * channels Driver-ID assigned to this driver. (Must be used on all
497  * subsequent callbacks.
498  * rcvcallb_skb Address of handler for received Skbuff's.
499  * statcallb " " " for status-changes.
500  *
501  */
502 extern int register_isdn(isdn_if*);
503 #include <asm/uaccess.h>
504 
505 #endif /* __ISDNIF_H__ */