l1oip.h 2.5 KB

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