• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

processone / ejabberd / 1296

19 Jan 2026 11:25AM UTC coverage: 33.562% (+0.09%) from 33.468%
1296

push

github

badlop
mod_conversejs: Cosmetic change: sort paths alphabetically

0 of 4 new or added lines in 1 file covered. (0.0%)

11245 existing lines in 174 files now uncovered.

15580 of 46421 relevant lines covered (33.56%)

1074.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

24.13
/src/ELDAPv3.erl
1
%% Generated by the Erlang ASN.1 BER_V2-compiler version, utilizing bit-syntax:2.0.1
2
%% Purpose: encoder and decoder to the types in mod ELDAPv3
3

4
-module('ELDAPv3').
5
-compile(nowarn_unused_vars).
6
-dialyzer(no_match).
7
-include("ELDAPv3.hrl").
8
-asn1_info([{vsn,'2.0.1'},
9
            {module,'ELDAPv3'},
10
            {options,[{i,"src"},{outdir,"src"},noobj,{i,"."},{i,"asn1"}]}]).
11

12
-export([encoding_rule/0,bit_string_format/0]).
13
-export([
14
'enc_LDAPMessage'/2,
15
'enc_MessageID'/2,
16
'enc_LDAPString'/2,
17
'enc_LDAPOID'/2,
18
'enc_LDAPDN'/2,
19
'enc_RelativeLDAPDN'/2,
20
'enc_AttributeType'/2,
21
'enc_AttributeDescription'/2,
22
'enc_AttributeDescriptionList'/2,
23
'enc_AttributeValue'/2,
24
'enc_AttributeValueAssertion'/2,
25
'enc_AssertionValue'/2,
26
'enc_Attribute'/2,
27
'enc_MatchingRuleId'/2,
28
'enc_LDAPResult'/2,
29
'enc_Referral'/2,
30
'enc_LDAPURL'/2,
31
'enc_Controls'/2,
32
'enc_Control'/2,
33
'enc_BindRequest'/2,
34
'enc_AuthenticationChoice'/2,
35
'enc_SaslCredentials'/2,
36
'enc_BindResponse'/2,
37
'enc_UnbindRequest'/2,
38
'enc_SearchRequest'/2,
39
'enc_Filter'/2,
40
'enc_SubstringFilter'/2,
41
'enc_MatchingRuleAssertion'/2,
42
'enc_SearchResultEntry'/2,
43
'enc_PartialAttributeList'/2,
44
'enc_SearchResultReference'/2,
45
'enc_SearchResultDone'/2,
46
'enc_ModifyRequest'/2,
47
'enc_AttributeTypeAndValues'/2,
48
'enc_ModifyResponse'/2,
49
'enc_AddRequest'/2,
50
'enc_AttributeList'/2,
51
'enc_AddResponse'/2,
52
'enc_DelRequest'/2,
53
'enc_DelResponse'/2,
54
'enc_ModifyDNRequest'/2,
55
'enc_ModifyDNResponse'/2,
56
'enc_CompareRequest'/2,
57
'enc_CompareResponse'/2,
58
'enc_AbandonRequest'/2,
59
'enc_ExtendedRequest'/2,
60
'enc_ExtendedResponse'/2,
61
'enc_PasswdModifyRequestValue'/2,
62
'enc_PasswdModifyResponseValue'/2
63
]).
64

65
-export([
66
'dec_LDAPMessage'/2,
67
'dec_MessageID'/2,
68
'dec_LDAPString'/2,
69
'dec_LDAPOID'/2,
70
'dec_LDAPDN'/2,
71
'dec_RelativeLDAPDN'/2,
72
'dec_AttributeType'/2,
73
'dec_AttributeDescription'/2,
74
'dec_AttributeDescriptionList'/2,
75
'dec_AttributeValue'/2,
76
'dec_AttributeValueAssertion'/2,
77
'dec_AssertionValue'/2,
78
'dec_Attribute'/2,
79
'dec_MatchingRuleId'/2,
80
'dec_LDAPResult'/2,
81
'dec_Referral'/2,
82
'dec_LDAPURL'/2,
83
'dec_Controls'/2,
84
'dec_Control'/2,
85
'dec_BindRequest'/2,
86
'dec_AuthenticationChoice'/2,
87
'dec_SaslCredentials'/2,
88
'dec_BindResponse'/2,
89
'dec_UnbindRequest'/2,
90
'dec_SearchRequest'/2,
91
'dec_Filter'/2,
92
'dec_SubstringFilter'/2,
93
'dec_MatchingRuleAssertion'/2,
94
'dec_SearchResultEntry'/2,
95
'dec_PartialAttributeList'/2,
96
'dec_SearchResultReference'/2,
97
'dec_SearchResultDone'/2,
98
'dec_ModifyRequest'/2,
99
'dec_AttributeTypeAndValues'/2,
100
'dec_ModifyResponse'/2,
101
'dec_AddRequest'/2,
102
'dec_AttributeList'/2,
103
'dec_AddResponse'/2,
104
'dec_DelRequest'/2,
105
'dec_DelResponse'/2,
106
'dec_ModifyDNRequest'/2,
107
'dec_ModifyDNResponse'/2,
108
'dec_CompareRequest'/2,
109
'dec_CompareResponse'/2,
110
'dec_AbandonRequest'/2,
111
'dec_ExtendedRequest'/2,
112
'dec_ExtendedResponse'/2,
113
'dec_PasswdModifyRequestValue'/2,
114
'dec_PasswdModifyResponseValue'/2
115
]).
116

117
-export([
118
'maxInt'/0,
119
'passwdModifyOID'/0
120
]).
121

122
-export([info/0]).
123

124

125
-export([encode/2,decode/2]).
126

127
encoding_rule() -> ber.
×
128

129
bit_string_format() -> bitstring.
×
130

131
encode(Type,Data) ->
132
case catch encode_disp(Type,Data) of
27✔
133
  {'EXIT',{error,Reason}} ->
134
    {error,Reason};
×
135
  {'EXIT',Reason} ->
136
    {error,{asn1,Reason}};
×
137
  {Bytes,_Len} ->
138
    {ok,iolist_to_binary(Bytes)};
27✔
139
  Bytes ->
140
    {ok,iolist_to_binary(Bytes)}
×
141
end.
142

143
decode(Type,Data) ->
144
case catch decode_disp(Type,element(1, ber_decode_nif(Data))) of
27✔
145
  {'EXIT',{error,Reason}} ->
146
    {error,Reason};
×
147
  {'EXIT',Reason} ->
148
    {error,{asn1,Reason}};
×
149
  Result ->
150
    {ok,Result}
27✔
151
end.
152

153
encode_disp('LDAPMessage',Data) -> 'enc_LDAPMessage'(Data);
27✔
154
encode_disp('MessageID',Data) -> 'enc_MessageID'(Data);
×
155
encode_disp('LDAPString',Data) -> 'enc_LDAPString'(Data);
×
156
encode_disp('LDAPOID',Data) -> 'enc_LDAPOID'(Data);
×
157
encode_disp('LDAPDN',Data) -> 'enc_LDAPDN'(Data);
×
158
encode_disp('RelativeLDAPDN',Data) -> 'enc_RelativeLDAPDN'(Data);
×
159
encode_disp('AttributeType',Data) -> 'enc_AttributeType'(Data);
×
160
encode_disp('AttributeDescription',Data) -> 'enc_AttributeDescription'(Data);
×
161
encode_disp('AttributeDescriptionList',Data) -> 'enc_AttributeDescriptionList'(Data);
×
162
encode_disp('AttributeValue',Data) -> 'enc_AttributeValue'(Data);
×
163
encode_disp('AttributeValueAssertion',Data) -> 'enc_AttributeValueAssertion'(Data);
×
164
encode_disp('AssertionValue',Data) -> 'enc_AssertionValue'(Data);
×
165
encode_disp('Attribute',Data) -> 'enc_Attribute'(Data);
×
166
encode_disp('MatchingRuleId',Data) -> 'enc_MatchingRuleId'(Data);
×
167
encode_disp('LDAPResult',Data) -> 'enc_LDAPResult'(Data);
×
168
encode_disp('Referral',Data) -> 'enc_Referral'(Data);
×
169
encode_disp('LDAPURL',Data) -> 'enc_LDAPURL'(Data);
×
170
encode_disp('Controls',Data) -> 'enc_Controls'(Data);
×
171
encode_disp('Control',Data) -> 'enc_Control'(Data);
×
172
encode_disp('BindRequest',Data) -> 'enc_BindRequest'(Data);
×
173
encode_disp('AuthenticationChoice',Data) -> 'enc_AuthenticationChoice'(Data);
×
174
encode_disp('SaslCredentials',Data) -> 'enc_SaslCredentials'(Data);
×
175
encode_disp('BindResponse',Data) -> 'enc_BindResponse'(Data);
×
176
encode_disp('UnbindRequest',Data) -> 'enc_UnbindRequest'(Data);
×
177
encode_disp('SearchRequest',Data) -> 'enc_SearchRequest'(Data);
×
178
encode_disp('Filter',Data) -> 'enc_Filter'(Data);
×
179
encode_disp('SubstringFilter',Data) -> 'enc_SubstringFilter'(Data);
×
180
encode_disp('MatchingRuleAssertion',Data) -> 'enc_MatchingRuleAssertion'(Data);
×
181
encode_disp('SearchResultEntry',Data) -> 'enc_SearchResultEntry'(Data);
×
182
encode_disp('PartialAttributeList',Data) -> 'enc_PartialAttributeList'(Data);
×
183
encode_disp('SearchResultReference',Data) -> 'enc_SearchResultReference'(Data);
×
184
encode_disp('SearchResultDone',Data) -> 'enc_SearchResultDone'(Data);
×
185
encode_disp('ModifyRequest',Data) -> 'enc_ModifyRequest'(Data);
×
186
encode_disp('AttributeTypeAndValues',Data) -> 'enc_AttributeTypeAndValues'(Data);
×
187
encode_disp('ModifyResponse',Data) -> 'enc_ModifyResponse'(Data);
×
188
encode_disp('AddRequest',Data) -> 'enc_AddRequest'(Data);
×
189
encode_disp('AttributeList',Data) -> 'enc_AttributeList'(Data);
×
190
encode_disp('AddResponse',Data) -> 'enc_AddResponse'(Data);
×
191
encode_disp('DelRequest',Data) -> 'enc_DelRequest'(Data);
×
192
encode_disp('DelResponse',Data) -> 'enc_DelResponse'(Data);
×
193
encode_disp('ModifyDNRequest',Data) -> 'enc_ModifyDNRequest'(Data);
×
194
encode_disp('ModifyDNResponse',Data) -> 'enc_ModifyDNResponse'(Data);
×
195
encode_disp('CompareRequest',Data) -> 'enc_CompareRequest'(Data);
×
196
encode_disp('CompareResponse',Data) -> 'enc_CompareResponse'(Data);
×
197
encode_disp('AbandonRequest',Data) -> 'enc_AbandonRequest'(Data);
×
198
encode_disp('ExtendedRequest',Data) -> 'enc_ExtendedRequest'(Data);
×
199
encode_disp('ExtendedResponse',Data) -> 'enc_ExtendedResponse'(Data);
×
200
encode_disp('PasswdModifyRequestValue',Data) -> 'enc_PasswdModifyRequestValue'(Data);
×
201
encode_disp('PasswdModifyResponseValue',Data) -> 'enc_PasswdModifyResponseValue'(Data);
×
202
encode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).
×
203

204

205
decode_disp('LDAPMessage',Data) -> 'dec_LDAPMessage'(Data);
27✔
206
decode_disp('MessageID',Data) -> 'dec_MessageID'(Data);
×
207
decode_disp('LDAPString',Data) -> 'dec_LDAPString'(Data);
×
208
decode_disp('LDAPOID',Data) -> 'dec_LDAPOID'(Data);
×
209
decode_disp('LDAPDN',Data) -> 'dec_LDAPDN'(Data);
×
210
decode_disp('RelativeLDAPDN',Data) -> 'dec_RelativeLDAPDN'(Data);
×
211
decode_disp('AttributeType',Data) -> 'dec_AttributeType'(Data);
×
212
decode_disp('AttributeDescription',Data) -> 'dec_AttributeDescription'(Data);
×
213
decode_disp('AttributeDescriptionList',Data) -> 'dec_AttributeDescriptionList'(Data);
×
214
decode_disp('AttributeValue',Data) -> 'dec_AttributeValue'(Data);
×
215
decode_disp('AttributeValueAssertion',Data) -> 'dec_AttributeValueAssertion'(Data);
×
216
decode_disp('AssertionValue',Data) -> 'dec_AssertionValue'(Data);
×
217
decode_disp('Attribute',Data) -> 'dec_Attribute'(Data);
×
218
decode_disp('MatchingRuleId',Data) -> 'dec_MatchingRuleId'(Data);
×
219
decode_disp('LDAPResult',Data) -> 'dec_LDAPResult'(Data);
×
220
decode_disp('Referral',Data) -> 'dec_Referral'(Data);
×
221
decode_disp('LDAPURL',Data) -> 'dec_LDAPURL'(Data);
×
222
decode_disp('Controls',Data) -> 'dec_Controls'(Data);
×
223
decode_disp('Control',Data) -> 'dec_Control'(Data);
×
224
decode_disp('BindRequest',Data) -> 'dec_BindRequest'(Data);
×
225
decode_disp('AuthenticationChoice',Data) -> 'dec_AuthenticationChoice'(Data);
×
226
decode_disp('SaslCredentials',Data) -> 'dec_SaslCredentials'(Data);
×
227
decode_disp('BindResponse',Data) -> 'dec_BindResponse'(Data);
×
228
decode_disp('UnbindRequest',Data) -> 'dec_UnbindRequest'(Data);
×
229
decode_disp('SearchRequest',Data) -> 'dec_SearchRequest'(Data);
×
230
decode_disp('Filter',Data) -> 'dec_Filter'(Data);
×
231
decode_disp('SubstringFilter',Data) -> 'dec_SubstringFilter'(Data);
×
232
decode_disp('MatchingRuleAssertion',Data) -> 'dec_MatchingRuleAssertion'(Data);
×
233
decode_disp('SearchResultEntry',Data) -> 'dec_SearchResultEntry'(Data);
×
234
decode_disp('PartialAttributeList',Data) -> 'dec_PartialAttributeList'(Data);
×
235
decode_disp('SearchResultReference',Data) -> 'dec_SearchResultReference'(Data);
×
236
decode_disp('SearchResultDone',Data) -> 'dec_SearchResultDone'(Data);
×
237
decode_disp('ModifyRequest',Data) -> 'dec_ModifyRequest'(Data);
×
238
decode_disp('AttributeTypeAndValues',Data) -> 'dec_AttributeTypeAndValues'(Data);
×
239
decode_disp('ModifyResponse',Data) -> 'dec_ModifyResponse'(Data);
×
240
decode_disp('AddRequest',Data) -> 'dec_AddRequest'(Data);
×
241
decode_disp('AttributeList',Data) -> 'dec_AttributeList'(Data);
×
242
decode_disp('AddResponse',Data) -> 'dec_AddResponse'(Data);
×
243
decode_disp('DelRequest',Data) -> 'dec_DelRequest'(Data);
×
244
decode_disp('DelResponse',Data) -> 'dec_DelResponse'(Data);
×
245
decode_disp('ModifyDNRequest',Data) -> 'dec_ModifyDNRequest'(Data);
×
246
decode_disp('ModifyDNResponse',Data) -> 'dec_ModifyDNResponse'(Data);
×
247
decode_disp('CompareRequest',Data) -> 'dec_CompareRequest'(Data);
×
248
decode_disp('CompareResponse',Data) -> 'dec_CompareResponse'(Data);
×
249
decode_disp('AbandonRequest',Data) -> 'dec_AbandonRequest'(Data);
×
250
decode_disp('ExtendedRequest',Data) -> 'dec_ExtendedRequest'(Data);
×
251
decode_disp('ExtendedResponse',Data) -> 'dec_ExtendedResponse'(Data);
×
252
decode_disp('PasswdModifyRequestValue',Data) -> 'dec_PasswdModifyRequestValue'(Data);
×
253
decode_disp('PasswdModifyResponseValue',Data) -> 'dec_PasswdModifyResponseValue'(Data);
×
254
decode_disp(Type,_Data) -> exit({error,{asn1,{undefined_type,Type}}}).
×
255

256

257

258

259

260
info() ->
261
   case ?MODULE:module_info(attributes) of
×
262
     Attributes when is_list(Attributes) ->
263
       case lists:keyfind(asn1_info, 1, Attributes) of
×
264
         {_,Info} when is_list(Info) ->
265
           Info;
×
266
         _ ->
267
           []
×
268
       end;
269
     _ ->
270
       []
×
271
   end.
272

273

274
%%================================
275
%%  LDAPMessage
276
%%================================
277
'enc_LDAPMessage'(Val) ->
278
    'enc_LDAPMessage'(Val, [<<48>>]).
27✔
279

280
'enc_LDAPMessage'(Val, TagIn) ->
281
{_,Cindex1, Cindex2, Cindex3} = Val,
27✔
282

283
%%-------------------------------------------------
284
%% attribute messageID(1) with type INTEGER
285
%%-------------------------------------------------
286
   {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]),
27✔
287

288
%%-------------------------------------------------
289
%% attribute protocolOp(2) with type CHOICE
290
%%-------------------------------------------------
291
   {EncBytes2,EncLen2} = 'enc_LDAPMessage_protocolOp'(Cindex2, []),
27✔
292

293
%%-------------------------------------------------
294
%% attribute controls(3)   External ELDAPv3:Controls OPTIONAL
295
%%-------------------------------------------------
296
   {EncBytes3,EncLen3} =  case Cindex3 of
27✔
297
         asn1_NOVALUE -> {<<>>,0};
27✔
298
         _ ->
299
            'enc_Controls'(Cindex3, [<<160>>])
×
300
       end,
301

302
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
27✔
303
LenSoFar = EncLen1 + EncLen2 + EncLen3,
27✔
304
encode_tags(TagIn, BytesSoFar, LenSoFar).
27✔
305

306

307

308
%%================================
309
%%  LDAPMessage_protocolOp
310
%%================================
311
'enc_LDAPMessage_protocolOp'(Val, TagIn) ->
312
      {EncBytes,EncLen} = case element(1,Val) of
27✔
313
      bindRequest ->
314
         'enc_BindRequest'(element(2,Val), [<<96>>]);
5✔
315
      bindResponse ->
316
         'enc_BindResponse'(element(2,Val), [<<97>>]);
5✔
317
      unbindRequest ->
318
         encode_null(element(2,Val), [<<66>>]);
×
319
      searchRequest ->
320
         'enc_SearchRequest'(element(2,Val), [<<99>>]);
6✔
321
      searchResEntry ->
322
         'enc_SearchResultEntry'(element(2,Val), [<<100>>]);
5✔
323
      searchResDone ->
324
         'enc_SearchResultDone'(element(2,Val), [<<101>>]);
6✔
325
      searchResRef ->
326
         'enc_SearchResultReference'(element(2,Val), [<<115>>]);
×
327
      modifyRequest ->
328
         'enc_ModifyRequest'(element(2,Val), [<<102>>]);
×
329
      modifyResponse ->
330
         'enc_ModifyResponse'(element(2,Val), [<<103>>]);
×
331
      addRequest ->
332
         'enc_AddRequest'(element(2,Val), [<<104>>]);
×
333
      addResponse ->
334
         'enc_AddResponse'(element(2,Val), [<<105>>]);
×
335
      delRequest ->
336
         encode_restricted_string(element(2,Val), [<<74>>]);
×
337
      delResponse ->
338
         'enc_DelResponse'(element(2,Val), [<<107>>]);
×
339
      modDNRequest ->
340
         'enc_ModifyDNRequest'(element(2,Val), [<<108>>]);
×
341
      modDNResponse ->
342
         'enc_ModifyDNResponse'(element(2,Val), [<<109>>]);
×
343
      compareRequest ->
344
         'enc_CompareRequest'(element(2,Val), [<<110>>]);
×
345
      compareResponse ->
346
         'enc_CompareResponse'(element(2,Val), [<<111>>]);
×
347
      abandonRequest ->
348
         encode_integer(element(2,Val), [<<80>>]);
×
349
      extendedReq ->
350
         'enc_ExtendedRequest'(element(2,Val), [<<119>>]);
×
351
      extendedResp ->
352
         'enc_ExtendedResponse'(element(2,Val), [<<120>>]);
×
353
      Else ->
354
         exit({error,{asn1,{invalid_choice_type,Else}}})
×
355
   end,
356

357
encode_tags(TagIn, EncBytes, EncLen).
27✔
358

359

360
'dec_LDAPMessage_protocolOp'(Tlv, TagIn) ->
361
Tlv1 = match_tags(Tlv, TagIn),
27✔
362
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
27✔
363

364
%% 'bindRequest'
365
    {65536, V1} ->
366
        {bindRequest, 'dec_BindRequest'(V1, [])};
5✔
367

368

369
%% 'bindResponse'
370
    {65537, V1} ->
371
        {bindResponse, 'dec_BindResponse'(V1, [])};
5✔
372

373

374
%% 'unbindRequest'
375
    {65538, V1} ->
376
        {unbindRequest, decode_null(V1,[])};
×
377

378

379
%% 'searchRequest'
380
    {65539, V1} ->
381
        {searchRequest, 'dec_SearchRequest'(V1, [])};
6✔
382

383

384
%% 'searchResEntry'
385
    {65540, V1} ->
386
        {searchResEntry, 'dec_SearchResultEntry'(V1, [])};
5✔
387

388

389
%% 'searchResDone'
390
    {65541, V1} ->
391
        {searchResDone, 'dec_SearchResultDone'(V1, [])};
6✔
392

393

394
%% 'searchResRef'
395
    {65555, V1} ->
396
        {searchResRef, 'dec_SearchResultReference'(V1, [])};
×
397

398

399
%% 'modifyRequest'
400
    {65542, V1} ->
401
        {modifyRequest, 'dec_ModifyRequest'(V1, [])};
×
402

403

404
%% 'modifyResponse'
405
    {65543, V1} ->
406
        {modifyResponse, 'dec_ModifyResponse'(V1, [])};
×
407

408

409
%% 'addRequest'
410
    {65544, V1} ->
411
        {addRequest, 'dec_AddRequest'(V1, [])};
×
412

413

414
%% 'addResponse'
415
    {65545, V1} ->
416
        {addResponse, 'dec_AddResponse'(V1, [])};
×
417

418

419
%% 'delRequest'
420
    {65546, V1} ->
421
        {delRequest, decode_restricted_string(V1,[])};
×
422

423

424
%% 'delResponse'
425
    {65547, V1} ->
426
        {delResponse, 'dec_DelResponse'(V1, [])};
×
427

428

429
%% 'modDNRequest'
430
    {65548, V1} ->
431
        {modDNRequest, 'dec_ModifyDNRequest'(V1, [])};
×
432

433

434
%% 'modDNResponse'
435
    {65549, V1} ->
436
        {modDNResponse, 'dec_ModifyDNResponse'(V1, [])};
×
437

438

439
%% 'compareRequest'
440
    {65550, V1} ->
441
        {compareRequest, 'dec_CompareRequest'(V1, [])};
×
442

443

444
%% 'compareResponse'
445
    {65551, V1} ->
446
        {compareResponse, 'dec_CompareResponse'(V1, [])};
×
447

448

449
%% 'abandonRequest'
450
    {65552, V1} ->
451
        {abandonRequest, decode_integer(V1,{0,2147483647},[])};
×
452

453

454
%% 'extendedReq'
455
    {65559, V1} ->
456
        {extendedReq, 'dec_ExtendedRequest'(V1, [])};
×
457

458

459
%% 'extendedResp'
460
    {65560, V1} ->
461
        {extendedResp, 'dec_ExtendedResponse'(V1, [])};
×
462

463
      Else ->
464
         exit({error,{asn1,{invalid_choice_tag,Else}}})
×
465
   end
466
.
467

468

469
'dec_LDAPMessage'(Tlv) ->
470
   'dec_LDAPMessage'(Tlv, [16]).
27✔
471

472
'dec_LDAPMessage'(Tlv, TagIn) ->
473
   %%-------------------------------------------------
474
   %% decode tag and length
475
   %%-------------------------------------------------
476
Tlv1 = match_tags(Tlv, TagIn),
27✔
477

478
%%-------------------------------------------------
479
%% attribute messageID(1) with type INTEGER
480
%%-------------------------------------------------
481
[V1|Tlv2] = Tlv1,
27✔
482
Term1 = decode_integer(V1,{0,2147483647},[2]),
27✔
483

484
%%-------------------------------------------------
485
%% attribute protocolOp(2) with type CHOICE
486
%%-------------------------------------------------
487
[V2|Tlv3] = Tlv2,
27✔
488
Term2 = 'dec_LDAPMessage_protocolOp'(V2, []),
27✔
489

490
%%-------------------------------------------------
491
%% attribute controls(3)   External ELDAPv3:Controls OPTIONAL
492
%%-------------------------------------------------
493
{Term3,Tlv4} = case Tlv3 of
27✔
494
[{131072,V3}|TempTlv4] ->
495
    {'dec_Controls'(V3, []), TempTlv4};
×
496
    _ ->
497
        { asn1_NOVALUE, Tlv3}
27✔
498
end,
499

500
case Tlv4 of
27✔
501
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
27✔
502
end,
503
   {'LDAPMessage', Term1, Term2, Term3}.
27✔
504

505

506

507
%%================================
508
%%  MessageID
509
%%================================
510
'enc_MessageID'(Val) ->
511
    'enc_MessageID'(Val, [<<2>>]).
×
512

513
'enc_MessageID'(Val, TagIn) ->
514
encode_integer(Val, TagIn).
×
515

516

517
'dec_MessageID'(Tlv) ->
518
   'dec_MessageID'(Tlv, [2]).
×
519

520
'dec_MessageID'(Tlv, TagIn) ->
521
decode_integer(Tlv,{0,2147483647},TagIn).
×
522

523

524

525
%%================================
526
%%  LDAPString
527
%%================================
528
'enc_LDAPString'(Val) ->
529
    'enc_LDAPString'(Val, [<<4>>]).
×
530

531
'enc_LDAPString'(Val, TagIn) ->
532
encode_restricted_string(Val, TagIn).
×
533

534

535
'dec_LDAPString'(Tlv) ->
536
   'dec_LDAPString'(Tlv, [4]).
×
537

538
'dec_LDAPString'(Tlv, TagIn) ->
539
decode_restricted_string(Tlv,TagIn).
×
540

541

542

543
%%================================
544
%%  LDAPOID
545
%%================================
546
'enc_LDAPOID'(Val) ->
547
    'enc_LDAPOID'(Val, [<<4>>]).
×
548

549
'enc_LDAPOID'(Val, TagIn) ->
550
encode_restricted_string(Val, TagIn).
×
551

552

553
'dec_LDAPOID'(Tlv) ->
554
   'dec_LDAPOID'(Tlv, [4]).
×
555

556
'dec_LDAPOID'(Tlv, TagIn) ->
557
decode_restricted_string(Tlv,TagIn).
×
558

559

560

561
%%================================
562
%%  LDAPDN
563
%%================================
564
'enc_LDAPDN'(Val) ->
565
    'enc_LDAPDN'(Val, [<<4>>]).
×
566

567
'enc_LDAPDN'(Val, TagIn) ->
568
encode_restricted_string(Val, TagIn).
×
569

570

571
'dec_LDAPDN'(Tlv) ->
572
   'dec_LDAPDN'(Tlv, [4]).
×
573

574
'dec_LDAPDN'(Tlv, TagIn) ->
575
decode_restricted_string(Tlv,TagIn).
×
576

577

578

579
%%================================
580
%%  RelativeLDAPDN
581
%%================================
582
'enc_RelativeLDAPDN'(Val) ->
583
    'enc_RelativeLDAPDN'(Val, [<<4>>]).
×
584

585
'enc_RelativeLDAPDN'(Val, TagIn) ->
586
encode_restricted_string(Val, TagIn).
×
587

588

589
'dec_RelativeLDAPDN'(Tlv) ->
590
   'dec_RelativeLDAPDN'(Tlv, [4]).
×
591

592
'dec_RelativeLDAPDN'(Tlv, TagIn) ->
593
decode_restricted_string(Tlv,TagIn).
×
594

595

596

597
%%================================
598
%%  AttributeType
599
%%================================
600
'enc_AttributeType'(Val) ->
601
    'enc_AttributeType'(Val, [<<4>>]).
×
602

603
'enc_AttributeType'(Val, TagIn) ->
604
encode_restricted_string(Val, TagIn).
×
605

606

607
'dec_AttributeType'(Tlv) ->
608
   'dec_AttributeType'(Tlv, [4]).
×
609

610
'dec_AttributeType'(Tlv, TagIn) ->
611
decode_restricted_string(Tlv,TagIn).
×
612

613

614

615
%%================================
616
%%  AttributeDescription
617
%%================================
618
'enc_AttributeDescription'(Val) ->
619
    'enc_AttributeDescription'(Val, [<<4>>]).
×
620

621
'enc_AttributeDescription'(Val, TagIn) ->
622
encode_restricted_string(Val, TagIn).
×
623

624

625
'dec_AttributeDescription'(Tlv) ->
626
   'dec_AttributeDescription'(Tlv, [4]).
×
627

628
'dec_AttributeDescription'(Tlv, TagIn) ->
629
decode_restricted_string(Tlv,TagIn).
×
630

631

632

633
%%================================
634
%%  AttributeDescriptionList
635
%%================================
636
'enc_AttributeDescriptionList'(Val) ->
637
    'enc_AttributeDescriptionList'(Val, [<<48>>]).
×
638

639
'enc_AttributeDescriptionList'(Val, TagIn) ->
640
   {EncBytes,EncLen} = 'enc_AttributeDescriptionList_components'(Val,[],0),
6✔
641
   encode_tags(TagIn, EncBytes, EncLen).
6✔
642

643
'enc_AttributeDescriptionList_components'([], AccBytes, AccLen) ->
644
   {lists:reverse(AccBytes),AccLen};
6✔
645

646
'enc_AttributeDescriptionList_components'([H|T],AccBytes, AccLen) ->
647
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
28✔
648
   'enc_AttributeDescriptionList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
28✔
649

650

651

652
'dec_AttributeDescriptionList'(Tlv) ->
653
   'dec_AttributeDescriptionList'(Tlv, [16]).
×
654

655
'dec_AttributeDescriptionList'(Tlv, TagIn) ->
656
   %%-------------------------------------------------
657
   %% decode tag and length
658
   %%-------------------------------------------------
659
Tlv1 = match_tags(Tlv, TagIn),
6✔
660
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
6✔
661

662

663

664

665
%%================================
666
%%  AttributeValue
667
%%================================
668
'enc_AttributeValue'(Val) ->
669
    'enc_AttributeValue'(Val, [<<4>>]).
×
670

671
'enc_AttributeValue'(Val, TagIn) ->
672
encode_restricted_string(Val, TagIn).
×
673

674

675
'dec_AttributeValue'(Tlv) ->
676
   'dec_AttributeValue'(Tlv, [4]).
×
677

678
'dec_AttributeValue'(Tlv, TagIn) ->
679
decode_restricted_string(Tlv,TagIn).
×
680

681

682

683
%%================================
684
%%  AttributeValueAssertion
685
%%================================
686
'enc_AttributeValueAssertion'(Val) ->
687
    'enc_AttributeValueAssertion'(Val, [<<48>>]).
×
688

689
'enc_AttributeValueAssertion'(Val, TagIn) ->
690
{_,Cindex1, Cindex2} = Val,
7✔
691

692
%%-------------------------------------------------
693
%% attribute attributeDesc(1) with type OCTET STRING
694
%%-------------------------------------------------
695
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
7✔
696

697
%%-------------------------------------------------
698
%% attribute assertionValue(2) with type OCTET STRING
699
%%-------------------------------------------------
700
   {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
7✔
701

702
   BytesSoFar = [EncBytes1, EncBytes2],
7✔
703
LenSoFar = EncLen1 + EncLen2,
7✔
704
encode_tags(TagIn, BytesSoFar, LenSoFar).
7✔
705

706

707
'dec_AttributeValueAssertion'(Tlv) ->
708
   'dec_AttributeValueAssertion'(Tlv, [16]).
×
709

710
'dec_AttributeValueAssertion'(Tlv, TagIn) ->
711
   %%-------------------------------------------------
712
   %% decode tag and length
713
   %%-------------------------------------------------
714
Tlv1 = match_tags(Tlv, TagIn),
7✔
715

716
%%-------------------------------------------------
717
%% attribute attributeDesc(1) with type OCTET STRING
718
%%-------------------------------------------------
719
[V1|Tlv2] = Tlv1,
7✔
720
Term1 = decode_restricted_string(V1,[4]),
7✔
721

722
%%-------------------------------------------------
723
%% attribute assertionValue(2) with type OCTET STRING
724
%%-------------------------------------------------
725
[V2|Tlv3] = Tlv2,
7✔
726
Term2 = decode_restricted_string(V2,[4]),
7✔
727

728
case Tlv3 of
7✔
729
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
7✔
730
end,
731
   {'AttributeValueAssertion', Term1, Term2}.
7✔
732

733

734

735
%%================================
736
%%  AssertionValue
737
%%================================
738
'enc_AssertionValue'(Val) ->
739
    'enc_AssertionValue'(Val, [<<4>>]).
×
740

741
'enc_AssertionValue'(Val, TagIn) ->
742
encode_restricted_string(Val, TagIn).
×
743

744

745
'dec_AssertionValue'(Tlv) ->
746
   'dec_AssertionValue'(Tlv, [4]).
×
747

748
'dec_AssertionValue'(Tlv, TagIn) ->
749
decode_restricted_string(Tlv,TagIn).
×
750

751

752

753
%%================================
754
%%  Attribute
755
%%================================
756
'enc_Attribute'(Val) ->
757
    'enc_Attribute'(Val, [<<48>>]).
×
758

759
'enc_Attribute'(Val, TagIn) ->
760
{_,Cindex1, Cindex2} = Val,
×
761

762
%%-------------------------------------------------
763
%% attribute type(1) with type OCTET STRING
764
%%-------------------------------------------------
765
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
766

767
%%-------------------------------------------------
768
%% attribute vals(2) with type SET OF
769
%%-------------------------------------------------
770
   {EncBytes2,EncLen2} = 'enc_Attribute_vals'(Cindex2, [<<49>>]),
×
771

772
   BytesSoFar = [EncBytes1, EncBytes2],
×
773
LenSoFar = EncLen1 + EncLen2,
×
774
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
775

776

777

778
%%================================
779
%%  Attribute_vals
780
%%================================
781
'enc_Attribute_vals'(Val, TagIn) ->
782
      {EncBytes,EncLen} = 'enc_Attribute_vals_components'(Val,[],0),
×
783
   encode_tags(TagIn, EncBytes, EncLen).
×
784

785
'enc_Attribute_vals_components'([], AccBytes, AccLen) ->
786
   {lists:reverse(AccBytes),AccLen};
×
787

788
'enc_Attribute_vals_components'([H|T],AccBytes, AccLen) ->
789
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
×
790
   'enc_Attribute_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
791

792
'dec_Attribute_vals'(Tlv, TagIn) ->
793
   %%-------------------------------------------------
794
   %% decode tag and length
795
   %%-------------------------------------------------
796
Tlv1 = match_tags(Tlv, TagIn),
×
797
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
×
798

799

800

801

802
'dec_Attribute'(Tlv) ->
803
   'dec_Attribute'(Tlv, [16]).
×
804

805
'dec_Attribute'(Tlv, TagIn) ->
806
   %%-------------------------------------------------
807
   %% decode tag and length
808
   %%-------------------------------------------------
809
Tlv1 = match_tags(Tlv, TagIn),
×
810

811
%%-------------------------------------------------
812
%% attribute type(1) with type OCTET STRING
813
%%-------------------------------------------------
814
[V1|Tlv2] = Tlv1,
×
815
Term1 = decode_restricted_string(V1,[4]),
×
816

817
%%-------------------------------------------------
818
%% attribute vals(2) with type SET OF
819
%%-------------------------------------------------
820
[V2|Tlv3] = Tlv2,
×
821
Term2 = 'dec_Attribute_vals'(V2, [17]),
×
822

823
case Tlv3 of
×
824
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
825
end,
826
   {'Attribute', Term1, Term2}.
×
827

828

829

830
%%================================
831
%%  MatchingRuleId
832
%%================================
833
'enc_MatchingRuleId'(Val) ->
834
    'enc_MatchingRuleId'(Val, [<<4>>]).
×
835

836
'enc_MatchingRuleId'(Val, TagIn) ->
837
encode_restricted_string(Val, TagIn).
×
838

839

840
'dec_MatchingRuleId'(Tlv) ->
841
   'dec_MatchingRuleId'(Tlv, [4]).
×
842

843
'dec_MatchingRuleId'(Tlv, TagIn) ->
844
decode_restricted_string(Tlv,TagIn).
×
845

846

847

848
%%================================
849
%%  LDAPResult
850
%%================================
851
'enc_LDAPResult'(Val) ->
852
    'enc_LDAPResult'(Val, [<<48>>]).
×
853

854
'enc_LDAPResult'(Val, TagIn) ->
855
{_,Cindex1, Cindex2, Cindex3, Cindex4} = Val,
6✔
856

857
%%-------------------------------------------------
858
%% attribute resultCode(1) with type ENUMERATED
859
%%-------------------------------------------------
860
   {EncBytes1,EncLen1} = case Cindex1 of
6✔
861
success -> encode_enumerated(0, [<<10>>]);
6✔
862
operationsError -> encode_enumerated(1, [<<10>>]);
×
863
protocolError -> encode_enumerated(2, [<<10>>]);
×
864
timeLimitExceeded -> encode_enumerated(3, [<<10>>]);
×
865
sizeLimitExceeded -> encode_enumerated(4, [<<10>>]);
×
866
compareFalse -> encode_enumerated(5, [<<10>>]);
×
867
compareTrue -> encode_enumerated(6, [<<10>>]);
×
868
authMethodNotSupported -> encode_enumerated(7, [<<10>>]);
×
869
strongAuthRequired -> encode_enumerated(8, [<<10>>]);
×
870
referral -> encode_enumerated(10, [<<10>>]);
×
871
adminLimitExceeded -> encode_enumerated(11, [<<10>>]);
×
872
unavailableCriticalExtension -> encode_enumerated(12, [<<10>>]);
×
873
confidentialityRequired -> encode_enumerated(13, [<<10>>]);
×
874
saslBindInProgress -> encode_enumerated(14, [<<10>>]);
×
875
noSuchAttribute -> encode_enumerated(16, [<<10>>]);
×
876
undefinedAttributeType -> encode_enumerated(17, [<<10>>]);
×
877
inappropriateMatching -> encode_enumerated(18, [<<10>>]);
×
878
constraintViolation -> encode_enumerated(19, [<<10>>]);
×
879
attributeOrValueExists -> encode_enumerated(20, [<<10>>]);
×
880
invalidAttributeSyntax -> encode_enumerated(21, [<<10>>]);
×
881
noSuchObject -> encode_enumerated(32, [<<10>>]);
×
882
aliasProblem -> encode_enumerated(33, [<<10>>]);
×
883
invalidDNSyntax -> encode_enumerated(34, [<<10>>]);
×
884
aliasDereferencingProblem -> encode_enumerated(36, [<<10>>]);
×
885
inappropriateAuthentication -> encode_enumerated(48, [<<10>>]);
×
886
invalidCredentials -> encode_enumerated(49, [<<10>>]);
×
887
insufficientAccessRights -> encode_enumerated(50, [<<10>>]);
×
888
busy -> encode_enumerated(51, [<<10>>]);
×
889
unavailable -> encode_enumerated(52, [<<10>>]);
×
890
unwillingToPerform -> encode_enumerated(53, [<<10>>]);
×
891
loopDetect -> encode_enumerated(54, [<<10>>]);
×
892
namingViolation -> encode_enumerated(64, [<<10>>]);
×
893
objectClassViolation -> encode_enumerated(65, [<<10>>]);
×
894
notAllowedOnNonLeaf -> encode_enumerated(66, [<<10>>]);
×
895
notAllowedOnRDN -> encode_enumerated(67, [<<10>>]);
×
896
entryAlreadyExists -> encode_enumerated(68, [<<10>>]);
×
897
objectClassModsProhibited -> encode_enumerated(69, [<<10>>]);
×
898
affectsMultipleDSAs -> encode_enumerated(71, [<<10>>]);
×
899
other -> encode_enumerated(80, [<<10>>]);
×
900
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
×
901
end,
902

903
%%-------------------------------------------------
904
%% attribute matchedDN(2) with type OCTET STRING
905
%%-------------------------------------------------
906
   {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
6✔
907

908
%%-------------------------------------------------
909
%% attribute errorMessage(3) with type OCTET STRING
910
%%-------------------------------------------------
911
   {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]),
6✔
912

913
%%-------------------------------------------------
914
%% attribute referral(4)   External ELDAPv3:Referral OPTIONAL
915
%%-------------------------------------------------
916
   {EncBytes4,EncLen4} =  case Cindex4 of
6✔
917
         asn1_NOVALUE -> {<<>>,0};
6✔
918
         _ ->
919
            'enc_Referral'(Cindex4, [<<163>>])
×
920
       end,
921

922
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
6✔
923
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
6✔
924
encode_tags(TagIn, BytesSoFar, LenSoFar).
6✔
925

926

927
'dec_LDAPResult'(Tlv) ->
928
   'dec_LDAPResult'(Tlv, [16]).
×
929

930
'dec_LDAPResult'(Tlv, TagIn) ->
931
   %%-------------------------------------------------
932
   %% decode tag and length
933
   %%-------------------------------------------------
934
Tlv1 = match_tags(Tlv, TagIn),
6✔
935

936
%%-------------------------------------------------
937
%% attribute resultCode(1) with type ENUMERATED
938
%%-------------------------------------------------
939
[V1|Tlv2] = Tlv1,
6✔
940
Term1 = decode_enumerated(V1,[{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}],[10]),
6✔
941

942
%%-------------------------------------------------
943
%% attribute matchedDN(2) with type OCTET STRING
944
%%-------------------------------------------------
945
[V2|Tlv3] = Tlv2,
6✔
946
Term2 = decode_restricted_string(V2,[4]),
6✔
947

948
%%-------------------------------------------------
949
%% attribute errorMessage(3) with type OCTET STRING
950
%%-------------------------------------------------
951
[V3|Tlv4] = Tlv3,
6✔
952
Term3 = decode_restricted_string(V3,[4]),
6✔
953

954
%%-------------------------------------------------
955
%% attribute referral(4)   External ELDAPv3:Referral OPTIONAL
956
%%-------------------------------------------------
957
{Term4,Tlv5} = case Tlv4 of
6✔
958
[{131075,V4}|TempTlv5] ->
959
    {'dec_Referral'(V4, []), TempTlv5};
×
960
    _ ->
961
        { asn1_NOVALUE, Tlv4}
6✔
962
end,
963

964
case Tlv5 of
6✔
965
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed
6✔
966
end,
967
   {'LDAPResult', Term1, Term2, Term3, Term4}.
6✔
968

969

970

971
%%================================
972
%%  Referral
973
%%================================
974
'enc_Referral'(Val) ->
975
    'enc_Referral'(Val, [<<48>>]).
×
976

977
'enc_Referral'(Val, TagIn) ->
978
   {EncBytes,EncLen} = 'enc_Referral_components'(Val,[],0),
×
979
   encode_tags(TagIn, EncBytes, EncLen).
×
980

981
'enc_Referral_components'([], AccBytes, AccLen) ->
982
   {lists:reverse(AccBytes),AccLen};
×
983

984
'enc_Referral_components'([H|T],AccBytes, AccLen) ->
985
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
×
986
   'enc_Referral_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
987

988

989

990
'dec_Referral'(Tlv) ->
991
   'dec_Referral'(Tlv, [16]).
×
992

993
'dec_Referral'(Tlv, TagIn) ->
994
   %%-------------------------------------------------
995
   %% decode tag and length
996
   %%-------------------------------------------------
997
Tlv1 = match_tags(Tlv, TagIn),
×
998
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
×
999

1000

1001

1002

1003
%%================================
1004
%%  LDAPURL
1005
%%================================
1006
'enc_LDAPURL'(Val) ->
1007
    'enc_LDAPURL'(Val, [<<4>>]).
×
1008

1009
'enc_LDAPURL'(Val, TagIn) ->
1010
encode_restricted_string(Val, TagIn).
×
1011

1012

1013
'dec_LDAPURL'(Tlv) ->
1014
   'dec_LDAPURL'(Tlv, [4]).
×
1015

1016
'dec_LDAPURL'(Tlv, TagIn) ->
1017
decode_restricted_string(Tlv,TagIn).
×
1018

1019

1020

1021
%%================================
1022
%%  Controls
1023
%%================================
1024
'enc_Controls'(Val) ->
1025
    'enc_Controls'(Val, [<<48>>]).
×
1026

1027
'enc_Controls'(Val, TagIn) ->
1028
   {EncBytes,EncLen} = 'enc_Controls_components'(Val,[],0),
×
1029
   encode_tags(TagIn, EncBytes, EncLen).
×
1030

1031
'enc_Controls_components'([], AccBytes, AccLen) ->
1032
   {lists:reverse(AccBytes),AccLen};
×
1033

1034
'enc_Controls_components'([H|T],AccBytes, AccLen) ->
1035
   {EncBytes,EncLen} = 'enc_Control'(H, [<<48>>]),
×
1036
   'enc_Controls_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
1037

1038

1039

1040
'dec_Controls'(Tlv) ->
1041
   'dec_Controls'(Tlv, [16]).
×
1042

1043
'dec_Controls'(Tlv, TagIn) ->
1044
   %%-------------------------------------------------
1045
   %% decode tag and length
1046
   %%-------------------------------------------------
1047
Tlv1 = match_tags(Tlv, TagIn),
×
1048
['dec_Control'(V1, [16]) || V1 <- Tlv1].
×
1049

1050

1051

1052

1053
%%================================
1054
%%  Control
1055
%%================================
1056
'enc_Control'(Val) ->
1057
    'enc_Control'(Val, [<<48>>]).
×
1058

1059
'enc_Control'(Val, TagIn) ->
1060
{_,Cindex1, Cindex2, Cindex3} = Val,
×
1061

1062
%%-------------------------------------------------
1063
%% attribute controlType(1) with type OCTET STRING
1064
%%-------------------------------------------------
1065
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
1066

1067
%%-------------------------------------------------
1068
%% attribute criticality(2) with type BOOLEAN DEFAULT = false
1069
%%-------------------------------------------------
1070
   {EncBytes2,EncLen2} =  case Cindex2 of
×
1071
         asn1_DEFAULT -> {<<>>,0};
×
1072
         false -> {<<>>,0};
×
1073
         _ ->
1074
            encode_boolean(Cindex2, [<<1>>])
×
1075
       end,
1076

1077
%%-------------------------------------------------
1078
%% attribute controlValue(3) with type OCTET STRING OPTIONAL
1079
%%-------------------------------------------------
1080
   {EncBytes3,EncLen3} =  case Cindex3 of
×
1081
         asn1_NOVALUE -> {<<>>,0};
×
1082
         _ ->
1083
            encode_restricted_string(Cindex3, [<<4>>])
×
1084
       end,
1085

1086
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
×
1087
LenSoFar = EncLen1 + EncLen2 + EncLen3,
×
1088
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
1089

1090

1091
'dec_Control'(Tlv) ->
1092
   'dec_Control'(Tlv, [16]).
×
1093

1094
'dec_Control'(Tlv, TagIn) ->
1095
   %%-------------------------------------------------
1096
   %% decode tag and length
1097
   %%-------------------------------------------------
1098
Tlv1 = match_tags(Tlv, TagIn),
×
1099

1100
%%-------------------------------------------------
1101
%% attribute controlType(1) with type OCTET STRING
1102
%%-------------------------------------------------
1103
[V1|Tlv2] = Tlv1,
×
1104
Term1 = decode_restricted_string(V1,[4]),
×
1105

1106
%%-------------------------------------------------
1107
%% attribute criticality(2) with type BOOLEAN DEFAULT = false
1108
%%-------------------------------------------------
1109
{Term2,Tlv3} = case Tlv2 of
×
1110
[{1,V2}|TempTlv3] ->
1111
    {decode_boolean(V2,[]), TempTlv3};
×
1112
    _ ->
1113
        {false,Tlv2}
×
1114
end,
1115

1116
%%-------------------------------------------------
1117
%% attribute controlValue(3) with type OCTET STRING OPTIONAL
1118
%%-------------------------------------------------
1119
{Term3,Tlv4} = case Tlv3 of
×
1120
[{4,V3}|TempTlv4] ->
1121
    {decode_restricted_string(V3,[]), TempTlv4};
×
1122
    _ ->
1123
        { asn1_NOVALUE, Tlv3}
×
1124
end,
1125

1126
case Tlv4 of
×
1127
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
×
1128
end,
1129
   {'Control', Term1, Term2, Term3}.
×
1130

1131

1132

1133
%%================================
1134
%%  BindRequest
1135
%%================================
1136
'enc_BindRequest'(Val) ->
1137
    'enc_BindRequest'(Val, [<<96>>]).
×
1138

1139
'enc_BindRequest'(Val, TagIn) ->
1140
{_,Cindex1, Cindex2, Cindex3} = Val,
5✔
1141

1142
%%-------------------------------------------------
1143
%% attribute version(1) with type INTEGER
1144
%%-------------------------------------------------
1145
   {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]),
5✔
1146

1147
%%-------------------------------------------------
1148
%% attribute name(2) with type OCTET STRING
1149
%%-------------------------------------------------
1150
   {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
5✔
1151

1152
%%-------------------------------------------------
1153
%% attribute authentication(3)   External ELDAPv3:AuthenticationChoice
1154
%%-------------------------------------------------
1155
   {EncBytes3,EncLen3} = 'enc_AuthenticationChoice'(Cindex3, []),
5✔
1156

1157
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
5✔
1158
LenSoFar = EncLen1 + EncLen2 + EncLen3,
5✔
1159
encode_tags(TagIn, BytesSoFar, LenSoFar).
5✔
1160

1161

1162
'dec_BindRequest'(Tlv) ->
1163
   'dec_BindRequest'(Tlv, [65536]).
×
1164

1165
'dec_BindRequest'(Tlv, TagIn) ->
1166
   %%-------------------------------------------------
1167
   %% decode tag and length
1168
   %%-------------------------------------------------
1169
Tlv1 = match_tags(Tlv, TagIn),
5✔
1170

1171
%%-------------------------------------------------
1172
%% attribute version(1) with type INTEGER
1173
%%-------------------------------------------------
1174
[V1|Tlv2] = Tlv1,
5✔
1175
Term1 = decode_integer(V1,{1,127},[2]),
5✔
1176

1177
%%-------------------------------------------------
1178
%% attribute name(2) with type OCTET STRING
1179
%%-------------------------------------------------
1180
[V2|Tlv3] = Tlv2,
5✔
1181
Term2 = decode_restricted_string(V2,[4]),
5✔
1182

1183
%%-------------------------------------------------
1184
%% attribute authentication(3)   External ELDAPv3:AuthenticationChoice
1185
%%-------------------------------------------------
1186
[V3|Tlv4] = Tlv3,
5✔
1187
Term3 = 'dec_AuthenticationChoice'(V3, []),
5✔
1188

1189
case Tlv4 of
5✔
1190
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
5✔
1191
end,
1192
   {'BindRequest', Term1, Term2, Term3}.
5✔
1193

1194

1195

1196
%%================================
1197
%%  AuthenticationChoice
1198
%%================================
1199
'enc_AuthenticationChoice'(Val) ->
1200
    'enc_AuthenticationChoice'(Val, []).
×
1201

1202
'enc_AuthenticationChoice'(Val, TagIn) ->
1203
   {EncBytes,EncLen} = case element(1,Val) of
5✔
1204
      simple ->
1205
         encode_restricted_string(element(2,Val), [<<128>>]);
5✔
1206
      sasl ->
1207
         'enc_SaslCredentials'(element(2,Val), [<<163>>]);
×
1208
      Else ->
1209
         exit({error,{asn1,{invalid_choice_type,Else}}})
×
1210
   end,
1211

1212
encode_tags(TagIn, EncBytes, EncLen).
5✔
1213

1214

1215

1216

1217
'dec_AuthenticationChoice'(Tlv) ->
1218
   'dec_AuthenticationChoice'(Tlv, []).
×
1219

1220
'dec_AuthenticationChoice'(Tlv, TagIn) ->
1221
Tlv1 = match_tags(Tlv, TagIn),
5✔
1222
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
5✔
1223

1224
%% 'simple'
1225
    {131072, V1} ->
1226
        {simple, decode_restricted_string(V1,[])};
5✔
1227

1228

1229
%% 'sasl'
1230
    {131075, V1} ->
1231
        {sasl, 'dec_SaslCredentials'(V1, [])};
×
1232

1233
      Else ->
1234
         exit({error,{asn1,{invalid_choice_tag,Else}}})
×
1235
   end
1236
.
1237

1238

1239
%%================================
1240
%%  SaslCredentials
1241
%%================================
1242
'enc_SaslCredentials'(Val) ->
1243
    'enc_SaslCredentials'(Val, [<<48>>]).
×
1244

1245
'enc_SaslCredentials'(Val, TagIn) ->
1246
{_,Cindex1, Cindex2} = Val,
×
1247

1248
%%-------------------------------------------------
1249
%% attribute mechanism(1) with type OCTET STRING
1250
%%-------------------------------------------------
1251
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
1252

1253
%%-------------------------------------------------
1254
%% attribute credentials(2) with type OCTET STRING OPTIONAL
1255
%%-------------------------------------------------
1256
   {EncBytes2,EncLen2} =  case Cindex2 of
×
1257
         asn1_NOVALUE -> {<<>>,0};
×
1258
         _ ->
1259
            encode_restricted_string(Cindex2, [<<4>>])
×
1260
       end,
1261

1262
   BytesSoFar = [EncBytes1, EncBytes2],
×
1263
LenSoFar = EncLen1 + EncLen2,
×
1264
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
1265

1266

1267
'dec_SaslCredentials'(Tlv) ->
1268
   'dec_SaslCredentials'(Tlv, [16]).
×
1269

1270
'dec_SaslCredentials'(Tlv, TagIn) ->
1271
   %%-------------------------------------------------
1272
   %% decode tag and length
1273
   %%-------------------------------------------------
1274
Tlv1 = match_tags(Tlv, TagIn),
×
1275

1276
%%-------------------------------------------------
1277
%% attribute mechanism(1) with type OCTET STRING
1278
%%-------------------------------------------------
1279
[V1|Tlv2] = Tlv1,
×
1280
Term1 = decode_restricted_string(V1,[4]),
×
1281

1282
%%-------------------------------------------------
1283
%% attribute credentials(2) with type OCTET STRING OPTIONAL
1284
%%-------------------------------------------------
1285
{Term2,Tlv3} = case Tlv2 of
×
1286
[{4,V2}|TempTlv3] ->
1287
    {decode_restricted_string(V2,[]), TempTlv3};
×
1288
    _ ->
1289
        { asn1_NOVALUE, Tlv2}
×
1290
end,
1291

1292
case Tlv3 of
×
1293
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
1294
end,
1295
   {'SaslCredentials', Term1, Term2}.
×
1296

1297

1298

1299
%%================================
1300
%%  BindResponse
1301
%%================================
1302
'enc_BindResponse'(Val) ->
1303
    'enc_BindResponse'(Val, [<<97>>]).
×
1304

1305
'enc_BindResponse'(Val, TagIn) ->
1306
{_,Cindex1, Cindex2, Cindex3, Cindex4, Cindex5} = Val,
5✔
1307

1308
%%-------------------------------------------------
1309
%% attribute resultCode(1) with type ENUMERATED
1310
%%-------------------------------------------------
1311
   {EncBytes1,EncLen1} = case Cindex1 of
5✔
1312
success -> encode_enumerated(0, [<<10>>]);
5✔
1313
operationsError -> encode_enumerated(1, [<<10>>]);
×
1314
protocolError -> encode_enumerated(2, [<<10>>]);
×
1315
timeLimitExceeded -> encode_enumerated(3, [<<10>>]);
×
1316
sizeLimitExceeded -> encode_enumerated(4, [<<10>>]);
×
1317
compareFalse -> encode_enumerated(5, [<<10>>]);
×
1318
compareTrue -> encode_enumerated(6, [<<10>>]);
×
1319
authMethodNotSupported -> encode_enumerated(7, [<<10>>]);
×
1320
strongAuthRequired -> encode_enumerated(8, [<<10>>]);
×
1321
referral -> encode_enumerated(10, [<<10>>]);
×
1322
adminLimitExceeded -> encode_enumerated(11, [<<10>>]);
×
1323
unavailableCriticalExtension -> encode_enumerated(12, [<<10>>]);
×
1324
confidentialityRequired -> encode_enumerated(13, [<<10>>]);
×
1325
saslBindInProgress -> encode_enumerated(14, [<<10>>]);
×
1326
noSuchAttribute -> encode_enumerated(16, [<<10>>]);
×
1327
undefinedAttributeType -> encode_enumerated(17, [<<10>>]);
×
1328
inappropriateMatching -> encode_enumerated(18, [<<10>>]);
×
1329
constraintViolation -> encode_enumerated(19, [<<10>>]);
×
1330
attributeOrValueExists -> encode_enumerated(20, [<<10>>]);
×
1331
invalidAttributeSyntax -> encode_enumerated(21, [<<10>>]);
×
1332
noSuchObject -> encode_enumerated(32, [<<10>>]);
×
1333
aliasProblem -> encode_enumerated(33, [<<10>>]);
×
1334
invalidDNSyntax -> encode_enumerated(34, [<<10>>]);
×
1335
aliasDereferencingProblem -> encode_enumerated(36, [<<10>>]);
×
1336
inappropriateAuthentication -> encode_enumerated(48, [<<10>>]);
×
1337
invalidCredentials -> encode_enumerated(49, [<<10>>]);
×
1338
insufficientAccessRights -> encode_enumerated(50, [<<10>>]);
×
1339
busy -> encode_enumerated(51, [<<10>>]);
×
1340
unavailable -> encode_enumerated(52, [<<10>>]);
×
1341
unwillingToPerform -> encode_enumerated(53, [<<10>>]);
×
1342
loopDetect -> encode_enumerated(54, [<<10>>]);
×
1343
namingViolation -> encode_enumerated(64, [<<10>>]);
×
1344
objectClassViolation -> encode_enumerated(65, [<<10>>]);
×
1345
notAllowedOnNonLeaf -> encode_enumerated(66, [<<10>>]);
×
1346
notAllowedOnRDN -> encode_enumerated(67, [<<10>>]);
×
1347
entryAlreadyExists -> encode_enumerated(68, [<<10>>]);
×
1348
objectClassModsProhibited -> encode_enumerated(69, [<<10>>]);
×
1349
affectsMultipleDSAs -> encode_enumerated(71, [<<10>>]);
×
1350
other -> encode_enumerated(80, [<<10>>]);
×
1351
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
×
1352
end,
1353

1354
%%-------------------------------------------------
1355
%% attribute matchedDN(2) with type OCTET STRING
1356
%%-------------------------------------------------
1357
   {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
5✔
1358

1359
%%-------------------------------------------------
1360
%% attribute errorMessage(3) with type OCTET STRING
1361
%%-------------------------------------------------
1362
   {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]),
5✔
1363

1364
%%-------------------------------------------------
1365
%% attribute referral(4)   External ELDAPv3:Referral OPTIONAL
1366
%%-------------------------------------------------
1367
   {EncBytes4,EncLen4} =  case Cindex4 of
5✔
1368
         asn1_NOVALUE -> {<<>>,0};
5✔
1369
         _ ->
1370
            'enc_Referral'(Cindex4, [<<163>>])
×
1371
       end,
1372

1373
%%-------------------------------------------------
1374
%% attribute serverSaslCreds(5) with type OCTET STRING OPTIONAL
1375
%%-------------------------------------------------
1376
   {EncBytes5,EncLen5} =  case Cindex5 of
5✔
1377
         asn1_NOVALUE -> {<<>>,0};
5✔
1378
         _ ->
1379
            encode_restricted_string(Cindex5, [<<135>>])
×
1380
       end,
1381

1382
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
5✔
1383
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
5✔
1384
encode_tags(TagIn, BytesSoFar, LenSoFar).
5✔
1385

1386

1387
'dec_BindResponse'(Tlv) ->
1388
   'dec_BindResponse'(Tlv, [65537]).
×
1389

1390
'dec_BindResponse'(Tlv, TagIn) ->
1391
   %%-------------------------------------------------
1392
   %% decode tag and length
1393
   %%-------------------------------------------------
1394
Tlv1 = match_tags(Tlv, TagIn),
5✔
1395

1396
%%-------------------------------------------------
1397
%% attribute resultCode(1) with type ENUMERATED
1398
%%-------------------------------------------------
1399
[V1|Tlv2] = Tlv1,
5✔
1400
Term1 = decode_enumerated(V1,[{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}],[10]),
5✔
1401

1402
%%-------------------------------------------------
1403
%% attribute matchedDN(2) with type OCTET STRING
1404
%%-------------------------------------------------
1405
[V2|Tlv3] = Tlv2,
5✔
1406
Term2 = decode_restricted_string(V2,[4]),
5✔
1407

1408
%%-------------------------------------------------
1409
%% attribute errorMessage(3) with type OCTET STRING
1410
%%-------------------------------------------------
1411
[V3|Tlv4] = Tlv3,
5✔
1412
Term3 = decode_restricted_string(V3,[4]),
5✔
1413

1414
%%-------------------------------------------------
1415
%% attribute referral(4)   External ELDAPv3:Referral OPTIONAL
1416
%%-------------------------------------------------
1417
{Term4,Tlv5} = case Tlv4 of
5✔
1418
[{131075,V4}|TempTlv5] ->
1419
    {'dec_Referral'(V4, []), TempTlv5};
×
1420
    _ ->
1421
        { asn1_NOVALUE, Tlv4}
5✔
1422
end,
1423

1424
%%-------------------------------------------------
1425
%% attribute serverSaslCreds(5) with type OCTET STRING OPTIONAL
1426
%%-------------------------------------------------
1427
{Term5,Tlv6} = case Tlv5 of
5✔
1428
[{131079,V5}|TempTlv6] ->
1429
    {decode_restricted_string(V5,[]), TempTlv6};
×
1430
    _ ->
1431
        { asn1_NOVALUE, Tlv5}
5✔
1432
end,
1433

1434
case Tlv6 of
5✔
1435
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed
5✔
1436
end,
1437
   {'BindResponse', Term1, Term2, Term3, Term4, Term5}.
5✔
1438

1439

1440

1441
%%================================
1442
%%  UnbindRequest
1443
%%================================
1444
'enc_UnbindRequest'(Val) ->
1445
    'enc_UnbindRequest'(Val, [<<66>>]).
×
1446

1447
'enc_UnbindRequest'(Val, TagIn) ->
1448
encode_null(Val, TagIn).
×
1449

1450

1451
'dec_UnbindRequest'(Tlv) ->
1452
   'dec_UnbindRequest'(Tlv, [65538]).
×
1453

1454
'dec_UnbindRequest'(Tlv, TagIn) ->
1455
decode_null(Tlv,TagIn).
×
1456

1457

1458

1459
%%================================
1460
%%  SearchRequest
1461
%%================================
1462
'enc_SearchRequest'(Val) ->
1463
    'enc_SearchRequest'(Val, [<<99>>]).
×
1464

1465
'enc_SearchRequest'(Val, TagIn) ->
1466
{_,Cindex1, Cindex2, Cindex3, Cindex4, Cindex5, Cindex6, Cindex7, Cindex8} = Val,
6✔
1467

1468
%%-------------------------------------------------
1469
%% attribute baseObject(1) with type OCTET STRING
1470
%%-------------------------------------------------
1471
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
6✔
1472

1473
%%-------------------------------------------------
1474
%% attribute scope(2) with type ENUMERATED
1475
%%-------------------------------------------------
1476
   {EncBytes2,EncLen2} = case Cindex2 of
6✔
1477
baseObject -> encode_enumerated(0, [<<10>>]);
×
1478
singleLevel -> encode_enumerated(1, [<<10>>]);
×
1479
wholeSubtree -> encode_enumerated(2, [<<10>>]);
6✔
1480
Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
×
1481
end,
1482

1483
%%-------------------------------------------------
1484
%% attribute derefAliases(3) with type ENUMERATED
1485
%%-------------------------------------------------
1486
   {EncBytes3,EncLen3} = case Cindex3 of
6✔
1487
neverDerefAliases -> encode_enumerated(0, [<<10>>]);
6✔
1488
derefInSearching -> encode_enumerated(1, [<<10>>]);
×
1489
derefFindingBaseObj -> encode_enumerated(2, [<<10>>]);
×
1490
derefAlways -> encode_enumerated(3, [<<10>>]);
×
1491
Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}})
×
1492
end,
1493

1494
%%-------------------------------------------------
1495
%% attribute sizeLimit(4) with type INTEGER
1496
%%-------------------------------------------------
1497
   {EncBytes4,EncLen4} = encode_integer(Cindex4, [<<2>>]),
6✔
1498

1499
%%-------------------------------------------------
1500
%% attribute timeLimit(5) with type INTEGER
1501
%%-------------------------------------------------
1502
   {EncBytes5,EncLen5} = encode_integer(Cindex5, [<<2>>]),
6✔
1503

1504
%%-------------------------------------------------
1505
%% attribute typesOnly(6) with type BOOLEAN
1506
%%-------------------------------------------------
1507
   {EncBytes6,EncLen6} = encode_boolean(Cindex6, [<<1>>]),
6✔
1508

1509
%%-------------------------------------------------
1510
%% attribute filter(7)   External ELDAPv3:Filter
1511
%%-------------------------------------------------
1512
   {EncBytes7,EncLen7} = 'enc_Filter'(Cindex7, []),
6✔
1513

1514
%%-------------------------------------------------
1515
%% attribute attributes(8)   External ELDAPv3:AttributeDescriptionList
1516
%%-------------------------------------------------
1517
   {EncBytes8,EncLen8} = 'enc_AttributeDescriptionList'(Cindex8, [<<48>>]),
6✔
1518

1519
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8],
6✔
1520
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8,
6✔
1521
encode_tags(TagIn, BytesSoFar, LenSoFar).
6✔
1522

1523

1524
'dec_SearchRequest'(Tlv) ->
1525
   'dec_SearchRequest'(Tlv, [65539]).
×
1526

1527
'dec_SearchRequest'(Tlv, TagIn) ->
1528
   %%-------------------------------------------------
1529
   %% decode tag and length
1530
   %%-------------------------------------------------
1531
Tlv1 = match_tags(Tlv, TagIn),
6✔
1532

1533
%%-------------------------------------------------
1534
%% attribute baseObject(1) with type OCTET STRING
1535
%%-------------------------------------------------
1536
[V1|Tlv2] = Tlv1,
6✔
1537
Term1 = decode_restricted_string(V1,[4]),
6✔
1538

1539
%%-------------------------------------------------
1540
%% attribute scope(2) with type ENUMERATED
1541
%%-------------------------------------------------
1542
[V2|Tlv3] = Tlv2,
6✔
1543
Term2 = decode_enumerated(V2,[{baseObject,0},{singleLevel,1},{wholeSubtree,2}],[10]),
6✔
1544

1545
%%-------------------------------------------------
1546
%% attribute derefAliases(3) with type ENUMERATED
1547
%%-------------------------------------------------
1548
[V3|Tlv4] = Tlv3,
6✔
1549
Term3 = decode_enumerated(V3,[{neverDerefAliases,0},{derefInSearching,1},{derefFindingBaseObj,2},{derefAlways,3}],[10]),
6✔
1550

1551
%%-------------------------------------------------
1552
%% attribute sizeLimit(4) with type INTEGER
1553
%%-------------------------------------------------
1554
[V4|Tlv5] = Tlv4,
6✔
1555
Term4 = decode_integer(V4,{0,2147483647},[2]),
6✔
1556

1557
%%-------------------------------------------------
1558
%% attribute timeLimit(5) with type INTEGER
1559
%%-------------------------------------------------
1560
[V5|Tlv6] = Tlv5,
6✔
1561
Term5 = decode_integer(V5,{0,2147483647},[2]),
6✔
1562

1563
%%-------------------------------------------------
1564
%% attribute typesOnly(6) with type BOOLEAN
1565
%%-------------------------------------------------
1566
[V6|Tlv7] = Tlv6,
6✔
1567
Term6 = decode_boolean(V6,[1]),
6✔
1568

1569
%%-------------------------------------------------
1570
%% attribute filter(7)   External ELDAPv3:Filter
1571
%%-------------------------------------------------
1572
[V7|Tlv8] = Tlv7,
6✔
1573
Term7 = 'dec_Filter'(V7, []),
6✔
1574

1575
%%-------------------------------------------------
1576
%% attribute attributes(8)   External ELDAPv3:AttributeDescriptionList
1577
%%-------------------------------------------------
1578
[V8|Tlv9] = Tlv8,
6✔
1579
Term8 = 'dec_AttributeDescriptionList'(V8, [16]),
6✔
1580

1581
case Tlv9 of
6✔
1582
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv9}}}) % extra fields not allowed
6✔
1583
end,
1584
   {'SearchRequest', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8}.
6✔
1585

1586

1587

1588
%%================================
1589
%%  Filter
1590
%%================================
1591
'enc_Filter'(Val) ->
1592
    'enc_Filter'(Val, []).
×
1593

1594
'enc_Filter'(Val, TagIn) ->
1595
   {EncBytes,EncLen} = case element(1,Val) of
8✔
1596
      'and' ->
1597
         'enc_Filter_and'(element(2,Val), [<<160>>]);
1✔
1598
      'or' ->
1599
         'enc_Filter_or'(element(2,Val), [<<161>>]);
×
1600
      'not' ->
1601
         'enc_Filter'(element(2,Val), [<<162>>]);
×
1602
      equalityMatch ->
1603
         'enc_AttributeValueAssertion'(element(2,Val), [<<163>>]);
7✔
1604
      substrings ->
1605
         'enc_SubstringFilter'(element(2,Val), [<<164>>]);
×
1606
      greaterOrEqual ->
1607
         'enc_AttributeValueAssertion'(element(2,Val), [<<165>>]);
×
1608
      lessOrEqual ->
1609
         'enc_AttributeValueAssertion'(element(2,Val), [<<166>>]);
×
1610
      present ->
UNCOV
1611
         encode_restricted_string(element(2,Val), [<<135>>]);
×
1612
      approxMatch ->
1613
         'enc_AttributeValueAssertion'(element(2,Val), [<<168>>]);
×
1614
      extensibleMatch ->
1615
         'enc_MatchingRuleAssertion'(element(2,Val), [<<169>>]);
×
1616
      Else ->
1617
         exit({error,{asn1,{invalid_choice_type,Else}}})
×
1618
   end,
1619

1620
encode_tags(TagIn, EncBytes, EncLen).
8✔
1621

1622

1623

1624

1625

1626
%%================================
1627
%%  Filter_and
1628
%%================================
1629
'enc_Filter_and'(Val, TagIn) ->
1630
      {EncBytes,EncLen} = 'enc_Filter_and_components'(Val,[],0),
1✔
1631
   encode_tags(TagIn, EncBytes, EncLen).
1✔
1632

1633
'enc_Filter_and_components'([], AccBytes, AccLen) ->
1634
   {lists:reverse(AccBytes),AccLen};
1✔
1635

1636
'enc_Filter_and_components'([H|T],AccBytes, AccLen) ->
1637
   {EncBytes,EncLen} = 'enc_Filter'(H, []),
2✔
1638
   'enc_Filter_and_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
2✔
1639

1640
'dec_Filter_and'(Tlv, TagIn) ->
1641
   %%-------------------------------------------------
1642
   %% decode tag and length
1643
   %%-------------------------------------------------
1644
Tlv1 = match_tags(Tlv, TagIn),
1✔
1645
['dec_Filter'(V1, []) || V1 <- Tlv1].
1✔
1646

1647

1648

1649

1650

1651
%%================================
1652
%%  Filter_or
1653
%%================================
1654
'enc_Filter_or'(Val, TagIn) ->
1655
      {EncBytes,EncLen} = 'enc_Filter_or_components'(Val,[],0),
×
1656
   encode_tags(TagIn, EncBytes, EncLen).
×
1657

1658
'enc_Filter_or_components'([], AccBytes, AccLen) ->
1659
   {lists:reverse(AccBytes),AccLen};
×
1660

1661
'enc_Filter_or_components'([H|T],AccBytes, AccLen) ->
1662
   {EncBytes,EncLen} = 'enc_Filter'(H, []),
×
1663
   'enc_Filter_or_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
1664

1665
'dec_Filter_or'(Tlv, TagIn) ->
1666
   %%-------------------------------------------------
1667
   %% decode tag and length
1668
   %%-------------------------------------------------
1669
Tlv1 = match_tags(Tlv, TagIn),
×
1670
['dec_Filter'(V1, []) || V1 <- Tlv1].
×
1671

1672

1673

1674

1675
'dec_Filter'(Tlv) ->
1676
   'dec_Filter'(Tlv, []).
×
1677

1678
'dec_Filter'(Tlv, TagIn) ->
1679
Tlv1 = match_tags(Tlv, TagIn),
8✔
1680
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
8✔
1681

1682
%% 'and'
1683
    {131072, V1} ->
1684
        {'and', 'dec_Filter_and'(V1, [])};
1✔
1685

1686

1687
%% 'or'
1688
    {131073, V1} ->
1689
        {'or', 'dec_Filter_or'(V1, [])};
×
1690

1691

1692
%% 'not'
1693
    {131074, V1} ->
1694
        {'not', 'dec_Filter'(V1, [])};
×
1695

1696

1697
%% 'equalityMatch'
1698
    {131075, V1} ->
1699
        {equalityMatch, 'dec_AttributeValueAssertion'(V1, [])};
7✔
1700

1701

1702
%% 'substrings'
1703
    {131076, V1} ->
1704
        {substrings, 'dec_SubstringFilter'(V1, [])};
×
1705

1706

1707
%% 'greaterOrEqual'
1708
    {131077, V1} ->
1709
        {greaterOrEqual, 'dec_AttributeValueAssertion'(V1, [])};
×
1710

1711

1712
%% 'lessOrEqual'
1713
    {131078, V1} ->
1714
        {lessOrEqual, 'dec_AttributeValueAssertion'(V1, [])};
×
1715

1716

1717
%% 'present'
1718
    {131079, V1} ->
UNCOV
1719
        {present, decode_restricted_string(V1,[])};
×
1720

1721

1722
%% 'approxMatch'
1723
    {131080, V1} ->
1724
        {approxMatch, 'dec_AttributeValueAssertion'(V1, [])};
×
1725

1726

1727
%% 'extensibleMatch'
1728
    {131081, V1} ->
1729
        {extensibleMatch, 'dec_MatchingRuleAssertion'(V1, [])};
×
1730

1731
      Else ->
1732
         exit({error,{asn1,{invalid_choice_tag,Else}}})
×
1733
   end
1734
.
1735

1736

1737
%%================================
1738
%%  SubstringFilter
1739
%%================================
1740
'enc_SubstringFilter'(Val) ->
1741
    'enc_SubstringFilter'(Val, [<<48>>]).
×
1742

1743
'enc_SubstringFilter'(Val, TagIn) ->
1744
{_,Cindex1, Cindex2} = Val,
×
1745

1746
%%-------------------------------------------------
1747
%% attribute type(1) with type OCTET STRING
1748
%%-------------------------------------------------
1749
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
1750

1751
%%-------------------------------------------------
1752
%% attribute substrings(2) with type SEQUENCE OF
1753
%%-------------------------------------------------
1754
   {EncBytes2,EncLen2} = 'enc_SubstringFilter_substrings'(Cindex2, [<<48>>]),
×
1755

1756
   BytesSoFar = [EncBytes1, EncBytes2],
×
1757
LenSoFar = EncLen1 + EncLen2,
×
1758
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
1759

1760

1761

1762
%%================================
1763
%%  SubstringFilter_substrings
1764
%%================================
1765
'enc_SubstringFilter_substrings'(Val, TagIn) ->
1766
      {EncBytes,EncLen} = 'enc_SubstringFilter_substrings_components'(Val,[],0),
×
1767
   encode_tags(TagIn, EncBytes, EncLen).
×
1768

1769
'enc_SubstringFilter_substrings_components'([], AccBytes, AccLen) ->
1770
   {lists:reverse(AccBytes),AccLen};
×
1771

1772
'enc_SubstringFilter_substrings_components'([H|T],AccBytes, AccLen) ->
1773
   {EncBytes,EncLen} = 'enc_SubstringFilter_substrings_SEQOF'(H, []),
×
1774
   'enc_SubstringFilter_substrings_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
1775

1776

1777

1778

1779
%%================================
1780
%%  SubstringFilter_substrings_SEQOF
1781
%%================================
1782
'enc_SubstringFilter_substrings_SEQOF'(Val, TagIn) ->
1783
      {EncBytes,EncLen} = case element(1,Val) of
×
1784
      initial ->
1785
         encode_restricted_string(element(2,Val), [<<128>>]);
×
1786
      any ->
1787
         encode_restricted_string(element(2,Val), [<<129>>]);
×
1788
      final ->
1789
         encode_restricted_string(element(2,Val), [<<130>>]);
×
1790
      Else ->
1791
         exit({error,{asn1,{invalid_choice_type,Else}}})
×
1792
   end,
1793

1794
encode_tags(TagIn, EncBytes, EncLen).
×
1795

1796

1797
'dec_SubstringFilter_substrings_SEQOF'(Tlv, TagIn) ->
1798
Tlv1 = match_tags(Tlv, TagIn),
×
1799
case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of
×
1800

1801
%% 'initial'
1802
    {131072, V1} ->
1803
        {initial, decode_restricted_string(V1,[])};
×
1804

1805

1806
%% 'any'
1807
    {131073, V1} ->
1808
        {any, decode_restricted_string(V1,[])};
×
1809

1810

1811
%% 'final'
1812
    {131074, V1} ->
1813
        {final, decode_restricted_string(V1,[])};
×
1814

1815
      Else ->
1816
         exit({error,{asn1,{invalid_choice_tag,Else}}})
×
1817
   end
1818
.
1819
'dec_SubstringFilter_substrings'(Tlv, TagIn) ->
1820
   %%-------------------------------------------------
1821
   %% decode tag and length
1822
   %%-------------------------------------------------
1823
Tlv1 = match_tags(Tlv, TagIn),
×
1824
['dec_SubstringFilter_substrings_SEQOF'(V1, []) || V1 <- Tlv1].
×
1825

1826

1827

1828

1829
'dec_SubstringFilter'(Tlv) ->
1830
   'dec_SubstringFilter'(Tlv, [16]).
×
1831

1832
'dec_SubstringFilter'(Tlv, TagIn) ->
1833
   %%-------------------------------------------------
1834
   %% decode tag and length
1835
   %%-------------------------------------------------
1836
Tlv1 = match_tags(Tlv, TagIn),
×
1837

1838
%%-------------------------------------------------
1839
%% attribute type(1) with type OCTET STRING
1840
%%-------------------------------------------------
1841
[V1|Tlv2] = Tlv1,
×
1842
Term1 = decode_restricted_string(V1,[4]),
×
1843

1844
%%-------------------------------------------------
1845
%% attribute substrings(2) with type SEQUENCE OF
1846
%%-------------------------------------------------
1847
[V2|Tlv3] = Tlv2,
×
1848
Term2 = 'dec_SubstringFilter_substrings'(V2, [16]),
×
1849

1850
case Tlv3 of
×
1851
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
1852
end,
1853
   {'SubstringFilter', Term1, Term2}.
×
1854

1855

1856

1857
%%================================
1858
%%  MatchingRuleAssertion
1859
%%================================
1860
'enc_MatchingRuleAssertion'(Val) ->
1861
    'enc_MatchingRuleAssertion'(Val, [<<48>>]).
×
1862

1863
'enc_MatchingRuleAssertion'(Val, TagIn) ->
1864
{_,Cindex1, Cindex2, Cindex3, Cindex4} = Val,
×
1865

1866
%%-------------------------------------------------
1867
%% attribute matchingRule(1) with type OCTET STRING OPTIONAL
1868
%%-------------------------------------------------
1869
   {EncBytes1,EncLen1} =  case Cindex1 of
×
1870
         asn1_NOVALUE -> {<<>>,0};
×
1871
         _ ->
1872
            encode_restricted_string(Cindex1, [<<129>>])
×
1873
       end,
1874

1875
%%-------------------------------------------------
1876
%% attribute type(2) with type OCTET STRING OPTIONAL
1877
%%-------------------------------------------------
1878
   {EncBytes2,EncLen2} =  case Cindex2 of
×
1879
         asn1_NOVALUE -> {<<>>,0};
×
1880
         _ ->
1881
            encode_restricted_string(Cindex2, [<<130>>])
×
1882
       end,
1883

1884
%%-------------------------------------------------
1885
%% attribute matchValue(3) with type OCTET STRING
1886
%%-------------------------------------------------
1887
   {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<131>>]),
×
1888

1889
%%-------------------------------------------------
1890
%% attribute dnAttributes(4) with type BOOLEAN DEFAULT = false
1891
%%-------------------------------------------------
1892
   {EncBytes4,EncLen4} =  case Cindex4 of
×
1893
         asn1_DEFAULT -> {<<>>,0};
×
1894
         false -> {<<>>,0};
×
1895
         _ ->
1896
            encode_boolean(Cindex4, [<<132>>])
×
1897
       end,
1898

1899
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
×
1900
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
×
1901
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
1902

1903

1904
'dec_MatchingRuleAssertion'(Tlv) ->
1905
   'dec_MatchingRuleAssertion'(Tlv, [16]).
×
1906

1907
'dec_MatchingRuleAssertion'(Tlv, TagIn) ->
1908
   %%-------------------------------------------------
1909
   %% decode tag and length
1910
   %%-------------------------------------------------
1911
Tlv1 = match_tags(Tlv, TagIn),
×
1912

1913
%%-------------------------------------------------
1914
%% attribute matchingRule(1) with type OCTET STRING OPTIONAL
1915
%%-------------------------------------------------
1916
{Term1,Tlv2} = case Tlv1 of
×
1917
[{131073,V1}|TempTlv2] ->
1918
    {decode_restricted_string(V1,[]), TempTlv2};
×
1919
    _ ->
1920
        { asn1_NOVALUE, Tlv1}
×
1921
end,
1922

1923
%%-------------------------------------------------
1924
%% attribute type(2) with type OCTET STRING OPTIONAL
1925
%%-------------------------------------------------
1926
{Term2,Tlv3} = case Tlv2 of
×
1927
[{131074,V2}|TempTlv3] ->
1928
    {decode_restricted_string(V2,[]), TempTlv3};
×
1929
    _ ->
1930
        { asn1_NOVALUE, Tlv2}
×
1931
end,
1932

1933
%%-------------------------------------------------
1934
%% attribute matchValue(3) with type OCTET STRING
1935
%%-------------------------------------------------
1936
[V3|Tlv4] = Tlv3,
×
1937
Term3 = decode_restricted_string(V3,[131075]),
×
1938

1939
%%-------------------------------------------------
1940
%% attribute dnAttributes(4) with type BOOLEAN DEFAULT = false
1941
%%-------------------------------------------------
1942
{Term4,Tlv5} = case Tlv4 of
×
1943
[{131076,V4}|TempTlv5] ->
1944
    {decode_boolean(V4,[]), TempTlv5};
×
1945
    _ ->
1946
        {false,Tlv4}
×
1947
end,
1948

1949
case Tlv5 of
×
1950
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed
×
1951
end,
1952
   {'MatchingRuleAssertion', Term1, Term2, Term3, Term4}.
×
1953

1954

1955

1956
%%================================
1957
%%  SearchResultEntry
1958
%%================================
1959
'enc_SearchResultEntry'(Val) ->
1960
    'enc_SearchResultEntry'(Val, [<<100>>]).
×
1961

1962
'enc_SearchResultEntry'(Val, TagIn) ->
1963
{_,Cindex1, Cindex2} = Val,
5✔
1964

1965
%%-------------------------------------------------
1966
%% attribute objectName(1) with type OCTET STRING
1967
%%-------------------------------------------------
1968
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
5✔
1969

1970
%%-------------------------------------------------
1971
%% attribute attributes(2)   External ELDAPv3:PartialAttributeList
1972
%%-------------------------------------------------
1973
   {EncBytes2,EncLen2} = 'enc_PartialAttributeList'(Cindex2, [<<48>>]),
5✔
1974

1975
   BytesSoFar = [EncBytes1, EncBytes2],
5✔
1976
LenSoFar = EncLen1 + EncLen2,
5✔
1977
encode_tags(TagIn, BytesSoFar, LenSoFar).
5✔
1978

1979

1980
'dec_SearchResultEntry'(Tlv) ->
1981
   'dec_SearchResultEntry'(Tlv, [65540]).
×
1982

1983
'dec_SearchResultEntry'(Tlv, TagIn) ->
1984
   %%-------------------------------------------------
1985
   %% decode tag and length
1986
   %%-------------------------------------------------
1987
Tlv1 = match_tags(Tlv, TagIn),
5✔
1988

1989
%%-------------------------------------------------
1990
%% attribute objectName(1) with type OCTET STRING
1991
%%-------------------------------------------------
1992
[V1|Tlv2] = Tlv1,
5✔
1993
Term1 = decode_restricted_string(V1,[4]),
5✔
1994

1995
%%-------------------------------------------------
1996
%% attribute attributes(2)   External ELDAPv3:PartialAttributeList
1997
%%-------------------------------------------------
1998
[V2|Tlv3] = Tlv2,
5✔
1999
Term2 = 'dec_PartialAttributeList'(V2, [16]),
5✔
2000

2001
case Tlv3 of
5✔
2002
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
5✔
2003
end,
2004
   {'SearchResultEntry', Term1, Term2}.
5✔
2005

2006

2007

2008
%%================================
2009
%%  PartialAttributeList
2010
%%================================
2011
'enc_PartialAttributeList'(Val) ->
2012
    'enc_PartialAttributeList'(Val, [<<48>>]).
×
2013

2014
'enc_PartialAttributeList'(Val, TagIn) ->
2015
   {EncBytes,EncLen} = 'enc_PartialAttributeList_components'(Val,[],0),
5✔
2016
   encode_tags(TagIn, EncBytes, EncLen).
5✔
2017

2018
'enc_PartialAttributeList_components'([], AccBytes, AccLen) ->
2019
   {lists:reverse(AccBytes),AccLen};
5✔
2020

2021
'enc_PartialAttributeList_components'([H|T],AccBytes, AccLen) ->
2022
   {EncBytes,EncLen} = 'enc_PartialAttributeList_SEQOF'(H, [<<48>>]),
8✔
2023
   'enc_PartialAttributeList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
8✔
2024

2025

2026

2027

2028
%%================================
2029
%%  PartialAttributeList_SEQOF
2030
%%================================
2031
'enc_PartialAttributeList_SEQOF'(Val, TagIn) ->
2032
   {_,Cindex1, Cindex2} = Val,
8✔
2033

2034
%%-------------------------------------------------
2035
%% attribute type(1) with type OCTET STRING
2036
%%-------------------------------------------------
2037
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
8✔
2038

2039
%%-------------------------------------------------
2040
%% attribute vals(2) with type SET OF
2041
%%-------------------------------------------------
2042
   {EncBytes2,EncLen2} = 'enc_PartialAttributeList_SEQOF_vals'(Cindex2, [<<49>>]),
8✔
2043

2044
   BytesSoFar = [EncBytes1, EncBytes2],
8✔
2045
LenSoFar = EncLen1 + EncLen2,
8✔
2046
encode_tags(TagIn, BytesSoFar, LenSoFar).
8✔
2047

2048

2049

2050
%%================================
2051
%%  PartialAttributeList_SEQOF_vals
2052
%%================================
2053
'enc_PartialAttributeList_SEQOF_vals'(Val, TagIn) ->
2054
      {EncBytes,EncLen} = 'enc_PartialAttributeList_SEQOF_vals_components'(Val,[],0),
8✔
2055
   encode_tags(TagIn, EncBytes, EncLen).
8✔
2056

2057
'enc_PartialAttributeList_SEQOF_vals_components'([], AccBytes, AccLen) ->
2058
   {lists:reverse(AccBytes),AccLen};
8✔
2059

2060
'enc_PartialAttributeList_SEQOF_vals_components'([H|T],AccBytes, AccLen) ->
2061
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
9✔
2062
   'enc_PartialAttributeList_SEQOF_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
9✔
2063

2064
'dec_PartialAttributeList_SEQOF_vals'(Tlv, TagIn) ->
2065
   %%-------------------------------------------------
2066
   %% decode tag and length
2067
   %%-------------------------------------------------
2068
Tlv1 = match_tags(Tlv, TagIn),
8✔
2069
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
8✔
2070

2071

2072
'dec_PartialAttributeList_SEQOF'(Tlv, TagIn) ->
2073
   %%-------------------------------------------------
2074
   %% decode tag and length
2075
   %%-------------------------------------------------
2076
Tlv1 = match_tags(Tlv, TagIn),
8✔
2077

2078
%%-------------------------------------------------
2079
%% attribute type(1) with type OCTET STRING
2080
%%-------------------------------------------------
2081
[V1|Tlv2] = Tlv1,
8✔
2082
Term1 = decode_restricted_string(V1,[4]),
8✔
2083

2084
%%-------------------------------------------------
2085
%% attribute vals(2) with type SET OF
2086
%%-------------------------------------------------
2087
[V2|Tlv3] = Tlv2,
8✔
2088
Term2 = 'dec_PartialAttributeList_SEQOF_vals'(V2, [17]),
8✔
2089

2090
case Tlv3 of
8✔
2091
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
8✔
2092
end,
2093
   {'PartialAttributeList_SEQOF', Term1, Term2}.
8✔
2094

2095

2096

2097
'dec_PartialAttributeList'(Tlv) ->
2098
   'dec_PartialAttributeList'(Tlv, [16]).
×
2099

2100
'dec_PartialAttributeList'(Tlv, TagIn) ->
2101
   %%-------------------------------------------------
2102
   %% decode tag and length
2103
   %%-------------------------------------------------
2104
Tlv1 = match_tags(Tlv, TagIn),
5✔
2105
['dec_PartialAttributeList_SEQOF'(V1, [16]) || V1 <- Tlv1].
5✔
2106

2107

2108

2109

2110
%%================================
2111
%%  SearchResultReference
2112
%%================================
2113
'enc_SearchResultReference'(Val) ->
2114
    'enc_SearchResultReference'(Val, [<<115>>]).
×
2115

2116
'enc_SearchResultReference'(Val, TagIn) ->
2117
   {EncBytes,EncLen} = 'enc_SearchResultReference_components'(Val,[],0),
×
2118
   encode_tags(TagIn, EncBytes, EncLen).
×
2119

2120
'enc_SearchResultReference_components'([], AccBytes, AccLen) ->
2121
   {lists:reverse(AccBytes),AccLen};
×
2122

2123
'enc_SearchResultReference_components'([H|T],AccBytes, AccLen) ->
2124
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
×
2125
   'enc_SearchResultReference_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
2126

2127

2128

2129
'dec_SearchResultReference'(Tlv) ->
2130
   'dec_SearchResultReference'(Tlv, [65555]).
×
2131

2132
'dec_SearchResultReference'(Tlv, TagIn) ->
2133
   %%-------------------------------------------------
2134
   %% decode tag and length
2135
   %%-------------------------------------------------
2136
Tlv1 = match_tags(Tlv, TagIn),
×
2137
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
×
2138

2139

2140

2141

2142
%%================================
2143
%%  SearchResultDone
2144
%%================================
2145
'enc_SearchResultDone'(Val) ->
2146
    'enc_SearchResultDone'(Val, [<<101>>]).
×
2147

2148
'enc_SearchResultDone'(Val, TagIn) ->
2149
   'enc_LDAPResult'(Val, TagIn).
6✔
2150

2151

2152
'dec_SearchResultDone'(Tlv) ->
2153
   'dec_SearchResultDone'(Tlv, [65541]).
×
2154

2155
'dec_SearchResultDone'(Tlv, TagIn) ->
2156
'dec_LDAPResult'(Tlv, TagIn).
6✔
2157

2158

2159

2160
%%================================
2161
%%  ModifyRequest
2162
%%================================
2163
'enc_ModifyRequest'(Val) ->
2164
    'enc_ModifyRequest'(Val, [<<102>>]).
×
2165

2166
'enc_ModifyRequest'(Val, TagIn) ->
2167
{_,Cindex1, Cindex2} = Val,
×
2168

2169
%%-------------------------------------------------
2170
%% attribute object(1) with type OCTET STRING
2171
%%-------------------------------------------------
2172
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
2173

2174
%%-------------------------------------------------
2175
%% attribute modification(2) with type SEQUENCE OF
2176
%%-------------------------------------------------
2177
   {EncBytes2,EncLen2} = 'enc_ModifyRequest_modification'(Cindex2, [<<48>>]),
×
2178

2179
   BytesSoFar = [EncBytes1, EncBytes2],
×
2180
LenSoFar = EncLen1 + EncLen2,
×
2181
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2182

2183

2184

2185
%%================================
2186
%%  ModifyRequest_modification
2187
%%================================
2188
'enc_ModifyRequest_modification'(Val, TagIn) ->
2189
      {EncBytes,EncLen} = 'enc_ModifyRequest_modification_components'(Val,[],0),
×
2190
   encode_tags(TagIn, EncBytes, EncLen).
×
2191

2192
'enc_ModifyRequest_modification_components'([], AccBytes, AccLen) ->
2193
   {lists:reverse(AccBytes),AccLen};
×
2194

2195
'enc_ModifyRequest_modification_components'([H|T],AccBytes, AccLen) ->
2196
   {EncBytes,EncLen} = 'enc_ModifyRequest_modification_SEQOF'(H, [<<48>>]),
×
2197
   'enc_ModifyRequest_modification_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
2198

2199

2200

2201

2202
%%================================
2203
%%  ModifyRequest_modification_SEQOF
2204
%%================================
2205
'enc_ModifyRequest_modification_SEQOF'(Val, TagIn) ->
2206
   {_,Cindex1, Cindex2} = Val,
×
2207

2208
%%-------------------------------------------------
2209
%% attribute operation(1) with type ENUMERATED
2210
%%-------------------------------------------------
2211
   {EncBytes1,EncLen1} = case Cindex1 of
×
2212
add -> encode_enumerated(0, [<<10>>]);
×
2213
delete -> encode_enumerated(1, [<<10>>]);
×
2214
replace -> encode_enumerated(2, [<<10>>]);
×
2215
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
×
2216
end,
2217

2218
%%-------------------------------------------------
2219
%% attribute modification(2)   External ELDAPv3:AttributeTypeAndValues
2220
%%-------------------------------------------------
2221
   {EncBytes2,EncLen2} = 'enc_AttributeTypeAndValues'(Cindex2, [<<48>>]),
×
2222

2223
   BytesSoFar = [EncBytes1, EncBytes2],
×
2224
LenSoFar = EncLen1 + EncLen2,
×
2225
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2226
'dec_ModifyRequest_modification_SEQOF'(Tlv, TagIn) ->
2227
   %%-------------------------------------------------
2228
   %% decode tag and length
2229
   %%-------------------------------------------------
2230
Tlv1 = match_tags(Tlv, TagIn),
×
2231

2232
%%-------------------------------------------------
2233
%% attribute operation(1) with type ENUMERATED
2234
%%-------------------------------------------------
2235
[V1|Tlv2] = Tlv1,
×
2236
Term1 = decode_enumerated(V1,[{add,0},{delete,1},{replace,2}],[10]),
×
2237

2238
%%-------------------------------------------------
2239
%% attribute modification(2)   External ELDAPv3:AttributeTypeAndValues
2240
%%-------------------------------------------------
2241
[V2|Tlv3] = Tlv2,
×
2242
Term2 = 'dec_AttributeTypeAndValues'(V2, [16]),
×
2243

2244
case Tlv3 of
×
2245
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2246
end,
2247
   {'ModifyRequest_modification_SEQOF', Term1, Term2}.
×
2248

2249
'dec_ModifyRequest_modification'(Tlv, TagIn) ->
2250
   %%-------------------------------------------------
2251
   %% decode tag and length
2252
   %%-------------------------------------------------
2253
Tlv1 = match_tags(Tlv, TagIn),
×
2254
['dec_ModifyRequest_modification_SEQOF'(V1, [16]) || V1 <- Tlv1].
×
2255

2256

2257

2258

2259
'dec_ModifyRequest'(Tlv) ->
2260
   'dec_ModifyRequest'(Tlv, [65542]).
×
2261

2262
'dec_ModifyRequest'(Tlv, TagIn) ->
2263
   %%-------------------------------------------------
2264
   %% decode tag and length
2265
   %%-------------------------------------------------
2266
Tlv1 = match_tags(Tlv, TagIn),
×
2267

2268
%%-------------------------------------------------
2269
%% attribute object(1) with type OCTET STRING
2270
%%-------------------------------------------------
2271
[V1|Tlv2] = Tlv1,
×
2272
Term1 = decode_restricted_string(V1,[4]),
×
2273

2274
%%-------------------------------------------------
2275
%% attribute modification(2) with type SEQUENCE OF
2276
%%-------------------------------------------------
2277
[V2|Tlv3] = Tlv2,
×
2278
Term2 = 'dec_ModifyRequest_modification'(V2, [16]),
×
2279

2280
case Tlv3 of
×
2281
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2282
end,
2283
   {'ModifyRequest', Term1, Term2}.
×
2284

2285

2286

2287
%%================================
2288
%%  AttributeTypeAndValues
2289
%%================================
2290
'enc_AttributeTypeAndValues'(Val) ->
2291
    'enc_AttributeTypeAndValues'(Val, [<<48>>]).
×
2292

2293
'enc_AttributeTypeAndValues'(Val, TagIn) ->
2294
{_,Cindex1, Cindex2} = Val,
×
2295

2296
%%-------------------------------------------------
2297
%% attribute type(1) with type OCTET STRING
2298
%%-------------------------------------------------
2299
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
2300

2301
%%-------------------------------------------------
2302
%% attribute vals(2) with type SET OF
2303
%%-------------------------------------------------
2304
   {EncBytes2,EncLen2} = 'enc_AttributeTypeAndValues_vals'(Cindex2, [<<49>>]),
×
2305

2306
   BytesSoFar = [EncBytes1, EncBytes2],
×
2307
LenSoFar = EncLen1 + EncLen2,
×
2308
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2309

2310

2311

2312
%%================================
2313
%%  AttributeTypeAndValues_vals
2314
%%================================
2315
'enc_AttributeTypeAndValues_vals'(Val, TagIn) ->
2316
      {EncBytes,EncLen} = 'enc_AttributeTypeAndValues_vals_components'(Val,[],0),
×
2317
   encode_tags(TagIn, EncBytes, EncLen).
×
2318

2319
'enc_AttributeTypeAndValues_vals_components'([], AccBytes, AccLen) ->
2320
   {lists:reverse(AccBytes),AccLen};
×
2321

2322
'enc_AttributeTypeAndValues_vals_components'([H|T],AccBytes, AccLen) ->
2323
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
×
2324
   'enc_AttributeTypeAndValues_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
2325

2326
'dec_AttributeTypeAndValues_vals'(Tlv, TagIn) ->
2327
   %%-------------------------------------------------
2328
   %% decode tag and length
2329
   %%-------------------------------------------------
2330
Tlv1 = match_tags(Tlv, TagIn),
×
2331
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
×
2332

2333

2334

2335

2336
'dec_AttributeTypeAndValues'(Tlv) ->
2337
   'dec_AttributeTypeAndValues'(Tlv, [16]).
×
2338

2339
'dec_AttributeTypeAndValues'(Tlv, TagIn) ->
2340
   %%-------------------------------------------------
2341
   %% decode tag and length
2342
   %%-------------------------------------------------
2343
Tlv1 = match_tags(Tlv, TagIn),
×
2344

2345
%%-------------------------------------------------
2346
%% attribute type(1) with type OCTET STRING
2347
%%-------------------------------------------------
2348
[V1|Tlv2] = Tlv1,
×
2349
Term1 = decode_restricted_string(V1,[4]),
×
2350

2351
%%-------------------------------------------------
2352
%% attribute vals(2) with type SET OF
2353
%%-------------------------------------------------
2354
[V2|Tlv3] = Tlv2,
×
2355
Term2 = 'dec_AttributeTypeAndValues_vals'(V2, [17]),
×
2356

2357
case Tlv3 of
×
2358
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2359
end,
2360
   {'AttributeTypeAndValues', Term1, Term2}.
×
2361

2362

2363

2364
%%================================
2365
%%  ModifyResponse
2366
%%================================
2367
'enc_ModifyResponse'(Val) ->
2368
    'enc_ModifyResponse'(Val, [<<103>>]).
×
2369

2370
'enc_ModifyResponse'(Val, TagIn) ->
2371
   'enc_LDAPResult'(Val, TagIn).
×
2372

2373

2374
'dec_ModifyResponse'(Tlv) ->
2375
   'dec_ModifyResponse'(Tlv, [65543]).
×
2376

2377
'dec_ModifyResponse'(Tlv, TagIn) ->
2378
'dec_LDAPResult'(Tlv, TagIn).
×
2379

2380

2381

2382
%%================================
2383
%%  AddRequest
2384
%%================================
2385
'enc_AddRequest'(Val) ->
2386
    'enc_AddRequest'(Val, [<<104>>]).
×
2387

2388
'enc_AddRequest'(Val, TagIn) ->
2389
{_,Cindex1, Cindex2} = Val,
×
2390

2391
%%-------------------------------------------------
2392
%% attribute entry(1) with type OCTET STRING
2393
%%-------------------------------------------------
2394
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
2395

2396
%%-------------------------------------------------
2397
%% attribute attributes(2)   External ELDAPv3:AttributeList
2398
%%-------------------------------------------------
2399
   {EncBytes2,EncLen2} = 'enc_AttributeList'(Cindex2, [<<48>>]),
×
2400

2401
   BytesSoFar = [EncBytes1, EncBytes2],
×
2402
LenSoFar = EncLen1 + EncLen2,
×
2403
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2404

2405

2406
'dec_AddRequest'(Tlv) ->
2407
   'dec_AddRequest'(Tlv, [65544]).
×
2408

2409
'dec_AddRequest'(Tlv, TagIn) ->
2410
   %%-------------------------------------------------
2411
   %% decode tag and length
2412
   %%-------------------------------------------------
2413
Tlv1 = match_tags(Tlv, TagIn),
×
2414

2415
%%-------------------------------------------------
2416
%% attribute entry(1) with type OCTET STRING
2417
%%-------------------------------------------------
2418
[V1|Tlv2] = Tlv1,
×
2419
Term1 = decode_restricted_string(V1,[4]),
×
2420

2421
%%-------------------------------------------------
2422
%% attribute attributes(2)   External ELDAPv3:AttributeList
2423
%%-------------------------------------------------
2424
[V2|Tlv3] = Tlv2,
×
2425
Term2 = 'dec_AttributeList'(V2, [16]),
×
2426

2427
case Tlv3 of
×
2428
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2429
end,
2430
   {'AddRequest', Term1, Term2}.
×
2431

2432

2433

2434
%%================================
2435
%%  AttributeList
2436
%%================================
2437
'enc_AttributeList'(Val) ->
2438
    'enc_AttributeList'(Val, [<<48>>]).
×
2439

2440
'enc_AttributeList'(Val, TagIn) ->
2441
   {EncBytes,EncLen} = 'enc_AttributeList_components'(Val,[],0),
×
2442
   encode_tags(TagIn, EncBytes, EncLen).
×
2443

2444
'enc_AttributeList_components'([], AccBytes, AccLen) ->
2445
   {lists:reverse(AccBytes),AccLen};
×
2446

2447
'enc_AttributeList_components'([H|T],AccBytes, AccLen) ->
2448
   {EncBytes,EncLen} = 'enc_AttributeList_SEQOF'(H, [<<48>>]),
×
2449
   'enc_AttributeList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
2450

2451

2452

2453

2454
%%================================
2455
%%  AttributeList_SEQOF
2456
%%================================
2457
'enc_AttributeList_SEQOF'(Val, TagIn) ->
2458
   {_,Cindex1, Cindex2} = Val,
×
2459

2460
%%-------------------------------------------------
2461
%% attribute type(1) with type OCTET STRING
2462
%%-------------------------------------------------
2463
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
2464

2465
%%-------------------------------------------------
2466
%% attribute vals(2) with type SET OF
2467
%%-------------------------------------------------
2468
   {EncBytes2,EncLen2} = 'enc_AttributeList_SEQOF_vals'(Cindex2, [<<49>>]),
×
2469

2470
   BytesSoFar = [EncBytes1, EncBytes2],
×
2471
LenSoFar = EncLen1 + EncLen2,
×
2472
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2473

2474

2475

2476
%%================================
2477
%%  AttributeList_SEQOF_vals
2478
%%================================
2479
'enc_AttributeList_SEQOF_vals'(Val, TagIn) ->
2480
      {EncBytes,EncLen} = 'enc_AttributeList_SEQOF_vals_components'(Val,[],0),
×
2481
   encode_tags(TagIn, EncBytes, EncLen).
×
2482

2483
'enc_AttributeList_SEQOF_vals_components'([], AccBytes, AccLen) ->
2484
   {lists:reverse(AccBytes),AccLen};
×
2485

2486
'enc_AttributeList_SEQOF_vals_components'([H|T],AccBytes, AccLen) ->
2487
   {EncBytes,EncLen} = encode_restricted_string(H, [<<4>>]),
×
2488
   'enc_AttributeList_SEQOF_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
×
2489

2490
'dec_AttributeList_SEQOF_vals'(Tlv, TagIn) ->
2491
   %%-------------------------------------------------
2492
   %% decode tag and length
2493
   %%-------------------------------------------------
2494
Tlv1 = match_tags(Tlv, TagIn),
×
2495
[decode_restricted_string(V1,[4]) || V1 <- Tlv1].
×
2496

2497

2498
'dec_AttributeList_SEQOF'(Tlv, TagIn) ->
2499
   %%-------------------------------------------------
2500
   %% decode tag and length
2501
   %%-------------------------------------------------
2502
Tlv1 = match_tags(Tlv, TagIn),
×
2503

2504
%%-------------------------------------------------
2505
%% attribute type(1) with type OCTET STRING
2506
%%-------------------------------------------------
2507
[V1|Tlv2] = Tlv1,
×
2508
Term1 = decode_restricted_string(V1,[4]),
×
2509

2510
%%-------------------------------------------------
2511
%% attribute vals(2) with type SET OF
2512
%%-------------------------------------------------
2513
[V2|Tlv3] = Tlv2,
×
2514
Term2 = 'dec_AttributeList_SEQOF_vals'(V2, [17]),
×
2515

2516
case Tlv3 of
×
2517
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2518
end,
2519
   {'AttributeList_SEQOF', Term1, Term2}.
×
2520

2521

2522

2523
'dec_AttributeList'(Tlv) ->
2524
   'dec_AttributeList'(Tlv, [16]).
×
2525

2526
'dec_AttributeList'(Tlv, TagIn) ->
2527
   %%-------------------------------------------------
2528
   %% decode tag and length
2529
   %%-------------------------------------------------
2530
Tlv1 = match_tags(Tlv, TagIn),
×
2531
['dec_AttributeList_SEQOF'(V1, [16]) || V1 <- Tlv1].
×
2532

2533

2534

2535

2536
%%================================
2537
%%  AddResponse
2538
%%================================
2539
'enc_AddResponse'(Val) ->
2540
    'enc_AddResponse'(Val, [<<105>>]).
×
2541

2542
'enc_AddResponse'(Val, TagIn) ->
2543
   'enc_LDAPResult'(Val, TagIn).
×
2544

2545

2546
'dec_AddResponse'(Tlv) ->
2547
   'dec_AddResponse'(Tlv, [65545]).
×
2548

2549
'dec_AddResponse'(Tlv, TagIn) ->
2550
'dec_LDAPResult'(Tlv, TagIn).
×
2551

2552

2553

2554
%%================================
2555
%%  DelRequest
2556
%%================================
2557
'enc_DelRequest'(Val) ->
2558
    'enc_DelRequest'(Val, [<<74>>]).
×
2559

2560
'enc_DelRequest'(Val, TagIn) ->
2561
encode_restricted_string(Val, TagIn).
×
2562

2563

2564
'dec_DelRequest'(Tlv) ->
2565
   'dec_DelRequest'(Tlv, [65546]).
×
2566

2567
'dec_DelRequest'(Tlv, TagIn) ->
2568
decode_restricted_string(Tlv,TagIn).
×
2569

2570

2571

2572
%%================================
2573
%%  DelResponse
2574
%%================================
2575
'enc_DelResponse'(Val) ->
2576
    'enc_DelResponse'(Val, [<<107>>]).
×
2577

2578
'enc_DelResponse'(Val, TagIn) ->
2579
   'enc_LDAPResult'(Val, TagIn).
×
2580

2581

2582
'dec_DelResponse'(Tlv) ->
2583
   'dec_DelResponse'(Tlv, [65547]).
×
2584

2585
'dec_DelResponse'(Tlv, TagIn) ->
2586
'dec_LDAPResult'(Tlv, TagIn).
×
2587

2588

2589

2590
%%================================
2591
%%  ModifyDNRequest
2592
%%================================
2593
'enc_ModifyDNRequest'(Val) ->
2594
    'enc_ModifyDNRequest'(Val, [<<108>>]).
×
2595

2596
'enc_ModifyDNRequest'(Val, TagIn) ->
2597
{_,Cindex1, Cindex2, Cindex3, Cindex4} = Val,
×
2598

2599
%%-------------------------------------------------
2600
%% attribute entry(1) with type OCTET STRING
2601
%%-------------------------------------------------
2602
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
2603

2604
%%-------------------------------------------------
2605
%% attribute newrdn(2) with type OCTET STRING
2606
%%-------------------------------------------------
2607
   {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
×
2608

2609
%%-------------------------------------------------
2610
%% attribute deleteoldrdn(3) with type BOOLEAN
2611
%%-------------------------------------------------
2612
   {EncBytes3,EncLen3} = encode_boolean(Cindex3, [<<1>>]),
×
2613

2614
%%-------------------------------------------------
2615
%% attribute newSuperior(4) with type OCTET STRING OPTIONAL
2616
%%-------------------------------------------------
2617
   {EncBytes4,EncLen4} =  case Cindex4 of
×
2618
         asn1_NOVALUE -> {<<>>,0};
×
2619
         _ ->
2620
            encode_restricted_string(Cindex4, [<<128>>])
×
2621
       end,
2622

2623
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
×
2624
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
×
2625
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2626

2627

2628
'dec_ModifyDNRequest'(Tlv) ->
2629
   'dec_ModifyDNRequest'(Tlv, [65548]).
×
2630

2631
'dec_ModifyDNRequest'(Tlv, TagIn) ->
2632
   %%-------------------------------------------------
2633
   %% decode tag and length
2634
   %%-------------------------------------------------
2635
Tlv1 = match_tags(Tlv, TagIn),
×
2636

2637
%%-------------------------------------------------
2638
%% attribute entry(1) with type OCTET STRING
2639
%%-------------------------------------------------
2640
[V1|Tlv2] = Tlv1,
×
2641
Term1 = decode_restricted_string(V1,[4]),
×
2642

2643
%%-------------------------------------------------
2644
%% attribute newrdn(2) with type OCTET STRING
2645
%%-------------------------------------------------
2646
[V2|Tlv3] = Tlv2,
×
2647
Term2 = decode_restricted_string(V2,[4]),
×
2648

2649
%%-------------------------------------------------
2650
%% attribute deleteoldrdn(3) with type BOOLEAN
2651
%%-------------------------------------------------
2652
[V3|Tlv4] = Tlv3,
×
2653
Term3 = decode_boolean(V3,[1]),
×
2654

2655
%%-------------------------------------------------
2656
%% attribute newSuperior(4) with type OCTET STRING OPTIONAL
2657
%%-------------------------------------------------
2658
{Term4,Tlv5} = case Tlv4 of
×
2659
[{131072,V4}|TempTlv5] ->
2660
    {decode_restricted_string(V4,[]), TempTlv5};
×
2661
    _ ->
2662
        { asn1_NOVALUE, Tlv4}
×
2663
end,
2664

2665
case Tlv5 of
×
2666
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed
×
2667
end,
2668
   {'ModifyDNRequest', Term1, Term2, Term3, Term4}.
×
2669

2670

2671

2672
%%================================
2673
%%  ModifyDNResponse
2674
%%================================
2675
'enc_ModifyDNResponse'(Val) ->
2676
    'enc_ModifyDNResponse'(Val, [<<109>>]).
×
2677

2678
'enc_ModifyDNResponse'(Val, TagIn) ->
2679
   'enc_LDAPResult'(Val, TagIn).
×
2680

2681

2682
'dec_ModifyDNResponse'(Tlv) ->
2683
   'dec_ModifyDNResponse'(Tlv, [65549]).
×
2684

2685
'dec_ModifyDNResponse'(Tlv, TagIn) ->
2686
'dec_LDAPResult'(Tlv, TagIn).
×
2687

2688

2689

2690
%%================================
2691
%%  CompareRequest
2692
%%================================
2693
'enc_CompareRequest'(Val) ->
2694
    'enc_CompareRequest'(Val, [<<110>>]).
×
2695

2696
'enc_CompareRequest'(Val, TagIn) ->
2697
{_,Cindex1, Cindex2} = Val,
×
2698

2699
%%-------------------------------------------------
2700
%% attribute entry(1) with type OCTET STRING
2701
%%-------------------------------------------------
2702
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
×
2703

2704
%%-------------------------------------------------
2705
%% attribute ava(2)   External ELDAPv3:AttributeValueAssertion
2706
%%-------------------------------------------------
2707
   {EncBytes2,EncLen2} = 'enc_AttributeValueAssertion'(Cindex2, [<<48>>]),
×
2708

2709
   BytesSoFar = [EncBytes1, EncBytes2],
×
2710
LenSoFar = EncLen1 + EncLen2,
×
2711
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2712

2713

2714
'dec_CompareRequest'(Tlv) ->
2715
   'dec_CompareRequest'(Tlv, [65550]).
×
2716

2717
'dec_CompareRequest'(Tlv, TagIn) ->
2718
   %%-------------------------------------------------
2719
   %% decode tag and length
2720
   %%-------------------------------------------------
2721
Tlv1 = match_tags(Tlv, TagIn),
×
2722

2723
%%-------------------------------------------------
2724
%% attribute entry(1) with type OCTET STRING
2725
%%-------------------------------------------------
2726
[V1|Tlv2] = Tlv1,
×
2727
Term1 = decode_restricted_string(V1,[4]),
×
2728

2729
%%-------------------------------------------------
2730
%% attribute ava(2)   External ELDAPv3:AttributeValueAssertion
2731
%%-------------------------------------------------
2732
[V2|Tlv3] = Tlv2,
×
2733
Term2 = 'dec_AttributeValueAssertion'(V2, [16]),
×
2734

2735
case Tlv3 of
×
2736
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2737
end,
2738
   {'CompareRequest', Term1, Term2}.
×
2739

2740

2741

2742
%%================================
2743
%%  CompareResponse
2744
%%================================
2745
'enc_CompareResponse'(Val) ->
2746
    'enc_CompareResponse'(Val, [<<111>>]).
×
2747

2748
'enc_CompareResponse'(Val, TagIn) ->
2749
   'enc_LDAPResult'(Val, TagIn).
×
2750

2751

2752
'dec_CompareResponse'(Tlv) ->
2753
   'dec_CompareResponse'(Tlv, [65551]).
×
2754

2755
'dec_CompareResponse'(Tlv, TagIn) ->
2756
'dec_LDAPResult'(Tlv, TagIn).
×
2757

2758

2759

2760
%%================================
2761
%%  AbandonRequest
2762
%%================================
2763
'enc_AbandonRequest'(Val) ->
2764
    'enc_AbandonRequest'(Val, [<<80>>]).
×
2765

2766
'enc_AbandonRequest'(Val, TagIn) ->
2767
encode_integer(Val, TagIn).
×
2768

2769

2770
'dec_AbandonRequest'(Tlv) ->
2771
   'dec_AbandonRequest'(Tlv, [65552]).
×
2772

2773
'dec_AbandonRequest'(Tlv, TagIn) ->
2774
decode_integer(Tlv,{0,2147483647},TagIn).
×
2775

2776

2777

2778
%%================================
2779
%%  ExtendedRequest
2780
%%================================
2781
'enc_ExtendedRequest'(Val) ->
2782
    'enc_ExtendedRequest'(Val, [<<119>>]).
×
2783

2784
'enc_ExtendedRequest'(Val, TagIn) ->
2785
{_,Cindex1, Cindex2} = Val,
×
2786

2787
%%-------------------------------------------------
2788
%% attribute requestName(1) with type OCTET STRING
2789
%%-------------------------------------------------
2790
   {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<128>>]),
×
2791

2792
%%-------------------------------------------------
2793
%% attribute requestValue(2) with type OCTET STRING OPTIONAL
2794
%%-------------------------------------------------
2795
   {EncBytes2,EncLen2} =  case Cindex2 of
×
2796
         asn1_NOVALUE -> {<<>>,0};
×
2797
         _ ->
2798
            encode_restricted_string(Cindex2, [<<129>>])
×
2799
       end,
2800

2801
   BytesSoFar = [EncBytes1, EncBytes2],
×
2802
LenSoFar = EncLen1 + EncLen2,
×
2803
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2804

2805

2806
'dec_ExtendedRequest'(Tlv) ->
2807
   'dec_ExtendedRequest'(Tlv, [65559]).
×
2808

2809
'dec_ExtendedRequest'(Tlv, TagIn) ->
2810
   %%-------------------------------------------------
2811
   %% decode tag and length
2812
   %%-------------------------------------------------
2813
Tlv1 = match_tags(Tlv, TagIn),
×
2814

2815
%%-------------------------------------------------
2816
%% attribute requestName(1) with type OCTET STRING
2817
%%-------------------------------------------------
2818
[V1|Tlv2] = Tlv1,
×
2819
Term1 = decode_restricted_string(V1,[131072]),
×
2820

2821
%%-------------------------------------------------
2822
%% attribute requestValue(2) with type OCTET STRING OPTIONAL
2823
%%-------------------------------------------------
2824
{Term2,Tlv3} = case Tlv2 of
×
2825
[{131073,V2}|TempTlv3] ->
2826
    {decode_restricted_string(V2,[]), TempTlv3};
×
2827
    _ ->
2828
        { asn1_NOVALUE, Tlv2}
×
2829
end,
2830

2831
case Tlv3 of
×
2832
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed
×
2833
end,
2834
   {'ExtendedRequest', Term1, Term2}.
×
2835

2836

2837

2838
%%================================
2839
%%  ExtendedResponse
2840
%%================================
2841
'enc_ExtendedResponse'(Val) ->
2842
    'enc_ExtendedResponse'(Val, [<<120>>]).
×
2843

2844
'enc_ExtendedResponse'(Val, TagIn) ->
2845
{_,Cindex1, Cindex2, Cindex3, Cindex4, Cindex5, Cindex6} = Val,
×
2846

2847
%%-------------------------------------------------
2848
%% attribute resultCode(1) with type ENUMERATED
2849
%%-------------------------------------------------
2850
   {EncBytes1,EncLen1} = case Cindex1 of
×
2851
success -> encode_enumerated(0, [<<10>>]);
×
2852
operationsError -> encode_enumerated(1, [<<10>>]);
×
2853
protocolError -> encode_enumerated(2, [<<10>>]);
×
2854
timeLimitExceeded -> encode_enumerated(3, [<<10>>]);
×
2855
sizeLimitExceeded -> encode_enumerated(4, [<<10>>]);
×
2856
compareFalse -> encode_enumerated(5, [<<10>>]);
×
2857
compareTrue -> encode_enumerated(6, [<<10>>]);
×
2858
authMethodNotSupported -> encode_enumerated(7, [<<10>>]);
×
2859
strongAuthRequired -> encode_enumerated(8, [<<10>>]);
×
2860
referral -> encode_enumerated(10, [<<10>>]);
×
2861
adminLimitExceeded -> encode_enumerated(11, [<<10>>]);
×
2862
unavailableCriticalExtension -> encode_enumerated(12, [<<10>>]);
×
2863
confidentialityRequired -> encode_enumerated(13, [<<10>>]);
×
2864
saslBindInProgress -> encode_enumerated(14, [<<10>>]);
×
2865
noSuchAttribute -> encode_enumerated(16, [<<10>>]);
×
2866
undefinedAttributeType -> encode_enumerated(17, [<<10>>]);
×
2867
inappropriateMatching -> encode_enumerated(18, [<<10>>]);
×
2868
constraintViolation -> encode_enumerated(19, [<<10>>]);
×
2869
attributeOrValueExists -> encode_enumerated(20, [<<10>>]);
×
2870
invalidAttributeSyntax -> encode_enumerated(21, [<<10>>]);
×
2871
noSuchObject -> encode_enumerated(32, [<<10>>]);
×
2872
aliasProblem -> encode_enumerated(33, [<<10>>]);
×
2873
invalidDNSyntax -> encode_enumerated(34, [<<10>>]);
×
2874
aliasDereferencingProblem -> encode_enumerated(36, [<<10>>]);
×
2875
inappropriateAuthentication -> encode_enumerated(48, [<<10>>]);
×
2876
invalidCredentials -> encode_enumerated(49, [<<10>>]);
×
2877
insufficientAccessRights -> encode_enumerated(50, [<<10>>]);
×
2878
busy -> encode_enumerated(51, [<<10>>]);
×
2879
unavailable -> encode_enumerated(52, [<<10>>]);
×
2880
unwillingToPerform -> encode_enumerated(53, [<<10>>]);
×
2881
loopDetect -> encode_enumerated(54, [<<10>>]);
×
2882
namingViolation -> encode_enumerated(64, [<<10>>]);
×
2883
objectClassViolation -> encode_enumerated(65, [<<10>>]);
×
2884
notAllowedOnNonLeaf -> encode_enumerated(66, [<<10>>]);
×
2885
notAllowedOnRDN -> encode_enumerated(67, [<<10>>]);
×
2886
entryAlreadyExists -> encode_enumerated(68, [<<10>>]);
×
2887
objectClassModsProhibited -> encode_enumerated(69, [<<10>>]);
×
2888
affectsMultipleDSAs -> encode_enumerated(71, [<<10>>]);
×
2889
other -> encode_enumerated(80, [<<10>>]);
×
2890
Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
×
2891
end,
2892

2893
%%-------------------------------------------------
2894
%% attribute matchedDN(2) with type OCTET STRING
2895
%%-------------------------------------------------
2896
   {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
×
2897

2898
%%-------------------------------------------------
2899
%% attribute errorMessage(3) with type OCTET STRING
2900
%%-------------------------------------------------
2901
   {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]),
×
2902

2903
%%-------------------------------------------------
2904
%% attribute referral(4)   External ELDAPv3:Referral OPTIONAL
2905
%%-------------------------------------------------
2906
   {EncBytes4,EncLen4} =  case Cindex4 of
×
2907
         asn1_NOVALUE -> {<<>>,0};
×
2908
         _ ->
2909
            'enc_Referral'(Cindex4, [<<163>>])
×
2910
       end,
2911

2912
%%-------------------------------------------------
2913
%% attribute responseName(5) with type OCTET STRING OPTIONAL
2914
%%-------------------------------------------------
2915
   {EncBytes5,EncLen5} =  case Cindex5 of
×
2916
         asn1_NOVALUE -> {<<>>,0};
×
2917
         _ ->
2918
            encode_restricted_string(Cindex5, [<<138>>])
×
2919
       end,
2920

2921
%%-------------------------------------------------
2922
%% attribute response(6) with type OCTET STRING OPTIONAL
2923
%%-------------------------------------------------
2924
   {EncBytes6,EncLen6} =  case Cindex6 of
×
2925
         asn1_NOVALUE -> {<<>>,0};
×
2926
         _ ->
2927
            encode_restricted_string(Cindex6, [<<139>>])
×
2928
       end,
2929

2930
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],
×
2931
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,
×
2932
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
2933

2934

2935
'dec_ExtendedResponse'(Tlv) ->
2936
   'dec_ExtendedResponse'(Tlv, [65560]).
×
2937

2938
'dec_ExtendedResponse'(Tlv, TagIn) ->
2939
   %%-------------------------------------------------
2940
   %% decode tag and length
2941
   %%-------------------------------------------------
2942
Tlv1 = match_tags(Tlv, TagIn),
×
2943

2944
%%-------------------------------------------------
2945
%% attribute resultCode(1) with type ENUMERATED
2946
%%-------------------------------------------------
2947
[V1|Tlv2] = Tlv1,
×
2948
Term1 = decode_enumerated(V1,[{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}],[10]),
×
2949

2950
%%-------------------------------------------------
2951
%% attribute matchedDN(2) with type OCTET STRING
2952
%%-------------------------------------------------
2953
[V2|Tlv3] = Tlv2,
×
2954
Term2 = decode_restricted_string(V2,[4]),
×
2955

2956
%%-------------------------------------------------
2957
%% attribute errorMessage(3) with type OCTET STRING
2958
%%-------------------------------------------------
2959
[V3|Tlv4] = Tlv3,
×
2960
Term3 = decode_restricted_string(V3,[4]),
×
2961

2962
%%-------------------------------------------------
2963
%% attribute referral(4)   External ELDAPv3:Referral OPTIONAL
2964
%%-------------------------------------------------
2965
{Term4,Tlv5} = case Tlv4 of
×
2966
[{131075,V4}|TempTlv5] ->
2967
    {'dec_Referral'(V4, []), TempTlv5};
×
2968
    _ ->
2969
        { asn1_NOVALUE, Tlv4}
×
2970
end,
2971

2972
%%-------------------------------------------------
2973
%% attribute responseName(5) with type OCTET STRING OPTIONAL
2974
%%-------------------------------------------------
2975
{Term5,Tlv6} = case Tlv5 of
×
2976
[{131082,V5}|TempTlv6] ->
2977
    {decode_restricted_string(V5,[]), TempTlv6};
×
2978
    _ ->
2979
        { asn1_NOVALUE, Tlv5}
×
2980
end,
2981

2982
%%-------------------------------------------------
2983
%% attribute response(6) with type OCTET STRING OPTIONAL
2984
%%-------------------------------------------------
2985
{Term6,Tlv7} = case Tlv6 of
×
2986
[{131083,V6}|TempTlv7] ->
2987
    {decode_restricted_string(V6,[]), TempTlv7};
×
2988
    _ ->
2989
        { asn1_NOVALUE, Tlv6}
×
2990
end,
2991

2992
case Tlv7 of
×
2993
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed
×
2994
end,
2995
   {'ExtendedResponse', Term1, Term2, Term3, Term4, Term5, Term6}.
×
2996

2997

2998

2999
%%================================
3000
%%  PasswdModifyRequestValue
3001
%%================================
3002
'enc_PasswdModifyRequestValue'(Val) ->
3003
    'enc_PasswdModifyRequestValue'(Val, [<<48>>]).
×
3004

3005
'enc_PasswdModifyRequestValue'(Val, TagIn) ->
3006
{_,Cindex1, Cindex2, Cindex3} = Val,
×
3007

3008
%%-------------------------------------------------
3009
%% attribute userIdentity(1) with type OCTET STRING OPTIONAL
3010
%%-------------------------------------------------
3011
   {EncBytes1,EncLen1} =  case Cindex1 of
×
3012
         asn1_NOVALUE -> {<<>>,0};
×
3013
         _ ->
3014
            encode_restricted_string(Cindex1, [<<128>>])
×
3015
       end,
3016

3017
%%-------------------------------------------------
3018
%% attribute oldPasswd(2) with type OCTET STRING OPTIONAL
3019
%%-------------------------------------------------
3020
   {EncBytes2,EncLen2} =  case Cindex2 of
×
3021
         asn1_NOVALUE -> {<<>>,0};
×
3022
         _ ->
3023
            encode_restricted_string(Cindex2, [<<129>>])
×
3024
       end,
3025

3026
%%-------------------------------------------------
3027
%% attribute newPasswd(3) with type OCTET STRING OPTIONAL
3028
%%-------------------------------------------------
3029
   {EncBytes3,EncLen3} =  case Cindex3 of
×
3030
         asn1_NOVALUE -> {<<>>,0};
×
3031
         _ ->
3032
            encode_restricted_string(Cindex3, [<<130>>])
×
3033
       end,
3034

3035
   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
×
3036
LenSoFar = EncLen1 + EncLen2 + EncLen3,
×
3037
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
3038

3039

3040
'dec_PasswdModifyRequestValue'(Tlv) ->
3041
   'dec_PasswdModifyRequestValue'(Tlv, [16]).
×
3042

3043
'dec_PasswdModifyRequestValue'(Tlv, TagIn) ->
3044
   %%-------------------------------------------------
3045
   %% decode tag and length
3046
   %%-------------------------------------------------
3047
Tlv1 = match_tags(Tlv, TagIn),
×
3048

3049
%%-------------------------------------------------
3050
%% attribute userIdentity(1) with type OCTET STRING OPTIONAL
3051
%%-------------------------------------------------
3052
{Term1,Tlv2} = case Tlv1 of
×
3053
[{131072,V1}|TempTlv2] ->
3054
    {decode_restricted_string(V1,[]), TempTlv2};
×
3055
    _ ->
3056
        { asn1_NOVALUE, Tlv1}
×
3057
end,
3058

3059
%%-------------------------------------------------
3060
%% attribute oldPasswd(2) with type OCTET STRING OPTIONAL
3061
%%-------------------------------------------------
3062
{Term2,Tlv3} = case Tlv2 of
×
3063
[{131073,V2}|TempTlv3] ->
3064
    {decode_restricted_string(V2,[]), TempTlv3};
×
3065
    _ ->
3066
        { asn1_NOVALUE, Tlv2}
×
3067
end,
3068

3069
%%-------------------------------------------------
3070
%% attribute newPasswd(3) with type OCTET STRING OPTIONAL
3071
%%-------------------------------------------------
3072
{Term3,Tlv4} = case Tlv3 of
×
3073
[{131074,V3}|TempTlv4] ->
3074
    {decode_restricted_string(V3,[]), TempTlv4};
×
3075
    _ ->
3076
        { asn1_NOVALUE, Tlv3}
×
3077
end,
3078

3079
case Tlv4 of
×
3080
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
×
3081
end,
3082
   {'PasswdModifyRequestValue', Term1, Term2, Term3}.
×
3083

3084

3085

3086
%%================================
3087
%%  PasswdModifyResponseValue
3088
%%================================
3089
'enc_PasswdModifyResponseValue'(Val) ->
3090
    'enc_PasswdModifyResponseValue'(Val, [<<48>>]).
×
3091

3092
'enc_PasswdModifyResponseValue'(Val, TagIn) ->
3093
{_,Cindex1} = Val,
×
3094

3095
%%-------------------------------------------------
3096
%% attribute genPasswd(1) with type OCTET STRING OPTIONAL
3097
%%-------------------------------------------------
3098
   {EncBytes1,EncLen1} =  case Cindex1 of
×
3099
         asn1_NOVALUE -> {<<>>,0};
×
3100
         _ ->
3101
            encode_restricted_string(Cindex1, [<<128>>])
×
3102
       end,
3103

3104
   BytesSoFar = [EncBytes1],
×
3105
LenSoFar = EncLen1,
×
3106
encode_tags(TagIn, BytesSoFar, LenSoFar).
×
3107

3108

3109
'dec_PasswdModifyResponseValue'(Tlv) ->
3110
   'dec_PasswdModifyResponseValue'(Tlv, [16]).
×
3111

3112
'dec_PasswdModifyResponseValue'(Tlv, TagIn) ->
3113
   %%-------------------------------------------------
3114
   %% decode tag and length
3115
   %%-------------------------------------------------
3116
Tlv1 = match_tags(Tlv, TagIn),
×
3117

3118
%%-------------------------------------------------
3119
%% attribute genPasswd(1) with type OCTET STRING OPTIONAL
3120
%%-------------------------------------------------
3121
{Term1,Tlv2} = case Tlv1 of
×
3122
[{131072,V1}|TempTlv2] ->
3123
    {decode_restricted_string(V1,[]), TempTlv2};
×
3124
    _ ->
3125
        { asn1_NOVALUE, Tlv1}
×
3126
end,
3127

3128
case Tlv2 of
×
3129
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv2}}}) % extra fields not allowed
×
3130
end,
3131
   {'PasswdModifyResponseValue', Term1}.
×
3132

3133
'maxInt'() ->
3134
2147483647.
×
3135

3136
'passwdModifyOID'() ->
3137
[49,46,51,46,54,46,49,46,52,46,49,46,52,50,48,51,46,49,46,49,49,46,49].
×
3138

3139

3140
%%%
3141
%%% Run-time functions.
3142
%%%
3143

3144
ber_decode_nif(B) ->
3145
    asn1rt_nif:decode_ber_tlv(B).
27✔
3146

3147
collect_parts(TlvList) ->
3148
    collect_parts(TlvList, []).
×
3149

3150
collect_parts([{_,L}|Rest], Acc) when is_list(L) ->
3151
    collect_parts(Rest, [collect_parts(L)|Acc]);
×
3152
collect_parts([{3,<<Unused,Bits/binary>>}|Rest], _Acc) ->
3153
    collect_parts_bit(Rest, [Bits], Unused);
×
3154
collect_parts([{_T,V}|Rest], Acc) ->
3155
    collect_parts(Rest, [V|Acc]);
×
3156
collect_parts([], Acc) ->
3157
    list_to_binary(lists:reverse(Acc)).
×
3158

3159
collect_parts_bit([{3,<<Unused,Bits/binary>>}|Rest], Acc, Uacc) ->
3160
    collect_parts_bit(Rest, [Bits|Acc], Unused + Uacc);
×
3161
collect_parts_bit([], Acc, Uacc) ->
3162
    list_to_binary([Uacc|lists:reverse(Acc)]).
×
3163

3164
decode_boolean(Tlv, TagIn) ->
3165
    Val = match_tags(Tlv, TagIn),
6✔
3166
    case Val of
6✔
3167
        <<0:8>> ->
3168
            false;
6✔
3169
        <<_:8>> ->
3170
            true;
×
3171
        _ ->
3172
            exit({error,{asn1,{decode_boolean,Val}}})
×
3173
    end.
3174

3175
decode_enumerated(Tlv, NamedNumberList, Tags) ->
3176
    Buffer = match_tags(Tlv, Tags),
23✔
3177
    decode_enumerated_notag(Buffer, NamedNumberList, Tags).
23✔
3178

3179
decode_enumerated1(Val, NamedNumberList) ->
3180
    case lists:keyfind(Val, 2, NamedNumberList) of
23✔
3181
        {NamedVal,_} ->
3182
            NamedVal;
23✔
3183
        _ ->
3184
            {asn1_enum,Val}
×
3185
    end.
3186

3187
decode_enumerated_notag(Buffer, {NamedNumberList,ExtList}, _Tags) ->
3188
    IVal = decode_integer(Buffer),
×
3189
    case decode_enumerated1(IVal, NamedNumberList) of
×
3190
        {asn1_enum,IVal} ->
3191
            decode_enumerated1(IVal, ExtList);
×
3192
        EVal ->
3193
            EVal
×
3194
    end;
3195
decode_enumerated_notag(Buffer, NNList, _Tags) ->
3196
    IVal = decode_integer(Buffer),
23✔
3197
    case decode_enumerated1(IVal, NNList) of
23✔
3198
        {asn1_enum,_} ->
3199
            exit({error,{asn1,{illegal_enumerated,IVal}}});
×
3200
        EVal ->
3201
            EVal
23✔
3202
    end.
3203

3204
decode_integer(Bin) ->
3205
    Len = byte_size(Bin),
67✔
3206
    <<Int:Len/signed-unit:8>> = Bin,
67✔
3207
    Int.
67✔
3208

3209
decode_integer(Tlv, Range, TagIn) ->
3210
    V = match_tags(Tlv, TagIn),
44✔
3211
    Int = decode_integer(V),
44✔
3212
    range_check_integer(Int, Range).
44✔
3213

3214
decode_null(Tlv, Tags) ->
3215
    Val = match_tags(Tlv, Tags),
×
3216
    case Val of
×
3217
        <<>> ->
3218
            'NULL';
×
3219
        _ ->
3220
            exit({error,{asn1,{decode_null,Val}}})
×
3221
    end.
3222

3223
decode_restricted_string(Tlv, TagsIn) ->
3224
    Bin = match_and_collect(Tlv, TagsIn),
102✔
3225
    Bin.
102✔
3226

3227
encode_boolean(true, TagIn) ->
3228
    encode_tags(TagIn, [255], 1);
×
3229
encode_boolean(false, TagIn) ->
3230
    encode_tags(TagIn, [0], 1);
6✔
3231
encode_boolean(X, _) ->
3232
    exit({error,{asn1,{encode_boolean,X}}}).
×
3233

3234
encode_enumerated(Val, TagIn) when is_integer(Val) ->
3235
    encode_tags(TagIn, encode_integer(Val)).
23✔
3236

3237
encode_integer(Val) ->
3238
    Bytes =
67✔
3239
        if
3240
            Val >= 0 ->
3241
                encode_integer_pos(Val, []);
67✔
3242
            true ->
3243
                encode_integer_neg(Val, [])
×
3244
        end,
3245
    {Bytes,length(Bytes)}.
67✔
3246

3247
encode_integer(Val, Tag) when is_integer(Val) ->
3248
    encode_tags(Tag, encode_integer(Val));
44✔
3249
encode_integer(Val, _Tag) ->
3250
    exit({error,{asn1,{encode_integer,Val}}}).
×
3251

3252
encode_integer_neg(- 1, [B1|_T] = L) when B1 > 127 ->
3253
    L;
×
3254
encode_integer_neg(N, Acc) ->
3255
    encode_integer_neg(N bsr 8, [N band 255|Acc]).
×
3256

3257
encode_integer_pos(0, [B|_Acc] = L) when B < 128 ->
3258
    L;
67✔
3259
encode_integer_pos(N, Acc) ->
3260
    encode_integer_pos(N bsr 8, [N band 255|Acc]).
67✔
3261

3262
encode_length(L) when L =< 127 ->
3263
    {[L],1};
259✔
3264
encode_length(L) ->
3265
    Oct = minimum_octets(L),
5✔
3266
    Len = length(Oct),
5✔
3267
    if
5✔
3268
        Len =< 126 ->
3269
            {[128 bor Len|Oct],Len + 1};
5✔
3270
        true ->
3271
            exit({error,{asn1,too_long_length_oct,Len}})
×
3272
    end.
3273

3274
encode_null(_Val, TagIn) ->
3275
    encode_tags(TagIn, [], 0).
×
3276

3277
encode_restricted_string(OctetList, TagIn) when is_binary(OctetList) ->
3278
    encode_tags(TagIn, OctetList, byte_size(OctetList));
102✔
3279
encode_restricted_string(OctetList, TagIn) when is_list(OctetList) ->
3280
    encode_tags(TagIn, OctetList, length(OctetList)).
×
3281

3282
encode_tags(TagIn, {BytesSoFar,LenSoFar}) ->
3283
    encode_tags(TagIn, BytesSoFar, LenSoFar).
67✔
3284

3285
encode_tags([Tag|Trest], BytesSoFar, LenSoFar) ->
3286
    {Bytes2,L2} = encode_length(LenSoFar),
264✔
3287
    encode_tags(Trest,
264✔
3288
                [Tag,Bytes2|BytesSoFar],
3289
                LenSoFar + byte_size(Tag) + L2);
3290
encode_tags([], BytesSoFar, LenSoFar) ->
3291
    {BytesSoFar,LenSoFar}.
304✔
3292

3293
match_and_collect(Tlv, TagsIn) ->
3294
    Val = match_tags(Tlv, TagsIn),
102✔
3295
    case Val of
102✔
3296
        [_|_] = PartList ->
3297
            collect_parts(PartList);
×
3298
        Bin when is_binary(Bin) ->
3299
            Bin
102✔
3300
    end.
3301

3302
match_tags({T,V}, [T]) ->
3303
    V;
224✔
3304
match_tags({T,V}, [T|Tt]) ->
3305
    match_tags(V, Tt);
×
3306
match_tags([{T,V}], [T|Tt]) ->
3307
    match_tags(V, Tt);
×
3308
match_tags([{T,_V}|_] = Vlist, [T]) ->
3309
    Vlist;
×
3310
match_tags(Tlv, []) ->
3311
    Tlv;
80✔
3312
match_tags({Tag,_V} = Tlv, [T|_Tt]) ->
3313
    exit({error,{asn1,{wrong_tag,{{expected,T},{got,Tag,Tlv}}}}}).
×
3314

3315
minimum_octets(0, Acc) ->
3316
    Acc;
5✔
3317
minimum_octets(Val, Acc) ->
3318
    minimum_octets(Val bsr 8, [Val band 255|Acc]).
6✔
3319

3320
minimum_octets(Val) ->
3321
    minimum_octets(Val, []).
5✔
3322

3323
range_check_integer(Int, Range) ->
3324
    case Range of
44✔
3325
        [] ->
3326
            Int;
×
3327
        {Lb,Ub} when Int >= Lb, Ub >= Int ->
3328
            Int;
44✔
3329
        {_,_} ->
3330
            exit({error,{asn1,{integer_range,Range,Int}}});
×
3331
        Int ->
3332
            Int;
×
3333
        SingleValue when is_integer(SingleValue) ->
3334
            exit({error,{asn1,{integer_range,Range,Int}}});
×
3335
        _ ->
3336
            Int
×
3337
    end.
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc