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