mISDNif.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /*
  2. *
  3. * Author Karsten Keil <[email protected]>
  4. *
  5. * Copyright 2008 by Karsten Keil <[email protected]>
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
  9. * version 2.1 as published by the Free Software Foundation.
  10. *
  11. * This code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU LESSER GENERAL PUBLIC LICENSE for more details.
  15. *
  16. */
  17. #ifndef mISDNIF_H
  18. #define mISDNIF_H
  19. #include <linux/types.h>
  20. #include <linux/errno.h>
  21. #include <linux/socket.h>
  22. /*
  23. * ABI Version 32 bit
  24. *
  25. * <8 bit> Major version
  26. * - changed if any interface become backwards incompatible
  27. *
  28. * <8 bit> Minor version
  29. * - changed if any interface is extended but backwards compatible
  30. *
  31. * <16 bit> Release number
  32. * - should be incremented on every checkin
  33. */
  34. #define MISDN_MAJOR_VERSION 1
  35. #define MISDN_MINOR_VERSION 1
  36. #define MISDN_RELEASE 29
  37. /* primitives for information exchange
  38. * generell format
  39. * <16 bit 0 >
  40. * <8 bit command>
  41. * BIT 8 = 1 LAYER private
  42. * BIT 7 = 1 answer
  43. * BIT 6 = 1 DATA
  44. * <8 bit target layer mask>
  45. *
  46. * Layer = 00 is reserved for general commands
  47. Layer = 01 L2 -> HW
  48. Layer = 02 HW -> L2
  49. Layer = 04 L3 -> L2
  50. Layer = 08 L2 -> L3
  51. * Layer = FF is reserved for broadcast commands
  52. */
  53. #define MISDN_CMDMASK 0xff00
  54. #define MISDN_LAYERMASK 0x00ff
  55. /* generell commands */
  56. #define OPEN_CHANNEL 0x0100
  57. #define CLOSE_CHANNEL 0x0200
  58. #define CONTROL_CHANNEL 0x0300
  59. #define CHECK_DATA 0x0400
  60. /* layer 2 -> layer 1 */
  61. #define PH_ACTIVATE_REQ 0x0101
  62. #define PH_DEACTIVATE_REQ 0x0201
  63. #define PH_DATA_REQ 0x2001
  64. #define MPH_ACTIVATE_REQ 0x0501
  65. #define MPH_DEACTIVATE_REQ 0x0601
  66. #define MPH_INFORMATION_REQ 0x0701
  67. #define PH_CONTROL_REQ 0x0801
  68. /* layer 1 -> layer 2 */
  69. #define PH_ACTIVATE_IND 0x0102
  70. #define PH_ACTIVATE_CNF 0x4102
  71. #define PH_DEACTIVATE_IND 0x0202
  72. #define PH_DEACTIVATE_CNF 0x4202
  73. #define PH_DATA_IND 0x2002
  74. #define PH_DATA_E_IND 0x3002
  75. #define MPH_ACTIVATE_IND 0x0502
  76. #define MPH_DEACTIVATE_IND 0x0602
  77. #define MPH_INFORMATION_IND 0x0702
  78. #define PH_DATA_CNF 0x6002
  79. #define PH_CONTROL_IND 0x0802
  80. #define PH_CONTROL_CNF 0x4802
  81. /* layer 3 -> layer 2 */
  82. #define DL_ESTABLISH_REQ 0x1004
  83. #define DL_RELEASE_REQ 0x1104
  84. #define DL_DATA_REQ 0x3004
  85. #define DL_UNITDATA_REQ 0x3104
  86. #define DL_INFORMATION_REQ 0x0004
  87. /* layer 2 -> layer 3 */
  88. #define DL_ESTABLISH_IND 0x1008
  89. #define DL_ESTABLISH_CNF 0x5008
  90. #define DL_RELEASE_IND 0x1108
  91. #define DL_RELEASE_CNF 0x5108
  92. #define DL_DATA_IND 0x3008
  93. #define DL_UNITDATA_IND 0x3108
  94. #define DL_INFORMATION_IND 0x0008
  95. /* intern layer 2 management */
  96. #define MDL_ASSIGN_REQ 0x1804
  97. #define MDL_ASSIGN_IND 0x1904
  98. #define MDL_REMOVE_REQ 0x1A04
  99. #define MDL_REMOVE_IND 0x1B04
  100. #define MDL_STATUS_UP_IND 0x1C04
  101. #define MDL_STATUS_DOWN_IND 0x1D04
  102. #define MDL_STATUS_UI_IND 0x1E04
  103. #define MDL_ERROR_IND 0x1F04
  104. #define MDL_ERROR_RSP 0x5F04
  105. /* intern layer 2 */
  106. #define DL_TIMER200_IND 0x7004
  107. #define DL_TIMER203_IND 0x7304
  108. #define DL_INTERN_MSG 0x7804
  109. /* DL_INFORMATION_IND types */
  110. #define DL_INFO_L2_CONNECT 0x0001
  111. #define DL_INFO_L2_REMOVED 0x0002
  112. /* PH_CONTROL types */
  113. /* TOUCH TONE IS 0x20XX XX "0"..."9", "A","B","C","D","*","#" */
  114. #define DTMF_TONE_VAL 0x2000
  115. #define DTMF_TONE_MASK 0x007F
  116. #define DTMF_TONE_START 0x2100
  117. #define DTMF_TONE_STOP 0x2200
  118. #define DTMF_HFC_COEF 0x4000
  119. #define DSP_CONF_JOIN 0x2403
  120. #define DSP_CONF_SPLIT 0x2404
  121. #define DSP_RECEIVE_OFF 0x2405
  122. #define DSP_RECEIVE_ON 0x2406
  123. #define DSP_ECHO_ON 0x2407
  124. #define DSP_ECHO_OFF 0x2408
  125. #define DSP_MIX_ON 0x2409
  126. #define DSP_MIX_OFF 0x240a
  127. #define DSP_DELAY 0x240b
  128. #define DSP_JITTER 0x240c
  129. #define DSP_TXDATA_ON 0x240d
  130. #define DSP_TXDATA_OFF 0x240e
  131. #define DSP_TX_DEJITTER 0x240f
  132. #define DSP_TX_DEJ_OFF 0x2410
  133. #define DSP_TONE_PATT_ON 0x2411
  134. #define DSP_TONE_PATT_OFF 0x2412
  135. #define DSP_VOL_CHANGE_TX 0x2413
  136. #define DSP_VOL_CHANGE_RX 0x2414
  137. #define DSP_BF_ENABLE_KEY 0x2415
  138. #define DSP_BF_DISABLE 0x2416
  139. #define DSP_BF_ACCEPT 0x2416
  140. #define DSP_BF_REJECT 0x2417
  141. #define DSP_PIPELINE_CFG 0x2418
  142. #define HFC_VOL_CHANGE_TX 0x2601
  143. #define HFC_VOL_CHANGE_RX 0x2602
  144. #define HFC_SPL_LOOP_ON 0x2603
  145. #define HFC_SPL_LOOP_OFF 0x2604
  146. /* for T30 FAX and analog modem */
  147. #define HW_MOD_FRM 0x4000
  148. #define HW_MOD_FRH 0x4001
  149. #define HW_MOD_FTM 0x4002
  150. #define HW_MOD_FTH 0x4003
  151. #define HW_MOD_FTS 0x4004
  152. #define HW_MOD_CONNECT 0x4010
  153. #define HW_MOD_OK 0x4011
  154. #define HW_MOD_NOCARR 0x4012
  155. #define HW_MOD_FCERROR 0x4013
  156. #define HW_MOD_READY 0x4014
  157. #define HW_MOD_LASTDATA 0x4015
  158. /* DSP_TONE_PATT_ON parameter */
  159. #define TONE_OFF 0x0000
  160. #define TONE_GERMAN_DIALTONE 0x0001
  161. #define TONE_GERMAN_OLDDIALTONE 0x0002
  162. #define TONE_AMERICAN_DIALTONE 0x0003
  163. #define TONE_GERMAN_DIALPBX 0x0004
  164. #define TONE_GERMAN_OLDDIALPBX 0x0005
  165. #define TONE_AMERICAN_DIALPBX 0x0006
  166. #define TONE_GERMAN_RINGING 0x0007
  167. #define TONE_GERMAN_OLDRINGING 0x0008
  168. #define TONE_AMERICAN_RINGPBX 0x000b
  169. #define TONE_GERMAN_RINGPBX 0x000c
  170. #define TONE_GERMAN_OLDRINGPBX 0x000d
  171. #define TONE_AMERICAN_RINGING 0x000e
  172. #define TONE_GERMAN_BUSY 0x000f
  173. #define TONE_GERMAN_OLDBUSY 0x0010
  174. #define TONE_AMERICAN_BUSY 0x0011
  175. #define TONE_GERMAN_HANGUP 0x0012
  176. #define TONE_GERMAN_OLDHANGUP 0x0013
  177. #define TONE_AMERICAN_HANGUP 0x0014
  178. #define TONE_SPECIAL_INFO 0x0015
  179. #define TONE_GERMAN_GASSENBESETZT 0x0016
  180. #define TONE_GERMAN_AUFSCHALTTON 0x0016
  181. /* MPH_INFORMATION_IND */
  182. #define L1_SIGNAL_LOS_OFF 0x0010
  183. #define L1_SIGNAL_LOS_ON 0x0011
  184. #define L1_SIGNAL_AIS_OFF 0x0012
  185. #define L1_SIGNAL_AIS_ON 0x0013
  186. #define L1_SIGNAL_RDI_OFF 0x0014
  187. #define L1_SIGNAL_RDI_ON 0x0015
  188. #define L1_SIGNAL_SLIP_RX 0x0020
  189. #define L1_SIGNAL_SLIP_TX 0x0021
  190. /*
  191. * protocol ids
  192. * D channel 1-31
  193. * B channel 33 - 63
  194. */
  195. #define ISDN_P_NONE 0
  196. #define ISDN_P_BASE 0
  197. #define ISDN_P_TE_S0 0x01
  198. #define ISDN_P_NT_S0 0x02
  199. #define ISDN_P_TE_E1 0x03
  200. #define ISDN_P_NT_E1 0x04
  201. #define ISDN_P_TE_UP0 0x05
  202. #define ISDN_P_NT_UP0 0x06
  203. #define IS_ISDN_P_TE(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_TE_E1) || \
  204. (p == ISDN_P_TE_UP0) || (p == ISDN_P_LAPD_TE))
  205. #define IS_ISDN_P_NT(p) ((p == ISDN_P_NT_S0) || (p == ISDN_P_NT_E1) || \
  206. (p == ISDN_P_NT_UP0) || (p == ISDN_P_LAPD_NT))
  207. #define IS_ISDN_P_S0(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_NT_S0))
  208. #define IS_ISDN_P_E1(p) ((p == ISDN_P_TE_E1) || (p == ISDN_P_NT_E1))
  209. #define IS_ISDN_P_UP0(p) ((p == ISDN_P_TE_UP0) || (p == ISDN_P_NT_UP0))
  210. #define ISDN_P_LAPD_TE 0x10
  211. #define ISDN_P_LAPD_NT 0x11
  212. #define ISDN_P_B_MASK 0x1f
  213. #define ISDN_P_B_START 0x20
  214. #define ISDN_P_B_RAW 0x21
  215. #define ISDN_P_B_HDLC 0x22
  216. #define ISDN_P_B_X75SLP 0x23
  217. #define ISDN_P_B_L2DTMF 0x24
  218. #define ISDN_P_B_L2DSP 0x25
  219. #define ISDN_P_B_L2DSPHDLC 0x26
  220. #define ISDN_P_B_T30_FAX 0x27
  221. #define ISDN_P_B_MODEM_ASYNC 0x28
  222. #define OPTION_L2_PMX 1
  223. #define OPTION_L2_PTP 2
  224. #define OPTION_L2_FIXEDTEI 3
  225. #define OPTION_L2_CLEANUP 4
  226. #define OPTION_L1_HOLD 5
  227. /* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */
  228. #define MISDN_MAX_IDLEN 20
  229. struct mISDNhead {
  230. unsigned int prim;
  231. unsigned int id;
  232. } __packed;
  233. #define MISDN_HEADER_LEN sizeof(struct mISDNhead)
  234. #define MAX_DATA_SIZE 2048
  235. #define MAX_DATA_MEM (MAX_DATA_SIZE + MISDN_HEADER_LEN)
  236. #define MAX_DFRAME_LEN 260
  237. #define MISDN_ID_ADDR_MASK 0xFFFF
  238. #define MISDN_ID_TEI_MASK 0xFF00
  239. #define MISDN_ID_SAPI_MASK 0x00FF
  240. #define MISDN_ID_TEI_ANY 0x7F00
  241. #define MISDN_ID_ANY 0xFFFF
  242. #define MISDN_ID_NONE 0xFFFE
  243. #define GROUP_TEI 127
  244. #define TEI_SAPI 63
  245. #define CTRL_SAPI 0
  246. #define MISDN_MAX_CHANNEL 127
  247. #define MISDN_CHMAP_SIZE ((MISDN_MAX_CHANNEL + 1) >> 3)
  248. #define SOL_MISDN 0
  249. struct sockaddr_mISDN {
  250. sa_family_t family;
  251. unsigned char dev;
  252. unsigned char channel;
  253. unsigned char sapi;
  254. unsigned char tei;
  255. };
  256. struct mISDNversion {
  257. unsigned char major;
  258. unsigned char minor;
  259. unsigned short release;
  260. };
  261. struct mISDN_devinfo {
  262. u_int id;
  263. u_int Dprotocols;
  264. u_int Bprotocols;
  265. u_int protocol;
  266. u_char channelmap[MISDN_CHMAP_SIZE];
  267. u_int nrbchan;
  268. char name[MISDN_MAX_IDLEN];
  269. };
  270. struct mISDN_devrename {
  271. u_int id;
  272. char name[MISDN_MAX_IDLEN]; /* new name */
  273. };
  274. /* MPH_INFORMATION_REQ payload */
  275. struct ph_info_ch {
  276. __u32 protocol;
  277. __u64 Flags;
  278. };
  279. struct ph_info_dch {
  280. struct ph_info_ch ch;
  281. __u16 state;
  282. __u16 num_bch;
  283. };
  284. struct ph_info {
  285. struct ph_info_dch dch;
  286. struct ph_info_ch bch[];
  287. };
  288. /* timer device ioctl */
  289. #define IMADDTIMER _IOR('I', 64, int)
  290. #define IMDELTIMER _IOR('I', 65, int)
  291. /* socket ioctls */
  292. #define IMGETVERSION _IOR('I', 66, int)
  293. #define IMGETCOUNT _IOR('I', 67, int)
  294. #define IMGETDEVINFO _IOR('I', 68, int)
  295. #define IMCTRLREQ _IOR('I', 69, int)
  296. #define IMCLEAR_L2 _IOR('I', 70, int)
  297. #define IMSETDEVNAME _IOR('I', 71, struct mISDN_devrename)
  298. #define IMHOLD_L1 _IOR('I', 72, int)
  299. static inline int
  300. test_channelmap(u_int nr, u_char *map)
  301. {
  302. if (nr <= MISDN_MAX_CHANNEL)
  303. return map[nr >> 3] & (1 << (nr & 7));
  304. else
  305. return 0;
  306. }
  307. static inline void
  308. set_channelmap(u_int nr, u_char *map)
  309. {
  310. map[nr >> 3] |= (1 << (nr & 7));
  311. }
  312. static inline void
  313. clear_channelmap(u_int nr, u_char *map)
  314. {
  315. map[nr >> 3] &= ~(1 << (nr & 7));
  316. }
  317. /* CONTROL_CHANNEL parameters */
  318. #define MISDN_CTRL_GETOP 0x0000
  319. #define MISDN_CTRL_LOOP 0x0001
  320. #define MISDN_CTRL_CONNECT 0x0002
  321. #define MISDN_CTRL_DISCONNECT 0x0004
  322. #define MISDN_CTRL_RX_BUFFER 0x0008
  323. #define MISDN_CTRL_PCMCONNECT 0x0010
  324. #define MISDN_CTRL_PCMDISCONNECT 0x0020
  325. #define MISDN_CTRL_SETPEER 0x0040
  326. #define MISDN_CTRL_UNSETPEER 0x0080
  327. #define MISDN_CTRL_RX_OFF 0x0100
  328. #define MISDN_CTRL_FILL_EMPTY 0x0200
  329. #define MISDN_CTRL_GETPEER 0x0400
  330. #define MISDN_CTRL_L1_TIMER3 0x0800
  331. #define MISDN_CTRL_HW_FEATURES_OP 0x2000
  332. #define MISDN_CTRL_HW_FEATURES 0x2001
  333. #define MISDN_CTRL_HFC_OP 0x4000
  334. #define MISDN_CTRL_HFC_PCM_CONN 0x4001
  335. #define MISDN_CTRL_HFC_PCM_DISC 0x4002
  336. #define MISDN_CTRL_HFC_CONF_JOIN 0x4003
  337. #define MISDN_CTRL_HFC_CONF_SPLIT 0x4004
  338. #define MISDN_CTRL_HFC_RECEIVE_OFF 0x4005
  339. #define MISDN_CTRL_HFC_RECEIVE_ON 0x4006
  340. #define MISDN_CTRL_HFC_ECHOCAN_ON 0x4007
  341. #define MISDN_CTRL_HFC_ECHOCAN_OFF 0x4008
  342. #define MISDN_CTRL_HFC_WD_INIT 0x4009
  343. #define MISDN_CTRL_HFC_WD_RESET 0x400A
  344. /* special RX buffer value for MISDN_CTRL_RX_BUFFER request.p1 is the minimum
  345. * buffer size request.p2 the maximum. Using MISDN_CTRL_RX_SIZE_IGNORE will
  346. * not change the value, but still read back the actual stetting.
  347. */
  348. #define MISDN_CTRL_RX_SIZE_IGNORE -1
  349. /* socket options */
  350. #define MISDN_TIME_STAMP 0x0001
  351. struct mISDN_ctrl_req {
  352. int op;
  353. int channel;
  354. int p1;
  355. int p2;
  356. };
  357. /* muxer options */
  358. #define MISDN_OPT_ALL 1
  359. #define MISDN_OPT_TEIMGR 2
  360. #ifdef __KERNEL__
  361. #include <linux/list.h>
  362. #include <linux/skbuff.h>
  363. #include <linux/net.h>
  364. #include <net/sock.h>
  365. #include <linux/completion.h>
  366. #define DEBUG_CORE 0x000000ff
  367. #define DEBUG_CORE_FUNC 0x00000002
  368. #define DEBUG_SOCKET 0x00000004
  369. #define DEBUG_MANAGER 0x00000008
  370. #define DEBUG_SEND_ERR 0x00000010
  371. #define DEBUG_MSG_THREAD 0x00000020
  372. #define DEBUG_QUEUE_FUNC 0x00000040
  373. #define DEBUG_L1 0x0000ff00
  374. #define DEBUG_L1_FSM 0x00000200
  375. #define DEBUG_L2 0x00ff0000
  376. #define DEBUG_L2_FSM 0x00020000
  377. #define DEBUG_L2_CTRL 0x00040000
  378. #define DEBUG_L2_RECV 0x00080000
  379. #define DEBUG_L2_TEI 0x00100000
  380. #define DEBUG_L2_TEIFSM 0x00200000
  381. #define DEBUG_TIMER 0x01000000
  382. #define DEBUG_CLOCK 0x02000000
  383. #define mISDN_HEAD_P(s) ((struct mISDNhead *)&s->cb[0])
  384. #define mISDN_HEAD_PRIM(s) (((struct mISDNhead *)&s->cb[0])->prim)
  385. #define mISDN_HEAD_ID(s) (((struct mISDNhead *)&s->cb[0])->id)
  386. /* socket states */
  387. #define MISDN_OPEN 1
  388. #define MISDN_BOUND 2
  389. #define MISDN_CLOSED 3
  390. struct mISDNchannel;
  391. struct mISDNdevice;
  392. struct mISDNstack;
  393. struct mISDNclock;
  394. struct channel_req {
  395. u_int protocol;
  396. struct sockaddr_mISDN adr;
  397. struct mISDNchannel *ch;
  398. };
  399. typedef int (ctrl_func_t)(struct mISDNchannel *, u_int, void *);
  400. typedef int (send_func_t)(struct mISDNchannel *, struct sk_buff *);
  401. typedef int (create_func_t)(struct channel_req *);
  402. struct Bprotocol {
  403. struct list_head list;
  404. char *name;
  405. u_int Bprotocols;
  406. create_func_t *create;
  407. };
  408. struct mISDNchannel {
  409. struct list_head list;
  410. u_int protocol;
  411. u_int nr;
  412. u_long opt;
  413. u_int addr;
  414. struct mISDNstack *st;
  415. struct mISDNchannel *peer;
  416. send_func_t *send;
  417. send_func_t *recv;
  418. ctrl_func_t *ctrl;
  419. };
  420. struct mISDN_sock_list {
  421. struct hlist_head head;
  422. rwlock_t lock;
  423. };
  424. struct mISDN_sock {
  425. struct sock sk;
  426. struct mISDNchannel ch;
  427. u_int cmask;
  428. struct mISDNdevice *dev;
  429. };
  430. struct mISDNdevice {
  431. struct mISDNchannel D;
  432. u_int id;
  433. u_int Dprotocols;
  434. u_int Bprotocols;
  435. u_int nrbchan;
  436. u_char channelmap[MISDN_CHMAP_SIZE];
  437. struct list_head bchannels;
  438. struct mISDNchannel *teimgr;
  439. struct device dev;
  440. };
  441. struct mISDNstack {
  442. u_long status;
  443. struct mISDNdevice *dev;
  444. struct task_struct *thread;
  445. struct completion *notify;
  446. wait_queue_head_t workq;
  447. struct sk_buff_head msgq;
  448. struct list_head layer2;
  449. struct mISDNchannel *layer1;
  450. struct mISDNchannel own;
  451. struct mutex lmutex; /* protect lists */
  452. struct mISDN_sock_list l1sock;
  453. #ifdef MISDN_MSG_STATS
  454. u_int msg_cnt;
  455. u_int sleep_cnt;
  456. u_int stopped_cnt;
  457. #endif
  458. };
  459. typedef int (clockctl_func_t)(void *, int);
  460. struct mISDNclock {
  461. struct list_head list;
  462. char name[64];
  463. int pri;
  464. clockctl_func_t *ctl;
  465. void *priv;
  466. };
  467. /* global alloc/queue functions */
  468. static inline struct sk_buff *
  469. mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
  470. {
  471. struct sk_buff *skb;
  472. skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask);
  473. if (likely(skb))
  474. skb_reserve(skb, MISDN_HEADER_LEN);
  475. return skb;
  476. }
  477. static inline struct sk_buff *
  478. _alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask)
  479. {
  480. struct sk_buff *skb = mI_alloc_skb(len, gfp_mask);
  481. struct mISDNhead *hh;
  482. if (!skb)
  483. return NULL;
  484. if (len)
  485. skb_put_data(skb, dp, len);
  486. hh = mISDN_HEAD_P(skb);
  487. hh->prim = prim;
  488. hh->id = id;
  489. return skb;
  490. }
  491. static inline void
  492. _queue_data(struct mISDNchannel *ch, u_int prim,
  493. u_int id, u_int len, void *dp, gfp_t gfp_mask)
  494. {
  495. struct sk_buff *skb;
  496. if (!ch->peer)
  497. return;
  498. skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask);
  499. if (!skb)
  500. return;
  501. if (ch->recv(ch->peer, skb))
  502. dev_kfree_skb(skb);
  503. }
  504. /* global register/unregister functions */
  505. extern int mISDN_register_device(struct mISDNdevice *,
  506. struct device *parent, char *name);
  507. extern void mISDN_unregister_device(struct mISDNdevice *);
  508. extern int mISDN_register_Bprotocol(struct Bprotocol *);
  509. extern void mISDN_unregister_Bprotocol(struct Bprotocol *);
  510. extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *,
  511. void *);
  512. extern void mISDN_unregister_clock(struct mISDNclock *);
  513. static inline struct mISDNdevice *dev_to_mISDN(struct device *dev)
  514. {
  515. if (dev)
  516. return dev_get_drvdata(dev);
  517. else
  518. return NULL;
  519. }
  520. extern void set_channel_address(struct mISDNchannel *, u_int, u_int);
  521. extern void mISDN_clock_update(struct mISDNclock *, int, ktime_t *);
  522. extern unsigned short mISDN_clock_get(void);
  523. extern const char *mISDNDevName4ch(struct mISDNchannel *);
  524. #endif /* __KERNEL__ */
  525. #endif /* mISDNIF_H */