layer2.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Layer 2 defines
  4. *
  5. * Copyright 2008 by Karsten Keil <[email protected]>
  6. */
  7. #include <linux/mISDNif.h>
  8. #include <linux/skbuff.h>
  9. #include "fsm.h"
  10. #define MAX_WINDOW 8
  11. struct manager {
  12. struct mISDNchannel ch;
  13. struct mISDNchannel bcast;
  14. u_long options;
  15. struct list_head layer2;
  16. rwlock_t lock;
  17. struct FsmInst deact;
  18. struct FsmTimer datimer;
  19. struct sk_buff_head sendq;
  20. struct mISDNchannel *up;
  21. u_int nextid;
  22. u_int lastid;
  23. };
  24. struct teimgr {
  25. int ri;
  26. int rcnt;
  27. struct FsmInst tei_m;
  28. struct FsmTimer timer;
  29. int tval, nval;
  30. struct layer2 *l2;
  31. struct manager *mgr;
  32. };
  33. struct laddr {
  34. u_char A;
  35. u_char B;
  36. };
  37. struct layer2 {
  38. struct list_head list;
  39. struct mISDNchannel ch;
  40. u_long flag;
  41. int id;
  42. struct mISDNchannel *up;
  43. signed char sapi;
  44. signed char tei;
  45. struct laddr addr;
  46. u_int maxlen;
  47. struct teimgr *tm;
  48. u_int vs, va, vr;
  49. int rc;
  50. u_int window;
  51. u_int sow;
  52. struct FsmInst l2m;
  53. struct FsmTimer t200, t203;
  54. int T200, N200, T203;
  55. u_int next_id;
  56. u_int down_id;
  57. struct sk_buff *windowar[MAX_WINDOW];
  58. struct sk_buff_head i_queue;
  59. struct sk_buff_head ui_queue;
  60. struct sk_buff_head down_queue;
  61. struct sk_buff_head tmp_queue;
  62. };
  63. enum {
  64. ST_L2_1,
  65. ST_L2_2,
  66. ST_L2_3,
  67. ST_L2_4,
  68. ST_L2_5,
  69. ST_L2_6,
  70. ST_L2_7,
  71. ST_L2_8,
  72. };
  73. #define L2_STATE_COUNT (ST_L2_8 + 1)
  74. extern struct layer2 *create_l2(struct mISDNchannel *, u_int,
  75. u_long, int, int);
  76. extern int tei_l2(struct layer2 *, u_int, u_long arg);
  77. /* from tei.c */
  78. extern int l2_tei(struct layer2 *, u_int, u_long arg);
  79. extern void TEIrelease(struct layer2 *);
  80. extern int TEIInit(u_int *);
  81. extern void TEIFree(void);
  82. #define MAX_L2HEADER_LEN 4
  83. #define RR 0x01
  84. #define RNR 0x05
  85. #define REJ 0x09
  86. #define SABME 0x6f
  87. #define SABM 0x2f
  88. #define DM 0x0f
  89. #define UI 0x03
  90. #define DISC 0x43
  91. #define UA 0x63
  92. #define FRMR 0x87
  93. #define XID 0xaf
  94. #define CMD 0
  95. #define RSP 1
  96. #define LC_FLUSH_WAIT 1
  97. #define FLG_LAPB 0
  98. #define FLG_LAPD 1
  99. #define FLG_ORIG 2
  100. #define FLG_MOD128 3
  101. #define FLG_PEND_REL 4
  102. #define FLG_L3_INIT 5
  103. #define FLG_T200_RUN 6
  104. #define FLG_ACK_PEND 7
  105. #define FLG_REJEXC 8
  106. #define FLG_OWN_BUSY 9
  107. #define FLG_PEER_BUSY 10
  108. #define FLG_DCHAN_BUSY 11
  109. #define FLG_L1_ACTIV 12
  110. #define FLG_ESTAB_PEND 13
  111. #define FLG_PTP 14
  112. #define FLG_FIXED_TEI 15
  113. #define FLG_L2BLOCK 16
  114. #define FLG_L1_NOTREADY 17
  115. #define FLG_LAPD_NET 18