layer2.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Layer 2 defines
  3. *
  4. * Copyright 2008 by Karsten Keil <kkeil@novell.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <linux/mISDNif.h>
  17. #include <linux/skbuff.h>
  18. #include "fsm.h"
  19. #define MAX_WINDOW 8
  20. struct manager {
  21. struct mISDNchannel ch;
  22. struct mISDNchannel bcast;
  23. u_long options;
  24. struct list_head layer2;
  25. rwlock_t lock;
  26. struct FsmInst deact;
  27. struct FsmTimer datimer;
  28. struct sk_buff_head sendq;
  29. struct mISDNchannel *up;
  30. u_int nextid;
  31. u_int lastid;
  32. };
  33. struct teimgr {
  34. int ri;
  35. int rcnt;
  36. struct FsmInst tei_m;
  37. struct FsmTimer timer;
  38. int tval, nval;
  39. struct layer2 *l2;
  40. struct manager *mgr;
  41. };
  42. struct laddr {
  43. u_char A;
  44. u_char B;
  45. };
  46. struct layer2 {
  47. struct list_head list;
  48. struct mISDNchannel ch;
  49. u_long flag;
  50. int id;
  51. struct mISDNchannel *up;
  52. signed char sapi;
  53. signed char tei;
  54. struct laddr addr;
  55. u_int maxlen;
  56. struct teimgr *tm;
  57. u_int vs, va, vr;
  58. int rc;
  59. u_int window;
  60. u_int sow;
  61. struct FsmInst l2m;
  62. struct FsmTimer t200, t203;
  63. int T200, N200, T203;
  64. u_int next_id;
  65. u_int down_id;
  66. struct sk_buff *windowar[MAX_WINDOW];
  67. struct sk_buff_head i_queue;
  68. struct sk_buff_head ui_queue;
  69. struct sk_buff_head down_queue;
  70. struct sk_buff_head tmp_queue;
  71. };
  72. enum {
  73. ST_L2_1,
  74. ST_L2_2,
  75. ST_L2_3,
  76. ST_L2_4,
  77. ST_L2_5,
  78. ST_L2_6,
  79. ST_L2_7,
  80. ST_L2_8,
  81. };
  82. #define L2_STATE_COUNT (ST_L2_8 + 1)
  83. extern struct layer2 *create_l2(struct mISDNchannel *, u_int,
  84. u_long, int, int);
  85. extern int tei_l2(struct layer2 *, u_int, u_long arg);
  86. /* from tei.c */
  87. extern int l2_tei(struct layer2 *, u_int, u_long arg);
  88. extern void TEIrelease(struct layer2 *);
  89. extern int TEIInit(u_int *);
  90. extern void TEIFree(void);
  91. #define MAX_L2HEADER_LEN 4
  92. #define RR 0x01
  93. #define RNR 0x05
  94. #define REJ 0x09
  95. #define SABME 0x6f
  96. #define SABM 0x2f
  97. #define DM 0x0f
  98. #define UI 0x03
  99. #define DISC 0x43
  100. #define UA 0x63
  101. #define FRMR 0x87
  102. #define XID 0xaf
  103. #define CMD 0
  104. #define RSP 1
  105. #define LC_FLUSH_WAIT 1
  106. #define FLG_LAPB 0
  107. #define FLG_LAPD 1
  108. #define FLG_ORIG 2
  109. #define FLG_MOD128 3
  110. #define FLG_PEND_REL 4
  111. #define FLG_L3_INIT 5
  112. #define FLG_T200_RUN 6
  113. #define FLG_ACK_PEND 7
  114. #define FLG_REJEXC 8
  115. #define FLG_OWN_BUSY 9
  116. #define FLG_PEER_BUSY 10
  117. #define FLG_DCHAN_BUSY 11
  118. #define FLG_L1_ACTIV 12
  119. #define FLG_ESTAB_PEND 13
  120. #define FLG_PTP 14
  121. #define FLG_FIXED_TEI 15
  122. #define FLG_L2BLOCK 16
  123. #define FLG_L1_NOTREADY 17
  124. #define FLG_LAPD_NET 18