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