Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
4.6 KiB

  1. // returns pointers pOutStr
  2. TCHAR *DecodeIRDA(int *pFrameType,// return frame type (-1 = bad frame)
  3. UCHAR *pFrameBuf, // pointer to buffer containing IRLAP frame
  4. UINT FrameLen, // length of buffer
  5. TCHAR *OutputBuffer, // string where decoded packet is placed
  6. ULONG OutputBufferSizeInCharacters,
  7. UINT DecodeLayer,// 2-LAP only, 3-LAP/LMP, 4-LAP/LMP/TTP
  8. int fNoConnAddr,// TRUE->Don't show conn address in str
  9. int DispMode // DISP_ASCII/HEX/BOTH
  10. );
  11. #define IAS_SEL 0
  12. #define DISP_ASCII 1
  13. #define DISP_HEX 2
  14. #define DISP_BOTH 3
  15. extern UINT BaudBitField;
  16. #define IRLAP_BOF 0xC0
  17. #define IRLAP_EOF 0xC1
  18. #define IRLAP_ESC 0x7D
  19. #define IRLAP_COMP_BIT 0x20
  20. #define IRLAP_BROADCAST 0xfe
  21. #define _IRLAP_CMD 0x01
  22. #define _IRLAP_RSP 0x00
  23. #define IRLAP_I_FRM 0x00
  24. #define IRLAP_S_FRM 0x01
  25. #define IRLAP_U_FRM 0x03
  26. /*
  27. ** Unnumbered Frame types with P/F bit set to 0
  28. */
  29. #define IRLAP_UI 0x03
  30. #define IRLAP_XID_CMD 0x2f
  31. #define IRLAP_TEST 0xe3
  32. #define IRLAP_SNRM 0x83
  33. #define IRLAP_DISC 0x43
  34. #define IRLAP_UA 0x63
  35. #define IRLAP_FRMR 0x87
  36. #define IRLAP_DM 0x0f
  37. #define IRLAP_XID_RSP 0xaf
  38. /*
  39. ** Supervisory Frames
  40. */
  41. #define IRLAP_RR 0x01
  42. #define IRLAP_RNR 0x05
  43. #define IRLAP_REJ 0x09
  44. #define IRLAP_SREJ 0x0d
  45. #define IRLAP_GET_ADDR(addr) (addr >> 1)
  46. #define IRLAP_GET_CRBIT(addr) (addr & 1)
  47. #define IRLAP_GET_PFBIT(cntl) ((cntl >>4) & 1)
  48. #define IRLAP_GET_UCNTL(cntl) (cntl & 0xEF)
  49. #define IRLAP_GET_SCNTL(cntl) (cntl & 0x0F)
  50. #define IRLAP_FRAME_TYPE(cntl) (cntl & 0x01 ? (cntl & 3) : 0)
  51. #define IRLAP_GET_NR(cntl) ((cntl & 0xE0) >> 5)
  52. #define IRLAP_GET_NS(cntl) ((cntl & 0xE) >> 1)
  53. /*
  54. ** XID stuff
  55. */
  56. #define XID_DISCV_FORMAT_ID 0x01
  57. #define XID_NEGPARMS_FORMAT_ID 0x02
  58. typedef struct
  59. {
  60. UCHAR SrcAddr[4];
  61. UCHAR DestAddr[4];
  62. UCHAR NoOfSlots:2;
  63. UCHAR GenNewAddr:1;
  64. UCHAR Reserved:5;
  65. UCHAR SlotNo;
  66. UCHAR Version;
  67. } XID_DISCV_FORMAT;
  68. /*
  69. ** SNRM
  70. */
  71. typedef struct
  72. {
  73. UCHAR SrcAddr[4];
  74. UCHAR DestAddr[4];
  75. UCHAR ConnAddr;
  76. UCHAR FirstPI;
  77. } SNRM_FORMAT;
  78. /*
  79. ** UA
  80. */
  81. typedef struct
  82. {
  83. UCHAR SrcAddr[4];
  84. UCHAR DestAddr[4];
  85. UCHAR FirstPI;
  86. } UA_FORMAT;
  87. /*
  88. ** LM-PDU stuff
  89. */
  90. typedef struct
  91. {
  92. UCHAR DLSAP_SEL:7;
  93. UCHAR CntlBit:1;
  94. UCHAR SLSAP_SEL:7;
  95. UCHAR RsvrdBi1:1;
  96. } LM_HEADER;
  97. /* LM-PDU frame types */
  98. #define LM_PDU_CNTL_FRAME 1
  99. #define LM_PDU_DATA_FRAME 0
  100. typedef struct
  101. {
  102. UCHAR OpCode:7;
  103. UCHAR ABit:1;
  104. } LM_CNTL_FORMAT;
  105. /* Opcodes */
  106. #define LM_PDU_CONNECT 1
  107. #define LM_PDU_DISCONNECT 2
  108. #define LM_PDU_ACCESSMODE 3
  109. #define LM_PDU_REQUEST 0
  110. #define LM_PDU_CONFIRM 1
  111. #define LM_PDU_SUCCESS 0
  112. #define LM_PDU_FAILURE 1
  113. #define LM_PDU_UNSUPPORTED 0xFF
  114. #define LM_PDU_MULTIPLEXED 0
  115. #define LM_PDU_EXCLUSIVE 1
  116. /* Max disconnect reason code, see _LM_PDU_DscReason[] in decdirda.c */
  117. #define LM_PDU_MAX_DSC_REASON 0x8
  118. /*
  119. ** Negotiation Parameter Identifiers
  120. */
  121. #define NEG_PI_BAUD 0x01
  122. #define NEG_PI_MAX_TAT 0x82
  123. #define NEG_PI_DATA_SZ 0x83
  124. #define NEG_PI_WIN_SZ 0x84
  125. #define NEG_PI_BOFS 0x85
  126. #define NEG_PI_MIN_TAT 0x86
  127. #define NEG_PI_DISC_THRESH 0x08
  128. // Tiny TP!
  129. #define TTP_PFLAG_NO_PARMS 0
  130. #define TTP_PFLAG_PARMS 1
  131. #define TTP_MBIT_NOT_FINAL 1
  132. #define TTP_MBIT_FINAL 0
  133. typedef struct
  134. {
  135. UCHAR InitialCredit : 7;
  136. UCHAR ParmFlag : 1;
  137. } TTP_CONN_HEADER;
  138. typedef struct
  139. {
  140. UCHAR AdditionalCredit : 7;
  141. UCHAR MoreBit : 1;
  142. } TTP_DATA_HEADER;
  143. #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
  144. #define net_short(_x) _byteswap_ushort((USHORT)(_x))
  145. #define net_long(_x) _byteswap_ulong(_x)
  146. #else
  147. #define net_short(x) ((((x)&0xff) << 8) | (((x)&0xff00) >> 8))
  148. #define net_long(x) (((((DWORD UNALIGNED)(x))&0xffL)<<24) | \
  149. ((((DWORD UNALIGNED)(x))&0xff00L)<<8) | \
  150. ((((DWORD UNALIGNED)(x))&0xff0000L)>>8) | \
  151. ((((DWORD UNALIGNED)(x))&0xff000000L)>>24))
  152. #endif
  153. typedef struct
  154. {
  155. UCHAR OpCode : 6;
  156. UCHAR Ack : 1;
  157. UCHAR Last : 1;
  158. } IAS_CNTL_HEADER;
  159. #define LM_GETVALUEBYCLASS 4