Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * see notice in l1oip.c
0004  */
0005 
0006 /* debugging */
0007 #define DEBUG_L1OIP_INIT    0x00010000
0008 #define DEBUG_L1OIP_SOCKET  0x00020000
0009 #define DEBUG_L1OIP_MGR     0x00040000
0010 #define DEBUG_L1OIP_MSG     0x00080000
0011 
0012 /* enable to disorder received bchannels by sequence 2143658798... */
0013 /*
0014   #define REORDER_DEBUG
0015 */
0016 
0017 /* frames */
0018 #define L1OIP_MAX_LEN       2048        /* max packet size form l2 */
0019 #define L1OIP_MAX_PERFRAME  1400        /* max data size in one frame */
0020 
0021 
0022 /* timers */
0023 #define L1OIP_KEEPALIVE     15
0024 #define L1OIP_TIMEOUT       65
0025 
0026 
0027 /* socket */
0028 #define L1OIP_DEFAULTPORT   931
0029 
0030 
0031 /* channel structure */
0032 struct l1oip_chan {
0033     struct dchannel     *dch;
0034     struct bchannel     *bch;
0035     u32         tx_counter; /* counts xmit bytes/packets */
0036     u32         rx_counter; /* counts recv bytes/packets */
0037     u32         codecstate; /* used by codec to save data */
0038 #ifdef REORDER_DEBUG
0039     int         disorder_flag;
0040     struct sk_buff      *disorder_skb;
0041     u32         disorder_cnt;
0042 #endif
0043 };
0044 
0045 
0046 /* card structure */
0047 struct l1oip {
0048     struct list_head        list;
0049 
0050     /* card */
0051     int         registered; /* if registered with mISDN */
0052     char            name[MISDN_MAX_IDLEN];
0053     int         idx;        /* card index */
0054     int         pri;        /* 1=pri, 0=bri */
0055     int         d_idx;      /* current dchannel number */
0056     int         b_num;      /* number of bchannels */
0057     u32         id;     /* id of connection */
0058     int         ondemand;   /* if transmis. is on demand */
0059     int         bundle;     /* bundle channels in one frm */
0060     int         codec;      /* codec to use for transmis. */
0061     int         limit;      /* limit number of bchannels */
0062 
0063     /* timer */
0064     struct timer_list   keep_tl;
0065     struct timer_list   timeout_tl;
0066     int         timeout_on;
0067     struct work_struct  workq;
0068 
0069     /* socket */
0070     struct socket       *socket;    /* if set, socket is created */
0071     struct completion   socket_complete;/* completion of sock thread */
0072     struct task_struct  *socket_thread;
0073     spinlock_t      socket_lock;    /* access sock outside thread */
0074     u32         remoteip;   /* if all set, ip is assigned */
0075     u16         localport;  /* must always be set */
0076     u16         remoteport; /* must always be set */
0077     struct sockaddr_in  sin_local;  /* local socket name */
0078     struct sockaddr_in  sin_remote; /* remote socket name */
0079     struct msghdr       sendmsg;    /* ip message to send */
0080     struct kvec     sendiov;    /* iov for message */
0081 
0082     /* frame */
0083     struct l1oip_chan   chan[128];  /* channel instances */
0084 };
0085 
0086 extern int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state);
0087 extern int l1oip_4bit_to_law(u8 *data, int len, u8 *result);
0088 extern int l1oip_alaw_to_ulaw(u8 *data, int len, u8 *result);
0089 extern int l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result);
0090 extern void l1oip_4bit_free(void);
0091 extern int l1oip_4bit_alloc(int ulaw);