]> granicus.if.org Git - ejabberd/commitdiff
Cleanup
authorAlexey Shchepin <alexey@process-one.net>
Sun, 17 Apr 2005 21:39:41 +0000 (21:39 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Sun, 17 Apr 2005 21:39:41 +0000 (21:39 +0000)
SVN Revision: 309

12 files changed:
.cvslog [deleted file]
ChangeLog
TODO-vh [deleted file]
src/ejabberd_auth_odbc.erl
src/ejabberd_c2s.erl
src/ejabberd_ctl.erl
src/ejabberd_sm.erl
src/eldap/ELDAPv3.erl [deleted file]
src/eldap/ELDAPv3.hrl [deleted file]
src/mod_muc/mod_muc_room.erl
src/web/ejabberd_http1.erl [deleted file]
src/web/ejabberd_wcs.erl [deleted file]

diff --git a/.cvslog b/.cvslog
deleted file mode 100644 (file)
index dd13d46..0000000
--- a/.cvslog
+++ /dev/null
@@ -1,3 +0,0 @@
-jabber://aleksey@jabber.ru
-jabber://sgolovan@nes.ru
-ryazanov@gmail.com
index 8fdd0eec6cefd304f9851e5a09a5c897e9bcda67..1629ce6a2f1eed61f7af7012600a678976d847e0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-04-17  Alexey Shchepin  <alexey@sevcom.net>
+
+       * (all): Merged virtual hosting support
+
 2005-04-09  Alexey Shchepin  <alexey@sevcom.net>
 
        * src/ejabberd_c2s.erl: Send new id for each new stream inside one
diff --git a/TODO-vh b/TODO-vh
deleted file mode 100644 (file)
index 7f08c63..0000000
--- a/TODO-vh
+++ /dev/null
@@ -1,86 +0,0 @@
-check remove_user hook
-
-check all usages of ejabberd_auth
-
-+ src/ejabberd.hrl -- add MYHOSTS macro to return a list of virtual domains,
-  MYNAME should return first defined host
-
-? src/acl.erl -- "user", "user_regexp", "user_regexp" should match all virtual
-  domains
-
-+ src/cyrsasl_digest.erl -- need to use both "username" and "authzid", or better
-  to use callback function
-
-+ src/cyrsasl_plain.erl -- likewise
-
-+ src/cyrsasl.erl -- likewise
-
-+ src/ejabberd_auth.erl -- add "Server" argument to almost all exported
-  functions
-
-(workaround) src/ejabberd_auth_external.erl -- likewise
-
-+ src/ejabberd_auth_internal.erl -- likewise
-
-(workaround) src/ejabberd_auth_ldap.erl -- likewise
-
-(workaround) src/ejabberd_auth_odbc.erl -- likewise
-
-+ src/ejabberd_c2s.erl -- add validation of a server field
-
-+ src/ejabberd_config.erl -- support for "hosts" option
-
-src/ejabberd_ctl.erl -- add server argument to "register", "unregister", and
-"registered-users" commands
-
-+ src/ejabberd_local.erl -- register all virtual hosts in router
-
-+ src/ejabberd_router.erl -- update dirty_get_all_routes/0
-
-src/ejabberd_service.erl -- probably minor update in stream header
-
-+ src/ejabberd_sm.erl -- update "session" and "presence" tables to contain
-  server name in first two fields
-
-- src/extauth.erl -- same as for src/ejabberd_auth_external.erl
-
-src/jd2ejd.erl -- anyway need to be rewriten :)
-
-+ src/mod_announce.erl -- update to ejabberd_auth changes, (-) probably update
-  to send different server names in "from" attribute to users on different
-  virtual hosts
-
-+ src/mod_configure.erl -- update users part
-
-+ src/mod_disco.erl -- likewise
-
-+ src/mod_last.erl -- update db table to store server part of jid
-
-src/mod_last_odbc.erl -- likewise
-
-+ src/mod_offline.erl -- likewise
-
-src/mod_offline_odbc.erl -- likewise
-
-+ src/mod_privacy.erl -- likewise
-
-+ src/mod_private.erl -- likewise
-
-+ src/mod_register.erl -- need to check server field in sender jid and pass it
-  to ejabberd_auth
-
-(not tested) src/mod_roster.erl -- update db table to store server part of jid
-
-src/mod_roster_odbc.erl -- update roster_in_subscription,
-roster_out_subscription, roster_get_subscription_lists hooks
-
-+ src/mod_vcard.erl -- update db table to store server part of jid
-
-src/mod_vcard_ldap.erl -- update db table to store server part of jid
-
-src/mod_pubsub/mod_pubsub.erl -- update defining of "ServedHosts" variable
-
-+ src/web/ejabberd_web_admin.erl -- update user listing, roster editing, acl
-  setting parts
-
-+ src/web/ejabberd_web.erl -- update user authorization
index 1cb5ca4e41df33b372f7df2c029824f2027aeedf..67696ed135ba614fb27c8b1eeaf7ed6c7df00789 100644 (file)
@@ -17,6 +17,7 @@
         check_password/5,
         try_register/3,
         dirty_get_registered_users/0,
+        get_vh_registered_users/1,
         get_password/2,
         get_password_s/2,
         is_user_exists/2,
@@ -118,7 +119,7 @@ dirty_get_registered_users() ->
            []
     end.
 
-dirty_get_registered_users(Server) ->
+get_vh_registered_users(Server) ->
     dirty_get_registered_users().
 
 get_password(User, _Server) ->
index 3873ac1715e42a49e2be14f8797abe00786a5a3d..43a8a10846e5a235f31cfe3860006553212d59f0 100644 (file)
@@ -445,7 +445,8 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
                    ?INFO_MSG("(~w) Accepted authentication for ~s",
                              [StateData#state.socket, U]),
                    {next_state, wait_for_stream,
-                    StateData#state{authentificated = true,
+                    StateData#state{streamid = new_id(),
+                                    authentificated = true,
                                     user = U
                                    }};
                {continue, ServerOut, NewSASLState} ->
@@ -475,6 +476,7 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
            {next_state, wait_for_stream,
             StateData#state{sockmod = tls,
                             socket = TLSSocket,
+                            streamid = new_id(),
                             tls_enabled = true
                            }};
        _ ->
@@ -533,7 +535,8 @@ wait_for_sasl_response({xmlstreamelement, El}, StateData) ->
                    ?INFO_MSG("(~w) Accepted authentication for ~s",
                              [StateData#state.socket, U]),
                    {next_state, wait_for_stream,
-                    StateData#state{authentificated = true,
+                    StateData#state{streamid = new_id(),
+                                    authentificated = true,
                                     user = U
                                    }};
                {continue, ServerOut, NewSASLState} ->
index 1c1d338771c3798655af31b174da9845da7302a6..55c8008a7804286fd3769057b66d793e4a306061 100644 (file)
@@ -147,7 +147,7 @@ process(Node, ["load", Path]) ->
 process(Node, ["restore", Path]) ->
     case rpc:call(Node,
                  mnesia, restore, [Path, [{default_op, keep_tables}]]) of
-       {atomic, ok} ->
+       {atomic, _} ->
            ?STATUS_SUCCESS;
        {error, Reason} ->
            io:format("Can't restore backup from ~p on node ~p: ~p~n",
index c7f78ca7119a9c3af9485e8da0920bb998484b8f..39a4beead9154503816fe5f389e4913e5f6ceb31 100644 (file)
@@ -146,7 +146,8 @@ clean_table_from_bad_node(Node) ->
                         [{'==', {node, '$1'}, Node}],
                         ['$_']}]),
                lists:foreach(fun(E) ->
-                                     mnesia:delete_object(E)
+                                     mnesia:delete_object(E),
+                                     mnesia:delete({presence, E#session.usr})
                              end, Es)
         end,
     mnesia:transaction(F).
diff --git a/src/eldap/ELDAPv3.erl b/src/eldap/ELDAPv3.erl
deleted file mode 100644 (file)
index 44657ee..0000000
+++ /dev/null
@@ -1,2972 +0,0 @@
-%% Generated by the Erlang ASN.1 BER-compiler version, utilizing bit-syntax:1.3.2
-%% Purpose: encoder and decoder to the types in mod ELDAPv3
-
--module('ELDAPv3').
--include("ELDAPv3.hrl").
--define('RT_BER',asn1rt_ber_bin).
--export([encoding_rule/0]).
--export([
-'enc_LDAPMessage'/2,
-'enc_MessageID'/2,
-'enc_LDAPString'/2,
-'enc_LDAPOID'/2,
-'enc_LDAPDN'/2,
-'enc_RelativeLDAPDN'/2,
-'enc_AttributeType'/2,
-'enc_AttributeDescription'/2,
-'enc_AttributeDescriptionList'/2,
-'enc_AttributeValue'/2,
-'enc_AttributeValueAssertion'/2,
-'enc_AssertionValue'/2,
-'enc_Attribute'/2,
-'enc_MatchingRuleId'/2,
-'enc_LDAPResult'/2,
-'enc_Referral'/2,
-'enc_LDAPURL'/2,
-'enc_Controls'/2,
-'enc_Control'/2,
-'enc_BindRequest'/2,
-'enc_AuthenticationChoice'/2,
-'enc_SaslCredentials'/2,
-'enc_BindResponse'/2,
-'enc_UnbindRequest'/2,
-'enc_SearchRequest'/2,
-'enc_Filter'/2,
-'enc_SubstringFilter'/2,
-'enc_MatchingRuleAssertion'/2,
-'enc_SearchResultEntry'/2,
-'enc_PartialAttributeList'/2,
-'enc_SearchResultReference'/2,
-'enc_SearchResultDone'/2,
-'enc_ModifyRequest'/2,
-'enc_AttributeTypeAndValues'/2,
-'enc_ModifyResponse'/2,
-'enc_AddRequest'/2,
-'enc_AttributeList'/2,
-'enc_AddResponse'/2,
-'enc_DelRequest'/2,
-'enc_DelResponse'/2,
-'enc_ModifyDNRequest'/2,
-'enc_ModifyDNResponse'/2,
-'enc_CompareRequest'/2,
-'enc_CompareResponse'/2,
-'enc_AbandonRequest'/2,
-'enc_ExtendedRequest'/2,
-'enc_ExtendedResponse'/2
-]).
-
--export([
-'dec_LDAPMessage'/2,
-'dec_MessageID'/2,
-'dec_LDAPString'/2,
-'dec_LDAPOID'/2,
-'dec_LDAPDN'/2,
-'dec_RelativeLDAPDN'/2,
-'dec_AttributeType'/2,
-'dec_AttributeDescription'/2,
-'dec_AttributeDescriptionList'/2,
-'dec_AttributeValue'/2,
-'dec_AttributeValueAssertion'/2,
-'dec_AssertionValue'/2,
-'dec_Attribute'/2,
-'dec_MatchingRuleId'/2,
-'dec_LDAPResult'/2,
-'dec_Referral'/2,
-'dec_LDAPURL'/2,
-'dec_Controls'/2,
-'dec_Control'/2,
-'dec_BindRequest'/2,
-'dec_AuthenticationChoice'/2,
-'dec_SaslCredentials'/2,
-'dec_BindResponse'/2,
-'dec_UnbindRequest'/2,
-'dec_SearchRequest'/2,
-'dec_Filter'/2,
-'dec_SubstringFilter'/2,
-'dec_MatchingRuleAssertion'/2,
-'dec_SearchResultEntry'/2,
-'dec_PartialAttributeList'/2,
-'dec_SearchResultReference'/2,
-'dec_SearchResultDone'/2,
-'dec_ModifyRequest'/2,
-'dec_AttributeTypeAndValues'/2,
-'dec_ModifyResponse'/2,
-'dec_AddRequest'/2,
-'dec_AttributeList'/2,
-'dec_AddResponse'/2,
-'dec_DelRequest'/2,
-'dec_DelResponse'/2,
-'dec_ModifyDNRequest'/2,
-'dec_ModifyDNResponse'/2,
-'dec_CompareRequest'/2,
-'dec_CompareResponse'/2,
-'dec_AbandonRequest'/2,
-'dec_ExtendedRequest'/2,
-'dec_ExtendedResponse'/2
-]).
-
--export([
-'dec_LDAPMessage'/3,
-'dec_MessageID'/3,
-'dec_LDAPString'/3,
-'dec_LDAPOID'/3,
-'dec_LDAPDN'/3,
-'dec_RelativeLDAPDN'/3,
-'dec_AttributeType'/3,
-'dec_AttributeDescription'/3,
-'dec_AttributeDescriptionList'/3,
-'dec_AttributeValue'/3,
-'dec_AttributeValueAssertion'/3,
-'dec_AssertionValue'/3,
-'dec_Attribute'/3,
-'dec_MatchingRuleId'/3,
-'dec_LDAPResult'/3,
-'dec_Referral'/3,
-'dec_LDAPURL'/3,
-'dec_Controls'/3,
-'dec_Control'/3,
-'dec_BindRequest'/3,
-'dec_AuthenticationChoice'/3,
-'dec_SaslCredentials'/3,
-'dec_BindResponse'/3,
-'dec_UnbindRequest'/3,
-'dec_SearchRequest'/3,
-'dec_Filter'/3,
-'dec_SubstringFilter'/3,
-'dec_MatchingRuleAssertion'/3,
-'dec_SearchResultEntry'/3,
-'dec_PartialAttributeList'/3,
-'dec_SearchResultReference'/3,
-'dec_SearchResultDone'/3,
-'dec_ModifyRequest'/3,
-'dec_AttributeTypeAndValues'/3,
-'dec_ModifyResponse'/3,
-'dec_AddRequest'/3,
-'dec_AttributeList'/3,
-'dec_AddResponse'/3,
-'dec_DelRequest'/3,
-'dec_DelResponse'/3,
-'dec_ModifyDNRequest'/3,
-'dec_ModifyDNResponse'/3,
-'dec_CompareRequest'/3,
-'dec_CompareResponse'/3,
-'dec_AbandonRequest'/3,
-'dec_ExtendedRequest'/3,
-'dec_ExtendedResponse'/3
-]).
-
--export([
-'maxInt'/0
-]).
-
-
-
--export([encode/2,decode/2,encode_disp/2,decode_disp/2]).
-
-encoding_rule() ->
-   ber_bin.
-
-encode(Type,Data) ->
-case catch encode_disp(Type,Data) of
-  {'EXIT',{error,Reason}} ->
-    {error,Reason};
-  {'EXIT',Reason} ->
-    {error,{asn1,Reason}};
-  {Bytes,Len} ->
-    {ok,Bytes};
-  X ->
-    {ok,X}
-end.
-
-decode(Type,Data) ->
-case catch decode_disp(Type,Data) of
-  {'EXIT',{error,Reason}} ->
-    {error,Reason};
-  {'EXIT',Reason} ->
-    {error,{asn1,Reason}};
-  {X,_Rest} ->
-    {ok,X};
-  {X,_Rest,_Len} ->
-    {ok,X}
-end.
-
-encode_disp('LDAPMessage',Data) -> 'enc_LDAPMessage'(Data,[]);
-encode_disp('MessageID',Data) -> 'enc_MessageID'(Data,[]);
-encode_disp('LDAPString',Data) -> 'enc_LDAPString'(Data,[]);
-encode_disp('LDAPOID',Data) -> 'enc_LDAPOID'(Data,[]);
-encode_disp('LDAPDN',Data) -> 'enc_LDAPDN'(Data,[]);
-encode_disp('RelativeLDAPDN',Data) -> 'enc_RelativeLDAPDN'(Data,[]);
-encode_disp('AttributeType',Data) -> 'enc_AttributeType'(Data,[]);
-encode_disp('AttributeDescription',Data) -> 'enc_AttributeDescription'(Data,[]);
-encode_disp('AttributeDescriptionList',Data) -> 'enc_AttributeDescriptionList'(Data,[]);
-encode_disp('AttributeValue',Data) -> 'enc_AttributeValue'(Data,[]);
-encode_disp('AttributeValueAssertion',Data) -> 'enc_AttributeValueAssertion'(Data,[]);
-encode_disp('AssertionValue',Data) -> 'enc_AssertionValue'(Data,[]);
-encode_disp('Attribute',Data) -> 'enc_Attribute'(Data,[]);
-encode_disp('MatchingRuleId',Data) -> 'enc_MatchingRuleId'(Data,[]);
-encode_disp('LDAPResult',Data) -> 'enc_LDAPResult'(Data,[]);
-encode_disp('Referral',Data) -> 'enc_Referral'(Data,[]);
-encode_disp('LDAPURL',Data) -> 'enc_LDAPURL'(Data,[]);
-encode_disp('Controls',Data) -> 'enc_Controls'(Data,[]);
-encode_disp('Control',Data) -> 'enc_Control'(Data,[]);
-encode_disp('BindRequest',Data) -> 'enc_BindRequest'(Data,[]);
-encode_disp('AuthenticationChoice',Data) -> 'enc_AuthenticationChoice'(Data,[]);
-encode_disp('SaslCredentials',Data) -> 'enc_SaslCredentials'(Data,[]);
-encode_disp('BindResponse',Data) -> 'enc_BindResponse'(Data,[]);
-encode_disp('UnbindRequest',Data) -> 'enc_UnbindRequest'(Data,[]);
-encode_disp('SearchRequest',Data) -> 'enc_SearchRequest'(Data,[]);
-encode_disp('Filter',Data) -> 'enc_Filter'(Data,[]);
-encode_disp('SubstringFilter',Data) -> 'enc_SubstringFilter'(Data,[]);
-encode_disp('MatchingRuleAssertion',Data) -> 'enc_MatchingRuleAssertion'(Data,[]);
-encode_disp('SearchResultEntry',Data) -> 'enc_SearchResultEntry'(Data,[]);
-encode_disp('PartialAttributeList',Data) -> 'enc_PartialAttributeList'(Data,[]);
-encode_disp('SearchResultReference',Data) -> 'enc_SearchResultReference'(Data,[]);
-encode_disp('SearchResultDone',Data) -> 'enc_SearchResultDone'(Data,[]);
-encode_disp('ModifyRequest',Data) -> 'enc_ModifyRequest'(Data,[]);
-encode_disp('AttributeTypeAndValues',Data) -> 'enc_AttributeTypeAndValues'(Data,[]);
-encode_disp('ModifyResponse',Data) -> 'enc_ModifyResponse'(Data,[]);
-encode_disp('AddRequest',Data) -> 'enc_AddRequest'(Data,[]);
-encode_disp('AttributeList',Data) -> 'enc_AttributeList'(Data,[]);
-encode_disp('AddResponse',Data) -> 'enc_AddResponse'(Data,[]);
-encode_disp('DelRequest',Data) -> 'enc_DelRequest'(Data,[]);
-encode_disp('DelResponse',Data) -> 'enc_DelResponse'(Data,[]);
-encode_disp('ModifyDNRequest',Data) -> 'enc_ModifyDNRequest'(Data,[]);
-encode_disp('ModifyDNResponse',Data) -> 'enc_ModifyDNResponse'(Data,[]);
-encode_disp('CompareRequest',Data) -> 'enc_CompareRequest'(Data,[]);
-encode_disp('CompareResponse',Data) -> 'enc_CompareResponse'(Data,[]);
-encode_disp('AbandonRequest',Data) -> 'enc_AbandonRequest'(Data,[]);
-encode_disp('ExtendedRequest',Data) -> 'enc_ExtendedRequest'(Data,[]);
-encode_disp('ExtendedResponse',Data) -> 'enc_ExtendedResponse'(Data,[]);
-encode_disp(Type,Data) -> exit({error,{asn1,{undefined_type,Type}}}).
-
-
-decode_disp('LDAPMessage',Data) -> 'dec_LDAPMessage'(Data,mandatory);
-decode_disp('MessageID',Data) -> 'dec_MessageID'(Data,mandatory);
-decode_disp('LDAPString',Data) -> 'dec_LDAPString'(Data,mandatory);
-decode_disp('LDAPOID',Data) -> 'dec_LDAPOID'(Data,mandatory);
-decode_disp('LDAPDN',Data) -> 'dec_LDAPDN'(Data,mandatory);
-decode_disp('RelativeLDAPDN',Data) -> 'dec_RelativeLDAPDN'(Data,mandatory);
-decode_disp('AttributeType',Data) -> 'dec_AttributeType'(Data,mandatory);
-decode_disp('AttributeDescription',Data) -> 'dec_AttributeDescription'(Data,mandatory);
-decode_disp('AttributeDescriptionList',Data) -> 'dec_AttributeDescriptionList'(Data,mandatory);
-decode_disp('AttributeValue',Data) -> 'dec_AttributeValue'(Data,mandatory);
-decode_disp('AttributeValueAssertion',Data) -> 'dec_AttributeValueAssertion'(Data,mandatory);
-decode_disp('AssertionValue',Data) -> 'dec_AssertionValue'(Data,mandatory);
-decode_disp('Attribute',Data) -> 'dec_Attribute'(Data,mandatory);
-decode_disp('MatchingRuleId',Data) -> 'dec_MatchingRuleId'(Data,mandatory);
-decode_disp('LDAPResult',Data) -> 'dec_LDAPResult'(Data,mandatory);
-decode_disp('Referral',Data) -> 'dec_Referral'(Data,mandatory);
-decode_disp('LDAPURL',Data) -> 'dec_LDAPURL'(Data,mandatory);
-decode_disp('Controls',Data) -> 'dec_Controls'(Data,mandatory);
-decode_disp('Control',Data) -> 'dec_Control'(Data,mandatory);
-decode_disp('BindRequest',Data) -> 'dec_BindRequest'(Data,mandatory);
-decode_disp('AuthenticationChoice',Data) -> 'dec_AuthenticationChoice'(Data,mandatory);
-decode_disp('SaslCredentials',Data) -> 'dec_SaslCredentials'(Data,mandatory);
-decode_disp('BindResponse',Data) -> 'dec_BindResponse'(Data,mandatory);
-decode_disp('UnbindRequest',Data) -> 'dec_UnbindRequest'(Data,mandatory);
-decode_disp('SearchRequest',Data) -> 'dec_SearchRequest'(Data,mandatory);
-decode_disp('Filter',Data) -> 'dec_Filter'(Data,mandatory);
-decode_disp('SubstringFilter',Data) -> 'dec_SubstringFilter'(Data,mandatory);
-decode_disp('MatchingRuleAssertion',Data) -> 'dec_MatchingRuleAssertion'(Data,mandatory);
-decode_disp('SearchResultEntry',Data) -> 'dec_SearchResultEntry'(Data,mandatory);
-decode_disp('PartialAttributeList',Data) -> 'dec_PartialAttributeList'(Data,mandatory);
-decode_disp('SearchResultReference',Data) -> 'dec_SearchResultReference'(Data,mandatory);
-decode_disp('SearchResultDone',Data) -> 'dec_SearchResultDone'(Data,mandatory);
-decode_disp('ModifyRequest',Data) -> 'dec_ModifyRequest'(Data,mandatory);
-decode_disp('AttributeTypeAndValues',Data) -> 'dec_AttributeTypeAndValues'(Data,mandatory);
-decode_disp('ModifyResponse',Data) -> 'dec_ModifyResponse'(Data,mandatory);
-decode_disp('AddRequest',Data) -> 'dec_AddRequest'(Data,mandatory);
-decode_disp('AttributeList',Data) -> 'dec_AttributeList'(Data,mandatory);
-decode_disp('AddResponse',Data) -> 'dec_AddResponse'(Data,mandatory);
-decode_disp('DelRequest',Data) -> 'dec_DelRequest'(Data,mandatory);
-decode_disp('DelResponse',Data) -> 'dec_DelResponse'(Data,mandatory);
-decode_disp('ModifyDNRequest',Data) -> 'dec_ModifyDNRequest'(Data,mandatory);
-decode_disp('ModifyDNResponse',Data) -> 'dec_ModifyDNResponse'(Data,mandatory);
-decode_disp('CompareRequest',Data) -> 'dec_CompareRequest'(Data,mandatory);
-decode_disp('CompareResponse',Data) -> 'dec_CompareResponse'(Data,mandatory);
-decode_disp('AbandonRequest',Data) -> 'dec_AbandonRequest'(Data,mandatory);
-decode_disp('ExtendedRequest',Data) -> 'dec_ExtendedRequest'(Data,mandatory);
-decode_disp('ExtendedResponse',Data) -> 'dec_ExtendedResponse'(Data,mandatory);
-decode_disp(Type,Data) -> exit({error,{asn1,{undefined_type,Type}}}).
-
-
-
-
-
-
-
-%%================================
-%%  LDAPMessage
-%%================================
-'enc_LDAPMessage'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type INTEGER
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,messageID), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type CHOICE
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_LDAPMessage_protocolOp'(?RT_BER:cindex(3,Val,protocolOp), []),
-
-%%-------------------------------------------------
-%% attribute number 3   External ELDAPv3:Controls OPTIONAL
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,controls) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            'enc_Controls'(?RT_BER:cindex(4,Val,controls), [{tag,128,0,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
-LenSoFar = EncLen1 + EncLen2 + EncLen3,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  LDAPMessage_protocolOp
-%%================================
-
-'enc_LDAPMessage_protocolOp'({'LDAPMessage_protocolOp',Val}, TagIn) ->
-   'enc_LDAPMessage_protocolOp'(Val, TagIn);
-
-'enc_LDAPMessage_protocolOp'(Val, TagIn) ->
-      {EncBytes,EncLen} = case element(1,Val) of
-      bindRequest ->
-         'enc_BindRequest'(element(2,Val), []);
-      bindResponse ->
-         'enc_BindResponse'(element(2,Val), []);
-      unbindRequest ->
-         ?RT_BER:encode_null(element(2,Val), [{tag,64,2,'IMPLICIT',32}]);
-      searchRequest ->
-         'enc_SearchRequest'(element(2,Val), []);
-      searchResEntry ->
-         'enc_SearchResultEntry'(element(2,Val), []);
-      searchResDone ->
-         'enc_SearchResultDone'(element(2,Val), []);
-      searchResRef ->
-         'enc_SearchResultReference'(element(2,Val), []);
-      modifyRequest ->
-         'enc_ModifyRequest'(element(2,Val), []);
-      modifyResponse ->
-         'enc_ModifyResponse'(element(2,Val), []);
-      addRequest ->
-         'enc_AddRequest'(element(2,Val), []);
-      addResponse ->
-         'enc_AddResponse'(element(2,Val), []);
-      delRequest ->
-         'enc_DelRequest'(element(2,Val), []);
-      delResponse ->
-         'enc_DelResponse'(element(2,Val), []);
-      modDNRequest ->
-         'enc_ModifyDNRequest'(element(2,Val), []);
-      modDNResponse ->
-         'enc_ModifyDNResponse'(element(2,Val), []);
-      compareRequest ->
-         'enc_CompareRequest'(element(2,Val), []);
-      compareResponse ->
-         'enc_CompareResponse'(element(2,Val), []);
-      abandonRequest ->
-         'enc_AbandonRequest'(element(2,Val), []);
-      extendedReq ->
-         'enc_ExtendedRequest'(element(2,Val), []);
-      extendedResp ->
-         'enc_ExtendedResponse'(element(2,Val), []);
-      Else -> 
-         exit({error,{asn1,{invalid_choice_type,Else}}})
-   end,
-
-?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
-
-
-'dec_LDAPMessage_protocolOp'(Bytes, OptOrMand, TagIn) ->
-   {FormLen,Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
-   case Bytes1 of
-
-%% 'bindRequest'
-      <<1:2,_:1,0:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_BindRequest'(Bytes1, mandatory, []),
-         {{bindRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'bindResponse'
-      <<1:2,_:1,1:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_BindResponse'(Bytes1, mandatory, []),
-         {{bindResponse, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'unbindRequest'
-      <<1:2,_:1,2:5,_/binary>> ->
-         {Dec, Rest, RbCho} = ?RT_BER:decode_null(Bytes1,[{tag,64,2,'IMPLICIT',32}], mandatory),
-         {{unbindRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'searchRequest'
-      <<1:2,_:1,3:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_SearchRequest'(Bytes1, mandatory, []),
-         {{searchRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'searchResEntry'
-      <<1:2,_:1,4:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_SearchResultEntry'(Bytes1, mandatory, []),
-         {{searchResEntry, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'searchResDone'
-      <<1:2,_:1,5:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_SearchResultDone'(Bytes1, mandatory, []),
-         {{searchResDone, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'searchResRef'
-      <<1:2,_:1,19:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_SearchResultReference'(Bytes1, mandatory, []),
-         {{searchResRef, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'modifyRequest'
-      <<1:2,_:1,6:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_ModifyRequest'(Bytes1, mandatory, []),
-         {{modifyRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'modifyResponse'
-      <<1:2,_:1,7:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_ModifyResponse'(Bytes1, mandatory, []),
-         {{modifyResponse, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'addRequest'
-      <<1:2,_:1,8:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AddRequest'(Bytes1, mandatory, []),
-         {{addRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'addResponse'
-      <<1:2,_:1,9:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AddResponse'(Bytes1, mandatory, []),
-         {{addResponse, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'delRequest'
-      <<1:2,_:1,10:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_DelRequest'(Bytes1, mandatory, []),
-         {{delRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'delResponse'
-      <<1:2,_:1,11:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_DelResponse'(Bytes1, mandatory, []),
-         {{delResponse, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'modDNRequest'
-      <<1:2,_:1,12:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_ModifyDNRequest'(Bytes1, mandatory, []),
-         {{modDNRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'modDNResponse'
-      <<1:2,_:1,13:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_ModifyDNResponse'(Bytes1, mandatory, []),
-         {{modDNResponse, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'compareRequest'
-      <<1:2,_:1,14:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_CompareRequest'(Bytes1, mandatory, []),
-         {{compareRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'compareResponse'
-      <<1:2,_:1,15:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_CompareResponse'(Bytes1, mandatory, []),
-         {{compareResponse, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'abandonRequest'
-      <<1:2,_:1,16:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AbandonRequest'(Bytes1, mandatory, []),
-         {{abandonRequest, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'extendedReq'
-      <<1:2,_:1,23:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_ExtendedRequest'(Bytes1, mandatory, []),
-         {{extendedReq, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'extendedResp'
-      <<1:2,_:1,24:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_ExtendedResponse'(Bytes1, mandatory, []),
-         {{extendedResp, Dec}, Rest, RbExp + RbCho};
-
-      Else -> 
-         case OptOrMand of
-            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
-            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
-         end
-   end.
-
-
-'dec_LDAPMessage'(Bytes, OptOrMand) ->
-   'dec_LDAPMessage'(Bytes, OptOrMand, []).
-
-'dec_LDAPMessage'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type INTEGER
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{0,2147483647},[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type CHOICE
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_LDAPMessage_protocolOp'(Bytes3, mandatory, []),
-
-%%-------------------------------------------------
-%% attribute number 3   External ELDAPv3:Controls OPTIONAL
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = case Bytes4 of
-<<2:2,_:1,0:5,_/binary>> ->
-'dec_Controls'(Bytes4, opt_or_default, [{tag,128,0,'IMPLICIT',32}]);
-_ ->
-{ asn1_NOVALUE, Bytes4, 0 }
-end,
-
-{Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
-   {{'LDAPMessage', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.
-
-
-%%================================
-%%  MessageID
-%%================================
-
-'enc_MessageID'({'MessageID',Val}, TagIn) ->
-   'enc_MessageID'(Val, TagIn);
-
-'enc_MessageID'(Val, TagIn) ->
-?RT_BER:encode_integer([], Val, TagIn ++ []).
-
-
-'dec_MessageID'(Bytes, OptOrMand) ->
-   'dec_MessageID'(Bytes, OptOrMand, []).
-
-'dec_MessageID'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_integer(Bytes,{0,2147483647},TagIn++[], OptOrMand).
-
-
-
-%%================================
-%%  LDAPString
-%%================================
-
-'enc_LDAPString'({'LDAPString',Val}, TagIn) ->
-   'enc_LDAPString'(Val, TagIn);
-
-'enc_LDAPString'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_LDAPString'(Bytes, OptOrMand) ->
-   'dec_LDAPString'(Bytes, OptOrMand, []).
-
-'dec_LDAPString'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  LDAPOID
-%%================================
-
-'enc_LDAPOID'({'LDAPOID',Val}, TagIn) ->
-   'enc_LDAPOID'(Val, TagIn);
-
-'enc_LDAPOID'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_LDAPOID'(Bytes, OptOrMand) ->
-   'dec_LDAPOID'(Bytes, OptOrMand, []).
-
-'dec_LDAPOID'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  LDAPDN
-%%================================
-
-'enc_LDAPDN'({'LDAPDN',Val}, TagIn) ->
-   'enc_LDAPDN'(Val, TagIn);
-
-'enc_LDAPDN'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_LDAPDN'(Bytes, OptOrMand) ->
-   'dec_LDAPDN'(Bytes, OptOrMand, []).
-
-'dec_LDAPDN'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  RelativeLDAPDN
-%%================================
-
-'enc_RelativeLDAPDN'({'RelativeLDAPDN',Val}, TagIn) ->
-   'enc_RelativeLDAPDN'(Val, TagIn);
-
-'enc_RelativeLDAPDN'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_RelativeLDAPDN'(Bytes, OptOrMand) ->
-   'dec_RelativeLDAPDN'(Bytes, OptOrMand, []).
-
-'dec_RelativeLDAPDN'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  AttributeType
-%%================================
-
-'enc_AttributeType'({'AttributeType',Val}, TagIn) ->
-   'enc_AttributeType'(Val, TagIn);
-
-'enc_AttributeType'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_AttributeType'(Bytes, OptOrMand) ->
-   'dec_AttributeType'(Bytes, OptOrMand, []).
-
-'dec_AttributeType'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  AttributeDescription
-%%================================
-
-'enc_AttributeDescription'({'AttributeDescription',Val}, TagIn) ->
-   'enc_AttributeDescription'(Val, TagIn);
-
-'enc_AttributeDescription'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_AttributeDescription'(Bytes, OptOrMand) ->
-   'dec_AttributeDescription'(Bytes, OptOrMand, []).
-
-'dec_AttributeDescription'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  AttributeDescriptionList
-%%================================
-
-'enc_AttributeDescriptionList'({'AttributeDescriptionList',Val}, TagIn) ->
-   'enc_AttributeDescriptionList'(Val, TagIn);
-
-'enc_AttributeDescriptionList'(Val, TagIn) ->
-   {EncBytes,EncLen} = 'enc_AttributeDescriptionList_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_AttributeDescriptionList_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_AttributeDescriptionList_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
-   'enc_AttributeDescriptionList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-'dec_AttributeDescriptionList'(Bytes, OptOrMand) ->
-   'dec_AttributeDescriptionList'(Bytes, OptOrMand, []).
-
-'dec_AttributeDescriptionList'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
-?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
-end, [], []).
-
-
-
-
-%%================================
-%%  AttributeValue
-%%================================
-
-'enc_AttributeValue'({'AttributeValue',Val}, TagIn) ->
-   'enc_AttributeValue'(Val, TagIn);
-
-'enc_AttributeValue'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_AttributeValue'(Bytes, OptOrMand) ->
-   'dec_AttributeValue'(Bytes, OptOrMand, []).
-
-'dec_AttributeValue'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  AttributeValueAssertion
-%%================================
-'enc_AttributeValueAssertion'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,attributeDesc), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,assertionValue), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_AttributeValueAssertion'(Bytes, OptOrMand) ->
-   'dec_AttributeValueAssertion'(Bytes, OptOrMand, []).
-
-'dec_AttributeValueAssertion'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'AttributeValueAssertion', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  AssertionValue
-%%================================
-
-'enc_AssertionValue'({'AssertionValue',Val}, TagIn) ->
-   'enc_AssertionValue'(Val, TagIn);
-
-'enc_AssertionValue'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_AssertionValue'(Bytes, OptOrMand) ->
-   'dec_AssertionValue'(Bytes, OptOrMand, []).
-
-'dec_AssertionValue'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  Attribute
-%%================================
-'enc_Attribute'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_Attribute_vals'(?RT_BER:cindex(3,Val,vals), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  Attribute_vals
-%%================================
-
-'enc_Attribute_vals'({'Attribute_vals',Val}, TagIn) ->
-   'enc_Attribute_vals'(Val, TagIn);
-
-'enc_Attribute_vals'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_Attribute_vals_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_Attribute_vals_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_Attribute_vals_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
-   'enc_Attribute_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-'dec_Attribute_vals'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
-?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
-end, [], []).
-
-
-
-
-'dec_Attribute'(Bytes, OptOrMand) ->
-   'dec_Attribute'(Bytes, OptOrMand, []).
-
-'dec_Attribute'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_Attribute_vals'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'Attribute', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  MatchingRuleId
-%%================================
-
-'enc_MatchingRuleId'({'MatchingRuleId',Val}, TagIn) ->
-   'enc_MatchingRuleId'(Val, TagIn);
-
-'enc_MatchingRuleId'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_MatchingRuleId'(Bytes, OptOrMand) ->
-   'dec_MatchingRuleId'(Bytes, OptOrMand, []).
-
-'dec_MatchingRuleId'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  LDAPResult
-%%================================
-'enc_LDAPResult'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,resultCode) of {_,_}->element(2,?RT_BER:cindex(2,Val,resultCode));_->?RT_BER:cindex(2,Val,resultCode) end) of
-success -> ?RT_BER:encode_enumerated(0,[]);
-operationsError -> ?RT_BER:encode_enumerated(1,[]);
-protocolError -> ?RT_BER:encode_enumerated(2,[]);
-timeLimitExceeded -> ?RT_BER:encode_enumerated(3,[]);
-sizeLimitExceeded -> ?RT_BER:encode_enumerated(4,[]);
-compareFalse -> ?RT_BER:encode_enumerated(5,[]);
-compareTrue -> ?RT_BER:encode_enumerated(6,[]);
-authMethodNotSupported -> ?RT_BER:encode_enumerated(7,[]);
-strongAuthRequired -> ?RT_BER:encode_enumerated(8,[]);
-referral -> ?RT_BER:encode_enumerated(10,[]);
-adminLimitExceeded -> ?RT_BER:encode_enumerated(11,[]);
-unavailableCriticalExtension -> ?RT_BER:encode_enumerated(12,[]);
-confidentialityRequired -> ?RT_BER:encode_enumerated(13,[]);
-saslBindInProgress -> ?RT_BER:encode_enumerated(14,[]);
-noSuchAttribute -> ?RT_BER:encode_enumerated(16,[]);
-undefinedAttributeType -> ?RT_BER:encode_enumerated(17,[]);
-inappropriateMatching -> ?RT_BER:encode_enumerated(18,[]);
-constraintViolation -> ?RT_BER:encode_enumerated(19,[]);
-attributeOrValueExists -> ?RT_BER:encode_enumerated(20,[]);
-invalidAttributeSyntax -> ?RT_BER:encode_enumerated(21,[]);
-noSuchObject -> ?RT_BER:encode_enumerated(32,[]);
-aliasProblem -> ?RT_BER:encode_enumerated(33,[]);
-invalidDNSyntax -> ?RT_BER:encode_enumerated(34,[]);
-aliasDereferencingProblem -> ?RT_BER:encode_enumerated(36,[]);
-inappropriateAuthentication -> ?RT_BER:encode_enumerated(48,[]);
-invalidCredentials -> ?RT_BER:encode_enumerated(49,[]);
-insufficientAccessRights -> ?RT_BER:encode_enumerated(50,[]);
-busy -> ?RT_BER:encode_enumerated(51,[]);
-unavailable -> ?RT_BER:encode_enumerated(52,[]);
-unwillingToPerform -> ?RT_BER:encode_enumerated(53,[]);
-loopDetect -> ?RT_BER:encode_enumerated(54,[]);
-namingViolation -> ?RT_BER:encode_enumerated(64,[]);
-objectClassViolation -> ?RT_BER:encode_enumerated(65,[]);
-notAllowedOnNonLeaf -> ?RT_BER:encode_enumerated(66,[]);
-notAllowedOnRDN -> ?RT_BER:encode_enumerated(67,[]);
-entryAlreadyExists -> ?RT_BER:encode_enumerated(68,[]);
-objectClassModsProhibited -> ?RT_BER:encode_enumerated(69,[]);
-affectsMultipleDSAs -> ?RT_BER:encode_enumerated(71,[]);
-other -> ?RT_BER:encode_enumerated(80,[]);
-Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
-end,
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,matchedDN), []),
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,errorMessage), []),
-
-%%-------------------------------------------------
-%% attribute number 4   External ELDAPv3:Referral OPTIONAL
-%%-------------------------------------------------
-   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,referral) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            'enc_Referral'(?RT_BER:cindex(5,Val,referral), [{tag,128,3,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
-LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_LDAPResult'(Bytes, OptOrMand) ->
-   'dec_LDAPResult'(Bytes, OptOrMand, []).
-
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{success,0},{operationsError,1},{protocolError,2},{timeLimitExceeded,3},{sizeLimitExceeded,4},{compareFalse,5},{compareTrue,6},{authMethodNotSupported,7},{strongAuthRequired,8},{referral,10},{adminLimitExceeded,11},{unavailableCriticalExtension,12},{confidentialityRequired,13},{saslBindInProgress,14},{noSuchAttribute,16},{undefinedAttributeType,17},{inappropriateMatching,18},{constraintViolation,19},{attributeOrValueExists,20},{invalidAttributeSyntax,21},{noSuchObject,32},{aliasProblem,33},{invalidDNSyntax,34},{aliasDereferencingProblem,36},{inappropriateAuthentication,48},{invalidCredentials,49},{insufficientAccessRights,50},{busy,51},{unavailable,52},{unwillingToPerform,53},{loopDetect,54},{namingViolation,64},{objectClassViolation,65},{notAllowedOnNonLeaf,66},{notAllowedOnRDN,67},{entryAlreadyExists,68},{objectClassModsProhibited,69},{affectsMultipleDSAs,71},{other,80}],[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 4   External ELDAPv3:Referral OPTIONAL
-%%-------------------------------------------------
-   {Term4,Bytes6,Rb5} = case Bytes5 of
-<<2:2,_:1,3:5,_/binary>> ->
-'dec_Referral'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',32}]);
-_ ->
-{ asn1_NOVALUE, Bytes5, 0 }
-end,
-
-{Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
-   {{'LDAPResult', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.
-
-
-%%================================
-%%  Referral
-%%================================
-
-'enc_Referral'({'Referral',Val}, TagIn) ->
-   'enc_Referral'(Val, TagIn);
-
-'enc_Referral'(Val, TagIn) ->
-   {EncBytes,EncLen} = 'enc_Referral_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_Referral_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_Referral_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_LDAPURL'(H, []),
-   'enc_Referral_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-'dec_Referral'(Bytes, OptOrMand) ->
-   'dec_Referral'(Bytes, OptOrMand, []).
-
-'dec_Referral'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_LDAPURL'/3, [], []).
-
-
-
-
-%%================================
-%%  LDAPURL
-%%================================
-
-'enc_LDAPURL'({'LDAPURL',Val}, TagIn) ->
-   'enc_LDAPURL'(Val, TagIn);
-
-'enc_LDAPURL'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ []).
-
-
-'dec_LDAPURL'(Bytes, OptOrMand) ->
-   'dec_LDAPURL'(Bytes, OptOrMand, []).
-
-'dec_LDAPURL'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[], no_length, OptOrMand).
-
-
-
-%%================================
-%%  Controls
-%%================================
-
-'enc_Controls'({'Controls',Val}, TagIn) ->
-   'enc_Controls'(Val, TagIn);
-
-'enc_Controls'(Val, TagIn) ->
-   {EncBytes,EncLen} = 'enc_Controls_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_Controls_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_Controls_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_Control'(H, []),
-   'enc_Controls_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-'dec_Controls'(Bytes, OptOrMand) ->
-   'dec_Controls'(Bytes, OptOrMand, []).
-
-'dec_Controls'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Control'/3, [], []).
-
-
-
-
-%%================================
-%%  Control
-%%================================
-'enc_Control'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,controlType), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type BOOLEAN DEFAULT = false
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,criticality) of
-         asn1_DEFAULT -> {<<>>,0};
-         false -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_boolean(?RT_BER:cindex(3,Val,criticality), [])
-       end,
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} =  case ?RT_BER:cindex(4,Val,controlValue) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,controlValue), [])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
-LenSoFar = EncLen1 + EncLen2 + EncLen3,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_Control'(Bytes, OptOrMand) ->
-   'dec_Control'(Bytes, OptOrMand, []).
-
-'dec_Control'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type BOOLEAN DEFAULT = false
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = case Bytes3 of
-<<0:2,_:1,1:5,_/binary>> ->
-?RT_BER:decode_boolean(Bytes3,[], mandatory);
-_ ->
-{false,Bytes3, 0 }
-end,
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = case Bytes4 of
-<<0:2,_:1,4:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes4, 0 }
-end,
-
-{Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
-   {{'Control', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.
-
-
-%%================================
-%%  BindRequest
-%%================================
-'enc_BindRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type INTEGER
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], ?RT_BER:cindex(2,Val,version), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,name), []),
-
-%%-------------------------------------------------
-%% attribute number 3   External ELDAPv3:AuthenticationChoice
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = 'enc_AuthenticationChoice'(?RT_BER:cindex(4,Val,authentication), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
-LenSoFar = EncLen1 + EncLen2 + EncLen3,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,0,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_BindRequest'(Bytes, OptOrMand) ->
-   'dec_BindRequest'(Bytes, OptOrMand, []).
-
-'dec_BindRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,0,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type INTEGER
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_integer(Bytes2,{1,127},[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 3   External ELDAPv3:AuthenticationChoice
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = 'dec_AuthenticationChoice'(Bytes4, mandatory, []),
-
-{Bytes6,Rb5} = ?RT_BER:restbytes2(RemBytes, Bytes5,noext),
-   {{'BindRequest', Term1, Term2, Term3}, Bytes6, Rb1+Rb2+Rb3+Rb4+Rb5}.
-
-
-%%================================
-%%  AuthenticationChoice
-%%================================
-
-'enc_AuthenticationChoice'({'AuthenticationChoice',Val}, TagIn) ->
-   'enc_AuthenticationChoice'(Val, TagIn);
-
-'enc_AuthenticationChoice'(Val, TagIn) ->
-   {EncBytes,EncLen} = case element(1,Val) of
-      simple ->
-         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,0,'IMPLICIT',32}]);
-      sasl ->
-         'enc_SaslCredentials'(element(2,Val), [{tag,128,3,'IMPLICIT',32}]);
-      Else -> 
-         exit({error,{asn1,{invalid_choice_type,Else}}})
-   end,
-
-?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
-
-
-
-
-'dec_AuthenticationChoice'(Bytes, OptOrMand) ->
-   'dec_AuthenticationChoice'(Bytes, OptOrMand, []).
-
-'dec_AuthenticationChoice'(Bytes, OptOrMand, TagIn) ->
-   {FormLen,Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
-   case Bytes1 of
-
-%% 'simple'
-      <<2:2,_:1,0:5,_/binary>> ->
-         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory),
-         {{simple, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'sasl'
-      <<2:2,_:1,3:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_SaslCredentials'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',32}]),
-         {{sasl, Dec}, Rest, RbExp + RbCho};
-
-      Else -> 
-         case OptOrMand of
-            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
-            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
-         end
-   end.
-
-
-%%================================
-%%  SaslCredentials
-%%================================
-'enc_SaslCredentials'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,mechanism), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,credentials) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,credentials), [])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_SaslCredentials'(Bytes, OptOrMand) ->
-   'dec_SaslCredentials'(Bytes, OptOrMand, []).
-
-'dec_SaslCredentials'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = case Bytes3 of
-<<0:2,_:1,4:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes3, 0 }
-end,
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'SaslCredentials', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  BindResponse
-%%================================
-'enc_BindResponse'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,resultCode) of {_,_}->element(2,?RT_BER:cindex(2,Val,resultCode));_->?RT_BER:cindex(2,Val,resultCode) end) of
-success -> ?RT_BER:encode_enumerated(0,[]);
-operationsError -> ?RT_BER:encode_enumerated(1,[]);
-protocolError -> ?RT_BER:encode_enumerated(2,[]);
-timeLimitExceeded -> ?RT_BER:encode_enumerated(3,[]);
-sizeLimitExceeded -> ?RT_BER:encode_enumerated(4,[]);
-compareFalse -> ?RT_BER:encode_enumerated(5,[]);
-compareTrue -> ?RT_BER:encode_enumerated(6,[]);
-authMethodNotSupported -> ?RT_BER:encode_enumerated(7,[]);
-strongAuthRequired -> ?RT_BER:encode_enumerated(8,[]);
-referral -> ?RT_BER:encode_enumerated(10,[]);
-adminLimitExceeded -> ?RT_BER:encode_enumerated(11,[]);
-unavailableCriticalExtension -> ?RT_BER:encode_enumerated(12,[]);
-confidentialityRequired -> ?RT_BER:encode_enumerated(13,[]);
-saslBindInProgress -> ?RT_BER:encode_enumerated(14,[]);
-noSuchAttribute -> ?RT_BER:encode_enumerated(16,[]);
-undefinedAttributeType -> ?RT_BER:encode_enumerated(17,[]);
-inappropriateMatching -> ?RT_BER:encode_enumerated(18,[]);
-constraintViolation -> ?RT_BER:encode_enumerated(19,[]);
-attributeOrValueExists -> ?RT_BER:encode_enumerated(20,[]);
-invalidAttributeSyntax -> ?RT_BER:encode_enumerated(21,[]);
-noSuchObject -> ?RT_BER:encode_enumerated(32,[]);
-aliasProblem -> ?RT_BER:encode_enumerated(33,[]);
-invalidDNSyntax -> ?RT_BER:encode_enumerated(34,[]);
-aliasDereferencingProblem -> ?RT_BER:encode_enumerated(36,[]);
-inappropriateAuthentication -> ?RT_BER:encode_enumerated(48,[]);
-invalidCredentials -> ?RT_BER:encode_enumerated(49,[]);
-insufficientAccessRights -> ?RT_BER:encode_enumerated(50,[]);
-busy -> ?RT_BER:encode_enumerated(51,[]);
-unavailable -> ?RT_BER:encode_enumerated(52,[]);
-unwillingToPerform -> ?RT_BER:encode_enumerated(53,[]);
-loopDetect -> ?RT_BER:encode_enumerated(54,[]);
-namingViolation -> ?RT_BER:encode_enumerated(64,[]);
-objectClassViolation -> ?RT_BER:encode_enumerated(65,[]);
-notAllowedOnNonLeaf -> ?RT_BER:encode_enumerated(66,[]);
-notAllowedOnRDN -> ?RT_BER:encode_enumerated(67,[]);
-entryAlreadyExists -> ?RT_BER:encode_enumerated(68,[]);
-objectClassModsProhibited -> ?RT_BER:encode_enumerated(69,[]);
-affectsMultipleDSAs -> ?RT_BER:encode_enumerated(71,[]);
-other -> ?RT_BER:encode_enumerated(80,[]);
-Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
-end,
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,matchedDN), []),
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,errorMessage), []),
-
-%%-------------------------------------------------
-%% attribute number 4   External ELDAPv3:Referral OPTIONAL
-%%-------------------------------------------------
-   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,referral) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            'enc_Referral'(?RT_BER:cindex(5,Val,referral), [{tag,128,3,'IMPLICIT',32}])
-       end,
-
-%%-------------------------------------------------
-%% attribute number 5 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,serverSaslCreds) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(6,Val,serverSaslCreds), [{tag,128,7,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
-LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,1,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_BindResponse'(Bytes, OptOrMand) ->
-   'dec_BindResponse'(Bytes, OptOrMand, []).
-
-'dec_BindResponse'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,1,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{success,0},{operationsError,1},{protocolError,2},{timeLimitExceeded,3},{sizeLimitExceeded,4},{compareFalse,5},{compareTrue,6},{authMethodNotSupported,7},{strongAuthRequired,8},{referral,10},{adminLimitExceeded,11},{unavailableCriticalExtension,12},{confidentialityRequired,13},{saslBindInProgress,14},{noSuchAttribute,16},{undefinedAttributeType,17},{inappropriateMatching,18},{constraintViolation,19},{attributeOrValueExists,20},{invalidAttributeSyntax,21},{noSuchObject,32},{aliasProblem,33},{invalidDNSyntax,34},{aliasDereferencingProblem,36},{inappropriateAuthentication,48},{invalidCredentials,49},{insufficientAccessRights,50},{busy,51},{unavailable,52},{unwillingToPerform,53},{loopDetect,54},{namingViolation,64},{objectClassViolation,65},{notAllowedOnNonLeaf,66},{notAllowedOnRDN,67},{entryAlreadyExists,68},{objectClassModsProhibited,69},{affectsMultipleDSAs,71},{other,80}],[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 4   External ELDAPv3:Referral OPTIONAL
-%%-------------------------------------------------
-   {Term4,Bytes6,Rb5} = case Bytes5 of
-<<2:2,_:1,3:5,_/binary>> ->
-'dec_Referral'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',32}]);
-_ ->
-{ asn1_NOVALUE, Bytes5, 0 }
-end,
-
-%%-------------------------------------------------
-%% attribute number 5 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term5,Bytes7,Rb6} = case Bytes6 of
-<<2:2,_:1,7:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes6,[],[{tag,128,7,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes6, 0 }
-end,
-
-{Bytes8,Rb7} = ?RT_BER:restbytes2(RemBytes, Bytes7,noext),
-   {{'BindResponse', Term1, Term2, Term3, Term4, Term5}, Bytes8, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7}.
-
-
-%%================================
-%%  UnbindRequest
-%%================================
-
-'enc_UnbindRequest'({'UnbindRequest',Val}, TagIn) ->
-   'enc_UnbindRequest'(Val, TagIn);
-
-'enc_UnbindRequest'(Val, TagIn) ->
-?RT_BER:encode_null(Val, TagIn ++ [{tag,64,2,'IMPLICIT',32}]).
-
-
-'dec_UnbindRequest'(Bytes, OptOrMand) ->
-   'dec_UnbindRequest'(Bytes, OptOrMand, []).
-
-'dec_UnbindRequest'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_null(Bytes,TagIn++[{tag,64,2,'IMPLICIT',32}], OptOrMand).
-
-
-
-%%================================
-%%  SearchRequest
-%%================================
-'enc_SearchRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,baseObject), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type ENUMERATED
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = case (case ?RT_BER:cindex(3,Val,scope) of {_,_}->element(2,?RT_BER:cindex(3,Val,scope));_->?RT_BER:cindex(3,Val,scope) end) of
-baseObject -> ?RT_BER:encode_enumerated(0,[]);
-singleLevel -> ?RT_BER:encode_enumerated(1,[]);
-wholeSubtree -> ?RT_BER:encode_enumerated(2,[]);
-Enumval2 -> exit({error,{asn1, {enumerated_not_in_range,Enumval2}}})
-end,
-
-%%-------------------------------------------------
-%% attribute number 3 with type ENUMERATED
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = case (case ?RT_BER:cindex(4,Val,derefAliases) of {_,_}->element(2,?RT_BER:cindex(4,Val,derefAliases));_->?RT_BER:cindex(4,Val,derefAliases) end) of
-neverDerefAliases -> ?RT_BER:encode_enumerated(0,[]);
-derefInSearching -> ?RT_BER:encode_enumerated(1,[]);
-derefFindingBaseObj -> ?RT_BER:encode_enumerated(2,[]);
-derefAlways -> ?RT_BER:encode_enumerated(3,[]);
-Enumval3 -> exit({error,{asn1, {enumerated_not_in_range,Enumval3}}})
-end,
-
-%%-------------------------------------------------
-%% attribute number 4 with type INTEGER
-%%-------------------------------------------------
-   {EncBytes4,EncLen4} = ?RT_BER:encode_integer([], ?RT_BER:cindex(5,Val,sizeLimit), []),
-
-%%-------------------------------------------------
-%% attribute number 5 with type INTEGER
-%%-------------------------------------------------
-   {EncBytes5,EncLen5} = ?RT_BER:encode_integer([], ?RT_BER:cindex(6,Val,timeLimit), []),
-
-%%-------------------------------------------------
-%% attribute number 6 with type BOOLEAN
-%%-------------------------------------------------
-   {EncBytes6,EncLen6} = ?RT_BER:encode_boolean(?RT_BER:cindex(7,Val,typesOnly), []),
-
-%%-------------------------------------------------
-%% attribute number 7   External ELDAPv3:Filter
-%%-------------------------------------------------
-   {EncBytes7,EncLen7} = 'enc_Filter'(?RT_BER:cindex(8,Val,filter), []),
-
-%%-------------------------------------------------
-%% attribute number 8   External ELDAPv3:AttributeDescriptionList
-%%-------------------------------------------------
-   {EncBytes8,EncLen8} = 'enc_AttributeDescriptionList'(?RT_BER:cindex(9,Val,attributes), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8],
-LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,3,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_SearchRequest'(Bytes, OptOrMand) ->
-   'dec_SearchRequest'(Bytes, OptOrMand, []).
-
-'dec_SearchRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,3,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type ENUMERATED
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_enumerated(Bytes3,[],[{baseObject,0},{singleLevel,1},{wholeSubtree,2}],[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 3 with type ENUMERATED
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = ?RT_BER:decode_enumerated(Bytes4,[],[{neverDerefAliases,0},{derefInSearching,1},{derefFindingBaseObj,2},{derefAlways,3}],[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 4 with type INTEGER
-%%-------------------------------------------------
-   {Term4,Bytes6,Rb5} = ?RT_BER:decode_integer(Bytes5,{0,2147483647},[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 5 with type INTEGER
-%%-------------------------------------------------
-   {Term5,Bytes7,Rb6} = ?RT_BER:decode_integer(Bytes6,{0,2147483647},[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 6 with type BOOLEAN
-%%-------------------------------------------------
-   {Term6,Bytes8,Rb7} = ?RT_BER:decode_boolean(Bytes7,[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 7   External ELDAPv3:Filter
-%%-------------------------------------------------
-   {Term7,Bytes9,Rb8} = 'dec_Filter'(Bytes8, mandatory, []),
-
-%%-------------------------------------------------
-%% attribute number 8   External ELDAPv3:AttributeDescriptionList
-%%-------------------------------------------------
-   {Term8,Bytes10,Rb9} = 'dec_AttributeDescriptionList'(Bytes9, mandatory, []),
-
-{Bytes11,Rb10} = ?RT_BER:restbytes2(RemBytes, Bytes10,noext),
-   {{'SearchRequest', Term1, Term2, Term3, Term4, Term5, Term6, Term7, Term8}, Bytes11, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8+Rb9+Rb10}.
-
-
-%%================================
-%%  Filter
-%%================================
-
-'enc_Filter'({'Filter',Val}, TagIn) ->
-   'enc_Filter'(Val, TagIn);
-
-'enc_Filter'(Val, TagIn) ->
-   {EncBytes,EncLen} = case element(1,Val) of
-      'and' ->
-         'enc_Filter_and'(element(2,Val), [{tag,128,0,'IMPLICIT',32}]);
-      'or' ->
-         'enc_Filter_or'(element(2,Val), [{tag,128,1,'IMPLICIT',32}]);
-      'not' ->
-         'enc_Filter'(element(2,Val), [{tag,128,2,'EXPLICIT',32}]);
-      equalityMatch ->
-         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,3,'IMPLICIT',32}]);
-      substrings ->
-         'enc_SubstringFilter'(element(2,Val), [{tag,128,4,'IMPLICIT',32}]);
-      greaterOrEqual ->
-         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,5,'IMPLICIT',32}]);
-      lessOrEqual ->
-         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,6,'IMPLICIT',32}]);
-      present ->
-         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,7,'IMPLICIT',32}]);
-      approxMatch ->
-         'enc_AttributeValueAssertion'(element(2,Val), [{tag,128,8,'IMPLICIT',32}]);
-      extensibleMatch ->
-         'enc_MatchingRuleAssertion'(element(2,Val), [{tag,128,9,'IMPLICIT',32}]);
-      Else -> 
-         exit({error,{asn1,{invalid_choice_type,Else}}})
-   end,
-
-?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
-
-
-
-
-
-%%================================
-%%  Filter_and
-%%================================
-
-'enc_Filter_and'({'Filter_and',Val}, TagIn) ->
-   'enc_Filter_and'(Val, TagIn);
-
-'enc_Filter_and'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_Filter_and_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_Filter_and_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_Filter_and_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_Filter'(H, []),
-   'enc_Filter_and_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-'dec_Filter_and'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Filter'/3, [], []).
-
-
-
-
-
-%%================================
-%%  Filter_or
-%%================================
-
-'enc_Filter_or'({'Filter_or',Val}, TagIn) ->
-   'enc_Filter_or'(Val, TagIn);
-
-'enc_Filter_or'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_Filter_or_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_Filter_or_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_Filter_or_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_Filter'(H, []),
-   'enc_Filter_or_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-'dec_Filter_or'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_Filter'/3, [], []).
-
-
-
-
-'dec_Filter'(Bytes, OptOrMand) ->
-   'dec_Filter'(Bytes, OptOrMand, []).
-
-'dec_Filter'(Bytes, OptOrMand, TagIn) ->
-   {FormLen,Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
-   case Bytes1 of
-
-%% 'and'
-      <<2:2,_:1,0:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_Filter_and'(Bytes1, mandatory, [{tag,128,0,'IMPLICIT',32}]),
-         {{'and', Dec}, Rest, RbExp + RbCho};
-
-
-%% 'or'
-      <<2:2,_:1,1:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_Filter_or'(Bytes1, mandatory, [{tag,128,1,'IMPLICIT',32}]),
-         {{'or', Dec}, Rest, RbExp + RbCho};
-
-
-%% 'not'
-      <<2:2,_:1,2:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_Filter'(Bytes1, mandatory, [{tag,128,2,'EXPLICIT',32}]),
-         {{'not', Dec}, Rest, RbExp + RbCho};
-
-
-%% 'equalityMatch'
-      <<2:2,_:1,3:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,3,'IMPLICIT',32}]),
-         {{equalityMatch, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'substrings'
-      <<2:2,_:1,4:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_SubstringFilter'(Bytes1, mandatory, [{tag,128,4,'IMPLICIT',32}]),
-         {{substrings, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'greaterOrEqual'
-      <<2:2,_:1,5:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,5,'IMPLICIT',32}]),
-         {{greaterOrEqual, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'lessOrEqual'
-      <<2:2,_:1,6:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,6,'IMPLICIT',32}]),
-         {{lessOrEqual, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'present'
-      <<2:2,_:1,7:5,_/binary>> ->
-         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,7,'IMPLICIT',32}], no_length, mandatory),
-         {{present, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'approxMatch'
-      <<2:2,_:1,8:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_AttributeValueAssertion'(Bytes1, mandatory, [{tag,128,8,'IMPLICIT',32}]),
-         {{approxMatch, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'extensibleMatch'
-      <<2:2,_:1,9:5,_/binary>> ->
-         {Dec, Rest, RbCho} = 'dec_MatchingRuleAssertion'(Bytes1, mandatory, [{tag,128,9,'IMPLICIT',32}]),
-         {{extensibleMatch, Dec}, Rest, RbExp + RbCho};
-
-      Else -> 
-         case OptOrMand of
-            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
-            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
-         end
-   end.
-
-
-%%================================
-%%  SubstringFilter
-%%================================
-'enc_SubstringFilter'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SEQUENCE OF
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_SubstringFilter_substrings'(?RT_BER:cindex(3,Val,substrings), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  SubstringFilter_substrings
-%%================================
-
-'enc_SubstringFilter_substrings'({'SubstringFilter_substrings',Val}, TagIn) ->
-   'enc_SubstringFilter_substrings'(Val, TagIn);
-
-'enc_SubstringFilter_substrings'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_SubstringFilter_substrings_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_SubstringFilter_substrings_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_SubstringFilter_substrings_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_SubstringFilter_substrings_SEQOF'(H, []),
-   'enc_SubstringFilter_substrings_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-
-%%================================
-%%  SubstringFilter_substrings_SEQOF
-%%================================
-
-'enc_SubstringFilter_substrings_SEQOF'({'SubstringFilter_substrings_SEQOF',Val}, TagIn) ->
-   'enc_SubstringFilter_substrings_SEQOF'(Val, TagIn);
-
-'enc_SubstringFilter_substrings_SEQOF'(Val, TagIn) ->
-      {EncBytes,EncLen} = case element(1,Val) of
-      initial ->
-         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,0,'IMPLICIT',32}]);
-      any ->
-         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,1,'IMPLICIT',32}]);
-      final ->
-         ?RT_BER:encode_octet_string([], element(2,Val), [{tag,128,2,'IMPLICIT',32}]);
-      Else -> 
-         exit({error,{asn1,{invalid_choice_type,Else}}})
-   end,
-
-?RT_BER:encode_tags(TagIn ++[], EncBytes, EncLen).
-
-
-'dec_SubstringFilter_substrings_SEQOF'(Bytes, OptOrMand, TagIn) ->
-   {FormLen,Bytes1, RbExp} = ?RT_BER:check_tags(TagIn++[], Bytes, OptOrMand),
-   case Bytes1 of
-
-%% 'initial'
-      <<2:2,_:1,0:5,_/binary>> ->
-         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory),
-         {{initial, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'any'
-      <<2:2,_:1,1:5,_/binary>> ->
-         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory),
-         {{any, Dec}, Rest, RbExp + RbCho};
-
-
-%% 'final'
-      <<2:2,_:1,2:5,_/binary>> ->
-         {Dec, Rest, RbCho} = ?RT_BER:decode_octet_string(Bytes1,[],[{tag,128,2,'IMPLICIT',32}], no_length, mandatory),
-         {{final, Dec}, Rest, RbExp + RbCho};
-
-      Else -> 
-         case OptOrMand of
-            mandatory ->exit({error,{asn1,{invalid_choice_tag,Else}}});
-            _ ->exit({error,{asn1,{no_optional_tag,Else}}})
-         end
-   end.
-'dec_SubstringFilter_substrings'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_SubstringFilter_substrings_SEQOF'/3, [], []).
-
-
-
-
-'dec_SubstringFilter'(Bytes, OptOrMand) ->
-   'dec_SubstringFilter'(Bytes, OptOrMand, []).
-
-'dec_SubstringFilter'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SEQUENCE OF
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_SubstringFilter_substrings'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'SubstringFilter', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  MatchingRuleAssertion
-%%================================
-'enc_MatchingRuleAssertion'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} =  case ?RT_BER:cindex(2,Val,matchingRule) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,matchingRule), [{tag,128,1,'IMPLICIT',32}])
-       end,
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,type) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,type), [{tag,128,2,'IMPLICIT',32}])
-       end,
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,matchValue), [{tag,128,3,'IMPLICIT',32}]),
-
-%%-------------------------------------------------
-%% attribute number 4 with type BOOLEAN DEFAULT = false
-%%-------------------------------------------------
-   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,dnAttributes) of
-         asn1_DEFAULT -> {<<>>,0};
-         false -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_boolean(?RT_BER:cindex(5,Val,dnAttributes), [{tag,128,4,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
-LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_MatchingRuleAssertion'(Bytes, OptOrMand) ->
-   'dec_MatchingRuleAssertion'(Bytes, OptOrMand, []).
-
-'dec_MatchingRuleAssertion'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = case Bytes2 of
-<<2:2,_:1,1:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes2,[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes2, 0 }
-end,
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = case Bytes3 of
-<<2:2,_:1,2:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes3,[],[{tag,128,2,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes3, 0 }
-end,
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[{tag,128,3,'IMPLICIT',32}], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 4 with type BOOLEAN DEFAULT = false
-%%-------------------------------------------------
-   {Term4,Bytes6,Rb5} = case Bytes5 of
-<<2:2,_:1,4:5,_/binary>> ->
-?RT_BER:decode_boolean(Bytes5,[{tag,128,4,'IMPLICIT',32}], mandatory);
-_ ->
-{false,Bytes5, 0 }
-end,
-
-{Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
-   {{'MatchingRuleAssertion', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.
-
-
-%%================================
-%%  SearchResultEntry
-%%================================
-'enc_SearchResultEntry'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,objectName), []),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:PartialAttributeList
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_PartialAttributeList'(?RT_BER:cindex(3,Val,attributes), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,4,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_SearchResultEntry'(Bytes, OptOrMand) ->
-   'dec_SearchResultEntry'(Bytes, OptOrMand, []).
-
-'dec_SearchResultEntry'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,4,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:PartialAttributeList
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_PartialAttributeList'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'SearchResultEntry', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  PartialAttributeList
-%%================================
-
-'enc_PartialAttributeList'({'PartialAttributeList',Val}, TagIn) ->
-   'enc_PartialAttributeList'(Val, TagIn);
-
-'enc_PartialAttributeList'(Val, TagIn) ->
-   {EncBytes,EncLen} = 'enc_PartialAttributeList_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_PartialAttributeList_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_PartialAttributeList_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_PartialAttributeList_SEQOF'(H, []),
-   'enc_PartialAttributeList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-
-%%================================
-%%  PartialAttributeList_SEQOF
-%%================================
-'enc_PartialAttributeList_SEQOF'(Val, TagIn) ->
-   
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_PartialAttributeList_SEQOF_vals'(?RT_BER:cindex(3,Val,vals), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  PartialAttributeList_SEQOF_vals
-%%================================
-
-'enc_PartialAttributeList_SEQOF_vals'({'PartialAttributeList_SEQOF_vals',Val}, TagIn) ->
-   'enc_PartialAttributeList_SEQOF_vals'(Val, TagIn);
-
-'enc_PartialAttributeList_SEQOF_vals'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_PartialAttributeList_SEQOF_vals_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_PartialAttributeList_SEQOF_vals_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_PartialAttributeList_SEQOF_vals_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
-   'enc_PartialAttributeList_SEQOF_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-'dec_PartialAttributeList_SEQOF_vals'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
-?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
-end, [], []).
-
-
-'dec_PartialAttributeList_SEQOF'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_PartialAttributeList_SEQOF_vals'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'PartialAttributeList_SEQOF', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-'dec_PartialAttributeList'(Bytes, OptOrMand) ->
-   'dec_PartialAttributeList'(Bytes, OptOrMand, []).
-
-'dec_PartialAttributeList'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_PartialAttributeList_SEQOF'/3, [], []).
-
-
-
-
-%%================================
-%%  SearchResultReference
-%%================================
-
-'enc_SearchResultReference'({'SearchResultReference',Val}, TagIn) ->
-   'enc_SearchResultReference'(Val, TagIn);
-
-'enc_SearchResultReference'(Val, TagIn) ->
-   {EncBytes,EncLen} = 'enc_SearchResultReference_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,64,19,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_SearchResultReference_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_SearchResultReference_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
-   'enc_SearchResultReference_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-'dec_SearchResultReference'(Bytes, OptOrMand) ->
-   'dec_SearchResultReference'(Bytes, OptOrMand, []).
-
-'dec_SearchResultReference'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,19,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
-?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
-end, [], []).
-
-
-
-
-%%================================
-%%  SearchResultDone
-%%================================
-
-'enc_SearchResultDone'({'SearchResultDone',Val}, TagIn) ->
-   'enc_SearchResultDone'(Val, TagIn);
-
-'enc_SearchResultDone'(Val, TagIn) ->
-   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,5,'IMPLICIT',32}]).
-
-
-'dec_SearchResultDone'(Bytes, OptOrMand) ->
-   'dec_SearchResultDone'(Bytes, OptOrMand, []).
-
-'dec_SearchResultDone'(Bytes, OptOrMand, TagIn) ->
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,5,'IMPLICIT',32}]).
-
-
-
-%%================================
-%%  ModifyRequest
-%%================================
-'enc_ModifyRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,object), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SEQUENCE OF
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_ModifyRequest_modification'(?RT_BER:cindex(3,Val,modification), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,6,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  ModifyRequest_modification
-%%================================
-
-'enc_ModifyRequest_modification'({'ModifyRequest_modification',Val}, TagIn) ->
-   'enc_ModifyRequest_modification'(Val, TagIn);
-
-'enc_ModifyRequest_modification'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_ModifyRequest_modification_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_ModifyRequest_modification_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_ModifyRequest_modification_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_ModifyRequest_modification_SEQOF'(H, []),
-   'enc_ModifyRequest_modification_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-
-%%================================
-%%  ModifyRequest_modification_SEQOF
-%%================================
-'enc_ModifyRequest_modification_SEQOF'(Val, TagIn) ->
-   
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,operation) of {_,_}->element(2,?RT_BER:cindex(2,Val,operation));_->?RT_BER:cindex(2,Val,operation) end) of
-add -> ?RT_BER:encode_enumerated(0,[]);
-delete -> ?RT_BER:encode_enumerated(1,[]);
-replace -> ?RT_BER:encode_enumerated(2,[]);
-Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
-end,
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:AttributeTypeAndValues
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_AttributeTypeAndValues'(?RT_BER:cindex(3,Val,modification), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-'dec_ModifyRequest_modification_SEQOF'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{add,0},{delete,1},{replace,2}],[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:AttributeTypeAndValues
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_AttributeTypeAndValues'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'ModifyRequest_modification_SEQOF', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-'dec_ModifyRequest_modification'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_ModifyRequest_modification_SEQOF'/3, [], []).
-
-
-
-
-'dec_ModifyRequest'(Bytes, OptOrMand) ->
-   'dec_ModifyRequest'(Bytes, OptOrMand, []).
-
-'dec_ModifyRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,6,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SEQUENCE OF
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_ModifyRequest_modification'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'ModifyRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  AttributeTypeAndValues
-%%================================
-'enc_AttributeTypeAndValues'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_AttributeTypeAndValues_vals'(?RT_BER:cindex(3,Val,vals), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  AttributeTypeAndValues_vals
-%%================================
-
-'enc_AttributeTypeAndValues_vals'({'AttributeTypeAndValues_vals',Val}, TagIn) ->
-   'enc_AttributeTypeAndValues_vals'(Val, TagIn);
-
-'enc_AttributeTypeAndValues_vals'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_AttributeTypeAndValues_vals_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_AttributeTypeAndValues_vals_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_AttributeTypeAndValues_vals_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
-   'enc_AttributeTypeAndValues_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-'dec_AttributeTypeAndValues_vals'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
-?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
-end, [], []).
-
-
-
-
-'dec_AttributeTypeAndValues'(Bytes, OptOrMand) ->
-   'dec_AttributeTypeAndValues'(Bytes, OptOrMand, []).
-
-'dec_AttributeTypeAndValues'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_AttributeTypeAndValues_vals'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'AttributeTypeAndValues', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  ModifyResponse
-%%================================
-
-'enc_ModifyResponse'({'ModifyResponse',Val}, TagIn) ->
-   'enc_ModifyResponse'(Val, TagIn);
-
-'enc_ModifyResponse'(Val, TagIn) ->
-   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,7,'IMPLICIT',32}]).
-
-
-'dec_ModifyResponse'(Bytes, OptOrMand) ->
-   'dec_ModifyResponse'(Bytes, OptOrMand, []).
-
-'dec_ModifyResponse'(Bytes, OptOrMand, TagIn) ->
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,7,'IMPLICIT',32}]).
-
-
-
-%%================================
-%%  AddRequest
-%%================================
-'enc_AddRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,entry), []),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:AttributeList
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_AttributeList'(?RT_BER:cindex(3,Val,attributes), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,8,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_AddRequest'(Bytes, OptOrMand) ->
-   'dec_AddRequest'(Bytes, OptOrMand, []).
-
-'dec_AddRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,8,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:AttributeList
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_AttributeList'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'AddRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  AttributeList
-%%================================
-
-'enc_AttributeList'({'AttributeList',Val}, TagIn) ->
-   'enc_AttributeList'(Val, TagIn);
-
-'enc_AttributeList'(Val, TagIn) ->
-   {EncBytes,EncLen} = 'enc_AttributeList_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_AttributeList_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_AttributeList_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = 'enc_AttributeList_SEQOF'(H, []),
-   'enc_AttributeList_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-
-
-
-%%================================
-%%  AttributeList_SEQOF
-%%================================
-'enc_AttributeList_SEQOF'(Val, TagIn) ->
-   
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,type), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_AttributeList_SEQOF_vals'(?RT_BER:cindex(3,Val,vals), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-
-%%================================
-%%  AttributeList_SEQOF_vals
-%%================================
-
-'enc_AttributeList_SEQOF_vals'({'AttributeList_SEQOF_vals',Val}, TagIn) ->
-   'enc_AttributeList_SEQOF_vals'(Val, TagIn);
-
-'enc_AttributeList_SEQOF_vals'(Val, TagIn) ->
-      {EncBytes,EncLen} = 'enc_AttributeList_SEQOF_vals_components'(Val,[],0),
-   ?RT_BER:encode_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], EncBytes, EncLen).
-
-'enc_AttributeList_SEQOF_vals_components'([], AccBytes, AccLen) -> 
-   {lists:reverse(AccBytes),AccLen};
-
-'enc_AttributeList_SEQOF_vals_components'([H|T],AccBytes, AccLen) ->
-   {EncBytes,EncLen} = ?RT_BER:encode_octet_string([], H, []),
-   'enc_AttributeList_SEQOF_vals_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
-
-'dec_AttributeList_SEQOF_vals'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,17,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun(FBytes,_,_)->
-?RT_BER:decode_octet_string(FBytes,[],[], no_length, mandatory)
-end, [], []).
-
-
-'dec_AttributeList_SEQOF'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type SET OF
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_AttributeList_SEQOF_vals'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'AttributeList_SEQOF', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-'dec_AttributeList'(Bytes, OptOrMand) ->
-   'dec_AttributeList'(Bytes, OptOrMand, []).
-
-'dec_AttributeList'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-   ?RT_BER:decode_components(Rb1, Len, Bytes1, fun 'dec_AttributeList_SEQOF'/3, [], []).
-
-
-
-
-%%================================
-%%  AddResponse
-%%================================
-
-'enc_AddResponse'({'AddResponse',Val}, TagIn) ->
-   'enc_AddResponse'(Val, TagIn);
-
-'enc_AddResponse'(Val, TagIn) ->
-   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,9,'IMPLICIT',32}]).
-
-
-'dec_AddResponse'(Bytes, OptOrMand) ->
-   'dec_AddResponse'(Bytes, OptOrMand, []).
-
-'dec_AddResponse'(Bytes, OptOrMand, TagIn) ->
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,9,'IMPLICIT',32}]).
-
-
-
-%%================================
-%%  DelRequest
-%%================================
-
-'enc_DelRequest'({'DelRequest',Val}, TagIn) ->
-   'enc_DelRequest'(Val, TagIn);
-
-'enc_DelRequest'(Val, TagIn) ->
-?RT_BER:encode_octet_string([], Val, TagIn ++ [{tag,64,10,'IMPLICIT',32}]).
-
-
-'dec_DelRequest'(Bytes, OptOrMand) ->
-   'dec_DelRequest'(Bytes, OptOrMand, []).
-
-'dec_DelRequest'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_octet_string(Bytes,[],TagIn++[{tag,64,10,'IMPLICIT',32}], no_length, OptOrMand).
-
-
-
-%%================================
-%%  DelResponse
-%%================================
-
-'enc_DelResponse'({'DelResponse',Val}, TagIn) ->
-   'enc_DelResponse'(Val, TagIn);
-
-'enc_DelResponse'(Val, TagIn) ->
-   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,11,'IMPLICIT',32}]).
-
-
-'dec_DelResponse'(Bytes, OptOrMand) ->
-   'dec_DelResponse'(Bytes, OptOrMand, []).
-
-'dec_DelResponse'(Bytes, OptOrMand, TagIn) ->
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,11,'IMPLICIT',32}]).
-
-
-
-%%================================
-%%  ModifyDNRequest
-%%================================
-'enc_ModifyDNRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,entry), []),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,newrdn), []),
-
-%%-------------------------------------------------
-%% attribute number 3 with type BOOLEAN
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = ?RT_BER:encode_boolean(?RT_BER:cindex(4,Val,deleteoldrdn), []),
-
-%%-------------------------------------------------
-%% attribute number 4 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,newSuperior) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(5,Val,newSuperior), [{tag,128,0,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4],
-LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,12,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_ModifyDNRequest'(Bytes, OptOrMand) ->
-   'dec_ModifyDNRequest'(Bytes, OptOrMand, []).
-
-'dec_ModifyDNRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,12,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 3 with type BOOLEAN
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = ?RT_BER:decode_boolean(Bytes4,[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 4 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term4,Bytes6,Rb5} = case Bytes5 of
-<<2:2,_:1,0:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes5,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes5, 0 }
-end,
-
-{Bytes7,Rb6} = ?RT_BER:restbytes2(RemBytes, Bytes6,noext),
-   {{'ModifyDNRequest', Term1, Term2, Term3, Term4}, Bytes7, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6}.
-
-
-%%================================
-%%  ModifyDNResponse
-%%================================
-
-'enc_ModifyDNResponse'({'ModifyDNResponse',Val}, TagIn) ->
-   'enc_ModifyDNResponse'(Val, TagIn);
-
-'enc_ModifyDNResponse'(Val, TagIn) ->
-   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,13,'IMPLICIT',32}]).
-
-
-'dec_ModifyDNResponse'(Bytes, OptOrMand) ->
-   'dec_ModifyDNResponse'(Bytes, OptOrMand, []).
-
-'dec_ModifyDNResponse'(Bytes, OptOrMand, TagIn) ->
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,13,'IMPLICIT',32}]).
-
-
-
-%%================================
-%%  CompareRequest
-%%================================
-'enc_CompareRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,entry), []),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:AttributeValueAssertion
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = 'enc_AttributeValueAssertion'(?RT_BER:cindex(3,Val,ava), []),
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,14,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_CompareRequest'(Bytes, OptOrMand) ->
-   'dec_CompareRequest'(Bytes, OptOrMand, []).
-
-'dec_CompareRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,14,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2   External ELDAPv3:AttributeValueAssertion
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = 'dec_AttributeValueAssertion'(Bytes3, mandatory, []),
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'CompareRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  CompareResponse
-%%================================
-
-'enc_CompareResponse'({'CompareResponse',Val}, TagIn) ->
-   'enc_CompareResponse'(Val, TagIn);
-
-'enc_CompareResponse'(Val, TagIn) ->
-   'enc_LDAPResult'(Val, TagIn ++ [{tag,64,15,'IMPLICIT',32}]).
-
-
-'dec_CompareResponse'(Bytes, OptOrMand) ->
-   'dec_CompareResponse'(Bytes, OptOrMand, []).
-
-'dec_CompareResponse'(Bytes, OptOrMand, TagIn) ->
-'dec_LDAPResult'(Bytes, OptOrMand, TagIn++[{tag,64,15,'IMPLICIT',32}]).
-
-
-
-%%================================
-%%  AbandonRequest
-%%================================
-
-'enc_AbandonRequest'({'AbandonRequest',Val}, TagIn) ->
-   'enc_AbandonRequest'(Val, TagIn);
-
-'enc_AbandonRequest'(Val, TagIn) ->
-?RT_BER:encode_integer([], Val, TagIn ++ [{tag,64,16,'IMPLICIT',32}]).
-
-
-'dec_AbandonRequest'(Bytes, OptOrMand) ->
-   'dec_AbandonRequest'(Bytes, OptOrMand, []).
-
-'dec_AbandonRequest'(Bytes, OptOrMand, TagIn) ->
-?RT_BER:decode_integer(Bytes,{0,2147483647},TagIn++[{tag,64,16,'IMPLICIT',32}], OptOrMand).
-
-
-
-%%================================
-%%  ExtendedRequest
-%%================================
-'enc_ExtendedRequest'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(2,Val,requestName), [{tag,128,0,'IMPLICIT',32}]),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} =  case ?RT_BER:cindex(3,Val,requestValue) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,requestValue), [{tag,128,1,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2],
-LenSoFar = EncLen1 + EncLen2,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,23,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_ExtendedRequest'(Bytes, OptOrMand) ->
-   'dec_ExtendedRequest'(Bytes, OptOrMand, []).
-
-'dec_ExtendedRequest'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,23,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type OCTET STRING
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_octet_string(Bytes2,[],[{tag,128,0,'IMPLICIT',32}], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = case Bytes3 of
-<<2:2,_:1,1:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes3,[],[{tag,128,1,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes3, 0 }
-end,
-
-{Bytes5,Rb4} = ?RT_BER:restbytes2(RemBytes, Bytes4,noext),
-   {{'ExtendedRequest', Term1, Term2}, Bytes5, Rb1+Rb2+Rb3+Rb4}.
-
-
-%%================================
-%%  ExtendedResponse
-%%================================
-'enc_ExtendedResponse'(Val, TagIn) ->
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {EncBytes1,EncLen1} = case (case ?RT_BER:cindex(2,Val,resultCode) of {_,_}->element(2,?RT_BER:cindex(2,Val,resultCode));_->?RT_BER:cindex(2,Val,resultCode) end) of
-success -> ?RT_BER:encode_enumerated(0,[]);
-operationsError -> ?RT_BER:encode_enumerated(1,[]);
-protocolError -> ?RT_BER:encode_enumerated(2,[]);
-timeLimitExceeded -> ?RT_BER:encode_enumerated(3,[]);
-sizeLimitExceeded -> ?RT_BER:encode_enumerated(4,[]);
-compareFalse -> ?RT_BER:encode_enumerated(5,[]);
-compareTrue -> ?RT_BER:encode_enumerated(6,[]);
-authMethodNotSupported -> ?RT_BER:encode_enumerated(7,[]);
-strongAuthRequired -> ?RT_BER:encode_enumerated(8,[]);
-referral -> ?RT_BER:encode_enumerated(10,[]);
-adminLimitExceeded -> ?RT_BER:encode_enumerated(11,[]);
-unavailableCriticalExtension -> ?RT_BER:encode_enumerated(12,[]);
-confidentialityRequired -> ?RT_BER:encode_enumerated(13,[]);
-saslBindInProgress -> ?RT_BER:encode_enumerated(14,[]);
-noSuchAttribute -> ?RT_BER:encode_enumerated(16,[]);
-undefinedAttributeType -> ?RT_BER:encode_enumerated(17,[]);
-inappropriateMatching -> ?RT_BER:encode_enumerated(18,[]);
-constraintViolation -> ?RT_BER:encode_enumerated(19,[]);
-attributeOrValueExists -> ?RT_BER:encode_enumerated(20,[]);
-invalidAttributeSyntax -> ?RT_BER:encode_enumerated(21,[]);
-noSuchObject -> ?RT_BER:encode_enumerated(32,[]);
-aliasProblem -> ?RT_BER:encode_enumerated(33,[]);
-invalidDNSyntax -> ?RT_BER:encode_enumerated(34,[]);
-aliasDereferencingProblem -> ?RT_BER:encode_enumerated(36,[]);
-inappropriateAuthentication -> ?RT_BER:encode_enumerated(48,[]);
-invalidCredentials -> ?RT_BER:encode_enumerated(49,[]);
-insufficientAccessRights -> ?RT_BER:encode_enumerated(50,[]);
-busy -> ?RT_BER:encode_enumerated(51,[]);
-unavailable -> ?RT_BER:encode_enumerated(52,[]);
-unwillingToPerform -> ?RT_BER:encode_enumerated(53,[]);
-loopDetect -> ?RT_BER:encode_enumerated(54,[]);
-namingViolation -> ?RT_BER:encode_enumerated(64,[]);
-objectClassViolation -> ?RT_BER:encode_enumerated(65,[]);
-notAllowedOnNonLeaf -> ?RT_BER:encode_enumerated(66,[]);
-notAllowedOnRDN -> ?RT_BER:encode_enumerated(67,[]);
-entryAlreadyExists -> ?RT_BER:encode_enumerated(68,[]);
-objectClassModsProhibited -> ?RT_BER:encode_enumerated(69,[]);
-affectsMultipleDSAs -> ?RT_BER:encode_enumerated(71,[]);
-other -> ?RT_BER:encode_enumerated(80,[]);
-Enumval1 -> exit({error,{asn1, {enumerated_not_in_range,Enumval1}}})
-end,
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(3,Val,matchedDN), []),
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {EncBytes3,EncLen3} = ?RT_BER:encode_octet_string([], ?RT_BER:cindex(4,Val,errorMessage), []),
-
-%%-------------------------------------------------
-%% attribute number 4   External ELDAPv3:Referral OPTIONAL
-%%-------------------------------------------------
-   {EncBytes4,EncLen4} =  case ?RT_BER:cindex(5,Val,referral) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            'enc_Referral'(?RT_BER:cindex(5,Val,referral), [{tag,128,3,'IMPLICIT',32}])
-       end,
-
-%%-------------------------------------------------
-%% attribute number 5 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes5,EncLen5} =  case ?RT_BER:cindex(6,Val,responseName) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(6,Val,responseName), [{tag,128,10,'IMPLICIT',32}])
-       end,
-
-%%-------------------------------------------------
-%% attribute number 6 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {EncBytes6,EncLen6} =  case ?RT_BER:cindex(7,Val,response) of
-         asn1_NOVALUE -> {<<>>,0};
-         _ ->
-            ?RT_BER:encode_octet_string([], ?RT_BER:cindex(7,Val,response), [{tag,128,11,'IMPLICIT',32}])
-       end,
-
-   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],
-LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,
-{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ [{tag,64,24,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], BytesSoFar, LenSoFar).
-
-
-'dec_ExtendedResponse'(Bytes, OptOrMand) ->
-   'dec_ExtendedResponse'(Bytes, OptOrMand, []).
-
-'dec_ExtendedResponse'(Bytes, OptOrMand, TagIn) ->
-   %%-------------------------------------------------
-   %% decode tag and length 
-   %%-------------------------------------------------
-   {{_,Len},Bytes1,Rb1} = ?RT_BER:check_tags(TagIn ++ [{tag,64,24,'IMPLICIT',32},{tag,0,16,'IMPLICIT',32}], Bytes, OptOrMand), 
-{Bytes2,RemBytes} = ?RT_BER:split_list(Bytes1,Len),
-
-%%-------------------------------------------------
-%% attribute number 1 with type ENUMERATED
-%%-------------------------------------------------
-   {Term1,Bytes3,Rb2} = ?RT_BER:decode_enumerated(Bytes2,[],[{success,0},{operationsError,1},{protocolError,2},{timeLimitExceeded,3},{sizeLimitExceeded,4},{compareFalse,5},{compareTrue,6},{authMethodNotSupported,7},{strongAuthRequired,8},{referral,10},{adminLimitExceeded,11},{unavailableCriticalExtension,12},{confidentialityRequired,13},{saslBindInProgress,14},{noSuchAttribute,16},{undefinedAttributeType,17},{inappropriateMatching,18},{constraintViolation,19},{attributeOrValueExists,20},{invalidAttributeSyntax,21},{noSuchObject,32},{aliasProblem,33},{invalidDNSyntax,34},{aliasDereferencingProblem,36},{inappropriateAuthentication,48},{invalidCredentials,49},{insufficientAccessRights,50},{busy,51},{unavailable,52},{unwillingToPerform,53},{loopDetect,54},{namingViolation,64},{objectClassViolation,65},{notAllowedOnNonLeaf,66},{notAllowedOnRDN,67},{entryAlreadyExists,68},{objectClassModsProhibited,69},{affectsMultipleDSAs,71},{other,80}],[], mandatory),
-
-%%-------------------------------------------------
-%% attribute number 2 with type OCTET STRING
-%%-------------------------------------------------
-   {Term2,Bytes4,Rb3} = ?RT_BER:decode_octet_string(Bytes3,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 3 with type OCTET STRING
-%%-------------------------------------------------
-   {Term3,Bytes5,Rb4} = ?RT_BER:decode_octet_string(Bytes4,[],[], no_length, mandatory),
-
-%%-------------------------------------------------
-%% attribute number 4   External ELDAPv3:Referral OPTIONAL
-%%-------------------------------------------------
-   {Term4,Bytes6,Rb5} = case Bytes5 of
-<<2:2,_:1,3:5,_/binary>> ->
-'dec_Referral'(Bytes5, opt_or_default, [{tag,128,3,'IMPLICIT',32}]);
-_ ->
-{ asn1_NOVALUE, Bytes5, 0 }
-end,
-
-%%-------------------------------------------------
-%% attribute number 5 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term5,Bytes7,Rb6} = case Bytes6 of
-<<2:2,_:1,10:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes6,[],[{tag,128,10,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes6, 0 }
-end,
-
-%%-------------------------------------------------
-%% attribute number 6 with type OCTET STRING OPTIONAL
-%%-------------------------------------------------
-   {Term6,Bytes8,Rb7} = case Bytes7 of
-<<2:2,_:1,11:5,_/binary>> ->
-?RT_BER:decode_octet_string(Bytes7,[],[{tag,128,11,'IMPLICIT',32}], no_length, mandatory);
-_ ->
-{ asn1_NOVALUE, Bytes7, 0 }
-end,
-
-{Bytes9,Rb8} = ?RT_BER:restbytes2(RemBytes, Bytes8,noext),
-   {{'ExtendedResponse', Term1, Term2, Term3, Term4, Term5, Term6}, Bytes9, Rb1+Rb2+Rb3+Rb4+Rb5+Rb6+Rb7+Rb8}.
-'maxInt'() ->
-2147483647.
-
diff --git a/src/eldap/ELDAPv3.hrl b/src/eldap/ELDAPv3.hrl
deleted file mode 100644 (file)
index e87bdda..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-%% Generated by the Erlang ASN.1 compiler version:1.3.2
-%% Purpose: Erlang record definitions for each named and unnamed
-%% SEQUENCE and SET, and macro definitions for each value
-%% definition,in module ELDAPv3
-
-
-
--record('LDAPMessage',{
-messageID, protocolOp, controls = asn1_NOVALUE}).
-
--record('AttributeValueAssertion',{
-attributeDesc, assertionValue}).
-
--record('Attribute',{
-type, vals}).
-
--record('LDAPResult',{
-resultCode, matchedDN, errorMessage, referral = asn1_NOVALUE}).
-
--record('Control',{
-controlType, criticality = asn1_DEFAULT, controlValue = asn1_NOVALUE}).
-
--record('BindRequest',{
-version, name, authentication}).
-
--record('SaslCredentials',{
-mechanism, credentials = asn1_NOVALUE}).
-
--record('BindResponse',{
-resultCode, matchedDN, errorMessage, referral = asn1_NOVALUE, serverSaslCreds = asn1_NOVALUE}).
-
--record('SearchRequest',{
-baseObject, scope, derefAliases, sizeLimit, timeLimit, typesOnly, filter, attributes}).
-
--record('SubstringFilter',{
-type, substrings}).
-
--record('MatchingRuleAssertion',{
-matchingRule = asn1_NOVALUE, type = asn1_NOVALUE, matchValue, dnAttributes = asn1_DEFAULT}).
-
--record('SearchResultEntry',{
-objectName, attributes}).
-
--record('PartialAttributeList_SEQOF',{
-type, vals}).
-
--record('ModifyRequest',{
-object, modification}).
-
--record('ModifyRequest_modification_SEQOF',{
-operation, modification}).
-
--record('AttributeTypeAndValues',{
-type, vals}).
-
--record('AddRequest',{
-entry, attributes}).
-
--record('AttributeList_SEQOF',{
-type, vals}).
-
--record('ModifyDNRequest',{
-entry, newrdn, deleteoldrdn, newSuperior = asn1_NOVALUE}).
-
--record('CompareRequest',{
-entry, ava}).
-
--record('ExtendedRequest',{
-requestName, requestValue = asn1_NOVALUE}).
-
--record('ExtendedResponse',{
-resultCode, matchedDN, errorMessage, referral = asn1_NOVALUE, responseName = asn1_NOVALUE, response = asn1_NOVALUE}).
-
--define('maxInt', 2147483647).
index 0a90faf3c1661376d41010589e0fce4b2492f04e..228f4960800c1f584171162a9a39e516f1b46bab 100644 (file)
@@ -808,8 +808,8 @@ filter_presence({xmlelement, "presence", Attrs, Els}) ->
                     case El of
                         {xmlcdata, _} ->
                             false;
-                        {xmlelement, Name1, _Attrs1, _Els1} ->
-                            XMLNS = xml:get_attr_s("xmlns", Attrs),
+                        {xmlelement, Name1, Attrs1, _Els1} ->
+                            XMLNS = xml:get_attr_s("xmlns", Attrs1),
                             case {Name1, XMLNS} of
                                 {"show", ""} ->
                                     true;
diff --git a/src/web/ejabberd_http1.erl b/src/web/ejabberd_http1.erl
deleted file mode 100644 (file)
index 24e1ad7..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-%%%----------------------------------------------------------------------
-%%% File    : ejabberd_http.erl
-%%% Author  : Alexey Shchepin <alexey@sevcom.net>
-%%% Purpose : 
-%%% Created : 27 Feb 2004 by Alexey Shchepin <alexey@sevcom.net>
-%%% Id      : $Id$
-%%%----------------------------------------------------------------------
-
--module(ejabberd_http).
--author('alexey@sevcom.net').
--vsn('$Revision$ ').
-
--behaviour(gen_fsm).
-
-%% External exports
--export([start/2,
-        start_link/2]).
-
-%% gen_fsm callbacks
--export([init/1,
-        wait_for_headers/2,
-        handle_event/3,
-        handle_sync_event/4,
-        code_change/4,
-        handle_info/3,
-        terminate/3]).
-
--include("ejabberd.hrl").
--include("jlib.hrl").
-
--define(DICT, dict).
-
--record(state, {socket,
-               request_method,
-               request_path,
-               request_auth
-              }).
-
-
--define(DBGFSM, true).
-
--ifdef(DBGFSM).
--define(FSMOPTS, [{debug, [trace]}]).
--else.
--define(FSMOPTS, []).
--endif.
-
--define(XHTML_DOCTYPE,
-       "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
-       "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n").
-
-
-%%%----------------------------------------------------------------------
-%%% API
-%%%----------------------------------------------------------------------
-start(SockData, Opts) ->
-    supervisor:start_child(ejabberd_http_sup, [SockData, Opts]).
-
-start_link(SockData, Opts) ->
-    gen_fsm:start_link(ejabberd_http, [SockData, Opts], ?FSMOPTS).
-
-%%%----------------------------------------------------------------------
-%%% Callback functions from gen_fsm
-%%%----------------------------------------------------------------------
-
-%%----------------------------------------------------------------------
-%% Func: init/1
-%% Returns: {ok, StateName, StateData}          |
-%%          {ok, StateName, StateData, Timeout} |
-%%          ignore                              |
-%%          {stop, StopReason}                   
-%%----------------------------------------------------------------------
-init([{SockMod, Socket}, Opts]) ->
-    ?INFO_MSG("started: ~p", [{SockMod, Socket}]),
-    case SockMod of
-       gen_tcp ->
-           inet:setopts(Socket, [{packet, http}, {active, true}, {recbuf, 0}]);
-       ssl ->
-           ssl:setopts(Socket, [{packet, http}, {active, true}])
-    end,
-    {ok, wait_for_headers, #state{socket = Socket}}.
-
-%%----------------------------------------------------------------------
-%% Func: StateName/2
-%% Returns: {next_state, NextStateName, NextStateData}          |
-%%          {next_state, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                         
-%%----------------------------------------------------------------------
-
-wait_for_headers(_, StateData) ->
-    {next_state, wait_for_headers, StateData}.
-
-
-%%----------------------------------------------------------------------
-%% Func: StateName/3
-%% Returns: {next_state, NextStateName, NextStateData}            |
-%%          {next_state, NextStateName, NextStateData, Timeout}   |
-%%          {reply, Reply, NextStateName, NextStateData}          |
-%%          {reply, Reply, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                          |
-%%          {stop, Reason, Reply, NewStateData}                    
-%%----------------------------------------------------------------------
-%state_name(Event, From, StateData) ->
-%    Reply = ok,
-%    {reply, Reply, state_name, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: handle_event/3
-%% Returns: {next_state, NextStateName, NextStateData}          |
-%%          {next_state, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                         
-%%----------------------------------------------------------------------
-handle_event(_Event, StateName, StateData) ->
-    {next_state, StateName, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: handle_sync_event/4
-%% Returns: {next_state, NextStateName, NextStateData}            |
-%%          {next_state, NextStateName, NextStateData, Timeout}   |
-%%          {reply, Reply, NextStateName, NextStateData}          |
-%%          {reply, Reply, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                          |
-%%          {stop, Reason, Reply, NewStateData}                    
-%%----------------------------------------------------------------------
-handle_sync_event(_Event, _From, StateName, StateData) ->
-    Reply = ok,
-    {reply, Reply, StateName, StateData}.
-
-code_change(_OldVsn, StateName, StateData, _Extra) ->
-    {ok, StateName, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: handle_info/3
-%% Returns: {next_state, NextStateName, NextStateData}          |
-%%          {next_state, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                         
-%%----------------------------------------------------------------------
-handle_info({http_request, _Socket, Method, Path, _Version},
-           StateName, StateData) ->
-    {next_state, StateName, StateData#state{request_method = Method,
-                                           request_path = Path}};
-handle_info({http_header, _Socket, _, 'Authorization', _, Auth},
-           StateName, StateData) ->
-    {next_state, StateName,
-     StateData#state{request_auth = parse_auth(Auth)}};
-handle_info({http_eoh, _Socket}, StateName, StateData) ->
-    process_request(StateData),
-    {stop, normal, StateData};
-
-handle_info({tcp_closed, _Socket}, StateName, StateData) ->
-    {stop, normal, StateData};
-
-handle_info({tcp_error, _Socket, _Reason}, StateName, StateData) ->
-    {stop, normal, StateData};
-
-handle_info(_, StateName, StateData) ->
-    {next_state, StateName, StateData}.
-
-
-%%----------------------------------------------------------------------
-%% Func: terminate/3
-%% Purpose: Shutdown the fsm
-%% Returns: any
-%%----------------------------------------------------------------------
-terminate(Reason, _StateName, StateData) ->
-    ?INFO_MSG("terminated: ~p", [Reason]),
-    gen_tcp:close(StateData#state.socket),
-    ok.
-
-%%%----------------------------------------------------------------------
-%%% Internal functions
-%%%----------------------------------------------------------------------
-
-send_text(State, Text) ->
-    gen_tcp:send(State#state.socket, Text).
-
-
-process_request(#state{request_method = 'GET',
-                      request_path = {abs_path, Path},
-                      request_auth = undefined} = State) ->
-    Out = make_xhtml_output(
-           401,
-           [{"WWW-Authenticate", "basic realm=\"ejabberd\""}],
-           make_xhtml([{xmlelement, "h1", [],
-                        [{xmlcdata, "403 Unauthorized"}]}])),
-    send_text(State, Out),
-    ok;
-
-process_request(#state{request_method = 'GET',
-                      request_path = {abs_path, Path},
-                      request_auth = {User, Pass}} = State) ->
-    Out = make_xhtml_output(
-           200,
-           [],
-           make_xhtml([{xmlelement, "h1", [],
-                        [{xmlcdata, "Welcome " ++ User}]}])),
-    send_text(State, Out),
-    ok;
-
-process_request(State) ->
-    todo.
-
-
-
-make_xhtml(Els) ->
-    {xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"},
-                         {"xml:lang", "en"},
-                         {"lang", "en"}],
-     [{xmlelement, "head", [],
-       [{xmlelement, "meta", [{"http-equiv", "Content-Type"},
-                             {"content", "text/html; charset=utf-8"}], []}]},
-      {xmlelement, "body", [], Els}
-     ]}.
-
-
-make_xhtml_output(Status, Headers, XHTML) ->
-    Data = list_to_binary([?XHTML_DOCTYPE, xml:element_to_string(XHTML)]),
-    Headers1 = [{"Content-Type", "text/html; charset=utf-8"},
-               {"Content-Length", integer_to_list(size(Data))} | Headers],
-    H = lists:map(fun({Attr, Val}) ->
-                         [Attr, ": ", Val, "\r\n"]
-                 end, Headers1),
-    SL = ["HTTP/1.1 ", integer_to_list(Status), " ",
-         code_to_phrase(Status), "\r\n"],
-    [SL, H, "\r\n", Data].
-    
-
-
-% Code below is taken (with some modifications) from the yaws webserver, which
-% is distributed under the folowing license:
-%
-%This software (the yaws webserver) is free software.
-%Parts of this software is Copyright (c) Claes Wikstrom <klacke@hyber.org>
-%Any use or misuse of the source code is hereby freely allowed.
-%
-%1. Redistributions of source code must retain the above copyright
-%   notice as well as this list of conditions.
-%
-%2. Redistributions in binary form must reproduce the above copyright
-%   notice as well as this list of conditions.
-
-
-%% url decode the path and return {Path, QueryPart}
-
-url_decode_q_split(Path) ->
-    url_decode_q_split(Path, []).
-
-url_decode_q_split([$%, $C, $2, $%, Hi, Lo | Tail], Ack) ->
-    Hex = hex_to_integer([Hi, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
-url_decode_q_split([$%, $C, $3, $%, Hi, Lo | Tail], Ack) when Hi > $9 ->
-    Hex = hex_to_integer([Hi+4, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
-url_decode_q_split([$%, $C, $3, $%, Hi, Lo | Tail], Ack) when Hi < $A ->
-    Hex = hex_to_integer([Hi+4+7, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
-url_decode_q_split([$%, Hi, Lo | Tail], Ack) ->
-    Hex = hex_to_integer([Hi, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
-url_decode_q_split([$?|T], Ack) ->
-    %% Don't decode the query string here, that is parsed separately.
-    {path_norm_reverse(Ack), T};
-url_decode_q_split([H|T], Ack) ->
-    url_decode_q_split(T, [H|Ack]);
-url_decode_q_split([], Ack) ->
-    {path_norm_reverse(Ack), []}.
-
-path_norm_reverse("/" ++ T) -> start_dir(0, "/", T);
-path_norm_reverse(       T) -> start_dir(0,  "", T).
-
-start_dir(N, Path, ".."       ) -> rest_dir(N, Path, "");
-start_dir(N, Path, "/"   ++ T ) -> start_dir(N    , Path, T);
-start_dir(N, Path, "./"  ++ T ) -> start_dir(N    , Path, T);
-start_dir(N, Path, "../" ++ T ) -> start_dir(N + 1, Path, T);
-start_dir(N, Path,          T ) -> rest_dir (N    , Path, T).
-
-rest_dir (_N, Path, []         ) -> case Path of 
-                                      [] -> "/";
-                                      _  -> Path
-                                  end;
-rest_dir (0, Path, [ $/ | T ] ) -> start_dir(0    , [ $/ | Path ], T);
-rest_dir (N, Path, [ $/ | T ] ) -> start_dir(N - 1,        Path  , T);
-rest_dir (0, Path, [  H | T ] ) -> rest_dir (0    , [  H | Path ], T);
-rest_dir (N, Path, [ _H | T ] ) -> rest_dir (N    ,        Path  , T).
-
-
-%% hex_to_integer
-
-
-hex_to_integer(Hex) ->
-    case catch erlang:list_to_integer(Hex, 16) of
-       {'EXIT', _} ->
-           old_hex_to_integer(Hex);
-       X ->
-           X
-    end.
-
-
-old_hex_to_integer(Hex) ->
-    DEHEX = fun (H) when H >= $a, H =< $f -> H - $a + 10;
-               (H) when H >= $A, H =< $F -> H - $A + 10;
-               (H) when H >= $0, H =< $9 -> H - $0
-           end,
-    lists:foldl(fun(E, Acc) -> Acc*16+DEHEX(E) end, 0, Hex).
-
-code_to_phrase(100) -> "Continue";
-code_to_phrase(101) -> "Switching Protocols ";
-code_to_phrase(200) -> "OK";
-code_to_phrase(201) -> "Created";
-code_to_phrase(202) -> "Accepted";
-code_to_phrase(203) -> "Non-Authoritative Information";
-code_to_phrase(204) -> "No Content";
-code_to_phrase(205) -> "Reset Content";
-code_to_phrase(206) -> "Partial Content";
-code_to_phrase(300) -> "Multiple Choices";
-code_to_phrase(301) -> "Moved Permanently";
-code_to_phrase(302) -> "Found";
-code_to_phrase(303) -> "See Other";
-code_to_phrase(304) -> "Not Modified";
-code_to_phrase(305) -> "Use Proxy";
-code_to_phrase(306) -> "(Unused)";
-code_to_phrase(307) -> "Temporary Redirect";
-code_to_phrase(400) -> "Bad Request";
-code_to_phrase(401) -> "Unauthorized";
-code_to_phrase(402) -> "Payment Required";
-code_to_phrase(403) -> "Forbidden";
-code_to_phrase(404) -> "Not Found";
-code_to_phrase(405) -> "Method Not Allowed";
-code_to_phrase(406) -> "Not Acceptable";
-code_to_phrase(407) -> "Proxy Authentication Required";
-code_to_phrase(408) -> "Request Timeout";
-code_to_phrase(409) -> "Conflict";
-code_to_phrase(410) -> "Gone";
-code_to_phrase(411) -> "Length Required";
-code_to_phrase(412) -> "Precondition Failed";
-code_to_phrase(413) -> "Request Entity Too Large";
-code_to_phrase(414) -> "Request-URI Too Long";
-code_to_phrase(415) -> "Unsupported Media Type";
-code_to_phrase(416) -> "Requested Range Not Satisfiable";
-code_to_phrase(417) -> "Expectation Failed";
-code_to_phrase(500) -> "Internal Server Error";
-code_to_phrase(501) -> "Not Implemented";
-code_to_phrase(502) -> "Bad Gateway";
-code_to_phrase(503) -> "Service Unavailable";
-code_to_phrase(504) -> "Gateway Timeout";
-code_to_phrase(505) -> "HTTP Version Not Supported".
-
-
-parse_auth(Orig = "Basic " ++ Auth64) ->
-    case decode_base64(Auth64) of
-       {error, _Err} ->
-           undefined;
-       Auth ->
-           case string:tokens(Auth, ":") of
-               [User, Pass] ->
-                   {User, Pass};
-               _ ->
-                   undefined
-           end
-    end;
-parse_auth(_) ->
-    undefined.
-
-
-
-decode_base64([]) ->
-  [];
-decode_base64([Sextet1,Sextet2,$=,$=|Rest]) ->
-  Bits2x6=
-    (d(Sextet1) bsl 18) bor
-    (d(Sextet2) bsl 12),
-  Octet1=Bits2x6 bsr 16,
-  [Octet1|decode_base64(Rest)];
-decode_base64([Sextet1,Sextet2,Sextet3,$=|Rest]) ->
-  Bits3x6=
-    (d(Sextet1) bsl 18) bor
-    (d(Sextet2) bsl 12) bor
-    (d(Sextet3) bsl 6),
-  Octet1=Bits3x6 bsr 16,
-  Octet2=(Bits3x6 bsr 8) band 16#ff,
-  [Octet1,Octet2|decode_base64(Rest)];
-decode_base64([Sextet1,Sextet2,Sextet3,Sextet4|Rest]) ->
-  Bits4x6=
-    (d(Sextet1) bsl 18) bor
-    (d(Sextet2) bsl 12) bor
-    (d(Sextet3) bsl 6) bor
-    d(Sextet4),
-  Octet1=Bits4x6 bsr 16,
-  Octet2=(Bits4x6 bsr 8) band 16#ff,
-  Octet3=Bits4x6 band 16#ff,
-  [Octet1,Octet2,Octet3|decode_base64(Rest)];
-decode_base64(_CatchAll) ->
-  {error, bad_base64}.
-
-d(X) when X >= $A, X =<$Z ->
-    X-65;
-d(X) when X >= $a, X =<$z ->
-    X-71;
-d(X) when X >= $0, X =<$9 ->
-    X+4;
-d($+) -> 62;
-d($/) -> 63;
-d(_) -> 63.
-
diff --git a/src/web/ejabberd_wcs.erl b/src/web/ejabberd_wcs.erl
deleted file mode 100644 (file)
index 0859b89..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-%%%----------------------------------------------------------------------
-%%% File    : ejabberd_wcs.erl
-%%% Author  : Alexey Shchepin <alexey@sevcom.net>
-%%% Purpose : Web Client Service
-%%% Created : 13 Jul 2004 by Alexey Shchepin <alexey@sevcom.net>
-%%% Id      : $Id$
-%%%----------------------------------------------------------------------
-
--module(ejabberd_wcs).
--author('alexey@sevcom.net').
--vsn('$Revision$ ').
-
--behaviour(gen_fsm).
-
-%% External exports
--export([start_link/2,
-        init/1,
-        handle_event/3,
-        handle_sync_event/4,
-        code_change/4,
-        handle_info/3,
-        terminate/3,
-        send/2,
-        recv/3,
-        close/1,
-        process_request/1]).
-
--include("ejabberd.hrl").
--include("jlib.hrl").
--include("ejabberd_http.hrl").
-
--record(http_poll, {id, pid}).
-
--record(state, {id,
-               key,
-               output = "",
-               input = "",
-               waiting_input = false,
-               timer}).
-
-%-define(DBGFSM, true).
-
--ifdef(DBGFSM).
--define(FSMOPTS, [{debug, [trace]}]).
--else.
--define(FSMOPTS, []).
--endif.
-
--define(HTTP_POLL_TIMEOUT, 300000).
--define(CT, {"Content-Type", "text/xml; charset=utf-8"}).
--define(BAD_REQUEST, [?CT, {"Set-Cookie", "ID=-3:0; expires=-1"}]).
-
-
-%%%----------------------------------------------------------------------
-%%% API
-%%%----------------------------------------------------------------------
-start(ID, Key) ->
-    mnesia:create_table(http_poll,
-                       [{ram_copies, [node()]},
-                        {attributes, record_info(fields, http_poll)}]),
-    supervisor:start_child(ejabberd_http_poll_sup, [ID, Key]).
-
-start_link(ID, Key) ->
-    gen_fsm:start_link(?MODULE, [ID, Key], ?FSMOPTS).
-
-send({http_poll, FsmRef}, Packet) ->
-    gen_fsm:sync_send_all_state_event(FsmRef, {send, Packet}).
-
-recv({http_poll, FsmRef}, _Length, Timeout) ->
-    gen_fsm:sync_send_all_state_event(FsmRef, recv, Timeout).
-
-close({http_poll, FsmRef}) ->
-    catch gen_fsm:sync_send_all_state_event(FsmRef, close).
-
-
-process_request(#request{path = [],
-                        data = Data} = Request) ->
-    case catch parse_request(Data) of
-       {ok, ID1, Key, NewKey, Packet} ->
-           ID = if
-                    (ID1 == "0") or (ID1 == "mobile") ->
-                        NewID = sha:sha(term_to_binary({now(), make_ref()})),
-                        {ok, Pid} = start(NewID, ""),
-                        mnesia:transaction(
-                          fun() ->
-                                  mnesia:write(#http_poll{id = NewID,
-                                                          pid = Pid})
-                          end),
-                        NewID;
-                    true ->
-                        ID1
-                end,
-           case http_put(ID, Key, NewKey, Packet) of
-               {error, not_exists} ->
-                   {200, ?BAD_REQUEST, ""};
-               {error, bad_key} ->
-                   {200, ?BAD_REQUEST, ""};
-               ok ->
-                   receive
-                   after 100 -> ok
-                   end,
-                   case http_get(ID) of
-                       {error, not_exists} ->
-                           {200, [?BAD_REQUEST], ""};
-                       {ok, OutPacket} ->
-                           if
-                               ID == ID1 ->
-                                   {200, [?CT], OutPacket};
-                               ID1 == "mobile" ->
-                                   {200, [?CT], [ID, $\n, OutPacket]};
-                               true ->
-                                   Cookie = "ID=" ++ ID ++ "; expires=-1",
-                                   {200, [?CT, {"Set-Cookie", Cookie}],
-                                    OutPacket}
-                           end
-                   end
-           end;
-       _ ->
-           {200, [?CT, {"Set-Cookie", "ID=-2:0; expires=-1"}], ""}
-    end.
-
-
-%%%----------------------------------------------------------------------
-%%% Callback functions from gen_fsm
-%%%----------------------------------------------------------------------
-
-%%----------------------------------------------------------------------
-%% Func: init/1
-%% Returns: {ok, StateName, StateData}          |
-%%          {ok, StateName, StateData, Timeout} |
-%%          ignore                              |
-%%          {stop, StopReason}                   
-%%----------------------------------------------------------------------
-init([ID, Key]) ->
-    ?INFO_MSG("started: ~p", [{ID, Key}]),
-    Opts = [], % TODO
-    ejabberd_c2s:start({?MODULE, {http_poll, self()}}, Opts),
-    Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []),
-    {ok, loop, #state{id = ID,
-                     key = Key,
-                     timer = Timer}}.
-
-%%----------------------------------------------------------------------
-%% Func: StateName/2
-%% Returns: {next_state, NextStateName, NextStateData}          |
-%%          {next_state, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                         
-%%----------------------------------------------------------------------
-
-
-%%----------------------------------------------------------------------
-%% Func: StateName/3
-%% Returns: {next_state, NextStateName, NextStateData}            |
-%%          {next_state, NextStateName, NextStateData, Timeout}   |
-%%          {reply, Reply, NextStateName, NextStateData}          |
-%%          {reply, Reply, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                          |
-%%          {stop, Reason, Reply, NewStateData}                    
-%%----------------------------------------------------------------------
-%state_name(Event, From, StateData) ->
-%    Reply = ok,
-%    {reply, Reply, state_name, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: handle_event/3
-%% Returns: {next_state, NextStateName, NextStateData}          |
-%%          {next_state, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                         
-%%----------------------------------------------------------------------
-handle_event(Event, StateName, StateData) ->
-    {next_state, StateName, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: handle_sync_event/4
-%% Returns: {next_state, NextStateName, NextStateData}            |
-%%          {next_state, NextStateName, NextStateData, Timeout}   |
-%%          {reply, Reply, NextStateName, NextStateData}          |
-%%          {reply, Reply, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                          |
-%%          {stop, Reason, Reply, NewStateData}                    
-%%----------------------------------------------------------------------
-handle_sync_event({send, Packet}, From, StateName, StateData) ->
-    Output = [StateData#state.output | Packet],
-    Reply = ok,
-    {reply, Reply, StateName, StateData#state{output = Output}};
-
-handle_sync_event(recv, From, StateName, StateData) ->
-    case StateData#state.input of
-       "" ->
-           {next_state, StateName, StateData#state{waiting_input = From}};
-       Input ->
-           Reply = {ok, list_to_binary(Input)},
-           {reply, Reply, StateName, StateData#state{input = "",
-                                                     waiting_input = false}}
-    end;
-
-handle_sync_event(stop, From, StateName, StateData) ->
-    Reply = ok,
-    {stop, normal, Reply, StateData};
-
-handle_sync_event({http_put, Key, NewKey, Packet},
-                 From, StateName, StateData) ->
-    Allow = case StateData#state.key of
-               "" ->
-                   true;
-               OldKey ->
-                   NextKey = jlib:encode_base64(
-                               binary_to_list(crypto:sha(Key))),
-                   if
-                       OldKey == NextKey ->
-                           true;
-                       true ->
-                           false
-                   end
-           end,
-    if
-       Allow ->
-           case StateData#state.waiting_input of
-               false ->
-                   Input = [StateData#state.input | Packet],
-                   Reply = ok,
-                   {reply, Reply, StateName, StateData#state{input = Input,
-                                                             key = NewKey}};
-               Receiver ->
-                   gen_fsm:reply(Receiver, {ok, list_to_binary(Packet)}),
-                   cancel_timer(StateData#state.timer),
-                   Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []),
-                   Reply = ok,
-                   {reply, Reply, StateName,
-                    StateData#state{waiting_input = false,
-                                    key = NewKey,
-                                    timer = Timer}}
-           end;
-       true ->
-           Reply = {error, bad_key},
-           {reply, Reply, StateName, StateData}
-    end;
-
-handle_sync_event(http_get, From, StateName, StateData) ->
-    Reply = {ok, StateData#state.output},
-    {reply, Reply, StateName, StateData#state{output = ""}};
-
-handle_sync_event(Event, From, StateName, StateData) ->
-    Reply = ok,
-    {reply, Reply, StateName, StateData}.
-
-code_change(OldVsn, StateName, StateData, Extra) ->
-    {ok, StateName, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: handle_info/3
-%% Returns: {next_state, NextStateName, NextStateData}          |
-%%          {next_state, NextStateName, NextStateData, Timeout} |
-%%          {stop, Reason, NewStateData}                         
-%%----------------------------------------------------------------------
-handle_info({timeout, Timer, _}, StateName,
-           #state{timer = Timer} = StateData) ->
-    {stop, normal, StateData};
-
-handle_info(_, StateName, StateData) ->
-    {next_state, StateName, StateData}.
-
-%%----------------------------------------------------------------------
-%% Func: terminate/3
-%% Purpose: Shutdown the fsm
-%% Returns: any
-%%----------------------------------------------------------------------
-terminate(Reason, StateName, StateData) ->
-    mnesia:transaction(
-      fun() ->
-             mnesia:delete({http_poll, StateData#state.id})
-      end),
-    case StateData#state.waiting_input of
-       false ->
-           ok;
-       Receiver ->
-           gen_fsm:reply(Receiver, {error, closed})
-    end,
-    ok.
-
-%%%----------------------------------------------------------------------
-%%% Internal functions
-%%%----------------------------------------------------------------------
-
-
-http_put(ID, Key, NewKey, Packet) ->
-    case mnesia:dirty_read({http_poll, ID}) of
-       [] ->
-           {error, not_exists};
-       [#http_poll{pid = FsmRef}] ->
-           gen_fsm:sync_send_all_state_event(
-             FsmRef, {http_put, Key, NewKey, Packet})
-    end.
-
-http_get(ID) ->
-    case mnesia:dirty_read({http_poll, ID}) of
-       [] ->
-           {error, not_exists};
-       [#http_poll{pid = FsmRef}] ->
-           gen_fsm:sync_send_all_state_event(FsmRef, http_get)
-    end.
-
-
-parse_request(Data) ->
-    Comma = string:chr(Data, $,),
-    Header = lists:sublist(Data, Comma - 1),
-    Packet = lists:nthtail(Comma, Data),
-    {ID, Key, NewKey} =
-       case string:tokens(Header, ";") of
-           [ID1] ->
-               {ID1, "", ""};
-           [ID1, Key1] ->
-               {ID1, Key1, Key1};
-           [ID1, Key1, NewKey1] ->
-               {ID1, Key1, NewKey1}
-       end,
-    {ok, ID, Key, NewKey, Packet}.
-
-
-cancel_timer(Timer) ->
-    erlang:cancel_timer(Timer),
-    receive
-       {timeout, Timer, _} ->
-           ok
-    after 0 ->
-           ok
-    end.
-