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.

1950 lines
63 KiB

  1. #include <windows.h>
  2. #include "ldap.h"
  3. ASN1module_t LDAP_Module = NULL;
  4. static int ASN1CALL ASN1Enc_SearchResponse_entry_attributes_Seq_values(ASN1encoding_t enc, ASN1uint32_t tag, PSearchResponse_entry_attributes_Seq_values *val);
  5. static int ASN1CALL ASN1Enc_ModifyRequest_modifications_Seq_modification_values(ASN1encoding_t enc, ASN1uint32_t tag, PModifyRequest_modifications_Seq_modification_values *val);
  6. static int ASN1CALL ASN1Enc_AddRequest_attrs_Seq_values(ASN1encoding_t enc, ASN1uint32_t tag, PAddRequest_attrs_Seq_values *val);
  7. static int ASN1CALL ASN1Enc_ModifyRequest_modifications_Seq_modification(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRequest_modifications_Seq_modification *val);
  8. static int ASN1CALL ASN1Enc_SearchResponse_entry_attributes_Seq(ASN1encoding_t enc, ASN1uint32_t tag, SearchResponse_entry_attributes_Seq *val);
  9. static int ASN1CALL ASN1Enc_SearchResponse_entry_attributes(ASN1encoding_t enc, ASN1uint32_t tag, PSearchResponse_entry_attributes *val);
  10. static int ASN1CALL ASN1Enc_ModifyRequest_modifications_Seq(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRequest_modifications_Seq *val);
  11. static int ASN1CALL ASN1Enc_AddRequest_attrs_Seq(ASN1encoding_t enc, ASN1uint32_t tag, AddRequest_attrs_Seq *val);
  12. static int ASN1CALL ASN1Enc_SubstringFilter_attributes_Seq(ASN1encoding_t enc, ASN1uint32_t tag, SubstringFilter_attributes_Seq *val);
  13. static int ASN1CALL ASN1Enc_SubstringFilter_attributes(ASN1encoding_t enc, ASN1uint32_t tag, PSubstringFilter_attributes *val);
  14. static int ASN1CALL ASN1Enc_AddRequest_attrs(ASN1encoding_t enc, ASN1uint32_t tag, PAddRequest_attrs *val);
  15. static int ASN1CALL ASN1Enc_ModifyRequest_modifications(ASN1encoding_t enc, ASN1uint32_t tag, PModifyRequest_modifications *val);
  16. static int ASN1CALL ASN1Enc_SearchResponse_entry(ASN1encoding_t enc, ASN1uint32_t tag, SearchResponse_entry *val);
  17. static int ASN1CALL ASN1Enc_SearchRequest_attributes(ASN1encoding_t enc, ASN1uint32_t tag, PSearchRequest_attributes *val);
  18. static int ASN1CALL ASN1Enc_SaslCredentials(ASN1encoding_t enc, ASN1uint32_t tag, SaslCredentials *val);
  19. static int ASN1CALL ASN1Enc_ModifyRequest(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRequest *val);
  20. static int ASN1CALL ASN1Enc_AddRequest(ASN1encoding_t enc, ASN1uint32_t tag, AddRequest *val);
  21. static int ASN1CALL ASN1Enc_ModifyRDNRequest(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRDNRequest *val);
  22. static int ASN1CALL ASN1Enc_LDAPResult(ASN1encoding_t enc, ASN1uint32_t tag, LDAPResult *val);
  23. static int ASN1CALL ASN1Enc_AttributeValueAssertion(ASN1encoding_t enc, ASN1uint32_t tag, AttributeValueAssertion *val);
  24. static int ASN1CALL ASN1Enc_SubstringFilter(ASN1encoding_t enc, ASN1uint32_t tag, SubstringFilter *val);
  25. static int ASN1CALL ASN1Enc_AuthenticationChoice(ASN1encoding_t enc, ASN1uint32_t tag, AuthenticationChoice *val);
  26. static int ASN1CALL ASN1Enc_BindResponse(ASN1encoding_t enc, ASN1uint32_t tag, BindResponse *val);
  27. static int ASN1CALL ASN1Enc_SearchResponse(ASN1encoding_t enc, ASN1uint32_t tag, SearchResponse *val);
  28. static int ASN1CALL ASN1Enc_ModifyResponse(ASN1encoding_t enc, ASN1uint32_t tag, ModifyResponse *val);
  29. static int ASN1CALL ASN1Enc_AddResponse(ASN1encoding_t enc, ASN1uint32_t tag, AddResponse *val);
  30. static int ASN1CALL ASN1Enc_DelResponse(ASN1encoding_t enc, ASN1uint32_t tag, DelResponse *val);
  31. static int ASN1CALL ASN1Enc_ModifyRDNResponse(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRDNResponse *val);
  32. static int ASN1CALL ASN1Enc_CompareRequest(ASN1encoding_t enc, ASN1uint32_t tag, CompareRequest *val);
  33. static int ASN1CALL ASN1Enc_CompareResponse(ASN1encoding_t enc, ASN1uint32_t tag, CompareResponse *val);
  34. static int ASN1CALL ASN1Enc_Filter(ASN1encoding_t enc, ASN1uint32_t tag, Filter *val);
  35. static int ASN1CALL ASN1Enc_Filter_or(ASN1encoding_t enc, ASN1uint32_t tag, PFilter_or *val);
  36. static int ASN1CALL ASN1Enc_Filter_and(ASN1encoding_t enc, ASN1uint32_t tag, PFilter_and *val);
  37. static int ASN1CALL ASN1Enc_BindRequest(ASN1encoding_t enc, ASN1uint32_t tag, BindRequest *val);
  38. static int ASN1CALL ASN1Enc_SearchRequest(ASN1encoding_t enc, ASN1uint32_t tag, SearchRequest *val);
  39. static int ASN1CALL ASN1Enc_LDAPMessage_protocolOp(ASN1encoding_t enc, ASN1uint32_t tag, LDAPMessage_protocolOp *val);
  40. static int ASN1CALL ASN1Enc_LDAPMessage(ASN1encoding_t enc, ASN1uint32_t tag, LDAPMessage *val);
  41. static int ASN1CALL ASN1Dec_SearchResponse_entry_attributes_Seq_values(ASN1decoding_t dec, ASN1uint32_t tag, PSearchResponse_entry_attributes_Seq_values *val);
  42. static int ASN1CALL ASN1Dec_ModifyRequest_modifications_Seq_modification_values(ASN1decoding_t dec, ASN1uint32_t tag, PModifyRequest_modifications_Seq_modification_values *val);
  43. static int ASN1CALL ASN1Dec_AddRequest_attrs_Seq_values(ASN1decoding_t dec, ASN1uint32_t tag, PAddRequest_attrs_Seq_values *val);
  44. static int ASN1CALL ASN1Dec_ModifyRequest_modifications_Seq_modification(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRequest_modifications_Seq_modification *val);
  45. static int ASN1CALL ASN1Dec_SearchResponse_entry_attributes_Seq(ASN1decoding_t dec, ASN1uint32_t tag, SearchResponse_entry_attributes_Seq *val);
  46. static int ASN1CALL ASN1Dec_SearchResponse_entry_attributes(ASN1decoding_t dec, ASN1uint32_t tag, PSearchResponse_entry_attributes *val);
  47. static int ASN1CALL ASN1Dec_ModifyRequest_modifications_Seq(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRequest_modifications_Seq *val);
  48. static int ASN1CALL ASN1Dec_AddRequest_attrs_Seq(ASN1decoding_t dec, ASN1uint32_t tag, AddRequest_attrs_Seq *val);
  49. static int ASN1CALL ASN1Dec_SubstringFilter_attributes_Seq(ASN1decoding_t dec, ASN1uint32_t tag, SubstringFilter_attributes_Seq *val);
  50. static int ASN1CALL ASN1Dec_SubstringFilter_attributes(ASN1decoding_t dec, ASN1uint32_t tag, PSubstringFilter_attributes *val);
  51. static int ASN1CALL ASN1Dec_AddRequest_attrs(ASN1decoding_t dec, ASN1uint32_t tag, PAddRequest_attrs *val);
  52. static int ASN1CALL ASN1Dec_ModifyRequest_modifications(ASN1decoding_t dec, ASN1uint32_t tag, PModifyRequest_modifications *val);
  53. static int ASN1CALL ASN1Dec_SearchResponse_entry(ASN1decoding_t dec, ASN1uint32_t tag, SearchResponse_entry *val);
  54. static int ASN1CALL ASN1Dec_SearchRequest_attributes(ASN1decoding_t dec, ASN1uint32_t tag, PSearchRequest_attributes *val);
  55. static int ASN1CALL ASN1Dec_SaslCredentials(ASN1decoding_t dec, ASN1uint32_t tag, SaslCredentials *val);
  56. static int ASN1CALL ASN1Dec_ModifyRequest(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRequest *val);
  57. static int ASN1CALL ASN1Dec_AddRequest(ASN1decoding_t dec, ASN1uint32_t tag, AddRequest *val);
  58. static int ASN1CALL ASN1Dec_ModifyRDNRequest(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRDNRequest *val);
  59. static int ASN1CALL ASN1Dec_LDAPResult(ASN1decoding_t dec, ASN1uint32_t tag, LDAPResult *val);
  60. static int ASN1CALL ASN1Dec_AttributeValueAssertion(ASN1decoding_t dec, ASN1uint32_t tag, AttributeValueAssertion *val);
  61. static int ASN1CALL ASN1Dec_SubstringFilter(ASN1decoding_t dec, ASN1uint32_t tag, SubstringFilter *val);
  62. static int ASN1CALL ASN1Dec_AuthenticationChoice(ASN1decoding_t dec, ASN1uint32_t tag, AuthenticationChoice *val);
  63. static int ASN1CALL ASN1Dec_BindResponse(ASN1decoding_t dec, ASN1uint32_t tag, BindResponse *val);
  64. static int ASN1CALL ASN1Dec_SearchResponse(ASN1decoding_t dec, ASN1uint32_t tag, SearchResponse *val);
  65. static int ASN1CALL ASN1Dec_ModifyResponse(ASN1decoding_t dec, ASN1uint32_t tag, ModifyResponse *val);
  66. static int ASN1CALL ASN1Dec_AddResponse(ASN1decoding_t dec, ASN1uint32_t tag, AddResponse *val);
  67. static int ASN1CALL ASN1Dec_DelResponse(ASN1decoding_t dec, ASN1uint32_t tag, DelResponse *val);
  68. static int ASN1CALL ASN1Dec_ModifyRDNResponse(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRDNResponse *val);
  69. static int ASN1CALL ASN1Dec_CompareRequest(ASN1decoding_t dec, ASN1uint32_t tag, CompareRequest *val);
  70. static int ASN1CALL ASN1Dec_CompareResponse(ASN1decoding_t dec, ASN1uint32_t tag, CompareResponse *val);
  71. static int ASN1CALL ASN1Dec_Filter(ASN1decoding_t dec, ASN1uint32_t tag, Filter *val);
  72. static int ASN1CALL ASN1Dec_Filter_or(ASN1decoding_t dec, ASN1uint32_t tag, PFilter_or *val);
  73. static int ASN1CALL ASN1Dec_Filter_and(ASN1decoding_t dec, ASN1uint32_t tag, PFilter_and *val);
  74. static int ASN1CALL ASN1Dec_BindRequest(ASN1decoding_t dec, ASN1uint32_t tag, BindRequest *val);
  75. static int ASN1CALL ASN1Dec_SearchRequest(ASN1decoding_t dec, ASN1uint32_t tag, SearchRequest *val);
  76. static int ASN1CALL ASN1Dec_LDAPMessage_protocolOp(ASN1decoding_t dec, ASN1uint32_t tag, LDAPMessage_protocolOp *val);
  77. static int ASN1CALL ASN1Dec_LDAPMessage(ASN1decoding_t dec, ASN1uint32_t tag, LDAPMessage *val);
  78. static void ASN1CALL ASN1Free_SearchResponse_entry_attributes_Seq_values(PSearchResponse_entry_attributes_Seq_values *val);
  79. static void ASN1CALL ASN1Free_ModifyRequest_modifications_Seq_modification_values(PModifyRequest_modifications_Seq_modification_values *val);
  80. static void ASN1CALL ASN1Free_AddRequest_attrs_Seq_values(PAddRequest_attrs_Seq_values *val);
  81. static void ASN1CALL ASN1Free_ModifyRequest_modifications_Seq_modification(ModifyRequest_modifications_Seq_modification *val);
  82. static void ASN1CALL ASN1Free_SearchResponse_entry_attributes_Seq(SearchResponse_entry_attributes_Seq *val);
  83. static void ASN1CALL ASN1Free_SearchResponse_entry_attributes(PSearchResponse_entry_attributes *val);
  84. static void ASN1CALL ASN1Free_ModifyRequest_modifications_Seq(ModifyRequest_modifications_Seq *val);
  85. static void ASN1CALL ASN1Free_AddRequest_attrs_Seq(AddRequest_attrs_Seq *val);
  86. static void ASN1CALL ASN1Free_SubstringFilter_attributes_Seq(SubstringFilter_attributes_Seq *val);
  87. static void ASN1CALL ASN1Free_SubstringFilter_attributes(PSubstringFilter_attributes *val);
  88. static void ASN1CALL ASN1Free_AddRequest_attrs(PAddRequest_attrs *val);
  89. static void ASN1CALL ASN1Free_ModifyRequest_modifications(PModifyRequest_modifications *val);
  90. static void ASN1CALL ASN1Free_SearchResponse_entry(SearchResponse_entry *val);
  91. static void ASN1CALL ASN1Free_SearchRequest_attributes(PSearchRequest_attributes *val);
  92. static void ASN1CALL ASN1Free_SaslCredentials(SaslCredentials *val);
  93. static void ASN1CALL ASN1Free_ModifyRequest(ModifyRequest *val);
  94. static void ASN1CALL ASN1Free_AddRequest(AddRequest *val);
  95. static void ASN1CALL ASN1Free_ModifyRDNRequest(ModifyRDNRequest *val);
  96. static void ASN1CALL ASN1Free_LDAPResult(LDAPResult *val);
  97. static void ASN1CALL ASN1Free_AttributeValueAssertion(AttributeValueAssertion *val);
  98. static void ASN1CALL ASN1Free_SubstringFilter(SubstringFilter *val);
  99. static void ASN1CALL ASN1Free_AuthenticationChoice(AuthenticationChoice *val);
  100. static void ASN1CALL ASN1Free_BindResponse(BindResponse *val);
  101. static void ASN1CALL ASN1Free_SearchResponse(SearchResponse *val);
  102. static void ASN1CALL ASN1Free_ModifyResponse(ModifyResponse *val);
  103. static void ASN1CALL ASN1Free_AddResponse(AddResponse *val);
  104. static void ASN1CALL ASN1Free_DelResponse(DelResponse *val);
  105. static void ASN1CALL ASN1Free_ModifyRDNResponse(ModifyRDNResponse *val);
  106. static void ASN1CALL ASN1Free_CompareRequest(CompareRequest *val);
  107. static void ASN1CALL ASN1Free_CompareResponse(CompareResponse *val);
  108. static void ASN1CALL ASN1Free_Filter(Filter *val);
  109. static void ASN1CALL ASN1Free_Filter_or(PFilter_or *val);
  110. static void ASN1CALL ASN1Free_Filter_and(PFilter_and *val);
  111. static void ASN1CALL ASN1Free_BindRequest(BindRequest *val);
  112. static void ASN1CALL ASN1Free_SearchRequest(SearchRequest *val);
  113. static void ASN1CALL ASN1Free_LDAPMessage_protocolOp(LDAPMessage_protocolOp *val);
  114. static void ASN1CALL ASN1Free_LDAPMessage(LDAPMessage *val);
  115. typedef ASN1BerEncFun_t ASN1EncFun_t;
  116. static const ASN1EncFun_t encfntab[1] = {
  117. (ASN1EncFun_t) ASN1Enc_LDAPMessage,
  118. };
  119. typedef ASN1BerDecFun_t ASN1DecFun_t;
  120. static const ASN1DecFun_t decfntab[1] = {
  121. (ASN1DecFun_t) ASN1Dec_LDAPMessage,
  122. };
  123. static const ASN1FreeFun_t freefntab[1] = {
  124. (ASN1FreeFun_t) ASN1Free_LDAPMessage,
  125. };
  126. static const ULONG sizetab[1] = {
  127. SIZE_LDAP_Module_ID_0,
  128. };
  129. /* forward declarations of values: */
  130. /* definitions of value components: */
  131. /* definitions of values: */
  132. ASN1int32_t maxInt = 2147483647;
  133. void ASN1CALL LDAP_Module_Startup(void)
  134. {
  135. LDAP_Module = ASN1_CreateModule(0x10000, ASN1_BER_RULE_BER, ASN1FLAGS_NONE, 1, (const ASN1GenericFun_t *) encfntab, (const ASN1GenericFun_t *) decfntab, freefntab, sizetab, 0x0);
  136. }
  137. void ASN1CALL LDAP_Module_Cleanup(void)
  138. {
  139. ASN1_CloseModule(LDAP_Module);
  140. LDAP_Module = NULL;
  141. }
  142. static int ASN1CALL ASN1Enc_SearchResponse_entry_attributes_Seq_values(ASN1encoding_t enc, ASN1uint32_t tag, PSearchResponse_entry_attributes_Seq_values *val)
  143. {
  144. PSearchResponse_entry_attributes_Seq_values f;
  145. ASN1uint32_t nLenOff;
  146. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  147. return 0;
  148. for (f = *val; f; f = f->next) {
  149. if (!ASN1BEREncOctetString(enc, 0x4, (f->value).length, (f->value).value))
  150. return 0;
  151. }
  152. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  153. return 0;
  154. return 1;
  155. }
  156. static int ASN1CALL ASN1Dec_SearchResponse_entry_attributes_Seq_values(ASN1decoding_t dec, ASN1uint32_t tag, PSearchResponse_entry_attributes_Seq_values *val)
  157. {
  158. PSearchResponse_entry_attributes_Seq_values *f;
  159. ASN1decoding_t dd;
  160. ASN1octet_t *di;
  161. ASN1uint32_t t;
  162. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  163. return 0;
  164. f = val;
  165. while (ASN1BERDecNotEndOfContents(dd, di)) {
  166. if (!ASN1BERDecPeekTag(dd, &t))
  167. return 0;
  168. if (!(*f = (PSearchResponse_entry_attributes_Seq_values)ASN1DecAlloc(dd, sizeof(**f))))
  169. return 0;
  170. if (!ASN1BERDecOctetString(dd, 0x4, &(*f)->value))
  171. return 0;
  172. f = &(*f)->next;
  173. }
  174. *f = NULL;
  175. if (!ASN1BERDecEndOfContents(dec, dd, di))
  176. return 0;
  177. return 1;
  178. }
  179. static void ASN1CALL ASN1Free_SearchResponse_entry_attributes_Seq_values(PSearchResponse_entry_attributes_Seq_values *val)
  180. {
  181. PSearchResponse_entry_attributes_Seq_values f, ff;
  182. if (val) {
  183. for (f = *val; f; f = ff) {
  184. ASN1octetstring_free(&f->value);
  185. ff = f->next;
  186. ASN1Free(f);
  187. }
  188. }
  189. }
  190. static int ASN1CALL ASN1Enc_ModifyRequest_modifications_Seq_modification_values(ASN1encoding_t enc, ASN1uint32_t tag, PModifyRequest_modifications_Seq_modification_values *val)
  191. {
  192. PModifyRequest_modifications_Seq_modification_values f;
  193. ASN1uint32_t nLenOff;
  194. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  195. return 0;
  196. for (f = *val; f; f = f->next) {
  197. if (!ASN1BEREncOctetString(enc, 0x4, (f->value).length, (f->value).value))
  198. return 0;
  199. }
  200. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  201. return 0;
  202. return 1;
  203. }
  204. static int ASN1CALL ASN1Dec_ModifyRequest_modifications_Seq_modification_values(ASN1decoding_t dec, ASN1uint32_t tag, PModifyRequest_modifications_Seq_modification_values *val)
  205. {
  206. PModifyRequest_modifications_Seq_modification_values *f;
  207. ASN1decoding_t dd;
  208. ASN1octet_t *di;
  209. ASN1uint32_t t;
  210. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  211. return 0;
  212. f = val;
  213. while (ASN1BERDecNotEndOfContents(dd, di)) {
  214. if (!ASN1BERDecPeekTag(dd, &t))
  215. return 0;
  216. if (!(*f = (PModifyRequest_modifications_Seq_modification_values)ASN1DecAlloc(dd, sizeof(**f))))
  217. return 0;
  218. if (!ASN1BERDecOctetString(dd, 0x4, &(*f)->value))
  219. return 0;
  220. f = &(*f)->next;
  221. }
  222. *f = NULL;
  223. if (!ASN1BERDecEndOfContents(dec, dd, di))
  224. return 0;
  225. return 1;
  226. }
  227. static void ASN1CALL ASN1Free_ModifyRequest_modifications_Seq_modification_values(PModifyRequest_modifications_Seq_modification_values *val)
  228. {
  229. PModifyRequest_modifications_Seq_modification_values f, ff;
  230. if (val) {
  231. for (f = *val; f; f = ff) {
  232. ASN1octetstring_free(&f->value);
  233. ff = f->next;
  234. ASN1Free(f);
  235. }
  236. }
  237. }
  238. static int ASN1CALL ASN1Enc_AddRequest_attrs_Seq_values(ASN1encoding_t enc, ASN1uint32_t tag, PAddRequest_attrs_Seq_values *val)
  239. {
  240. PAddRequest_attrs_Seq_values f;
  241. ASN1uint32_t nLenOff;
  242. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  243. return 0;
  244. for (f = *val; f; f = f->next) {
  245. if (!ASN1BEREncOctetString(enc, 0x4, (f->value).length, (f->value).value))
  246. return 0;
  247. }
  248. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  249. return 0;
  250. return 1;
  251. }
  252. static int ASN1CALL ASN1Dec_AddRequest_attrs_Seq_values(ASN1decoding_t dec, ASN1uint32_t tag, PAddRequest_attrs_Seq_values *val)
  253. {
  254. PAddRequest_attrs_Seq_values *f;
  255. ASN1decoding_t dd;
  256. ASN1octet_t *di;
  257. ASN1uint32_t t;
  258. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  259. return 0;
  260. f = val;
  261. while (ASN1BERDecNotEndOfContents(dd, di)) {
  262. if (!ASN1BERDecPeekTag(dd, &t))
  263. return 0;
  264. if (!(*f = (PAddRequest_attrs_Seq_values)ASN1DecAlloc(dd, sizeof(**f))))
  265. return 0;
  266. if (!ASN1BERDecOctetString(dd, 0x4, &(*f)->value))
  267. return 0;
  268. f = &(*f)->next;
  269. }
  270. *f = NULL;
  271. if (!ASN1BERDecEndOfContents(dec, dd, di))
  272. return 0;
  273. return 1;
  274. }
  275. static void ASN1CALL ASN1Free_AddRequest_attrs_Seq_values(PAddRequest_attrs_Seq_values *val)
  276. {
  277. PAddRequest_attrs_Seq_values f, ff;
  278. if (val) {
  279. for (f = *val; f; f = ff) {
  280. ASN1octetstring_free(&f->value);
  281. ff = f->next;
  282. ASN1Free(f);
  283. }
  284. }
  285. }
  286. static int ASN1CALL ASN1Enc_ModifyRequest_modifications_Seq_modification(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRequest_modifications_Seq_modification *val)
  287. {
  288. ASN1uint32_t nLenOff;
  289. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  290. return 0;
  291. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->type).length, ((val)->type).value))
  292. return 0;
  293. if (!ASN1Enc_ModifyRequest_modifications_Seq_modification_values(enc, 0, &(val)->values))
  294. return 0;
  295. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  296. return 0;
  297. return 1;
  298. }
  299. static int ASN1CALL ASN1Dec_ModifyRequest_modifications_Seq_modification(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRequest_modifications_Seq_modification *val)
  300. {
  301. ASN1decoding_t dd;
  302. ASN1octet_t *di;
  303. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  304. return 0;
  305. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->type))
  306. return 0;
  307. if (!ASN1Dec_ModifyRequest_modifications_Seq_modification_values(dd, 0, &(val)->values))
  308. return 0;
  309. if (!ASN1BERDecEndOfContents(dec, dd, di))
  310. return 0;
  311. return 1;
  312. }
  313. static void ASN1CALL ASN1Free_ModifyRequest_modifications_Seq_modification(ModifyRequest_modifications_Seq_modification *val)
  314. {
  315. if (val) {
  316. ASN1octetstring_free(&(val)->type);
  317. ASN1Free_ModifyRequest_modifications_Seq_modification_values(&(val)->values);
  318. }
  319. }
  320. static int ASN1CALL ASN1Enc_SearchResponse_entry_attributes_Seq(ASN1encoding_t enc, ASN1uint32_t tag, SearchResponse_entry_attributes_Seq *val)
  321. {
  322. ASN1uint32_t nLenOff;
  323. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  324. return 0;
  325. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->type).length, ((val)->type).value))
  326. return 0;
  327. if (!ASN1Enc_SearchResponse_entry_attributes_Seq_values(enc, 0, &(val)->values))
  328. return 0;
  329. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  330. return 0;
  331. return 1;
  332. }
  333. static int ASN1CALL ASN1Dec_SearchResponse_entry_attributes_Seq(ASN1decoding_t dec, ASN1uint32_t tag, SearchResponse_entry_attributes_Seq *val)
  334. {
  335. ASN1decoding_t dd;
  336. ASN1octet_t *di;
  337. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  338. return 0;
  339. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->type))
  340. return 0;
  341. if (!ASN1Dec_SearchResponse_entry_attributes_Seq_values(dd, 0, &(val)->values))
  342. return 0;
  343. if (!ASN1BERDecEndOfContents(dec, dd, di))
  344. return 0;
  345. return 1;
  346. }
  347. static void ASN1CALL ASN1Free_SearchResponse_entry_attributes_Seq(SearchResponse_entry_attributes_Seq *val)
  348. {
  349. if (val) {
  350. ASN1octetstring_free(&(val)->type);
  351. ASN1Free_SearchResponse_entry_attributes_Seq_values(&(val)->values);
  352. }
  353. }
  354. static int ASN1CALL ASN1Enc_SearchResponse_entry_attributes(ASN1encoding_t enc, ASN1uint32_t tag, PSearchResponse_entry_attributes *val)
  355. {
  356. PSearchResponse_entry_attributes f;
  357. ASN1uint32_t nLenOff;
  358. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  359. return 0;
  360. for (f = *val; f; f = f->next) {
  361. if (!ASN1Enc_SearchResponse_entry_attributes_Seq(enc, 0, &f->value))
  362. return 0;
  363. }
  364. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  365. return 0;
  366. return 1;
  367. }
  368. static int ASN1CALL ASN1Dec_SearchResponse_entry_attributes(ASN1decoding_t dec, ASN1uint32_t tag, PSearchResponse_entry_attributes *val)
  369. {
  370. PSearchResponse_entry_attributes *f;
  371. ASN1decoding_t dd;
  372. ASN1octet_t *di;
  373. ASN1uint32_t t;
  374. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  375. return 0;
  376. f = val;
  377. while (ASN1BERDecNotEndOfContents(dd, di)) {
  378. if (!ASN1BERDecPeekTag(dd, &t))
  379. return 0;
  380. if (!(*f = (PSearchResponse_entry_attributes)ASN1DecAlloc(dd, sizeof(**f))))
  381. return 0;
  382. if (!ASN1Dec_SearchResponse_entry_attributes_Seq(dd, 0, &(*f)->value))
  383. return 0;
  384. f = &(*f)->next;
  385. }
  386. *f = NULL;
  387. if (!ASN1BERDecEndOfContents(dec, dd, di))
  388. return 0;
  389. return 1;
  390. }
  391. static void ASN1CALL ASN1Free_SearchResponse_entry_attributes(PSearchResponse_entry_attributes *val)
  392. {
  393. PSearchResponse_entry_attributes f, ff;
  394. if (val) {
  395. for (f = *val; f; f = ff) {
  396. ASN1Free_SearchResponse_entry_attributes_Seq(&f->value);
  397. ff = f->next;
  398. ASN1Free(f);
  399. }
  400. }
  401. }
  402. static int ASN1CALL ASN1Enc_ModifyRequest_modifications_Seq(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRequest_modifications_Seq *val)
  403. {
  404. ASN1uint32_t nLenOff;
  405. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  406. return 0;
  407. if (!ASN1BEREncU32(enc, 0xa, (val)->operation))
  408. return 0;
  409. if (!ASN1Enc_ModifyRequest_modifications_Seq_modification(enc, 0, &(val)->modification))
  410. return 0;
  411. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  412. return 0;
  413. return 1;
  414. }
  415. static int ASN1CALL ASN1Dec_ModifyRequest_modifications_Seq(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRequest_modifications_Seq *val)
  416. {
  417. ASN1decoding_t dd;
  418. ASN1octet_t *di;
  419. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  420. return 0;
  421. if (!ASN1BERDecU32Val(dd, 0xa, (ASN1uint32_t *) &(val)->operation))
  422. return 0;
  423. if (!ASN1Dec_ModifyRequest_modifications_Seq_modification(dd, 0, &(val)->modification))
  424. return 0;
  425. if (!ASN1BERDecEndOfContents(dec, dd, di))
  426. return 0;
  427. return 1;
  428. }
  429. static void ASN1CALL ASN1Free_ModifyRequest_modifications_Seq(ModifyRequest_modifications_Seq *val)
  430. {
  431. if (val) {
  432. ASN1Free_ModifyRequest_modifications_Seq_modification(&(val)->modification);
  433. }
  434. }
  435. static int ASN1CALL ASN1Enc_AddRequest_attrs_Seq(ASN1encoding_t enc, ASN1uint32_t tag, AddRequest_attrs_Seq *val)
  436. {
  437. ASN1uint32_t nLenOff;
  438. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  439. return 0;
  440. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->type).length, ((val)->type).value))
  441. return 0;
  442. if (!ASN1Enc_AddRequest_attrs_Seq_values(enc, 0, &(val)->values))
  443. return 0;
  444. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  445. return 0;
  446. return 1;
  447. }
  448. static int ASN1CALL ASN1Dec_AddRequest_attrs_Seq(ASN1decoding_t dec, ASN1uint32_t tag, AddRequest_attrs_Seq *val)
  449. {
  450. ASN1decoding_t dd;
  451. ASN1octet_t *di;
  452. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  453. return 0;
  454. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->type))
  455. return 0;
  456. if (!ASN1Dec_AddRequest_attrs_Seq_values(dd, 0, &(val)->values))
  457. return 0;
  458. if (!ASN1BERDecEndOfContents(dec, dd, di))
  459. return 0;
  460. return 1;
  461. }
  462. static void ASN1CALL ASN1Free_AddRequest_attrs_Seq(AddRequest_attrs_Seq *val)
  463. {
  464. if (val) {
  465. ASN1octetstring_free(&(val)->type);
  466. ASN1Free_AddRequest_attrs_Seq_values(&(val)->values);
  467. }
  468. }
  469. static int ASN1CALL ASN1Enc_SubstringFilter_attributes_Seq(ASN1encoding_t enc, ASN1uint32_t tag, SubstringFilter_attributes_Seq *val)
  470. {
  471. switch ((val)->choice) {
  472. case 1:
  473. if (!ASN1BEREncOctetString(enc, 0x80000000, ((val)->u.initial).length, ((val)->u.initial).value))
  474. return 0;
  475. break;
  476. case 2:
  477. if (!ASN1BEREncOctetString(enc, 0x80000001, ((val)->u.any).length, ((val)->u.any).value))
  478. return 0;
  479. break;
  480. case 3:
  481. if (!ASN1BEREncOctetString(enc, 0x80000002, ((val)->u.final).length, ((val)->u.final).value))
  482. return 0;
  483. break;
  484. }
  485. return 1;
  486. }
  487. static int ASN1CALL ASN1Dec_SubstringFilter_attributes_Seq(ASN1decoding_t dec, ASN1uint32_t tag, SubstringFilter_attributes_Seq *val)
  488. {
  489. ASN1uint32_t t;
  490. if (!ASN1BERDecPeekTag(dec, &t))
  491. return 0;
  492. switch (t) {
  493. case 0x80000000:
  494. (val)->choice = 1;
  495. if (!ASN1BERDecOctetString(dec, 0x80000000, &(val)->u.initial))
  496. return 0;
  497. break;
  498. case 0x80000001:
  499. (val)->choice = 2;
  500. if (!ASN1BERDecOctetString(dec, 0x80000001, &(val)->u.any))
  501. return 0;
  502. break;
  503. case 0x80000002:
  504. (val)->choice = 3;
  505. if (!ASN1BERDecOctetString(dec, 0x80000002, &(val)->u.final))
  506. return 0;
  507. break;
  508. default:
  509. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  510. return 0;
  511. }
  512. return 1;
  513. }
  514. static void ASN1CALL ASN1Free_SubstringFilter_attributes_Seq(SubstringFilter_attributes_Seq *val)
  515. {
  516. if (val) {
  517. switch ((val)->choice) {
  518. case 1:
  519. ASN1octetstring_free(&(val)->u.initial);
  520. break;
  521. case 2:
  522. ASN1octetstring_free(&(val)->u.any);
  523. break;
  524. case 3:
  525. ASN1octetstring_free(&(val)->u.final);
  526. break;
  527. }
  528. }
  529. }
  530. static int ASN1CALL ASN1Enc_SubstringFilter_attributes(ASN1encoding_t enc, ASN1uint32_t tag, PSubstringFilter_attributes *val)
  531. {
  532. PSubstringFilter_attributes f;
  533. ASN1uint32_t nLenOff;
  534. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  535. return 0;
  536. for (f = *val; f; f = f->next) {
  537. if (!ASN1Enc_SubstringFilter_attributes_Seq(enc, 0, &f->value))
  538. return 0;
  539. }
  540. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  541. return 0;
  542. return 1;
  543. }
  544. static int ASN1CALL ASN1Dec_SubstringFilter_attributes(ASN1decoding_t dec, ASN1uint32_t tag, PSubstringFilter_attributes *val)
  545. {
  546. PSubstringFilter_attributes *f;
  547. ASN1decoding_t dd;
  548. ASN1octet_t *di;
  549. ASN1uint32_t t;
  550. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  551. return 0;
  552. f = val;
  553. while (ASN1BERDecNotEndOfContents(dd, di)) {
  554. if (!ASN1BERDecPeekTag(dd, &t))
  555. return 0;
  556. if (!(*f = (PSubstringFilter_attributes)ASN1DecAlloc(dd, sizeof(**f))))
  557. return 0;
  558. if (!ASN1Dec_SubstringFilter_attributes_Seq(dd, 0, &(*f)->value))
  559. return 0;
  560. f = &(*f)->next;
  561. }
  562. *f = NULL;
  563. if (!ASN1BERDecEndOfContents(dec, dd, di))
  564. return 0;
  565. return 1;
  566. }
  567. static void ASN1CALL ASN1Free_SubstringFilter_attributes(PSubstringFilter_attributes *val)
  568. {
  569. PSubstringFilter_attributes f, ff;
  570. if (val) {
  571. for (f = *val; f; f = ff) {
  572. ASN1Free_SubstringFilter_attributes_Seq(&f->value);
  573. ff = f->next;
  574. ASN1Free(f);
  575. }
  576. }
  577. }
  578. static int ASN1CALL ASN1Enc_AddRequest_attrs(ASN1encoding_t enc, ASN1uint32_t tag, PAddRequest_attrs *val)
  579. {
  580. PAddRequest_attrs f;
  581. ASN1uint32_t nLenOff;
  582. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  583. return 0;
  584. for (f = *val; f; f = f->next) {
  585. if (!ASN1Enc_AddRequest_attrs_Seq(enc, 0, &f->value))
  586. return 0;
  587. }
  588. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  589. return 0;
  590. return 1;
  591. }
  592. static int ASN1CALL ASN1Dec_AddRequest_attrs(ASN1decoding_t dec, ASN1uint32_t tag, PAddRequest_attrs *val)
  593. {
  594. PAddRequest_attrs *f;
  595. ASN1decoding_t dd;
  596. ASN1octet_t *di;
  597. ASN1uint32_t t;
  598. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  599. return 0;
  600. f = val;
  601. while (ASN1BERDecNotEndOfContents(dd, di)) {
  602. if (!ASN1BERDecPeekTag(dd, &t))
  603. return 0;
  604. if (!(*f = (PAddRequest_attrs)ASN1DecAlloc(dd, sizeof(**f))))
  605. return 0;
  606. if (!ASN1Dec_AddRequest_attrs_Seq(dd, 0, &(*f)->value))
  607. return 0;
  608. f = &(*f)->next;
  609. }
  610. *f = NULL;
  611. if (!ASN1BERDecEndOfContents(dec, dd, di))
  612. return 0;
  613. return 1;
  614. }
  615. static void ASN1CALL ASN1Free_AddRequest_attrs(PAddRequest_attrs *val)
  616. {
  617. PAddRequest_attrs f, ff;
  618. if (val) {
  619. for (f = *val; f; f = ff) {
  620. ASN1Free_AddRequest_attrs_Seq(&f->value);
  621. ff = f->next;
  622. ASN1Free(f);
  623. }
  624. }
  625. }
  626. static int ASN1CALL ASN1Enc_ModifyRequest_modifications(ASN1encoding_t enc, ASN1uint32_t tag, PModifyRequest_modifications *val)
  627. {
  628. PModifyRequest_modifications f;
  629. ASN1uint32_t nLenOff;
  630. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  631. return 0;
  632. for (f = *val; f; f = f->next) {
  633. if (!ASN1Enc_ModifyRequest_modifications_Seq(enc, 0, &f->value))
  634. return 0;
  635. }
  636. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  637. return 0;
  638. return 1;
  639. }
  640. static int ASN1CALL ASN1Dec_ModifyRequest_modifications(ASN1decoding_t dec, ASN1uint32_t tag, PModifyRequest_modifications *val)
  641. {
  642. PModifyRequest_modifications *f;
  643. ASN1decoding_t dd;
  644. ASN1octet_t *di;
  645. ASN1uint32_t t;
  646. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  647. return 0;
  648. f = val;
  649. while (ASN1BERDecNotEndOfContents(dd, di)) {
  650. if (!ASN1BERDecPeekTag(dd, &t))
  651. return 0;
  652. if (!(*f = (PModifyRequest_modifications)ASN1DecAlloc(dd, sizeof(**f))))
  653. return 0;
  654. if (!ASN1Dec_ModifyRequest_modifications_Seq(dd, 0, &(*f)->value))
  655. return 0;
  656. f = &(*f)->next;
  657. }
  658. *f = NULL;
  659. if (!ASN1BERDecEndOfContents(dec, dd, di))
  660. return 0;
  661. return 1;
  662. }
  663. static void ASN1CALL ASN1Free_ModifyRequest_modifications(PModifyRequest_modifications *val)
  664. {
  665. PModifyRequest_modifications f, ff;
  666. if (val) {
  667. for (f = *val; f; f = ff) {
  668. ASN1Free_ModifyRequest_modifications_Seq(&f->value);
  669. ff = f->next;
  670. ASN1Free(f);
  671. }
  672. }
  673. }
  674. static int ASN1CALL ASN1Enc_SearchResponse_entry(ASN1encoding_t enc, ASN1uint32_t tag, SearchResponse_entry *val)
  675. {
  676. ASN1uint32_t nLenOff;
  677. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x40000004, &nLenOff))
  678. return 0;
  679. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->objectName).length, ((val)->objectName).value))
  680. return 0;
  681. if (!ASN1Enc_SearchResponse_entry_attributes(enc, 0, &(val)->attributes))
  682. return 0;
  683. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  684. return 0;
  685. return 1;
  686. }
  687. static int ASN1CALL ASN1Dec_SearchResponse_entry(ASN1decoding_t dec, ASN1uint32_t tag, SearchResponse_entry *val)
  688. {
  689. ASN1decoding_t dd;
  690. ASN1octet_t *di;
  691. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x40000004, &dd, &di))
  692. return 0;
  693. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->objectName))
  694. return 0;
  695. if (!ASN1Dec_SearchResponse_entry_attributes(dd, 0, &(val)->attributes))
  696. return 0;
  697. if (!ASN1BERDecEndOfContents(dec, dd, di))
  698. return 0;
  699. return 1;
  700. }
  701. static void ASN1CALL ASN1Free_SearchResponse_entry(SearchResponse_entry *val)
  702. {
  703. if (val) {
  704. ASN1octetstring_free(&(val)->objectName);
  705. ASN1Free_SearchResponse_entry_attributes(&(val)->attributes);
  706. }
  707. }
  708. static int ASN1CALL ASN1Enc_SearchRequest_attributes(ASN1encoding_t enc, ASN1uint32_t tag, PSearchRequest_attributes *val)
  709. {
  710. PSearchRequest_attributes f;
  711. ASN1uint32_t nLenOff;
  712. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  713. return 0;
  714. for (f = *val; f; f = f->next) {
  715. if (!ASN1BEREncOctetString(enc, 0x4, (f->value).length, (f->value).value))
  716. return 0;
  717. }
  718. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  719. return 0;
  720. return 1;
  721. }
  722. static int ASN1CALL ASN1Dec_SearchRequest_attributes(ASN1decoding_t dec, ASN1uint32_t tag, PSearchRequest_attributes *val)
  723. {
  724. PSearchRequest_attributes *f;
  725. ASN1decoding_t dd;
  726. ASN1octet_t *di;
  727. ASN1uint32_t t;
  728. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  729. return 0;
  730. f = val;
  731. while (ASN1BERDecNotEndOfContents(dd, di)) {
  732. if (!ASN1BERDecPeekTag(dd, &t))
  733. return 0;
  734. if (!(*f = (PSearchRequest_attributes)ASN1DecAlloc(dd, sizeof(**f))))
  735. return 0;
  736. if (!ASN1BERDecOctetString(dd, 0x4, &(*f)->value))
  737. return 0;
  738. f = &(*f)->next;
  739. }
  740. *f = NULL;
  741. if (!ASN1BERDecEndOfContents(dec, dd, di))
  742. return 0;
  743. return 1;
  744. }
  745. static void ASN1CALL ASN1Free_SearchRequest_attributes(PSearchRequest_attributes *val)
  746. {
  747. PSearchRequest_attributes f, ff;
  748. if (val) {
  749. for (f = *val; f; f = ff) {
  750. ASN1octetstring_free(&f->value);
  751. ff = f->next;
  752. ASN1Free(f);
  753. }
  754. }
  755. }
  756. static int ASN1CALL ASN1Enc_SaslCredentials(ASN1encoding_t enc, ASN1uint32_t tag, SaslCredentials *val)
  757. {
  758. ASN1uint32_t nLenOff;
  759. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  760. return 0;
  761. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->mechanism).length, ((val)->mechanism).value))
  762. return 0;
  763. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->credentials).length, ((val)->credentials).value))
  764. return 0;
  765. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  766. return 0;
  767. return 1;
  768. }
  769. static int ASN1CALL ASN1Dec_SaslCredentials(ASN1decoding_t dec, ASN1uint32_t tag, SaslCredentials *val)
  770. {
  771. ASN1decoding_t dd;
  772. ASN1octet_t *di;
  773. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  774. return 0;
  775. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->mechanism))
  776. return 0;
  777. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->credentials))
  778. return 0;
  779. if (!ASN1BERDecEndOfContents(dec, dd, di))
  780. return 0;
  781. return 1;
  782. }
  783. static void ASN1CALL ASN1Free_SaslCredentials(SaslCredentials *val)
  784. {
  785. if (val) {
  786. ASN1octetstring_free(&(val)->mechanism);
  787. ASN1octetstring_free(&(val)->credentials);
  788. }
  789. }
  790. static int ASN1CALL ASN1Enc_ModifyRequest(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRequest *val)
  791. {
  792. ASN1uint32_t nLenOff;
  793. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x40000006, &nLenOff))
  794. return 0;
  795. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->object).length, ((val)->object).value))
  796. return 0;
  797. if (!ASN1Enc_ModifyRequest_modifications(enc, 0, &(val)->modifications))
  798. return 0;
  799. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  800. return 0;
  801. return 1;
  802. }
  803. static int ASN1CALL ASN1Dec_ModifyRequest(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRequest *val)
  804. {
  805. ASN1decoding_t dd;
  806. ASN1octet_t *di;
  807. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x40000006, &dd, &di))
  808. return 0;
  809. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->object))
  810. return 0;
  811. if (!ASN1Dec_ModifyRequest_modifications(dd, 0, &(val)->modifications))
  812. return 0;
  813. if (!ASN1BERDecEndOfContents(dec, dd, di))
  814. return 0;
  815. return 1;
  816. }
  817. static void ASN1CALL ASN1Free_ModifyRequest(ModifyRequest *val)
  818. {
  819. if (val) {
  820. ASN1octetstring_free(&(val)->object);
  821. ASN1Free_ModifyRequest_modifications(&(val)->modifications);
  822. }
  823. }
  824. static int ASN1CALL ASN1Enc_AddRequest(ASN1encoding_t enc, ASN1uint32_t tag, AddRequest *val)
  825. {
  826. ASN1uint32_t nLenOff;
  827. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x40000008, &nLenOff))
  828. return 0;
  829. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->entry).length, ((val)->entry).value))
  830. return 0;
  831. if (!ASN1Enc_AddRequest_attrs(enc, 0, &(val)->attrs))
  832. return 0;
  833. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  834. return 0;
  835. return 1;
  836. }
  837. static int ASN1CALL ASN1Dec_AddRequest(ASN1decoding_t dec, ASN1uint32_t tag, AddRequest *val)
  838. {
  839. ASN1decoding_t dd;
  840. ASN1octet_t *di;
  841. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x40000008, &dd, &di))
  842. return 0;
  843. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->entry))
  844. return 0;
  845. if (!ASN1Dec_AddRequest_attrs(dd, 0, &(val)->attrs))
  846. return 0;
  847. if (!ASN1BERDecEndOfContents(dec, dd, di))
  848. return 0;
  849. return 1;
  850. }
  851. static void ASN1CALL ASN1Free_AddRequest(AddRequest *val)
  852. {
  853. if (val) {
  854. ASN1octetstring_free(&(val)->entry);
  855. ASN1Free_AddRequest_attrs(&(val)->attrs);
  856. }
  857. }
  858. static int ASN1CALL ASN1Enc_ModifyRDNRequest(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRDNRequest *val)
  859. {
  860. ASN1uint32_t nLenOff;
  861. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x4000000c, &nLenOff))
  862. return 0;
  863. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->entry).length, ((val)->entry).value))
  864. return 0;
  865. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->newrdn).length, ((val)->newrdn).value))
  866. return 0;
  867. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  868. return 0;
  869. return 1;
  870. }
  871. static int ASN1CALL ASN1Dec_ModifyRDNRequest(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRDNRequest *val)
  872. {
  873. ASN1decoding_t dd;
  874. ASN1octet_t *di;
  875. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x4000000c, &dd, &di))
  876. return 0;
  877. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->entry))
  878. return 0;
  879. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->newrdn))
  880. return 0;
  881. if (!ASN1BERDecEndOfContents(dec, dd, di))
  882. return 0;
  883. return 1;
  884. }
  885. static void ASN1CALL ASN1Free_ModifyRDNRequest(ModifyRDNRequest *val)
  886. {
  887. if (val) {
  888. ASN1octetstring_free(&(val)->entry);
  889. ASN1octetstring_free(&(val)->newrdn);
  890. }
  891. }
  892. static int ASN1CALL ASN1Enc_LDAPResult(ASN1encoding_t enc, ASN1uint32_t tag, LDAPResult *val)
  893. {
  894. ASN1uint32_t nLenOff;
  895. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  896. return 0;
  897. if (!ASN1BEREncU32(enc, 0xa, (val)->resultCode))
  898. return 0;
  899. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->matchedDN).length, ((val)->matchedDN).value))
  900. return 0;
  901. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->errorMessage).length, ((val)->errorMessage).value))
  902. return 0;
  903. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  904. return 0;
  905. return 1;
  906. }
  907. static int ASN1CALL ASN1Dec_LDAPResult(ASN1decoding_t dec, ASN1uint32_t tag, LDAPResult *val)
  908. {
  909. ASN1decoding_t dd;
  910. ASN1octet_t *di;
  911. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  912. return 0;
  913. if (!ASN1BERDecU32Val(dd, 0xa, (ASN1uint32_t *) &(val)->resultCode))
  914. return 0;
  915. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->matchedDN))
  916. return 0;
  917. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->errorMessage))
  918. return 0;
  919. if (!ASN1BERDecEndOfContents(dec, dd, di))
  920. return 0;
  921. return 1;
  922. }
  923. static void ASN1CALL ASN1Free_LDAPResult(LDAPResult *val)
  924. {
  925. if (val) {
  926. ASN1octetstring_free(&(val)->matchedDN);
  927. ASN1octetstring_free(&(val)->errorMessage);
  928. }
  929. }
  930. static int ASN1CALL ASN1Enc_AttributeValueAssertion(ASN1encoding_t enc, ASN1uint32_t tag, AttributeValueAssertion *val)
  931. {
  932. ASN1uint32_t nLenOff;
  933. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  934. return 0;
  935. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->attributeType).length, ((val)->attributeType).value))
  936. return 0;
  937. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->attributeValue).length, ((val)->attributeValue).value))
  938. return 0;
  939. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  940. return 0;
  941. return 1;
  942. }
  943. static int ASN1CALL ASN1Dec_AttributeValueAssertion(ASN1decoding_t dec, ASN1uint32_t tag, AttributeValueAssertion *val)
  944. {
  945. ASN1decoding_t dd;
  946. ASN1octet_t *di;
  947. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  948. return 0;
  949. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->attributeType))
  950. return 0;
  951. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->attributeValue))
  952. return 0;
  953. if (!ASN1BERDecEndOfContents(dec, dd, di))
  954. return 0;
  955. return 1;
  956. }
  957. static void ASN1CALL ASN1Free_AttributeValueAssertion(AttributeValueAssertion *val)
  958. {
  959. if (val) {
  960. ASN1octetstring_free(&(val)->attributeType);
  961. ASN1octetstring_free(&(val)->attributeValue);
  962. }
  963. }
  964. static int ASN1CALL ASN1Enc_SubstringFilter(ASN1encoding_t enc, ASN1uint32_t tag, SubstringFilter *val)
  965. {
  966. ASN1uint32_t nLenOff;
  967. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  968. return 0;
  969. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->type).length, ((val)->type).value))
  970. return 0;
  971. if (!ASN1Enc_SubstringFilter_attributes(enc, 0, &(val)->attributes))
  972. return 0;
  973. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  974. return 0;
  975. return 1;
  976. }
  977. static int ASN1CALL ASN1Dec_SubstringFilter(ASN1decoding_t dec, ASN1uint32_t tag, SubstringFilter *val)
  978. {
  979. ASN1decoding_t dd;
  980. ASN1octet_t *di;
  981. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  982. return 0;
  983. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->type))
  984. return 0;
  985. if (!ASN1Dec_SubstringFilter_attributes(dd, 0, &(val)->attributes))
  986. return 0;
  987. if (!ASN1BERDecEndOfContents(dec, dd, di))
  988. return 0;
  989. return 1;
  990. }
  991. static void ASN1CALL ASN1Free_SubstringFilter(SubstringFilter *val)
  992. {
  993. if (val) {
  994. ASN1octetstring_free(&(val)->type);
  995. ASN1Free_SubstringFilter_attributes(&(val)->attributes);
  996. }
  997. }
  998. static int ASN1CALL ASN1Enc_AuthenticationChoice(ASN1encoding_t enc, ASN1uint32_t tag, AuthenticationChoice *val)
  999. {
  1000. switch ((val)->choice) {
  1001. case 1:
  1002. if (!ASN1BEREncOctetString(enc, 0x80000000, ((val)->u.simple).length, ((val)->u.simple).value))
  1003. return 0;
  1004. break;
  1005. case 2:
  1006. if (!ASN1Enc_SaslCredentials(enc, 0x80000003, &(val)->u.sasl))
  1007. return 0;
  1008. break;
  1009. case 3:
  1010. if (!ASN1BEREncOctetString(enc, 0x80000009, ((val)->u.sicilyNegotiate).length, ((val)->u.sicilyNegotiate).value))
  1011. return 0;
  1012. break;
  1013. case 4:
  1014. if (!ASN1BEREncOctetString(enc, 0x8000000a, ((val)->u.sicilyInitial).length, ((val)->u.sicilyInitial).value))
  1015. return 0;
  1016. break;
  1017. case 5:
  1018. if (!ASN1BEREncOctetString(enc, 0x8000000b, ((val)->u.sicilySubsequent).length, ((val)->u.sicilySubsequent).value))
  1019. return 0;
  1020. break;
  1021. }
  1022. return 1;
  1023. }
  1024. static int ASN1CALL ASN1Dec_AuthenticationChoice(ASN1decoding_t dec, ASN1uint32_t tag, AuthenticationChoice *val)
  1025. {
  1026. ASN1uint32_t t;
  1027. if (!ASN1BERDecPeekTag(dec, &t))
  1028. return 0;
  1029. switch (t) {
  1030. case 0x80000000:
  1031. (val)->choice = 1;
  1032. if (!ASN1BERDecOctetString(dec, 0x80000000, &(val)->u.simple))
  1033. return 0;
  1034. break;
  1035. case 0x80000003:
  1036. (val)->choice = 2;
  1037. if (!ASN1Dec_SaslCredentials(dec, 0x80000003, &(val)->u.sasl))
  1038. return 0;
  1039. break;
  1040. case 0x80000009:
  1041. (val)->choice = 3;
  1042. if (!ASN1BERDecOctetString(dec, 0x80000009, &(val)->u.sicilyNegotiate))
  1043. return 0;
  1044. break;
  1045. case 0x8000000a:
  1046. (val)->choice = 4;
  1047. if (!ASN1BERDecOctetString(dec, 0x8000000a, &(val)->u.sicilyInitial))
  1048. return 0;
  1049. break;
  1050. case 0x8000000b:
  1051. (val)->choice = 5;
  1052. if (!ASN1BERDecOctetString(dec, 0x8000000b, &(val)->u.sicilySubsequent))
  1053. return 0;
  1054. break;
  1055. default:
  1056. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1057. return 0;
  1058. }
  1059. return 1;
  1060. }
  1061. static void ASN1CALL ASN1Free_AuthenticationChoice(AuthenticationChoice *val)
  1062. {
  1063. if (val) {
  1064. switch ((val)->choice) {
  1065. case 1:
  1066. ASN1octetstring_free(&(val)->u.simple);
  1067. break;
  1068. case 2:
  1069. ASN1Free_SaslCredentials(&(val)->u.sasl);
  1070. break;
  1071. case 3:
  1072. ASN1octetstring_free(&(val)->u.sicilyNegotiate);
  1073. break;
  1074. case 4:
  1075. ASN1octetstring_free(&(val)->u.sicilyInitial);
  1076. break;
  1077. case 5:
  1078. ASN1octetstring_free(&(val)->u.sicilySubsequent);
  1079. break;
  1080. }
  1081. }
  1082. }
  1083. static int ASN1CALL ASN1Enc_BindResponse(ASN1encoding_t enc, ASN1uint32_t tag, BindResponse *val)
  1084. {
  1085. if (!ASN1Enc_LDAPResult(enc, tag ? tag : 0x40000001, val))
  1086. return 0;
  1087. return 1;
  1088. }
  1089. static int ASN1CALL ASN1Dec_BindResponse(ASN1decoding_t dec, ASN1uint32_t tag, BindResponse *val)
  1090. {
  1091. if (!ASN1Dec_LDAPResult(dec, tag ? tag : 0x40000001, val))
  1092. return 0;
  1093. return 1;
  1094. }
  1095. static void ASN1CALL ASN1Free_BindResponse(BindResponse *val)
  1096. {
  1097. if (val) {
  1098. ASN1Free_LDAPResult(val);
  1099. }
  1100. }
  1101. static int ASN1CALL ASN1Enc_SearchResponse(ASN1encoding_t enc, ASN1uint32_t tag, SearchResponse *val)
  1102. {
  1103. switch ((val)->choice) {
  1104. case 1:
  1105. if (!ASN1Enc_SearchResponse_entry(enc, 0, &(val)->u.entry))
  1106. return 0;
  1107. break;
  1108. case 2:
  1109. if (!ASN1Enc_LDAPResult(enc, 0x40000005, &(val)->u.resultCode))
  1110. return 0;
  1111. break;
  1112. }
  1113. return 1;
  1114. }
  1115. static int ASN1CALL ASN1Dec_SearchResponse(ASN1decoding_t dec, ASN1uint32_t tag, SearchResponse *val)
  1116. {
  1117. ASN1uint32_t t;
  1118. if (!ASN1BERDecPeekTag(dec, &t))
  1119. return 0;
  1120. switch (t) {
  1121. case 0x40000004:
  1122. (val)->choice = 1;
  1123. if (!ASN1Dec_SearchResponse_entry(dec, 0, &(val)->u.entry))
  1124. return 0;
  1125. break;
  1126. case 0x40000005:
  1127. (val)->choice = 2;
  1128. if (!ASN1Dec_LDAPResult(dec, 0x40000005, &(val)->u.resultCode))
  1129. return 0;
  1130. break;
  1131. default:
  1132. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1133. return 0;
  1134. }
  1135. return 1;
  1136. }
  1137. static void ASN1CALL ASN1Free_SearchResponse(SearchResponse *val)
  1138. {
  1139. if (val) {
  1140. switch ((val)->choice) {
  1141. case 1:
  1142. ASN1Free_SearchResponse_entry(&(val)->u.entry);
  1143. break;
  1144. case 2:
  1145. ASN1Free_LDAPResult(&(val)->u.resultCode);
  1146. break;
  1147. }
  1148. }
  1149. }
  1150. static int ASN1CALL ASN1Enc_ModifyResponse(ASN1encoding_t enc, ASN1uint32_t tag, ModifyResponse *val)
  1151. {
  1152. if (!ASN1Enc_LDAPResult(enc, tag ? tag : 0x40000007, val))
  1153. return 0;
  1154. return 1;
  1155. }
  1156. static int ASN1CALL ASN1Dec_ModifyResponse(ASN1decoding_t dec, ASN1uint32_t tag, ModifyResponse *val)
  1157. {
  1158. if (!ASN1Dec_LDAPResult(dec, tag ? tag : 0x40000007, val))
  1159. return 0;
  1160. return 1;
  1161. }
  1162. static void ASN1CALL ASN1Free_ModifyResponse(ModifyResponse *val)
  1163. {
  1164. if (val) {
  1165. ASN1Free_LDAPResult(val);
  1166. }
  1167. }
  1168. static int ASN1CALL ASN1Enc_AddResponse(ASN1encoding_t enc, ASN1uint32_t tag, AddResponse *val)
  1169. {
  1170. if (!ASN1Enc_LDAPResult(enc, tag ? tag : 0x40000009, val))
  1171. return 0;
  1172. return 1;
  1173. }
  1174. static int ASN1CALL ASN1Dec_AddResponse(ASN1decoding_t dec, ASN1uint32_t tag, AddResponse *val)
  1175. {
  1176. if (!ASN1Dec_LDAPResult(dec, tag ? tag : 0x40000009, val))
  1177. return 0;
  1178. return 1;
  1179. }
  1180. static void ASN1CALL ASN1Free_AddResponse(AddResponse *val)
  1181. {
  1182. if (val) {
  1183. ASN1Free_LDAPResult(val);
  1184. }
  1185. }
  1186. static int ASN1CALL ASN1Enc_DelResponse(ASN1encoding_t enc, ASN1uint32_t tag, DelResponse *val)
  1187. {
  1188. if (!ASN1Enc_LDAPResult(enc, tag ? tag : 0x4000000b, val))
  1189. return 0;
  1190. return 1;
  1191. }
  1192. static int ASN1CALL ASN1Dec_DelResponse(ASN1decoding_t dec, ASN1uint32_t tag, DelResponse *val)
  1193. {
  1194. if (!ASN1Dec_LDAPResult(dec, tag ? tag : 0x4000000b, val))
  1195. return 0;
  1196. return 1;
  1197. }
  1198. static void ASN1CALL ASN1Free_DelResponse(DelResponse *val)
  1199. {
  1200. if (val) {
  1201. ASN1Free_LDAPResult(val);
  1202. }
  1203. }
  1204. static int ASN1CALL ASN1Enc_ModifyRDNResponse(ASN1encoding_t enc, ASN1uint32_t tag, ModifyRDNResponse *val)
  1205. {
  1206. if (!ASN1Enc_LDAPResult(enc, tag ? tag : 0x4000000d, val))
  1207. return 0;
  1208. return 1;
  1209. }
  1210. static int ASN1CALL ASN1Dec_ModifyRDNResponse(ASN1decoding_t dec, ASN1uint32_t tag, ModifyRDNResponse *val)
  1211. {
  1212. if (!ASN1Dec_LDAPResult(dec, tag ? tag : 0x4000000d, val))
  1213. return 0;
  1214. return 1;
  1215. }
  1216. static void ASN1CALL ASN1Free_ModifyRDNResponse(ModifyRDNResponse *val)
  1217. {
  1218. if (val) {
  1219. ASN1Free_LDAPResult(val);
  1220. }
  1221. }
  1222. static int ASN1CALL ASN1Enc_CompareRequest(ASN1encoding_t enc, ASN1uint32_t tag, CompareRequest *val)
  1223. {
  1224. ASN1uint32_t nLenOff;
  1225. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x4000000e, &nLenOff))
  1226. return 0;
  1227. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->entry).length, ((val)->entry).value))
  1228. return 0;
  1229. if (!ASN1Enc_AttributeValueAssertion(enc, 0, &(val)->ava))
  1230. return 0;
  1231. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1232. return 0;
  1233. return 1;
  1234. }
  1235. static int ASN1CALL ASN1Dec_CompareRequest(ASN1decoding_t dec, ASN1uint32_t tag, CompareRequest *val)
  1236. {
  1237. ASN1decoding_t dd;
  1238. ASN1octet_t *di;
  1239. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x4000000e, &dd, &di))
  1240. return 0;
  1241. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->entry))
  1242. return 0;
  1243. if (!ASN1Dec_AttributeValueAssertion(dd, 0, &(val)->ava))
  1244. return 0;
  1245. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1246. return 0;
  1247. return 1;
  1248. }
  1249. static void ASN1CALL ASN1Free_CompareRequest(CompareRequest *val)
  1250. {
  1251. if (val) {
  1252. ASN1octetstring_free(&(val)->entry);
  1253. ASN1Free_AttributeValueAssertion(&(val)->ava);
  1254. }
  1255. }
  1256. static int ASN1CALL ASN1Enc_CompareResponse(ASN1encoding_t enc, ASN1uint32_t tag, CompareResponse *val)
  1257. {
  1258. if (!ASN1Enc_LDAPResult(enc, tag ? tag : 0x4000000f, val))
  1259. return 0;
  1260. return 1;
  1261. }
  1262. static int ASN1CALL ASN1Dec_CompareResponse(ASN1decoding_t dec, ASN1uint32_t tag, CompareResponse *val)
  1263. {
  1264. if (!ASN1Dec_LDAPResult(dec, tag ? tag : 0x4000000f, val))
  1265. return 0;
  1266. return 1;
  1267. }
  1268. static void ASN1CALL ASN1Free_CompareResponse(CompareResponse *val)
  1269. {
  1270. if (val) {
  1271. ASN1Free_LDAPResult(val);
  1272. }
  1273. }
  1274. static int ASN1CALL ASN1Enc_Filter(ASN1encoding_t enc, ASN1uint32_t tag, Filter *val)
  1275. {
  1276. switch ((val)->choice) {
  1277. case 1:
  1278. if (!ASN1Enc_Filter_and(enc, 0, &(val)->u.and))
  1279. return 0;
  1280. break;
  1281. case 2:
  1282. if (!ASN1Enc_Filter_or(enc, 0, &(val)->u.or))
  1283. return 0;
  1284. break;
  1285. case 3:
  1286. if (!ASN1Enc_AttributeValueAssertion(enc, 0x80000003, &(val)->u.equalityMatch))
  1287. return 0;
  1288. break;
  1289. case 4:
  1290. if (!ASN1Enc_SubstringFilter(enc, 0x80000004, &(val)->u.substrings))
  1291. return 0;
  1292. break;
  1293. case 5:
  1294. if (!ASN1Enc_AttributeValueAssertion(enc, 0x80000005, &(val)->u.greaterOrEqual))
  1295. return 0;
  1296. break;
  1297. case 6:
  1298. if (!ASN1Enc_AttributeValueAssertion(enc, 0x80000006, &(val)->u.lessOrEqual))
  1299. return 0;
  1300. break;
  1301. case 7:
  1302. if (!ASN1BEREncOctetString(enc, 0x80000007, ((val)->u.present).length, ((val)->u.present).value))
  1303. return 0;
  1304. break;
  1305. case 8:
  1306. if (!ASN1Enc_AttributeValueAssertion(enc, 0x80000008, &(val)->u.approxMatch))
  1307. return 0;
  1308. break;
  1309. }
  1310. return 1;
  1311. }
  1312. static int ASN1CALL ASN1Dec_Filter(ASN1decoding_t dec, ASN1uint32_t tag, Filter *val)
  1313. {
  1314. ASN1uint32_t t;
  1315. if (!ASN1BERDecPeekTag(dec, &t))
  1316. return 0;
  1317. switch (t) {
  1318. case 0x80000000:
  1319. (val)->choice = 1;
  1320. if (!ASN1Dec_Filter_and(dec, 0, &(val)->u.and))
  1321. return 0;
  1322. break;
  1323. case 0x80000001:
  1324. (val)->choice = 2;
  1325. if (!ASN1Dec_Filter_or(dec, 0, &(val)->u.or))
  1326. return 0;
  1327. break;
  1328. case 0x80000003:
  1329. (val)->choice = 3;
  1330. if (!ASN1Dec_AttributeValueAssertion(dec, 0x80000003, &(val)->u.equalityMatch))
  1331. return 0;
  1332. break;
  1333. case 0x80000004:
  1334. (val)->choice = 4;
  1335. if (!ASN1Dec_SubstringFilter(dec, 0x80000004, &(val)->u.substrings))
  1336. return 0;
  1337. break;
  1338. case 0x80000005:
  1339. (val)->choice = 5;
  1340. if (!ASN1Dec_AttributeValueAssertion(dec, 0x80000005, &(val)->u.greaterOrEqual))
  1341. return 0;
  1342. break;
  1343. case 0x80000006:
  1344. (val)->choice = 6;
  1345. if (!ASN1Dec_AttributeValueAssertion(dec, 0x80000006, &(val)->u.lessOrEqual))
  1346. return 0;
  1347. break;
  1348. case 0x80000007:
  1349. (val)->choice = 7;
  1350. if (!ASN1BERDecOctetString(dec, 0x80000007, &(val)->u.present))
  1351. return 0;
  1352. break;
  1353. case 0x80000008:
  1354. (val)->choice = 8;
  1355. if (!ASN1Dec_AttributeValueAssertion(dec, 0x80000008, &(val)->u.approxMatch))
  1356. return 0;
  1357. break;
  1358. default:
  1359. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1360. return 0;
  1361. }
  1362. return 1;
  1363. }
  1364. static void ASN1CALL ASN1Free_Filter(Filter *val)
  1365. {
  1366. if (val) {
  1367. switch ((val)->choice) {
  1368. case 1:
  1369. ASN1Free_Filter_and(&(val)->u.and);
  1370. break;
  1371. case 2:
  1372. ASN1Free_Filter_or(&(val)->u.or);
  1373. break;
  1374. case 3:
  1375. ASN1Free_AttributeValueAssertion(&(val)->u.equalityMatch);
  1376. break;
  1377. case 4:
  1378. ASN1Free_SubstringFilter(&(val)->u.substrings);
  1379. break;
  1380. case 5:
  1381. ASN1Free_AttributeValueAssertion(&(val)->u.greaterOrEqual);
  1382. break;
  1383. case 6:
  1384. ASN1Free_AttributeValueAssertion(&(val)->u.lessOrEqual);
  1385. break;
  1386. case 7:
  1387. ASN1octetstring_free(&(val)->u.present);
  1388. break;
  1389. case 8:
  1390. ASN1Free_AttributeValueAssertion(&(val)->u.approxMatch);
  1391. break;
  1392. }
  1393. }
  1394. }
  1395. static int ASN1CALL ASN1Enc_Filter_or(ASN1encoding_t enc, ASN1uint32_t tag, PFilter_or *val)
  1396. {
  1397. PFilter_or f;
  1398. ASN1uint32_t nLenOff;
  1399. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x80000001, &nLenOff))
  1400. return 0;
  1401. for (f = *val; f; f = f->next) {
  1402. if (!ASN1Enc_Filter(enc, 0, &f->value))
  1403. return 0;
  1404. }
  1405. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1406. return 0;
  1407. return 1;
  1408. }
  1409. static int ASN1CALL ASN1Dec_Filter_or(ASN1decoding_t dec, ASN1uint32_t tag, PFilter_or *val)
  1410. {
  1411. PFilter_or *f;
  1412. ASN1decoding_t dd;
  1413. ASN1octet_t *di;
  1414. ASN1uint32_t t;
  1415. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x80000001, &dd, &di))
  1416. return 0;
  1417. f = val;
  1418. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1419. if (!ASN1BERDecPeekTag(dd, &t))
  1420. return 0;
  1421. if (!(*f = (PFilter_or)ASN1DecAlloc(dd, sizeof(**f))))
  1422. return 0;
  1423. if (!ASN1Dec_Filter(dd, 0, &(*f)->value))
  1424. return 0;
  1425. f = &(*f)->next;
  1426. }
  1427. *f = NULL;
  1428. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1429. return 0;
  1430. return 1;
  1431. }
  1432. static void ASN1CALL ASN1Free_Filter_or(PFilter_or *val)
  1433. {
  1434. PFilter_or f, ff;
  1435. if (val) {
  1436. for (f = *val; f; f = ff) {
  1437. ASN1Free_Filter(&f->value);
  1438. ff = f->next;
  1439. ASN1Free(f);
  1440. }
  1441. }
  1442. }
  1443. static int ASN1CALL ASN1Enc_Filter_and(ASN1encoding_t enc, ASN1uint32_t tag, PFilter_and *val)
  1444. {
  1445. PFilter_and f;
  1446. ASN1uint32_t nLenOff;
  1447. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x80000000, &nLenOff))
  1448. return 0;
  1449. for (f = *val; f; f = f->next) {
  1450. if (!ASN1Enc_Filter(enc, 0, &f->value))
  1451. return 0;
  1452. }
  1453. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1454. return 0;
  1455. return 1;
  1456. }
  1457. static int ASN1CALL ASN1Dec_Filter_and(ASN1decoding_t dec, ASN1uint32_t tag, PFilter_and *val)
  1458. {
  1459. PFilter_and *f;
  1460. ASN1decoding_t dd;
  1461. ASN1octet_t *di;
  1462. ASN1uint32_t t;
  1463. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x80000000, &dd, &di))
  1464. return 0;
  1465. f = val;
  1466. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1467. if (!ASN1BERDecPeekTag(dd, &t))
  1468. return 0;
  1469. if (!(*f = (PFilter_and)ASN1DecAlloc(dd, sizeof(**f))))
  1470. return 0;
  1471. if (!ASN1Dec_Filter(dd, 0, &(*f)->value))
  1472. return 0;
  1473. f = &(*f)->next;
  1474. }
  1475. *f = NULL;
  1476. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1477. return 0;
  1478. return 1;
  1479. }
  1480. static void ASN1CALL ASN1Free_Filter_and(PFilter_and *val)
  1481. {
  1482. PFilter_and f, ff;
  1483. if (val) {
  1484. for (f = *val; f; f = ff) {
  1485. ASN1Free_Filter(&f->value);
  1486. ff = f->next;
  1487. ASN1Free(f);
  1488. }
  1489. }
  1490. }
  1491. static int ASN1CALL ASN1Enc_BindRequest(ASN1encoding_t enc, ASN1uint32_t tag, BindRequest *val)
  1492. {
  1493. ASN1uint32_t nLenOff;
  1494. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x40000000, &nLenOff))
  1495. return 0;
  1496. if (!ASN1BEREncU32(enc, 0x2, (val)->version))
  1497. return 0;
  1498. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->name).length, ((val)->name).value))
  1499. return 0;
  1500. if (!ASN1Enc_AuthenticationChoice(enc, 0, &(val)->authentication))
  1501. return 0;
  1502. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1503. return 0;
  1504. return 1;
  1505. }
  1506. static int ASN1CALL ASN1Dec_BindRequest(ASN1decoding_t dec, ASN1uint32_t tag, BindRequest *val)
  1507. {
  1508. ASN1decoding_t dd;
  1509. ASN1octet_t *di;
  1510. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x40000000, &dd, &di))
  1511. return 0;
  1512. if (!ASN1BERDecU16Val(dd, 0x2, &(val)->version))
  1513. return 0;
  1514. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->name))
  1515. return 0;
  1516. if (!ASN1Dec_AuthenticationChoice(dd, 0, &(val)->authentication))
  1517. return 0;
  1518. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1519. return 0;
  1520. return 1;
  1521. }
  1522. static void ASN1CALL ASN1Free_BindRequest(BindRequest *val)
  1523. {
  1524. if (val) {
  1525. ASN1octetstring_free(&(val)->name);
  1526. ASN1Free_AuthenticationChoice(&(val)->authentication);
  1527. }
  1528. }
  1529. static int ASN1CALL ASN1Enc_SearchRequest(ASN1encoding_t enc, ASN1uint32_t tag, SearchRequest *val)
  1530. {
  1531. ASN1uint32_t nLenOff;
  1532. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x40000003, &nLenOff))
  1533. return 0;
  1534. if (!ASN1BEREncOctetString(enc, 0x4, ((val)->baseObject).length, ((val)->baseObject).value))
  1535. return 0;
  1536. if (!ASN1BEREncU32(enc, 0xa, (val)->scope))
  1537. return 0;
  1538. if (!ASN1BEREncU32(enc, 0xa, (val)->derefAliases))
  1539. return 0;
  1540. if (!ASN1BEREncU32(enc, 0x2, (val)->sizeLimit))
  1541. return 0;
  1542. if (!ASN1BEREncU32(enc, 0x2, (val)->timeLimit))
  1543. return 0;
  1544. if (!ASN1BEREncBool(enc, 0x1, (val)->attrsOnly))
  1545. return 0;
  1546. if (!ASN1Enc_Filter(enc, 0, &(val)->filter))
  1547. return 0;
  1548. if (!ASN1Enc_SearchRequest_attributes(enc, 0, &(val)->attributes))
  1549. return 0;
  1550. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1551. return 0;
  1552. return 1;
  1553. }
  1554. static int ASN1CALL ASN1Dec_SearchRequest(ASN1decoding_t dec, ASN1uint32_t tag, SearchRequest *val)
  1555. {
  1556. ASN1decoding_t dd;
  1557. ASN1octet_t *di;
  1558. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x40000003, &dd, &di))
  1559. return 0;
  1560. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->baseObject))
  1561. return 0;
  1562. if (!ASN1BERDecU32Val(dd, 0xa, (ASN1uint32_t *) &(val)->scope))
  1563. return 0;
  1564. if (!ASN1BERDecU32Val(dd, 0xa, (ASN1uint32_t *) &(val)->derefAliases))
  1565. return 0;
  1566. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->sizeLimit))
  1567. return 0;
  1568. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->timeLimit))
  1569. return 0;
  1570. if (!ASN1BERDecBool(dd, 0x1, &(val)->attrsOnly))
  1571. return 0;
  1572. if (!ASN1Dec_Filter(dd, 0, &(val)->filter))
  1573. return 0;
  1574. if (!ASN1Dec_SearchRequest_attributes(dd, 0, &(val)->attributes))
  1575. return 0;
  1576. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1577. return 0;
  1578. return 1;
  1579. }
  1580. static void ASN1CALL ASN1Free_SearchRequest(SearchRequest *val)
  1581. {
  1582. if (val) {
  1583. ASN1octetstring_free(&(val)->baseObject);
  1584. ASN1Free_Filter(&(val)->filter);
  1585. ASN1Free_SearchRequest_attributes(&(val)->attributes);
  1586. }
  1587. }
  1588. static int ASN1CALL ASN1Enc_LDAPMessage_protocolOp(ASN1encoding_t enc, ASN1uint32_t tag, LDAPMessage_protocolOp *val)
  1589. {
  1590. switch ((val)->choice) {
  1591. case 1:
  1592. if (!ASN1Enc_BindRequest(enc, 0, &(val)->u.bindRequest))
  1593. return 0;
  1594. break;
  1595. case 2:
  1596. if (!ASN1Enc_BindResponse(enc, 0, &(val)->u.bindResponse))
  1597. return 0;
  1598. break;
  1599. case 3:
  1600. if (!ASN1BEREncNull(enc, 0x40000002))
  1601. return 0;
  1602. break;
  1603. case 4:
  1604. if (!ASN1Enc_SearchRequest(enc, 0, &(val)->u.searchRequest))
  1605. return 0;
  1606. break;
  1607. case 5:
  1608. if (!ASN1Enc_SearchResponse(enc, 0, &(val)->u.searchResponse))
  1609. return 0;
  1610. break;
  1611. case 6:
  1612. if (!ASN1Enc_ModifyRequest(enc, 0, &(val)->u.modifyRequest))
  1613. return 0;
  1614. break;
  1615. case 7:
  1616. if (!ASN1Enc_ModifyResponse(enc, 0, &(val)->u.modifyResponse))
  1617. return 0;
  1618. break;
  1619. case 8:
  1620. if (!ASN1Enc_AddRequest(enc, 0, &(val)->u.addRequest))
  1621. return 0;
  1622. break;
  1623. case 9:
  1624. if (!ASN1Enc_AddResponse(enc, 0, &(val)->u.addResponse))
  1625. return 0;
  1626. break;
  1627. case 10:
  1628. if (!ASN1BEREncOctetString(enc, 0x4000000a, ((val)->u.delRequest).length, ((val)->u.delRequest).value))
  1629. return 0;
  1630. break;
  1631. case 11:
  1632. if (!ASN1Enc_DelResponse(enc, 0, &(val)->u.delResponse))
  1633. return 0;
  1634. break;
  1635. case 12:
  1636. if (!ASN1Enc_ModifyRDNRequest(enc, 0, &(val)->u.modifyRDNRequest))
  1637. return 0;
  1638. break;
  1639. case 13:
  1640. if (!ASN1Enc_ModifyRDNResponse(enc, 0, &(val)->u.modifyRDNResponse))
  1641. return 0;
  1642. break;
  1643. case 14:
  1644. if (!ASN1Enc_CompareRequest(enc, 0, &(val)->u.compareDNRequest))
  1645. return 0;
  1646. break;
  1647. case 15:
  1648. if (!ASN1Enc_CompareResponse(enc, 0, &(val)->u.compareDNResponse))
  1649. return 0;
  1650. break;
  1651. case 16:
  1652. if (!ASN1BEREncU32(enc, 0x40000010, (val)->u.abandonRequest))
  1653. return 0;
  1654. break;
  1655. }
  1656. return 1;
  1657. }
  1658. static int ASN1CALL ASN1Dec_LDAPMessage_protocolOp(ASN1decoding_t dec, ASN1uint32_t tag, LDAPMessage_protocolOp *val)
  1659. {
  1660. ASN1uint32_t t;
  1661. if (!ASN1BERDecPeekTag(dec, &t))
  1662. return 0;
  1663. switch (t) {
  1664. case 0x40000000:
  1665. (val)->choice = 1;
  1666. if (!ASN1Dec_BindRequest(dec, 0, &(val)->u.bindRequest))
  1667. return 0;
  1668. break;
  1669. case 0x40000001:
  1670. (val)->choice = 2;
  1671. if (!ASN1Dec_BindResponse(dec, 0, &(val)->u.bindResponse))
  1672. return 0;
  1673. break;
  1674. case 0x40000002:
  1675. (val)->choice = 3;
  1676. if (!ASN1BERDecNull(dec, 0x40000002))
  1677. return 0;
  1678. break;
  1679. case 0x40000003:
  1680. (val)->choice = 4;
  1681. if (!ASN1Dec_SearchRequest(dec, 0, &(val)->u.searchRequest))
  1682. return 0;
  1683. break;
  1684. case 0x40000004:
  1685. case 0x40000005:
  1686. (val)->choice = 5;
  1687. if (!ASN1Dec_SearchResponse(dec, 0, &(val)->u.searchResponse))
  1688. return 0;
  1689. break;
  1690. case 0x40000006:
  1691. (val)->choice = 6;
  1692. if (!ASN1Dec_ModifyRequest(dec, 0, &(val)->u.modifyRequest))
  1693. return 0;
  1694. break;
  1695. case 0x40000007:
  1696. (val)->choice = 7;
  1697. if (!ASN1Dec_ModifyResponse(dec, 0, &(val)->u.modifyResponse))
  1698. return 0;
  1699. break;
  1700. case 0x40000008:
  1701. (val)->choice = 8;
  1702. if (!ASN1Dec_AddRequest(dec, 0, &(val)->u.addRequest))
  1703. return 0;
  1704. break;
  1705. case 0x40000009:
  1706. (val)->choice = 9;
  1707. if (!ASN1Dec_AddResponse(dec, 0, &(val)->u.addResponse))
  1708. return 0;
  1709. break;
  1710. case 0x4000000a:
  1711. (val)->choice = 10;
  1712. if (!ASN1BERDecOctetString(dec, 0x4000000a, &(val)->u.delRequest))
  1713. return 0;
  1714. break;
  1715. case 0x4000000b:
  1716. (val)->choice = 11;
  1717. if (!ASN1Dec_DelResponse(dec, 0, &(val)->u.delResponse))
  1718. return 0;
  1719. break;
  1720. case 0x4000000c:
  1721. (val)->choice = 12;
  1722. if (!ASN1Dec_ModifyRDNRequest(dec, 0, &(val)->u.modifyRDNRequest))
  1723. return 0;
  1724. break;
  1725. case 0x4000000d:
  1726. (val)->choice = 13;
  1727. if (!ASN1Dec_ModifyRDNResponse(dec, 0, &(val)->u.modifyRDNResponse))
  1728. return 0;
  1729. break;
  1730. case 0x4000000e:
  1731. (val)->choice = 14;
  1732. if (!ASN1Dec_CompareRequest(dec, 0, &(val)->u.compareDNRequest))
  1733. return 0;
  1734. break;
  1735. case 0x4000000f:
  1736. (val)->choice = 15;
  1737. if (!ASN1Dec_CompareResponse(dec, 0, &(val)->u.compareDNResponse))
  1738. return 0;
  1739. break;
  1740. case 0x40000010:
  1741. (val)->choice = 16;
  1742. if (!ASN1BERDecU32Val(dec, 0x40000010, (ASN1uint32_t *) &(val)->u.abandonRequest))
  1743. return 0;
  1744. break;
  1745. default:
  1746. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1747. return 0;
  1748. }
  1749. return 1;
  1750. }
  1751. static void ASN1CALL ASN1Free_LDAPMessage_protocolOp(LDAPMessage_protocolOp *val)
  1752. {
  1753. if (val) {
  1754. switch ((val)->choice) {
  1755. case 1:
  1756. ASN1Free_BindRequest(&(val)->u.bindRequest);
  1757. break;
  1758. case 2:
  1759. ASN1Free_BindResponse(&(val)->u.bindResponse);
  1760. break;
  1761. case 4:
  1762. ASN1Free_SearchRequest(&(val)->u.searchRequest);
  1763. break;
  1764. case 5:
  1765. ASN1Free_SearchResponse(&(val)->u.searchResponse);
  1766. break;
  1767. case 6:
  1768. ASN1Free_ModifyRequest(&(val)->u.modifyRequest);
  1769. break;
  1770. case 7:
  1771. ASN1Free_ModifyResponse(&(val)->u.modifyResponse);
  1772. break;
  1773. case 8:
  1774. ASN1Free_AddRequest(&(val)->u.addRequest);
  1775. break;
  1776. case 9:
  1777. ASN1Free_AddResponse(&(val)->u.addResponse);
  1778. break;
  1779. case 10:
  1780. ASN1octetstring_free(&(val)->u.delRequest);
  1781. break;
  1782. case 11:
  1783. ASN1Free_DelResponse(&(val)->u.delResponse);
  1784. break;
  1785. case 12:
  1786. ASN1Free_ModifyRDNRequest(&(val)->u.modifyRDNRequest);
  1787. break;
  1788. case 13:
  1789. ASN1Free_ModifyRDNResponse(&(val)->u.modifyRDNResponse);
  1790. break;
  1791. case 14:
  1792. ASN1Free_CompareRequest(&(val)->u.compareDNRequest);
  1793. break;
  1794. case 15:
  1795. ASN1Free_CompareResponse(&(val)->u.compareDNResponse);
  1796. break;
  1797. }
  1798. }
  1799. }
  1800. static int ASN1CALL ASN1Enc_LDAPMessage(ASN1encoding_t enc, ASN1uint32_t tag, LDAPMessage *val)
  1801. {
  1802. ASN1uint32_t nLenOff;
  1803. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1804. return 0;
  1805. if (!ASN1BEREncU32(enc, 0x2, (val)->messageID))
  1806. return 0;
  1807. if (!ASN1Enc_LDAPMessage_protocolOp(enc, 0, &(val)->protocolOp))
  1808. return 0;
  1809. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1810. return 0;
  1811. return 1;
  1812. }
  1813. static int ASN1CALL ASN1Dec_LDAPMessage(ASN1decoding_t dec, ASN1uint32_t tag, LDAPMessage *val)
  1814. {
  1815. ASN1decoding_t dd;
  1816. ASN1octet_t *di;
  1817. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1818. return 0;
  1819. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->messageID))
  1820. return 0;
  1821. if (!ASN1Dec_LDAPMessage_protocolOp(dd, 0, &(val)->protocolOp))
  1822. return 0;
  1823. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1824. return 0;
  1825. return 1;
  1826. }
  1827. static void ASN1CALL ASN1Free_LDAPMessage(LDAPMessage *val)
  1828. {
  1829. if (val) {
  1830. ASN1Free_LDAPMessage_protocolOp(&(val)->protocolOp);
  1831. }
  1832. }