blob: 661c060ada49fcea3cd9957a063be9eac8fbf683 [file] [log] [blame]
Karsten Keil3712b422008-07-27 02:02:10 +02001/*
2 * see notice in l1oip.c
3 */
4
5/* debugging */
6#define DEBUG_L1OIP_INIT 0x00010000
7#define DEBUG_L1OIP_SOCKET 0x00020000
8#define DEBUG_L1OIP_MGR 0x00040000
9#define DEBUG_L1OIP_MSG 0x00080000
10
11/* enable to disorder received bchannels by sequence 2143658798... */
12/*
Joe Perches475be4d2012-02-19 19:52:38 -080013 #define REORDER_DEBUG
Karsten Keil3712b422008-07-27 02:02:10 +020014*/
15
16/* frames */
17#define L1OIP_MAX_LEN 2048 /* max packet size form l2 */
18#define L1OIP_MAX_PERFRAME 1400 /* max data size in one frame */
19
20
21/* timers */
22#define L1OIP_KEEPALIVE 15
23#define L1OIP_TIMEOUT 65
24
25
26/* socket */
27#define L1OIP_DEFAULTPORT 931
28
29
30/* channel structure */
31struct l1oip_chan {
Joe Perches475be4d2012-02-19 19:52:38 -080032 struct dchannel *dch;
33 struct bchannel *bch;
Karsten Keil3712b422008-07-27 02:02:10 +020034 u32 tx_counter; /* counts xmit bytes/packets */
35 u32 rx_counter; /* counts recv bytes/packets */
36 u32 codecstate; /* used by codec to save data */
37#ifdef REORDER_DEBUG
38 int disorder_flag;
39 struct sk_buff *disorder_skb;
40 u32 disorder_cnt;
41#endif
42};
43
44
45/* card structure */
46struct l1oip {
47 struct list_head list;
48
49 /* card */
50 int registered; /* if registered with mISDN */
51 char name[MISDN_MAX_IDLEN];
52 int idx; /* card index */
53 int pri; /* 1=pri, 0=bri */
54 int d_idx; /* current dchannel number */
55 int b_num; /* number of bchannels */
56 u32 id; /* id of connection */
57 int ondemand; /* if transmis. is on demand */
58 int bundle; /* bundle channels in one frm */
59 int codec; /* codec to use for transmis. */
60 int limit; /* limit number of bchannels */
61
62 /* timer */
Joe Perches475be4d2012-02-19 19:52:38 -080063 struct timer_list keep_tl;
64 struct timer_list timeout_tl;
Karsten Keil3712b422008-07-27 02:02:10 +020065 int timeout_on;
66 struct work_struct workq;
67
68 /* socket */
Joe Perches475be4d2012-02-19 19:52:38 -080069 struct socket *socket; /* if set, socket is created */
70 struct completion socket_complete;/* completion of sock thread */
Karsten Keil3712b422008-07-27 02:02:10 +020071 struct task_struct *socket_thread;
Joe Perches475be4d2012-02-19 19:52:38 -080072 spinlock_t socket_lock; /* access sock outside thread */
Karsten Keil3712b422008-07-27 02:02:10 +020073 u32 remoteip; /* if all set, ip is assigned */
Joe Perches475be4d2012-02-19 19:52:38 -080074 u16 localport; /* must always be set */
75 u16 remoteport; /* must always be set */
Karsten Keil3712b422008-07-27 02:02:10 +020076 struct sockaddr_in sin_local; /* local socket name */
77 struct sockaddr_in sin_remote; /* remote socket name */
78 struct msghdr sendmsg; /* ip message to send */
Arnaldo Carvalho de Melo8c90e112009-05-22 11:04:57 +000079 struct kvec sendiov; /* iov for message */
Karsten Keil3712b422008-07-27 02:02:10 +020080
81 /* frame */
82 struct l1oip_chan chan[128]; /* channel instances */
83};
84
85extern int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state);
86extern int l1oip_4bit_to_law(u8 *data, int len, u8 *result);
87extern int l1oip_alaw_to_ulaw(u8 *data, int len, u8 *result);
88extern int l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result);
89extern void l1oip_4bit_free(void);
90extern int l1oip_4bit_alloc(int ulaw);