~ubuntu-branches/ubuntu/raring/tsung/raring

« back to all changes in this revision

Viewing changes to src/lib/ELDAPv3.erl

  • Committer: Package Import Robot
  • Author(s): Ignace Mouzannar
  • Date: 2011-09-20 05:21:15 UTC
  • Revision ID: package-import@ubuntu.com-20110920052115-nqhu0na28zgm78ei
Tags: upstream-1.4.1
ImportĀ upstreamĀ versionĀ 1.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%% Generated by the Erlang ASN.1 BER-compiler version:1.4.5
 
2
%% Purpose: encoder and decoder to the types in mod ELDAPv3
 
3
 
 
4
-module('ELDAPv3').
 
5
-include("ELDAPv3.hrl").
 
6
-define('RT_BER',asn1rt_ber_bin).
 
7
-asn1_info([{vsn,'1.4.5'},
 
8
            {module,'ELDAPv3'},
 
9
            {options,[ber,report_errors,{cwd,[47,104,111,109,101,47,112,97,98,108,111,47,108,111,99,111,115,47,106,117,110,103,101,114,108,47,108,105,98,47,101,108,100,97,112,47,115,114,99]},{outdir,[47,104,111,109,101,47,112,97,98,108,111,47,108,111,99,111,115,47,106,117,110,103,101,114,108,47,108,105,98,47,101,108,100,97,112,47,115,114,99]},{i,[46]},{i,[47,104,111,109,101,47,112,97,98,108,111,47,108,111,99,111,115,47,106,117,110,103,101,114,108,47,108,105,98,47,101,108,100,97,112,47,115,114,99]}]}]).
 
10
 
 
11
-export([encoding_rule/0]).
 
12
-export([
 
13
'enc_LDAPMessage'/2,
 
14
'enc_MessageID'/2,
 
15
'enc_LDAPString'/2,
 
16
'enc_LDAPOID'/2,
 
17
'enc_LDAPDN'/2,
 
18
'enc_RelativeLDAPDN'/2,
 
19
'enc_AttributeType'/2,
 
20
'enc_AttributeDescription'/2,
 
21
'enc_AttributeDescriptionList'/2,
 
22
'enc_AttributeValue'/2,
 
23
'enc_AttributeValueAssertion'/2,
 
24
'enc_AssertionValue'/2,
 
25
'enc_Attribute'/2,
 
26
'enc_MatchingRuleId'/2,
 
27
'enc_LDAPResult'/2,
 
28
'enc_Referral'/2,
 
29
'enc_LDAPURL'/2,
 
30
'enc_Controls'/2,
 
31
'enc_Control'/2,
 
32
'enc_BindRequest'/2,
 
33
'enc_AuthenticationChoice'/2,
 
34
'enc_SaslCredentials'/2,
 
35
'enc_BindResponse'/2,
 
36
'enc_UnbindRequest'/2,
 
37
'enc_SearchRequest'/2,
 
38
'enc_Filter'/2,
 
39
'enc_SubstringFilter'/2,
 
40
'enc_MatchingRuleAssertion'/2,
 
41
'enc_SearchResultEntry'/2,
 
42
'enc_PartialAttributeList'/2,
 
43
'enc_SearchResultReference'/2,
 
44
'enc_SearchResultDone'/2,
 
45
'enc_ModifyRequest'/2,
 
46
'enc_AttributeTypeAndValues'/2,
 
47
'enc_ModifyResponse'/2,
 
48
'enc_AddRequest'/2,
 
49
'enc_AttributeList'/2,
 
50
'enc_AddResponse'/2,
 
51
'enc_DelRequest'/2,
 
52
'enc_DelResponse'/2,
 
53
'enc_ModifyDNRequest'/2,
 
54
'enc_ModifyDNResponse'/2,
 
55
'enc_CompareRequest'/2,
 
56
'enc_CompareResponse'/2,
 
57
'enc_AbandonRequest'/2,
 
58
'enc_ExtendedRequest'/2,
 
59
'enc_ExtendedResponse'/2
 
60
]).
 
61
 
 
62
-export([
 
63
'dec_LDAPMessage'/2,
 
64
'dec_MessageID'/2,
 
65
'dec_LDAPString'/2,
 
66
'dec_LDAPOID'/2,
 
67
'dec_LDAPDN'/2,
 
68
'dec_RelativeLDAPDN'/2,
 
69
'dec_AttributeType'/2,
 
70
'dec_AttributeDescription'/2,
 
71
'dec_AttributeDescriptionList'/2,
 
72
'dec_AttributeValue'/2,
 
73
'dec_AttributeValueAssertion'/2,
 
74
'dec_AssertionValue'/2,
 
75
'dec_Attribute'/2,
 
76
'dec_MatchingRuleId'/2,
 
77
'dec_LDAPResult'/2,
 
78
'dec_Referral'/2,
 
79
'dec_LDAPURL'/2,
 
80
'dec_Controls'/2,
 
81
'dec_Control'/2,
 
82
'dec_BindRequest'/2,
 
83
'dec_AuthenticationChoice'/2,
 
84
'dec_SaslCredentials'/2,
 
85
'dec_BindResponse'/2,
 
86
'dec_UnbindRequest'/2,
 
87
'dec_SearchRequest'/2,
 
88
'dec_Filter'/2,
 
89
'dec_SubstringFilter'/2,
 
90
'dec_MatchingRuleAssertion'/2,
 
91
'dec_SearchResultEntry'/2,
 
92
'dec_PartialAttributeList'/2,
 
93
'dec_SearchResultReference'/2,
 
94
'dec_SearchResultDone'/2,
 
95
'dec_ModifyRequest'/2,
 
96
'dec_AttributeTypeAndValues'/2,
 
97
'dec_ModifyResponse'/2,
 
98
'dec_AddRequest'/2,
 
99
'dec_AttributeList'/2,
 
100
'dec_AddResponse'/2,
 
101
'dec_DelRequest'/2,
 
102
'dec_DelResponse'/2,
 
103
'dec_ModifyDNRequest'/2,
 
104
'dec_ModifyDNResponse'/2,
 
105
'dec_CompareRequest'/2,
 
106
'dec_CompareResponse'/2,
 
107
'dec_AbandonRequest'/2,
 
108
'dec_ExtendedRequest'/2,
 
109
'dec_ExtendedResponse'/2
 
110
]).
 
111
 
 
112
-export([
 
113
'dec_LDAPMessage'/3,
 
114
'dec_MessageID'/3,
 
115
'dec_LDAPString'/3,
 
116
'dec_LDAPOID'/3,
 
117
'dec_LDAPDN'/3,
 
118
'dec_RelativeLDAPDN'/3,
 
119
'dec_AttributeType'/3,
 
120
'dec_AttributeDescription'/3,
 
121
'dec_AttributeDescriptionList'/3,
 
122
'dec_AttributeValue'/3,
 
123
'dec_AttributeValueAssertion'/3,
 
124
'dec_AssertionValue'/3,
 
125
'dec_Attribute'/3,
 
126
'dec_MatchingRuleId'/3,
 
127
'dec_LDAPResult'/3,
 
128
'dec_Referral'/3,
 
129
'dec_LDAPURL'/3,
 
130
'dec_Controls'/3,
 
131
'dec_Control'/3,
 
132
'dec_BindRequest'/3,
 
133
'dec_AuthenticationChoice'/3,
 
134
'dec_SaslCredentials'/3,
 
135
'dec_BindResponse'/3,
 
136
'dec_UnbindRequest'/3,
 
137
'dec_SearchRequest'/3,
 
138
'dec_Filter'/3,
 
139
'dec_SubstringFilter'/3,
 
140
'dec_MatchingRuleAssertion'/3,
 
141
'dec_SearchResultEntry'/3,
 
142
'dec_PartialAttributeList'/3,
 
143
'dec_SearchResultReference'/3,
 
144
'dec_SearchResultDone'/3,
 
145
'dec_ModifyRequest'/3,
 
146
'dec_AttributeTypeAndValues'/3,
 
147
'dec_ModifyResponse'/3,
 
148
'dec_AddRequest'/3,
 
149
'dec_AttributeList'/3,
 
150
'dec_AddResponse'/3,
 
151
'dec_DelRequest'/3,
 
152
'dec_DelResponse'/3,
 
153
'dec_ModifyDNRequest'/3,
 
154
'dec_ModifyDNResponse'/3,
 
155
'dec_CompareRequest'/3,
 
156
'dec_CompareResponse'/3,
 
157
'dec_AbandonRequest'/3,
 
158
'dec_ExtendedRequest'/3,
 
159
'dec_ExtendedResponse'/3
 
160
]).
 
161
 
 
162
-export([
 
163
'maxInt'/0
 
164
]).
 
165
 
 
166
-export([info/0]).
 
167
 
 
168
 
 
169
-export([encode/2,decode/2,encode_disp/2,decode_disp/2]).
 
170
 
 
171
encoding_rule() ->
 
172
   ber.
 
173
 
 
174
encode(Type,Data) ->
 
175
case catch encode_disp(Type,Data) of
 
176
  {'EXIT',{error,Reason}} ->
 
177
    {error,Reason};
 
178
  {'EXIT',Reason} ->
 
179
    {error,{asn1,Reason}};
 
180
  {Bytes,_Len} ->
 
181
    {ok,wrap_encode(Bytes)};
 
182
  Bytes ->
 
183
    {ok,wrap_encode(Bytes)}
 
184
end.
 
185
 
 
186
decode(Type,Data) ->
 
187
case catch decode_disp(Type,wrap_decode(Data)) of
 
188
  {'EXIT',{error,Reason}} ->
 
189
    {error,Reason};
 
190
  {'EXIT',Reason} ->
 
191
    {error,{asn1,Reason}};
 
192
  {X,_Rest} ->
 
193
    {ok,X};
 
194
  {X,_Rest,_Len} ->
 
195
    {ok,X}
 
196
end.
 
197
 
 
198
encode_disp('LDAPMessage',Data) -> 'enc_LDAPMessage'(Data,[]);
 
199
encode_disp('MessageID',Data) -> 'enc_MessageID'(Data,[]);
 
200
encode_disp('LDAPString',Data) -> 'enc_LDAPString'(Data,[]);
 
201
encode_disp('LDAPOID',Data) -> 'enc_LDAPOID'(Data,[]);
 
202
encode_disp('LDAPDN',Data) -> 'enc_LDAPDN'(Data,[]);
 
203
encode_disp('RelativeLDAPDN',Data) -> 'enc_RelativeLDAPDN'(Data,[]);
 
204
encode_disp('AttributeType',Data) -> 'enc_AttributeType'(Data,[]);
 
205
encode_disp('AttributeDescription',Data) -> 'enc_AttributeDescription'(Data,[]);
 
206
encode_disp('AttributeDescriptionList',Data) -> 'enc_AttributeDescriptionList'(Data,[]);
 
207
encode_disp('AttributeValue',Data) -> 'enc_AttributeValue'(Data,[]);
 
208
encode_disp('AttributeValueAssertion',Data) -> 'enc_AttributeValueAssertion'(Data,[]);
 
209
encode_disp('AssertionValue',Data) -> 'enc_AssertionValue'(Data,[]);
 
210
encode_disp('Attribute',Data) -> 'enc_Attribute'(Data,[]);
 
211
encode_disp('MatchingRuleId',Data) -> 'enc_MatchingRuleId'(Data,[]);
 
212
encode_disp('LDAPResult',Data) -> 'enc_LDAPResult'(Data,[]);
 
213
encode_disp('Referral',Data) -> 'enc_Referral'(Data,[]);
 
214
encode_disp('LDAPURL',Data) -> 'enc_LDAPURL'(Data,[]);
 
215
encode_disp('Controls',Data) -> 'enc_Controls'(Data,[]);
 
216
encode_disp('Control',Data) -> 'enc_Control'(Data,[]);
 
217
encode_disp('BindRequest',Data) -> 'enc_BindRequest'(Data,[]);
 
218
encode_disp('AuthenticationChoice',Data) -> 'enc_AuthenticationChoice'(Data,[]);
 
219
encode_disp('SaslCredentials',Data) -> 'enc_SaslCredentials'(Data,[]);
 
220
encode_disp('BindResponse',Data) -> 'enc_BindResponse'(Data,[]);
 
221
encode_disp('UnbindRequest',Data) -> 'enc_UnbindRequest'(Data,[]);
 
222
encode_disp('SearchRequest',Data) -> 'enc_SearchRequest'(Data,[]);
 
223
encode_disp('Filter',Data) -> 'enc_Filter'(Data,[]);
 
224
encode_disp('SubstringFilter',Data) -> 'enc_SubstringFilter'(Data,[]);
 
225
encode_disp('MatchingRuleAssertion',Data) -> 'enc_MatchingRuleAssertion'(Data,[]);
 
226
encode_disp('SearchResultEntry',Data) -> 'enc_SearchResultEntry'(Data,[]);
 
227
encode_disp('PartialAttributeList',Data) -> 'enc_PartialAttributeList'(Data,[]);
 
228
encode_disp('SearchResultReference',Data) -> 'enc_SearchResultReference'(Data,[]);
 
229
encode_disp('SearchResultDone',Data) -> 'enc_SearchResultDone'(Data,[]);
 
230
encode_disp('ModifyRequest',Data) -> 'enc_ModifyRequest'(Data,[]);
 
231
encode_disp('AttributeTypeAndValues',Data) -> 'enc_AttributeTypeAndValues'(Data,[]);
 
232
encode_disp('ModifyResponse',Data) -> 'enc_ModifyResponse'(Data,[]);
 
233
encode_disp('AddRequest',Data) -> 'enc_AddRequest'(Data,[]);
 
234
encode_disp('AttributeList',Data) -> 'enc_AttributeList'(Data,[]);
 
235
encode_disp('AddResponse',Data) -> 'enc_AddResponse'(Data,[]);
 
236
encode_disp('DelRequest',Data) -> 'enc_DelRequest'(Data,[]);
 
237
encode_disp('DelResponse',Data) -> 'enc_DelResponse'(Data,[]);
 
238
encode_disp('ModifyDNRequest',Data) -> 'enc_ModifyDNRequest'(Data,[]);
 
239
encode_disp('ModifyDNResponse',Data) -> 'enc_ModifyDNResponse'(Data,[]);
 
240
encode_disp('CompareRequest',Data) -> 'enc_CompareRequest'(Data,[]);
 
241
encode_disp('CompareResponse',Data) -> 'enc_CompareResponse'(Data,[]);
 
242
encode_disp('AbandonRequest',Data) -> 'enc_AbandonRequest'(Data,[]);
 
243
encode_disp('ExtendedRequest',Data) -> 'enc_ExtendedRequest'(Data,[]);
 
244
encode_disp('ExtendedResponse',Data) -> 'enc_ExtendedResponse'(Data,[]);
 
245
encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).
 
246
 
 
247
 
 
248
decode_disp('LDAPMessage',Data) -> 'dec_LDAPMessage'(Data,mandatory);
 
249
decode_disp('MessageID',Data) -> 'dec_MessageID'(Data,mandatory);
 
250
decode_disp('LDAPString',Data) -> 'dec_LDAPString'(Data,mandatory);
 
251
decode_disp('LDAPOID',Data) -> 'dec_LDAPOID'(Data,mandatory);
 
252
decode_disp('LDAPDN',Data) -> 'dec_LDAPDN'(Data,mandatory);
 
253
decode_disp('RelativeLDAPDN',Data) -> 'dec_RelativeLDAPDN'(Data,mandatory);
 
254
decode_disp('AttributeType',Data) -> 'dec_AttributeType'(Data,mandatory);
 
255
decode_disp('AttributeDescription',Data) -> 'dec_AttributeDescription'(Data,mandatory);
 
256
decode_disp('AttributeDescriptionList',Data) -> 'dec_AttributeDescriptionList'(Data,mandatory);
 
257
decode_disp('AttributeValue',Data) -> 'dec_AttributeValue'(Data,mandatory);
 
258
decode_disp('AttributeValueAssertion',Data) -> 'dec_AttributeValueAssertion'(Data,mandatory);
 
259
decode_disp('AssertionValue',Data) -> 'dec_AssertionValue'(Data,mandatory);
 
260
decode_disp('Attribute',Data) -> 'dec_Attribute'(Data,mandatory);
 
261
decode_disp('MatchingRuleId',Data) -> 'dec_MatchingRuleId'(Data,mandatory);
 
262
decode_disp('LDAPResult',Data) -> 'dec_LDAPResult'(Data,mandatory);
 
263
decode_disp('Referral',Data) -> 'dec_Referral'(Data,mandatory);
 
264
decode_disp('LDAPURL',Data) -> 'dec_LDAPURL'(Data,mandatory);
 
265
decode_disp('Controls',Data) -> 'dec_Controls'(Data,mandatory);
 
266
decode_disp('Control',Data) -> 'dec_Control'(Data,mandatory);
 
267
decode_disp('BindRequest',Data) -> 'dec_BindRequest'(Data,mandatory);
 
268
decode_disp('AuthenticationChoice',Data) -> 'dec_AuthenticationChoice'(Data,mandatory);
 
269
decode_disp('SaslCredentials',Data) -> 'dec_SaslCredentials'(Data,mandatory);
 
270
decode_disp('BindResponse',Data) -> 'dec_BindResponse'(Data,mandatory);
 
271
decode_disp('UnbindRequest',Data) -> 'dec_UnbindRequest'(Data,mandatory);
 
272
decode_disp('SearchRequest',Data) -> 'dec_SearchRequest'(Data,mandatory);
 
273
decode_disp('Filter',Data) -> 'dec_Filter'(Data,mandatory);
 
274
decode_disp('SubstringFilter',Data) -> 'dec_SubstringFilter'(Data,mandatory);
 
275
decode_disp('MatchingRuleAssertion',Data) -> 'dec_MatchingRuleAssertion'(Data,mandatory);
 
276
decode_disp('SearchResultEntry',Data) -> 'dec_SearchResultEntry'(Data,mandatory);
 
277
decode_disp('PartialAttributeList',Data) -> 'dec_PartialAttributeList'(Data,mandatory);
 
278
decode_disp('SearchResultReference',Data) -> 'dec_SearchResultReference'(Data,mandatory);
 
279
decode_disp('SearchResultDone',Data) -> 'dec_SearchResultDone'(Data,mandatory);
 
280
decode_disp('ModifyRequest',Data) -> 'dec_ModifyRequest'(Data,mandatory);
 
281
decode_disp('AttributeTypeAndValues',Data) -> 'dec_AttributeTypeAndValues'(Data,mandatory);
 
282
decode_disp('ModifyResponse',Data) -> 'dec_ModifyResponse'(Data,mandatory);
 
283
decode_disp('AddRequest',Data) -> 'dec_AddRequest'(Data,mandatory);
 
284
decode_disp('AttributeList',Data) -> 'dec_AttributeList'(Data,mandatory);
 
285
decode_disp('AddResponse',Data) -> 'dec_AddResponse'(Data,mandatory);
 
286
decode_disp('DelRequest',Data) -> 'dec_DelRequest'(Data,mandatory);
 
287
decode_disp('DelResponse',Data) -> 'dec_DelResponse'(Data,mandatory);
 
288
decode_disp('ModifyDNRequest',Data) -> 'dec_ModifyDNRequest'(Data,mandatory);
 
289
decode_disp('ModifyDNResponse',Data) -> 'dec_ModifyDNResponse'(Data,mandatory);
 
290
decode_disp('CompareRequest',Data) -> 'dec_CompareRequest'(Data,mandatory);
 
291
decode_disp('CompareResponse',Data) -> 'dec_CompareResponse'(Data,mandatory);
 
292
decode_disp('AbandonRequest',Data) -> 'dec_AbandonRequest'(Data,mandatory);
 
293
decode_disp('ExtendedRequest',Data) -> 'dec_ExtendedRequest'(Data,mandatory);
 
294
decode_disp('ExtendedResponse',Data) -> 'dec_ExtendedResponse'(Data,mandatory);
 
295
decode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).
 
296
 
 
297
 
 
298
 
 
299
wrap_encode(Bytes) when list(Bytes) ->
 
300
   binary_to_list(list_to_binary(Bytes));
 
301
wrap_encode(Bytes) when binary(Bytes) ->
 
302
   binary_to_list(Bytes);
 
303
wrap_encode(Bytes) -> Bytes.
 
304
 
 
305
wrap_decode(Bytes) when list(Bytes) ->
 
306
   list_to_binary(Bytes);
 
307
wrap_decode(Bytes) -> Bytes.
 
308
 
 
309
 
 
310
info() ->
 
311
   case ?MODULE:module_info() of
 
312
      MI when is_list(MI) ->
 
313
         case lists:keysearch(attributes,1,MI) of
 
314
            {value,{_,Attributes}} when is_list(Attributes) ->
 
315
               case lists:keysearch(asn1_info,1,Attributes) of
 
316
                  {value,{_,Info}} when is_list(Info) ->
 
317
                     Info;
 
318
                  _ ->
 
319
                     []
 
320
               end;
 
321
            _ ->
 
322
               []
 
323
         end
 
324
   end.
 
325
 
 
326
 
 
327
%%================================
 
328
%%  LDAPMessage
 
329
%%================================
 
330
'enc_LDAPMessage'(Val, TagIn) ->
 
331
 
 
332
%%-------------------------------------------------
 
333
%% attribute number 1 with type INTEGER
 
334
%%-------------------------------------------------
 
335
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,messageID), []),
 
336
 
 
337
%%-------------------------------------------------
 
338
%% attribute number 2 with type CHOICE
 
339
%%-------------------------------------------------
 
340
   {EncBytes2,EncLen2} = 'enc_LDAPMessage_protocolOp'(?RT_BER:cindex(3,Val,protocolOp), []),
 
341
 
 
342
%%-------------------------------------------------
 
343
%% attribute number 3   External ELDAPv3:Controls OPTIONAL
 
344
%%-------------------------------------------------
 
345
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,controls) of
 
346
         asn1_NOVALUE -> {<<>>,0};
 
347
         _ ->
 
348
            'enc_Controls'(?RT_BER:cindex(4,Val,controls), [{tag,128,0,'IMPLICIT',32}])
 
349
       end,
 
350
 
 
351
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
 
352
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
 
353
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
354
 
 
355
 
 
356
 
 
357
%%================================
 
358
%%  LDAPMessage_protocolOp
 
359
%%================================
 
360
 
 
361
'enc_LDAPMessage_protocolOp'({'LDAPMessage_protocolOp',Val}, TagIn) ->
 
362
   'enc_LDAPMessage_protocolOp'(Val, TagIn);
 
363
 
 
364
'enc_LDAPMessage_protocolOp'(Val, TagIn) ->
 
365
      {EncBytes,EncLen} = case element(1,Val) of
 
366
      bindRequest ->
 
367
         'enc_BindRequest'(element(2,Val), []);
 
368
      bindResponse ->
 
369
         'enc_BindResponse'(element(2,Val), []);
 
370
      unbindRequest ->
 
371
         ?RT_BER:encode_null(element(2,Val), [{tag,64,2,'IMPLICIT',32}]);
 
372
      searchRequest ->
 
373
         'enc_SearchRequest'(element(2,Val), []);
 
374
      searchResEntry ->
 
375
         'enc_SearchResultEntry'(element(2,Val), []);
 
376
      searchResDone ->
 
377
         'enc_SearchResultDone'(element(2,Val), []);
 
378
      searchResRef ->
 
379
         'enc_SearchResultReference'(element(2,Val), []);
 
380
      modifyRequest ->
 
381
         'enc_ModifyRequest'(element(2,Val), []);
 
382
      modifyResponse ->
 
383
         'enc_ModifyResponse'(element(2,Val), []);
 
384
      addRequest ->
 
385
         'enc_AddRequest'(element(2,Val), []);
 
386
      addResponse ->
 
387
         'enc_AddResponse'(element(2,Val), []);
 
388
      delRequest ->
 
389
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,64,10,'IMPLICIT',32}]);
 
390
      delResponse ->
 
391
         'enc_DelResponse'(element(2,Val), []);
 
392
      modDNRequest ->
 
393
         'enc_ModifyDNRequest'(element(2,Val), []);
 
394
      modDNResponse ->
 
395
         'enc_ModifyDNResponse'(element(2,Val), []);
 
396
      compareRequest ->
 
397
         'enc_CompareRequest'(element(2,Val), []);
 
398
      compareResponse ->
 
399
         'enc_CompareResponse'(element(2,Val), []);
 
400
      abandonRequest ->
 
401
         ?RT_BER:encode_integer([], element(2,Val), [{tag,64,16,'IMPLICIT',32}]);
 
402
      extendedReq ->
 
403
         'enc_ExtendedRequest'(element(2,Val), []);
 
404
      extendedResp ->
 
405
         'enc_ExtendedResponse'(element(2,Val), []);
 
406
      Else -> 
 
407
         exit({error,{asn1,{invalid_choice_type,Else}}})
 
408
   end,
 
409
 
 
410
?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
 
411
 
 
412
 
 
413
'dec_LDAPMessage_protocolOp'(Bytes, OptOrMand, TagIn) ->
 
414
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
 
415
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
 
416
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
 
417
   case Bytes1 of
 
418
 
 
419
%% 'bindRequest'
 
420
      <<1:2,_:1,0:5,_/binary>> ->
 
421
         {Dec, Rest, RbCho} = 'dec_BindRequest'(Bytes1, mandatory, []),
 
422
         {{bindRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
423
 
 
424
 
 
425
%% 'bindResponse'
 
426
      <<1:2,_:1,1:5,_/binary>> ->
 
427
         {Dec, Rest, RbCho} = 'dec_BindResponse'(Bytes1, mandatory, []),
 
428
         {{bindResponse, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
429
 
 
430
 
 
431
%% 'unbindRequest'
 
432
      <<1:2,_:1,2:5,_/binary>> ->
 
433
         {Dec, Rest, RbCho} = ?RT_BER:decode_null(Bytes1,[{tag,64,2,'IMPLICIT',32}], mandatory),
 
434
         {{unbindRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
435
 
 
436
 
 
437
%% 'searchRequest'
 
438
      <<1:2,_:1,3:5,_/binary>> ->
 
439
         {Dec, Rest, RbCho} = 'dec_SearchRequest'(Bytes1, mandatory, []),
 
440
         {{searchRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
441
 
 
442
 
 
443
%% 'searchResEntry'
 
444
      <<1:2,_:1,4:5,_/binary>> ->
 
445
         {Dec, Rest, RbCho} = 'dec_SearchResultEntry'(Bytes1, mandatory, []),
 
446
         {{searchResEntry, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
447
 
 
448
 
 
449
%% 'searchResDone'
 
450
      <<1:2,_:1,5:5,_/binary>> ->
 
451
         {Dec, Rest, RbCho} = 'dec_SearchResultDone'(Bytes1, mandatory, []),
 
452
         {{searchResDone, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
453
 
 
454
 
 
455
%% 'searchResRef'
 
456
      <<1:2,_:1,19:5,_/binary>> ->
 
457
         {Dec, Rest, RbCho} = 'dec_SearchResultReference'(Bytes1, mandatory, []),
 
458
         {{searchResRef, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
459
 
 
460
 
 
461
%% 'modifyRequest'
 
462
      <<1:2,_:1,6:5,_/binary>> ->
 
463
         {Dec, Rest, RbCho} = 'dec_ModifyRequest'(Bytes1, mandatory, []),
 
464
         {{modifyRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
465
 
 
466
 
 
467
%% 'modifyResponse'
 
468
      <<1:2,_:1,7:5,_/binary>> ->
 
469
         {Dec, Rest, RbCho} = 'dec_ModifyResponse'(Bytes1, mandatory, []),
 
470
         {{modifyResponse, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
471
 
 
472
 
 
473
%% 'addRequest'
 
474
      <<1:2,_:1,8:5,_/binary>> ->
 
475
         {Dec, Rest, RbCho} = 'dec_AddRequest'(Bytes1, mandatory, []),
 
476
         {{addRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
477
 
 
478
 
 
479
%% 'addResponse'
 
480
      <<1:2,_:1,9:5,_/binary>> ->
 
481
         {Dec, Rest, RbCho} = 'dec_AddResponse'(Bytes1, mandatory, []),
 
482
         {{addResponse, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
483
 
 
484
 
 
485
%% 'delRequest'
 
486
      <<1:2,_:1,10:5,_/binary>> ->
 
487
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,64,10,'IMPLICIT',32}], no_length, mandatory),
 
488
         {{delRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
489
 
 
490
 
 
491
%% 'delResponse'
 
492
      <<1:2,_:1,11:5,_/binary>> ->
 
493
         {Dec, Rest, RbCho} = 'dec_DelResponse'(Bytes1, mandatory, []),
 
494
         {{delResponse, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
495
 
 
496
 
 
497
%% 'modDNRequest'
 
498
      <<1:2,_:1,12:5,_/binary>> ->
 
499
         {Dec, Rest, RbCho} = 'dec_ModifyDNRequest'(Bytes1, mandatory, []),
 
500
         {{modDNRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
501
 
 
502
 
 
503
%% 'modDNResponse'
 
504
      <<1:2,_:1,13:5,_/binary>> ->
 
505
         {Dec, Rest, RbCho} = 'dec_ModifyDNResponse'(Bytes1, mandatory, []),
 
506
         {{modDNResponse, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
507
 
 
508
 
 
509
%% 'compareRequest'
 
510
      <<1:2,_:1,14:5,_/binary>> ->
 
511
         {Dec, Rest, RbCho} = 'dec_CompareRequest'(Bytes1, mandatory, []),
 
512
         {{compareRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
513
 
 
514
 
 
515
%% 'compareResponse'
 
516
      <<1:2,_:1,15:5,_/binary>> ->
 
517
         {Dec, Rest, RbCho} = 'dec_CompareResponse'(Bytes1, mandatory, []),
 
518
         {{compareResponse, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
519
 
 
520
 
 
521
%% 'abandonRequest'
 
522
      <<1:2,_:1,16:5,_/binary>> ->
 
523
         {Dec, Rest, RbCho} = ?RT_BER:decode_integer(Bytes1,{0,2147483647},[{tag,64,16,'IMPLICIT',32}], mandatory),
 
524
         {{abandonRequest, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
525
 
 
526
 
 
527
%% 'extendedReq'
 
528
      <<1:2,_:1,23:5,_/binary>> ->
 
529
         {Dec, Rest, RbCho} = 'dec_ExtendedRequest'(Bytes1, mandatory, []),
 
530
         {{extendedReq, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
531
 
 
532
 
 
533
%% 'extendedResp'
 
534
      <<1:2,_:1,24:5,_/binary>> ->
 
535
         {Dec, Rest, RbCho} = 'dec_ExtendedResponse'(Bytes1, mandatory, []),
 
536
         {{extendedResp, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
537
 
 
538
      Else -> 
 
539
         case OptOrMand of
 
540
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
 
541
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
 
542
         end
 
543
   end.
 
544
 
 
545
 
 
546
'dec_LDAPMessage'(Bytes, OptOrMand) ->
 
547
   'dec_LDAPMessage'(Bytes, OptOrMand, []).
 
548
 
 
549
'dec_LDAPMessage'(Bytes, OptOrMand, TagIn) ->
 
550
   %%-------------------------------------------------
 
551
   %% decode tag and length 
 
552
   %%-------------------------------------------------
 
553
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
554
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
555
 
 
556
%%-------------------------------------------------
 
557
%% attribute number 1 with type INTEGER
 
558
%%-------------------------------------------------
 
559
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,2147483647},[], mandatory),
 
560
 
 
561
%%-------------------------------------------------
 
562
%% attribute number 2 with type CHOICE
 
563
%%-------------------------------------------------
 
564
   {Term2,Bytes4,Rb3} = 'dec_LDAPMessage_protocolOp'(Bytes3, mandatory, []),
 
565
 
 
566
%%-------------------------------------------------
 
567
%% attribute number 3   External ELDAPv3:Controls OPTIONAL
 
568
%%-------------------------------------------------
 
569
   {Term3,Bytes5,Rb4} = case Bytes4 of
 
570
<<2:2,_:1,0:5,_/binary>> ->
 
571
'dec_Controls'(Bytes4, opt_or_default, [{tag,128,0,'IMPLICIT',32}]);
 
572
_ ->
 
573
{ asn1_NOVALUE, Bytes4, 0 }
 
574
end,
 
575
 
 
576
   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
 
577
   {{'LDAPMessage', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.
 
578
 
 
579
 
 
580
%%================================
 
581
%%  MessageID
 
582
%%================================
 
583
 
 
584
'enc_MessageID'({'MessageID',Val}, TagIn) ->
 
585
   'enc_MessageID'(Val, TagIn);
 
586
 
 
587
'enc_MessageID'(Val, TagIn) ->
 
588
?RT_BER:encode_integer([], Val, TagIn ++ []).
 
589
 
 
590
 
 
591
'dec_MessageID'(Bytes, OptOrMand) ->
 
592
   'dec_MessageID'(Bytes, OptOrMand, []).
 
593
 
 
594
'dec_MessageID'(Bytes, OptOrMand, TagIn) ->
 
595
?RT_BER:decode_integer(Bytes,{0,2147483647},TagIn++[], OptOrMand).
 
596
 
 
597
 
 
598
 
 
599
%%================================
 
600
%%  LDAPString
 
601
%%================================
 
602
 
 
603
'enc_LDAPString'({'LDAPString',Val}, TagIn) ->
 
604
   'enc_LDAPString'(Val, TagIn);
 
605
 
 
606
'enc_LDAPString'(Val, TagIn) ->
 
607
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
608
 
 
609
 
 
610
'dec_LDAPString'(Bytes, OptOrMand) ->
 
611
   'dec_LDAPString'(Bytes, OptOrMand, []).
 
612
 
 
613
'dec_LDAPString'(Bytes, OptOrMand, TagIn) ->
 
614
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
615
 
 
616
 
 
617
 
 
618
%%================================
 
619
%%  LDAPOID
 
620
%%================================
 
621
 
 
622
'enc_LDAPOID'({'LDAPOID',Val}, TagIn) ->
 
623
   'enc_LDAPOID'(Val, TagIn);
 
624
 
 
625
'enc_LDAPOID'(Val, TagIn) ->
 
626
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
627
 
 
628
 
 
629
'dec_LDAPOID'(Bytes, OptOrMand) ->
 
630
   'dec_LDAPOID'(Bytes, OptOrMand, []).
 
631
 
 
632
'dec_LDAPOID'(Bytes, OptOrMand, TagIn) ->
 
633
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
634
 
 
635
 
 
636
 
 
637
%%================================
 
638
%%  LDAPDN
 
639
%%================================
 
640
 
 
641
'enc_LDAPDN'({'LDAPDN',Val}, TagIn) ->
 
642
   'enc_LDAPDN'(Val, TagIn);
 
643
 
 
644
'enc_LDAPDN'(Val, TagIn) ->
 
645
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
646
 
 
647
 
 
648
'dec_LDAPDN'(Bytes, OptOrMand) ->
 
649
   'dec_LDAPDN'(Bytes, OptOrMand, []).
 
650
 
 
651
'dec_LDAPDN'(Bytes, OptOrMand, TagIn) ->
 
652
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
653
 
 
654
 
 
655
 
 
656
%%================================
 
657
%%  RelativeLDAPDN
 
658
%%================================
 
659
 
 
660
'enc_RelativeLDAPDN'({'RelativeLDAPDN',Val}, TagIn) ->
 
661
   'enc_RelativeLDAPDN'(Val, TagIn);
 
662
 
 
663
'enc_RelativeLDAPDN'(Val, TagIn) ->
 
664
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
665
 
 
666
 
 
667
'dec_RelativeLDAPDN'(Bytes, OptOrMand) ->
 
668
   'dec_RelativeLDAPDN'(Bytes, OptOrMand, []).
 
669
 
 
670
'dec_RelativeLDAPDN'(Bytes, OptOrMand, TagIn) ->
 
671
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
672
 
 
673
 
 
674
 
 
675
%%================================
 
676
%%  AttributeType
 
677
%%================================
 
678
 
 
679
'enc_AttributeType'({'AttributeType',Val}, TagIn) ->
 
680
   'enc_AttributeType'(Val, TagIn);
 
681
 
 
682
'enc_AttributeType'(Val, TagIn) ->
 
683
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
684
 
 
685
 
 
686
'dec_AttributeType'(Bytes, OptOrMand) ->
 
687
   'dec_AttributeType'(Bytes, OptOrMand, []).
 
688
 
 
689
'dec_AttributeType'(Bytes, OptOrMand, TagIn) ->
 
690
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
691
 
 
692
 
 
693
 
 
694
%%================================
 
695
%%  AttributeDescription
 
696
%%================================
 
697
 
 
698
'enc_AttributeDescription'({'AttributeDescription',Val}, TagIn) ->
 
699
   'enc_AttributeDescription'(Val, TagIn);
 
700
 
 
701
'enc_AttributeDescription'(Val, TagIn) ->
 
702
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
703
 
 
704
 
 
705
'dec_AttributeDescription'(Bytes, OptOrMand) ->
 
706
   'dec_AttributeDescription'(Bytes, OptOrMand, []).
 
707
 
 
708
'dec_AttributeDescription'(Bytes, OptOrMand, TagIn) ->
 
709
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
710
 
 
711
 
 
712
 
 
713
%%================================
 
714
%%  AttributeDescriptionList
 
715
%%================================
 
716
 
 
717
'enc_AttributeDescriptionList'({'AttributeDescriptionList',Val}, TagIn) ->
 
718
   'enc_AttributeDescriptionList'(Val, TagIn);
 
719
 
 
720
'enc_AttributeDescriptionList'(Val, TagIn) ->
 
721
   {EncBytes,EncLen} = 'enc_AttributeDescriptionList_components'(Val,[],0),
 
722
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
723
 
 
724
'enc_AttributeDescriptionList_components'([], AccBytes, AccLen) -> 
 
725
   {lists:reverse(AccBytes),AccLen};
 
726
 
 
727
'enc_AttributeDescriptionList_components'([H|T],AccBytes, AccLen) ->
 
728
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
729
   'enc_AttributeDescriptionList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
730
 
 
731
 
 
732
 
 
733
'dec_AttributeDescriptionList'(Bytes, OptOrMand) ->
 
734
   'dec_AttributeDescriptionList'(Bytes, OptOrMand, []).
 
735
 
 
736
'dec_AttributeDescriptionList'(Bytes, OptOrMand, TagIn) ->
 
737
   %%-------------------------------------------------
 
738
   %% decode tag and length 
 
739
   %%-------------------------------------------------
 
740
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
741
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
742
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
743
end, [], []).
 
744
 
 
745
 
 
746
 
 
747
 
 
748
%%================================
 
749
%%  AttributeValue
 
750
%%================================
 
751
 
 
752
'enc_AttributeValue'({'AttributeValue',Val}, TagIn) ->
 
753
   'enc_AttributeValue'(Val, TagIn);
 
754
 
 
755
'enc_AttributeValue'(Val, TagIn) ->
 
756
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
757
 
 
758
 
 
759
'dec_AttributeValue'(Bytes, OptOrMand) ->
 
760
   'dec_AttributeValue'(Bytes, OptOrMand, []).
 
761
 
 
762
'dec_AttributeValue'(Bytes, OptOrMand, TagIn) ->
 
763
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
764
 
 
765
 
 
766
 
 
767
%%================================
 
768
%%  AttributeValueAssertion
 
769
%%================================
 
770
'enc_AttributeValueAssertion'(Val, TagIn) ->
 
771
 
 
772
%%-------------------------------------------------
 
773
%% attribute number 1 with type OCTET STRING
 
774
%%-------------------------------------------------
 
775
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,attributeDesc), []),
 
776
 
 
777
%%-------------------------------------------------
 
778
%% attribute number 2 with type OCTET STRING
 
779
%%-------------------------------------------------
 
780
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,assertionValue), []),
 
781
 
 
782
   BytesSoFar = [EncBytes1, EncBytes2],
 
783
  LenSoFar = EncLen1 + EncLen2,
 
784
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
785
 
 
786
 
 
787
'dec_AttributeValueAssertion'(Bytes, OptOrMand) ->
 
788
   'dec_AttributeValueAssertion'(Bytes, OptOrMand, []).
 
789
 
 
790
'dec_AttributeValueAssertion'(Bytes, OptOrMand, TagIn) ->
 
791
   %%-------------------------------------------------
 
792
   %% decode tag and length 
 
793
   %%-------------------------------------------------
 
794
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
795
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
796
 
 
797
%%-------------------------------------------------
 
798
%% attribute number 1 with type OCTET STRING
 
799
%%-------------------------------------------------
 
800
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
801
 
 
802
%%-------------------------------------------------
 
803
%% attribute number 2 with type OCTET STRING
 
804
%%-------------------------------------------------
 
805
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
 
806
 
 
807
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
808
   {{'AttributeValueAssertion', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
809
 
 
810
 
 
811
%%================================
 
812
%%  AssertionValue
 
813
%%================================
 
814
 
 
815
'enc_AssertionValue'({'AssertionValue',Val}, TagIn) ->
 
816
   'enc_AssertionValue'(Val, TagIn);
 
817
 
 
818
'enc_AssertionValue'(Val, TagIn) ->
 
819
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
820
 
 
821
 
 
822
'dec_AssertionValue'(Bytes, OptOrMand) ->
 
823
   'dec_AssertionValue'(Bytes, OptOrMand, []).
 
824
 
 
825
'dec_AssertionValue'(Bytes, OptOrMand, TagIn) ->
 
826
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
827
 
 
828
 
 
829
 
 
830
%%================================
 
831
%%  Attribute
 
832
%%================================
 
833
'enc_Attribute'(Val, TagIn) ->
 
834
 
 
835
%%-------------------------------------------------
 
836
%% attribute number 1 with type OCTET STRING
 
837
%%-------------------------------------------------
 
838
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
 
839
 
 
840
%%-------------------------------------------------
 
841
%% attribute number 2 with type SET OF
 
842
%%-------------------------------------------------
 
843
   {EncBytes2,EncLen2} = 'enc_Attribute_vals'(?RT_BER:cindex(3,Val,vals), []),
 
844
 
 
845
   BytesSoFar = [EncBytes1, EncBytes2],
 
846
  LenSoFar = EncLen1 + EncLen2,
 
847
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
848
 
 
849
 
 
850
 
 
851
%%================================
 
852
%%  Attribute_vals
 
853
%%================================
 
854
 
 
855
'enc_Attribute_vals'({'Attribute_vals',Val}, TagIn) ->
 
856
   'enc_Attribute_vals'(Val, TagIn);
 
857
 
 
858
'enc_Attribute_vals'(Val, TagIn) ->
 
859
      {EncBytes,EncLen} = 'enc_Attribute_vals_components'(Val,[],0),
 
860
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
 
861
 
 
862
'enc_Attribute_vals_components'([], AccBytes, AccLen) -> 
 
863
   {lists:reverse(AccBytes),AccLen};
 
864
 
 
865
'enc_Attribute_vals_components'([H|T],AccBytes, AccLen) ->
 
866
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
867
   'enc_Attribute_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
868
 
 
869
'dec_Attribute_vals'(Bytes, OptOrMand, TagIn) ->
 
870
   %%-------------------------------------------------
 
871
   %% decode tag and length 
 
872
   %%-------------------------------------------------
 
873
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
 
874
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
875
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
876
end, [], []).
 
877
 
 
878
 
 
879
 
 
880
 
 
881
'dec_Attribute'(Bytes, OptOrMand) ->
 
882
   'dec_Attribute'(Bytes, OptOrMand, []).
 
883
 
 
884
'dec_Attribute'(Bytes, OptOrMand, TagIn) ->
 
885
   %%-------------------------------------------------
 
886
   %% decode tag and length 
 
887
   %%-------------------------------------------------
 
888
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
889
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
890
 
 
891
%%-------------------------------------------------
 
892
%% attribute number 1 with type OCTET STRING
 
893
%%-------------------------------------------------
 
894
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
895
 
 
896
%%-------------------------------------------------
 
897
%% attribute number 2 with type SET OF
 
898
%%-------------------------------------------------
 
899
   {Term2,Bytes4,Rb3} = 'dec_Attribute_vals'(Bytes3, mandatory, []),
 
900
 
 
901
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
902
   {{'Attribute', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
903
 
 
904
 
 
905
%%================================
 
906
%%  MatchingRuleId
 
907
%%================================
 
908
 
 
909
'enc_MatchingRuleId'({'MatchingRuleId',Val}, TagIn) ->
 
910
   'enc_MatchingRuleId'(Val, TagIn);
 
911
 
 
912
'enc_MatchingRuleId'(Val, TagIn) ->
 
913
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
914
 
 
915
 
 
916
'dec_MatchingRuleId'(Bytes, OptOrMand) ->
 
917
   'dec_MatchingRuleId'(Bytes, OptOrMand, []).
 
918
 
 
919
'dec_MatchingRuleId'(Bytes, OptOrMand, TagIn) ->
 
920
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
921
 
 
922
 
 
923
 
 
924
%%================================
 
925
%%  LDAPResult
 
926
%%================================
 
927
'enc_LDAPResult'(Val, TagIn) ->
 
928
 
 
929
%%-------------------------------------------------
 
930
%% attribute number 1 with type ENUMERATED
 
931
%%-------------------------------------------------
 
932
   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,resultCode) of {_,_}->element(2,?RT_BER:cindex(2,Val,resultCode));_->?RT_BER:cindex(2,Val,resultCode) end) of
 
933
success -> ?RT_BER:encode_enumerated(0,[]);
 
934
operationsError -> ?RT_BER:encode_enumerated(1,[]);
 
935
protocolError -> ?RT_BER:encode_enumerated(2,[]);
 
936
timeLimitExceeded -> ?RT_BER:encode_enumerated(3,[]);
 
937
sizeLimitExceeded -> ?RT_BER:encode_enumerated(4,[]);
 
938
compareFalse -> ?RT_BER:encode_enumerated(5,[]);
 
939
compareTrue -> ?RT_BER:encode_enumerated(6,[]);
 
940
authMethodNotSupported -> ?RT_BER:encode_enumerated(7,[]);
 
941
strongAuthRequired -> ?RT_BER:encode_enumerated(8,[]);
 
942
referral -> ?RT_BER:encode_enumerated(10,[]);
 
943
adminLimitExceeded -> ?RT_BER:encode_enumerated(11,[]);
 
944
unavailableCriticalExtension -> ?RT_BER:encode_enumerated(12,[]);
 
945
confidentialityRequired -> ?RT_BER:encode_enumerated(13,[]);
 
946
saslBindInProgress -> ?RT_BER:encode_enumerated(14,[]);
 
947
noSuchAttribute -> ?RT_BER:encode_enumerated(16,[]);
 
948
undefinedAttributeType -> ?RT_BER:encode_enumerated(17,[]);
 
949
inappropriateMatching -> ?RT_BER:encode_enumerated(18,[]);
 
950
constraintViolation -> ?RT_BER:encode_enumerated(19,[]);
 
951
attributeOrValueExists -> ?RT_BER:encode_enumerated(20,[]);
 
952
invalidAttributeSyntax -> ?RT_BER:encode_enumerated(21,[]);
 
953
noSuchObject -> ?RT_BER:encode_enumerated(32,[]);
 
954
aliasProblem -> ?RT_BER:encode_enumerated(33,[]);
 
955
invalidDNSyntax -> ?RT_BER:encode_enumerated(34,[]);
 
956
aliasDereferencingProblem -> ?RT_BER:encode_enumerated(36,[]);
 
957
inappropriateAuthentication -> ?RT_BER:encode_enumerated(48,[]);
 
958
invalidCredentials -> ?RT_BER:encode_enumerated(49,[]);
 
959
insufficientAccessRights -> ?RT_BER:encode_enumerated(50,[]);
 
960
busy -> ?RT_BER:encode_enumerated(51,[]);
 
961
unavailable -> ?RT_BER:encode_enumerated(52,[]);
 
962
unwillingToPerform -> ?RT_BER:encode_enumerated(53,[]);
 
963
loopDetect -> ?RT_BER:encode_enumerated(54,[]);
 
964
namingViolation -> ?RT_BER:encode_enumerated(64,[]);
 
965
objectClassViolation -> ?RT_BER:encode_enumerated(65,[]);
 
966
notAllowedOnNonLeaf -> ?RT_BER:encode_enumerated(66,[]);
 
967
notAllowedOnRDN -> ?RT_BER:encode_enumerated(67,[]);
 
968
entryAlreadyExists -> ?RT_BER:encode_enumerated(68,[]);
 
969
objectClassModsProhibited -> ?RT_BER:encode_enumerated(69,[]);
 
970
affectsMultipleDSAs -> ?RT_BER:encode_enumerated(71,[]);
 
971
other -> ?RT_BER:encode_enumerated(80,[]);
 
972
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
 
973
end,
 
974
 
 
975
%%-------------------------------------------------
 
976
%% attribute number 2 with type OCTET STRING
 
977
%%-------------------------------------------------
 
978
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,matchedDN), []),
 
979
 
 
980
%%-------------------------------------------------
 
981
%% attribute number 3 with type OCTET STRING
 
982
%%-------------------------------------------------
 
983
   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,errorMessage), []),
 
984
 
 
985
%%-------------------------------------------------
 
986
%% attribute number 4   External ELDAPv3:Referral OPTIONAL
 
987
%%-------------------------------------------------
 
988
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,referral) of
 
989
         asn1_NOVALUE -> {<<>>,0};
 
990
         _ ->
 
991
            'enc_Referral'(?RT_BER:cindex(5,Val,referral), [{tag,128,3,'IMPLICIT',32}])
 
992
       end,
 
993
 
 
994
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
 
995
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
 
996
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
997
 
 
998
 
 
999
'dec_LDAPResult'(Bytes, OptOrMand) ->
 
1000
   'dec_LDAPResult'(Bytes, OptOrMand, []).
 
1001
 
 
1002
'dec_LDAPResult'(Bytes, OptOrMand, TagIn) ->
 
1003
   %%-------------------------------------------------
 
1004
   %% decode tag and length 
 
1005
   %%-------------------------------------------------
 
1006
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1007
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1008
 
 
1009
%%-------------------------------------------------
 
1010
%% attribute number 1 with type ENUMERATED
 
1011
%%-------------------------------------------------
 
1012
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{success,0},{operationsError,1},{protocolError,2},{timeLimitExceeded,3},{sizeLimitExceeded,4},{compareFalse,5},{compareTrue,6},{authMethodNotSupported,7},{strongAuthRequired,8},{referral,10},{adminLimitExceeded,11},{unavailableCriticalExtension,12},{confidentialityRequired,13},{saslBindInProgress,14},{noSuchAttribute,16},{undefinedAttributeType,17},{inappropriateMatching,18},{constraintViolation,19},{attributeOrValueExists,20},{invalidAttributeSyntax,21},{noSuchObject,32},{aliasProblem,33},{invalidDNSyntax,34},{aliasDereferencingProblem,36},{inappropriateAuthentication,48},{invalidCredentials,49},{insufficientAccessRights,50},{busy,51},{unavailable,52},{unwillingToPerform,53},{loopDetect,54},{namingViolation,64},{objectClassViolation,65},{notAllowedOnNonLeaf,66},{notAllowedOnRDN,67},{entryAlreadyExists,68},{objectClassModsProhibited,69},{affectsMultipleDSAs,71},{other,80}],[], mandatory),
 
1013
 
 
1014
%%-------------------------------------------------
 
1015
%% attribute number 2 with type OCTET STRING
 
1016
%%-------------------------------------------------
 
1017
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
 
1018
 
 
1019
%%-------------------------------------------------
 
1020
%% attribute number 3 with type OCTET STRING
 
1021
%%-------------------------------------------------
 
1022
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory),
 
1023
 
 
1024
%%-------------------------------------------------
 
1025
%% attribute number 4   External ELDAPv3:Referral OPTIONAL
 
1026
%%-------------------------------------------------
 
1027
   {Term4,Bytes6,Rb5} = case Bytes5 of
 
1028
<<2:2,_:1,3:5,_/binary>> ->
 
1029
'dec_Referral'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',32}]);
 
1030
_ ->
 
1031
{ asn1_NOVALUE, Bytes5, 0 }
 
1032
end,
 
1033
 
 
1034
   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
 
1035
   {{'LDAPResult', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.
 
1036
 
 
1037
 
 
1038
%%================================
 
1039
%%  Referral
 
1040
%%================================
 
1041
 
 
1042
'enc_Referral'({'Referral',Val}, TagIn) ->
 
1043
   'enc_Referral'(Val, TagIn);
 
1044
 
 
1045
'enc_Referral'(Val, TagIn) ->
 
1046
   {EncBytes,EncLen} = 'enc_Referral_components'(Val,[],0),
 
1047
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
1048
 
 
1049
'enc_Referral_components'([], AccBytes, AccLen) -> 
 
1050
   {lists:reverse(AccBytes),AccLen};
 
1051
 
 
1052
'enc_Referral_components'([H|T],AccBytes, AccLen) ->
 
1053
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
1054
   'enc_Referral_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
1055
 
 
1056
 
 
1057
 
 
1058
'dec_Referral'(Bytes, OptOrMand) ->
 
1059
   'dec_Referral'(Bytes, OptOrMand, []).
 
1060
 
 
1061
'dec_Referral'(Bytes, OptOrMand, TagIn) ->
 
1062
   %%-------------------------------------------------
 
1063
   %% decode tag and length 
 
1064
   %%-------------------------------------------------
 
1065
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1066
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
1067
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
1068
end, [], []).
 
1069
 
 
1070
 
 
1071
 
 
1072
 
 
1073
%%================================
 
1074
%%  LDAPURL
 
1075
%%================================
 
1076
 
 
1077
'enc_LDAPURL'({'LDAPURL',Val}, TagIn) ->
 
1078
   'enc_LDAPURL'(Val, TagIn);
 
1079
 
 
1080
'enc_LDAPURL'(Val, TagIn) ->
 
1081
?RT_BER:encode_octet_string([], Val, TagIn ++ []).
 
1082
 
 
1083
 
 
1084
'dec_LDAPURL'(Bytes, OptOrMand) ->
 
1085
   'dec_LDAPURL'(Bytes, OptOrMand, []).
 
1086
 
 
1087
'dec_LDAPURL'(Bytes, OptOrMand, TagIn) ->
 
1088
?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
 
1089
 
 
1090
 
 
1091
 
 
1092
%%================================
 
1093
%%  Controls
 
1094
%%================================
 
1095
 
 
1096
'enc_Controls'({'Controls',Val}, TagIn) ->
 
1097
   'enc_Controls'(Val, TagIn);
 
1098
 
 
1099
'enc_Controls'(Val, TagIn) ->
 
1100
   {EncBytes,EncLen} = 'enc_Controls_components'(Val,[],0),
 
1101
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
1102
 
 
1103
'enc_Controls_components'([], AccBytes, AccLen) -> 
 
1104
   {lists:reverse(AccBytes),AccLen};
 
1105
 
 
1106
'enc_Controls_components'([H|T],AccBytes, AccLen) ->
 
1107
   {EncBytes,EncLen} = 'enc_Control'(H, []),
 
1108
   'enc_Controls_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
1109
 
 
1110
 
 
1111
 
 
1112
'dec_Controls'(Bytes, OptOrMand) ->
 
1113
   'dec_Controls'(Bytes, OptOrMand, []).
 
1114
 
 
1115
'dec_Controls'(Bytes, OptOrMand, TagIn) ->
 
1116
   %%-------------------------------------------------
 
1117
   %% decode tag and length 
 
1118
   %%-------------------------------------------------
 
1119
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1120
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Control'/3, [], []).
 
1121
 
 
1122
 
 
1123
 
 
1124
 
 
1125
%%================================
 
1126
%%  Control
 
1127
%%================================
 
1128
'enc_Control'(Val, TagIn) ->
 
1129
 
 
1130
%%-------------------------------------------------
 
1131
%% attribute number 1 with type OCTET STRING
 
1132
%%-------------------------------------------------
 
1133
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,controlType), []),
 
1134
 
 
1135
%%-------------------------------------------------
 
1136
%% attribute number 2 with type BOOLEAN DEFAULT = false
 
1137
%%-------------------------------------------------
 
1138
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,criticality) of
 
1139
         asn1_DEFAULT -> {<<>>,0};
 
1140
         false -> {<<>>,0};
 
1141
         _ ->
 
1142
            ?RT_BER:encode_boolean(?RT_BER:cindex(3,Val,criticality), [])
 
1143
       end,
 
1144
 
 
1145
%%-------------------------------------------------
 
1146
%% attribute number 3 with type OCTET STRING OPTIONAL
 
1147
%%-------------------------------------------------
 
1148
   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,controlValue) of
 
1149
         asn1_NOVALUE -> {<<>>,0};
 
1150
         _ ->
 
1151
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,controlValue), [])
 
1152
       end,
 
1153
 
 
1154
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
 
1155
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
 
1156
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1157
 
 
1158
 
 
1159
'dec_Control'(Bytes, OptOrMand) ->
 
1160
   'dec_Control'(Bytes, OptOrMand, []).
 
1161
 
 
1162
'dec_Control'(Bytes, OptOrMand, TagIn) ->
 
1163
   %%-------------------------------------------------
 
1164
   %% decode tag and length 
 
1165
   %%-------------------------------------------------
 
1166
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1167
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1168
 
 
1169
%%-------------------------------------------------
 
1170
%% attribute number 1 with type OCTET STRING
 
1171
%%-------------------------------------------------
 
1172
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
1173
 
 
1174
%%-------------------------------------------------
 
1175
%% attribute number 2 with type BOOLEAN DEFAULT = false
 
1176
%%-------------------------------------------------
 
1177
   {Term2,Bytes4,Rb3} = case Bytes3 of
 
1178
<<0:2,_:1,1:5,_/binary>> ->
 
1179
?RT_BER:decode_boolean(Bytes3,[], mandatory);
 
1180
_ ->
 
1181
{false,Bytes3, 0 }
 
1182
end,
 
1183
 
 
1184
%%-------------------------------------------------
 
1185
%% attribute number 3 with type OCTET STRING OPTIONAL
 
1186
%%-------------------------------------------------
 
1187
   {Term3,Bytes5,Rb4} = case Bytes4 of
 
1188
<<0:2,_:1,4:5,_/binary>> ->
 
1189
?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory);
 
1190
_ ->
 
1191
{ asn1_NOVALUE, Bytes4, 0 }
 
1192
end,
 
1193
 
 
1194
   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
 
1195
   {{'Control', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.
 
1196
 
 
1197
 
 
1198
%%================================
 
1199
%%  BindRequest
 
1200
%%================================
 
1201
'enc_BindRequest'(Val, TagIn) ->
 
1202
 
 
1203
%%-------------------------------------------------
 
1204
%% attribute number 1 with type INTEGER
 
1205
%%-------------------------------------------------
 
1206
   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,version), []),
 
1207
 
 
1208
%%-------------------------------------------------
 
1209
%% attribute number 2 with type OCTET STRING
 
1210
%%-------------------------------------------------
 
1211
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,name), []),
 
1212
 
 
1213
%%-------------------------------------------------
 
1214
%% attribute number 3   External ELDAPv3:AuthenticationChoice
 
1215
%%-------------------------------------------------
 
1216
   {EncBytes3,EncLen3} = 'enc_AuthenticationChoice'(?RT_BER:cindex(4,Val,authentication), []),
 
1217
 
 
1218
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
 
1219
  LenSoFar = EncLen1 + EncLen2 + EncLen3,
 
1220
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,0,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1221
 
 
1222
 
 
1223
'dec_BindRequest'(Bytes, OptOrMand) ->
 
1224
   'dec_BindRequest'(Bytes, OptOrMand, []).
 
1225
 
 
1226
'dec_BindRequest'(Bytes, OptOrMand, TagIn) ->
 
1227
   %%-------------------------------------------------
 
1228
   %% decode tag and length 
 
1229
   %%-------------------------------------------------
 
1230
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,0,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1231
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1232
 
 
1233
%%-------------------------------------------------
 
1234
%% attribute number 1 with type INTEGER
 
1235
%%-------------------------------------------------
 
1236
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{1,127},[], mandatory),
 
1237
 
 
1238
%%-------------------------------------------------
 
1239
%% attribute number 2 with type OCTET STRING
 
1240
%%-------------------------------------------------
 
1241
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
 
1242
 
 
1243
%%-------------------------------------------------
 
1244
%% attribute number 3   External ELDAPv3:AuthenticationChoice
 
1245
%%-------------------------------------------------
 
1246
   {Term3,Bytes5,Rb4} = 'dec_AuthenticationChoice'(Bytes4, mandatory, []),
 
1247
 
 
1248
   {Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
 
1249
   {{'BindRequest', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.
 
1250
 
 
1251
 
 
1252
%%================================
 
1253
%%  AuthenticationChoice
 
1254
%%================================
 
1255
 
 
1256
'enc_AuthenticationChoice'({'AuthenticationChoice',Val}, TagIn) ->
 
1257
   'enc_AuthenticationChoice'(Val, TagIn);
 
1258
 
 
1259
'enc_AuthenticationChoice'(Val, TagIn) ->
 
1260
   {EncBytes,EncLen} = case element(1,Val) of
 
1261
      simple ->
 
1262
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,0,'IMPLICIT',32}]);
 
1263
      sasl ->
 
1264
         'enc_SaslCredentials'(element(2,Val), [{tag,128,3,'IMPLICIT',32}]);
 
1265
      Else -> 
 
1266
         exit({error,{asn1,{invalid_choice_type,Else}}})
 
1267
   end,
 
1268
 
 
1269
?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
 
1270
 
 
1271
 
 
1272
 
 
1273
 
 
1274
'dec_AuthenticationChoice'(Bytes, OptOrMand) ->
 
1275
   'dec_AuthenticationChoice'(Bytes, OptOrMand, []).
 
1276
 
 
1277
'dec_AuthenticationChoice'(Bytes, OptOrMand, TagIn) ->
 
1278
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
 
1279
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
 
1280
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
 
1281
   case Bytes1 of
 
1282
 
 
1283
%% 'simple'
 
1284
      <<2:2,_:1,0:5,_/binary>> ->
 
1285
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory),
 
1286
         {{simple, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1287
 
 
1288
 
 
1289
%% 'sasl'
 
1290
      <<2:2,_:1,3:5,_/binary>> ->
 
1291
         {Dec, Rest, RbCho} = 'dec_SaslCredentials'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',32}]),
 
1292
         {{sasl, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1293
 
 
1294
      Else -> 
 
1295
         case OptOrMand of
 
1296
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
 
1297
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
 
1298
         end
 
1299
   end.
 
1300
 
 
1301
 
 
1302
%%================================
 
1303
%%  SaslCredentials
 
1304
%%================================
 
1305
'enc_SaslCredentials'(Val, TagIn) ->
 
1306
 
 
1307
%%-------------------------------------------------
 
1308
%% attribute number 1 with type OCTET STRING
 
1309
%%-------------------------------------------------
 
1310
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,mechanism), []),
 
1311
 
 
1312
%%-------------------------------------------------
 
1313
%% attribute number 2 with type OCTET STRING OPTIONAL
 
1314
%%-------------------------------------------------
 
1315
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,credentials) of
 
1316
         asn1_NOVALUE -> {<<>>,0};
 
1317
         _ ->
 
1318
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,credentials), [])
 
1319
       end,
 
1320
 
 
1321
   BytesSoFar = [EncBytes1, EncBytes2],
 
1322
  LenSoFar = EncLen1 + EncLen2,
 
1323
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1324
 
 
1325
 
 
1326
'dec_SaslCredentials'(Bytes, OptOrMand) ->
 
1327
   'dec_SaslCredentials'(Bytes, OptOrMand, []).
 
1328
 
 
1329
'dec_SaslCredentials'(Bytes, OptOrMand, TagIn) ->
 
1330
   %%-------------------------------------------------
 
1331
   %% decode tag and length 
 
1332
   %%-------------------------------------------------
 
1333
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1334
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1335
 
 
1336
%%-------------------------------------------------
 
1337
%% attribute number 1 with type OCTET STRING
 
1338
%%-------------------------------------------------
 
1339
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
1340
 
 
1341
%%-------------------------------------------------
 
1342
%% attribute number 2 with type OCTET STRING OPTIONAL
 
1343
%%-------------------------------------------------
 
1344
   {Term2,Bytes4,Rb3} = case Bytes3 of
 
1345
<<0:2,_:1,4:5,_/binary>> ->
 
1346
?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory);
 
1347
_ ->
 
1348
{ asn1_NOVALUE, Bytes3, 0 }
 
1349
end,
 
1350
 
 
1351
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
1352
   {{'SaslCredentials', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
1353
 
 
1354
 
 
1355
%%================================
 
1356
%%  BindResponse
 
1357
%%================================
 
1358
'enc_BindResponse'(Val, TagIn) ->
 
1359
 
 
1360
%%-------------------------------------------------
 
1361
%% attribute number 1 with type ENUMERATED
 
1362
%%-------------------------------------------------
 
1363
   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,resultCode) of {_,_}->element(2,?RT_BER:cindex(2,Val,resultCode));_->?RT_BER:cindex(2,Val,resultCode) end) of
 
1364
success -> ?RT_BER:encode_enumerated(0,[]);
 
1365
operationsError -> ?RT_BER:encode_enumerated(1,[]);
 
1366
protocolError -> ?RT_BER:encode_enumerated(2,[]);
 
1367
timeLimitExceeded -> ?RT_BER:encode_enumerated(3,[]);
 
1368
sizeLimitExceeded -> ?RT_BER:encode_enumerated(4,[]);
 
1369
compareFalse -> ?RT_BER:encode_enumerated(5,[]);
 
1370
compareTrue -> ?RT_BER:encode_enumerated(6,[]);
 
1371
authMethodNotSupported -> ?RT_BER:encode_enumerated(7,[]);
 
1372
strongAuthRequired -> ?RT_BER:encode_enumerated(8,[]);
 
1373
referral -> ?RT_BER:encode_enumerated(10,[]);
 
1374
adminLimitExceeded -> ?RT_BER:encode_enumerated(11,[]);
 
1375
unavailableCriticalExtension -> ?RT_BER:encode_enumerated(12,[]);
 
1376
confidentialityRequired -> ?RT_BER:encode_enumerated(13,[]);
 
1377
saslBindInProgress -> ?RT_BER:encode_enumerated(14,[]);
 
1378
noSuchAttribute -> ?RT_BER:encode_enumerated(16,[]);
 
1379
undefinedAttributeType -> ?RT_BER:encode_enumerated(17,[]);
 
1380
inappropriateMatching -> ?RT_BER:encode_enumerated(18,[]);
 
1381
constraintViolation -> ?RT_BER:encode_enumerated(19,[]);
 
1382
attributeOrValueExists -> ?RT_BER:encode_enumerated(20,[]);
 
1383
invalidAttributeSyntax -> ?RT_BER:encode_enumerated(21,[]);
 
1384
noSuchObject -> ?RT_BER:encode_enumerated(32,[]);
 
1385
aliasProblem -> ?RT_BER:encode_enumerated(33,[]);
 
1386
invalidDNSyntax -> ?RT_BER:encode_enumerated(34,[]);
 
1387
aliasDereferencingProblem -> ?RT_BER:encode_enumerated(36,[]);
 
1388
inappropriateAuthentication -> ?RT_BER:encode_enumerated(48,[]);
 
1389
invalidCredentials -> ?RT_BER:encode_enumerated(49,[]);
 
1390
insufficientAccessRights -> ?RT_BER:encode_enumerated(50,[]);
 
1391
busy -> ?RT_BER:encode_enumerated(51,[]);
 
1392
unavailable -> ?RT_BER:encode_enumerated(52,[]);
 
1393
unwillingToPerform -> ?RT_BER:encode_enumerated(53,[]);
 
1394
loopDetect -> ?RT_BER:encode_enumerated(54,[]);
 
1395
namingViolation -> ?RT_BER:encode_enumerated(64,[]);
 
1396
objectClassViolation -> ?RT_BER:encode_enumerated(65,[]);
 
1397
notAllowedOnNonLeaf -> ?RT_BER:encode_enumerated(66,[]);
 
1398
notAllowedOnRDN -> ?RT_BER:encode_enumerated(67,[]);
 
1399
entryAlreadyExists -> ?RT_BER:encode_enumerated(68,[]);
 
1400
objectClassModsProhibited -> ?RT_BER:encode_enumerated(69,[]);
 
1401
affectsMultipleDSAs -> ?RT_BER:encode_enumerated(71,[]);
 
1402
other -> ?RT_BER:encode_enumerated(80,[]);
 
1403
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
 
1404
end,
 
1405
 
 
1406
%%-------------------------------------------------
 
1407
%% attribute number 2 with type OCTET STRING
 
1408
%%-------------------------------------------------
 
1409
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,matchedDN), []),
 
1410
 
 
1411
%%-------------------------------------------------
 
1412
%% attribute number 3 with type OCTET STRING
 
1413
%%-------------------------------------------------
 
1414
   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,errorMessage), []),
 
1415
 
 
1416
%%-------------------------------------------------
 
1417
%% attribute number 4   External ELDAPv3:Referral OPTIONAL
 
1418
%%-------------------------------------------------
 
1419
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,referral) of
 
1420
         asn1_NOVALUE -> {<<>>,0};
 
1421
         _ ->
 
1422
            'enc_Referral'(?RT_BER:cindex(5,Val,referral), [{tag,128,3,'IMPLICIT',32}])
 
1423
       end,
 
1424
 
 
1425
%%-------------------------------------------------
 
1426
%% attribute number 5 with type OCTET STRING OPTIONAL
 
1427
%%-------------------------------------------------
 
1428
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,serverSaslCreds) of
 
1429
         asn1_NOVALUE -> {<<>>,0};
 
1430
         _ ->
 
1431
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(6,Val,serverSaslCreds), [{tag,128,7,'IMPLICIT',32}])
 
1432
       end,
 
1433
 
 
1434
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
 
1435
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
 
1436
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,1,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1437
 
 
1438
 
 
1439
'dec_BindResponse'(Bytes, OptOrMand) ->
 
1440
   'dec_BindResponse'(Bytes, OptOrMand, []).
 
1441
 
 
1442
'dec_BindResponse'(Bytes, OptOrMand, TagIn) ->
 
1443
   %%-------------------------------------------------
 
1444
   %% decode tag and length 
 
1445
   %%-------------------------------------------------
 
1446
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,1,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1447
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1448
 
 
1449
%%-------------------------------------------------
 
1450
%% attribute number 1 with type ENUMERATED
 
1451
%%-------------------------------------------------
 
1452
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{success,0},{operationsError,1},{protocolError,2},{timeLimitExceeded,3},{sizeLimitExceeded,4},{compareFalse,5},{compareTrue,6},{authMethodNotSupported,7},{strongAuthRequired,8},{referral,10},{adminLimitExceeded,11},{unavailableCriticalExtension,12},{confidentialityRequired,13},{saslBindInProgress,14},{noSuchAttribute,16},{undefinedAttributeType,17},{inappropriateMatching,18},{constraintViolation,19},{attributeOrValueExists,20},{invalidAttributeSyntax,21},{noSuchObject,32},{aliasProblem,33},{invalidDNSyntax,34},{aliasDereferencingProblem,36},{inappropriateAuthentication,48},{invalidCredentials,49},{insufficientAccessRights,50},{busy,51},{unavailable,52},{unwillingToPerform,53},{loopDetect,54},{namingViolation,64},{objectClassViolation,65},{notAllowedOnNonLeaf,66},{notAllowedOnRDN,67},{entryAlreadyExists,68},{objectClassModsProhibited,69},{affectsMultipleDSAs,71},{other,80}],[], mandatory),
 
1453
 
 
1454
%%-------------------------------------------------
 
1455
%% attribute number 2 with type OCTET STRING
 
1456
%%-------------------------------------------------
 
1457
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
 
1458
 
 
1459
%%-------------------------------------------------
 
1460
%% attribute number 3 with type OCTET STRING
 
1461
%%-------------------------------------------------
 
1462
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory),
 
1463
 
 
1464
%%-------------------------------------------------
 
1465
%% attribute number 4   External ELDAPv3:Referral OPTIONAL
 
1466
%%-------------------------------------------------
 
1467
   {Term4,Bytes6,Rb5} = case Bytes5 of
 
1468
<<2:2,_:1,3:5,_/binary>> ->
 
1469
'dec_Referral'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',32}]);
 
1470
_ ->
 
1471
{ asn1_NOVALUE, Bytes5, 0 }
 
1472
end,
 
1473
 
 
1474
%%-------------------------------------------------
 
1475
%% attribute number 5 with type OCTET STRING OPTIONAL
 
1476
%%-------------------------------------------------
 
1477
   {Term5,Bytes7,Rb6} = case Bytes6 of
 
1478
<<2:2,_:1,7:5,_/binary>> ->
 
1479
?RT_BER:decode_octet_string(Bytes6,[],[{tag,128,7,'IMPLICIT',32}], no_length, mandatory);
 
1480
_ ->
 
1481
{ asn1_NOVALUE, Bytes6, 0 }
 
1482
end,
 
1483
 
 
1484
   {Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,noext),
 
1485
   {{'BindResponse', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.
 
1486
 
 
1487
 
 
1488
%%================================
 
1489
%%  UnbindRequest
 
1490
%%================================
 
1491
 
 
1492
'enc_UnbindRequest'({'UnbindRequest',Val}, TagIn) ->
 
1493
   'enc_UnbindRequest'(Val, TagIn);
 
1494
 
 
1495
'enc_UnbindRequest'(Val, TagIn) ->
 
1496
?RT_BER:encode_null(Val, TagIn ++ [{tag,64,2,'IMPLICIT',32}]).
 
1497
 
 
1498
 
 
1499
'dec_UnbindRequest'(Bytes, OptOrMand) ->
 
1500
   'dec_UnbindRequest'(Bytes, OptOrMand, []).
 
1501
 
 
1502
'dec_UnbindRequest'(Bytes, OptOrMand, TagIn) ->
 
1503
?RT_BER:decode_null(Bytes,TagIn++[{tag,64,2,'IMPLICIT',32}], OptOrMand).
 
1504
 
 
1505
 
 
1506
 
 
1507
%%================================
 
1508
%%  SearchRequest
 
1509
%%================================
 
1510
'enc_SearchRequest'(Val, TagIn) ->
 
1511
 
 
1512
%%-------------------------------------------------
 
1513
%% attribute number 1 with type OCTET STRING
 
1514
%%-------------------------------------------------
 
1515
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,baseObject), []),
 
1516
 
 
1517
%%-------------------------------------------------
 
1518
%% attribute number 2 with type ENUMERATED
 
1519
%%-------------------------------------------------
 
1520
   {EncBytes2,EncLen2} = case (case ?RT_BER:cindex(3,Val,scope) of {_,_}->element(2,?RT_BER:cindex(3,Val,scope));_->?RT_BER:cindex(3,Val,scope) end) of
 
1521
baseObject -> ?RT_BER:encode_enumerated(0,[]);
 
1522
singleLevel -> ?RT_BER:encode_enumerated(1,[]);
 
1523
wholeSubtree -> ?RT_BER:encode_enumerated(2,[]);
 
1524
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
 
1525
end,
 
1526
 
 
1527
%%-------------------------------------------------
 
1528
%% attribute number 3 with type ENUMERATED
 
1529
%%-------------------------------------------------
 
1530
   {EncBytes3,EncLen3} = case (case ?RT_BER:cindex(4,Val,derefAliases) of {_,_}->element(2,?RT_BER:cindex(4,Val,derefAliases));_->?RT_BER:cindex(4,Val,derefAliases) end) of
 
1531
neverDerefAliases -> ?RT_BER:encode_enumerated(0,[]);
 
1532
derefInSearching -> ?RT_BER:encode_enumerated(1,[]);
 
1533
derefFindingBaseObj -> ?RT_BER:encode_enumerated(2,[]);
 
1534
derefAlways -> ?RT_BER:encode_enumerated(3,[]);
 
1535
Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}})
 
1536
end,
 
1537
 
 
1538
%%-------------------------------------------------
 
1539
%% attribute number 4 with type INTEGER
 
1540
%%-------------------------------------------------
 
1541
   {EncBytes4,EncLen4} = ?RT_BER:encode_integer([], ?RT_BER:cindex(5,Val,sizeLimit), []),
 
1542
 
 
1543
%%-------------------------------------------------
 
1544
%% attribute number 5 with type INTEGER
 
1545
%%-------------------------------------------------
 
1546
   {EncBytes5,EncLen5} = ?RT_BER:encode_integer([], ?RT_BER:cindex(6,Val,timeLimit), []),
 
1547
 
 
1548
%%-------------------------------------------------
 
1549
%% attribute number 6 with type BOOLEAN
 
1550
%%-------------------------------------------------
 
1551
   {EncBytes6,EncLen6} = ?RT_BER:encode_boolean(?RT_BER:cindex(7,Val,typesOnly), []),
 
1552
 
 
1553
%%-------------------------------------------------
 
1554
%% attribute number 7   External ELDAPv3:Filter
 
1555
%%-------------------------------------------------
 
1556
   {EncBytes7,EncLen7} = 'enc_Filter'(?RT_BER:cindex(8,Val,filter), []),
 
1557
 
 
1558
%%-------------------------------------------------
 
1559
%% attribute number 8   External ELDAPv3:AttributeDescriptionList
 
1560
%%-------------------------------------------------
 
1561
   {EncBytes8,EncLen8} = 'enc_AttributeDescriptionList'(?RT_BER:cindex(9,Val,attributes), []),
 
1562
 
 
1563
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8],
 
1564
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8,
 
1565
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,3,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1566
 
 
1567
 
 
1568
'dec_SearchRequest'(Bytes, OptOrMand) ->
 
1569
   'dec_SearchRequest'(Bytes, OptOrMand, []).
 
1570
 
 
1571
'dec_SearchRequest'(Bytes, OptOrMand, TagIn) ->
 
1572
   %%-------------------------------------------------
 
1573
   %% decode tag and length 
 
1574
   %%-------------------------------------------------
 
1575
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,3,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1576
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1577
 
 
1578
%%-------------------------------------------------
 
1579
%% attribute number 1 with type OCTET STRING
 
1580
%%-------------------------------------------------
 
1581
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
1582
 
 
1583
%%-------------------------------------------------
 
1584
%% attribute number 2 with type ENUMERATED
 
1585
%%-------------------------------------------------
 
1586
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_enumerated(Bytes3,[],[{baseObject,0},{singleLevel,1},{wholeSubtree,2}],[], mandatory),
 
1587
 
 
1588
%%-------------------------------------------------
 
1589
%% attribute number 3 with type ENUMERATED
 
1590
%%-------------------------------------------------
 
1591
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_enumerated(Bytes4,[],[{neverDerefAliases,0},{derefInSearching,1},{derefFindingBaseObj,2},{derefAlways,3}],[], mandatory),
 
1592
 
 
1593
%%-------------------------------------------------
 
1594
%% attribute number 4 with type INTEGER
 
1595
%%-------------------------------------------------
 
1596
   {Term4,Bytes6,Rb5} = ?RT_BER:decode_integer(Bytes5,{0,2147483647},[], mandatory),
 
1597
 
 
1598
%%-------------------------------------------------
 
1599
%% attribute number 5 with type INTEGER
 
1600
%%-------------------------------------------------
 
1601
   {Term5,Bytes7,Rb6} = ?RT_BER:decode_integer(Bytes6,{0,2147483647},[], mandatory),
 
1602
 
 
1603
%%-------------------------------------------------
 
1604
%% attribute number 6 with type BOOLEAN
 
1605
%%-------------------------------------------------
 
1606
   {Term6,Bytes8,Rb7} = ?RT_BER:decode_boolean(Bytes7,[], mandatory),
 
1607
 
 
1608
%%-------------------------------------------------
 
1609
%% attribute number 7   External ELDAPv3:Filter
 
1610
%%-------------------------------------------------
 
1611
   {Term7,Bytes9,Rb8} = 'dec_Filter'(Bytes8, mandatory, []),
 
1612
 
 
1613
%%-------------------------------------------------
 
1614
%% attribute number 8   External ELDAPv3:AttributeDescriptionList
 
1615
%%-------------------------------------------------
 
1616
   {Term8,Bytes10,Rb9} = 'dec_AttributeDescriptionList'(Bytes9, mandatory, []),
 
1617
 
 
1618
   {Bytes11,Rb10} = ?RT_BER:restbytes2(RemBytes, Bytes10,noext),
 
1619
   {{'SearchRequest', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8}, Bytes11, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10}.
 
1620
 
 
1621
 
 
1622
%%================================
 
1623
%%  Filter
 
1624
%%================================
 
1625
 
 
1626
'enc_Filter'({'Filter',Val}, TagIn) ->
 
1627
   'enc_Filter'(Val, TagIn);
 
1628
 
 
1629
'enc_Filter'(Val, TagIn) ->
 
1630
   {EncBytes,EncLen} = case element(1,Val) of
 
1631
      'and' ->
 
1632
         'enc_Filter_and'(element(2,Val), [{tag,128,0,'IMPLICIT',32}]);
 
1633
      'or' ->
 
1634
         'enc_Filter_or'(element(2,Val), [{tag,128,1,'IMPLICIT',32}]);
 
1635
      'not' ->
 
1636
         'enc_Filter'(element(2,Val), [{tag,128,2,'EXPLICIT',32}]);
 
1637
      equalityMatch ->
 
1638
         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,3,'IMPLICIT',32}]);
 
1639
      substrings ->
 
1640
         'enc_SubstringFilter'(element(2,Val), [{tag,128,4,'IMPLICIT',32}]);
 
1641
      greaterOrEqual ->
 
1642
         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,5,'IMPLICIT',32}]);
 
1643
      lessOrEqual ->
 
1644
         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,6,'IMPLICIT',32}]);
 
1645
      present ->
 
1646
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,7,'IMPLICIT',32}]);
 
1647
      approxMatch ->
 
1648
         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,8,'IMPLICIT',32}]);
 
1649
      extensibleMatch ->
 
1650
         'enc_MatchingRuleAssertion'(element(2,Val), [{tag,128,9,'IMPLICIT',32}]);
 
1651
      Else -> 
 
1652
         exit({error,{asn1,{invalid_choice_type,Else}}})
 
1653
   end,
 
1654
 
 
1655
?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
 
1656
 
 
1657
 
 
1658
 
 
1659
 
 
1660
 
 
1661
%%================================
 
1662
%%  Filter_and
 
1663
%%================================
 
1664
 
 
1665
'enc_Filter_and'({'Filter_and',Val}, TagIn) ->
 
1666
   'enc_Filter_and'(Val, TagIn);
 
1667
 
 
1668
'enc_Filter_and'(Val, TagIn) ->
 
1669
      {EncBytes,EncLen} = 'enc_Filter_and_components'(Val,[],0),
 
1670
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
 
1671
 
 
1672
'enc_Filter_and_components'([], AccBytes, AccLen) -> 
 
1673
   {lists:reverse(AccBytes),AccLen};
 
1674
 
 
1675
'enc_Filter_and_components'([H|T],AccBytes, AccLen) ->
 
1676
   {EncBytes,EncLen} = 'enc_Filter'(H, []),
 
1677
   'enc_Filter_and_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
1678
 
 
1679
'dec_Filter_and'(Bytes, OptOrMand, TagIn) ->
 
1680
   %%-------------------------------------------------
 
1681
   %% decode tag and length 
 
1682
   %%-------------------------------------------------
 
1683
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1684
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Filter'/3, [], []).
 
1685
 
 
1686
 
 
1687
 
 
1688
 
 
1689
 
 
1690
%%================================
 
1691
%%  Filter_or
 
1692
%%================================
 
1693
 
 
1694
'enc_Filter_or'({'Filter_or',Val}, TagIn) ->
 
1695
   'enc_Filter_or'(Val, TagIn);
 
1696
 
 
1697
'enc_Filter_or'(Val, TagIn) ->
 
1698
      {EncBytes,EncLen} = 'enc_Filter_or_components'(Val,[],0),
 
1699
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
 
1700
 
 
1701
'enc_Filter_or_components'([], AccBytes, AccLen) -> 
 
1702
   {lists:reverse(AccBytes),AccLen};
 
1703
 
 
1704
'enc_Filter_or_components'([H|T],AccBytes, AccLen) ->
 
1705
   {EncBytes,EncLen} = 'enc_Filter'(H, []),
 
1706
   'enc_Filter_or_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
1707
 
 
1708
'dec_Filter_or'(Bytes, OptOrMand, TagIn) ->
 
1709
   %%-------------------------------------------------
 
1710
   %% decode tag and length 
 
1711
   %%-------------------------------------------------
 
1712
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1713
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Filter'/3, [], []).
 
1714
 
 
1715
 
 
1716
 
 
1717
 
 
1718
'dec_Filter'(Bytes, OptOrMand) ->
 
1719
   'dec_Filter'(Bytes, OptOrMand, []).
 
1720
 
 
1721
'dec_Filter'(Bytes, OptOrMand, TagIn) ->
 
1722
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
 
1723
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
 
1724
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
 
1725
   case Bytes1 of
 
1726
 
 
1727
%% 'and'
 
1728
      <<2:2,_:1,0:5,_/binary>> ->
 
1729
         {Dec, Rest, RbCho} = 'dec_Filter_and'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',32}]),
 
1730
         {{'and', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1731
 
 
1732
 
 
1733
%% 'or'
 
1734
      <<2:2,_:1,1:5,_/binary>> ->
 
1735
         {Dec, Rest, RbCho} = 'dec_Filter_or'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',32}]),
 
1736
         {{'or', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1737
 
 
1738
 
 
1739
%% 'not'
 
1740
      <<2:2,_:1,2:5,_/binary>> ->
 
1741
         {Dec, Rest, RbCho} = 'dec_Filter'(Bytes1, mandatory, [{tag,128,2,'EXPLICIT',32}]),
 
1742
         {{'not', Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1743
 
 
1744
 
 
1745
%% 'equalityMatch'
 
1746
      <<2:2,_:1,3:5,_/binary>> ->
 
1747
         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',32}]),
 
1748
         {{equalityMatch, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1749
 
 
1750
 
 
1751
%% 'substrings'
 
1752
      <<2:2,_:1,4:5,_/binary>> ->
 
1753
         {Dec, Rest, RbCho} = 'dec_SubstringFilter'(Bytes1, mandatory, [{tag,128,4,'IMPLICIT',32}]),
 
1754
         {{substrings, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1755
 
 
1756
 
 
1757
%% 'greaterOrEqual'
 
1758
      <<2:2,_:1,5:5,_/binary>> ->
 
1759
         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,5,'IMPLICIT',32}]),
 
1760
         {{greaterOrEqual, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1761
 
 
1762
 
 
1763
%% 'lessOrEqual'
 
1764
      <<2:2,_:1,6:5,_/binary>> ->
 
1765
         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',32}]),
 
1766
         {{lessOrEqual, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1767
 
 
1768
 
 
1769
%% 'present'
 
1770
      <<2:2,_:1,7:5,_/binary>> ->
 
1771
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,7,'IMPLICIT',32}], no_length, mandatory),
 
1772
         {{present, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1773
 
 
1774
 
 
1775
%% 'approxMatch'
 
1776
      <<2:2,_:1,8:5,_/binary>> ->
 
1777
         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,8,'IMPLICIT',32}]),
 
1778
         {{approxMatch, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1779
 
 
1780
 
 
1781
%% 'extensibleMatch'
 
1782
      <<2:2,_:1,9:5,_/binary>> ->
 
1783
         {Dec, Rest, RbCho} = 'dec_MatchingRuleAssertion'(Bytes1, mandatory, [{tag,128,9,'IMPLICIT',32}]),
 
1784
         {{extensibleMatch, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1785
 
 
1786
      Else -> 
 
1787
         case OptOrMand of
 
1788
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
 
1789
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
 
1790
         end
 
1791
   end.
 
1792
 
 
1793
 
 
1794
%%================================
 
1795
%%  SubstringFilter
 
1796
%%================================
 
1797
'enc_SubstringFilter'(Val, TagIn) ->
 
1798
 
 
1799
%%-------------------------------------------------
 
1800
%% attribute number 1 with type OCTET STRING
 
1801
%%-------------------------------------------------
 
1802
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
 
1803
 
 
1804
%%-------------------------------------------------
 
1805
%% attribute number 2 with type SEQUENCE OF
 
1806
%%-------------------------------------------------
 
1807
   {EncBytes2,EncLen2} = 'enc_SubstringFilter_substrings'(?RT_BER:cindex(3,Val,substrings), []),
 
1808
 
 
1809
   BytesSoFar = [EncBytes1, EncBytes2],
 
1810
  LenSoFar = EncLen1 + EncLen2,
 
1811
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1812
 
 
1813
 
 
1814
 
 
1815
%%================================
 
1816
%%  SubstringFilter_substrings
 
1817
%%================================
 
1818
 
 
1819
'enc_SubstringFilter_substrings'({'SubstringFilter_substrings',Val}, TagIn) ->
 
1820
   'enc_SubstringFilter_substrings'(Val, TagIn);
 
1821
 
 
1822
'enc_SubstringFilter_substrings'(Val, TagIn) ->
 
1823
      {EncBytes,EncLen} = 'enc_SubstringFilter_substrings_components'(Val,[],0),
 
1824
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
1825
 
 
1826
'enc_SubstringFilter_substrings_components'([], AccBytes, AccLen) -> 
 
1827
   {lists:reverse(AccBytes),AccLen};
 
1828
 
 
1829
'enc_SubstringFilter_substrings_components'([H|T],AccBytes, AccLen) ->
 
1830
   {EncBytes,EncLen} = 'enc_SubstringFilter_substrings_SEQOF'(H, []),
 
1831
   'enc_SubstringFilter_substrings_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
1832
 
 
1833
 
 
1834
 
 
1835
 
 
1836
%%================================
 
1837
%%  SubstringFilter_substrings_SEQOF
 
1838
%%================================
 
1839
 
 
1840
'enc_SubstringFilter_substrings_SEQOF'({'SubstringFilter_substrings_SEQOF',Val}, TagIn) ->
 
1841
   'enc_SubstringFilter_substrings_SEQOF'(Val, TagIn);
 
1842
 
 
1843
'enc_SubstringFilter_substrings_SEQOF'(Val, TagIn) ->
 
1844
      {EncBytes,EncLen} = case element(1,Val) of
 
1845
      initial ->
 
1846
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,0,'IMPLICIT',32}]);
 
1847
      any ->
 
1848
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,1,'IMPLICIT',32}]);
 
1849
      final ->
 
1850
         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,2,'IMPLICIT',32}]);
 
1851
      Else -> 
 
1852
         exit({error,{asn1,{invalid_choice_type,Else}}})
 
1853
   end,
 
1854
 
 
1855
?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
 
1856
 
 
1857
 
 
1858
'dec_SubstringFilter_substrings_SEQOF'(Bytes, OptOrMand, TagIn) ->
 
1859
   {{_,Len},Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
 
1860
   IndefEndBytes = fun(indefinite,<<0,0,R/binary>>)-> R; (_,B)-> B end,
 
1861
   IndefEndRb = fun(indefinite,<<0,0,_R/binary>>)-> 2; (_,_)-> 0 end,
 
1862
   case Bytes1 of
 
1863
 
 
1864
%% 'initial'
 
1865
      <<2:2,_:1,0:5,_/binary>> ->
 
1866
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory),
 
1867
         {{initial, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1868
 
 
1869
 
 
1870
%% 'any'
 
1871
      <<2:2,_:1,1:5,_/binary>> ->
 
1872
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory),
 
1873
         {{any, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1874
 
 
1875
 
 
1876
%% 'final'
 
1877
      <<2:2,_:1,2:5,_/binary>> ->
 
1878
         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,2,'IMPLICIT',32}], no_length, mandatory),
 
1879
         {{final, Dec}, IndefEndBytes(Len,Rest), RbExp + RbCho + IndefEndRb(Len,Rest)};
 
1880
 
 
1881
      Else -> 
 
1882
         case OptOrMand of
 
1883
            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
 
1884
            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
 
1885
         end
 
1886
   end.
 
1887
'dec_SubstringFilter_substrings'(Bytes, OptOrMand, TagIn) ->
 
1888
   %%-------------------------------------------------
 
1889
   %% decode tag and length 
 
1890
   %%-------------------------------------------------
 
1891
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1892
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_SubstringFilter_substrings_SEQOF'/3, [], []).
 
1893
 
 
1894
 
 
1895
 
 
1896
 
 
1897
'dec_SubstringFilter'(Bytes, OptOrMand) ->
 
1898
   'dec_SubstringFilter'(Bytes, OptOrMand, []).
 
1899
 
 
1900
'dec_SubstringFilter'(Bytes, OptOrMand, TagIn) ->
 
1901
   %%-------------------------------------------------
 
1902
   %% decode tag and length 
 
1903
   %%-------------------------------------------------
 
1904
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1905
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1906
 
 
1907
%%-------------------------------------------------
 
1908
%% attribute number 1 with type OCTET STRING
 
1909
%%-------------------------------------------------
 
1910
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
1911
 
 
1912
%%-------------------------------------------------
 
1913
%% attribute number 2 with type SEQUENCE OF
 
1914
%%-------------------------------------------------
 
1915
   {Term2,Bytes4,Rb3} = 'dec_SubstringFilter_substrings'(Bytes3, mandatory, []),
 
1916
 
 
1917
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
1918
   {{'SubstringFilter', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
1919
 
 
1920
 
 
1921
%%================================
 
1922
%%  MatchingRuleAssertion
 
1923
%%================================
 
1924
'enc_MatchingRuleAssertion'(Val, TagIn) ->
 
1925
 
 
1926
%%-------------------------------------------------
 
1927
%% attribute number 1 with type OCTET STRING OPTIONAL
 
1928
%%-------------------------------------------------
 
1929
   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,matchingRule) of
 
1930
         asn1_NOVALUE -> {<<>>,0};
 
1931
         _ ->
 
1932
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,matchingRule), [{tag,128,1,'IMPLICIT',32}])
 
1933
       end,
 
1934
 
 
1935
%%-------------------------------------------------
 
1936
%% attribute number 2 with type OCTET STRING OPTIONAL
 
1937
%%-------------------------------------------------
 
1938
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,type) of
 
1939
         asn1_NOVALUE -> {<<>>,0};
 
1940
         _ ->
 
1941
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,type), [{tag,128,2,'IMPLICIT',32}])
 
1942
       end,
 
1943
 
 
1944
%%-------------------------------------------------
 
1945
%% attribute number 3 with type OCTET STRING
 
1946
%%-------------------------------------------------
 
1947
   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,matchValue), [{tag,128,3,'IMPLICIT',32}]),
 
1948
 
 
1949
%%-------------------------------------------------
 
1950
%% attribute number 4 with type BOOLEAN DEFAULT = false
 
1951
%%-------------------------------------------------
 
1952
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,dnAttributes) of
 
1953
         asn1_DEFAULT -> {<<>>,0};
 
1954
         false -> {<<>>,0};
 
1955
         _ ->
 
1956
            ?RT_BER:encode_boolean(?RT_BER:cindex(5,Val,dnAttributes), [{tag,128,4,'IMPLICIT',32}])
 
1957
       end,
 
1958
 
 
1959
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
 
1960
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
 
1961
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
1962
 
 
1963
 
 
1964
'dec_MatchingRuleAssertion'(Bytes, OptOrMand) ->
 
1965
   'dec_MatchingRuleAssertion'(Bytes, OptOrMand, []).
 
1966
 
 
1967
'dec_MatchingRuleAssertion'(Bytes, OptOrMand, TagIn) ->
 
1968
   %%-------------------------------------------------
 
1969
   %% decode tag and length 
 
1970
   %%-------------------------------------------------
 
1971
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
1972
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
1973
 
 
1974
%%-------------------------------------------------
 
1975
%% attribute number 1 with type OCTET STRING OPTIONAL
 
1976
%%-------------------------------------------------
 
1977
   {Term1,Bytes3,Rb2} = case Bytes2 of
 
1978
<<2:2,_:1,1:5,_/binary>> ->
 
1979
?RT_BER:decode_octet_string(Bytes2,[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory);
 
1980
_ ->
 
1981
{ asn1_NOVALUE, Bytes2, 0 }
 
1982
end,
 
1983
 
 
1984
%%-------------------------------------------------
 
1985
%% attribute number 2 with type OCTET STRING OPTIONAL
 
1986
%%-------------------------------------------------
 
1987
   {Term2,Bytes4,Rb3} = case Bytes3 of
 
1988
<<2:2,_:1,2:5,_/binary>> ->
 
1989
?RT_BER:decode_octet_string(Bytes3,[],[{tag,128,2,'IMPLICIT',32}], no_length, mandatory);
 
1990
_ ->
 
1991
{ asn1_NOVALUE, Bytes3, 0 }
 
1992
end,
 
1993
 
 
1994
%%-------------------------------------------------
 
1995
%% attribute number 3 with type OCTET STRING
 
1996
%%-------------------------------------------------
 
1997
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[{tag,128,3,'IMPLICIT',32}], no_length, mandatory),
 
1998
 
 
1999
%%-------------------------------------------------
 
2000
%% attribute number 4 with type BOOLEAN DEFAULT = false
 
2001
%%-------------------------------------------------
 
2002
   {Term4,Bytes6,Rb5} = case Bytes5 of
 
2003
<<2:2,_:1,4:5,_/binary>> ->
 
2004
?RT_BER:decode_boolean(Bytes5,[{tag,128,4,'IMPLICIT',32}], mandatory);
 
2005
_ ->
 
2006
{false,Bytes5, 0 }
 
2007
end,
 
2008
 
 
2009
   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
 
2010
   {{'MatchingRuleAssertion', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.
 
2011
 
 
2012
 
 
2013
%%================================
 
2014
%%  SearchResultEntry
 
2015
%%================================
 
2016
'enc_SearchResultEntry'(Val, TagIn) ->
 
2017
 
 
2018
%%-------------------------------------------------
 
2019
%% attribute number 1 with type OCTET STRING
 
2020
%%-------------------------------------------------
 
2021
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,objectName), []),
 
2022
 
 
2023
%%-------------------------------------------------
 
2024
%% attribute number 2   External ELDAPv3:PartialAttributeList
 
2025
%%-------------------------------------------------
 
2026
   {EncBytes2,EncLen2} = 'enc_PartialAttributeList'(?RT_BER:cindex(3,Val,attributes), []),
 
2027
 
 
2028
   BytesSoFar = [EncBytes1, EncBytes2],
 
2029
  LenSoFar = EncLen1 + EncLen2,
 
2030
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,4,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2031
 
 
2032
 
 
2033
'dec_SearchResultEntry'(Bytes, OptOrMand) ->
 
2034
   'dec_SearchResultEntry'(Bytes, OptOrMand, []).
 
2035
 
 
2036
'dec_SearchResultEntry'(Bytes, OptOrMand, TagIn) ->
 
2037
   %%-------------------------------------------------
 
2038
   %% decode tag and length 
 
2039
   %%-------------------------------------------------
 
2040
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,4,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2041
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2042
 
 
2043
%%-------------------------------------------------
 
2044
%% attribute number 1 with type OCTET STRING
 
2045
%%-------------------------------------------------
 
2046
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2047
 
 
2048
%%-------------------------------------------------
 
2049
%% attribute number 2   External ELDAPv3:PartialAttributeList
 
2050
%%-------------------------------------------------
 
2051
   {Term2,Bytes4,Rb3} = 'dec_PartialAttributeList'(Bytes3, mandatory, []),
 
2052
 
 
2053
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2054
   {{'SearchResultEntry', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2055
 
 
2056
 
 
2057
%%================================
 
2058
%%  PartialAttributeList
 
2059
%%================================
 
2060
 
 
2061
'enc_PartialAttributeList'({'PartialAttributeList',Val}, TagIn) ->
 
2062
   'enc_PartialAttributeList'(Val, TagIn);
 
2063
 
 
2064
'enc_PartialAttributeList'(Val, TagIn) ->
 
2065
   {EncBytes,EncLen} = 'enc_PartialAttributeList_components'(Val,[],0),
 
2066
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
2067
 
 
2068
'enc_PartialAttributeList_components'([], AccBytes, AccLen) -> 
 
2069
   {lists:reverse(AccBytes),AccLen};
 
2070
 
 
2071
'enc_PartialAttributeList_components'([H|T],AccBytes, AccLen) ->
 
2072
   {EncBytes,EncLen} = 'enc_PartialAttributeList_SEQOF'(H, []),
 
2073
   'enc_PartialAttributeList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2074
 
 
2075
 
 
2076
 
 
2077
 
 
2078
%%================================
 
2079
%%  PartialAttributeList_SEQOF
 
2080
%%================================
 
2081
'enc_PartialAttributeList_SEQOF'(Val, TagIn) ->
 
2082
   
 
2083
%%-------------------------------------------------
 
2084
%% attribute number 1 with type OCTET STRING
 
2085
%%-------------------------------------------------
 
2086
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
 
2087
 
 
2088
%%-------------------------------------------------
 
2089
%% attribute number 2 with type SET OF
 
2090
%%-------------------------------------------------
 
2091
   {EncBytes2,EncLen2} = 'enc_PartialAttributeList_SEQOF_vals'(?RT_BER:cindex(3,Val,vals), []),
 
2092
 
 
2093
   BytesSoFar = [EncBytes1, EncBytes2],
 
2094
  LenSoFar = EncLen1 + EncLen2,
 
2095
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2096
 
 
2097
 
 
2098
 
 
2099
%%================================
 
2100
%%  PartialAttributeList_SEQOF_vals
 
2101
%%================================
 
2102
 
 
2103
'enc_PartialAttributeList_SEQOF_vals'({'PartialAttributeList_SEQOF_vals',Val}, TagIn) ->
 
2104
   'enc_PartialAttributeList_SEQOF_vals'(Val, TagIn);
 
2105
 
 
2106
'enc_PartialAttributeList_SEQOF_vals'(Val, TagIn) ->
 
2107
      {EncBytes,EncLen} = 'enc_PartialAttributeList_SEQOF_vals_components'(Val,[],0),
 
2108
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
 
2109
 
 
2110
'enc_PartialAttributeList_SEQOF_vals_components'([], AccBytes, AccLen) -> 
 
2111
   {lists:reverse(AccBytes),AccLen};
 
2112
 
 
2113
'enc_PartialAttributeList_SEQOF_vals_components'([H|T],AccBytes, AccLen) ->
 
2114
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
2115
   'enc_PartialAttributeList_SEQOF_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2116
 
 
2117
'dec_PartialAttributeList_SEQOF_vals'(Bytes, OptOrMand, TagIn) ->
 
2118
   %%-------------------------------------------------
 
2119
   %% decode tag and length 
 
2120
   %%-------------------------------------------------
 
2121
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2122
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
2123
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
2124
end, [], []).
 
2125
 
 
2126
 
 
2127
'dec_PartialAttributeList_SEQOF'(Bytes, OptOrMand, TagIn) ->
 
2128
   %%-------------------------------------------------
 
2129
   %% decode tag and length 
 
2130
   %%-------------------------------------------------
 
2131
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2132
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2133
 
 
2134
%%-------------------------------------------------
 
2135
%% attribute number 1 with type OCTET STRING
 
2136
%%-------------------------------------------------
 
2137
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2138
 
 
2139
%%-------------------------------------------------
 
2140
%% attribute number 2 with type SET OF
 
2141
%%-------------------------------------------------
 
2142
   {Term2,Bytes4,Rb3} = 'dec_PartialAttributeList_SEQOF_vals'(Bytes3, mandatory, []),
 
2143
 
 
2144
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2145
   {{'PartialAttributeList_SEQOF', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2146
 
 
2147
 
 
2148
'dec_PartialAttributeList'(Bytes, OptOrMand) ->
 
2149
   'dec_PartialAttributeList'(Bytes, OptOrMand, []).
 
2150
 
 
2151
'dec_PartialAttributeList'(Bytes, OptOrMand, TagIn) ->
 
2152
   %%-------------------------------------------------
 
2153
   %% decode tag and length 
 
2154
   %%-------------------------------------------------
 
2155
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2156
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PartialAttributeList_SEQOF'/3, [], []).
 
2157
 
 
2158
 
 
2159
 
 
2160
 
 
2161
%%================================
 
2162
%%  SearchResultReference
 
2163
%%================================
 
2164
 
 
2165
'enc_SearchResultReference'({'SearchResultReference',Val}, TagIn) ->
 
2166
   'enc_SearchResultReference'(Val, TagIn);
 
2167
 
 
2168
'enc_SearchResultReference'(Val, TagIn) ->
 
2169
   {EncBytes,EncLen} = 'enc_SearchResultReference_components'(Val,[],0),
 
2170
   ?RT_BER:encode_tags(TagIn ++ [{tag,64,19,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
2171
 
 
2172
'enc_SearchResultReference_components'([], AccBytes, AccLen) -> 
 
2173
   {lists:reverse(AccBytes),AccLen};
 
2174
 
 
2175
'enc_SearchResultReference_components'([H|T],AccBytes, AccLen) ->
 
2176
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
2177
   'enc_SearchResultReference_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2178
 
 
2179
 
 
2180
 
 
2181
'dec_SearchResultReference'(Bytes, OptOrMand) ->
 
2182
   'dec_SearchResultReference'(Bytes, OptOrMand, []).
 
2183
 
 
2184
'dec_SearchResultReference'(Bytes, OptOrMand, TagIn) ->
 
2185
   %%-------------------------------------------------
 
2186
   %% decode tag and length 
 
2187
   %%-------------------------------------------------
 
2188
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,19,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2189
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
2190
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
2191
end, [], []).
 
2192
 
 
2193
 
 
2194
 
 
2195
 
 
2196
%%================================
 
2197
%%  SearchResultDone
 
2198
%%================================
 
2199
 
 
2200
'enc_SearchResultDone'({'SearchResultDone',Val}, TagIn) ->
 
2201
   'enc_SearchResultDone'(Val, TagIn);
 
2202
 
 
2203
'enc_SearchResultDone'(Val, TagIn) ->
 
2204
   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,5,'IMPLICIT',32}]).
 
2205
 
 
2206
 
 
2207
'dec_SearchResultDone'(Bytes, OptOrMand) ->
 
2208
   'dec_SearchResultDone'(Bytes, OptOrMand, []).
 
2209
 
 
2210
'dec_SearchResultDone'(Bytes, OptOrMand, TagIn) ->
 
2211
'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,5,'IMPLICIT',32}]).
 
2212
 
 
2213
 
 
2214
 
 
2215
%%================================
 
2216
%%  ModifyRequest
 
2217
%%================================
 
2218
'enc_ModifyRequest'(Val, TagIn) ->
 
2219
 
 
2220
%%-------------------------------------------------
 
2221
%% attribute number 1 with type OCTET STRING
 
2222
%%-------------------------------------------------
 
2223
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,object), []),
 
2224
 
 
2225
%%-------------------------------------------------
 
2226
%% attribute number 2 with type SEQUENCE OF
 
2227
%%-------------------------------------------------
 
2228
   {EncBytes2,EncLen2} = 'enc_ModifyRequest_modification'(?RT_BER:cindex(3,Val,modification), []),
 
2229
 
 
2230
   BytesSoFar = [EncBytes1, EncBytes2],
 
2231
  LenSoFar = EncLen1 + EncLen2,
 
2232
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,6,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2233
 
 
2234
 
 
2235
 
 
2236
%%================================
 
2237
%%  ModifyRequest_modification
 
2238
%%================================
 
2239
 
 
2240
'enc_ModifyRequest_modification'({'ModifyRequest_modification',Val}, TagIn) ->
 
2241
   'enc_ModifyRequest_modification'(Val, TagIn);
 
2242
 
 
2243
'enc_ModifyRequest_modification'(Val, TagIn) ->
 
2244
      {EncBytes,EncLen} = 'enc_ModifyRequest_modification_components'(Val,[],0),
 
2245
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
2246
 
 
2247
'enc_ModifyRequest_modification_components'([], AccBytes, AccLen) -> 
 
2248
   {lists:reverse(AccBytes),AccLen};
 
2249
 
 
2250
'enc_ModifyRequest_modification_components'([H|T],AccBytes, AccLen) ->
 
2251
   {EncBytes,EncLen} = 'enc_ModifyRequest_modification_SEQOF'(H, []),
 
2252
   'enc_ModifyRequest_modification_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2253
 
 
2254
 
 
2255
 
 
2256
 
 
2257
%%================================
 
2258
%%  ModifyRequest_modification_SEQOF
 
2259
%%================================
 
2260
'enc_ModifyRequest_modification_SEQOF'(Val, TagIn) ->
 
2261
   
 
2262
%%-------------------------------------------------
 
2263
%% attribute number 1 with type ENUMERATED
 
2264
%%-------------------------------------------------
 
2265
   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,operation) of {_,_}->element(2,?RT_BER:cindex(2,Val,operation));_->?RT_BER:cindex(2,Val,operation) end) of
 
2266
add -> ?RT_BER:encode_enumerated(0,[]);
 
2267
delete -> ?RT_BER:encode_enumerated(1,[]);
 
2268
replace -> ?RT_BER:encode_enumerated(2,[]);
 
2269
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
 
2270
end,
 
2271
 
 
2272
%%-------------------------------------------------
 
2273
%% attribute number 2   External ELDAPv3:AttributeTypeAndValues
 
2274
%%-------------------------------------------------
 
2275
   {EncBytes2,EncLen2} = 'enc_AttributeTypeAndValues'(?RT_BER:cindex(3,Val,modification), []),
 
2276
 
 
2277
   BytesSoFar = [EncBytes1, EncBytes2],
 
2278
  LenSoFar = EncLen1 + EncLen2,
 
2279
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2280
'dec_ModifyRequest_modification_SEQOF'(Bytes, OptOrMand, TagIn) ->
 
2281
   %%-------------------------------------------------
 
2282
   %% decode tag and length 
 
2283
   %%-------------------------------------------------
 
2284
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2285
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2286
 
 
2287
%%-------------------------------------------------
 
2288
%% attribute number 1 with type ENUMERATED
 
2289
%%-------------------------------------------------
 
2290
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{add,0},{delete,1},{replace,2}],[], mandatory),
 
2291
 
 
2292
%%-------------------------------------------------
 
2293
%% attribute number 2   External ELDAPv3:AttributeTypeAndValues
 
2294
%%-------------------------------------------------
 
2295
   {Term2,Bytes4,Rb3} = 'dec_AttributeTypeAndValues'(Bytes3, mandatory, []),
 
2296
 
 
2297
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2298
   {{'ModifyRequest_modification_SEQOF', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2299
'dec_ModifyRequest_modification'(Bytes, OptOrMand, TagIn) ->
 
2300
   %%-------------------------------------------------
 
2301
   %% decode tag and length 
 
2302
   %%-------------------------------------------------
 
2303
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2304
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_ModifyRequest_modification_SEQOF'/3, [], []).
 
2305
 
 
2306
 
 
2307
 
 
2308
 
 
2309
'dec_ModifyRequest'(Bytes, OptOrMand) ->
 
2310
   'dec_ModifyRequest'(Bytes, OptOrMand, []).
 
2311
 
 
2312
'dec_ModifyRequest'(Bytes, OptOrMand, TagIn) ->
 
2313
   %%-------------------------------------------------
 
2314
   %% decode tag and length 
 
2315
   %%-------------------------------------------------
 
2316
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,6,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2317
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2318
 
 
2319
%%-------------------------------------------------
 
2320
%% attribute number 1 with type OCTET STRING
 
2321
%%-------------------------------------------------
 
2322
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2323
 
 
2324
%%-------------------------------------------------
 
2325
%% attribute number 2 with type SEQUENCE OF
 
2326
%%-------------------------------------------------
 
2327
   {Term2,Bytes4,Rb3} = 'dec_ModifyRequest_modification'(Bytes3, mandatory, []),
 
2328
 
 
2329
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2330
   {{'ModifyRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2331
 
 
2332
 
 
2333
%%================================
 
2334
%%  AttributeTypeAndValues
 
2335
%%================================
 
2336
'enc_AttributeTypeAndValues'(Val, TagIn) ->
 
2337
 
 
2338
%%-------------------------------------------------
 
2339
%% attribute number 1 with type OCTET STRING
 
2340
%%-------------------------------------------------
 
2341
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
 
2342
 
 
2343
%%-------------------------------------------------
 
2344
%% attribute number 2 with type SET OF
 
2345
%%-------------------------------------------------
 
2346
   {EncBytes2,EncLen2} = 'enc_AttributeTypeAndValues_vals'(?RT_BER:cindex(3,Val,vals), []),
 
2347
 
 
2348
   BytesSoFar = [EncBytes1, EncBytes2],
 
2349
  LenSoFar = EncLen1 + EncLen2,
 
2350
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2351
 
 
2352
 
 
2353
 
 
2354
%%================================
 
2355
%%  AttributeTypeAndValues_vals
 
2356
%%================================
 
2357
 
 
2358
'enc_AttributeTypeAndValues_vals'({'AttributeTypeAndValues_vals',Val}, TagIn) ->
 
2359
   'enc_AttributeTypeAndValues_vals'(Val, TagIn);
 
2360
 
 
2361
'enc_AttributeTypeAndValues_vals'(Val, TagIn) ->
 
2362
      {EncBytes,EncLen} = 'enc_AttributeTypeAndValues_vals_components'(Val,[],0),
 
2363
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
 
2364
 
 
2365
'enc_AttributeTypeAndValues_vals_components'([], AccBytes, AccLen) -> 
 
2366
   {lists:reverse(AccBytes),AccLen};
 
2367
 
 
2368
'enc_AttributeTypeAndValues_vals_components'([H|T],AccBytes, AccLen) ->
 
2369
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
2370
   'enc_AttributeTypeAndValues_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2371
 
 
2372
'dec_AttributeTypeAndValues_vals'(Bytes, OptOrMand, TagIn) ->
 
2373
   %%-------------------------------------------------
 
2374
   %% decode tag and length 
 
2375
   %%-------------------------------------------------
 
2376
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2377
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
2378
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
2379
end, [], []).
 
2380
 
 
2381
 
 
2382
 
 
2383
 
 
2384
'dec_AttributeTypeAndValues'(Bytes, OptOrMand) ->
 
2385
   'dec_AttributeTypeAndValues'(Bytes, OptOrMand, []).
 
2386
 
 
2387
'dec_AttributeTypeAndValues'(Bytes, OptOrMand, TagIn) ->
 
2388
   %%-------------------------------------------------
 
2389
   %% decode tag and length 
 
2390
   %%-------------------------------------------------
 
2391
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2392
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2393
 
 
2394
%%-------------------------------------------------
 
2395
%% attribute number 1 with type OCTET STRING
 
2396
%%-------------------------------------------------
 
2397
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2398
 
 
2399
%%-------------------------------------------------
 
2400
%% attribute number 2 with type SET OF
 
2401
%%-------------------------------------------------
 
2402
   {Term2,Bytes4,Rb3} = 'dec_AttributeTypeAndValues_vals'(Bytes3, mandatory, []),
 
2403
 
 
2404
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2405
   {{'AttributeTypeAndValues', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2406
 
 
2407
 
 
2408
%%================================
 
2409
%%  ModifyResponse
 
2410
%%================================
 
2411
 
 
2412
'enc_ModifyResponse'({'ModifyResponse',Val}, TagIn) ->
 
2413
   'enc_ModifyResponse'(Val, TagIn);
 
2414
 
 
2415
'enc_ModifyResponse'(Val, TagIn) ->
 
2416
   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,7,'IMPLICIT',32}]).
 
2417
 
 
2418
 
 
2419
'dec_ModifyResponse'(Bytes, OptOrMand) ->
 
2420
   'dec_ModifyResponse'(Bytes, OptOrMand, []).
 
2421
 
 
2422
'dec_ModifyResponse'(Bytes, OptOrMand, TagIn) ->
 
2423
'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,7,'IMPLICIT',32}]).
 
2424
 
 
2425
 
 
2426
 
 
2427
%%================================
 
2428
%%  AddRequest
 
2429
%%================================
 
2430
'enc_AddRequest'(Val, TagIn) ->
 
2431
 
 
2432
%%-------------------------------------------------
 
2433
%% attribute number 1 with type OCTET STRING
 
2434
%%-------------------------------------------------
 
2435
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,entry), []),
 
2436
 
 
2437
%%-------------------------------------------------
 
2438
%% attribute number 2   External ELDAPv3:AttributeList
 
2439
%%-------------------------------------------------
 
2440
   {EncBytes2,EncLen2} = 'enc_AttributeList'(?RT_BER:cindex(3,Val,attributes), []),
 
2441
 
 
2442
   BytesSoFar = [EncBytes1, EncBytes2],
 
2443
  LenSoFar = EncLen1 + EncLen2,
 
2444
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,8,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2445
 
 
2446
 
 
2447
'dec_AddRequest'(Bytes, OptOrMand) ->
 
2448
   'dec_AddRequest'(Bytes, OptOrMand, []).
 
2449
 
 
2450
'dec_AddRequest'(Bytes, OptOrMand, TagIn) ->
 
2451
   %%-------------------------------------------------
 
2452
   %% decode tag and length 
 
2453
   %%-------------------------------------------------
 
2454
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,8,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2455
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2456
 
 
2457
%%-------------------------------------------------
 
2458
%% attribute number 1 with type OCTET STRING
 
2459
%%-------------------------------------------------
 
2460
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2461
 
 
2462
%%-------------------------------------------------
 
2463
%% attribute number 2   External ELDAPv3:AttributeList
 
2464
%%-------------------------------------------------
 
2465
   {Term2,Bytes4,Rb3} = 'dec_AttributeList'(Bytes3, mandatory, []),
 
2466
 
 
2467
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2468
   {{'AddRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2469
 
 
2470
 
 
2471
%%================================
 
2472
%%  AttributeList
 
2473
%%================================
 
2474
 
 
2475
'enc_AttributeList'({'AttributeList',Val}, TagIn) ->
 
2476
   'enc_AttributeList'(Val, TagIn);
 
2477
 
 
2478
'enc_AttributeList'(Val, TagIn) ->
 
2479
   {EncBytes,EncLen} = 'enc_AttributeList_components'(Val,[],0),
 
2480
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
 
2481
 
 
2482
'enc_AttributeList_components'([], AccBytes, AccLen) -> 
 
2483
   {lists:reverse(AccBytes),AccLen};
 
2484
 
 
2485
'enc_AttributeList_components'([H|T],AccBytes, AccLen) ->
 
2486
   {EncBytes,EncLen} = 'enc_AttributeList_SEQOF'(H, []),
 
2487
   'enc_AttributeList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2488
 
 
2489
 
 
2490
 
 
2491
 
 
2492
%%================================
 
2493
%%  AttributeList_SEQOF
 
2494
%%================================
 
2495
'enc_AttributeList_SEQOF'(Val, TagIn) ->
 
2496
   
 
2497
%%-------------------------------------------------
 
2498
%% attribute number 1 with type OCTET STRING
 
2499
%%-------------------------------------------------
 
2500
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
 
2501
 
 
2502
%%-------------------------------------------------
 
2503
%% attribute number 2 with type SET OF
 
2504
%%-------------------------------------------------
 
2505
   {EncBytes2,EncLen2} = 'enc_AttributeList_SEQOF_vals'(?RT_BER:cindex(3,Val,vals), []),
 
2506
 
 
2507
   BytesSoFar = [EncBytes1, EncBytes2],
 
2508
  LenSoFar = EncLen1 + EncLen2,
 
2509
  ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2510
 
 
2511
 
 
2512
 
 
2513
%%================================
 
2514
%%  AttributeList_SEQOF_vals
 
2515
%%================================
 
2516
 
 
2517
'enc_AttributeList_SEQOF_vals'({'AttributeList_SEQOF_vals',Val}, TagIn) ->
 
2518
   'enc_AttributeList_SEQOF_vals'(Val, TagIn);
 
2519
 
 
2520
'enc_AttributeList_SEQOF_vals'(Val, TagIn) ->
 
2521
      {EncBytes,EncLen} = 'enc_AttributeList_SEQOF_vals_components'(Val,[],0),
 
2522
   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
 
2523
 
 
2524
'enc_AttributeList_SEQOF_vals_components'([], AccBytes, AccLen) -> 
 
2525
   {lists:reverse(AccBytes),AccLen};
 
2526
 
 
2527
'enc_AttributeList_SEQOF_vals_components'([H|T],AccBytes, AccLen) ->
 
2528
   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
 
2529
   'enc_AttributeList_SEQOF_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
 
2530
 
 
2531
'dec_AttributeList_SEQOF_vals'(Bytes, OptOrMand, TagIn) ->
 
2532
   %%-------------------------------------------------
 
2533
   %% decode tag and length 
 
2534
   %%-------------------------------------------------
 
2535
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2536
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
 
2537
?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
 
2538
end, [], []).
 
2539
 
 
2540
 
 
2541
'dec_AttributeList_SEQOF'(Bytes, OptOrMand, TagIn) ->
 
2542
   %%-------------------------------------------------
 
2543
   %% decode tag and length 
 
2544
   %%-------------------------------------------------
 
2545
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2546
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2547
 
 
2548
%%-------------------------------------------------
 
2549
%% attribute number 1 with type OCTET STRING
 
2550
%%-------------------------------------------------
 
2551
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2552
 
 
2553
%%-------------------------------------------------
 
2554
%% attribute number 2 with type SET OF
 
2555
%%-------------------------------------------------
 
2556
   {Term2,Bytes4,Rb3} = 'dec_AttributeList_SEQOF_vals'(Bytes3, mandatory, []),
 
2557
 
 
2558
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2559
   {{'AttributeList_SEQOF', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2560
 
 
2561
 
 
2562
'dec_AttributeList'(Bytes, OptOrMand) ->
 
2563
   'dec_AttributeList'(Bytes, OptOrMand, []).
 
2564
 
 
2565
'dec_AttributeList'(Bytes, OptOrMand, TagIn) ->
 
2566
   %%-------------------------------------------------
 
2567
   %% decode tag and length 
 
2568
   %%-------------------------------------------------
 
2569
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2570
   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_AttributeList_SEQOF'/3, [], []).
 
2571
 
 
2572
 
 
2573
 
 
2574
 
 
2575
%%================================
 
2576
%%  AddResponse
 
2577
%%================================
 
2578
 
 
2579
'enc_AddResponse'({'AddResponse',Val}, TagIn) ->
 
2580
   'enc_AddResponse'(Val, TagIn);
 
2581
 
 
2582
'enc_AddResponse'(Val, TagIn) ->
 
2583
   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,9,'IMPLICIT',32}]).
 
2584
 
 
2585
 
 
2586
'dec_AddResponse'(Bytes, OptOrMand) ->
 
2587
   'dec_AddResponse'(Bytes, OptOrMand, []).
 
2588
 
 
2589
'dec_AddResponse'(Bytes, OptOrMand, TagIn) ->
 
2590
'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,9,'IMPLICIT',32}]).
 
2591
 
 
2592
 
 
2593
 
 
2594
%%================================
 
2595
%%  DelRequest
 
2596
%%================================
 
2597
 
 
2598
'enc_DelRequest'({'DelRequest',Val}, TagIn) ->
 
2599
   'enc_DelRequest'(Val, TagIn);
 
2600
 
 
2601
'enc_DelRequest'(Val, TagIn) ->
 
2602
?RT_BER:encode_octet_string([], Val, TagIn ++ [{tag,64,10,'IMPLICIT',32}]).
 
2603
 
 
2604
 
 
2605
'dec_DelRequest'(Bytes, OptOrMand) ->
 
2606
   'dec_DelRequest'(Bytes, OptOrMand, []).
 
2607
 
 
2608
'dec_DelRequest'(Bytes, OptOrMand, TagIn) ->
 
2609
?RT_BER:decode_octet_string(Bytes,[],TagIn++[{tag,64,10,'IMPLICIT',32}], no_length, OptOrMand).
 
2610
 
 
2611
 
 
2612
 
 
2613
%%================================
 
2614
%%  DelResponse
 
2615
%%================================
 
2616
 
 
2617
'enc_DelResponse'({'DelResponse',Val}, TagIn) ->
 
2618
   'enc_DelResponse'(Val, TagIn);
 
2619
 
 
2620
'enc_DelResponse'(Val, TagIn) ->
 
2621
   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,11,'IMPLICIT',32}]).
 
2622
 
 
2623
 
 
2624
'dec_DelResponse'(Bytes, OptOrMand) ->
 
2625
   'dec_DelResponse'(Bytes, OptOrMand, []).
 
2626
 
 
2627
'dec_DelResponse'(Bytes, OptOrMand, TagIn) ->
 
2628
'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,11,'IMPLICIT',32}]).
 
2629
 
 
2630
 
 
2631
 
 
2632
%%================================
 
2633
%%  ModifyDNRequest
 
2634
%%================================
 
2635
'enc_ModifyDNRequest'(Val, TagIn) ->
 
2636
 
 
2637
%%-------------------------------------------------
 
2638
%% attribute number 1 with type OCTET STRING
 
2639
%%-------------------------------------------------
 
2640
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,entry), []),
 
2641
 
 
2642
%%-------------------------------------------------
 
2643
%% attribute number 2 with type OCTET STRING
 
2644
%%-------------------------------------------------
 
2645
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,newrdn), []),
 
2646
 
 
2647
%%-------------------------------------------------
 
2648
%% attribute number 3 with type BOOLEAN
 
2649
%%-------------------------------------------------
 
2650
   {EncBytes3,EncLen3} = ?RT_BER:encode_boolean(?RT_BER:cindex(4,Val,deleteoldrdn), []),
 
2651
 
 
2652
%%-------------------------------------------------
 
2653
%% attribute number 4 with type OCTET STRING OPTIONAL
 
2654
%%-------------------------------------------------
 
2655
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,newSuperior) of
 
2656
         asn1_NOVALUE -> {<<>>,0};
 
2657
         _ ->
 
2658
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(5,Val,newSuperior), [{tag,128,0,'IMPLICIT',32}])
 
2659
       end,
 
2660
 
 
2661
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
 
2662
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
 
2663
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,12,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2664
 
 
2665
 
 
2666
'dec_ModifyDNRequest'(Bytes, OptOrMand) ->
 
2667
   'dec_ModifyDNRequest'(Bytes, OptOrMand, []).
 
2668
 
 
2669
'dec_ModifyDNRequest'(Bytes, OptOrMand, TagIn) ->
 
2670
   %%-------------------------------------------------
 
2671
   %% decode tag and length 
 
2672
   %%-------------------------------------------------
 
2673
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,12,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2674
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2675
 
 
2676
%%-------------------------------------------------
 
2677
%% attribute number 1 with type OCTET STRING
 
2678
%%-------------------------------------------------
 
2679
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2680
 
 
2681
%%-------------------------------------------------
 
2682
%% attribute number 2 with type OCTET STRING
 
2683
%%-------------------------------------------------
 
2684
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
 
2685
 
 
2686
%%-------------------------------------------------
 
2687
%% attribute number 3 with type BOOLEAN
 
2688
%%-------------------------------------------------
 
2689
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_boolean(Bytes4,[], mandatory),
 
2690
 
 
2691
%%-------------------------------------------------
 
2692
%% attribute number 4 with type OCTET STRING OPTIONAL
 
2693
%%-------------------------------------------------
 
2694
   {Term4,Bytes6,Rb5} = case Bytes5 of
 
2695
<<2:2,_:1,0:5,_/binary>> ->
 
2696
?RT_BER:decode_octet_string(Bytes5,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory);
 
2697
_ ->
 
2698
{ asn1_NOVALUE, Bytes5, 0 }
 
2699
end,
 
2700
 
 
2701
   {Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
 
2702
   {{'ModifyDNRequest', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.
 
2703
 
 
2704
 
 
2705
%%================================
 
2706
%%  ModifyDNResponse
 
2707
%%================================
 
2708
 
 
2709
'enc_ModifyDNResponse'({'ModifyDNResponse',Val}, TagIn) ->
 
2710
   'enc_ModifyDNResponse'(Val, TagIn);
 
2711
 
 
2712
'enc_ModifyDNResponse'(Val, TagIn) ->
 
2713
   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,13,'IMPLICIT',32}]).
 
2714
 
 
2715
 
 
2716
'dec_ModifyDNResponse'(Bytes, OptOrMand) ->
 
2717
   'dec_ModifyDNResponse'(Bytes, OptOrMand, []).
 
2718
 
 
2719
'dec_ModifyDNResponse'(Bytes, OptOrMand, TagIn) ->
 
2720
'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,13,'IMPLICIT',32}]).
 
2721
 
 
2722
 
 
2723
 
 
2724
%%================================
 
2725
%%  CompareRequest
 
2726
%%================================
 
2727
'enc_CompareRequest'(Val, TagIn) ->
 
2728
 
 
2729
%%-------------------------------------------------
 
2730
%% attribute number 1 with type OCTET STRING
 
2731
%%-------------------------------------------------
 
2732
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,entry), []),
 
2733
 
 
2734
%%-------------------------------------------------
 
2735
%% attribute number 2   External ELDAPv3:AttributeValueAssertion
 
2736
%%-------------------------------------------------
 
2737
   {EncBytes2,EncLen2} = 'enc_AttributeValueAssertion'(?RT_BER:cindex(3,Val,ava), []),
 
2738
 
 
2739
   BytesSoFar = [EncBytes1, EncBytes2],
 
2740
  LenSoFar = EncLen1 + EncLen2,
 
2741
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,14,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2742
 
 
2743
 
 
2744
'dec_CompareRequest'(Bytes, OptOrMand) ->
 
2745
   'dec_CompareRequest'(Bytes, OptOrMand, []).
 
2746
 
 
2747
'dec_CompareRequest'(Bytes, OptOrMand, TagIn) ->
 
2748
   %%-------------------------------------------------
 
2749
   %% decode tag and length 
 
2750
   %%-------------------------------------------------
 
2751
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,14,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2752
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2753
 
 
2754
%%-------------------------------------------------
 
2755
%% attribute number 1 with type OCTET STRING
 
2756
%%-------------------------------------------------
 
2757
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
 
2758
 
 
2759
%%-------------------------------------------------
 
2760
%% attribute number 2   External ELDAPv3:AttributeValueAssertion
 
2761
%%-------------------------------------------------
 
2762
   {Term2,Bytes4,Rb3} = 'dec_AttributeValueAssertion'(Bytes3, mandatory, []),
 
2763
 
 
2764
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2765
   {{'CompareRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2766
 
 
2767
 
 
2768
%%================================
 
2769
%%  CompareResponse
 
2770
%%================================
 
2771
 
 
2772
'enc_CompareResponse'({'CompareResponse',Val}, TagIn) ->
 
2773
   'enc_CompareResponse'(Val, TagIn);
 
2774
 
 
2775
'enc_CompareResponse'(Val, TagIn) ->
 
2776
   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,15,'IMPLICIT',32}]).
 
2777
 
 
2778
 
 
2779
'dec_CompareResponse'(Bytes, OptOrMand) ->
 
2780
   'dec_CompareResponse'(Bytes, OptOrMand, []).
 
2781
 
 
2782
'dec_CompareResponse'(Bytes, OptOrMand, TagIn) ->
 
2783
'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,15,'IMPLICIT',32}]).
 
2784
 
 
2785
 
 
2786
 
 
2787
%%================================
 
2788
%%  AbandonRequest
 
2789
%%================================
 
2790
 
 
2791
'enc_AbandonRequest'({'AbandonRequest',Val}, TagIn) ->
 
2792
   'enc_AbandonRequest'(Val, TagIn);
 
2793
 
 
2794
'enc_AbandonRequest'(Val, TagIn) ->
 
2795
?RT_BER:encode_integer([], Val, TagIn ++ [{tag,64,16,'IMPLICIT',32}]).
 
2796
 
 
2797
 
 
2798
'dec_AbandonRequest'(Bytes, OptOrMand) ->
 
2799
   'dec_AbandonRequest'(Bytes, OptOrMand, []).
 
2800
 
 
2801
'dec_AbandonRequest'(Bytes, OptOrMand, TagIn) ->
 
2802
?RT_BER:decode_integer(Bytes,{0,2147483647},TagIn++[{tag,64,16,'IMPLICIT',32}], OptOrMand).
 
2803
 
 
2804
 
 
2805
 
 
2806
%%================================
 
2807
%%  ExtendedRequest
 
2808
%%================================
 
2809
'enc_ExtendedRequest'(Val, TagIn) ->
 
2810
 
 
2811
%%-------------------------------------------------
 
2812
%% attribute number 1 with type OCTET STRING
 
2813
%%-------------------------------------------------
 
2814
   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,requestName), [{tag,128,0,'IMPLICIT',32}]),
 
2815
 
 
2816
%%-------------------------------------------------
 
2817
%% attribute number 2 with type OCTET STRING OPTIONAL
 
2818
%%-------------------------------------------------
 
2819
   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,requestValue) of
 
2820
         asn1_NOVALUE -> {<<>>,0};
 
2821
         _ ->
 
2822
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,requestValue), [{tag,128,1,'IMPLICIT',32}])
 
2823
       end,
 
2824
 
 
2825
   BytesSoFar = [EncBytes1, EncBytes2],
 
2826
  LenSoFar = EncLen1 + EncLen2,
 
2827
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,23,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2828
 
 
2829
 
 
2830
'dec_ExtendedRequest'(Bytes, OptOrMand) ->
 
2831
   'dec_ExtendedRequest'(Bytes, OptOrMand, []).
 
2832
 
 
2833
'dec_ExtendedRequest'(Bytes, OptOrMand, TagIn) ->
 
2834
   %%-------------------------------------------------
 
2835
   %% decode tag and length 
 
2836
   %%-------------------------------------------------
 
2837
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,23,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2838
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2839
 
 
2840
%%-------------------------------------------------
 
2841
%% attribute number 1 with type OCTET STRING
 
2842
%%-------------------------------------------------
 
2843
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory),
 
2844
 
 
2845
%%-------------------------------------------------
 
2846
%% attribute number 2 with type OCTET STRING OPTIONAL
 
2847
%%-------------------------------------------------
 
2848
   {Term2,Bytes4,Rb3} = case Bytes3 of
 
2849
<<2:2,_:1,1:5,_/binary>> ->
 
2850
?RT_BER:decode_octet_string(Bytes3,[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory);
 
2851
_ ->
 
2852
{ asn1_NOVALUE, Bytes3, 0 }
 
2853
end,
 
2854
 
 
2855
   {Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
 
2856
   {{'ExtendedRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
 
2857
 
 
2858
 
 
2859
%%================================
 
2860
%%  ExtendedResponse
 
2861
%%================================
 
2862
'enc_ExtendedResponse'(Val, TagIn) ->
 
2863
 
 
2864
%%-------------------------------------------------
 
2865
%% attribute number 1 with type ENUMERATED
 
2866
%%-------------------------------------------------
 
2867
   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,resultCode) of {_,_}->element(2,?RT_BER:cindex(2,Val,resultCode));_->?RT_BER:cindex(2,Val,resultCode) end) of
 
2868
success -> ?RT_BER:encode_enumerated(0,[]);
 
2869
operationsError -> ?RT_BER:encode_enumerated(1,[]);
 
2870
protocolError -> ?RT_BER:encode_enumerated(2,[]);
 
2871
timeLimitExceeded -> ?RT_BER:encode_enumerated(3,[]);
 
2872
sizeLimitExceeded -> ?RT_BER:encode_enumerated(4,[]);
 
2873
compareFalse -> ?RT_BER:encode_enumerated(5,[]);
 
2874
compareTrue -> ?RT_BER:encode_enumerated(6,[]);
 
2875
authMethodNotSupported -> ?RT_BER:encode_enumerated(7,[]);
 
2876
strongAuthRequired -> ?RT_BER:encode_enumerated(8,[]);
 
2877
referral -> ?RT_BER:encode_enumerated(10,[]);
 
2878
adminLimitExceeded -> ?RT_BER:encode_enumerated(11,[]);
 
2879
unavailableCriticalExtension -> ?RT_BER:encode_enumerated(12,[]);
 
2880
confidentialityRequired -> ?RT_BER:encode_enumerated(13,[]);
 
2881
saslBindInProgress -> ?RT_BER:encode_enumerated(14,[]);
 
2882
noSuchAttribute -> ?RT_BER:encode_enumerated(16,[]);
 
2883
undefinedAttributeType -> ?RT_BER:encode_enumerated(17,[]);
 
2884
inappropriateMatching -> ?RT_BER:encode_enumerated(18,[]);
 
2885
constraintViolation -> ?RT_BER:encode_enumerated(19,[]);
 
2886
attributeOrValueExists -> ?RT_BER:encode_enumerated(20,[]);
 
2887
invalidAttributeSyntax -> ?RT_BER:encode_enumerated(21,[]);
 
2888
noSuchObject -> ?RT_BER:encode_enumerated(32,[]);
 
2889
aliasProblem -> ?RT_BER:encode_enumerated(33,[]);
 
2890
invalidDNSyntax -> ?RT_BER:encode_enumerated(34,[]);
 
2891
aliasDereferencingProblem -> ?RT_BER:encode_enumerated(36,[]);
 
2892
inappropriateAuthentication -> ?RT_BER:encode_enumerated(48,[]);
 
2893
invalidCredentials -> ?RT_BER:encode_enumerated(49,[]);
 
2894
insufficientAccessRights -> ?RT_BER:encode_enumerated(50,[]);
 
2895
busy -> ?RT_BER:encode_enumerated(51,[]);
 
2896
unavailable -> ?RT_BER:encode_enumerated(52,[]);
 
2897
unwillingToPerform -> ?RT_BER:encode_enumerated(53,[]);
 
2898
loopDetect -> ?RT_BER:encode_enumerated(54,[]);
 
2899
namingViolation -> ?RT_BER:encode_enumerated(64,[]);
 
2900
objectClassViolation -> ?RT_BER:encode_enumerated(65,[]);
 
2901
notAllowedOnNonLeaf -> ?RT_BER:encode_enumerated(66,[]);
 
2902
notAllowedOnRDN -> ?RT_BER:encode_enumerated(67,[]);
 
2903
entryAlreadyExists -> ?RT_BER:encode_enumerated(68,[]);
 
2904
objectClassModsProhibited -> ?RT_BER:encode_enumerated(69,[]);
 
2905
affectsMultipleDSAs -> ?RT_BER:encode_enumerated(71,[]);
 
2906
other -> ?RT_BER:encode_enumerated(80,[]);
 
2907
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
 
2908
end,
 
2909
 
 
2910
%%-------------------------------------------------
 
2911
%% attribute number 2 with type OCTET STRING
 
2912
%%-------------------------------------------------
 
2913
   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,matchedDN), []),
 
2914
 
 
2915
%%-------------------------------------------------
 
2916
%% attribute number 3 with type OCTET STRING
 
2917
%%-------------------------------------------------
 
2918
   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,errorMessage), []),
 
2919
 
 
2920
%%-------------------------------------------------
 
2921
%% attribute number 4   External ELDAPv3:Referral OPTIONAL
 
2922
%%-------------------------------------------------
 
2923
   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,referral) of
 
2924
         asn1_NOVALUE -> {<<>>,0};
 
2925
         _ ->
 
2926
            'enc_Referral'(?RT_BER:cindex(5,Val,referral), [{tag,128,3,'IMPLICIT',32}])
 
2927
       end,
 
2928
 
 
2929
%%-------------------------------------------------
 
2930
%% attribute number 5 with type OCTET STRING OPTIONAL
 
2931
%%-------------------------------------------------
 
2932
   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,responseName) of
 
2933
         asn1_NOVALUE -> {<<>>,0};
 
2934
         _ ->
 
2935
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(6,Val,responseName), [{tag,128,10,'IMPLICIT',32}])
 
2936
       end,
 
2937
 
 
2938
%%-------------------------------------------------
 
2939
%% attribute number 6 with type OCTET STRING OPTIONAL
 
2940
%%-------------------------------------------------
 
2941
   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,response) of
 
2942
         asn1_NOVALUE -> {<<>>,0};
 
2943
         _ ->
 
2944
            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(7,Val,response), [{tag,128,11,'IMPLICIT',32}])
 
2945
       end,
 
2946
 
 
2947
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],
 
2948
  LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,
 
2949
  ?RT_BER:encode_tags(TagIn ++ [{tag,64,24,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
 
2950
 
 
2951
 
 
2952
'dec_ExtendedResponse'(Bytes, OptOrMand) ->
 
2953
   'dec_ExtendedResponse'(Bytes, OptOrMand, []).
 
2954
 
 
2955
'dec_ExtendedResponse'(Bytes, OptOrMand, TagIn) ->
 
2956
   %%-------------------------------------------------
 
2957
   %% decode tag and length 
 
2958
   %%-------------------------------------------------
 
2959
   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,24,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
 
2960
{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
 
2961
 
 
2962
%%-------------------------------------------------
 
2963
%% attribute number 1 with type ENUMERATED
 
2964
%%-------------------------------------------------
 
2965
   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{success,0},{operationsError,1},{protocolError,2},{timeLimitExceeded,3},{sizeLimitExceeded,4},{compareFalse,5},{compareTrue,6},{authMethodNotSupported,7},{strongAuthRequired,8},{referral,10},{adminLimitExceeded,11},{unavailableCriticalExtension,12},{confidentialityRequired,13},{saslBindInProgress,14},{noSuchAttribute,16},{undefinedAttributeType,17},{inappropriateMatching,18},{constraintViolation,19},{attributeOrValueExists,20},{invalidAttributeSyntax,21},{noSuchObject,32},{aliasProblem,33},{invalidDNSyntax,34},{aliasDereferencingProblem,36},{inappropriateAuthentication,48},{invalidCredentials,49},{insufficientAccessRights,50},{busy,51},{unavailable,52},{unwillingToPerform,53},{loopDetect,54},{namingViolation,64},{objectClassViolation,65},{notAllowedOnNonLeaf,66},{notAllowedOnRDN,67},{entryAlreadyExists,68},{objectClassModsProhibited,69},{affectsMultipleDSAs,71},{other,80}],[], mandatory),
 
2966
 
 
2967
%%-------------------------------------------------
 
2968
%% attribute number 2 with type OCTET STRING
 
2969
%%-------------------------------------------------
 
2970
   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
 
2971
 
 
2972
%%-------------------------------------------------
 
2973
%% attribute number 3 with type OCTET STRING
 
2974
%%-------------------------------------------------
 
2975
   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory),
 
2976
 
 
2977
%%-------------------------------------------------
 
2978
%% attribute number 4   External ELDAPv3:Referral OPTIONAL
 
2979
%%-------------------------------------------------
 
2980
   {Term4,Bytes6,Rb5} = case Bytes5 of
 
2981
<<2:2,_:1,3:5,_/binary>> ->
 
2982
'dec_Referral'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',32}]);
 
2983
_ ->
 
2984
{ asn1_NOVALUE, Bytes5, 0 }
 
2985
end,
 
2986
 
 
2987
%%-------------------------------------------------
 
2988
%% attribute number 5 with type OCTET STRING OPTIONAL
 
2989
%%-------------------------------------------------
 
2990
   {Term5,Bytes7,Rb6} = case Bytes6 of
 
2991
<<2:2,_:1,10:5,_/binary>> ->
 
2992
?RT_BER:decode_octet_string(Bytes6,[],[{tag,128,10,'IMPLICIT',32}], no_length, mandatory);
 
2993
_ ->
 
2994
{ asn1_NOVALUE, Bytes6, 0 }
 
2995
end,
 
2996
 
 
2997
%%-------------------------------------------------
 
2998
%% attribute number 6 with type OCTET STRING OPTIONAL
 
2999
%%-------------------------------------------------
 
3000
   {Term6,Bytes8,Rb7} = case Bytes7 of
 
3001
<<2:2,_:1,11:5,_/binary>> ->
 
3002
?RT_BER:decode_octet_string(Bytes7,[],[{tag,128,11,'IMPLICIT',32}], no_length, mandatory);
 
3003
_ ->
 
3004
{ asn1_NOVALUE, Bytes7, 0 }
 
3005
end,
 
3006
 
 
3007
   {Bytes9,Rb8} = ?RT_BER:restbytes2(RemBytes, Bytes8,noext),
 
3008
   {{'ExtendedResponse', Term1, Term2, Term3, Term4, Term5, Term6}, Bytes9, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8}.
 
3009
'maxInt'() ->
 
3010
2147483647.
 
3011