Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *
0003  * Author   Karsten Keil <kkeil@novell.com>
0004  *
0005  * Copyright 2008  by Karsten Keil <kkeil@novell.com>
0006  *
0007  * This code is free software; you can redistribute it and/or modify
0008  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
0009  * version 2.1 as published by the Free Software Foundation.
0010  *
0011  * This code is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU LESSER GENERAL PUBLIC LICENSE for more details.
0015  *
0016  */
0017 
0018 #ifndef mISDNIF_H
0019 #define mISDNIF_H
0020 
0021 #include <linux/types.h>
0022 #include <linux/errno.h>
0023 #include <linux/socket.h>
0024 
0025 /*
0026  * ABI Version 32 bit
0027  *
0028  * <8 bit> Major version
0029  *      - changed if any interface become backwards incompatible
0030  *
0031  * <8 bit> Minor version
0032  *              - changed if any interface is extended but backwards compatible
0033  *
0034  * <16 bit> Release number
0035  *              - should be incremented on every checkin
0036  */
0037 #define MISDN_MAJOR_VERSION 1
0038 #define MISDN_MINOR_VERSION 1
0039 #define MISDN_RELEASE       29
0040 
0041 /* primitives for information exchange
0042  * generell format
0043  * <16  bit  0 >
0044  * <8  bit command>
0045  *    BIT 8 = 1 LAYER private
0046  *    BIT 7 = 1 answer
0047  *    BIT 6 = 1 DATA
0048  * <8  bit target layer mask>
0049  *
0050  * Layer = 00 is reserved for general commands
0051    Layer = 01  L2 -> HW
0052    Layer = 02  HW -> L2
0053    Layer = 04  L3 -> L2
0054    Layer = 08  L2 -> L3
0055  * Layer = FF is reserved for broadcast commands
0056  */
0057 
0058 #define MISDN_CMDMASK       0xff00
0059 #define MISDN_LAYERMASK     0x00ff
0060 
0061 /* generell commands */
0062 #define OPEN_CHANNEL        0x0100
0063 #define CLOSE_CHANNEL       0x0200
0064 #define CONTROL_CHANNEL     0x0300
0065 #define CHECK_DATA      0x0400
0066 
0067 /* layer 2 -> layer 1 */
0068 #define PH_ACTIVATE_REQ     0x0101
0069 #define PH_DEACTIVATE_REQ   0x0201
0070 #define PH_DATA_REQ     0x2001
0071 #define MPH_ACTIVATE_REQ    0x0501
0072 #define MPH_DEACTIVATE_REQ  0x0601
0073 #define MPH_INFORMATION_REQ 0x0701
0074 #define PH_CONTROL_REQ      0x0801
0075 
0076 /* layer 1 -> layer 2 */
0077 #define PH_ACTIVATE_IND     0x0102
0078 #define PH_ACTIVATE_CNF     0x4102
0079 #define PH_DEACTIVATE_IND   0x0202
0080 #define PH_DEACTIVATE_CNF   0x4202
0081 #define PH_DATA_IND     0x2002
0082 #define PH_DATA_E_IND       0x3002
0083 #define MPH_ACTIVATE_IND    0x0502
0084 #define MPH_DEACTIVATE_IND  0x0602
0085 #define MPH_INFORMATION_IND 0x0702
0086 #define PH_DATA_CNF     0x6002
0087 #define PH_CONTROL_IND      0x0802
0088 #define PH_CONTROL_CNF      0x4802
0089 
0090 /* layer 3 -> layer 2 */
0091 #define DL_ESTABLISH_REQ    0x1004
0092 #define DL_RELEASE_REQ      0x1104
0093 #define DL_DATA_REQ     0x3004
0094 #define DL_UNITDATA_REQ     0x3104
0095 #define DL_INFORMATION_REQ  0x0004
0096 
0097 /* layer 2 -> layer 3 */
0098 #define DL_ESTABLISH_IND    0x1008
0099 #define DL_ESTABLISH_CNF    0x5008
0100 #define DL_RELEASE_IND      0x1108
0101 #define DL_RELEASE_CNF      0x5108
0102 #define DL_DATA_IND     0x3008
0103 #define DL_UNITDATA_IND     0x3108
0104 #define DL_INFORMATION_IND  0x0008
0105 
0106 /* intern layer 2 management */
0107 #define MDL_ASSIGN_REQ      0x1804
0108 #define MDL_ASSIGN_IND      0x1904
0109 #define MDL_REMOVE_REQ      0x1A04
0110 #define MDL_REMOVE_IND      0x1B04
0111 #define MDL_STATUS_UP_IND   0x1C04
0112 #define MDL_STATUS_DOWN_IND 0x1D04
0113 #define MDL_STATUS_UI_IND   0x1E04
0114 #define MDL_ERROR_IND       0x1F04
0115 #define MDL_ERROR_RSP       0x5F04
0116 
0117 /* intern layer 2 */
0118 #define DL_TIMER200_IND     0x7004
0119 #define DL_TIMER203_IND     0x7304
0120 #define DL_INTERN_MSG       0x7804
0121 
0122 /* DL_INFORMATION_IND types */
0123 #define DL_INFO_L2_CONNECT  0x0001
0124 #define DL_INFO_L2_REMOVED  0x0002
0125 
0126 /* PH_CONTROL types */
0127 /* TOUCH TONE IS 0x20XX  XX "0"..."9", "A","B","C","D","*","#" */
0128 #define DTMF_TONE_VAL       0x2000
0129 #define DTMF_TONE_MASK      0x007F
0130 #define DTMF_TONE_START     0x2100
0131 #define DTMF_TONE_STOP      0x2200
0132 #define DTMF_HFC_COEF       0x4000
0133 #define DSP_CONF_JOIN       0x2403
0134 #define DSP_CONF_SPLIT      0x2404
0135 #define DSP_RECEIVE_OFF     0x2405
0136 #define DSP_RECEIVE_ON      0x2406
0137 #define DSP_ECHO_ON     0x2407
0138 #define DSP_ECHO_OFF        0x2408
0139 #define DSP_MIX_ON      0x2409
0140 #define DSP_MIX_OFF     0x240a
0141 #define DSP_DELAY       0x240b
0142 #define DSP_JITTER      0x240c
0143 #define DSP_TXDATA_ON       0x240d
0144 #define DSP_TXDATA_OFF      0x240e
0145 #define DSP_TX_DEJITTER     0x240f
0146 #define DSP_TX_DEJ_OFF      0x2410
0147 #define DSP_TONE_PATT_ON    0x2411
0148 #define DSP_TONE_PATT_OFF   0x2412
0149 #define DSP_VOL_CHANGE_TX   0x2413
0150 #define DSP_VOL_CHANGE_RX   0x2414
0151 #define DSP_BF_ENABLE_KEY   0x2415
0152 #define DSP_BF_DISABLE      0x2416
0153 #define DSP_BF_ACCEPT       0x2416
0154 #define DSP_BF_REJECT       0x2417
0155 #define DSP_PIPELINE_CFG    0x2418
0156 #define HFC_VOL_CHANGE_TX   0x2601
0157 #define HFC_VOL_CHANGE_RX   0x2602
0158 #define HFC_SPL_LOOP_ON     0x2603
0159 #define HFC_SPL_LOOP_OFF    0x2604
0160 /* for T30 FAX and analog modem */
0161 #define HW_MOD_FRM      0x4000
0162 #define HW_MOD_FRH      0x4001
0163 #define HW_MOD_FTM      0x4002
0164 #define HW_MOD_FTH      0x4003
0165 #define HW_MOD_FTS      0x4004
0166 #define HW_MOD_CONNECT      0x4010
0167 #define HW_MOD_OK       0x4011
0168 #define HW_MOD_NOCARR       0x4012
0169 #define HW_MOD_FCERROR      0x4013
0170 #define HW_MOD_READY        0x4014
0171 #define HW_MOD_LASTDATA     0x4015
0172 
0173 /* DSP_TONE_PATT_ON parameter */
0174 #define TONE_OFF            0x0000
0175 #define TONE_GERMAN_DIALTONE        0x0001
0176 #define TONE_GERMAN_OLDDIALTONE     0x0002
0177 #define TONE_AMERICAN_DIALTONE      0x0003
0178 #define TONE_GERMAN_DIALPBX     0x0004
0179 #define TONE_GERMAN_OLDDIALPBX      0x0005
0180 #define TONE_AMERICAN_DIALPBX       0x0006
0181 #define TONE_GERMAN_RINGING     0x0007
0182 #define TONE_GERMAN_OLDRINGING      0x0008
0183 #define TONE_AMERICAN_RINGPBX       0x000b
0184 #define TONE_GERMAN_RINGPBX     0x000c
0185 #define TONE_GERMAN_OLDRINGPBX      0x000d
0186 #define TONE_AMERICAN_RINGING       0x000e
0187 #define TONE_GERMAN_BUSY        0x000f
0188 #define TONE_GERMAN_OLDBUSY     0x0010
0189 #define TONE_AMERICAN_BUSY      0x0011
0190 #define TONE_GERMAN_HANGUP      0x0012
0191 #define TONE_GERMAN_OLDHANGUP       0x0013
0192 #define TONE_AMERICAN_HANGUP        0x0014
0193 #define TONE_SPECIAL_INFO       0x0015
0194 #define TONE_GERMAN_GASSENBESETZT   0x0016
0195 #define TONE_GERMAN_AUFSCHALTTON    0x0016
0196 
0197 /* MPH_INFORMATION_IND */
0198 #define L1_SIGNAL_LOS_OFF   0x0010
0199 #define L1_SIGNAL_LOS_ON    0x0011
0200 #define L1_SIGNAL_AIS_OFF   0x0012
0201 #define L1_SIGNAL_AIS_ON    0x0013
0202 #define L1_SIGNAL_RDI_OFF   0x0014
0203 #define L1_SIGNAL_RDI_ON    0x0015
0204 #define L1_SIGNAL_SLIP_RX   0x0020
0205 #define L1_SIGNAL_SLIP_TX   0x0021
0206 
0207 /*
0208  * protocol ids
0209  * D channel 1-31
0210  * B channel 33 - 63
0211  */
0212 
0213 #define ISDN_P_NONE     0
0214 #define ISDN_P_BASE     0
0215 #define ISDN_P_TE_S0        0x01
0216 #define ISDN_P_NT_S0        0x02
0217 #define ISDN_P_TE_E1        0x03
0218 #define ISDN_P_NT_E1        0x04
0219 #define ISDN_P_TE_UP0       0x05
0220 #define ISDN_P_NT_UP0       0x06
0221 
0222 #define IS_ISDN_P_TE(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_TE_E1) || \
0223                 (p == ISDN_P_TE_UP0) || (p == ISDN_P_LAPD_TE))
0224 #define IS_ISDN_P_NT(p) ((p == ISDN_P_NT_S0) || (p == ISDN_P_NT_E1) || \
0225                 (p == ISDN_P_NT_UP0) || (p == ISDN_P_LAPD_NT))
0226 #define IS_ISDN_P_S0(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_NT_S0))
0227 #define IS_ISDN_P_E1(p) ((p == ISDN_P_TE_E1) || (p == ISDN_P_NT_E1))
0228 #define IS_ISDN_P_UP0(p) ((p == ISDN_P_TE_UP0) || (p == ISDN_P_NT_UP0))
0229 
0230 
0231 #define ISDN_P_LAPD_TE      0x10
0232 #define ISDN_P_LAPD_NT      0x11
0233 
0234 #define ISDN_P_B_MASK       0x1f
0235 #define ISDN_P_B_START      0x20
0236 
0237 #define ISDN_P_B_RAW        0x21
0238 #define ISDN_P_B_HDLC       0x22
0239 #define ISDN_P_B_X75SLP     0x23
0240 #define ISDN_P_B_L2DTMF     0x24
0241 #define ISDN_P_B_L2DSP      0x25
0242 #define ISDN_P_B_L2DSPHDLC  0x26
0243 #define ISDN_P_B_T30_FAX    0x27
0244 #define ISDN_P_B_MODEM_ASYNC    0x28
0245 
0246 #define OPTION_L2_PMX       1
0247 #define OPTION_L2_PTP       2
0248 #define OPTION_L2_FIXEDTEI  3
0249 #define OPTION_L2_CLEANUP   4
0250 #define OPTION_L1_HOLD      5
0251 
0252 /* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */
0253 #define MISDN_MAX_IDLEN     20
0254 
0255 struct mISDNhead {
0256     unsigned int    prim;
0257     unsigned int    id;
0258 }  __packed;
0259 
0260 #define MISDN_HEADER_LEN    sizeof(struct mISDNhead)
0261 #define MAX_DATA_SIZE       2048
0262 #define MAX_DATA_MEM        (MAX_DATA_SIZE + MISDN_HEADER_LEN)
0263 #define MAX_DFRAME_LEN      260
0264 
0265 #define MISDN_ID_ADDR_MASK  0xFFFF
0266 #define MISDN_ID_TEI_MASK   0xFF00
0267 #define MISDN_ID_SAPI_MASK  0x00FF
0268 #define MISDN_ID_TEI_ANY    0x7F00
0269 
0270 #define MISDN_ID_ANY        0xFFFF
0271 #define MISDN_ID_NONE       0xFFFE
0272 
0273 #define GROUP_TEI       127
0274 #define TEI_SAPI        63
0275 #define CTRL_SAPI       0
0276 
0277 #define MISDN_MAX_CHANNEL   127
0278 #define MISDN_CHMAP_SIZE    ((MISDN_MAX_CHANNEL + 1) >> 3)
0279 
0280 #define SOL_MISDN   0
0281 
0282 struct sockaddr_mISDN {
0283     sa_family_t    family;
0284     unsigned char   dev;
0285     unsigned char   channel;
0286     unsigned char   sapi;
0287     unsigned char   tei;
0288 };
0289 
0290 struct mISDNversion {
0291     unsigned char   major;
0292     unsigned char   minor;
0293     unsigned short  release;
0294 };
0295 
0296 struct mISDN_devinfo {
0297     u_int           id;
0298     u_int           Dprotocols;
0299     u_int           Bprotocols;
0300     u_int           protocol;
0301     u_char          channelmap[MISDN_CHMAP_SIZE];
0302     u_int           nrbchan;
0303     char            name[MISDN_MAX_IDLEN];
0304 };
0305 
0306 struct mISDN_devrename {
0307     u_int           id;
0308     char            name[MISDN_MAX_IDLEN]; /* new name */
0309 };
0310 
0311 /* MPH_INFORMATION_REQ payload */
0312 struct ph_info_ch {
0313     __u32 protocol;
0314     __u64 Flags;
0315 };
0316 
0317 struct ph_info_dch {
0318     struct ph_info_ch ch;
0319     __u16 state;
0320     __u16 num_bch;
0321 };
0322 
0323 struct ph_info {
0324     struct ph_info_dch dch;
0325     struct ph_info_ch  bch[];
0326 };
0327 
0328 /* timer device ioctl */
0329 #define IMADDTIMER  _IOR('I', 64, int)
0330 #define IMDELTIMER  _IOR('I', 65, int)
0331 
0332 /* socket ioctls */
0333 #define IMGETVERSION    _IOR('I', 66, int)
0334 #define IMGETCOUNT  _IOR('I', 67, int)
0335 #define IMGETDEVINFO    _IOR('I', 68, int)
0336 #define IMCTRLREQ   _IOR('I', 69, int)
0337 #define IMCLEAR_L2  _IOR('I', 70, int)
0338 #define IMSETDEVNAME    _IOR('I', 71, struct mISDN_devrename)
0339 #define IMHOLD_L1   _IOR('I', 72, int)
0340 
0341 static inline int
0342 test_channelmap(u_int nr, u_char *map)
0343 {
0344     if (nr <= MISDN_MAX_CHANNEL)
0345         return map[nr >> 3] & (1 << (nr & 7));
0346     else
0347         return 0;
0348 }
0349 
0350 static inline void
0351 set_channelmap(u_int nr, u_char *map)
0352 {
0353     map[nr >> 3] |= (1 << (nr & 7));
0354 }
0355 
0356 static inline void
0357 clear_channelmap(u_int nr, u_char *map)
0358 {
0359     map[nr >> 3] &= ~(1 << (nr & 7));
0360 }
0361 
0362 /* CONTROL_CHANNEL parameters */
0363 #define MISDN_CTRL_GETOP        0x0000
0364 #define MISDN_CTRL_LOOP         0x0001
0365 #define MISDN_CTRL_CONNECT      0x0002
0366 #define MISDN_CTRL_DISCONNECT       0x0004
0367 #define MISDN_CTRL_RX_BUFFER        0x0008
0368 #define MISDN_CTRL_PCMCONNECT       0x0010
0369 #define MISDN_CTRL_PCMDISCONNECT    0x0020
0370 #define MISDN_CTRL_SETPEER      0x0040
0371 #define MISDN_CTRL_UNSETPEER        0x0080
0372 #define MISDN_CTRL_RX_OFF       0x0100
0373 #define MISDN_CTRL_FILL_EMPTY       0x0200
0374 #define MISDN_CTRL_GETPEER      0x0400
0375 #define MISDN_CTRL_L1_TIMER3        0x0800
0376 #define MISDN_CTRL_HW_FEATURES_OP   0x2000
0377 #define MISDN_CTRL_HW_FEATURES      0x2001
0378 #define MISDN_CTRL_HFC_OP       0x4000
0379 #define MISDN_CTRL_HFC_PCM_CONN     0x4001
0380 #define MISDN_CTRL_HFC_PCM_DISC     0x4002
0381 #define MISDN_CTRL_HFC_CONF_JOIN    0x4003
0382 #define MISDN_CTRL_HFC_CONF_SPLIT   0x4004
0383 #define MISDN_CTRL_HFC_RECEIVE_OFF  0x4005
0384 #define MISDN_CTRL_HFC_RECEIVE_ON   0x4006
0385 #define MISDN_CTRL_HFC_ECHOCAN_ON   0x4007
0386 #define MISDN_CTRL_HFC_ECHOCAN_OFF  0x4008
0387 #define MISDN_CTRL_HFC_WD_INIT      0x4009
0388 #define MISDN_CTRL_HFC_WD_RESET     0x400A
0389 
0390 /* special RX buffer value for MISDN_CTRL_RX_BUFFER request.p1 is the minimum
0391  * buffer size request.p2 the maximum. Using  MISDN_CTRL_RX_SIZE_IGNORE will
0392  * not change the value, but still read back the actual stetting.
0393  */
0394 #define MISDN_CTRL_RX_SIZE_IGNORE   -1
0395 
0396 /* socket options */
0397 #define MISDN_TIME_STAMP        0x0001
0398 
0399 struct mISDN_ctrl_req {
0400     int     op;
0401     int     channel;
0402     int     p1;
0403     int     p2;
0404 };
0405 
0406 /* muxer options */
0407 #define MISDN_OPT_ALL       1
0408 #define MISDN_OPT_TEIMGR    2
0409 
0410 #ifdef __KERNEL__
0411 #include <linux/list.h>
0412 #include <linux/skbuff.h>
0413 #include <linux/net.h>
0414 #include <net/sock.h>
0415 #include <linux/completion.h>
0416 
0417 #define DEBUG_CORE      0x000000ff
0418 #define DEBUG_CORE_FUNC     0x00000002
0419 #define DEBUG_SOCKET        0x00000004
0420 #define DEBUG_MANAGER       0x00000008
0421 #define DEBUG_SEND_ERR      0x00000010
0422 #define DEBUG_MSG_THREAD    0x00000020
0423 #define DEBUG_QUEUE_FUNC    0x00000040
0424 #define DEBUG_L1        0x0000ff00
0425 #define DEBUG_L1_FSM        0x00000200
0426 #define DEBUG_L2        0x00ff0000
0427 #define DEBUG_L2_FSM        0x00020000
0428 #define DEBUG_L2_CTRL       0x00040000
0429 #define DEBUG_L2_RECV       0x00080000
0430 #define DEBUG_L2_TEI        0x00100000
0431 #define DEBUG_L2_TEIFSM     0x00200000
0432 #define DEBUG_TIMER     0x01000000
0433 #define DEBUG_CLOCK     0x02000000
0434 
0435 #define mISDN_HEAD_P(s)     ((struct mISDNhead *)&s->cb[0])
0436 #define mISDN_HEAD_PRIM(s)  (((struct mISDNhead *)&s->cb[0])->prim)
0437 #define mISDN_HEAD_ID(s)    (((struct mISDNhead *)&s->cb[0])->id)
0438 
0439 /* socket states */
0440 #define MISDN_OPEN  1
0441 #define MISDN_BOUND 2
0442 #define MISDN_CLOSED    3
0443 
0444 struct mISDNchannel;
0445 struct mISDNdevice;
0446 struct mISDNstack;
0447 struct mISDNclock;
0448 
0449 struct channel_req {
0450     u_int           protocol;
0451     struct sockaddr_mISDN   adr;
0452     struct mISDNchannel *ch;
0453 };
0454 
0455 typedef int (ctrl_func_t)(struct mISDNchannel *, u_int, void *);
0456 typedef int (send_func_t)(struct mISDNchannel *, struct sk_buff *);
0457 typedef int (create_func_t)(struct channel_req *);
0458 
0459 struct Bprotocol {
0460     struct list_head    list;
0461     char            *name;
0462     u_int           Bprotocols;
0463     create_func_t       *create;
0464 };
0465 
0466 struct mISDNchannel {
0467     struct list_head    list;
0468     u_int           protocol;
0469     u_int           nr;
0470     u_long          opt;
0471     u_int           addr;
0472     struct mISDNstack   *st;
0473     struct mISDNchannel *peer;
0474     send_func_t     *send;
0475     send_func_t     *recv;
0476     ctrl_func_t     *ctrl;
0477 };
0478 
0479 struct mISDN_sock_list {
0480     struct hlist_head   head;
0481     rwlock_t        lock;
0482 };
0483 
0484 struct mISDN_sock {
0485     struct sock     sk;
0486     struct mISDNchannel ch;
0487     u_int           cmask;
0488     struct mISDNdevice  *dev;
0489 };
0490 
0491 
0492 
0493 struct mISDNdevice {
0494     struct mISDNchannel D;
0495     u_int           id;
0496     u_int           Dprotocols;
0497     u_int           Bprotocols;
0498     u_int           nrbchan;
0499     u_char          channelmap[MISDN_CHMAP_SIZE];
0500     struct list_head    bchannels;
0501     struct mISDNchannel *teimgr;
0502     struct device       dev;
0503 };
0504 
0505 struct mISDNstack {
0506     u_long          status;
0507     struct mISDNdevice  *dev;
0508     struct task_struct  *thread;
0509     struct completion   *notify;
0510     wait_queue_head_t   workq;
0511     struct sk_buff_head msgq;
0512     struct list_head    layer2;
0513     struct mISDNchannel *layer1;
0514     struct mISDNchannel own;
0515     struct mutex        lmutex; /* protect lists */
0516     struct mISDN_sock_list  l1sock;
0517 #ifdef MISDN_MSG_STATS
0518     u_int           msg_cnt;
0519     u_int           sleep_cnt;
0520     u_int           stopped_cnt;
0521 #endif
0522 };
0523 
0524 typedef int (clockctl_func_t)(void *, int);
0525 
0526 struct  mISDNclock {
0527     struct list_head    list;
0528     char            name[64];
0529     int         pri;
0530     clockctl_func_t     *ctl;
0531     void            *priv;
0532 };
0533 
0534 /* global alloc/queue functions */
0535 
0536 static inline struct sk_buff *
0537 mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
0538 {
0539     struct sk_buff  *skb;
0540 
0541     skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask);
0542     if (likely(skb))
0543         skb_reserve(skb, MISDN_HEADER_LEN);
0544     return skb;
0545 }
0546 
0547 static inline struct sk_buff *
0548 _alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask)
0549 {
0550     struct sk_buff  *skb = mI_alloc_skb(len, gfp_mask);
0551     struct mISDNhead *hh;
0552 
0553     if (!skb)
0554         return NULL;
0555     if (len)
0556         skb_put_data(skb, dp, len);
0557     hh = mISDN_HEAD_P(skb);
0558     hh->prim = prim;
0559     hh->id = id;
0560     return skb;
0561 }
0562 
0563 static inline void
0564 _queue_data(struct mISDNchannel *ch, u_int prim,
0565     u_int id, u_int len, void *dp, gfp_t gfp_mask)
0566 {
0567     struct sk_buff      *skb;
0568 
0569     if (!ch->peer)
0570         return;
0571     skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask);
0572     if (!skb)
0573         return;
0574     if (ch->recv(ch->peer, skb))
0575         dev_kfree_skb(skb);
0576 }
0577 
0578 /* global register/unregister functions */
0579 
0580 extern int  mISDN_register_device(struct mISDNdevice *,
0581                     struct device *parent, char *name);
0582 extern void mISDN_unregister_device(struct mISDNdevice *);
0583 extern int  mISDN_register_Bprotocol(struct Bprotocol *);
0584 extern void mISDN_unregister_Bprotocol(struct Bprotocol *);
0585 extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *,
0586                         void *);
0587 extern void mISDN_unregister_clock(struct mISDNclock *);
0588 
0589 static inline struct mISDNdevice *dev_to_mISDN(struct device *dev)
0590 {
0591     if (dev)
0592         return dev_get_drvdata(dev);
0593     else
0594         return NULL;
0595 }
0596 
0597 extern void set_channel_address(struct mISDNchannel *, u_int, u_int);
0598 extern void mISDN_clock_update(struct mISDNclock *, int, ktime_t *);
0599 extern unsigned short mISDN_clock_get(void);
0600 extern const char *mISDNDevName4ch(struct mISDNchannel *);
0601 
0602 #endif /* __KERNEL__ */
0603 #endif /* mISDNIF_H */