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.

272 lines
8.7 KiB

  1. #include <windows.h>
  2. #include <msber.h>
  3. #include "mcspdu.h"
  4. #ifndef ASSERT
  5. #ifdef _DEBUG
  6. #define ASSERT(flag) if (!(flag)) DebugBreak()
  7. #else
  8. #define ASSERT(flag)
  9. #endif /* _DEBUG */
  10. #endif /* ! ASSERT */
  11. __inline int ASN1API ASN1BEREncSimpleOSTR(ASN1encoding_t enc, ASN1uint32_t len, ASN1octet_t *val)
  12. {
  13. return ASN1BEREncOctetString(enc, 0x4, len, val);
  14. }
  15. __inline int ASN1API ASN1BERDecSimpleOSTR(ASN1decoding_t dec, ASN1octetstring_t *val)
  16. {
  17. return ASN1BERDecOctetString(dec, 0x4, val);
  18. }
  19. __inline int ASN1API ASN1BEREncSimpleU32(ASN1encoding_t enc, ASN1uint32_t val)
  20. {
  21. return ASN1BEREncU32(enc, 0x02, val);
  22. }
  23. __inline int ASN1API ASN1BERDecSimpleU32Val(ASN1decoding_t dec, ASN1uint32_t *val)
  24. {
  25. return ASN1BERDecU32Val(dec, 0x02, val);
  26. }
  27. __inline int ASN1API ASN1BEREncEnum(ASN1encoding_t enc, ASN1uint32_t val)
  28. {
  29. return ASN1BEREncU32(enc, 0x0a, val);
  30. }
  31. __inline int ASN1API ASN1BERDecEnum(ASN1decoding_t dec, ASN1uint32_t *val)
  32. {
  33. return ASN1BERDecU32Val(dec, 0x0a, val);
  34. }
  35. // THE FOLLOWING IS GENERATED BY THE TELES COMPILER PLUS MANUAL CHANGES
  36. ASN1int32_t ASN1CALL ASN1Enc_PDUDomainParameters(ASN1encoding_t enc, PDUDomainParameters *val)
  37. {
  38. ASN1uint32_t nLenOff;
  39. if (!ASN1BEREncExplicitTag(enc, 0x10, &nLenOff))
  40. return 0;
  41. if (!ASN1BEREncSimpleU32(enc, (val)->max_channel_ids))
  42. return 0;
  43. if (!ASN1BEREncSimpleU32(enc, (val)->max_user_ids))
  44. return 0;
  45. if (!ASN1BEREncSimpleU32(enc, (val)->max_token_ids))
  46. return 0;
  47. if (!ASN1BEREncSimpleU32(enc, (val)->number_priorities))
  48. return 0;
  49. if (!ASN1BEREncSimpleU32(enc, (val)->min_throughput))
  50. return 0;
  51. if (!ASN1BEREncSimpleU32(enc, (val)->max_height))
  52. return 0;
  53. if (!ASN1BEREncSimpleU32(enc, (val)->max_mcspdu_size))
  54. return 0;
  55. if (!ASN1BEREncSimpleU32(enc, (val)->protocol_version))
  56. return 0;
  57. return ASN1BEREncEndOfContents(enc, nLenOff);
  58. }
  59. ASN1int32_t ASN1CALL ASN1Dec_PDUDomainParameters(ASN1decoding_t dec, PDUDomainParameters *val)
  60. {
  61. ASN1octet_t *pBufEnd;
  62. if (!ASN1BERDecExplicitTag(dec, 0x10, NULL, &pBufEnd))
  63. return 0;
  64. if (!ASN1BERDecSimpleU32Val(dec, &(val)->max_channel_ids))
  65. return 0;
  66. if (!ASN1BERDecSimpleU32Val(dec, &(val)->max_user_ids))
  67. return 0;
  68. if (!ASN1BERDecSimpleU32Val(dec, &(val)->max_token_ids))
  69. return 0;
  70. if (!ASN1BERDecSimpleU32Val(dec, &(val)->number_priorities))
  71. return 0;
  72. if (!ASN1BERDecSimpleU32Val(dec, &(val)->min_throughput))
  73. return 0;
  74. if (!ASN1BERDecSimpleU32Val(dec, &(val)->max_height))
  75. return 0;
  76. if (!ASN1BERDecSimpleU32Val(dec, &(val)->max_mcspdu_size))
  77. return 0;
  78. if (!ASN1BERDecSimpleU32Val(dec, &(val)->protocol_version))
  79. return 0;
  80. return ASN1BERDecEndOfContents(dec, NULL, pBufEnd);
  81. }
  82. ASN1int32_t ASN1CALL ASN1Enc_ConnectInitialPDU(ASN1encoding_t enc, ConnectInitialPDU *val)
  83. {
  84. ASN1uint32_t nLenOff;
  85. if (!ASN1BEREncExplicitTag(enc, 0x40000065, &nLenOff))
  86. return 0;
  87. if (!ASN1BEREncSimpleOSTR(enc, ((val)->calling_domain_selector).length, ((val)->calling_domain_selector).value))
  88. return 0;
  89. if (!ASN1BEREncSimpleOSTR(enc, ((val)->called_domain_selector).length, ((val)->called_domain_selector).value))
  90. return 0;
  91. if (!ASN1BEREncBool(enc, 0x01, (val)->upward_flag))
  92. return 0;
  93. if (!ASN1Enc_PDUDomainParameters(enc, &(val)->target_parameters))
  94. return 0;
  95. if (!ASN1Enc_PDUDomainParameters(enc, &(val)->minimum_parameters))
  96. return 0;
  97. if (!ASN1Enc_PDUDomainParameters(enc, &(val)->maximum_parameters))
  98. return 0;
  99. if (!ASN1BEREncSimpleOSTR(enc, ((val)->user_data).length, ((val)->user_data).value))
  100. return 0;
  101. return ASN1BEREncEndOfContents(enc, nLenOff);
  102. }
  103. ASN1int32_t ASN1CALL ASN1Dec_ConnectInitialPDU(ASN1decoding_t dec, ConnectInitialPDU *val)
  104. {
  105. ASN1octet_t *pBufEnd;
  106. if (!ASN1BERDecExplicitTag(dec, 0x40000065, NULL, &pBufEnd))
  107. return 0;
  108. if (!ASN1BERDecSimpleOSTR(dec, &(val)->calling_domain_selector))
  109. return 0;
  110. if (!ASN1BERDecSimpleOSTR(dec, &(val)->called_domain_selector))
  111. return 0;
  112. if (!ASN1BERDecBool(dec, 0x01, &(val)->upward_flag))
  113. return 0;
  114. if (!ASN1Dec_PDUDomainParameters(dec, &(val)->target_parameters))
  115. return 0;
  116. if (!ASN1Dec_PDUDomainParameters(dec, &(val)->minimum_parameters))
  117. return 0;
  118. if (!ASN1Dec_PDUDomainParameters(dec, &(val)->maximum_parameters))
  119. return 0;
  120. if (!ASN1BERDecSimpleOSTR(dec, &(val)->user_data))
  121. return 0;
  122. return ASN1BERDecEndOfContents(dec, NULL, pBufEnd);
  123. }
  124. ASN1int32_t ASN1CALL ASN1Enc_ConnectResponsePDU(ASN1encoding_t enc, ConnectResponsePDU *val)
  125. {
  126. ASN1uint32_t nLenOff;
  127. if (!ASN1BEREncExplicitTag(enc, 0x40000066, &nLenOff))
  128. return 0;
  129. if (!ASN1BEREncEnum(enc, (val)->result))
  130. return 0;
  131. if (!ASN1BEREncSimpleU32(enc, (val)->called_connect_id))
  132. return 0;
  133. if (!ASN1Enc_PDUDomainParameters(enc, &(val)->domain_parameters))
  134. return 0;
  135. if (!ASN1BEREncSimpleOSTR(enc, ((val)->user_data).length, ((val)->user_data).value))
  136. return 0;
  137. return ASN1BEREncEndOfContents(enc, nLenOff);
  138. }
  139. ASN1int32_t ASN1CALL ASN1Dec_ConnectResponsePDU(ASN1decoding_t dec, ConnectResponsePDU *val)
  140. {
  141. ASN1octet_t *pBufEnd;
  142. if (!ASN1BERDecExplicitTag(dec, 0x40000066, NULL, &pBufEnd))
  143. return 0;
  144. if (!ASN1BERDecEnum(dec, (ASN1uint32_t *) &(val)->result))
  145. return 0;
  146. if (!ASN1BERDecSimpleU32Val(dec, &(val)->called_connect_id))
  147. return 0;
  148. if (!ASN1Dec_PDUDomainParameters(dec, &(val)->domain_parameters))
  149. return 0;
  150. if (!ASN1BERDecSimpleOSTR(dec, &(val)->user_data))
  151. return 0;
  152. return ASN1BERDecEndOfContents(dec, NULL, pBufEnd);
  153. }
  154. ASN1int32_t ASN1CALL ASN1Enc_ConnectAdditionalPDU(ASN1encoding_t enc, ConnectAdditionalPDU *val)
  155. {
  156. ASN1uint32_t nLenOff;
  157. if (!ASN1BEREncExplicitTag(enc, 0x40000067, &nLenOff))
  158. return 0;
  159. if (!ASN1BEREncSimpleU32(enc, (val)->called_connect_id))
  160. return 0;
  161. if (!ASN1BEREncEnum(enc, (val)->data_priority))
  162. return 0;
  163. return ASN1BEREncEndOfContents(enc, nLenOff);
  164. }
  165. ASN1int32_t ASN1CALL ASN1Dec_ConnectAdditionalPDU(ASN1decoding_t dec, ConnectAdditionalPDU *val)
  166. {
  167. ASN1octet_t *pBufEnd;
  168. if (!ASN1BERDecExplicitTag(dec, 0x40000067, NULL, &pBufEnd))
  169. return 0;
  170. if (!ASN1BERDecSimpleU32Val(dec, &(val)->called_connect_id))
  171. return 0;
  172. if (!ASN1BERDecEnum(dec, (ASN1uint32_t *) &(val)->data_priority))
  173. return 0;
  174. return ASN1BERDecEndOfContents(dec, NULL, pBufEnd);
  175. }
  176. ASN1int32_t ASN1CALL ASN1Enc_ConnectResultPDU(ASN1encoding_t enc, ConnectResultPDU *val)
  177. {
  178. ASN1uint32_t nLenOff;
  179. if (!ASN1BEREncExplicitTag(enc, 0x40000068, &nLenOff))
  180. return 0;
  181. if (!ASN1BEREncEnum(enc, (val)->result))
  182. return 0;
  183. return ASN1BEREncEndOfContents(enc, nLenOff);
  184. }
  185. ASN1int32_t ASN1CALL ASN1Dec_ConnectResultPDU(ASN1decoding_t dec, ConnectResultPDU *val)
  186. {
  187. ASN1octet_t *pBufEnd;
  188. if (!ASN1BERDecExplicitTag(dec, 0x40000068, NULL, &pBufEnd))
  189. return 0;
  190. if (!ASN1BERDecEnum(dec, (ASN1uint32_t *) &(val)->result))
  191. return 0;
  192. return ASN1BERDecEndOfContents(dec, NULL, pBufEnd);
  193. }
  194. ASN1int32_t ASN1CALL ASN1Enc_ConnectMCSPDU(ASN1encoding_t enc, ConnectMCSPDU *val)
  195. {
  196. switch ((val)->choice) {
  197. case 1:
  198. if (!ASN1Enc_ConnectInitialPDU(enc, &(val)->u.connect_initial))
  199. return 0;
  200. break;
  201. case 2:
  202. if (!ASN1Enc_ConnectResponsePDU(enc, &(val)->u.connect_response))
  203. return 0;
  204. break;
  205. case 3:
  206. if (!ASN1Enc_ConnectAdditionalPDU(enc, &(val)->u.connect_additional))
  207. return 0;
  208. break;
  209. case 4:
  210. if (!ASN1Enc_ConnectResultPDU(enc, &(val)->u.connect_result))
  211. return 0;
  212. break;
  213. default:
  214. ASSERT(0);
  215. return 0;
  216. }
  217. return 1;
  218. }
  219. ASN1int32_t ASN1CALL ASN1Dec_ConnectMCSPDU(ASN1decoding_t dec, ConnectMCSPDU *val)
  220. {
  221. ASN1uint32_t t;
  222. if (!ASN1BERDecPeekTag(dec, &t))
  223. return 0;
  224. switch (t) {
  225. case 0x40000065:
  226. (val)->choice = 1;
  227. if (!ASN1Dec_ConnectInitialPDU(dec, &(val)->u.connect_initial))
  228. return 0;
  229. break;
  230. case 0x40000066:
  231. (val)->choice = 2;
  232. if (!ASN1Dec_ConnectResponsePDU(dec, &(val)->u.connect_response))
  233. return 0;
  234. break;
  235. case 0x40000067:
  236. (val)->choice = 3;
  237. if (!ASN1Dec_ConnectAdditionalPDU(dec, &(val)->u.connect_additional))
  238. return 0;
  239. break;
  240. case 0x40000068:
  241. (val)->choice = 4;
  242. if (!ASN1Dec_ConnectResultPDU(dec, &(val)->u.connect_result))
  243. return 0;
  244. break;
  245. default:
  246. (val)->choice = -1;
  247. ASSERT(0);
  248. return 0;
  249. }
  250. return 1;
  251. }