mISDNif.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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 21
  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. /* DL_INFORMATION_IND types */
  107. #define DL_INFO_L2_CONNECT 0x0001
  108. #define DL_INFO_L2_REMOVED 0x0002
  109. /* PH_CONTROL types */
  110. /* TOUCH TONE IS 0x20XX XX "0"..."9", "A","B","C","D","*","#" */
  111. #define DTMF_TONE_VAL 0x2000
  112. #define DTMF_TONE_MASK 0x007F
  113. #define DTMF_TONE_START 0x2100
  114. #define DTMF_TONE_STOP 0x2200
  115. #define DTMF_HFC_COEF 0x4000
  116. #define DSP_CONF_JOIN 0x2403
  117. #define DSP_CONF_SPLIT 0x2404
  118. #define DSP_RECEIVE_OFF 0x2405
  119. #define DSP_RECEIVE_ON 0x2406
  120. #define DSP_ECHO_ON 0x2407
  121. #define DSP_ECHO_OFF 0x2408
  122. #define DSP_MIX_ON 0x2409
  123. #define DSP_MIX_OFF 0x240a
  124. #define DSP_DELAY 0x240b
  125. #define DSP_JITTER 0x240c
  126. #define DSP_TXDATA_ON 0x240d
  127. #define DSP_TXDATA_OFF 0x240e
  128. #define DSP_TX_DEJITTER 0x240f
  129. #define DSP_TX_DEJ_OFF 0x2410
  130. #define DSP_TONE_PATT_ON 0x2411
  131. #define DSP_TONE_PATT_OFF 0x2412
  132. #define DSP_VOL_CHANGE_TX 0x2413
  133. #define DSP_VOL_CHANGE_RX 0x2414
  134. #define DSP_BF_ENABLE_KEY 0x2415
  135. #define DSP_BF_DISABLE 0x2416
  136. #define DSP_BF_ACCEPT 0x2416
  137. #define DSP_BF_REJECT 0x2417
  138. #define DSP_PIPELINE_CFG 0x2418
  139. #define HFC_VOL_CHANGE_TX 0x2601
  140. #define HFC_VOL_CHANGE_RX 0x2602
  141. #define HFC_SPL_LOOP_ON 0x2603
  142. #define HFC_SPL_LOOP_OFF 0x2604
  143. /* for T30 FAX and analog modem */
  144. #define HW_MOD_FRM 0x4000
  145. #define HW_MOD_FRH 0x4001
  146. #define HW_MOD_FTM 0x4002
  147. #define HW_MOD_FTH 0x4003
  148. #define HW_MOD_FTS 0x4004
  149. #define HW_MOD_CONNECT 0x4010
  150. #define HW_MOD_OK 0x4011
  151. #define HW_MOD_NOCARR 0x4012
  152. #define HW_MOD_FCERROR 0x4013
  153. #define HW_MOD_READY 0x4014
  154. #define HW_MOD_LASTDATA 0x4015
  155. /* DSP_TONE_PATT_ON parameter */
  156. #define TONE_OFF 0x0000
  157. #define TONE_GERMAN_DIALTONE 0x0001
  158. #define TONE_GERMAN_OLDDIALTONE 0x0002
  159. #define TONE_AMERICAN_DIALTONE 0x0003
  160. #define TONE_GERMAN_DIALPBX 0x0004
  161. #define TONE_GERMAN_OLDDIALPBX 0x0005
  162. #define TONE_AMERICAN_DIALPBX 0x0006
  163. #define TONE_GERMAN_RINGING 0x0007
  164. #define TONE_GERMAN_OLDRINGING 0x0008
  165. #define TONE_AMERICAN_RINGPBX 0x000b
  166. #define TONE_GERMAN_RINGPBX 0x000c
  167. #define TONE_GERMAN_OLDRINGPBX 0x000d
  168. #define TONE_AMERICAN_RINGING 0x000e
  169. #define TONE_GERMAN_BUSY 0x000f
  170. #define TONE_GERMAN_OLDBUSY 0x0010
  171. #define TONE_AMERICAN_BUSY 0x0011
  172. #define TONE_GERMAN_HANGUP 0x0012
  173. #define TONE_GERMAN_OLDHANGUP 0x0013
  174. #define TONE_AMERICAN_HANGUP 0x0014
  175. #define TONE_SPECIAL_INFO 0x0015
  176. #define TONE_GERMAN_GASSENBESETZT 0x0016
  177. #define TONE_GERMAN_AUFSCHALTTON 0x0016
  178. /* MPH_INFORMATION_IND */
  179. #define L1_SIGNAL_LOS_OFF 0x0010
  180. #define L1_SIGNAL_LOS_ON 0x0011
  181. #define L1_SIGNAL_AIS_OFF 0x0012
  182. #define L1_SIGNAL_AIS_ON 0x0013
  183. #define L1_SIGNAL_RDI_OFF 0x0014
  184. #define L1_SIGNAL_RDI_ON 0x0015
  185. #define L1_SIGNAL_SLIP_RX 0x0020
  186. #define L1_SIGNAL_SLIP_TX 0x0021
  187. /*
  188. * protocol ids
  189. * D channel 1-31
  190. * B channel 33 - 63
  191. */
  192. #define ISDN_P_NONE 0
  193. #define ISDN_P_BASE 0
  194. #define ISDN_P_TE_S0 0x01
  195. #define ISDN_P_NT_S0 0x02
  196. #define ISDN_P_TE_E1 0x03
  197. #define ISDN_P_NT_E1 0x04
  198. #define ISDN_P_TE_UP0 0x05
  199. #define ISDN_P_NT_UP0 0x06
  200. #define IS_ISDN_P_TE(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_TE_E1) || \
  201. (p == ISDN_P_TE_UP0) || (p == ISDN_P_LAPD_TE))
  202. #define IS_ISDN_P_NT(p) ((p == ISDN_P_NT_S0) || (p == ISDN_P_NT_E1) || \
  203. (p == ISDN_P_NT_UP0) || (p == ISDN_P_LAPD_NT))
  204. #define IS_ISDN_P_S0(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_NT_S0))
  205. #define IS_ISDN_P_E1(p) ((p == ISDN_P_TE_E1) || (p == ISDN_P_NT_E1))
  206. #define IS_ISDN_P_UP0(p) ((p == ISDN_P_TE_UP0) || (p == ISDN_P_NT_UP0))
  207. #define ISDN_P_LAPD_TE 0x10
  208. #define ISDN_P_LAPD_NT 0x11
  209. #define ISDN_P_B_MASK 0x1f
  210. #define ISDN_P_B_START 0x20
  211. #define ISDN_P_B_RAW 0x21
  212. #define ISDN_P_B_HDLC 0x22
  213. #define ISDN_P_B_X75SLP 0x23
  214. #define ISDN_P_B_L2DTMF 0x24
  215. #define ISDN_P_B_L2DSP 0x25
  216. #define ISDN_P_B_L2DSPHDLC 0x26
  217. #define ISDN_P_B_T30_FAX 0x27
  218. #define ISDN_P_B_MODEM_ASYNC 0x28
  219. #define OPTION_L2_PMX 1
  220. #define OPTION_L2_PTP 2
  221. #define OPTION_L2_FIXEDTEI 3
  222. #define OPTION_L2_CLEANUP 4
  223. #define OPTION_L1_HOLD 5
  224. /* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */
  225. #define MISDN_MAX_IDLEN 20
  226. struct mISDNhead {
  227. unsigned int prim;
  228. unsigned int id;
  229. } __packed;
  230. #define MISDN_HEADER_LEN sizeof(struct mISDNhead)
  231. #define MAX_DATA_SIZE 2048
  232. #define MAX_DATA_MEM (MAX_DATA_SIZE + MISDN_HEADER_LEN)
  233. #define MAX_DFRAME_LEN 260
  234. #define MISDN_ID_ADDR_MASK 0xFFFF
  235. #define MISDN_ID_TEI_MASK 0xFF00
  236. #define MISDN_ID_SAPI_MASK 0x00FF
  237. #define MISDN_ID_TEI_ANY 0x7F00
  238. #define MISDN_ID_ANY 0xFFFF
  239. #define MISDN_ID_NONE 0xFFFE
  240. #define GROUP_TEI 127
  241. #define TEI_SAPI 63
  242. #define CTRL_SAPI 0
  243. #define MISDN_MAX_CHANNEL 127
  244. #define MISDN_CHMAP_SIZE ((MISDN_MAX_CHANNEL + 1) >> 3)
  245. #define SOL_MISDN 0
  246. struct sockaddr_mISDN {
  247. sa_family_t family;
  248. unsigned char dev;
  249. unsigned char channel;
  250. unsigned char sapi;
  251. unsigned char tei;
  252. };
  253. struct mISDNversion {
  254. unsigned char major;
  255. unsigned char minor;
  256. unsigned short release;
  257. };
  258. struct mISDN_devinfo {
  259. u_int id;
  260. u_int Dprotocols;
  261. u_int Bprotocols;
  262. u_int protocol;
  263. u_char channelmap[MISDN_CHMAP_SIZE];
  264. u_int nrbchan;
  265. char name[MISDN_MAX_IDLEN];
  266. };
  267. struct mISDN_devrename {
  268. u_int id;
  269. char name[MISDN_MAX_IDLEN]; /* new name */
  270. };
  271. /* MPH_INFORMATION_REQ payload */
  272. struct ph_info_ch {
  273. __u32 protocol;
  274. __u64 Flags;
  275. };
  276. struct ph_info_dch {
  277. struct ph_info_ch ch;
  278. __u16 state;
  279. __u16 num_bch;
  280. };
  281. struct ph_info {
  282. struct ph_info_dch dch;
  283. struct ph_info_ch bch[];
  284. };
  285. /* timer device ioctl */
  286. #define IMADDTIMER _IOR('I', 64, int)
  287. #define IMDELTIMER _IOR('I', 65, int)
  288. /* socket ioctls */
  289. #define IMGETVERSION _IOR('I', 66, int)
  290. #define IMGETCOUNT _IOR('I', 67, int)
  291. #define IMGETDEVINFO _IOR('I', 68, int)
  292. #define IMCTRLREQ _IOR('I', 69, int)
  293. #define IMCLEAR_L2 _IOR('I', 70, int)
  294. #define IMSETDEVNAME _IOR('I', 71, struct mISDN_devrename)
  295. #define IMHOLD_L1 _IOR('I', 72, int)
  296. static inline int
  297. test_channelmap(u_int nr, u_char *map)
  298. {
  299. if (nr <= MISDN_MAX_CHANNEL)
  300. return map[nr >> 3] & (1 << (nr & 7));
  301. else
  302. return 0;
  303. }
  304. static inline void
  305. set_channelmap(u_int nr, u_char *map)
  306. {
  307. map[nr >> 3] |= (1 << (nr & 7));
  308. }
  309. static inline void
  310. clear_channelmap(u_int nr, u_char *map)
  311. {
  312. map[nr >> 3] &= ~(1 << (nr & 7));
  313. }
  314. /* CONTROL_CHANNEL parameters */
  315. #define MISDN_CTRL_GETOP 0x0000
  316. #define MISDN_CTRL_LOOP 0x0001
  317. #define MISDN_CTRL_CONNECT 0x0002
  318. #define MISDN_CTRL_DISCONNECT 0x0004
  319. #define MISDN_CTRL_PCMCONNECT 0x0010
  320. #define MISDN_CTRL_PCMDISCONNECT 0x0020
  321. #define MISDN_CTRL_SETPEER 0x0040
  322. #define MISDN_CTRL_UNSETPEER 0x0080
  323. #define MISDN_CTRL_RX_OFF 0x0100
  324. #define MISDN_CTRL_FILL_EMPTY 0x0200
  325. #define MISDN_CTRL_GETPEER 0x0400
  326. #define MISDN_CTRL_HW_FEATURES_OP 0x2000
  327. #define MISDN_CTRL_HW_FEATURES 0x2001
  328. #define MISDN_CTRL_HFC_OP 0x4000
  329. #define MISDN_CTRL_HFC_PCM_CONN 0x4001
  330. #define MISDN_CTRL_HFC_PCM_DISC 0x4002
  331. #define MISDN_CTRL_HFC_CONF_JOIN 0x4003
  332. #define MISDN_CTRL_HFC_CONF_SPLIT 0x4004
  333. #define MISDN_CTRL_HFC_RECEIVE_OFF 0x4005
  334. #define MISDN_CTRL_HFC_RECEIVE_ON 0x4006
  335. #define MISDN_CTRL_HFC_ECHOCAN_ON 0x4007
  336. #define MISDN_CTRL_HFC_ECHOCAN_OFF 0x4008
  337. #define MISDN_CTRL_HFC_WD_INIT 0x4009
  338. #define MISDN_CTRL_HFC_WD_RESET 0x400A
  339. /* socket options */
  340. #define MISDN_TIME_STAMP 0x0001
  341. struct mISDN_ctrl_req {
  342. int op;
  343. int channel;
  344. int p1;
  345. int p2;
  346. };
  347. /* muxer options */
  348. #define MISDN_OPT_ALL 1
  349. #define MISDN_OPT_TEIMGR 2
  350. #ifdef __KERNEL__
  351. #include <linux/list.h>
  352. #include <linux/skbuff.h>
  353. #include <linux/net.h>
  354. #include <net/sock.h>
  355. #include <linux/completion.h>
  356. #define DEBUG_CORE 0x000000ff
  357. #define DEBUG_CORE_FUNC 0x00000002
  358. #define DEBUG_SOCKET 0x00000004
  359. #define DEBUG_MANAGER 0x00000008
  360. #define DEBUG_SEND_ERR 0x00000010
  361. #define DEBUG_MSG_THREAD 0x00000020
  362. #define DEBUG_QUEUE_FUNC 0x00000040
  363. #define DEBUG_L1 0x0000ff00
  364. #define DEBUG_L1_FSM 0x00000200
  365. #define DEBUG_L2 0x00ff0000
  366. #define DEBUG_L2_FSM 0x00020000
  367. #define DEBUG_L2_CTRL 0x00040000
  368. #define DEBUG_L2_RECV 0x00080000
  369. #define DEBUG_L2_TEI 0x00100000
  370. #define DEBUG_L2_TEIFSM 0x00200000
  371. #define DEBUG_TIMER 0x01000000
  372. #define DEBUG_CLOCK 0x02000000
  373. #define mISDN_HEAD_P(s) ((struct mISDNhead *)&s->cb[0])
  374. #define mISDN_HEAD_PRIM(s) (((struct mISDNhead *)&s->cb[0])->prim)
  375. #define mISDN_HEAD_ID(s) (((struct mISDNhead *)&s->cb[0])->id)
  376. /* socket states */
  377. #define MISDN_OPEN 1
  378. #define MISDN_BOUND 2
  379. #define MISDN_CLOSED 3
  380. struct mISDNchannel;
  381. struct mISDNdevice;
  382. struct mISDNstack;
  383. struct mISDNclock;
  384. struct channel_req {
  385. u_int protocol;
  386. struct sockaddr_mISDN adr;
  387. struct mISDNchannel *ch;
  388. };
  389. typedef int (ctrl_func_t)(struct mISDNchannel *, u_int, void *);
  390. typedef int (send_func_t)(struct mISDNchannel *, struct sk_buff *);
  391. typedef int (create_func_t)(struct channel_req *);
  392. struct Bprotocol {
  393. struct list_head list;
  394. char *name;
  395. u_int Bprotocols;
  396. create_func_t *create;
  397. };
  398. struct mISDNchannel {
  399. struct list_head list;
  400. u_int protocol;
  401. u_int nr;
  402. u_long opt;
  403. u_int addr;
  404. struct mISDNstack *st;
  405. struct mISDNchannel *peer;
  406. send_func_t *send;
  407. send_func_t *recv;
  408. ctrl_func_t *ctrl;
  409. };
  410. struct mISDN_sock_list {
  411. struct hlist_head head;
  412. rwlock_t lock;
  413. };
  414. struct mISDN_sock {
  415. struct sock sk;
  416. struct mISDNchannel ch;
  417. u_int cmask;
  418. struct mISDNdevice *dev;
  419. };
  420. struct mISDNdevice {
  421. struct mISDNchannel D;
  422. u_int id;
  423. u_int Dprotocols;
  424. u_int Bprotocols;
  425. u_int nrbchan;
  426. u_char channelmap[MISDN_CHMAP_SIZE];
  427. struct list_head bchannels;
  428. struct mISDNchannel *teimgr;
  429. struct device dev;
  430. };
  431. struct mISDNstack {
  432. u_long status;
  433. struct mISDNdevice *dev;
  434. struct task_struct *thread;
  435. struct completion *notify;
  436. wait_queue_head_t workq;
  437. struct sk_buff_head msgq;
  438. struct list_head layer2;
  439. struct mISDNchannel *layer1;
  440. struct mISDNchannel own;
  441. struct mutex lmutex; /* protect lists */
  442. struct mISDN_sock_list l1sock;
  443. #ifdef MISDN_MSG_STATS
  444. u_int msg_cnt;
  445. u_int sleep_cnt;
  446. u_int stopped_cnt;
  447. #endif
  448. };
  449. typedef int (clockctl_func_t)(void *, int);
  450. struct mISDNclock {
  451. struct list_head list;
  452. char name[64];
  453. int pri;
  454. clockctl_func_t *ctl;
  455. void *priv;
  456. };
  457. /* global alloc/queue functions */
  458. static inline struct sk_buff *
  459. mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
  460. {
  461. struct sk_buff *skb;
  462. skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask);
  463. if (likely(skb))
  464. skb_reserve(skb, MISDN_HEADER_LEN);
  465. return skb;
  466. }
  467. static inline struct sk_buff *
  468. _alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask)
  469. {
  470. struct sk_buff *skb = mI_alloc_skb(len, gfp_mask);
  471. struct mISDNhead *hh;
  472. if (!skb)
  473. return NULL;
  474. if (len)
  475. memcpy(skb_put(skb, len), dp, len);
  476. hh = mISDN_HEAD_P(skb);
  477. hh->prim = prim;
  478. hh->id = id;
  479. return skb;
  480. }
  481. static inline void
  482. _queue_data(struct mISDNchannel *ch, u_int prim,
  483. u_int id, u_int len, void *dp, gfp_t gfp_mask)
  484. {
  485. struct sk_buff *skb;
  486. if (!ch->peer)
  487. return;
  488. skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask);
  489. if (!skb)
  490. return;
  491. if (ch->recv(ch->peer, skb))
  492. dev_kfree_skb(skb);
  493. }
  494. /* global register/unregister functions */
  495. extern int mISDN_register_device(struct mISDNdevice *,
  496. struct device *parent, char *name);
  497. extern void mISDN_unregister_device(struct mISDNdevice *);
  498. extern int mISDN_register_Bprotocol(struct Bprotocol *);
  499. extern void mISDN_unregister_Bprotocol(struct Bprotocol *);
  500. extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *,
  501. void *);
  502. extern void mISDN_unregister_clock(struct mISDNclock *);
  503. static inline struct mISDNdevice *dev_to_mISDN(struct device *dev)
  504. {
  505. if (dev)
  506. return dev_get_drvdata(dev);
  507. else
  508. return NULL;
  509. }
  510. extern void set_channel_address(struct mISDNchannel *, u_int, u_int);
  511. extern void mISDN_clock_update(struct mISDNclock *, int, struct timeval *);
  512. extern unsigned short mISDN_clock_get(void);
  513. #endif /* __KERNEL__ */
  514. #endif /* mISDNIF_H */