22 #include <linux/types.h>
23 #include <linux/errno.h>
24 #include <linux/socket.h>
38 #define MISDN_MAJOR_VERSION 1
39 #define MISDN_MINOR_VERSION 1
40 #define MISDN_RELEASE 29
59 #define MISDN_CMDMASK 0xff00
60 #define MISDN_LAYERMASK 0x00ff
63 #define OPEN_CHANNEL 0x0100
64 #define CLOSE_CHANNEL 0x0200
65 #define CONTROL_CHANNEL 0x0300
66 #define CHECK_DATA 0x0400
69 #define PH_ACTIVATE_REQ 0x0101
70 #define PH_DEACTIVATE_REQ 0x0201
71 #define PH_DATA_REQ 0x2001
72 #define MPH_ACTIVATE_REQ 0x0501
73 #define MPH_DEACTIVATE_REQ 0x0601
74 #define MPH_INFORMATION_REQ 0x0701
75 #define PH_CONTROL_REQ 0x0801
78 #define PH_ACTIVATE_IND 0x0102
79 #define PH_ACTIVATE_CNF 0x4102
80 #define PH_DEACTIVATE_IND 0x0202
81 #define PH_DEACTIVATE_CNF 0x4202
82 #define PH_DATA_IND 0x2002
83 #define PH_DATA_E_IND 0x3002
84 #define MPH_ACTIVATE_IND 0x0502
85 #define MPH_DEACTIVATE_IND 0x0602
86 #define MPH_INFORMATION_IND 0x0702
87 #define PH_DATA_CNF 0x6002
88 #define PH_CONTROL_IND 0x0802
89 #define PH_CONTROL_CNF 0x4802
92 #define DL_ESTABLISH_REQ 0x1004
93 #define DL_RELEASE_REQ 0x1104
94 #define DL_DATA_REQ 0x3004
95 #define DL_UNITDATA_REQ 0x3104
96 #define DL_INFORMATION_REQ 0x0004
99 #define DL_ESTABLISH_IND 0x1008
100 #define DL_ESTABLISH_CNF 0x5008
101 #define DL_RELEASE_IND 0x1108
102 #define DL_RELEASE_CNF 0x5108
103 #define DL_DATA_IND 0x3008
104 #define DL_UNITDATA_IND 0x3108
105 #define DL_INFORMATION_IND 0x0008
108 #define MDL_ASSIGN_REQ 0x1804
109 #define MDL_ASSIGN_IND 0x1904
110 #define MDL_REMOVE_REQ 0x1A04
111 #define MDL_REMOVE_IND 0x1B04
112 #define MDL_STATUS_UP_IND 0x1C04
113 #define MDL_STATUS_DOWN_IND 0x1D04
114 #define MDL_STATUS_UI_IND 0x1E04
115 #define MDL_ERROR_IND 0x1F04
116 #define MDL_ERROR_RSP 0x5F04
119 #define DL_TIMER200_IND 0x7004
120 #define DL_TIMER203_IND 0x7304
121 #define DL_INTERN_MSG 0x7804
124 #define DL_INFO_L2_CONNECT 0x0001
125 #define DL_INFO_L2_REMOVED 0x0002
129 #define DTMF_TONE_VAL 0x2000
130 #define DTMF_TONE_MASK 0x007F
131 #define DTMF_TONE_START 0x2100
132 #define DTMF_TONE_STOP 0x2200
133 #define DTMF_HFC_COEF 0x4000
134 #define DSP_CONF_JOIN 0x2403
135 #define DSP_CONF_SPLIT 0x2404
136 #define DSP_RECEIVE_OFF 0x2405
137 #define DSP_RECEIVE_ON 0x2406
138 #define DSP_ECHO_ON 0x2407
139 #define DSP_ECHO_OFF 0x2408
140 #define DSP_MIX_ON 0x2409
141 #define DSP_MIX_OFF 0x240a
142 #define DSP_DELAY 0x240b
143 #define DSP_JITTER 0x240c
144 #define DSP_TXDATA_ON 0x240d
145 #define DSP_TXDATA_OFF 0x240e
146 #define DSP_TX_DEJITTER 0x240f
147 #define DSP_TX_DEJ_OFF 0x2410
148 #define DSP_TONE_PATT_ON 0x2411
149 #define DSP_TONE_PATT_OFF 0x2412
150 #define DSP_VOL_CHANGE_TX 0x2413
151 #define DSP_VOL_CHANGE_RX 0x2414
152 #define DSP_BF_ENABLE_KEY 0x2415
153 #define DSP_BF_DISABLE 0x2416
154 #define DSP_BF_ACCEPT 0x2416
155 #define DSP_BF_REJECT 0x2417
156 #define DSP_PIPELINE_CFG 0x2418
157 #define HFC_VOL_CHANGE_TX 0x2601
158 #define HFC_VOL_CHANGE_RX 0x2602
159 #define HFC_SPL_LOOP_ON 0x2603
160 #define HFC_SPL_LOOP_OFF 0x2604
162 #define HW_MOD_FRM 0x4000
163 #define HW_MOD_FRH 0x4001
164 #define HW_MOD_FTM 0x4002
165 #define HW_MOD_FTH 0x4003
166 #define HW_MOD_FTS 0x4004
167 #define HW_MOD_CONNECT 0x4010
168 #define HW_MOD_OK 0x4011
169 #define HW_MOD_NOCARR 0x4012
170 #define HW_MOD_FCERROR 0x4013
171 #define HW_MOD_READY 0x4014
172 #define HW_MOD_LASTDATA 0x4015
175 #define TONE_OFF 0x0000
176 #define TONE_GERMAN_DIALTONE 0x0001
177 #define TONE_GERMAN_OLDDIALTONE 0x0002
178 #define TONE_AMERICAN_DIALTONE 0x0003
179 #define TONE_GERMAN_DIALPBX 0x0004
180 #define TONE_GERMAN_OLDDIALPBX 0x0005
181 #define TONE_AMERICAN_DIALPBX 0x0006
182 #define TONE_GERMAN_RINGING 0x0007
183 #define TONE_GERMAN_OLDRINGING 0x0008
184 #define TONE_AMERICAN_RINGPBX 0x000b
185 #define TONE_GERMAN_RINGPBX 0x000c
186 #define TONE_GERMAN_OLDRINGPBX 0x000d
187 #define TONE_AMERICAN_RINGING 0x000e
188 #define TONE_GERMAN_BUSY 0x000f
189 #define TONE_GERMAN_OLDBUSY 0x0010
190 #define TONE_AMERICAN_BUSY 0x0011
191 #define TONE_GERMAN_HANGUP 0x0012
192 #define TONE_GERMAN_OLDHANGUP 0x0013
193 #define TONE_AMERICAN_HANGUP 0x0014
194 #define TONE_SPECIAL_INFO 0x0015
195 #define TONE_GERMAN_GASSENBESETZT 0x0016
196 #define TONE_GERMAN_AUFSCHALTTON 0x0016
199 #define L1_SIGNAL_LOS_OFF 0x0010
200 #define L1_SIGNAL_LOS_ON 0x0011
201 #define L1_SIGNAL_AIS_OFF 0x0012
202 #define L1_SIGNAL_AIS_ON 0x0013
203 #define L1_SIGNAL_RDI_OFF 0x0014
204 #define L1_SIGNAL_RDI_ON 0x0015
205 #define L1_SIGNAL_SLIP_RX 0x0020
206 #define L1_SIGNAL_SLIP_TX 0x0021
214 #define ISDN_P_NONE 0
215 #define ISDN_P_BASE 0
216 #define ISDN_P_TE_S0 0x01
217 #define ISDN_P_NT_S0 0x02
218 #define ISDN_P_TE_E1 0x03
219 #define ISDN_P_NT_E1 0x04
220 #define ISDN_P_TE_UP0 0x05
221 #define ISDN_P_NT_UP0 0x06
223 #define IS_ISDN_P_TE(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_TE_E1) || \
224 (p == ISDN_P_TE_UP0) || (p == ISDN_P_LAPD_TE))
225 #define IS_ISDN_P_NT(p) ((p == ISDN_P_NT_S0) || (p == ISDN_P_NT_E1) || \
226 (p == ISDN_P_NT_UP0) || (p == ISDN_P_LAPD_NT))
227 #define IS_ISDN_P_S0(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_NT_S0))
228 #define IS_ISDN_P_E1(p) ((p == ISDN_P_TE_E1) || (p == ISDN_P_NT_E1))
229 #define IS_ISDN_P_UP0(p) ((p == ISDN_P_TE_UP0) || (p == ISDN_P_NT_UP0))
232 #define ISDN_P_LAPD_TE 0x10
233 #define ISDN_P_LAPD_NT 0x11
235 #define ISDN_P_B_MASK 0x1f
236 #define ISDN_P_B_START 0x20
238 #define ISDN_P_B_RAW 0x21
239 #define ISDN_P_B_HDLC 0x22
240 #define ISDN_P_B_X75SLP 0x23
241 #define ISDN_P_B_L2DTMF 0x24
242 #define ISDN_P_B_L2DSP 0x25
243 #define ISDN_P_B_L2DSPHDLC 0x26
244 #define ISDN_P_B_T30_FAX 0x27
245 #define ISDN_P_B_MODEM_ASYNC 0x28
247 #define OPTION_L2_PMX 1
248 #define OPTION_L2_PTP 2
249 #define OPTION_L2_FIXEDTEI 3
250 #define OPTION_L2_CLEANUP 4
251 #define OPTION_L1_HOLD 5
254 #define MISDN_MAX_IDLEN 20
261 #define MISDN_HEADER_LEN sizeof(struct mISDNhead)
262 #define MAX_DATA_SIZE 2048
263 #define MAX_DATA_MEM (MAX_DATA_SIZE + MISDN_HEADER_LEN)
264 #define MAX_DFRAME_LEN 260
266 #define MISDN_ID_ADDR_MASK 0xFFFF
267 #define MISDN_ID_TEI_MASK 0xFF00
268 #define MISDN_ID_SAPI_MASK 0x00FF
269 #define MISDN_ID_TEI_ANY 0x7F00
271 #define MISDN_ID_ANY 0xFFFF
272 #define MISDN_ID_NONE 0xFFFE
274 #define GROUP_TEI 127
278 #define MISDN_MAX_CHANNEL 127
279 #define MISDN_CHMAP_SIZE ((MISDN_MAX_CHANNEL + 1) >> 3)
330 #define IMADDTIMER _IOR('I', 64, int)
331 #define IMDELTIMER _IOR('I', 65, int)
334 #define IMGETVERSION _IOR('I', 66, int)
335 #define IMGETCOUNT _IOR('I', 67, int)
336 #define IMGETDEVINFO _IOR('I', 68, int)
337 #define IMCTRLREQ _IOR('I', 69, int)
338 #define IMCLEAR_L2 _IOR('I', 70, int)
339 #define IMSETDEVNAME _IOR('I', 71, struct mISDN_devrename)
340 #define IMHOLD_L1 _IOR('I', 72, int)
346 return map[nr >> 3] & (1 << (nr & 7));
354 map[nr >> 3] |= (1 << (nr & 7));
360 map[nr >> 3] &= ~(1 << (nr & 7));
364 #define MISDN_CTRL_GETOP 0x0000
365 #define MISDN_CTRL_LOOP 0x0001
366 #define MISDN_CTRL_CONNECT 0x0002
367 #define MISDN_CTRL_DISCONNECT 0x0004
368 #define MISDN_CTRL_RX_BUFFER 0x0008
369 #define MISDN_CTRL_PCMCONNECT 0x0010
370 #define MISDN_CTRL_PCMDISCONNECT 0x0020
371 #define MISDN_CTRL_SETPEER 0x0040
372 #define MISDN_CTRL_UNSETPEER 0x0080
373 #define MISDN_CTRL_RX_OFF 0x0100
374 #define MISDN_CTRL_FILL_EMPTY 0x0200
375 #define MISDN_CTRL_GETPEER 0x0400
376 #define MISDN_CTRL_L1_TIMER3 0x0800
377 #define MISDN_CTRL_HW_FEATURES_OP 0x2000
378 #define MISDN_CTRL_HW_FEATURES 0x2001
379 #define MISDN_CTRL_HFC_OP 0x4000
380 #define MISDN_CTRL_HFC_PCM_CONN 0x4001
381 #define MISDN_CTRL_HFC_PCM_DISC 0x4002
382 #define MISDN_CTRL_HFC_CONF_JOIN 0x4003
383 #define MISDN_CTRL_HFC_CONF_SPLIT 0x4004
384 #define MISDN_CTRL_HFC_RECEIVE_OFF 0x4005
385 #define MISDN_CTRL_HFC_RECEIVE_ON 0x4006
386 #define MISDN_CTRL_HFC_ECHOCAN_ON 0x4007
387 #define MISDN_CTRL_HFC_ECHOCAN_OFF 0x4008
388 #define MISDN_CTRL_HFC_WD_INIT 0x4009
389 #define MISDN_CTRL_HFC_WD_RESET 0x400A
395 #define MISDN_CTRL_RX_SIZE_IGNORE -1
398 #define MISDN_TIME_STAMP 0x0001
408 #define MISDN_OPT_ALL 1
409 #define MISDN_OPT_TEIMGR 2
412 #include <linux/list.h>
414 #include <linux/net.h>
418 #define DEBUG_CORE 0x000000ff
419 #define DEBUG_CORE_FUNC 0x00000002
420 #define DEBUG_SOCKET 0x00000004
421 #define DEBUG_MANAGER 0x00000008
422 #define DEBUG_SEND_ERR 0x00000010
423 #define DEBUG_MSG_THREAD 0x00000020
424 #define DEBUG_QUEUE_FUNC 0x00000040
425 #define DEBUG_L1 0x0000ff00
426 #define DEBUG_L1_FSM 0x00000200
427 #define DEBUG_L2 0x00ff0000
428 #define DEBUG_L2_FSM 0x00020000
429 #define DEBUG_L2_CTRL 0x00040000
430 #define DEBUG_L2_RECV 0x00080000
431 #define DEBUG_L2_TEI 0x00100000
432 #define DEBUG_L2_TEIFSM 0x00200000
433 #define DEBUG_TIMER 0x01000000
434 #define DEBUG_CLOCK 0x02000000
436 #define mISDN_HEAD_P(s) ((struct mISDNhead *)&s->cb[0])
437 #define mISDN_HEAD_PRIM(s) (((struct mISDNhead *)&s->cb[0])->prim)
438 #define mISDN_HEAD_ID(s) (((struct mISDNhead *)&s->cb[0])->id)
442 #define MISDN_BOUND 2
443 #define MISDN_CLOSED 3
453 struct mISDNchannel *ch;
456 typedef int (ctrl_func_t)(
struct mISDNchannel *,
u_int,
void *);
457 typedef int (send_func_t)(
struct mISDNchannel *,
struct sk_buff *);
458 typedef int (create_func_t)(
struct channel_req *);
467 struct mISDNchannel {
473 struct mISDNstack *
st;
474 struct mISDNchannel *peer;
480 struct mISDN_sock_list {
487 struct mISDNchannel ch;
489 struct mISDNdevice *
dev;
495 struct mISDNchannel
D;
502 struct mISDNchannel *
teimgr;
508 struct mISDNdevice *
dev;
514 struct mISDNchannel *
layer1;
515 struct mISDNchannel own;
517 struct mISDN_sock_list l1sock;
518 #ifdef MISDN_MSG_STATS
525 typedef int (clockctl_func_t)(
void *,
int);
531 clockctl_func_t *
ctl;
551 struct sk_buff *skb = mI_alloc_skb(len, gfp_mask);
558 hh = mISDN_HEAD_P(skb);
565 _queue_data(
struct mISDNchannel *ch,
u_int prim,
572 skb = _alloc_mISDN_skb(prim,
id, len, dp, gfp_mask);
575 if (ch->recv(ch->peer, skb))
590 static inline struct mISDNdevice *dev_to_mISDN(
struct device *
dev)