mISDNif.h 15 KB

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