Source code of Windows XP (NT5)
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.

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