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.

242 lines
8.1 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1995 Microsoft Corporation
  4. *
  5. * File: irlmp.h
  6. *
  7. * Description: IRLMP Protocol and control block definitions
  8. *
  9. * Author: mbert
  10. *
  11. * Date: 6/12/95
  12. *
  13. */
  14. #define IRLMP_MAX_TX_MSG_LIST_LEN 8
  15. #define LSAP_RESPONSE_TIMEOUT 7000
  16. // This is the time that:
  17. // (1) the IRLMP client has to respond to an IRLMP_CONNECT_IND, or
  18. // (2) the peer LSAP has to respond to an IRLMP LM-Connect request PDU, or
  19. // (3) the peer LSAP has to respond to an LM-Access request PDU
  20. // On expiration:
  21. // (1) send peer LSAP an IRLMP LM-Disconnect indication PDU. Or
  22. // (2) notify IRLMP client with a IRLMP_DISCONNECT_IND
  23. // (3) notify IRLMP client with a IRLMP_ACCESSMODE_CONF
  24. #define IRLMP_DISCONNECT_DELAY_TIMEOUT 2000
  25. // When the final LSAP-LSAP connection is terminated, wait before
  26. // disconnecting link in case another LSAP connection is made.
  27. // This is primarily used when the remote connects to the IAS
  28. // and then disconnects followed by a new LSAP connection.
  29. #define IRLMP_NOT_SEEN_THRESHOLD 3 // The number of times that a device
  30. // is not seen in a discovery before
  31. // it is removed from the aged list
  32. // maintained by IRLMP
  33. typedef struct IAS_Attribute
  34. {
  35. struct IAS_Attribute *pNext;
  36. CHAR *pAttribName;
  37. void *pAttribVal;
  38. int AttribValLen;
  39. int CharSet;
  40. UCHAR AttribValType;
  41. } IAS_ATTRIBUTE, *PIAS_ATTRIBUTE;
  42. typedef struct IAS_Object
  43. {
  44. LIST_ENTRY Linkage;
  45. CHAR *pClassName;
  46. IAS_ATTRIBUTE *pAttributes;
  47. UINT ObjectId;
  48. } IAS_OBJECT, *PIAS_OBJECT;
  49. typedef struct
  50. {
  51. LIST_ENTRY Linkage;
  52. int Lsap;
  53. UINT Flags; // see IRLMP_LSAP_CB.Flags
  54. } IRLMP_REGISTERED_LSAP, *PIRLMP_REGISTERED_LSAP;
  55. // IRLMP Control Block
  56. typedef enum
  57. {
  58. LSAP_CREATED,
  59. LSAP_DISCONNECTED,
  60. LSAP_IRLAP_CONN_PEND, // waiting for IRLAP_CONNECT_CONF from IRLAP
  61. LSAP_LMCONN_CONF_PEND, // waiting for IRLMP Conn conf PDU from peer
  62. LSAP_CONN_RESP_PEND, // waiting for IRLMP_CONNECT_RESP from client
  63. LSAP_CONN_REQ_PEND, // Got IRLMP_CONNECT_REQ when link is either
  64. // in discovery or disconnecting
  65. LSAP_EXCLUSIVEMODE_PEND, // Pending response from peer
  66. LSAP_MULTIPLEXEDMODE_PEND, // Pending response from peer
  67. LSAP_READY, // CONNECTED STATES SHOULD ALWAYS FOLLOW THIS
  68. LSAP_NO_TX_CREDIT // IRLMP_DATA_REQ with no transmit credit
  69. } IRLMP_LSAP_STATE;
  70. typedef enum
  71. {
  72. LINK_DOWN,
  73. LINK_DISCONNECTED,
  74. LINK_DISCONNECTING, // Sent IRLAP_DISCONNECT_REQ, waiting for IND
  75. LINK_IN_DISCOVERY, // Sent IRLAP_DISCOVERY_REQ, waiting for CONF
  76. LINK_CONNECTING, // Sent IRLAP_CONNECT_REQ, waiting for CONF
  77. LINK_READY // Received CONF
  78. } IRLMP_LINK_STATE;
  79. #define LSAPSIG 0xEEEEAAAA
  80. #define VALIDLSAP(l) ASSERT(l->Sig == LSAPSIG)
  81. typedef struct
  82. {
  83. LIST_ENTRY Linkage;
  84. struct IrlmpLinkCb *pIrlmpCb;
  85. IRLMP_LSAP_STATE State;
  86. #ifdef DBG
  87. int Sig;
  88. #endif
  89. int UserDataLen;
  90. int LocalLsapSel;
  91. int RemoteLsapSel;
  92. int AvailableCredit; // additional credit that
  93. // can be advanced to remote
  94. int LocalTxCredit; // credit for transmitting
  95. int RemoteTxCredit; // what remote has for txing
  96. LIST_ENTRY TxMsgList; // messages from client waiting
  97. // for ack
  98. LIST_ENTRY SegTxMsgList; // above messages that have been
  99. // segmented, but not sent because
  100. // there is no credit available
  101. int TxMaxSDUSize;
  102. int RxMaxSDUSize;
  103. IRLMP_DISC_REASON DiscReason;
  104. IRDA_TIMER ResponseTimer;
  105. PVOID TdiContext;
  106. REF_CNT RefCnt;
  107. UINT Flags;
  108. #define LCBF_USE_TTP 1
  109. #define LCBF_TDI_OPEN 2
  110. UCHAR UserData[IRLMP_MAX_USER_DATA_LEN];
  111. } IRLMP_LSAP_CB, *PIRLMP_LSAP_CB;
  112. typedef struct IrlmpLinkCb
  113. {
  114. LIST_ENTRY LsapCbList;
  115. PIRDA_LINK_CB pIrdaLinkCb;
  116. IRLMP_LINK_STATE LinkState;
  117. UCHAR ConnDevAddr[IRDA_DEV_ADDR_LEN];
  118. IRDA_QOS_PARMS RequestedQOS;
  119. IRDA_QOS_PARMS NegotiatedQOS;
  120. int MaxSlot;
  121. int MaxPDUSize;
  122. int WindowSize;
  123. IRDA_TIMER DiscDelayTimer;
  124. IRLMP_LSAP_CB *pExclLsapCb; // pointer to LSAP_CB that has
  125. // link in exclusive mode
  126. IAS_QUERY *pIasQuery;
  127. UINT AttribLen;
  128. UINT AttribLenWritten;
  129. int QueryListLen;
  130. UCHAR IasQueryDevAddr[IRDA_DEV_ADDR_LEN];
  131. int IasRetryCnt;
  132. PVOID hAttribDeviceName;
  133. PVOID hAttribIrlmpSupport;
  134. LIST_ENTRY DeviceList;
  135. UINT DiscoveryFlags;
  136. #define DF_NORMAL_DSCV 1
  137. #define DF_NO_SENSE_DSCV 2
  138. BOOLEAN ConnDevAddrSet;
  139. BOOLEAN ConnReqScheduled;
  140. BOOLEAN FirstIasRespReceived;
  141. BOOLEAN AcceptConnection;
  142. } IRLMP_LINK_CB, *PIRLMP_LINK_CB;
  143. // IRLMP-PDU types (CntlBit)
  144. #define IRLMP_CNTL_PDU 1
  145. #define IRLMP_DATA_PDU 0
  146. typedef struct
  147. {
  148. UCHAR DstLsapSel:7;
  149. UCHAR CntlBit:1;
  150. UCHAR SrcLsapSel:7;
  151. UCHAR RsvrdBit:1;
  152. } IRLMP_HEADER;
  153. // Control IRLMP-PDU types (OpCode)
  154. #define IRLMP_CONNECT_PDU 1
  155. #define IRLMP_DISCONNECT_PDU 2
  156. #define IRLMP_ACCESSMODE_PDU 3
  157. // A Bit
  158. #define IRLMP_ABIT_REQUEST 0
  159. #define IRLMP_ABIT_CONFIRM 1
  160. // Status
  161. #define IRLMP_RSVD_PARM 0x00
  162. #define IRLMP_STATUS_SUCCESS 0x00
  163. #define IRLMP_STATUS_FAILURE 0x01
  164. #define IRLMP_STATUS_UNSUPPORTED 0xFF
  165. typedef struct
  166. {
  167. UCHAR OpCode:7;
  168. UCHAR ABit:1;
  169. UCHAR Parm1;
  170. UCHAR Parm2;
  171. } IRLMP_CNTL_FORMAT;
  172. // Tiny TP!
  173. #define TTP_PFLAG_NO_PARMS 0
  174. #define TTP_PFLAG_PARMS 1
  175. #define TTP_MBIT_NOT_FINAL 1
  176. #define TTP_MBIT_FINAL 0
  177. typedef struct
  178. {
  179. UCHAR InitialCredit:7;
  180. UCHAR ParmFlag:1;
  181. } TTP_CONN_HEADER;
  182. typedef struct
  183. {
  184. UCHAR AdditionalCredit:7;
  185. UCHAR MoreBit:1;
  186. } TTP_DATA_HEADER;
  187. #define TTP_MAX_SDU_SIZE_PI 1
  188. #define TTP_MAX_SDU_SIZE_PL 4 // I'm hardcoding this. Seems unecessary
  189. // to make it variable. I will handle
  190. // receiving varialbe sized however
  191. typedef struct
  192. {
  193. UCHAR PLen;
  194. UCHAR PI;
  195. UCHAR PL;
  196. UCHAR PV[TTP_MAX_SDU_SIZE_PL];
  197. } TTP_CONN_PARM;
  198. // IAS
  199. #define IAS_SUCCESS 0
  200. #define IAS_NO_SUCH_OBJECT 1
  201. #define IAS_NO_SUCH_ATTRIB 2
  202. #define IAS_MSGBUF_LEN 50
  203. #define IAS_LSAP_SEL 0
  204. #define IAS_LOCAL_LSAP_SEL 3
  205. #define IAS_IRLMP_VERSION 1
  206. #define IAS_SUPPORT_BIT_FIELD 0 // No other IAS support
  207. #define IAS_LMMUX_SUPPORT_BIT_FIELD 1 // Exclusive mode only
  208. typedef struct
  209. {
  210. UCHAR OpCode:6;
  211. UCHAR Ack:1;
  212. UCHAR Last:1;
  213. } IAS_CONTROL_FIELD;