aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2012-12-03 10:22:40 +0100
committerFredrik Gustafsson <[email protected]>2012-12-03 10:22:40 +0100
commitc228ceb941e26a04317bd2f66a2ee64687f0f869 (patch)
treefb019fce335b6db5b92ce300ee707496a9fe759b /lib
parentf78daeeccbf6de61b9e5dae4dd70f12fba03a2ff (diff)
parent26dffbeec17226a25c00d4072cb0f5c29ed48cea (diff)
downloadotp-c228ceb941e26a04317bd2f66a2ee64687f0f869.tar.gz
otp-c228ceb941e26a04317bd2f66a2ee64687f0f869.tar.bz2
otp-c228ceb941e26a04317bd2f66a2ee64687f0f869.zip
Merge branch 'fredrik/ssh/fix-idle-tests' into fredrik/ssh/rekeying
* fredrik/ssh/fix-idle-tests: (50 commits) Modifications to idle_time testcase Teach Win installer to handle redist on w2012/w8 ssl: Receive port EXIT-message so that it does not get mixed up with the protocol-error message we are expecting ssl: Add and enhance tests ssl: Consider new server options when resuming a session Prepare release ssl: Add dependencies to Makefile Simplify the code for the generated info/0 function Don't try to work around a non-loadable NIF library Fix BER encoding when multiple levels of typedefs are used Update megaco documentation Update documentation for the asn1 application Fix other applications Fix use of asn1 in megaco Remove the unused asn1ct_gen_ber module Fix erroneous skipping for jinterface, erl_interface and ic kernel: Heart port needs to be unregistered Update preloaded modules Update primary bootstrap Update copyright years ...
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1/doc/src/asn1_ug.xml397
-rw-r--r--lib/asn1/doc/src/asn1ct.xml69
-rw-r--r--lib/asn1/doc/src/asn1rt.xml39
-rw-r--r--lib/asn1/doc/src/notes.xml2
-rw-r--r--lib/asn1/src/Makefile3
-rw-r--r--lib/asn1/src/asn1.app.src1
-rw-r--r--lib/asn1/src/asn1ct.erl107
-rw-r--r--lib/asn1/src/asn1ct_check.erl39
-rw-r--r--lib/asn1/src/asn1ct_constructed_ber.erl1596
-rw-r--r--lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl25
-rw-r--r--lib/asn1/src/asn1ct_constructed_per.erl53
-rw-r--r--lib/asn1/src/asn1ct_gen.erl344
-rw-r--r--lib/asn1/src/asn1ct_gen_ber.erl1749
-rw-r--r--lib/asn1/src/asn1ct_gen_ber_bin_v2.erl49
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl18
-rw-r--r--lib/asn1/src/asn1ct_value.erl21
-rw-r--r--lib/asn1/src/asn1rt_ber_bin.erl1974
-rw-r--r--lib/asn1/src/asn1rt_ber_bin_v2.erl53
-rw-r--r--lib/asn1/src/asn1rt_per_bin.erl2285
-rw-r--r--lib/asn1/src/asn1rt_per_bin_rt2ct.erl26
-rw-r--r--lib/asn1/src/asn1rt_uper_bin.erl14
-rw-r--r--lib/asn1/test/Makefile1
-rw-r--r--lib/asn1/test/asn1_SUITE.erl226
-rw-r--r--lib/asn1/test/asn1_SUITE_data/MultipleLevels.asn19
-rw-r--r--lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config2
-rw-r--r--lib/asn1/test/asn1_SUITE_data/testobj.erl25
-rw-r--r--lib/asn1/test/asn1_test_lib.erl10
-rw-r--r--lib/asn1/test/asn1_wrapper.erl35
-rw-r--r--lib/asn1/test/h323test.erl1
-rw-r--r--lib/asn1/test/testChoiceIndefinite.erl5
-rw-r--r--lib/asn1/test/testCompactBitString.erl4
-rw-r--r--lib/asn1/test/testEnumExt.erl8
-rw-r--r--lib/asn1/test/testINSTANCE_OF.erl17
-rw-r--r--lib/asn1/test/testInfObjectClass.erl15
-rw-r--r--lib/asn1/test/testMergeCompile.erl12
-rw-r--r--lib/asn1/test/testMultipleLevels.erl27
-rw-r--r--lib/asn1/test/testParameterizedInfObj.erl2
-rw-r--r--lib/asn1/test/testSSLspecs.erl14
-rw-r--r--lib/asn1/test/testSeqIndefinite.erl6
-rw-r--r--lib/asn1/test/testSeqOf.erl11
-rw-r--r--lib/asn1/test/testSetIndefinite.erl5
-rw-r--r--lib/asn1/test/testSetOptional.erl2
-rw-r--r--lib/asn1/test/testTCAP.erl4
-rw-r--r--lib/asn1/test/testTimer.erl53
-rw-r--r--lib/asn1/test/testTypeValueNotation.erl31
-rw-r--r--lib/asn1/test/testX420.erl2
-rw-r--r--lib/asn1/test/test_compile_options.erl3
-rw-r--r--lib/asn1/test/test_inline.erl16
-rw-r--r--lib/asn1/test/test_special_decode_performance.erl2
-rw-r--r--lib/common_test/doc/src/notes.xml94
-rw-r--r--lib/common_test/src/ct_groups.erl2
-rw-r--r--lib/common_test/src/ct_slave.erl35
-rw-r--r--lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_1_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_2_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_master_SUITE.erl57
-rw-r--r--lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl9
-rw-r--r--lib/common_test/test/ct_test_support.erl10
-rw-r--r--lib/common_test/vsn.mk2
-rw-r--r--lib/compiler/test/bs_match_SUITE.erl2
-rw-r--r--lib/crypto/c_src/Makefile.in49
-rw-r--r--lib/crypto/c_src/crypto.c244
-rw-r--r--lib/crypto/c_src/crypto_callback.c165
-rw-r--r--lib/crypto/c_src/crypto_callback.h46
-rw-r--r--lib/crypto/doc/src/notes.xml2
-rw-r--r--lib/crypto/src/crypto.erl6
-rw-r--r--lib/dialyzer/doc/src/notes.xml18
-rw-r--r--lib/dialyzer/vsn.mk2
-rw-r--r--lib/diameter/doc/src/diameter.xml34
-rw-r--r--lib/diameter/doc/src/diameter_app.xml39
-rw-r--r--lib/diameter/doc/src/diameter_codec.xml389
-rw-r--r--lib/diameter/doc/src/diameter_compile.xml55
-rw-r--r--lib/diameter/doc/src/diameter_dict.xml85
-rw-r--r--lib/diameter/doc/src/diameter_intro.xml11
-rw-r--r--lib/diameter/doc/src/diameter_make.xml144
-rw-r--r--lib/diameter/doc/src/diameter_sctp.xml27
-rw-r--r--lib/diameter/doc/src/diameter_soc.xml30
-rw-r--r--lib/diameter/doc/src/diameter_tcp.xml46
-rw-r--r--lib/diameter/doc/src/diameter_transport.xml82
-rw-r--r--lib/diameter/doc/src/files.mk2
-rw-r--r--lib/diameter/doc/src/notes.xml161
-rw-r--r--lib/diameter/doc/src/ref_man.xml3
-rw-r--r--lib/diameter/doc/src/seealso.ent28
-rw-r--r--lib/diameter/doc/standard/draft-ietf-dime-capablities-update-07.txt392
-rw-r--r--lib/diameter/doc/standard/rfc6733.txt (renamed from lib/diameter/doc/standard/draft-ietf-dime-rfc3588bis-26.txt)6264
-rw-r--r--lib/diameter/doc/standard/rfc6737.txt339
-rw-r--r--lib/diameter/src/base/diameter_capx.erl2
-rw-r--r--lib/edoc/doc/src/notes.xml2
-rw-r--r--lib/eldap/src/Makefile2
-rw-r--r--lib/erl_docgen/doc/src/notes.xml18
-rw-r--r--lib/erl_interface/configure.in2
-rw-r--r--lib/erl_interface/doc/src/notes.xml18
-rw-r--r--lib/erl_interface/src/connect/ei_resolve.c8
-rw-r--r--lib/erl_interface/vsn.mk2
-rw-r--r--lib/eunit/doc/src/notes.xml2
-rw-r--r--lib/hipe/doc/src/notes.xml16
-rw-r--r--lib/hipe/vsn.mk2
-rw-r--r--lib/ic/test/java_client_erl_server_SUITE.erl11
-rw-r--r--lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src2
-rw-r--r--lib/inets/doc/src/httpd.xml2
-rw-r--r--lib/inets/doc/src/notes.xml22
-rw-r--r--lib/inets/src/http_server/httpd_request_handler.erl2
-rw-r--r--lib/inets/test/erl_make_certs.erl4
-rw-r--r--lib/inets/test/inets_app_test.erl2
-rw-r--r--lib/jinterface/test/jitu.erl2
-rw-r--r--lib/kernel/doc/src/heart.xml2
-rw-r--r--lib/kernel/doc/src/notes.xml38
-rw-r--r--lib/kernel/src/heart.erl4
-rw-r--r--lib/kernel/test/global_SUITE.erl2
-rw-r--r--lib/kernel/test/heart_SUITE.erl2
-rw-r--r--lib/kernel/test/wrap_log_reader_SUITE.erl2
-rw-r--r--lib/megaco/doc/src/megaco_encode.xml23
-rw-r--r--lib/megaco/examples/meas/megaco_codec_meas.erl14
-rw-r--r--lib/megaco/examples/meas/megaco_codec_mstone_lib.erl38
-rw-r--r--lib/megaco/examples/meas/megaco_codec_transform.erl4
-rw-r--r--lib/megaco/src/app/megaco.app.src26
-rw-r--r--lib/megaco/src/binary/Makefile34
-rw-r--r--lib/megaco/src/binary/depend.mk281
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.asn1config43
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.asn1config43
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.asn1config43
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.asn1config43
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.asn1config43
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_encoder.erl716
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.asn1config43
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.asn1config44
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3a.asn1config (renamed from lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.asn1config)4
-rw-r--r--lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3b.asn1config (renamed from lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.asn1config)4
-rw-r--r--lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3c.asn1config (renamed from lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.asn1config)4
-rw-r--r--lib/megaco/src/binary/megaco_ber_media_gateway_control_v1.asn1config (renamed from lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.asn1config)6
-rw-r--r--lib/megaco/src/binary/megaco_ber_media_gateway_control_v3.asn1config (renamed from lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.asn1config)4
-rw-r--r--lib/megaco/src/binary/megaco_binary_encoder.erl285
-rw-r--r--lib/megaco/src/binary/megaco_binary_encoder_lib.erl15
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3a.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3b.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3c.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v1.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v2.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v3.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_encoder.erl447
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3a.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3b.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3c.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v1.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v2.set.asn1
-rw-r--r--lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v3.set.asn1
-rw-r--r--lib/megaco/src/binary/modules.mk50
-rw-r--r--lib/megaco/test/megaco_actions_test.erl36
-rw-r--r--lib/megaco/test/megaco_call_flow_test.erl22
-rw-r--r--lib/megaco/test/megaco_codec_prev3a_test.erl31
-rw-r--r--lib/megaco/test/megaco_codec_prev3b_test.erl30
-rw-r--r--lib/megaco/test/megaco_codec_prev3c_test.erl39
-rw-r--r--lib/megaco/test/megaco_codec_v1_test.erl32
-rw-r--r--lib/megaco/test/megaco_codec_v2_test.erl31
-rw-r--r--lib/megaco/test/megaco_codec_v3_test.erl39
-rw-r--r--lib/megaco/test/megaco_mess_test.erl4
-rw-r--r--lib/megaco/test/megaco_mib_test.erl6
-rw-r--r--lib/megaco/test/megaco_test_mg.erl2
-rw-r--r--lib/megaco/test/megaco_test_mgc.erl2
-rw-r--r--lib/observer/doc/src/notes.xml2
-rw-r--r--lib/odbc/doc/src/notes.xml2
-rw-r--r--lib/orber/src/Makefile3
-rw-r--r--lib/percept/doc/src/notes.xml15
-rw-r--r--lib/percept/src/percept.app.src2
-rw-r--r--lib/percept/vsn.mk2
-rw-r--r--lib/public_key/asn1/Makefile2
-rw-r--r--lib/public_key/doc/src/notes.xml35
-rw-r--r--lib/public_key/include/public_key.hrl2
-rw-r--r--lib/public_key/src/pubkey_cert_records.erl6
-rw-r--r--lib/public_key/test/erl_make_certs.erl4
-rw-r--r--lib/ssh/doc/src/notes.xml44
-rw-r--r--lib/ssh/src/ssh_io.erl2
-rw-r--r--lib/ssh/test/ssh_basic_SUITE.erl4
-rw-r--r--lib/ssl/doc/src/notes.xml34
-rw-r--r--lib/ssl/src/Makefile20
-rw-r--r--lib/ssl/src/ssl_manager.erl2
-rw-r--r--lib/ssl/src/ssl_session.erl18
-rw-r--r--lib/ssl/test/erl_make_certs.erl4
-rw-r--r--lib/ssl/test/ssl_basic_SUITE.erl115
-rw-r--r--lib/ssl/test/ssl_to_openssl_SUITE.erl13
-rw-r--r--lib/stdlib/doc/src/notes.xml15
-rw-r--r--lib/test_server/doc/src/notes.xml41
-rw-r--r--lib/test_server/src/test_server_io.erl6
-rw-r--r--lib/test_server/src/ts.erl52
-rw-r--r--lib/test_server/vsn.mk2
-rw-r--r--lib/tools/src/tools.app.src2
197 files changed, 6045 insertions, 15430 deletions
diff --git a/lib/asn1/doc/src/asn1_ug.xml b/lib/asn1/doc/src/asn1_ug.xml
index 1b399fb641..6cb251c3e2 100644
--- a/lib/asn1/doc/src/asn1_ug.xml
+++ b/lib/asn1/doc/src/asn1_ug.xml
@@ -186,13 +186,21 @@ END </pre>
The following shows how the compiler
can be called from the Erlang shell:</p>
<pre>
-1><input>asn1ct:compile("People",[ber_bin]).</input>
+1><input>asn1ct:compile("People", [ber]).</input>
+ok
+2> </pre>
+
+ <p>The <c>verbose</c> option can be given to have information
+ about the generated files printed:</p>
+ <pre>
+2><input>asn1ct:compile("People", [ber,verbose]).</input>
Erlang ASN.1 compiling "People.asn"
--{generated,"People.asn1db"}--
--{generated,"People.hrl"}--
--{generated,"People.erl"}--
ok
-2> </pre>
+3> </pre>
+
<p>The ASN.1 module People is now accepted and the abstract syntax tree
is saved in the <c>People.asn1db</c> file, the
generated Erlang code is compiled using the Erlang compiler and
@@ -229,7 +237,7 @@ receive
constructed and encoded using
<c>'People':encode('Person',Answer)</c> which takes an
instance of a defined ASN.1 type and transforms it to a
- (possibly) nested list of bytes according to the BER or PER
+ binary according to the BER or PER
encoding-rules.
<br></br>
The encoder and the decoder can also be run from
@@ -239,24 +247,12 @@ The encoder and the decoder can also be run from
<pre>
2> <input>Rockstar = {'Person',"Some Name",roving,50}.</input>
{'Person',"Some Name",roving,50}
-3> <input>{ok,Bytes} = asn1rt:encode('People','Person',Rockstar).</input>
-{ok,[&lt;&lt;243&gt;&gt;,
- [17],
- [19,9,"Some Name"],
- [2,1,[2]],
- [2,1,"2"]]}
-4> <input>Bin = list_to_binary(Bytes).</input>
-&lt;&lt;243,17,19,9,83,111,109,101,32,78,97,109,101,2,1,2,2,1,50&gt;&gt;
-5> <input>{ok,Person} = asn1rt:decode('People','Person',Bin).</input>
+3> <input>{ok,Bin} = asn1rt:encode('People','Person',Rockstar).</input>
+{ok,&lt;&lt;243,17,19,9,83,111,109,101,32,78,97,109,101,2,1,2,
+ 2,1,50&gt;&gt;}
+4> <input>{ok,Person} = asn1rt:decode('People','Person',Bin).</input>
{ok,{'Person',"Some Name",roving,50}}
-6> </pre>
- <p>Notice that the result from <c>encode</c> is a nested list which
- must be turned into a binary before the call to <c>decode</c>. A
- binary is necessary as input to decode since the module was compiled
- with the <c>ber_bin</c> option
- The reason for returning a nested list is that it is faster to produce
- and the <c>list_to_binary</c> operation is
- performed automatically when the list is sent via the Erlang port mechanism.</p>
+5> </pre>
</section>
<section>
@@ -305,17 +301,15 @@ The encoder and the decoder can also be run from
ASN.1 compiler:</p>
<pre>
erlc Person.asn
-erlc -bper_bin Person.asn
-erlc -bber_bin +optimize ../Example.asn
+erlc -bper Person.asn
+erlc -bber ../Example.asn
erlc -o ../asnfiles -I ../asnfiles -I /usr/local/standards/asn1 Person.asn </pre>
<p>The useful options for the ASN.1 compiler are:</p>
<taglist>
- <tag><c>-b[ber | per | ber_bin | per_bin | uper_bin]</c></tag>
+ <tag><c>-b[ber | per | uper]</c></tag>
<item>
<p>Choice of encoding rules, if omitted <c>ber</c> is the
- default. The <c>ber_bin</c> and <c>per_bin</c> options
- allows for optimizations and are therefore recommended
- instead of the <c>ber</c> and <c>per</c> options.</p>
+ default.</p>
</item>
<tag><c>-o OutDirectory</c></tag>
<item>
@@ -339,42 +333,12 @@ erlc -o ../asnfiles -I ../asnfiles -I /usr/local/standards/asn1 Person.asn
</item>
<tag><c>+der</c></tag>
<item>
- <p>DER encoding rule. Only when using <c>-ber</c> or
- <c>-ber_bin</c> option.</p>
- </item>
- <tag><c>+optimize</c></tag>
- <item>
- <p>This flag has effect only when used together with one of
- <c>per_bin</c> or <c>ber_bin</c> flags. It gives time optimized
- code in the generated modules and it uses another runtime module.
- In the <c>per_bin</c> case a nif is used. The
- result from an encode is a binary.</p>
- <p><em>When this flag is used you cannot use the old format</em><c>{TypeName,Value}</c> when you encode values. Since it is
- an unnecessary construct it has been removed in favor of
- performance. It
- is neither admitted to construct SEQUENCE or SET component values
- with the format <c>{ComponentName,Value}</c> since it also is
- unnecessary. The only case were it is necessary is in a CHOICE,
- were you have to pass values to the right component by specifying
- <c>{ComponentName,Value}</c>. See also about
- <seealso marker="#TypeNameValue">{Typename,Value}</seealso> below
- and in the sections for each type.</p>
- </item>
- <tag><c>+driver</c></tag>
- <item>
- <p>As of R15B this means the same as the <c>nif</c> option. Kept for
- backwards compatability reasons.</p>
- </item>
- <tag><c>+nif</c></tag>
- <item>
- <p>Together with the flags <c>ber_bin</c>
- and <c>optimize</c> you choose to use a nif for considerable
- faster encode and decode. </p>
+ <p>DER encoding rule. Only when using <c>-ber</c> option.</p>
</item>
<tag><c>+asn1config</c></tag>
<item>
<p>This functionality works together with the flags
- <c>ber_bin</c> and <c>optimize</c>. You enables the
+ <c>ber</c>. It enables the
specialized decodes, see the <seealso marker="asn1_spec">Specialized Decode</seealso> chapter.
</p>
</item>
@@ -413,7 +377,6 @@ erlc -o ../asnfiles -I ../asnfiles -I /usr/local/standards/asn1 Person.asn
</item>
</taglist>
<p>For a complete description of <c>erlc</c> see Erts Reference Manual.</p>
- <p>For preferred option use see <seealso marker="#preferred option use">Preferred Option Use</seealso> section.</p>
<p>The compiler and other compile-time functions can also be invoked from
the Erlang shell. Below follows a brief
description of the primary functions, for a
@@ -429,9 +392,9 @@ asn1ct:compile("H323-MESSAGES.asn1"). </pre>
<p>which equals:</p>
<pre>
asn1ct:compile("H323-MESSAGES.asn1",[ber]). </pre>
- <p>If one wants PER encoding with optimizations:</p>
+ <p>If one wants PER encoding:</p>
<pre>
-asn1ct:compile("H323-MESSAGES.asn1",[per_bin,optimize]). </pre>
+asn1ct:compile("H323-MESSAGES.asn1",[per]). </pre>
<p>The generic encode and decode functions can be invoked like this:</p>
<pre>
asn1ct:encode('H323-MESSAGES','SomeChoiceType',{call,"octetstring"}).
@@ -443,269 +406,6 @@ asn1ct:decode('H323-MESSAGES','SomeChoiceType',Bytes). </pre>
</section>
<section>
- <marker id="preferred option use"></marker>
- <title>Preferred Option Use</title>
- <p>
- It may not be obvious which compile options best fit a
- situation. This section describes the format of the result of
- encode and decode. It also gives some performance statistics
- when using certain options. Finally there is a recommendation
- which option combinations should be used.
- </p>
- <p>
- The default option is <c>ber</c>. It is the same backend as
- <c>ber_bin</c> except that the result of encode is transformed
- to a flat list. Below is a table that gives the different
- formats of input and output of encode and decode using the
- <em>allowed combinations</em> of coding and optimization
- options: (EAVF stands for how ASN1 values are represented in
- Erlang which is described in the <seealso
- marker="#ASN1Types">ASN1 Types chapter</seealso>)
- </p>
- <table>
- <row>
- <cell align="left" valign="middle"><em>Encoding Rule</em></cell>
- <cell align="left" valign="middle"><em>Compile options, allowed combinations</em></cell>
- <cell align="left" valign="middle"><em>encode input</em></cell>
- <cell align="left" valign="middle"><em>encode output</em></cell>
- <cell align="left" valign="middle"><em>decode input</em></cell>
- <cell align="left" valign="middle"><em>decode output</em></cell>
- </row>
- <row>
- <cell align="left" valign="middle">BER</cell>
- <cell align="left" valign="middle">[ber] (default)</cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">flat list</cell>
- <cell align="left" valign="middle">flat list / binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">BER</cell>
- <cell align="left" valign="middle">[ber_bin]</cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">BER</cell>
- <cell align="left" valign="middle"><em>[ber_bin, optimize]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">BER</cell>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, nif]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist</cell>
- <cell align="left" valign="middle">iolist / binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">PER aligned variant</cell>
- <cell align="left" valign="middle">[per]</cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">flat list</cell>
- <cell align="left" valign="middle">flat list</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">PER aligned variant</cell>
- <cell align="left" valign="middle"><em>[per_bin]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist / binary</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">PER aligned variant</cell>
- <cell align="left" valign="middle"><em>[per_bin, optimize]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">PER unaligned variant</cell>
- <cell align="left" valign="middle"><em>[uper_bin]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
-
- <row>
- <cell align="left" valign="middle">DER</cell>
- <cell align="left" valign="middle">[(ber), der]</cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">flat list</cell>
- <cell align="left" valign="middle">flat list / binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">DER</cell>
- <cell align="left" valign="middle">[ber_bin, der]</cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">DER</cell>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, der]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
- <row>
- <cell align="left" valign="middle">DER</cell>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, nif, der]</em></cell>
- <cell align="left" valign="middle">EAVF</cell>
- <cell align="left" valign="middle">iolist</cell>
- <cell align="left" valign="middle">binary</cell>
- <cell align="left" valign="middle">EAVF</cell>
- </row>
-
-
- <tcaption>The output / input formats for different combinations of compile options.</tcaption>
- </table>
- <p>
- Encode / decode speed comparison in one user case for the above
- alternatives (except <c>DER</c>) is showed in the table below. The
- <c>DER</c> alternatives are slower than their corresponding
- <c>BER</c> alternative.
- </p>
-
- <table>
- <row>
- <cell align="left" valign="middle"><em>compile options</em></cell>
- <cell align="left" valign="middle"><em>encode time</em></cell>
- <cell align="left" valign="middle"><em>decode time</em></cell>
- </row>
- <row>
- <cell align="left" valign="middle">[ber]</cell>
- <cell align="left" valign="middle">120</cell>
- <cell align="left" valign="middle">162</cell>
- </row>
- <row>
- <cell align="left" valign="middle">[ber_bin]</cell>
- <cell align="left" valign="middle">124</cell>
- <cell align="left" valign="middle">154</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[ber_bin, optimize]</em></cell>
- <cell align="left" valign="middle">50</cell>
- <cell align="left" valign="middle">78</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, driver]</em></cell>
- <cell align="left" valign="middle">50</cell>
- <cell align="left" valign="middle">62</cell>
- </row>
- <row>
- <cell align="left" valign="middle">[per]</cell>
- <cell align="left" valign="middle">141</cell>
- <cell align="left" valign="middle">133</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[per_bin]</em></cell>
- <cell align="left" valign="middle">125</cell>
- <cell align="left" valign="middle">123</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[per_bin, optimize]</em></cell>
- <cell align="left" valign="middle">77</cell>
- <cell align="left" valign="middle">72</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[uper_bin]</em></cell>
- <cell align="left" valign="middle">97</cell>
- <cell align="left" valign="middle">104</cell>
- </row>
- <tcaption>
- One example of difference in speed for the compile option alternatives.
- </tcaption>
- </table>
-
- <p>
- The compile options <c>ber</c>, <c>per</c> and
- <c>driver</c> are kept for backwards compatibility and should not be
- used in new code. The nif implementation which replaces the linked-in
- driver has been shown to be about 5-15% faster.
- </p>
- <p>
- You are strongly recommended to use the appropriate alternative
- of the bold typed options. The <c>optimize</c> and
- <c>nif</c> options does not affect the encode or decode
- result, just the time spent in run-time. When <c>ber_bin</c> and
- <c>nif</c> or <c>per_bin</c> and <c>optimize</c> is
- combined the C-code nif is used in chosen parts of encode /
- decode procedure.
- </p>
- <table>
- <row>
- <cell align="left" valign="middle"><em>Compile options, allowed combinations</em></cell>
- <cell align="left" valign="middle"><em>use of nif</em></cell>
- </row>
- <row>
- <cell align="left" valign="middle">[ber]</cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle">[ber_bin]</cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[ber_bin, optimize]</em></cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, nif]</em></cell>
- <cell align="left" valign="middle">yes</cell>
- </row>
- <row>
- <cell align="left" valign="middle">[per]</cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[per_bin]</em></cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[per_bin, optimize]</em></cell>
- <cell align="left" valign="middle">yes</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[uper_bin]</em></cell>
- <cell align="left" valign="middle">no</cell>
- </row>
-
- <row>
- <cell align="left" valign="middle">[(ber), der]</cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle">[ber_bin, der]</cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, der]</em></cell>
- <cell align="left" valign="middle">no</cell>
- </row>
- <row>
- <cell align="left" valign="middle"><em>[ber_bin, optimize, nif, der]</em></cell>
- <cell align="left" valign="middle">yes</cell>
- </row>
-
-
- <tcaption>When the ASN1 nif is used.</tcaption>
- </table>
-
- </section>
- <section>
<title>Run-time Functions</title>
<p>A brief description of the major functions is given here. For a
complete description of each function see
@@ -719,9 +419,9 @@ asn1rt:decode('H323-MESSAGES','SomeChoiceType',Bytes). </pre>
'H323-MESSAGES':encode('SomeChoiceType',{call,"octetstring"}).
'H323-MESSAGES':decode('SomeChoiceType',Bytes). </pre>
<p>The asn1 nif is enabled in two occasions: encoding of
- asn1 values when the asn1 spec is compiled with <c>per_bin</c> and
- <c>optimize</c> or decode of encoded asn1 values when the asn1 spec is
- compiled with <c>ber_bin</c>, <c>optimize</c> and <c>nif</c>. In
+ asn1 values when the asn1 spec is compiled with <c>per</c> and
+ or decode of encoded asn1 values when the asn1 spec is
+ compiled with <c>ber</c>. In
those cases the nif will be loaded automatically at the first call
to <c>encode</c>/<c>decode</c>. If one doesn't want the performance
overhead of the nif being loaded at the first call it is possible
@@ -868,26 +568,6 @@ Operational ::= BOOLEAN --ASN.1 definition </pre>
<pre>
Val = true,
{ok,Bytes}=asn1rt:encode(MyModule,'Operational',Val), </pre>
- <p>For historical reasons it is also possible to assign ASN.1 values
- in Erlang using a tuple notation
- with type and value as this</p>
- <pre>
-Val = {'Operational',true} </pre>
- <warning>
- <marker id="warning"></marker>
- <p>The tuple notation, <c>{Typename, Value}</c> is only kept
- because of backward compatibility and may be withdrawn in a
- future release. If the notation is used the <c>Typename</c>
- element must be spelled correctly, otherwise a run-time error
- will occur.
- </p>
- <p>If the ASN.1 module is compiled with the flags
- <c>per_bin</c> or <c>ber_bin</c> and <c>optimize</c> it is not
- allowed to use the tuple notation. That possibility has been
- removed due to performance reasons. Neither is it allowed to
- use the <c>{ComponentName,Value}</c> notation in case of a
- SEQUENCE or SET type.</p>
- </warning>
<p>Below follows a description of how
values of each type can be represented in Erlang.
</p>
@@ -1149,7 +829,7 @@ TextFileVal2 = [88,76,55,44,99,121 .......... a lot of characters here ....]
The following example shows how it works:</p>
<p>In a file <c>PrimStrings.asn1</c> the type <c>BMP</c> is defined as
<br></br>
-<c>BMP ::= BMPString</c> then using BER encoding (<c>ber_bin</c>
+<c>BMP ::= BMPString</c> then using BER encoding (<c>ber</c>
option)the input/output format will be:</p>
<pre>
1> <input>{ok,Bytes1} = asn1rt:encode('PrimStrings','BMP',[{0,0,53,53},{0,0,45,56}]).</input>
@@ -1174,9 +854,9 @@ TextFileVal2 = [88,76,55,44,99,121 .......... a lot of characters here ....]
<c>utf8_list_to_binary</c>, are in the <c>asn1rt</c> module. In
the example below we assume an asn1 definition <c>UTF ::= UTF8String</c> in a module <c>UTF.asn</c>:</p>
<pre>
-1> <input>asn1ct:compile('UTF',[ber_bin]).</input>
+1> <input>asn1ct:compile('UTF',[ber]).</input>
Erlang ASN.1 version "1.4.3.3" compiling "UTF.asn"
-Compiler Options: [ber_bin]
+Compiler Options: [ber]
--{generated,"UTF.asn1db"}--
--{generated,"UTF.erl"}--
ok
@@ -1287,14 +967,6 @@ Pdu ::= SEQUENCE {
<p>Values can be assigned in Erlang as shown below:</p>
<pre>
MyPdu = #'Pdu'{a=22,b=77.99,c={0,1,2,3,4},d='NULL'}. </pre>
-<note>
- <p>
- In very early versions of the asn1 compiler it was also possible to
- specify the values of the components in
- a SEQUENCE or a SET as a list of tuples <c>{ComponentName,Value}</c>.
- This is no longer supported.
- </p>
-</note>
<p>The decode functions will return a record as result when decoding
a <c>SEQUENCE</c> or a <c>SET</c>.
<marker id="DEFAULT"></marker>
@@ -1739,12 +1411,9 @@ SS ::= SET {
1> <input>Val = 'Values':tt().</input>
{'TT',77,["kalle","kula"]}
2> <input>{ok,Bytes} = 'Values':encode('TT',Val).</input>
-{ok,["0",
- [18],
- [[[128],[1],"M"],["\\241","\\r",[[[4],[5],"kalle"],[[4],[4],"kula"]]]]]}
-3> <input>FlatBytes = lists:flatten(Bytes).</input>
-[48,18,128,1,77,161,13,4,5,107,97,108,108,101,4,4,107,117,108,97]
-4> <input>'Values':decode('TT',FlatBytes).</input>
+{ok,&lt;&lt;48,18,128,1,77,161,13,4,5,107,97,108,108,101,4,4,
+ 107,117,108,97&gt;&gt;}
+4> <input>'Values':decode('TT',Bytes).</input>
{ok,{'TT',77,["kalle","kula"]}}
5>
</pre>
diff --git a/lib/asn1/doc/src/asn1ct.xml b/lib/asn1/doc/src/asn1ct.xml
index 3be58cbc8e..9a9bb7ec1b 100644
--- a/lib/asn1/doc/src/asn1ct.xml
+++ b/lib/asn1/doc/src/asn1ct.xml
@@ -41,6 +41,19 @@
encode/decode functions. There are also some generic functions which
can be used in during development of applications which handles ASN.1
data (encoded as BER or PER).</p>
+ <note>
+ <p>In R16, the options have been simplified. The back-end is chosen
+ using one of the options <c>ber</c>, <c>per</c>, or <c>uper</c>.
+ The options <c>optimize</c>, <c>nif</c>, and <c>driver</c> options
+ are no longer necessary (and the ASN.1 compiler will print a
+ warning if they are used). The options <c>ber_bin</c>, <c>per_bin</c>,
+ and <c>uper_bin</c> options will still work, but will print a warning.
+ </p>
+ <p>Another change in R16 is that the generated <c>encode/2</c>
+ function (and <c>asn1rt:encode/3</c>) always returns a binary.
+ The <c>encode/2</c> function for the BER back-end used to return
+ an iolist.</p>
+ </note>
</description>
<funcs>
<func>
@@ -50,9 +63,9 @@
<type>
<v>Asn1module = atom() | string()</v>
<v>Options = [Option| OldOption]</v>
- <v>Option = ber_bin | per_bin | uper_bin | der | compact_bit_string |
- noobj | {n2n, EnumTypeName} |{outdir, Dir} | {i, IncludeDir} | optimize |
- nif | asn1config | undec_rest | {inline, OutputName} | inline |
+ <v>Option = ber | per | uper | der | compact_bit_string |
+ noobj | {n2n, EnumTypeName} |{outdir, Dir} | {i, IncludeDir} |
+ asn1config | undec_rest | {inline, OutputName} | inline |
{macro_name_prefix, Prefix} | {record_name_prefix, Prefix} | verbose | warnings_as_errors</v>
<v>OldOption = ber | per</v>
<v>Reason = term()</v>
@@ -112,7 +125,7 @@ File3.asn </pre>
section in users guide</seealso>. Available options are:
</p>
<taglist>
- <tag><c>ber | ber_bin | per | per_bin | uper_bin</c></tag>
+ <tag><c>ber | per | uper</c></tag>
<item>
<p>
The encoding rule to be used. The supported encoding rules
@@ -120,23 +133,12 @@ File3.asn </pre>
PER aligned (Packed Encoding Rules) and PER unaligned.
If the encoding rule option is omitted <c>ber</c>
is the default.
- The <c>per_bin</c> option means the aligned
- variant. To use the unaligned variant the <c>uper_bin</c>
- option has to be used.
</p>
<p>
The generated Erlang module always gets the same name
as the ASN.1 module and as a consequence of this only one
encoding rule per ASN.1 module can be used at runtime.
</p>
- <p>
- The <c>ber_bin</c> and <c>per_bin</c> options are
- equivalent with the <c>OldOptions</c> <c>ber</c> and <c>per</c>
- with the difference that the generated encoding/decoding
- functions take advantage of the bit syntax, which in most
- cases increases the performance considerably. The result
- from encoding is a binary or an iolist.
- </p>
</item>
<tag><c>der</c></tag>
<item>
@@ -144,7 +146,7 @@ File3.asn </pre>
By this option the Distinguished Encoding Rules (DER) is chosen.
DER is regarded as a specialized variant of the BER encoding
rule, therefore the <c>der</c> option only makes sense together
- with the <c>ber</c> or <c>ber_bin</c> option.
+ with the <c>ber</c> option.
This option
sometimes adds sorting and value checks when encoding, which
implies a slower encoding. The decoding routines are the same
@@ -206,28 +208,6 @@ Binary = binary()
shall be placed. If omitted the files are placed in the
current directory.</p>
</item>
- <tag><c>optimize</c></tag>
- <item>
- <p>This option is only valid together with one of the
- <c>per_bin</c>
- or <c>ber_bin</c> option. It gives time optimized code
- generated and it uses another runtime module and
- in the <c>per_bin</c> case a nif. The result
- in the <c>per_bin</c> case from an encode when compiled
- with this option will be a binary.</p>
- </item>
- <tag><c>driver</c></tag>
- <item>
- <p>As of R15B this means the same as the <c>nif</c> option. Kept for
- backwards compatability reasons.</p>
- </item>
- <tag><c>nif</c></tag>
- <item>
- <p>Option valid together with <c>ber_bin</c> and <c>optimize</c>
- options. It enables the use of several nifs that gives faster
- encode and decode. Nifs are only enabled by the explicit use of
- the option <c>nif</c></p>
- </item>
<tag><c>asn1config</c></tag>
<item>
<p>When one of the specialized decodes, exclusive or
@@ -270,10 +250,6 @@ Binary = binary()
<c>{export, [atom()]}</c> or <c>{export_all, true}</c> option
are provided. The list of atoms are names of chosen asn1
specs from the <c>.set.asn</c> file. </p>
- <p>When used together with <c>nif</c> for <c>ber_bin</c>, the
- asn1 nifs will be used if the <c>asn1rt_nif</c> module is
- available. If it is not available, a slower erlang fallback
- will be used.</p>
</item>
<tag><c>inline</c></tag>
<item>
@@ -327,13 +303,12 @@ Binary = binary()
<type>
<v>Module = Type = atom()</v>
<v>Value = term()</v>
- <v>Bytes = [Int] when integer(Int), Int >= 0, Int =&lt; 255</v>
+ <v>Bytes = binary()</v>
<v>Reason = term()</v>
</type>
<desc>
<p>Encodes <c>Value</c> of <c>Type</c> defined in the ASN.1 module
- <c>Module</c>. Returns a list of bytes if successful. To get as fast execution as
- possible the
+ <c>Module</c>. To get as fast execution as possible the
encode function only performs rudimentary tests that the input
<c>Value</c>
is a correct instance of <c>Type</c>. The length of strings is for example
@@ -348,10 +323,10 @@ Binary = binary()
<type>
<v>Module = Type = atom()</v>
<v>Value = Reason = term()</v>
- <v>Bytes = [Int] when integer(Int), Int >= 0, Int =&lt; 255</v>
+ <v>Bytes = binary()</v>
</type>
<desc>
- <p>Decodes <c>Type</c> from <c>Module</c> from the list of bytes
+ <p>Decodes <c>Type</c> from <c>Module</c> from the binary
<c>Bytes</c>. Returns <c>{ok, Value}</c> if successful.</p>
</desc>
</func>
diff --git a/lib/asn1/doc/src/asn1rt.xml b/lib/asn1/doc/src/asn1rt.xml
index 0c3c257189..f2cac0c9e7 100644
--- a/lib/asn1/doc/src/asn1rt.xml
+++ b/lib/asn1/doc/src/asn1rt.xml
@@ -47,35 +47,34 @@
<type>
<v>Module = Type = atom()</v>
<v>Value = Reason = term()</v>
- <v>Bytes = binary | [Int] when integer(Int), Int >= 0, Int =&lt; 255 | binary</v>
+ <v>Bytes = binary</v>
</type>
<desc>
- <p>Decodes <c>Type</c> from <c>Module</c> from the list of bytes or
- binary <c>Bytes</c>. If the module is compiled with <c>ber_bin</c>
- or <c>per_bin</c> option <c>Bytes</c> must be a binary.
+ <p>Decodes <c>Type</c> from <c>Module</c> from the binary <c>Bytes</c>.
Returns <c>{ok,Value}</c> if successful.</p>
</desc>
</func>
<func>
- <name>encode(Module,Type,Value)-> {ok,BinOrList} | {error,Reason}</name>
+ <name>encode(Module,Type,Value)-> {ok,Bytes} | {error,Reason}</name>
<fsummary>Encode an ASN.1 value.</fsummary>
<type>
<v>Module = Type = atom()</v>
<v>Value = term()</v>
- <v>BinOrList = Bytes | binary()</v>
- <v>Bytes = [Int|binary|Bytes] when integer(Int), Int >= 0, Int =&lt; 255</v>
+ <v>Bytes = binary</v>
<v>Reason = term()</v>
</type>
<desc>
<p>Encodes <c>Value</c> of <c>Type</c> defined in the ASN.1 module
<c>Module</c>. Returns a possibly nested list of bytes and or binaries
- if successful. If <c>Module</c> was compiled with the options <c>per_bin</c> and <c>optimize</c> the result is a binary. To get as
- fast execution as possible the
+ if successful. To get as fast execution as possible the
encode function only performs rudimentary tests that the input
<c>Value</c>
is a correct instance of <c>Type</c>. The length of strings is for example
not always checked. </p>
+ <note>
+ <p>Starting in R16, <c>Bytes</c> is always a binary.</p>
+ </note>
</desc>
</func>
@@ -95,28 +94,6 @@
</func>
<func>
- <name>load_driver() -> ok | {error,Reason}</name>
- <fsummary>Loads the linked-in driver. (deprecated)</fsummary>
- <type>
- <v>Reason = term()</v>
- </type>
- <desc>
- <p>This function is obsolete and will be removed in R16A</p>
- </desc>
- </func>
-
- <func>
- <name>unload_driver() -> ok | {error,Reason}</name>
- <fsummary>Unloads the linked-in driver. (deprecated)</fsummary>
- <type>
- <v>Reason = term()</v>
- </type>
- <desc>
- <p>This function is obsolete and will be removed in R16A</p>
- </desc>
- </func>
-
- <func>
<name>utf8_binary_to_list(UTF8Binary) -> {ok,UnicodeList} | {error,Reason}</name>
<fsummary>Transforms an utf8 encoded binary to a unicode list.</fsummary>
<type>
diff --git a/lib/asn1/doc/src/notes.xml b/lib/asn1/doc/src/notes.xml
index 5ca86130a1..72b496caf7 100644
--- a/lib/asn1/doc/src/notes.xml
+++ b/lib/asn1/doc/src/notes.xml
@@ -483,7 +483,7 @@
ENUMERATION type, the compilation will be terminated with an
error code.<br/>
Below follows an example on how to use the option from the command line with <c>erlc</c>:<br/>
- <c>erlc -bper_bin +optimize +driver +"{n2n,'CauseMisc'}" +"{n2n,'CausePcl'}" MyModyle.asn</c>
+ <c>erlc -bper+"{n2n,'CauseMisc'}" +"{n2n,'CausePcl'}" MyModyle.asn</c>
</p>
<p>
Own Id: OTP-8136 Aux Id: seq11347 </p>
diff --git a/lib/asn1/src/Makefile b/lib/asn1/src/Makefile
index 4bd49aa93b..3d66583745 100644
--- a/lib/asn1/src/Makefile
+++ b/lib/asn1/src/Makefile
@@ -52,8 +52,6 @@ CT_MODULES= \
asn1ct_gen_per_rt2ct \
asn1ct_name \
asn1ct_constructed_per \
- asn1ct_constructed_ber \
- asn1ct_gen_ber \
asn1ct_constructed_ber_bin_v2 \
asn1ct_gen_ber_bin_v2 \
asn1ct_value \
@@ -63,7 +61,6 @@ CT_MODULES= \
RT_MODULES= \
asn1rt \
- asn1rt_per_bin \
asn1rt_ber_bin \
asn1rt_ber_bin_v2 \
asn1rt_per_bin_rt2ct \
diff --git a/lib/asn1/src/asn1.app.src b/lib/asn1/src/asn1.app.src
index 09144ba2f7..64b33a8a30 100644
--- a/lib/asn1/src/asn1.app.src
+++ b/lib/asn1/src/asn1.app.src
@@ -3,7 +3,6 @@
{vsn, "%VSN%"},
{modules, [
asn1rt,
- asn1rt_per_bin,
asn1rt_per_bin_rt2ct,
asn1rt_uper_bin,
asn1rt_ber_bin,
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl
index 8e971a1c76..90882462ac 100644
--- a/lib/asn1/src/asn1ct.erl
+++ b/lib/asn1/src/asn1ct.erl
@@ -85,14 +85,8 @@
compile(File) ->
compile(File,[]).
-compile(File,Options) when is_list(Options) ->
- case lists:member(driver, Options) of %% remove me in R16A!
- true ->
- io:format("Warning: driver option is obsolete and will be removed in R16A, use nif instead!");
- false ->
- ok
- end,
- Options1 = optimize_ber_bin(Options),
+compile(File, Options0) when is_list(Options0) ->
+ Options1 = translate_options(Options0),
Options2 = includes(File,Options1),
Includes = strip_includes(Options2),
in_process(fun() -> compile_proc(File, Includes, Options2) end).
@@ -852,8 +846,8 @@ generate({true,{M,_Module,GenTOrV}},OutFile,EncodingRule,Options) ->
debug_off(Options),
put(compact_bit_string,false),
erase(encoding_options),
- erase(tlv_format), % used in ber_bin, optimize
- erase(class_default_type),% used in ber_bin, optimize
+ erase(tlv_format), % used in ber
+ erase(class_default_type),% used in ber
asn1ct_table:delete(check_functions),
case Result of
{error,_} ->
@@ -876,14 +870,13 @@ parse_and_save(Module,S) ->
Options = S#state.options,
SourceDir = S#state.sourcedir,
Includes = [I || {i,I} <-Options],
- Options1 = optimize_ber_bin(Options),
-
+
case get_input_file(Module,[SourceDir|Includes]) of
%% search for asn1 source
{file,SuffixedASN1source} ->
- case dbfile_uptodate(SuffixedASN1source,Options1) of
+ case dbfile_uptodate(SuffixedASN1source,Options) of
false ->
- parse_and_save1(S,SuffixedASN1source,Options1,Includes);
+ parse_and_save1(S,SuffixedASN1source,Options,Includes);
_ -> ok
end;
Err ->
@@ -1065,9 +1058,9 @@ get_file_list1(Stream,Dir,Includes,Acc) ->
end.
get_rule(Options) ->
- case [Rule ||Rule <-[per,ber,ber_bin,ber_bin_v2,per_bin,uper_bin],
- Opt <- Options,
- Rule==Opt] of
+ case [Rule || Rule <- [ber,per,uper],
+ Opt <- Options,
+ Rule =:= Opt] of
[Rule] ->
Rule;
[Rule|_] ->
@@ -1079,19 +1072,34 @@ get_rule(Options) ->
get_runtime_mod(Options) ->
RtMod1=
case get_rule(Options) of
- per -> ["asn1rt_per_bin.erl"];
- ber -> ["asn1rt_ber_bin.erl"];
- per_bin ->
- case lists:member(optimize,Options) of
- true -> ["asn1rt_per_bin_rt2ct.erl"];
- _ -> ["asn1rt_per_bin.erl"]
- end;
- ber_bin -> ["asn1rt_ber_bin.erl"];
- ber_bin_v2 -> ["asn1rt_ber_bin_v2.erl"];
- uper_bin -> ["asn1rt_uper_bin.erl"]
+ per -> "asn1rt_per_bin_rt2ct.erl";
+ ber -> ["asn1rt_ber_bin_v2.erl"];
+ uper -> ["asn1rt_uper_bin.erl"]
end,
RtMod1++["asn1rt_check.erl","asn1rt.erl"].
-
+
+%% translate_options(NewOptions) -> OldOptions
+%% Translate the new option names to the old option name.
+%% FIXME. We should rewrite all code to handle the new option names.
+
+translate_options([ber_bin|T]) ->
+ io:format("Warning: The option 'ber_bin' is now called 'ber'.\n"),
+ [ber|translate_options(T)];
+translate_options([per_bin|T]) ->
+ io:format("Warning: The option 'per_bin' is now called 'per'.\n"),
+ [per|translate_options(T)];
+translate_options([uper_bin|T]) ->
+ io:format("Warning: The option 'uper_bin' is now called 'uper'.\n"),
+ translate_options([uper|T]);
+translate_options([nif|T]) ->
+ io:format("Warning: The option 'nif' is no longer needed.\n"),
+ translate_options(T);
+translate_options([optimize|T]) ->
+ io:format("Warning: The option 'optimize' is no longer needed.\n"),
+ translate_options(T);
+translate_options([H|T]) ->
+ [H|translate_options(T)];
+translate_options([]) -> [].
erl_compile(OutFile,Options) ->
% io:format("Options:~n~p~n",[Options]),
@@ -1115,7 +1123,6 @@ remove_asn_flags(Options) ->
X /= optimize,
X /= compact_bit_string,
X /= debug,
- X /= keyed_list,
X /= asn1config,
X /= record_name_prefix].
@@ -1125,12 +1132,6 @@ debug_on(Options) ->
put(asndebug,true);
_ ->
true
- end,
- case lists:member(keyed_list,Options) of
- true ->
- put(asn_keyed_list,true);
- _ ->
- true
end.
igorify_options(Options) ->
@@ -1151,8 +1152,7 @@ generated_file(Name,Options) ->
end.
debug_off(_Options) ->
- erase(asndebug),
- erase(asn_keyed_list).
+ erase(asndebug).
outfile(Base, Ext, Opts) ->
@@ -1168,13 +1168,6 @@ outfile(Base, Ext, Opts) ->
lists:concat([Obase,".",Ext])
end.
-optimize_ber_bin(Options) ->
- case {lists:member(optimize,Options),lists:member(ber_bin,Options)} of
- {true,true} ->
- [ber_bin_v2|Options--[ber_bin]];
- _ -> Options
- end.
-
includes(File,Options) ->
Options2 = include_append(".", Options),
Options3 = include_append(filename:dirname(File), Options2),
@@ -1284,12 +1277,7 @@ make_erl_options(Opts) ->
Defines) ++
case OutputType of
undefined -> [ber]; % temporary default (ber when it's ready)
- ber -> [ber];
- ber_bin -> [ber_bin];
- ber_bin_v2 -> [ber_bin_v2];
- per -> [per];
- per_bin -> [per_bin];
- uper_bin -> [uper_bin]
+ _ -> [OutputType] % pass through
end,
Options++[errors, {cwd, Cwd}, {outdir, Outdir}|
@@ -1400,8 +1388,7 @@ test_value(Module, Type, Value) ->
in_process(fun() ->
case catch encode(Module, Type, Value) of
{ok, Bytes} ->
- M = to_atom(Module),
- NewBytes = prepare_bytes(M:encoding_rule(), Bytes),
+ NewBytes = prepare_bytes(Bytes),
case decode(Module, Type, NewBytes) of
{ok, Value} ->
{ok, {Module, Type, Value}};
@@ -1452,18 +1439,8 @@ check(Module, Includes) ->
end
end.
-to_atom(Term) when is_list(Term) -> list_to_atom(Term);
-to_atom(Term) when is_atom(Term) -> Term.
-
-prepare_bytes(ber, Bytes) -> lists:flatten(Bytes);
-prepare_bytes(ber_bin, Bytes) when is_binary(Bytes) -> Bytes;
-prepare_bytes(ber_bin, Bytes) -> list_to_binary(Bytes);
-prepare_bytes(ber_bin_v2, Bytes) when is_binary(Bytes) -> Bytes;
-prepare_bytes(ber_bin_v2, Bytes) -> list_to_binary(Bytes);
-prepare_bytes(per, Bytes) -> lists:flatten(Bytes);
-prepare_bytes(per_bin, Bytes) when is_binary(Bytes) -> Bytes;
-prepare_bytes(per_bin, Bytes) -> list_to_binary(Bytes);
-prepare_bytes(uper_bin, Bytes) -> Bytes.
+prepare_bytes(Bytes) when is_binary(Bytes) -> Bytes;
+prepare_bytes(Bytes) -> list_to_binary(Bytes).
vsn() ->
?vsn.
@@ -1504,7 +1481,7 @@ specialized_decode_prepare(Erule,M,TsAndVs,Options) ->
end.
%% Reads the configuration file if it exists and stores information
%% about partial decode and incomplete decode
-partial_decode_prepare(ber_bin_v2,M,TsAndVs,Options) when is_tuple(TsAndVs) ->
+partial_decode_prepare(ber,M,TsAndVs,Options) when is_tuple(TsAndVs) ->
%% read configure file
ModName =
diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl
index 59e82b7a57..fe1b2e14a8 100644
--- a/lib/asn1/src/asn1ct_check.erl
+++ b/lib/asn1/src/asn1ct_check.erl
@@ -61,13 +61,13 @@
-define(TAG_PRIMITIVE(Num),
case S#state.erule of
- ber_bin_v2 ->
+ ber ->
#tag{class='UNIVERSAL',number=Num,type='IMPLICIT',form=0};
_ -> []
end).
-define(TAG_CONSTRUCTED(Num),
case S#state.erule of
- ber_bin_v2 ->
+ ber ->
#tag{class='UNIVERSAL',number=Num,type='IMPLICIT',form=32};
_ -> []
end).
@@ -3262,7 +3262,7 @@ check_type(S=#state{recordtopname=TopName},Type,Ts) when is_record(Ts,type) ->
inlined=IsInlined},
TestFun =
fun(Tref) ->
- {_,MaybeChoice} = get_referenced_type(S,Tref),
+ MaybeChoice = get_non_typedef(S, Tref),
case catch((MaybeChoice#typedef.typespec)#type.def) of
{'CHOICE',_} ->
maybe_illicit_implicit_tag(choice,Tag);
@@ -3347,7 +3347,7 @@ check_type(S=#state{recordtopname=TopName},Type,Ts) when is_record(Ts,type) ->
TempNewDef#newt{
type = check_externaltypereference(S,NewExt),
tag = case S#state.erule of
- ber_bin_v2 ->
+ ber ->
merge_tags(Ct,RefType#type.tag);
_ ->
Ct
@@ -3617,6 +3617,14 @@ check_type(S=#state{recordtopname=TopName},Type,Ts) when is_record(Ts,type) ->
check_type(_S,Type,Ts) ->
exit({error,{asn1,internal_error,Type,Ts}}).
+get_non_typedef(S, Tref0) ->
+ case get_referenced_type(S, Tref0) of
+ {_,#typedef{typespec=#type{def=#'Externaltypereference'{}=Tref}}} ->
+ get_non_typedef(S, Tref);
+ {_,Type} ->
+ Type
+ end.
+
%% tablecinf_choose. A SEQUENCE or SET may be inserted in another
%% SEQUENCE or SET by the COMPONENTS OF directive. If this inserted
%% type is a referenced type that already has been checked it already
@@ -5289,7 +5297,7 @@ iof_associated_type(S,[]) ->
AssociateSeq = iof_associated_type1(S,[]),
Tag =
case S#state.erule of
- ber_bin_v2 ->
+ ber ->
[?TAG_CONSTRUCTED(?N_INSTANCE_OF)];
_ -> []
end,
@@ -5320,7 +5328,7 @@ iof_associated_type1(S,C) ->
end,
{ObjIdTag,C1TypeTag}=
case S#state.erule of
- ber_bin_v2 ->
+ ber ->
{[{'UNIVERSAL',8}],
[#tag{class='UNIVERSAL',
number=6,
@@ -5551,8 +5559,9 @@ complist_as_tuple(_Per,[],Acc,Ext,_Acc2,ext) ->
complist_as_tuple(_Per,[],Acc,Ext,Acc2,root2) ->
{lists:reverse(Acc),lists:reverse(Ext),lists:reverse(Acc2)}.
-is_erule_per(Erule) ->
- lists:member(Erule,[per,per_bin,uper_bin]).
+is_erule_per(per) -> true;
+is_erule_per(uper) -> true;
+is_erule_per(ber) -> false.
expand_components(S, [{'COMPONENTS OF',Type}|T]) ->
CompList = expand_components2(S,get_referenced_type(S,Type#type.def)),
@@ -5641,7 +5650,7 @@ check_set(S,Type,Components) ->
{true,_} ->
{Sorted,SortedComponents} = sort_components(der,S,NewComponents),
{Sorted,TableCInf,SortedComponents};
- {_,PER} when PER =:= per; PER =:= per_bin; PER =:= uper_bin ->
+ {_,PER} when PER =:= per; PER =:= uper ->
{Sorted,SortedComponents} = sort_components(per,S,NewComponents),
{Sorted,TableCInf,SortedComponents};
_ ->
@@ -5765,7 +5774,7 @@ sort_universal_type(Components) ->
decode_type(I) when is_integer(I) ->
I;
decode_type(T) ->
- asn1ct_gen_ber:decode_type(T).
+ asn1ct_gen_ber_bin_v2:decode_type(T).
untagged_choice(_S,[#'ComponentType'{typespec=#type{tag=[],def={'CHOICE',_}}}|_Rest]) ->
true;
@@ -6884,16 +6893,16 @@ get_taglist(S,{ObjCl,FieldNameList}) when is_record(ObjCl,objectclass),
{TypeFieldName,_} when is_atom(TypeFieldName) -> []%should check if allowed
end;
get_taglist(S,Def) ->
- case lists:member(S#state.erule,[ber_bin_v2]) of
- false ->
+ case S#state.erule of
+ ber ->
+ [];
+ _ ->
case Def of
'ASN1_OPEN_TYPE' -> % open_type has no UNIVERSAL tag as such
[];
_ ->
[asn1ct_gen:def_to_tag(Def)]
- end;
- _ ->
- []
+ end
end.
get_taglist1(S,[#'ComponentType'{name=_Cname,tags=TagL}|Rest]) when is_list(TagL) ->
diff --git a/lib/asn1/src/asn1ct_constructed_ber.erl b/lib/asn1/src/asn1ct_constructed_ber.erl
deleted file mode 100644
index 360de77663..0000000000
--- a/lib/asn1/src/asn1ct_constructed_ber.erl
+++ /dev/null
@@ -1,1596 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
-%%
-%% The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-%%
--module(asn1ct_constructed_ber).
-
--export([gen_encode_sequence/3]).
--export([gen_decode_sequence/3]).
--export([gen_encode_set/3]).
--export([gen_decode_set/3]).
--export([gen_encode_sof/4]).
--export([gen_decode_sof/4]).
--export([gen_encode_choice/3]).
--export([gen_decode_choice/3]).
-
-%%%% Application internal exports
--export([match_tag/2]).
-
--include("asn1_records.hrl").
-
--import(asn1ct_gen, [emit/1,demit/1,get_record_name_prefix/0]).
-
-% the encoding of class of tag bits 8 and 7
--define(UNIVERSAL, 0).
--define(APPLICATION, 16#40).
--define(CONTEXT, 16#80).
--define(PRIVATE, 16#C0).
-
-% primitive or constructed encoding % bit 6
--define(PRIMITIVE, 0).
--define(CONSTRUCTED, 2#00100000).
-
-
-
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Encode/decode SEQUENCE
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-gen_encode_sequence(Erules,Typename,D) when is_record(D,type) ->
- asn1ct_name:start(),
- asn1ct_name:new(term),
- asn1ct_name:new(bytes),
-
- %% if EXTERNAL type the input value must be transformed to
- %% ASN1 1990 format
- case Typename of
- ['EXTERNAL'] ->
- emit([" NewVal = asn1rt_check:transform_to_EXTERNAL1990(Val),",
- nl]);
- _ ->
- ok
- end,
-
- {SeqOrSet,TableConsInfo,CompList0} =
- case D#type.def of
- #'SEQUENCE'{tablecinf=TCI,components=CL} ->
- {'SEQUENCE',TCI,CL};
- #'SET'{tablecinf=TCI,components=CL} ->
- {'SET',TCI,CL}
- end,
- %% filter away extensionAdditiongroup markers
- CompList = filter_complist(CompList0),
- Ext = extensible(CompList),
- CompList1 = case CompList of
- {Rl1,El,Rl2} -> Rl1 ++ El ++ Rl2;
- {Rl,El} -> Rl ++ El;
- _ -> CompList
- end,
- EncObj =
- case TableConsInfo of
- #simpletableattributes{usedclassfield=Used,
- uniqueclassfield=Unique} when Used /= Unique ->
- false;
- %% ObjectSetRef, name of the object set in constraints
- %%
- %%{ObjectSetRef,AttrN,N,UniqueFieldName}
- #simpletableattributes{objectsetname=ObjectSetRef,
- c_name=AttrN,
- c_index=N,
- usedclassfield=UniqueFieldName,
- uniqueclassfield=UniqueFieldName,
- valueindex=ValueIndex
- } ->
- OSDef =
- case ObjectSetRef of
- {Module,OSName} ->
- asn1_db:dbget(Module,OSName);
- OSName ->
- asn1_db:dbget(get(currmod),OSName)
- end,
-% io:format("currmod: ~p~nOSName: ~p~nAttrN: ~p~nN: ~p~nUniqueFieldName: ~p~n",
-% [get(currmod),OSName,AttrN,N,UniqueFieldName]),
- case (OSDef#typedef.typespec)#'ObjectSet'.gen of
- true ->
-% Val = lists:concat(["?RT_BER:cindex(",
-% N+1,",Val,"]),
- ObjectEncode =
- asn1ct_gen:un_hyphen_var(lists:concat(['Obj',
- AttrN])),
- emit({ObjectEncode," = ",nl}),
- {ObjSetMod,ObjSetName} =
- case ObjectSetRef of
- {M,O} ->
- {{asis,M},O};
- O ->
- {"?MODULE",O}
- end,
- emit({" ",ObjSetMod,":'getenc_",ObjSetName,"'(",{asis,UniqueFieldName},
- ", ",nl}),
-% emit({indent(35),"?RT_BER:cindex(",N+1,", Val,",
-% {asis,AttrN},")),",nl}),
- Length = fun(X,_LFun) when is_atom(X) ->
- length(atom_to_list(X));
- (X,_LFun) when is_list(X) ->
- length(X);
- ({X1,X2},LFun) ->
- LFun(X1,LFun) + LFun(X2,LFun)
- end,
- emit([indent(10+Length(ObjectSetRef,Length)),
- "value_match(",{asis,ValueIndex},",",
- "?RT_BER:cindex(",N+1,",Val,",
- {asis,AttrN},"))),",nl]),
- notice_value_match(),
- {AttrN,ObjectEncode};
- _ ->
- false
- end;
- _ ->
- case D#type.tablecinf of
- [{objfun,_}|_] ->
- %% when the simpletableattributes was at an
- %% outer level and the objfun has been passed
- %% through the function call
- {"got objfun through args","ObjFun"};
- _ ->
- false
- end
- end,
-
- gen_enc_sequence_call(Erules,Typename,CompList1,1,Ext,EncObj),
-
- MyTag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- D#type.tag]
- ++
- [#tag{class = asn1ct_gen_ber:decode_class('UNIVERSAL'),
- number = asn1ct_gen_ber:decode_type(SeqOrSet),
- form = ?CONSTRUCTED,
- type = 'IMPLICIT'}],
- emit([nl," BytesSoFar = "]),
- case SeqOrSet of
- 'SET' when (D#type.def)#'SET'.sorted == dynamic ->
- emit("asn1rt_check:dynamicsort_SET_components(["),
- mkvlist(asn1ct_name:all(encBytes)),
- emit(["]),",nl]);
- _ ->
- emit("["),
- mkvlist(asn1ct_name:all(encBytes)),
- emit(["],",nl])
- end,
- emit(" LenSoFar = "),
- case asn1ct_name:all(encLen) of
- [] -> emit("0");
- AllLengths ->
- mkvplus(AllLengths)
- end,
- emit([",",nl]),
-% emit(["{TagBytes,Len} = ?RT_BER:encode_tags(TagIn ++ ",
- emit([" ?RT_BER:encode_tags(TagIn ++ ",
- {asis,MyTag},", BytesSoFar, LenSoFar).",nl]).
-
-
-gen_decode_sequence(Erules,Typename,D) when is_record(D,type) ->
- asn1ct_name:start(),
- asn1ct_name:new(tag),
- #'SEQUENCE'{tablecinf=TableConsInfo,components=CList0} = D#type.def,
-
- %% filter away extensionAdditiongroup markers
- CList = filter_complist(CList0),
-
- Ext = extensible(CList),
- {CompList,CompList2} = case CList of
- {Rl1,El,Rl2} -> {Rl1 ++ El ++ Rl2,CList};
- {Rl,El} -> {Rl ++ El, Rl ++ El};
- _ -> {CList,CList}
- end,
-
- emit([" %%-------------------------------------------------",nl]),
- emit([" %% decode tag and length ",nl]),
- emit([" %%-------------------------------------------------",nl]),
-
- asn1ct_name:new(rb),
- MyTag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- D#type.tag]
- ++
- [#tag{class = asn1ct_gen_ber:decode_class('UNIVERSAL'),
- number = asn1ct_gen_ber:decode_type('SEQUENCE'),
- form = ?CONSTRUCTED,
- type = 'IMPLICIT'}],
- emit([" {{_,",asn1ct_gen_ber:unused_var("Len",D#type.def),"},",{next,bytes},",",{curr,rb},
- "} = ?RT_BER:check_tags(TagIn ++ ",{asis,MyTag},", ",
- {curr,bytes},", OptOrMand), ",nl]),
- asn1ct_name:new(bytes),
- asn1ct_name:new(len),
-
- case CompList of
- [] -> true;
- _ ->
- emit({"{",{next,bytes},
- ",RemBytes} = ?RT_BER:split_list(",
- {curr,bytes},
- ",", {prev,len},"),",nl}),
- asn1ct_name:new(bytes)
- end,
-
- {DecObjInf,UniqueFName,ValueIndex} =
- case TableConsInfo of
- #simpletableattributes{objectsetname=ObjectSet,
- c_name=AttrN,
- usedclassfield=UniqueFieldName,
- uniqueclassfield=UniqueFieldName,
- valueindex=ValIndex
- } ->
- F = fun(#'ComponentType'{typespec=CT})->
- case {asn1ct_gen:get_constraint(CT#type.constraint,componentrelation),CT#type.tablecinf} of
-% case {CT#type.constraint,CT#type.tablecinf} of
- {no,[{objfun,_}|_R]} -> true;
- _ -> false
- end
- end,
- case lists:any(F,CompList) of
- %%AttributeName = asn1ct_gen:un_hyphen_var(AttrN),
- true -> % when component relation constraint establish
- %% relation from a component to another components
- %% subtype component
- {{AttrN,{deep,ObjectSet,UniqueFieldName,
- ValIndex}},
- UniqueFieldName,ValIndex};
- false ->
- {{AttrN,ObjectSet},UniqueFieldName,ValIndex}
- end;
- _ ->
- {false,false,false}
- end,
- RecordName = lists:concat([get_record_name_prefix(),asn1ct_gen:list2rname(Typename)]),
- case gen_dec_sequence_call(Erules,Typename,CompList2,Ext,DecObjInf) of
- no_terms -> % an empty sequence
- emit([nl,nl]),
- demit({"Result = "}), %dbg
- %% return value as record
- asn1ct_name:new(rb),
- emit([" {{'",RecordName,"'}, ",{curr,bytes},",",nl," "]),
- asn1ct_gen_ber:add_removed_bytes(),
- emit(["}.",nl]);
- {LeadingAttrTerm,PostponedDecArgs} ->
- emit([com,nl,nl]),
- case {LeadingAttrTerm,PostponedDecArgs} of
- {[],[]} ->
- ok;
- {_,[]} ->
- ok;
- {[{ObjSet,LeadingAttr,Term}],PostponedDecArgs} ->
- DecObj = asn1ct_gen:un_hyphen_var(lists:concat(['DecObj',LeadingAttr,Term])),
- ValueMatch = value_match(ValueIndex,Term),
- {ObjSetMod,ObjSetName} =
- case ObjSet of
- {M,O} ->
- {{asis,M},O};
- _ ->
- {"?MODULE",ObjSet}
- end,
- emit([DecObj," =",nl," ",ObjSetMod,":'getdec_",ObjSetName,"'(",
-% {asis,UniqueFName},", ",Term,"),",nl}),
- {asis,UniqueFName},", ",ValueMatch,"),",nl]),
- gen_dec_postponed_decs(DecObj,PostponedDecArgs)
- end,
- demit({"Result = "}), %dbg
- %% return value as record
- asn1ct_name:new(rb),
- asn1ct_name:new(bytes),
- ExtStatus = case Ext of
- {ext,_,_} -> ext;
- _ -> noext % noext | extensible
- end,
- emit([" {",{next,bytes},",",{curr,rb},"} = ?RT_BER:restbytes2(RemBytes, ",
- {curr,bytes},",",ExtStatus,"),",nl]),
- asn1ct_name:new(rb),
- case Typename of
- ['EXTERNAL'] ->
- emit([" OldFormat={'",RecordName,
- "', "]),
- mkvlist(asn1ct_name:all(term)),
- emit(["},",nl]),
- emit([" ASN11994Format =",nl,
- " asn1rt_check:transform_to_EXTERNAL1994",
- "(OldFormat),",nl]),
- emit([" {ASN11994Format,",{next,bytes},", "]);
- _ ->
- emit([" {{'",RecordName,"', "]),
- mkvlist(asn1ct_name:all(term)),
- emit(["}, ",{next,bytes},", "])
- end,
- asn1ct_gen_ber:add_removed_bytes(),
- emit(["}.",nl])
- end.
-
-gen_dec_postponed_decs(_,[]) ->
- emit(nl);
-gen_dec_postponed_decs(DecObj,[{_Cname,{FirstPFN,PFNList},Term,TmpTerm,_Tag,OptOrMand}|Rest]) ->
-% asn1ct_name:new(term),
- asn1ct_name:new(tmpterm),
- asn1ct_name:new(reason),
-
- emit({"{",Term,", _, _} = ",nl}),
- N = case OptOrMand of
- mandatory -> 0;
- 'OPTIONAL' ->
- emit_opt_or_mand_check(asn1_NOVALUE,TmpTerm),
- 6;
- {'DEFAULT',Val} ->
- emit_opt_or_mand_check(Val,TmpTerm),
- 6
- end,
- emit({indent(N+3),"case (catch ",DecObj,"(",{asis,FirstPFN},
-% ", ",TmpTerm,", ", {asis,Tag},", ",{asis,PFNList},")) of",nl}),
- ", ",TmpTerm,", [], ",{asis,PFNList},")) of",nl}),
- emit({indent(N+6),"{'EXIT', ",{curr,reason},"} ->",nl}),
- emit({indent(N+9),"exit({'Type not compatible with table constraint',",
- {curr,reason},"});",nl}),
- emit({indent(N+6),{curr,tmpterm}," ->",nl}),
- emit({indent(N+9),{curr,tmpterm},nl}),
-
- case OptOrMand of
- mandatory -> emit([indent(N+3),"end,",nl]);
- _ ->
- emit([indent(N+3),"end",nl,
- indent(3),"end,",nl])
- end,
-% emit({indent(3),"end,",nl}),
- gen_dec_postponed_decs(DecObj,Rest).
-
-
-emit_opt_or_mand_check(Value,TmpTerm) ->
- emit([indent(3),"case ",TmpTerm," of",nl,
- indent(6),{asis,Value}," -> {",{asis,Value},",[],[]};",nl,
- indent(6),"_ ->",nl]).
-
-%%============================================================================
-%% Encode/decode SET
-%%
-%%============================================================================
-
-gen_encode_set(Erules,Typename,D) when is_record(D,type) ->
- gen_encode_sequence(Erules,Typename,D).
-
-gen_decode_set(Erules,Typename,D) when is_record(D,type) ->
- asn1ct_name:start(),
- asn1ct_name:clear(),
- asn1ct_name:new(term),
- asn1ct_name:new(tag),
- #'SET'{components=TCompList0} = D#type.def,
-
- %% filter away extensionAdditiongroup markers
- TCompList = filter_complist(TCompList0),
- Ext = extensible(TCompList),
- ToOptional = fun(mandatory) ->
- 'OPTIONAL';
- (X) -> X
- end,
- CompList = case TCompList of
- {Rl1,El,Rl2} ->
- Rl1 ++ [X#'ComponentType'{prop=ToOptional(Y)}||X = #'ComponentType'{prop=Y}<-El] ++ Rl2;
- {Rl,El} -> Rl ++ El;
- _ -> TCompList
- end,
-
- emit([" %%-------------------------------------------------",nl]),
- emit([" %% decode tag and length ",nl]),
- emit([" %%-------------------------------------------------",nl]),
-
- asn1ct_name:new(rb),
- MyTag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- D#type.tag]
- ++
- [#tag{class = asn1ct_gen_ber:decode_class('UNIVERSAL'),
- number = asn1ct_gen_ber:decode_type('SET'),
- form = ?CONSTRUCTED,
- type = 'IMPLICIT'}],
- emit([" {{_,Len},",{next,bytes},",",{curr,rb},
- "} = ?RT_BER:check_tags(TagIn ++ ",{asis,MyTag},", ",
- {curr,bytes},", OptOrMand), ",nl]),
- asn1ct_name:new(bytes),
- asn1ct_name:new(len),
- asn1ct_name:new(rb),
-
- emit([" {SetTerm, SetBytes, ",{curr,rb},"} = ?RT_BER:decode_set(0, Len, ",
- {curr,bytes},", OptOrMand, ",
- "fun 'dec_",asn1ct_gen:list2name(Typename),"_fun'/2, []),",nl]),
-
- asn1ct_name:new(rb),
- {ExtFlatten1,ExtFlatten2} =
- case Ext of
- noext -> {"",""};
- _ -> {"lists:flatten(",")"}
- end,
- emit([" 'dec_",asn1ct_gen:list2name(Typename),
- "__result__'(lists:sort(",ExtFlatten1,"SetTerm",ExtFlatten2,"), SetBytes, "]),
- asn1ct_gen_ber:add_removed_bytes(),
- emit([").",nl,nl,nl]),
-
- emit({"%%-------------------------------------------------",nl}),
- emit({"%% Set loop fun for ",asn1ct_gen:list2name(Typename),nl}),
- emit({"%%-------------------------------------------------",nl}),
-
- asn1ct_name:clear(),
- asn1ct_name:new(term),
- emit(["'dec_",asn1ct_gen:list2name(Typename),"_fun'(",{curr,bytes},
- ", OptOrMand) ->",nl]),
-
- asn1ct_name:new(bytes),
- gen_dec_set(Erules,Typename,CompList,1,Ext),
-
- emit([" %% tag not found, if extensionmark we should skip bytes here",nl]),
- emit([indent(6),"_ -> ",nl]),
- case Ext of
- noext ->
- emit([indent(9),"{[], Bytes,0}",nl]);
- _ ->
- asn1ct_name:new(rbCho),
- emit([indent(9),"{RestBytes, ",{curr,rbCho},
- "} = ?RT_BER:skipvalue(Bytes),",nl,
- indent(9),"{[], RestBytes, ",{curr,rbCho},"}",nl])
- end,
- emit([indent(3),"end.",nl,nl,nl]),
-
-
- emit({"%%-------------------------------------------------",nl}),
- emit({"%% Result ",asn1ct_gen:list2name(Typename),nl}),
- emit({"%%-------------------------------------------------",nl}),
-
- asn1ct_name:clear(),
- emit({"'dec_",asn1ct_gen:list2name(Typename),"__result__'(",
- asn1ct_gen_ber:unused_var("TermList",D#type.def),", Bytes, Rb) ->",nl}),
- RecordName = lists:concat([get_record_name_prefix(),
- asn1ct_gen:list2rname(Typename)]),
- case gen_dec_set_result(Erules,Typename,CompList) of
- no_terms ->
- %% return value as record
- asn1ct_name:new(rb),
- emit({" {{'",RecordName,"'}, Bytes, Rb}.",nl});
- _ ->
- emit({nl," case ",{curr,termList}," of",nl}),
- emit({" [] -> {{'",RecordName,"', "}),
- mkvlist(asn1ct_name:all(term)),
- emit({"}, Bytes, Rb};",nl}),
- emit({" ExtraAtt -> exit({error,{asn1,{too_many_attributes, ExtraAtt}}})",nl}),
- emit({" end.",nl}),
- emit({nl,nl,nl})
- end.
-
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Encode/decode SEQUENCE OF and SET OF
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-gen_encode_sof(Erules,Typename,_InnerTypename,D) when is_record(D,type) ->
- asn1ct_name:start(),
- {SeqOrSetOf, Cont} = D#type.def,
-
- Objfun = case D#type.tablecinf of
- [{objfun,_}|_R] ->
- ", ObjFun";
- _ ->
- ""
- end,
-
- emit({" {EncBytes,EncLen} = 'enc_",asn1ct_gen:list2name(Typename),
- "_components'(Val",Objfun,",[],0),",nl}),
-
- MyTag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- D#type.tag]
- ++
- [#tag{class = asn1ct_gen_ber:decode_class('UNIVERSAL'),
- number = asn1ct_gen_ber:decode_type(SeqOrSetOf),
- form = ?CONSTRUCTED,
- type = 'IMPLICIT'}],
-% gen_encode_tags(Erules,MyTag,"EncLen","EncBytes"),
- emit([" ?RT_BER:encode_tags(TagIn ++ ",
- {asis,MyTag},", EncBytes, EncLen).",nl,nl]),
-
- gen_encode_sof_components(Erules,Typename,SeqOrSetOf,Cont).
-% gen_enc_line(Erules,Typename,TypeNameSuffix,Cont,"H",0,
-% mandatory,"{EncBytes,EncLen} = "),
-
-
-gen_decode_sof(Erules,Typename,_InnerTypename,D) when is_record(D,type) ->
- asn1ct_name:start(),
- asn1ct_name:clear(),
- {SeqOrSetOf, TypeTag, Cont} =
- case D#type.def of
- {'SET OF',_Cont} -> {'SET OF','SET',_Cont};
- {'SEQUENCE OF',_Cont} -> {'SEQUENCE OF','SEQUENCE',_Cont}
- end,
- TypeNameSuffix = asn1ct_gen:constructed_suffix(SeqOrSetOf,Cont#type.def),
-
- emit({" %%-------------------------------------------------",nl}),
- emit({" %% decode tag and length ",nl}),
- emit({" %%-------------------------------------------------",nl}),
-
- asn1ct_name:new(rb),
- MyTag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- D#type.tag]
- ++
- [#tag{class = asn1ct_gen_ber:decode_class('UNIVERSAL'),
- number = asn1ct_gen_ber:decode_type(TypeTag),
- form = ?CONSTRUCTED,
- type = 'IMPLICIT'}],
- emit([" {{_,Len},",{next,bytes},",",{curr,rb},
- "} = ?RT_BER:check_tags(TagIn ++ ",{asis,MyTag},", ",
- {curr,bytes},", OptOrMand), ",nl]),
-
- emit([" ?RT_BER:decode_components(",{curr,rb}]),
- InnerType = asn1ct_gen:get_inner(Cont#type.def),
- ContName = case asn1ct_gen:type(InnerType) of
- Atom when is_atom(Atom) -> Atom;
- _ -> TypeNameSuffix
- end,
- emit([", Len, ",{next,bytes},", "]),
-% NewCont =
-% case Cont#type.def of
-% {'ENUMERATED',_,Components}->
-% Cont#type{def={'ENUMERATED',Components}};
-% _ -> Cont
-% end,
- ObjFun =
- case D#type.tablecinf of
- [{objfun,_}|_R] ->
- ", ObjFun";
- _ ->
- []
- end,
- gen_dec_line_sof(Erules,Typename,ContName,Cont,ObjFun),
- emit([", []).",nl,nl,nl]).
-
-
-gen_encode_sof_components(Erules,Typename,SeqOrSetOf,Cont)
- when is_record(Cont,type)->
-
- {Objfun,ObjFun_novar,EncObj} =
- case Cont#type.tablecinf of
- [{objfun,_}|_R] ->
- {", ObjFun",", _",{no_attr,"ObjFun"}};
- _ ->
- {"","",false}
- end,
- emit(["'enc_",asn1ct_gen:list2name(Typename),
- "_components'([]",ObjFun_novar,", AccBytes, AccLen) -> ",nl]),
-
- case catch lists:member(der,get(encoding_options)) of
- true when SeqOrSetOf=='SET OF' ->
- emit([indent(3),
- "{asn1rt_check:dynamicsort_SETOF(AccBytes),AccLen};",nl,nl]);
- _ ->
- emit([indent(3),"{lists:reverse(AccBytes),AccLen};",nl,nl])
- end,
- emit(["'enc_",asn1ct_gen:list2name(Typename),
- "_components'([H|T]",Objfun,",AccBytes, AccLen) ->",nl]),
- TypeNameSuffix = asn1ct_gen:constructed_suffix(SeqOrSetOf,Cont#type.def),
- gen_enc_line(Erules,Typename,TypeNameSuffix,Cont,"H",3,
-% mandatory,"{EncBytes,EncLen} = ",EncObj),
- mandatory,EncObj),
- emit([",",nl]),
- emit([indent(3),"'enc_",asn1ct_gen:list2name(Typename),
- "_components'(T",Objfun,","]),
- emit(["[EncBytes|AccBytes], AccLen + EncLen).",nl,nl]).
-
-%%============================================================================
-%% Encode/decode CHOICE
-%%
-%%============================================================================
-
-gen_encode_choice(Erules,Typename,D) when is_record(D,type) ->
- ChoiceTag = D#type.tag,
- {'CHOICE',CompList} = D#type.def,
- Ext = extensible(CompList),
- CompList1 = case CompList of
- {Rl1,El,Rl2} -> Rl1 ++ El ++ Rl2;
- {Rl,El} -> Rl ++ El;
- _ -> CompList
- end,
- gen_enc_choice(Erules,Typename,ChoiceTag,CompList1,Ext),
- emit({nl,nl}).
-
-gen_decode_choice(Erules,Typename,D) when is_record(D,type) ->
- asn1ct_name:start(),
- asn1ct_name:new(bytes),
- ChoiceTag = D#type.tag,
- {'CHOICE',CompList} = D#type.def,
- Ext = extensible(CompList),
- CompList1 = case CompList of
- {Rl1,El,Rl2} -> Rl1 ++ El ++Rl2;
- {Rl,El} -> Rl ++ El;
- _ -> CompList
- end,
- gen_dec_choice(Erules,Typename,ChoiceTag,CompList1,Ext),
- emit({".",nl}).
-
-
-%%============================================================================
-%% Encode SEQUENCE
-%%
-%%============================================================================
-
-gen_enc_sequence_call(Erules,TopType,[#'ComponentType'{name=Cname,typespec=Type,prop=Prop,textual_order=Order}|Rest],Pos,Ext,EncObj) ->
- asn1ct_name:new(encBytes),
- asn1ct_name:new(encLen),
- CindexPos =
- case Order of
- undefined ->
- Pos;
- _ -> Order % der
- end,
- Element =
- case TopType of
- ['EXTERNAL'] ->
- io_lib:format("?RT_BER:cindex(~w,NewVal,~w)",[CindexPos+1,Cname]);
- _ ->
- io_lib:format("?RT_BER:cindex(~w,Val,~w)",[CindexPos+1,Cname])
- end,
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- print_attribute_comment(InnerType,Pos,Prop),
- gen_enc_line(Erules,TopType,Cname,Type,Element,3,Prop,EncObj),
- case Rest of
- [] ->
- emit({com,nl});
- _ ->
- emit({com,nl}),
- gen_enc_sequence_call(Erules,TopType,Rest,Pos+1,Ext,EncObj)
- end;
-
-gen_enc_sequence_call(_Erules,_TopType,[],_Num,_,_) ->
- true.
-
-%%============================================================================
-%% Decode SEQUENCE
-%%
-%%============================================================================
-
-gen_dec_sequence_call(Erules,TopType,CompList,Ext,DecObjInf)
- when is_list(CompList) ->
- gen_dec_sequence_call1(Erules,TopType, CompList, 1, Ext,DecObjInf,[],[]);
-gen_dec_sequence_call(Erules,TopType,CList,Ext,DecObjInf) ->
- gen_dec_sequence_call2(Erules,TopType,CList,Ext,DecObjInf).
-
-gen_dec_sequence_call1(Erules,TopType,[#'ComponentType'{name=Cname,typespec=Type,prop=Prop,tags=Tags}|Rest],Num,Ext,DecObjInf,LeadingAttrAcc,ArgsAcc) ->
- {LA,PostponedDec} =
- gen_dec_component(Erules,TopType,Cname,Tags,Type,Num,Prop,
- Ext,DecObjInf),
- case Rest of
- [] ->
- {LA ++ LeadingAttrAcc,PostponedDec ++ ArgsAcc};
- _ ->
- emit({com,nl}),
-% asn1ct_name:new(term),
- asn1ct_name:new(bytes),
- gen_dec_sequence_call1(Erules,TopType,Rest,Num+1,Ext,DecObjInf,
- LA++LeadingAttrAcc,PostponedDec++ArgsAcc)
- end;
-
-gen_dec_sequence_call1(_Erules,_TopType,[],1,_,_,_,_) ->
- no_terms.
-
-gen_dec_sequence_call2(_Erules,_TopType,{[],[],[]},_Ext,_DecObjInf) ->
- no_terms;
-gen_dec_sequence_call2(Erules,TopType,{Root1,EList,Root2},_Ext,DecObjInf) ->
- {LA,ArgsAcc} =
- case gen_dec_sequence_call1(Erules,TopType,Root1++EList,1,
- extensible({Root1,EList}),DecObjInf,[],[]) of
- no_terms ->
- {[],[]};
- Res -> Res
- end,
- %% TagList is the tags of Root2 elements from the first up to and
- %% including the first mandatory element.
- TagList = get_root2_taglist(Root2,[]),
- emit({com,nl}),
- asn1ct_name:new(bytes),
- emit([" {",{next,bytes},", ",{next,rb},
- "} = ?RT_BER:skip_ExtensionAdditions(",
- {curr,bytes},", ",{asis,TagList},"),",nl]),
- asn1ct_name:new(rb),
- asn1ct_name:new(bytes),
- gen_dec_sequence_call1(Erules,TopType,Root2,
- length(Root1)+length(EList),noext,
- DecObjInf,LA,ArgsAcc).
-
-%% returns a list of tags of the elements in the component (second
-%% root) list up to and including the first mandatory tag. See 24.6 in
-%% X.680 (7/2002)
-get_root2_taglist([],Acc) ->
- lists:reverse(Acc);
-get_root2_taglist([#'ComponentType'{prop=Prop,typespec=Type}|Rest],Acc) ->
- FirstTag = fun([])->[];
- ([H|_T])->H#tag{class=asn1ct_gen_ber:decode_class(H#tag.class)}
- end(Type#type.tag),
- case Prop of
- mandatory ->
- %% match_tags/ may be used
- %% this is the last tag of interest -> return
- lists:reverse([FirstTag|Acc]);
- _ ->
- get_root2_taglist(Rest,[FirstTag|Acc])
- end.
-
-
-%%----------------------------
-%%SEQUENCE mandatory
-%%----------------------------
-
-gen_dec_component(Erules,TopType,Cname,CTags,Type,Pos,Prop,Ext,DecObjInf) ->
- InnerType =
- case Type#type.def of
- #'ObjectClassFieldType'{type=OCFTType} -> OCFTType;
- _ -> asn1ct_gen:get_inner(Type#type.def)
- end,
-
- Prop1 = case {Prop,Ext} of
- {_,{ext,Epos,_Root2pos}} when Pos < Epos ->
- Prop;
- {mandatory,{ext,Epos,_}} when Pos >= Epos ->
- 'OPTIONAL';
- _ ->
- Prop
- end,
- print_attribute_comment(InnerType,Pos,Prop1),
- emit(" "),
-
- case {InnerType,DecObjInf} of
- {{typefield,_},NotFalse} when NotFalse /= false ->
- asn1ct_name:new(term),
- asn1ct_name:new(tmpterm),
- emit({"{",{curr,tmpterm},", ",{next,bytes},",",{next,rb},"} = "});
- {{objectfield,_,_},_} ->
- asn1ct_name:new(term),
- asn1ct_name:new(tmpterm),
- emit({"{",{curr,tmpterm},", ",{next,bytes},",",{next,rb},"} = "});
- _ ->
- asn1ct_name:new(term),
- emit({"{",{curr,term},",",{next,bytes},",",{next,rb},"} = "})
- end,
- asn1ct_name:new(rb),
- PostponedDec =
- gen_dec_line(Erules,TopType,Cname,CTags,Type,Prop1,DecObjInf),
- asn1ct_name:new(form),
- PostponedDec.
-
-
-%%-------------------------------------
-%% Decode SET
-%%-------------------------------------
-
-gen_dec_set(Erules,TopType,CompList,Pos,Ext) ->
- ExtCatch = case Ext of
- noext ->"";
- _ -> " catch"
- end,
- TagList = get_all_choice_tags(CompList),
- emit({indent(3),
- {curr,tagList}," = ",{asis,TagList},",",nl}),
- emit({indent(3),
- "case",ExtCatch," ?RT_BER:check_if_valid_tag(Bytes, ",
- {curr,tagList},", OptOrMand) of",nl}),
- asn1ct_name:new(tagList),
- asn1ct_name:new(rbCho),
- asn1ct_name:new(choTags),
- gen_dec_set_cases(Erules,TopType,CompList,TagList,Pos),
- asn1ct_name:new(tag),
- asn1ct_name:new(bytes).
-
-
-
-gen_dec_set_cases(_,_,[],_,_) ->
- ok;
-gen_dec_set_cases(Erules,TopType,[H|T],List,Pos) ->
- Name = H#'ComponentType'.name,
- Type = H#'ComponentType'.typespec,
-
- emit({indent(6),"'",Name,"' ->",nl}),
- case Type#type.def of
- {'CHOICE',_NewCompList} ->
- gen_dec_set_cases_choice(Erules,TopType,H,Pos);
- _ ->
- gen_dec_set_cases_type(Erules,TopType,H,Pos)
- end,
- gen_dec_set_cases(Erules,TopType,T,List,Pos+1).
-
-
-
-gen_dec_set_cases_choice(_Erules,TopType,H,Pos) ->
- Cname = H#'ComponentType'.name,
- Tag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}
- || X <- (H#'ComponentType'.typespec)#type.tag],
- asn1ct_name:new(rbCho),
- emit({indent(9),"{Dec, Rest, ",{curr,rbCho},"} = "}),
- emit({"'dec_",asn1ct_gen:list2name([Cname|TopType]),
- "'(Bytes,OptOrMand,",{asis,Tag},"),",nl}),
- emit([" {{",Pos,",Dec}, Rest, ",{curr,rbCho},"}"]),
- emit([";",nl,nl]).
-
-
-gen_dec_set_cases_type(Erules,TopType,H,Pos) ->
- Cname = H#'ComponentType'.name,
- Type = H#'ComponentType'.typespec,
- %% always use Prop = mandatory here Prop = H#'ComponentType'.prop,
-
- asn1ct_name:new(rbCho),
- emit({indent(9),"{Dec, Rest, ",{curr,rbCho},"} = "}),
- asn1ct_name:delete(bytes),
- %% we have already seen the tag so now we must find the value
- %% that why we always use 'mandatory' here
- gen_dec_line(Erules,TopType,Cname,[],Type,mandatory,decObjInf),
- asn1ct_name:new(bytes),
-
- emit([",",nl]),
- emit(["{{",Pos,",Dec}, Rest, ",{curr,rbCho},"}"]),
- emit([";",nl,nl]).
-
-
-%%---------------------------------
-%% Decode SET result
-%%---------------------------------
-
-gen_dec_set_result(Erules,TopType,CompList) ->
- gen_dec_set_result1(Erules,TopType, CompList, 1).
-
-gen_dec_set_result1(Erules,TopType,
- [#'ComponentType'{name=Cname,
- typespec=Type,
- prop=Prop}|Rest],Num) ->
- gen_dec_set_component(Erules,TopType,Cname,Type,Num,Prop),
- case Rest of
- [] ->
- true;
- _ ->
- gen_dec_set_result1(Erules,TopType,Rest,Num+1)
- end;
-
-gen_dec_set_result1(_Erules,_TopType,[],1) ->
- no_terms;
-gen_dec_set_result1(_Erules,_TopType,[],_Num) ->
- true.
-
-
-gen_dec_set_component(_Erules,_TopType,_Cname,Type,Pos,Prop) ->
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- print_attribute_comment(InnerType,Pos,Prop),
- emit({" {",{next,term},com,{next,termList},"} =",nl}),
- emit({" case ",{curr,termList}," of",nl}),
- emit({" [{",Pos,com,{curr,termTmp},"}|",
- {curr,rest},"] -> "}),
- emit({"{",{curr,termTmp},com,
- {curr,rest},"};",nl}),
- case Prop of
- 'OPTIONAL' ->
- emit([indent(10),"_ -> {asn1_NOVALUE, ",{curr,termList},"}",nl]);
- {'DEFAULT', DefVal} ->
- emit([indent(10),
- "_ -> {",{asis,DefVal},", ",{curr,termList},"}",nl]);
- mandatory ->
- emit([indent(10),
- "_ -> exit({error,{asn1,{mandatory_attribute_no, ",
- Pos,", missing}}})",nl])
- end,
- emit([indent(6),"end,",nl]),
- asn1ct_name:new(rest),
- asn1ct_name:new(term),
- asn1ct_name:new(termList),
- asn1ct_name:new(termTmp).
-
-
-%%---------------------------------------------
-%% Encode CHOICE
-%%---------------------------------------------
-%% for BER we currently do care (a little) if the choice has an EXTENSIONMARKER
-
-
-gen_enc_choice(Erules,TopType,Tag,CompList,_Ext) ->
- gen_enc_choice1(Erules,TopType,Tag,CompList,_Ext).
-
-gen_enc_choice1(Erules,TopType,Tag,CompList,_Ext) ->
- asn1ct_name:clear(),
- emit({" {EncBytes,EncLen} = case element(1,Val) of",nl}),
- gen_enc_choice2(Erules,TopType,CompList),
- emit([nl," end,",nl,nl]),
- NewTag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- Tag],
-% gen_encode_tags(Erules,NewTag,"EncLen","EncBytes").
- emit(["?RT_BER:encode_tags(TagIn ++",{asis,NewTag},", EncBytes, EncLen).",nl]).
-
-
-
-gen_enc_choice2(Erules,TopType,[H1|T]) when is_record(H1,'ComponentType') ->
- Cname = H1#'ComponentType'.name,
- Type = H1#'ComponentType'.typespec,
- emit({" ",{asis,Cname}," ->",nl}),
- {Encobj,Assign} =
-% case asn1ct_gen:get_constraint(Type#type.constraint,
-% tableconstraint_info) of
- case {Type#type.def,asn1ct_gen:get_constraint(Type#type.constraint,
- componentrelation)} of
- {#'ObjectClassFieldType'{},{componentrelation,_,_}} ->
- asn1ct_name:new(tmpBytes),
- asn1ct_name:new(encBytes),
- asn1ct_name:new(encLen),
- Emit = ["{",{curr,tmpBytes},", _} = "],
- {{no_attr,"ObjFun"},Emit};
- _ ->
- case Type#type.tablecinf of
- [{objfun,_}] -> {{no_attr,"ObjFun"},[]};
- _-> {false,[]}
- end
- end,
- gen_enc_line(Erules,TopType,Cname,Type,"element(2,Val)",9,
- mandatory,Assign,Encobj),
- case {Type#type.def,Encobj} of
- {#'ObjectClassFieldType'{},{no_attr,"ObjFun"}} ->
- emit({",",nl,indent(9),"{",{curr,encBytes},", ",
- {curr,encLen},"}"});
- _ -> ok
- end,
- emit({";",nl}),
- case T of
- [] ->
- emit([indent(6), "Else -> ",nl,
- indent(9),"exit({error,{asn1,{invalid_choice_type,Else}}})"]);
- _ ->
- true
- end,
- gen_enc_choice2(Erules,TopType,T);
-
-gen_enc_choice2(_,_,[]) ->
- true.
-
-
-
-
-%%--------------------------------------------
-%% Decode CHOICE
-%%--------------------------------------------
-
-gen_dec_choice(Erules,TopType, ChTag, CompList, Ext) ->
- asn1ct_name:delete(bytes),
- Tags = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}|| X <- ChTag],
-
- emit([" {{_,Len},",{next,bytes},
- ", RbExp} = ?RT_BER:check_tags(TagIn++",
- {asis,Tags},", ",
- {curr,bytes},", OptOrMand),",nl]),
- asn1ct_name:new(bytes),
- asn1ct_name:new(len),
- gen_dec_choice_indef_funs(Erules),
- case Erules of
- ber_bin ->
- emit([indent(3),"case ",{curr,bytes}," of",nl]);
- ber ->
- emit([indent(3),
- "case (catch ?RT_BER:peek_tag(",{curr,bytes},")) of",nl])
- end,
- asn1ct_name:new(tagList),
- asn1ct_name:new(choTags),
- gen_dec_choice_cases(Erules,TopType,CompList),
- case Ext of
- noext ->
- emit([indent(6), {curr,else}," -> ",nl]),
- emit([indent(9),"case OptOrMand of",nl,
- indent(12),"mandatory ->","exit({error,{asn1,",
- "{invalid_choice_tag,",{curr,else},"}}});",nl,
- indent(12),"_ ->","exit({error,{asn1,{no_optional_tag,",
- {curr,else},"}}})",nl,
- indent(9),"end",nl]);
- _ ->
- emit([indent(6),"_ -> ",nl]),
- emit([indent(9),"{{asn1_ExtAlt,",{curr,bytes},"},",
- empty_lb(Erules),", RbExp}",nl])
- end,
- emit([indent(3),"end"]),
- asn1ct_name:new(tag),
- asn1ct_name:new(else).
-
-gen_dec_choice_indef_funs(Erules) ->
- emit({indent(3),"IndefEndBytes = fun(indefinite,",indefend_match(Erules,used_var),
- ")-> R; (_,B)-> B end,",nl}),
- emit({indent(3),"IndefEndRb = fun(indefinite,",indefend_match(Erules,unused_var),
- ")-> 2; (_,_)-> 0 end,",nl}).
-
-
-gen_dec_choice_cases(_,_, []) ->
- ok;
-gen_dec_choice_cases(Erules,TopType, [H|T]) ->
- asn1ct_name:push(rbCho),
- Name = H#'ComponentType'.name,
- emit([nl,"%% '",Name,"'",nl]),
- Fcases = fun([T1,T2|Tail],Fun) ->
- emit([indent(6),match_tag(Erules,T1)," ->",nl]),
- gen_dec_choice_cases_type(Erules,TopType, H),
- Fun([T2|Tail],Fun);
- ([T1],_) ->
- emit([indent(6),match_tag(Erules,T1)," ->",nl]),
- gen_dec_choice_cases_type(Erules,TopType, H)
- end,
- Fcases(H#'ComponentType'.tags,Fcases),
- asn1ct_name:pop(rbCho),
- gen_dec_choice_cases(Erules,TopType, T).
-
-
-
-gen_dec_choice_cases_type(Erules,TopType,H) ->
- Cname = H#'ComponentType'.name,
- Type = H#'ComponentType'.typespec,
- Prop = H#'ComponentType'.prop,
- emit({indent(9),"{Dec, Rest, ",{curr,rbCho},"} = "}),
- gen_dec_line(Erules,TopType,Cname,[],Type,Prop,false),
- emit([",",nl,indent(9),"{{",{asis,Cname},
- ", Dec}, IndefEndBytes(Len,Rest), RbExp + ",
- {curr,rbCho}," + IndefEndRb(Len,Rest)};",nl,nl]).
-
-encode_tag_val(Erules,{Class,TagNo}) when is_integer(TagNo) ->
- Rtmod = rtmod(Erules),
- Rtmod:encode_tag_val({asn1ct_gen_ber:decode_class(Class),
- 0,TagNo});
-encode_tag_val(Erules,{Class,TypeName}) ->
- Rtmod = rtmod(Erules),
- Rtmod:encode_tag_val({asn1ct_gen_ber:decode_class(Class),
- 0,asn1ct_gen_ber:decode_type(TypeName)}).
-
-
-match_tag(ber_bin,Arg) ->
- match_tag_with_bitsyntax(Arg);
-match_tag(Erules,Arg) ->
- io_lib:format("~p",[encode_tag_val(Erules,Arg)]).
-
-match_tag_with_bitsyntax({Class,TagNo}) when is_integer(TagNo) ->
- match_tag_with_bitsyntax1({asn1ct_gen_ber:decode_class(Class),
- 0,TagNo});
-match_tag_with_bitsyntax({Class,TypeName}) ->
- match_tag_with_bitsyntax1({asn1ct_gen_ber:decode_class(Class),
- 0,asn1ct_gen_ber:decode_type(TypeName)}).
-
-match_tag_with_bitsyntax1({Class, _Form, TagNo}) when (TagNo =< 30) ->
- io_lib:format("<<~p:2,_:1,~p:5,_/binary>>",[Class bsr 6,TagNo]);
-
-match_tag_with_bitsyntax1({Class, _Form, TagNo}) ->
- {Octets,Len} = mk_object_val(TagNo),
- OctForm = case Len of
- 1 -> "~p";
- 2 -> "~p,~p";
- 3 -> "~p,~p,~p";
- 4 -> "~p,~p,~p,~p"
- end,
- io_lib:format("<<~p:2,_:1,31:5," ++ OctForm ++ ",_/binary>>",
- [Class bsr 6] ++ Octets).
-
-%%%%%%%%%%%
-%% mk_object_val(Value) -> {OctetList, Len}
-%% returns a Val as a list of octets, the 8 bit is allways set to one except
-%% for the last octet, where its 0
-%%
-
-
-mk_object_val(Val) when Val =< 127 ->
- {[255 band Val], 1};
-mk_object_val(Val) ->
- mk_object_val(Val bsr 7, [Val band 127], 1).
-mk_object_val(0, Ack, Len) ->
- {Ack, Len};
-mk_object_val(Val, Ack, Len) ->
- mk_object_val(Val bsr 7, [((Val band 127) bor 128) | Ack], Len + 1).
-
-
-get_all_choice_tags(ComponentTypeList) ->
- get_all_choice_tags(ComponentTypeList,[]).
-
-get_all_choice_tags([],TagList) ->
- TagList;
-get_all_choice_tags([H|T],TagList) ->
- Tags = H#'ComponentType'.tags,
- get_all_choice_tags(T, TagList ++ [{H#'ComponentType'.name, Tags}]).
-
-
-
-%%---------------------------------------
-%% Generate the encode/decode code
-%%---------------------------------------
-
-gen_enc_line(Erules,TopType,Cname,
- Type=#type{constraint=C,
- def=#'ObjectClassFieldType'{type={typefield,_}}},
- Element,Indent,OptOrMand=mandatory,EncObj)
- when is_list(Element) ->
- case asn1ct_gen:get_constraint(C,componentrelation) of
- {componentrelation,_,_} ->
- asn1ct_name:new(tmpBytes),
- gen_enc_line(Erules,TopType,Cname,Type,Element,Indent,OptOrMand,
- ["{",{curr,tmpBytes},",_} = "],EncObj);
- _ ->
- gen_enc_line(Erules,TopType,Cname,Type,Element,Indent,OptOrMand,
- ["{",{curr,encBytes},",",{curr,encLen},"} = "],
- EncObj)
- end;
- gen_enc_line(Erules,TopType,Cname,Type,Element,Indent,OptOrMand,EncObj)
- when is_list(Element) ->
- gen_enc_line(Erules,TopType,Cname,Type,Element,Indent,OptOrMand,
- ["{",{curr,encBytes},",",{curr,encLen},"} = "],EncObj).
-
-gen_enc_line(Erules,TopType,Cname,Type,Element,Indent,OptOrMand,Assign,EncObj)
- when is_list(Element) ->
- IndDeep = indent(Indent),
-
- Tag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}
- || X <- Type#type.tag],
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- WhatKind = asn1ct_gen:type(InnerType),
- emit(IndDeep),
- emit(Assign),
- gen_optormand_case(OptOrMand,Erules,TopType,Cname,Type,InnerType,WhatKind,
- Element),
- case {Type,asn1ct_gen:get_constraint(Type#type.constraint,
- componentrelation)} of
- {#type{def=#'ObjectClassFieldType'{type={typefield,_},
- fieldname=RefedFieldName}},
- {componentrelation,_,_}} ->
- {_LeadingAttrName,Fun} = EncObj,
- case RefedFieldName of
- {Name,RestFieldNames} when is_atom(Name),Name =/= notype ->
- case OptOrMand of
- mandatory -> ok;
- _ ->
- emit(["{",{curr,tmpBytes},", _} = "])
- end,
- emit({Fun,"(",{asis,Name},", ",Element,", [], ",
- {asis,RestFieldNames},"),",nl}),
- emit(IndDeep),
- case OptOrMand of
- mandatory ->
- emit({"{",{curr,encBytes},", ",{curr,encLen},"} = "}),
- emit({"?RT_BER:encode_open_type(",{curr,tmpBytes},
- ",",{asis,Tag},")"});
- _ ->
- emit({"{",{next,tmpBytes},", ",{curr,tmpLen},
- "} = "}),
- emit({"?RT_BER:encode_open_type(",{curr,tmpBytes},
- ",",{asis,Tag},"),",nl}),
- emit(IndDeep),
- emit({"{",{next,tmpBytes},", ",{curr,tmpLen},"}"})
- end;
- Err ->
- throw({asn1,{'internal error',Err}})
- end;
- _ ->
- case WhatKind of
- {primitive,bif} ->
- EncType =
- case Type#type.def of
- #'ObjectClassFieldType'{
- type={fixedtypevaluefield,
- _,Btype}} ->
- Btype;
- _ ->
- Type
- end,
- asn1ct_gen_ber:gen_encode_prim(ber,EncType,{asis,Tag},
- Element);
- 'ASN1_OPEN_TYPE' ->
- asn1ct_gen_ber:gen_encode_prim(ber,Type#type{def='ASN1_OPEN_TYPE'},{asis,Tag},Element);
- _ ->
- {EncFunName, _, _} =
- mkfuncname(TopType,Cname,WhatKind,enc),
- case {WhatKind,Type#type.tablecinf,EncObj} of
- {{constructed,bif},[{objfun,_}|_R],{_,Fun}} ->
- emit([EncFunName,"(",Element,", ",{asis,Tag},
- ", ",Fun,")"]);
- _ ->
- emit([EncFunName,"(",Element,", ",{asis,Tag},")"])
- end
- end
- end,
- case OptOrMand of
- mandatory -> true;
- _ ->
- emit({nl,indent(7),"end"})
- end.
-
-
-
-gen_optormand_case(mandatory,_,_,_,_,_,_, _) ->
- ok;
-gen_optormand_case('OPTIONAL',Erules,_,_,_,_,_,Element) ->
- emit({" case ",Element," of",nl}),
- emit({indent(9),"asn1_NOVALUE -> {",
- empty_lb(Erules),",0};",nl}),
- emit({indent(9),"_ ->",nl,indent(12)});
-gen_optormand_case({'DEFAULT',DefaultValue},Erules,TopType,Cname,Type,
- InnerType,WhatKind,Element) ->
- CurrMod = get(currmod),
- case catch lists:member(der,get(encoding_options)) of
- true ->
- emit(" case catch "),
- asn1ct_gen:gen_check_call(TopType,Cname,Type,InnerType,
- WhatKind,{asis,DefaultValue},
- Element),
- emit({" of",nl}),
- emit({indent(12),"true -> {[],0};",nl});
- _ ->
- emit({" case ",Element," of",nl}),
- emit({indent(9),"asn1_DEFAULT -> {",
- empty_lb(Erules),
- ",0};",nl}),
- case DefaultValue of
- #'Externalvaluereference'{module=CurrMod,
- value=V} ->
- emit({indent(9),"?",{asis,V}," -> {",
- empty_lb(Erules),",0};",nl});
- _ ->
- emit({indent(9),{asis,
- DefaultValue}," -> {",
- empty_lb(Erules),",0};",nl})
- end
- end,
- emit({indent(9),"_ ->",nl,indent(12)}).
-
-
-
-
-gen_dec_line_sof(Erules,TopType,Cname,Type,ObjFun) ->
-
- Tag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}
- || X <- Type#type.tag],
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- WhatKind = asn1ct_gen:type(InnerType),
- case WhatKind of
- {primitive,bif} ->
- asn1ct_name:delete(len),
-
- asn1ct_name:new(len),
- emit(["fun(FBytes,_,_)->",nl]),
- EncType = case Type#type.def of
- #'ObjectClassFieldType'{
- type={fixedtypevaluefield,
- _,Btype}} ->
- Btype;
- _ ->
- Type
- end,
- asn1ct_gen_ber:gen_dec_prim(ber,EncType,"FBytes",Tag,
- [],no_length,?PRIMITIVE,
- mandatory),
- emit([nl,"end, []"]);
- _ ->
- case ObjFun of
- [] ->
- {DecFunName, _, _} =
- mkfunname(Erules,TopType,Cname,WhatKind,dec,3),
- emit([DecFunName,", ",{asis,Tag}]);
- _ ->
- {DecFunName, _, _} =
- mkfunname(Erules,TopType,Cname,WhatKind,dec,4),
- emit([DecFunName,", ",{asis,Tag},", ObjFun"])
- end
- end.
-
-
-gen_dec_line(Erules,TopType,Cname,CTags,Type,OptOrMand,DecObjInf) ->
- BytesVar = asn1ct_gen:mk_var(asn1ct_name:curr(bytes)),
- Tag = [X#tag{class=asn1ct_gen_ber:decode_class(X#tag.class)}
- || X <- Type#type.tag],
- InnerType =
- case Type#type.def of
- #'ObjectClassFieldType'{type=OCFTType} ->
- OCFTType;
- _ ->
- asn1ct_gen:get_inner(Type#type.def)
- end,
- PostpDec =
- case OptOrMand of
- mandatory ->
- gen_dec_call(InnerType,Erules,TopType,Cname,Type,
- BytesVar,Tag,mandatory,", mandatory, ",
- DecObjInf,OptOrMand);
- _ -> %optional or default
- case {CTags,Erules} of
- {[CTag],ber_bin} when CTag =/= [] -> % R9C-0.patch-34
- emit(["case ",{curr,bytes}," of",nl]),
- emit([match_tag(Erules,CTag)," ->",nl]),
- PostponedDec =
- gen_dec_call(InnerType,Erules,TopType,Cname,Type,
- BytesVar,Tag,mandatory,
- ", opt_or_default, ",DecObjInf,
- OptOrMand),
- emit([";",nl]),
- emit(["_ ->",nl]),
- case OptOrMand of
- {'DEFAULT', Def} ->
- emit(["{",{asis,Def},",",
- BytesVar,", 0 }",nl]);
- 'OPTIONAL' ->
- emit(["{ asn1_NOVALUE, ",
- BytesVar,", 0 }",nl])
- end,
- emit("end"),
- PostponedDec;
- _ ->
- emit("case (catch "),
- PostponedDec =
- gen_dec_call(InnerType,Erules,TopType,Cname,Type,
- BytesVar,Tag,OptOrMand,
- ", opt_or_default, ",DecObjInf,
- OptOrMand),
- emit([") of",nl]),
- case OptOrMand of
- {'DEFAULT', Def} ->
- emit(["{'EXIT',{error,{asn1,{no_optional_tag,_}}}}",
- " -> {",{asis,Def},",",
- BytesVar,", 0 };",nl]);
- 'OPTIONAL' ->
- emit(["{'EXIT',{error,{asn1,{no_optional_tag,_}}}}",
- " -> { asn1_NOVALUE, ",
- BytesVar,", 0 };",nl])
- end,
- asn1ct_name:new(casetmp),
- emit([{curr,casetmp},"-> ",{curr,casetmp},nl,"end"]),
- PostponedDec
- end
- end,
- case DecObjInf of
- {Cname,ObjSet} -> % this must be the component were an object is
- %% choosen from the object set according to the table
- %% constraint.
- ObjSetName = case ObjSet of
- {deep,OSName,_,_} ->
- OSName;
- _ -> ObjSet
- end,
- {[{ObjSetName,Cname,asn1ct_gen:mk_var(asn1ct_name:curr(term))}],
- PostpDec};
- _ -> {[],PostpDec}
- end.
-
-
-gen_dec_call({typefield,_},Erules,_,_,Type,_,Tag,_,_,false,_) ->
- %% this in case of a choice with typefield components
- asn1ct_name:new(reason),
- {FirstPFName,RestPFName} =
-% asn1ct_gen:get_constraint(Type#type.constraint,
-% tableconstraint_info),
- (Type#type.def)#'ObjectClassFieldType'.fieldname,
- emit([nl,indent(6),"begin",nl]),
- emit([indent(9),"{OpenDec,TmpRest,TmpRbCho} =",nl,indent(12),
- "?RT_BER:decode_open_type(",Erules,",",{curr,bytes},",",
- {asis,Tag},"),",nl]),
- emit([indent(9),"case (catch ObjFun(",{asis,FirstPFName},
- ", OpenDec, [], ",{asis,RestPFName},
- ")) of", nl]),%% ??? What about Tag
- emit([indent(12),"{'EXIT',",{curr,reason},"} ->",nl]),
-%% emit({indent(15),"throw({runtime_error,{'Type not ",
-%% "compatible with tableconstraint', OpenDec}});",nl}),
- emit([indent(15),"exit({'Type not ",
- "compatible with table constraint', ",{curr,reason},"});",nl]),
- emit([indent(12),"{TmpDec,_ ,_} ->",nl]),
- emit([indent(15),"{TmpDec, TmpRest, TmpRbCho}",nl]),
- emit([indent(9),"end",nl,indent(6),"end",nl]),
- [];
-gen_dec_call({typefield,_},_Erules,_,Cname,Type,_BytesVar,Tag,_,_,
- _DecObjInf,OptOrMandComp) ->
- emit(["?RT_BER:decode_open_type(",{curr,bytes},",",{asis,Tag},")"]),
- RefedFieldName =
- (Type#type.def)#'ObjectClassFieldType'.fieldname,
-% asn1ct_gen:get_constraint(Type#type.constraint,
-% tableconstraint_info),
- [{Cname,RefedFieldName,
- asn1ct_gen:mk_var(asn1ct_name:curr(term)),
-% asn1ct_gen:mk_var(asn1ct_name:curr(tmpterm)),[],OptOrMandComp}];
- asn1ct_gen:mk_var(asn1ct_name:curr(tmpterm)),Tag,OptOrMandComp}];
-gen_dec_call({objectfield,PrimFieldName,PFNList},_Erules,_,Cname,_,_,Tag,_,_,_,
- OptOrMandComp) ->
- emit(["?RT_BER:decode_open_type(",{curr,bytes},",",{asis,Tag},")"]),
- [{Cname,{PrimFieldName,PFNList},
- asn1ct_gen:mk_var(asn1ct_name:curr(term)),
-% asn1ct_gen:mk_var(asn1ct_name:curr(tmpterm)),[],OptOrMandComp}];
- asn1ct_gen:mk_var(asn1ct_name:curr(tmpterm)),Tag,OptOrMandComp}];
-gen_dec_call(InnerType,Erules,TopType,Cname,Type,BytesVar,Tag,PrimOptOrMand,
- OptOrMand,DecObjInf,_) ->
- WhatKind = asn1ct_gen:type(InnerType),
- gen_dec_call1(WhatKind,InnerType,Erules,TopType,Cname,Type,BytesVar,Tag,
- PrimOptOrMand,OptOrMand),
- case DecObjInf of
- {Cname,{_,OSet,UniqueFName,ValIndex}} ->
- Term = asn1ct_gen:mk_var(asn1ct_name:curr(term)),
- ValueMatch = value_match(ValIndex,Term),
- {ObjSetMod,ObjSetName} =
- case OSet of
- {M,O} ->
- {{asis,M},O};
- _ ->
- {"?MODULE",OSet}
- end,
- emit({",",nl,"ObjFun = ",ObjSetMod,":'getdec_",ObjSetName,"'(",
- {asis,UniqueFName},", ",ValueMatch,")"});
- _ ->
- ok
- end,
- [].
-gen_dec_call1({primitive,bif},InnerType,Erules,_,_,Type,BytesVar,
- Tag,OptOrMand,_) ->
- case InnerType of
- {fixedtypevaluefield,_,Btype} ->
- asn1ct_gen_ber:gen_dec_prim(Erules,Btype,BytesVar,Tag,[],no_length,
- ?PRIMITIVE,OptOrMand);
- _ ->
- asn1ct_gen_ber:gen_dec_prim(Erules,Type,BytesVar,Tag,[],no_length,
- ?PRIMITIVE,OptOrMand)
- end;
-gen_dec_call1('ASN1_OPEN_TYPE',_InnerType,Erules,_,_,Type,BytesVar,
- Tag,OptOrMand,_) ->
- asn1ct_gen_ber:gen_dec_prim(Erules,Type#type{def='ASN1_OPEN_TYPE'},
- BytesVar,Tag,[],no_length,
- ?PRIMITIVE,OptOrMand);
-gen_dec_call1(WhatKind,_,_Erules,TopType,Cname,Type,_,Tag,_,OptOrMand) ->
- {DecFunName,_,_} =
- mkfuncname(TopType,Cname,WhatKind,dec),
- case {WhatKind,Type#type.tablecinf} of
- {{constructed,bif},[{objfun,_}|_R]} ->
- emit({DecFunName,"(",{curr,bytes},OptOrMand,{asis,Tag},", ObjFun)"});
- _ ->
- emit({DecFunName,"(",{curr,bytes},OptOrMand,{asis,Tag},")"})
- end.
-
-
-%%------------------------------------------------------
-%% General and special help functions (not exported)
-%%------------------------------------------------------
-
-
-indent(N) ->
- lists:duplicate(N,32). % 32 = space
-
-
-mkvlist([H,T1|T], Sep) -> % Sep is a string e.g ", " or "+ "
- emit([{var,H},Sep]),
- mkvlist([T1|T], Sep);
-mkvlist([H|T], Sep) ->
- emit([{var,H}]),
- mkvlist(T, Sep);
-mkvlist([], _) ->
- true.
-
-mkvlist(L) ->
- mkvlist(L,", ").
-
-mkvplus(L) ->
- mkvlist(L," + ").
-
-extensible(CompList) when is_list(CompList) ->
- noext;
-extensible({RootList,ExtList}) ->
- {ext,length(RootList)+1,length(ExtList)};
-extensible({_Rl1,_ExtL,_Rl2}) ->
- extensible.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% filter away ExtensionAdditionGroup start and end marks since these
-%% have no significance for the BER encoding
-%%
-filter_complist(CompList) when is_list(CompList) ->
- lists:filter(fun(#'ExtensionAdditionGroup'{}) ->
- false;
- ('ExtensionAdditionGroupEnd') ->
- false;
- (_) ->
- true
- end, CompList);
-filter_complist({Root,Ext}) ->
- {Root,filter_complist(Ext)};
-filter_complist({Root1,Ext,Root2}) ->
- {Root1,filter_complist(Ext),Root2}.
-
-print_attribute_comment(InnerType,Pos,Prop) ->
- CommentLine = "%%-------------------------------------------------",
- emit([nl,CommentLine]),
- case InnerType of
- {typereference,_,Name} ->
- emit([nl,"%% attribute number ",Pos," with type ",Name]);
- {'Externaltypereference',_,XModule,Name} ->
- emit([nl,"%% attribute number ",Pos," External ",XModule,":",Name]);
- _ ->
- emit([nl,"%% attribute number ",Pos," with type ",InnerType])
- end,
- case Prop of
- mandatory ->
- continue;
- {'DEFAULT', Def} ->
- emit([" DEFAULT = ",{asis,Def}]);
- 'OPTIONAL' ->
- emit([" OPTIONAL"])
- end,
- emit([nl,CommentLine,nl]).
-
-
-mkfuncname(TopType,Cname,WhatKind,DecOrEnc) ->
- CurrMod = get(currmod),
- case WhatKind of
- #'Externaltypereference'{module=CurrMod,type=EType} ->
- F = lists:concat(["'",DecOrEnc,"_",EType,"'"]),
- {F, "?MODULE", F};
- #'Externaltypereference'{module=Mod,type=EType} ->
- {lists:concat(["'",Mod,"':'",DecOrEnc,"_",EType,"'"]),Mod,
- lists:concat(["'",DecOrEnc,"_",EType,"'"])};
- {constructed,bif} ->
- F = lists:concat(["'",DecOrEnc,"_",asn1ct_gen:list2name([Cname|TopType]),"'"]),
- {F, "?MODULE", F}
- end.
-
-mkfunname(Erule,TopType,Cname,WhatKind,DecOrEnc,Arity) ->
- CurrMod = get(currmod),
- case WhatKind of
- #'Externaltypereference'{module=CurrMod,type=EType} ->
- F = lists:concat(["fun '",DecOrEnc,"_",EType,"'/",Arity]),
- {F, "?MODULE", F};
- #'Externaltypereference'{module=Mod,type=EType} ->
- {lists:concat(["fun '",Mod,"':'",DecOrEnc,"_",EType,"'/",Arity]),Mod,
- lists:concat(["'",DecOrEnc,"_",EType,"'"])};
- {constructed,bif} ->
- F =
- lists:concat(["fun '",DecOrEnc,"_",
- asn1ct_gen:list2name([Cname|TopType]),"'/",
- Arity]),
- {F, "?MODULE", F};
- 'ASN1_OPEN_TYPE' ->
- case Arity of
- 3 ->
- F = lists:concat(["fun(A,_,C) -> ?RT_BER:decode_open_type(",Erule,",A,C) end"]),
- {F, "?MODULE", F};
- 4 ->
- F = lists:concat(["fun(A,_,C,_) -> ?RT_BER:decode_open_type(",Erule,",A,C) end"]),
- {F, "?MODULE", F}
- end
- end.
-
-empty_lb(ber) ->
- "[]";
-empty_lb(ber_bin) ->
- "<<>>".
-
-rtmod(ber) ->
- list_to_atom(?RT_BER_BIN);
-rtmod(ber_bin) ->
- list_to_atom(?RT_BER_BIN).
-
-indefend_match(ber,used_var) ->
- "[0,0|R]";
-indefend_match(ber,unused_var) ->
- "[0,0|_R]";
-indefend_match(ber_bin,used_var) ->
- "<<0,0,R/binary>>";
-indefend_match(ber_bin,unused_var) ->
- "<<0,0,_R/binary>>".
-
-notice_value_match() ->
- Module = get(currmod),
- put(value_match,{true,Module}).
-
-value_match(Index,Value) when is_atom(Value) ->
- value_match(Index,atom_to_list(Value));
-value_match([],Value) ->
- Value;
-value_match([{VI,_Cname}|VIs],Value) ->
- value_match1(Value,VIs,lists:concat(["element(",VI,","]),1).
-value_match1(Value,[],Acc,Depth) ->
- Acc ++ Value ++ lists:concat(lists:duplicate(Depth,")"));
-value_match1(Value,[{VI,_Cname}|VIs],Acc,Depth) ->
- value_match1(Value,VIs,Acc++lists:concat(["element(",VI,","]),Depth+1).
diff --git a/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl b/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
index 2c4b44996d..78cb9297d8 100644
--- a/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1ct_constructed_ber_bin_v2.erl
@@ -32,7 +32,6 @@
-include("asn1_records.hrl").
-import(asn1ct_gen, [emit/1,demit/1,get_record_name_prefix/0]).
--import(asn1ct_constructed_ber,[match_tag/2]).
-define(ASN1CT_GEN_BER,asn1ct_gen_ber_bin_v2).
@@ -913,7 +912,7 @@ gen_dec_choice_cases(Erules,TopType, [H|T]) ->
[DecTag],Type}),
asn1ct:update_gen_state(namelist,Names),
emit([indent(4),{curr,res}," = ",
- match_tag(ber_bin,{FirstT#tag.class,FirstT#tag.number}),
+ match_tag(FirstT#tag.class, FirstT#tag.number),
" -> ",nl]),
emit([indent(8),"{",{asis,Cname},", {'",
asn1ct_gen:list2name([Cname|TopType]),"',",
@@ -928,7 +927,25 @@ gen_dec_choice_cases(Erules,TopType, [H|T]) ->
end,
gen_dec_choice_cases(Erules,TopType, T).
+match_tag(Class, TagNo) when is_integer(TagNo) ->
+ match_tag1(asn1ct_gen_ber_bin_v2:decode_class(Class), TagNo).
+match_tag1(Class, TagNo) when TagNo =< 30 ->
+ io_lib:format("<<~p:2,_:1,~p:5,_/binary>>", [Class bsr 6,TagNo]);
+match_tag1(Class, TagNo) ->
+ Octets = mk_object_val(TagNo),
+ io_lib:format("<<~p:2,_:1,31:5,~s,_/binary>>", [Class bsr 6,Octets]).
+
+mk_object_val(Val) when Val < 16#80 ->
+ integer_to_list(Val);
+mk_object_val(Val) ->
+ mk_object_val(Val bsr 7, [integer_to_list(Val band 16#7F)]).
+
+mk_object_val(0, Acc) ->
+ Acc;
+mk_object_val(Val, Acc) ->
+ I = integer_to_list((Val band 16#7F) bor 16#80),
+ mk_object_val(Val bsr 7, [I,","|Acc]).
%%---------------------------------------
%% Generate the encode/decode code
@@ -1493,10 +1510,6 @@ mkfuncname(TopType,Cname,WhatKind,Prefix,Suffix) ->
end.
empty_lb(ber) ->
- "[]";
-empty_lb(ber_bin) ->
- "<<>>";
-empty_lb(ber_bin_v2) ->
"<<>>".
value_match(Index,Value) when is_atom(Value) ->
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl
index 8de41a4dd4..e4e0e064e8 100644
--- a/lib/asn1/src/asn1ct_constructed_per.erl
+++ b/lib/asn1/src/asn1ct_constructed_per.erl
@@ -80,9 +80,7 @@ gen_encode_constructed(Erule,Typename,D) when is_record(D,type) ->
"compiler warning for unused vars!",nl,
"_Val = ",{curr,val},",",nl]);
{[],_,_} ->
- emit([{next,val}," = ?RT_PER:list_to_record("]),
- emit(["'",asn1ct_gen:list2rname(Typename),"'"]),
- emit([", ",{curr,val},"),",nl]);
+ emit([{next,val}," = ",{curr,val},",",nl]);
{_,_,true} ->
gen_fixoptionals(Optionals),
FixOpts = param_map(fun(Var) ->
@@ -155,7 +153,7 @@ gen_encode_constructed(Erule,Typename,D) when is_record(D,type) ->
emit([ObjectEncode," = ",nl]),
emit([" ",ObjSetMod,":'getenc_",ObjSetName,"'(",
{asis,UniqueFieldName},", ",nl]),
- El = make_element(N+1,asn1ct_gen:mk_var(asn1ct_name:curr(val)),AttrN),
+ El = make_element(N+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))),
Length = fun(X,_LFun) when is_atom(X) ->
length(atom_to_list(X));
@@ -583,8 +581,7 @@ gen_encode_sof_components(Erule,Typename,SeqOrSetOf,Cont) ->
Conttype = asn1ct_gen:get_inner(Cont#type.def),
Currmod = get(currmod),
- Ctgenmod = list_to_atom(lists:concat(["asn1ct_gen_",per,
- asn1ct_gen:rt2ct_suffix()])),
+ Ctgenmod = asn1ct_gen:ct_gen_module(Erule),
case asn1ct_gen:type(Conttype) of
{primitive,bif} ->
gen_encode_prim_wrapper(Ctgenmod,Erule,Cont,false,"H");
@@ -622,8 +619,7 @@ gen_decode_sof_components(Erule,Typename,SeqOrSetOf,Cont) ->
Constructed_Suffix = asn1ct_gen:constructed_suffix(SeqOrSetOf,
Cont#type.def),
Conttype = asn1ct_gen:get_inner(Cont#type.def),
- Ctgenmod = list_to_atom(lists:concat(["asn1ct_gen_",per,
- asn1ct_gen:rt2ct_suffix()])),
+ Ctgenmod = asn1ct_gen:ct_gen_module(Erule),
CurrMod = get(currmod),
case asn1ct_gen:type(Conttype) of
{primitive,bif} ->
@@ -889,7 +885,7 @@ gen_enc_components_call1(_Erule,_TopType,[],Pos,_,_,_) ->
Pos.
gen_enc_component_default(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext,DefaultVal) ->
- Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val)),Cname),
+ Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))),
emit({"case ",Element," of",nl}),
% emit({"asn1_DEFAULT -> [];",nl}),
emit({"DFLT when DFLT == asn1_DEFAULT; DFLT == ",{asis,DefaultVal}," -> [];",nl}),
@@ -909,7 +905,7 @@ gen_enc_component_optional(Erule,TopType,Cname,
components=_ExtGroupCompList}},
Pos,DynamicEnc,Ext) when is_integer(Number) ->
- Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val)),Cname),
+ Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))),
emit({"case ",Element," of",nl}),
emit({"asn1_NOVALUE -> [];",nl}),
@@ -922,7 +918,7 @@ gen_enc_component_optional(Erule,TopType,Cname,
gen_enc_line(Erule,TopType,Cname,Type,NextElement, Pos,DynamicEnc,Ext),
emit({nl,"end"});
gen_enc_component_optional(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext) ->
- Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val)),Cname),
+ Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))),
emit({"case ",Element," of",nl}),
emit({"asn1_NOVALUE -> [];",nl}),
@@ -942,11 +938,10 @@ gen_enc_component_mandatory(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext) ->
gen_enc_line(Erule,TopType,Cname,Type,[],Pos,DynamicEnc,Ext).
gen_enc_line(Erule,TopType, Cname, Type, [], Pos,DynamicEnc,Ext) ->
- Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val)),Cname),
+ Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))),
gen_enc_line(Erule,TopType,Cname,Type,Element, Pos,DynamicEnc,Ext);
gen_enc_line(Erule,TopType,Cname,Type,Element, _Pos,DynamicEnc,Ext) ->
- Ctgenmod = list_to_atom(lists:concat(["asn1ct_gen_",per,
- asn1ct_gen:rt2ct_suffix()])),
+ Ctgenmod = asn1ct_gen:ct_gen_module(Erule),
Atype =
case Type of
#type{def=#'ObjectClassFieldType'{type=InnerType}} ->
@@ -1214,8 +1209,7 @@ gen_dec_component_no_val({ext,_,_},mandatory) ->
gen_dec_line(Erule,TopType,Cname,Type,Pos,DecInfObj,Ext,Prop) ->
- Ctgenmod = list_to_atom(lists:concat(["asn1ct_gen_",per,
- asn1ct_gen:rt2ct_suffix()])),
+ Ctgenmod = asn1ct_gen:ct_gen_module(Erule),
Atype =
case Type of
#type{def=#'ObjectClassFieldType'{type=InnerType}} ->
@@ -1578,22 +1572,17 @@ gen_encode_prim_wrapper(CtgenMod,Erule,Cont,DoTag,Value) ->
make_elements(I,Val,ExtCnames) ->
make_elements(I,Val,ExtCnames,[]).
-make_elements(I,Val,[ExtCname],Acc)-> % the last one, no comma needed
- Element = make_element(I,Val,ExtCname),
+make_elements(I,Val,[_ExtCname],Acc)-> % the last one, no comma needed
+ Element = make_element(I, Val),
make_elements(I+1,Val,[],[Element|Acc]);
-make_elements(I,Val,[ExtCname|Rest],Acc)->
- Element = make_element(I,Val,ExtCname),
+make_elements(I,Val,[_ExtCname|Rest],Acc)->
+ Element = make_element(I, Val),
make_elements(I+1,Val,Rest,[", ",Element|Acc]);
make_elements(_I,_,[],Acc) ->
lists:reverse(Acc).
-make_element(I,Val,Cname) ->
- case tuple_notation_allowed() of
- true ->
- io_lib:format("?RT_PER:cindex(~w,~s,~w)",[I,Val,Cname]);
- _ ->
- io_lib:format("element(~w,~s)",[I,Val])
- end.
+make_element(I, Val) ->
+ io_lib:format("element(~w,~s)", [I,Val]).
emit_extaddgroupTerms(VarSeries,[_]) ->
asn1ct_name:new(VarSeries),
@@ -1651,10 +1640,6 @@ wrap_extensionAdditionGroups([],_,Acc,_,_) ->
lists:reverse(Acc).
-tuple_notation_allowed() ->
- Options = get(encoding_options),
- not (lists:member(optimize,Options) orelse lists:member(uper_bin,Options)).
-
wrap_gen_dec_line(Erule,C,TopType,Cname,Type,Pos,DIO,Ext) ->
put(component_type,{true,C}),
gen_dec_line(Erule,TopType,Cname,Type,Pos,DIO,Ext,mandatory),
@@ -1683,7 +1668,5 @@ notice_value_match() ->
Module = get(currmod),
put(value_match,{true,Module}).
-is_optimized(per_bin) ->
- lists:member(optimize,get(encoding_options));
-is_optimized(_Erule) ->
- false.
+is_optimized(per) -> true;
+is_optimized(uper) -> false.
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index 64a3555f62..b0990e92cf 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -37,8 +37,7 @@
gen_check_call/7,
get_constraint/2,
insert_once/2,
- rt2ct_suffix/1,
- rt2ct_suffix/0,
+ ct_gen_module/1,
index2suffix/1,
get_record_name_prefix/0]).
-export([pgen/5,
@@ -52,7 +51,7 @@
%% pgen(Outfile, Erules, Module, TypeOrVal, Options)
%% Generate Erlang module (.erl) and (.hrl) file corresponding to an ASN.1 module
%% .hrl file is only generated if necessary
-%% Erules = per | ber | ber_bin | per_bin
+%% Erules = per | ber
%% Module = atom()
%% TypeOrVal = {TypeList,ValueList}
%% TypeList = ValueList = [atom()]
@@ -83,7 +82,7 @@ pgen_module(OutFile,Erules,Module,
pgen_exports(Erules,Module,TypeOrVal),
pgen_dispatcher(Erules,Module,TypeOrVal),
pgen_info(),
- pgen_typeorval(wrap_ber(Erules),Module,N2nConvEnums,TypeOrVal),
+ pgen_typeorval(Erules,Module,N2nConvEnums,TypeOrVal),
pgen_partial_incomplete_decode(Erules),
% gen_vars(asn1_db:mod_to_vars(Module)),
% gen_tag_table(AllTypes),
@@ -92,8 +91,7 @@ pgen_module(OutFile,Erules,Module,
pgen_typeorval(Erules,Module,N2nConvEnums,{Types,Values,_Ptypes,_Classes,Objects,ObjectSets}) ->
- Rtmod = list_to_atom(lists:concat(["asn1ct_gen_",erule(Erules),
- rt2ct_suffix(Erules)])),
+ Rtmod = ct_gen_module(Erules),
pgen_types(Rtmod,Erules,N2nConvEnums,Module,Types),
pgen_values(Erules,Module,Values),
pgen_objects(Rtmod,Erules,Module,Objects),
@@ -196,7 +194,7 @@ pgen_check_defaultval(Erules,Module) ->
end,
gen_check_defaultval(Erules,Module,CheckObjects).
-pgen_partial_decode(Rtmod,Erule,Module) when Erule == ber_bin_v2 ->
+pgen_partial_decode(Rtmod,Erule,Module) when Erule == ber ->
pgen_partial_inc_dec(Rtmod,Erule,Module),
pgen_partial_dec(Rtmod,Erule,Module);
pgen_partial_decode(_,_,_) ->
@@ -240,7 +238,7 @@ pgen_partial_inc_dec1(Rtmod,Erules,Module,[P|Ps]) ->
pgen_partial_inc_dec1(_,_,_,[]) ->
ok.
-gen_partial_inc_dec_refed_funcs(Rtmod,Erule) when Erule == ber_bin_v2 ->
+gen_partial_inc_dec_refed_funcs(Rtmod,Erule) when Erule == ber ->
case asn1ct:next_refed_func() of
[] ->
ok;
@@ -296,8 +294,7 @@ pgen_partial_types1(_,undefined) ->
%% TypeList a decode function will be generated.
traverse_type_structure(Erules,Type,[],FuncName,TopTypeName) ->
%% this is the selected type
- Ctmod = list_to_atom(lists:concat(["asn1ct_gen_",erule(Erules),
- rt2ct_suffix(Erules)])),
+ Ctmod = ct_gen_module(Erules),
TypeDef =
case Type of
#type{} ->
@@ -457,7 +454,7 @@ pgen_partial_incomplete_decode(Erule) ->
_ ->
ok
end.
-pgen_partial_incomplete_decode1(ber_bin_v2) ->
+pgen_partial_incomplete_decode1(ber) ->
case asn1ct:read_config_data(partial_incomplete_decode) of
undefined ->
ok;
@@ -552,20 +549,17 @@ gen_part_decode_funcs(WhatKind,_TypeName,{_,Directive,_,_}) ->
gen_types(Erules,Tname,{RootL1,ExtList,RootL2})
when is_list(RootL1), is_list(RootL2) ->
gen_types(Erules,Tname,RootL1),
- Rtmod = list_to_atom(lists:concat(["asn1ct_gen_",erule(Erules),
- rt2ct_suffix(Erules)])),
+ Rtmod = ct_gen_module(Erules),
gen_types(Erules,Tname,Rtmod:extaddgroup2sequence(ExtList)),
gen_types(Erules,Tname,RootL2);
gen_types(Erules,Tname,{RootList,ExtList}) when is_list(RootList) ->
gen_types(Erules,Tname,RootList),
- Rtmod = list_to_atom(lists:concat(["asn1ct_gen_",erule(Erules),
- rt2ct_suffix(Erules)])),
+ Rtmod = ct_gen_module(Erules),
gen_types(Erules,Tname,Rtmod:extaddgroup2sequence(ExtList));
gen_types(Erules,Tname,[{'EXTENSIONMARK',_,_}|Rest]) ->
gen_types(Erules,Tname,Rest);
gen_types(Erules,Tname,[ComponentType|Rest]) ->
- Rtmod = list_to_atom(lists:concat(["asn1ct_gen_",erule(Erules),
- rt2ct_suffix(Erules)])),
+ Rtmod = ct_gen_module(Erules),
asn1ct_name:clear(),
Rtmod:gen_encode(Erules,Tname,ComponentType),
asn1ct_name:clear(),
@@ -574,8 +568,7 @@ gen_types(Erules,Tname,[ComponentType|Rest]) ->
gen_types(_,_,[]) ->
true;
gen_types(Erules,Tname,Type) when is_record(Type,type) ->
- Rtmod = list_to_atom(lists:concat(["asn1ct_gen_",erule(Erules),
- rt2ct_suffix(Erules)])),
+ Rtmod = ct_gen_module(Erules),
asn1ct_name:clear(),
Rtmod:gen_encode(Erules,Tname,Type),
asn1ct_name:clear(),
@@ -754,8 +747,7 @@ gen_value(Value) when is_record(Value,valuedef) ->
emit([{asis,V},".",nl,nl]).
gen_encode_constructed(Erules,Typename,InnerType,D) when is_record(D,type) ->
-
- Rtmod = list_to_atom(lists:concat(["asn1ct_constructed_",erule(Erules)])),
+ Rtmod = ct_constructed_module(Erules),
case InnerType of
'SET' ->
Rtmod:gen_encode_set(Erules,Typename,D),
@@ -787,7 +779,7 @@ gen_encode_constructed(Erules,Typename,InnerType,D)
gen_encode_constructed(Erules,Typename,InnerType,D#typedef.typespec).
gen_decode_constructed(Erules,Typename,InnerType,D) when is_record(D,type) ->
- Rtmod = list_to_atom(lists:concat(["asn1ct_constructed_",erule(Erules)])),
+ Rtmod = ct_constructed_module(Erules),
asn1ct:step_in_constructed(), %% updates namelist for exclusive decode
case InnerType of
'SET' ->
@@ -818,27 +810,11 @@ pgen_exports(Erules,_Module,{Types,Values,_,_,Objects,ObjectSets}) ->
case Erules of
ber ->
gen_exports1(Types,"enc_",2);
- ber_bin ->
- gen_exports1(Types,"enc_",2);
- ber_bin_v2 ->
- gen_exports1(Types,"enc_",2);
_ ->
gen_exports1(Types,"enc_",1)
end,
emit({"-export([",nl}),
- gen_exports1(Types,"dec_",2),
- case Erules of
- ber ->
- emit({"-export([",nl}),
- gen_exports1(Types,"dec_",3);
- ber_bin ->
- emit({"-export([",nl}),
- gen_exports1(Types,"dec_",3);
-% ber_bin_v2 ->
-% emit({"-export([",nl}),
-% gen_exports1(Types,"dec_",2);
- _ -> ok
- end
+ gen_exports1(Types,"dec_",2)
end,
case [X || {n2n,X} <- get(encoding_options)] of
[] -> ok;
@@ -863,16 +839,11 @@ pgen_exports(Erules,_Module,{Types,Values,_,_,Objects,ObjectSets}) ->
gen_exports1(Objects,"enc_",3),
emit({"-export([",nl}),
gen_exports1(Objects,"dec_",4);
- ber_bin_v2 ->
+ ber ->
emit({"-export([",nl}),
gen_exports1(Objects,"enc_",3),
emit({"-export([",nl}),
- gen_exports1(Objects,"dec_",3);
- _ ->
- emit({"-export([",nl}),
- gen_exports1(Objects,"enc_",4),
- emit({"-export([",nl}),
- gen_exports1(Objects,"dec_",4)
+ gen_exports1(Objects,"dec_",3)
end
end,
case ObjectSets of
@@ -948,20 +919,17 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
emit(["encoding_rule() ->",nl]),
emit([" ",{asis,Erules},".",nl,nl]),
NoFinalPadding = lists:member(no_final_padding,get(encoding_options)),
- Call = case Erules of
- per -> "?RT_PER:complete(encode_disp(Type,Data))";
- per_bin -> ["?RT_PER:complete(encode_disp(Type,Data))"];
- ber -> "encode_disp(Type,Data)";
- ber_bin -> "encode_disp(Type,Data)";
- ber_bin_v2 -> "encode_disp(Type,Data)";
- uper_bin when NoFinalPadding == true ->
- "?RT_PER:complete_NFP(encode_disp(Type,Data))";
- uper_bin -> ["?RT_PER:complete(encode_disp(Type,Data))"]
- end,
- EncWrap = case Erules of
- ber -> "wrap_encode(Bytes)";
- _ -> "Bytes"
- end,
+ {Call,BytesAsBinary} =
+ case Erules of
+ per ->
+ {["?RT_PER:complete(encode_disp(Type,Data))"],"Bytes"};
+ ber ->
+ {"encode_disp(Type,Data)","iolist_to_binary(Bytes)"};
+ uper when NoFinalPadding == true ->
+ {"?RT_PER:complete_NFP(encode_disp(Type,Data))","Bytes"};
+ uper ->
+ {["?RT_PER:complete(encode_disp(Type,Data))"],"Bytes"}
+ end,
emit(["encode(Type,Data) ->",nl,
"case catch ",Call," of",nl,
" {'EXIT',{error,Reason}} ->",nl,
@@ -969,42 +937,25 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
" {'EXIT',Reason} ->",nl,
" {error,{asn1,Reason}};",nl,
" {Bytes,_Len} ->",nl,
- " {ok,",EncWrap,"};",nl]),
- case Erules of
- per ->
- emit([" Bytes when is_binary(Bytes) ->",nl,
- " {ok,binary_to_list(Bytes)};",nl,
- " Bytes ->",nl,
- " {ok,binary_to_list(list_to_binary(Bytes))}",nl,
- " end.",nl,nl]);
- _ ->
- emit([" Bytes ->",nl,
- " {ok,",EncWrap,"}",nl,
- "end.",nl,nl])
- end,
-
-% case Erules of
-% ber_bin_v2 ->
-% emit(["decode(Type,Data0) ->",nl]),
-% emit(["{Data,_RestBin} = ?RT_BER:decode(Data0",nif_parameter(),"),",nl]);
-% _ ->
-% emit(["decode(Type,Data) ->",nl])
-% end,
+ " {ok,",BytesAsBinary,"};",nl,
+ " Bytes ->",nl,
+ " {ok,",BytesAsBinary,"}",nl,
+ "end.",nl,nl]),
Return_rest = lists:member(undec_rest,get(encoding_options)),
Data = case {Erules,Return_rest} of
- {ber_bin_v2,true} -> "Data0";
+ {ber,true} -> "Data0";
_ -> "Data"
end,
emit(["decode(Type,",Data,") ->",nl]),
DecAnonymous =
case {Erules,Return_rest} of
- {ber_bin_v2,false} ->
+ {ber,false} ->
io_lib:format("~s~s~s~n",
["element(1,?RT_BER:decode(Data",
nif_parameter(),"))"]);
- {ber_bin_v2,true} ->
+ {ber,true} ->
emit(["{Data,Rest} = ?RT_BER:decode(Data0",
nif_parameter(),"),",nl]),
"Data";
@@ -1012,10 +963,8 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
"Data"
end,
DecWrap = case Erules of
- ber -> "wrap_decode(Data)";
- ber_bin_v2 ->
+ ber ->
DecAnonymous;
- per -> "list_to_binary(Data)";
_ -> "Data"
end,
@@ -1025,32 +974,18 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
" {'EXIT',Reason} ->",nl,
" {error,{asn1,Reason}};",nl]),
case {Erules,Return_rest} of
- {ber_bin_v2,false} ->
+ {ber,false} ->
emit([" Result ->",nl,
" {ok,Result}",nl]);
- {ber_bin_v2,true} ->
+ {ber,true} ->
emit([" Result ->",nl,
" {ok,Result,Rest}",nl]);
- {per,false} ->
- emit([" {X,_Rest} ->",nl,
- " {ok,if_binary2list(X)};",nl,
- " {X,_Rest,_Len} ->",nl,
- " {ok,if_binary2list(X)}",nl]);
{_,false} ->
emit([" {X,_Rest} ->",nl,
" {ok,X};",nl,
" {X,_Rest,_Len} ->",nl,
" {ok,X}",nl]);
- {per,true} ->
- emit([" {X,{_,Rest}} ->",nl,
- " {ok,if_binary2list(X),Rest};",nl,
- " {X,{_,Rest},_Len} ->",nl,
- " {ok,if_binary2list(X),Rest};",nl,
- " {X,Rest} ->",nl,
- " {ok,if_binary2list(X),Rest};",nl,
- " {X,Rest,_Len} ->",nl,
- " {ok,if_binary2list(X),Rest}",nl]);
- {per_bin,true} ->
+ {per,true} ->
emit([" {X,{_,Rest}} ->",nl,
" {ok,X,Rest};",nl,
" {X,{_,Rest},_Len} ->",nl,
@@ -1059,7 +994,7 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
" {ok,X,Rest};",nl,
" {X,Rest,_Len} ->",nl,
" {ok,X,Rest}",nl]);
- {uper_bin,true} ->
+ {uper,true} ->
emit([" {X,{_,Rest}} ->",nl,
" {ok,X,Rest};",nl,
" {X,{_,Rest},_Len} ->",nl,
@@ -1067,34 +1002,14 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
" {X,Rest} ->",nl,
" {ok,X,Rest};",nl,
" {X,Rest,_Len} ->",nl,
- " {ok,X,Rest}",nl]);
- _ ->
- emit([" {X,Rest} ->",nl,
- " {ok,X,Rest};",nl,
- " {X,Rest,_Len} ->",nl,
" {ok,X,Rest}",nl])
end,
emit(["end.",nl,nl]),
- case Erules of
- per ->
- emit(["if_binary2list(B) when is_binary(B) ->",nl,
- " binary_to_list(B);",nl,
- "if_binary2list(L) -> L.",nl,nl]);
- _ ->
- ok
- end,
-
gen_decode_partial_incomplete(Erules),
case Erules of
ber ->
- gen_dispatcher(Types,"encode_disp","enc_",",[]"),
- gen_dispatcher(Types,"decode_disp","dec_",",mandatory");
- ber_bin ->
- gen_dispatcher(Types,"encode_disp","enc_",",[]"),
- gen_dispatcher(Types,"decode_disp","dec_",",mandatory");
- ber_bin_v2 ->
gen_dispatcher(Types,"encode_disp","enc_",""),
gen_dispatcher(Types,"decode_disp","dec_",""),
gen_partial_inc_dispatcher();
@@ -1103,17 +1018,10 @@ pgen_dispatcher(Erules,_Module,{Types,_Values,_,_,_Objects,_ObjectSets}) ->
gen_dispatcher(Types,"decode_disp","dec_",",mandatory")
end,
emit([nl]),
-
- case Erules of
- ber ->
- gen_wrapper();
- _ -> ok
- end,
emit({nl,nl}).
-gen_decode_partial_incomplete(Erule) when Erule == ber;Erule==ber_bin;
- Erule==ber_bin_v2 ->
+gen_decode_partial_incomplete(ber) ->
case {asn1ct:read_config_data(partial_incomplete_decode),
asn1ct:get_gen_state_field(inc_type_pattern)} of
{undefined,_} ->
@@ -1121,34 +1029,35 @@ gen_decode_partial_incomplete(Erule) when Erule == ber;Erule==ber_bin;
{_,undefined} ->
ok;
_ ->
- case Erule of
- ber_bin_v2 ->
- EmitCaseClauses =
- fun() ->
- emit([" {'EXIT',{error,Reason}} ->",nl,
- " {error,Reason};",nl,
- " {'EXIT',Reason} ->",nl,
- " {error,{asn1,Reason}};",nl,
- " Result ->",nl,
- " {ok,Result}",nl,
- " end.",nl,nl])
- end,
- emit(["decode_partial_incomplete(Type,Data0,",
- "Pattern) ->",nl]),
- emit([" {Data,_RestBin} =",nl,
- " ?RT_BER:decode_primitive_",
- "incomplete(Pattern,Data0),",nl,
- " case catch decode_partial_inc_disp(Type,",
- "Data) of",nl]),
- EmitCaseClauses(),
- emit(["decode_part(Type,Data0) ->",nl]),
- emit([" case catch decode_inc_disp(Type,element(1,"
- "?RT_BER:decode(Data0",nif_parameter(),"))) of",nl]),
-% " {Data,_RestBin} = ?RT_BER:decode(Data0),",nl,
-% " case catch decode_inc_disp(Type,Data) of",nl]),
- EmitCaseClauses();
- _ -> ok % add later
- end
+ EmitCaseClauses =
+ fun() ->
+ emit([" {'EXIT',{error,Reason}} ->",nl,
+ " {error,Reason};",nl,
+ " {'EXIT',Reason} ->",nl,
+ " {error,{asn1,Reason}};",nl,
+ " Result ->",nl,
+ " {ok,Result}",nl,
+ " end"])
+ end,
+ emit(["decode_partial_incomplete(Type,Data0,",
+ "Pattern) ->",nl]),
+ emit([" {Data,_RestBin} =",nl,
+ " ?RT_BER:decode_primitive_",
+ "incomplete(Pattern,Data0),",nl,
+ " case catch decode_partial_inc_disp(Type,",
+ "Data) of",nl]),
+ EmitCaseClauses(),
+ emit([".",nl,nl]),
+ emit(["decode_part(Type, Data0) "
+ "when is_binary(Data0) ->",nl]),
+ emit([" case catch decode_inc_disp(Type,element(1,"
+ "?RT_BER:decode(Data0",nif_parameter(),"))) of",nl]),
+ EmitCaseClauses(),
+ emit([";",nl]),
+ emit(["decode_part(Type, Data0) ->",nl]),
+ emit([" case catch decode_inc_disp(Type, Data0) of",nl]),
+ EmitCaseClauses(),
+ emit([".",nl,nl])
end;
gen_decode_partial_incomplete(_Erule) ->
ok.
@@ -1187,23 +1096,8 @@ gen_partial_inc_dispatcher([],_) ->
" exit({error,{asn1,{undefined_type,Type}}}).",nl]).
nif_parameter() ->
- Options = get(encoding_options),
- case {lists:member(driver,Options),lists:member(nif,Options)} of
- {true,_} -> ",nif";
- {_,true} -> ",nif";
- _ -> ""
- end.
+ ",nif".
-gen_wrapper() ->
- emit(["wrap_encode(Bytes) when is_list(Bytes) ->",nl,
- " binary_to_list(list_to_binary(Bytes));",nl,
- "wrap_encode(Bytes) when is_binary(Bytes) ->",nl,
- " binary_to_list(Bytes);",nl,
- "wrap_encode(Bytes) -> Bytes.",nl,nl]),
- emit(["wrap_decode(Bytes) when is_list(Bytes) ->",nl,
- " list_to_binary(Bytes);",nl,
- "wrap_decode(Bytes) -> Bytes.",nl]).
-
gen_dispatcher([F1,F2|T],FuncName,Prefix,ExtraArg) ->
emit([FuncName,"('",F1,"',Data) -> '",Prefix,F1,"'(Data",ExtraArg,")",";",nl]),
gen_dispatcher([F2|T],FuncName,Prefix,ExtraArg);
@@ -1213,19 +1107,16 @@ gen_dispatcher([Flast|_T],FuncName,Prefix,ExtraArg) ->
pgen_info() ->
emit(["info() ->",nl,
- " case ?MODULE:module_info() of",nl,
- " MI when is_list(MI) ->",nl,
- " case lists:keysearch(attributes,1,MI) of",nl,
- " {value,{_,Attributes}} when is_list(Attributes) ->",nl,
- " case lists:keysearch(asn1_info,1,Attributes) of",nl,
- " {value,{_,Info}} when is_list(Info) ->",nl,
- " Info;",nl,
- " _ ->",nl,
- " []",nl,
- " end;",nl,
- " _ ->",nl,
- " []",nl,
- " end",nl,
+ " case ?MODULE:module_info(attributes) of",nl,
+ " Attributes when is_list(Attributes) ->",nl,
+ " case lists:keyfind(asn1_info, 1, Attributes) of",nl,
+ " {_,Info} when is_list(Info) ->",nl,
+ " Info;",nl,
+ " _ ->",nl,
+ " []",nl,
+ " end;",nl,
+ " _ ->",nl,
+ " []",nl,
" end.",nl]).
open_hrl(OutFile,Module) ->
@@ -1496,32 +1387,15 @@ gen_head(Erules,Mod,Hrl) ->
{Rtmac,Rtmod} = case Erules of
per ->
emit({"%% Generated by the Erlang ASN.1 PER-"
- "compiler version:",asn1ct:vsn(),nl}),
- {"RT_PER",?RT_PER_BIN};
- ber ->
- emit({"%% Generated by the Erlang ASN.1 BER-"
- "compiler version:",asn1ct:vsn(),nl}),
- {"RT_BER",?RT_BER_BIN};
- per_bin ->
- emit({"%% Generated by the Erlang ASN.1 BER-"
- "compiler version, utilizing bit-syntax:",
- asn1ct:vsn(),nl}),
- %% temporary code to enable rt2ct optimization
- case lists:member(optimize,Options) of
- true -> {"RT_PER","asn1rt_per_bin_rt2ct"};
- _ -> {"RT_PER",?RT_PER_BIN}
- end;
- ber_bin ->
- emit({"%% Generated by the Erlang ASN.1 BER-"
"compiler version, utilizing bit-syntax:",
asn1ct:vsn(),nl}),
- {"RT_BER",?RT_BER_BIN};
- ber_bin_v2 ->
+ {"RT_PER","asn1rt_per_bin_rt2ct"};
+ ber ->
emit({"%% Generated by the Erlang ASN.1 BER_V2-"
"compiler version, utilizing bit-syntax:",
asn1ct:vsn(),nl}),
{"RT_BER","asn1rt_ber_bin_v2"};
- uper_bin ->
+ uper ->
emit(["%% Generated by the Erlang ASN.1 UNALIGNED"
" PER-compiler version, utilizing"
" bit-syntax:",
@@ -1541,7 +1415,7 @@ gen_head(Erules,Mod,Hrl) ->
emit(["-define('",Rtmac,"',",Rtmod,").",nl]),
emit(["-asn1_info([{vsn,'",asn1ct:vsn(),"'},",nl,
" {module,'",Mod,"'},",nl,
- " {options,",io_lib:format("~w",[Options]),"}]).",nl,nl]).
+ " {options,",io_lib:format("~p",[Options]),"}]).",nl,nl]).
gen_hrlhead(Mod) ->
@@ -2019,43 +1893,29 @@ constructed_suffix('SEQUENCE OF',_) ->
constructed_suffix('SET OF',_) ->
'SETOF'.
-erule(ber) ->
- ber;
-erule(ber_bin) ->
- ber;
-erule(ber_bin_v2) ->
- ber_bin_v2;
-erule(per) ->
- per;
-erule(per_bin) ->
- per;
-erule(uper_bin) ->
- per.
-
-wrap_ber(ber) ->
- ber_bin;
-wrap_ber(Erule) ->
- Erule.
-
-rt2ct_suffix() ->
- Options = get(encoding_options),
- case {lists:member(optimize,Options),lists:member(per_bin,Options)} of
- {true,true} -> "_rt2ct";
- _ -> ""
- end.
-rt2ct_suffix(per_bin) ->
- Options = get(encoding_options),
- case lists:member(optimize,Options) of
- true -> "_rt2ct";
- _ -> ""
- end;
-rt2ct_suffix(_) -> "".
+erule(ber) -> ber;
+erule(per) -> per;
+erule(uper) -> per.
index2suffix(0) ->
"";
index2suffix(N) ->
lists:concat(["_",N]).
+ct_gen_module(ber) ->
+ asn1ct_gen_ber_bin_v2;
+ct_gen_module(per) ->
+ asn1ct_gen_per_rt2ct;
+ct_gen_module(uper) ->
+ asn1ct_gen_per.
+
+ct_constructed_module(ber) ->
+ asn1ct_constructed_ber_bin_v2;
+ct_constructed_module(per) ->
+ asn1ct_constructed_per;
+ct_constructed_module(uper) ->
+ asn1ct_constructed_per.
+
get_constraint(C,Key) ->
case lists:keysearch(Key,1,C) of
false ->
diff --git a/lib/asn1/src/asn1ct_gen_ber.erl b/lib/asn1/src/asn1ct_gen_ber.erl
deleted file mode 100644
index 491ebcb8fd..0000000000
--- a/lib/asn1/src/asn1ct_gen_ber.erl
+++ /dev/null
@@ -1,1749 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
-%%
-%% The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-%%
--module(asn1ct_gen_ber).
-
-%% Generate erlang module which handles (PER) encode and decode for
-%% all types in an ASN.1 module
-
--include("asn1_records.hrl").
-
--export([pgen/4]).
--export([decode_class/1, decode_type/1]).
--export([add_removed_bytes/0]).
--export([gen_encode/2,gen_encode/3,gen_decode/2,gen_decode/3]).
--export([gen_encode_prim/4]).
--export([gen_dec_prim/8]).
--export([gen_objectset_code/2, gen_obj_code/3]).
--export([re_wrap_erule/1]).
--export([unused_var/2]).
--export([extaddgroup2sequence/1]).
-
--import(asn1ct_gen, [emit/1,demit/1]).
-
- % the encoding of class of tag bits 8 and 7
--define(UNIVERSAL, 0).
--define(APPLICATION, 16#40).
--define(CONTEXT, 16#80).
--define(PRIVATE, 16#C0).
-
- % primitive or constructed encoding % bit 6
--define(PRIMITIVE, 0).
--define(CONSTRUCTED, 2#00100000).
-
-
--define(T_ObjectDescriptor, ?UNIVERSAL bor ?PRIMITIVE bor 7).
- % restricted character string types
--define(T_NumericString, ?UNIVERSAL bor ?PRIMITIVE bor 18). %can be constructed
--define(T_PrintableString, ?UNIVERSAL bor ?PRIMITIVE bor 19). %can be constructed
--define(T_TeletexString, ?UNIVERSAL bor ?PRIMITIVE bor 20). %can be constructed
--define(T_VideotexString, ?UNIVERSAL bor ?PRIMITIVE bor 21). %can be constructed
--define(T_IA5String, ?UNIVERSAL bor ?PRIMITIVE bor 22). %can be constructed
--define(T_GraphicString, ?UNIVERSAL bor ?PRIMITIVE bor 25). %can be constructed
--define(T_VisibleString, ?UNIVERSAL bor ?PRIMITIVE bor 26). %can be constructed
--define(T_GeneralString, ?UNIVERSAL bor ?PRIMITIVE bor 27). %can be constructed
-
-%% pgen(Erules, Module, TypeOrVal)
-%% Generate Erlang module (.erl) and (.hrl) file corresponding to an ASN.1 module
-%% .hrl file is only generated if necessary
-%% Erules = per | ber
-%% Module = atom()
-%% TypeOrVal = {TypeList,ValueList,PTypeList}
-%% TypeList = ValueList = [atom()]
-
-pgen(OutFile,Erules,Module,TypeOrVal) ->
- asn1ct_gen:pgen_module(OutFile,Erules,Module,TypeOrVal,[],true).
-
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Generate ENCODING
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-%%===============================================================================
-%% encode #{typedef, {pos, name, typespec}}
-%%===============================================================================
-
-gen_encode(Erules,Type) when is_record(Type,typedef) ->
- gen_encode_user(Erules,Type).
-
-%%===============================================================================
-%% encode #{type, {tag, def, constraint}}
-%%===============================================================================
-
-gen_encode(Erules,Typename,Type) when is_record(Type,type) ->
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- ObjFun =
- case lists:keysearch(objfun,1,Type#type.tablecinf) of
- {value,{_,_Name}} ->
- ", ObjFun";
- false ->
- ""
- end,
- case asn1ct_gen:type(InnerType) of
- {constructed,bif} ->
- emit([nl,nl,nl,"%%================================"]),
- emit([nl,"%% ",asn1ct_gen:list2name(Typename)]),
- emit([nl,"%%================================",nl]),
- case lists:member(InnerType,['SET','SEQUENCE']) of
- true ->
- case get(asn_keyed_list) of
- true ->
- CompList =
- case Type#type.def of
- #'SEQUENCE'{components=Cl} -> Cl;
- #'SET'{components=Cl} -> Cl
- end,
- emit([nl,"'enc_",asn1ct_gen:list2name(Typename),
- "'(Val, TagIn",ObjFun,
- ") when is_list(Val) ->",nl]),
- emit([" 'enc_",asn1ct_gen:list2name(Typename),
- "'(?RT_BER:fixoptionals(",
- {asis,optionals(CompList)},
- ",Val), TagIn",ObjFun,");",nl,nl]);
- _ -> true
- end;
- _ ->
- emit([nl,"'enc_",asn1ct_gen:list2name(Typename),
- "'({'",asn1ct_gen:list2name(Typename),
- "',Val}, TagIn",ObjFun,") ->",nl]),
- emit([" 'enc_",asn1ct_gen:list2name(Typename),
- "'(Val, TagIn",ObjFun,");",nl,nl])
- end,
- emit(["'enc_",asn1ct_gen:list2name(Typename),
- "'(Val, TagIn",ObjFun,") ->",nl," "]),
- asn1ct_gen:gen_encode_constructed(Erules,Typename,InnerType,Type);
- _ ->
- true
- end;
-
-%%===============================================================================
-%% encode ComponentType
-%%===============================================================================
-
-gen_encode(Erules,Tname,#'ComponentType'{name=Cname,typespec=Type}) ->
- NewTname = [Cname|Tname],
- %% The tag is set to [] to avoid that it is
- %% taken into account twice, both as a component/alternative (passed as
- %% argument to the encode decode function and within the encode decode
- %% function it self.
- NewType = Type#type{tag=[]},
- gen_encode(Erules,NewTname,NewType).
-
-gen_encode_user(Erules,D) when is_record(D,typedef) ->
- Typename = [D#typedef.name],
- Type = D#typedef.typespec,
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit([nl,nl,"%%================================"]),
- emit([nl,"%% ",Typename]),
- emit([nl,"%%================================",nl]),
- case lists:member(InnerType,['SET','SEQUENCE']) of
- true ->
- case get(asn_keyed_list) of
- true ->
- CompList =
- case Type#type.def of
- #'SEQUENCE'{components=Cl} -> Cl;
- #'SET'{components=Cl} -> Cl
- end,
-
- emit([nl,"'enc_",asn1ct_gen:list2name(Typename),
- "'(Val, TagIn) when is_list(Val) ->",nl]),
- emit([" 'enc_",asn1ct_gen:list2name(Typename),
- "'(?RT_BER:fixoptionals(",
- {asis,optionals(CompList)},
- ",Val), TagIn);",nl,nl]);
- _ -> true
- end;
- _ ->
- emit({nl,"'enc_",asn1ct_gen:list2name(Typename),
- "'({'",asn1ct_gen:list2name(Typename),"',Val}, TagIn) ->",nl}),
- emit({" 'enc_",asn1ct_gen:list2name(Typename),"'(Val, TagIn);",nl,nl})
- end,
- emit({"'enc_",asn1ct_gen:list2name(Typename),"'(",
- unused_var("Val",Type#type.def),", TagIn) ->",nl}),
- CurrentMod = get(currmod),
- case asn1ct_gen:type(InnerType) of
- {constructed,bif} ->
- asn1ct_gen:gen_encode_constructed(Erules,Typename,InnerType,D);
- {primitive,bif} ->
- asn1ct_gen_ber:gen_encode_prim(ber,Type,["TagIn ++ ",
- {asis,Tag}],"Val"),
- emit([".",nl]);
- #typereference{val=Ename} ->
- emit([" 'enc_",Ename,"'(Val, TagIn ++ ",{asis,Tag},").",nl]);
- #'Externaltypereference'{module=CurrentMod,type=Etype} ->
- emit([" 'enc_",Etype,"'(Val, TagIn ++ ",
- {asis,Tag},").",nl]);
- #'Externaltypereference'{module=Emod,type=Etype} ->
- emit([" '",Emod,"':'enc_",Etype,"'(Val, TagIn ++ ",
- {asis,Tag},").",nl]);
- 'ASN1_OPEN_TYPE' ->
- emit(["%% OPEN TYPE",nl]),
- asn1ct_gen_ber:gen_encode_prim(ber,
- Type#type{def='ASN1_OPEN_TYPE'},
- ["TagIn ++ ",
- {asis,Tag}],"Val"),
- emit([".",nl])
- end.
-
-unused_var(Var,#'SEQUENCE'{components=Cl}) ->
- unused_var1(Var,Cl);
-unused_var(Var,#'SET'{components=Cl}) ->
- unused_var1(Var,Cl);
-unused_var(Var,_) ->
- Var.
-unused_var1(Var,Cs) when Cs == []; Cs == {[],[]} ->
- lists:concat(["_",Var]);
-unused_var1(Var,_) ->
- Var.
-
-unused_optormand_var(Var,Def) ->
- case asn1ct_gen:type(asn1ct_gen:get_inner(Def)) of
- 'ASN1_OPEN_TYPE' ->
- lists:concat(["_",Var]);
- _ ->
- Var
- end.
-
-
-gen_encode_prim(Erules,D,DoTag,Value) when is_record(D,type) ->
-
-%%% Currently not used for BER (except for BitString) and therefore replaced
-%%% with [] as a placeholder
- BitStringConstraint = D#type.constraint,
- Constraint = [],
- asn1ct_name:new(enumval),
- case D#type.def of
- 'BOOLEAN' ->
- emit_encode_func('boolean',Value,DoTag);
- 'INTEGER' ->
- emit_encode_func('integer',Constraint,Value,DoTag);
- {'INTEGER',NamedNumberList} ->
- emit_encode_func('integer',Constraint,Value,
- NamedNumberList,DoTag);
- {'ENUMERATED',NamedNumberList={_,_}} ->
-
- emit(["case (case ",Value," of {_,",{curr,enumval},"}->",
- {curr,enumval},";_->", Value," end) of",nl]),
- asn1ct_name:new(enumval),
- emit_enc_enumerated_cases(NamedNumberList,DoTag);
- {'ENUMERATED',NamedNumberList} ->
-
- emit(["case (case ",Value," of {_,",{curr,enumval},"}->",
- {curr,enumval},";_->", Value," end) of",nl]),
- asn1ct_name:new(enumval),
- emit_enc_enumerated_cases(NamedNumberList,DoTag);
-
- 'REAL' ->
- emit_encode_func('real',Constraint,Value,DoTag);
-
- {'BIT STRING',NamedNumberList} ->
- emit_encode_func('bit_string',BitStringConstraint,Value,
- NamedNumberList,DoTag);
- 'ANY' ->
- emit_encode_func('open_type', Value,DoTag);
- 'NULL' ->
- emit_encode_func('null',Value,DoTag);
- 'OBJECT IDENTIFIER' ->
- emit_encode_func("object_identifier",Value,DoTag);
- 'RELATIVE-OID' ->
- emit_encode_func("relative_oid",Value,DoTag);
- 'ObjectDescriptor' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_ObjectDescriptor,DoTag);
- 'OCTET STRING' ->
- emit_encode_func('octet_string',Constraint,Value,DoTag);
- 'NumericString' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_NumericString,DoTag);
- TString when TString == 'TeletexString';
- TString == 'T61String' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_TeletexString,DoTag);
- 'VideotexString' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_VideotexString,DoTag);
- 'GraphicString' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_GraphicString,DoTag);
- 'VisibleString' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_VisibleString,DoTag);
- 'GeneralString' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_GeneralString,DoTag);
- 'PrintableString' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_PrintableString,DoTag);
- 'IA5String' ->
- emit_encode_func('restricted_string',Constraint,Value,
- ?T_IA5String,DoTag);
- 'UniversalString' ->
- emit_encode_func('universal_string',Constraint,Value,DoTag);
- 'UTF8String' ->
- emit_encode_func('UTF8_string',Constraint,Value,DoTag);
- 'BMPString' ->
- emit_encode_func('BMP_string',Constraint,Value,DoTag);
- 'UTCTime' ->
- emit_encode_func('utc_time',Constraint,Value,DoTag);
- 'GeneralizedTime' ->
- emit_encode_func('generalized_time',Constraint,Value,DoTag);
- 'ASN1_OPEN_TYPE' ->
- emit_encode_func('open_type', Value,DoTag);
- #'ObjectClassFieldType'{} ->
- case asn1ct_gen:get_inner(D#type.def) of
- {fixedtypevaluefield,_,InnerType} ->
- gen_encode_prim(Erules,InnerType,DoTag,Value);
- 'ASN1_OPEN_TYPE' ->
- emit_encode_func('open_type', Value,DoTag);
- XX ->
- exit({'can not encode' ,XX})
- end;
- XX ->
- exit({'can not encode' ,XX})
- end.
-
-
-emit_encode_func(Name,Value,Tags) when is_atom(Name) ->
- emit_encode_func(atom_to_list(Name),Value,Tags);
-emit_encode_func(Name,Value,Tags) ->
- Fname = "?RT_BER:encode_" ++ Name,
- emit([Fname,"(",Value,", ",Tags,")"]).
-
-emit_encode_func(Name,Constraint,Value,Tags) when is_atom(Name) ->
- emit_encode_func(atom_to_list(Name),Constraint,Value,Tags);
-emit_encode_func(Name,Constraint,Value,Tags) ->
- Fname = "?RT_BER:encode_" ++ Name,
- emit([Fname,"(",{asis,Constraint},", ",Value,", ",Tags,")"]).
-
-emit_encode_func(Name,Constraint,Value,Asis,Tags) when is_atom(Name) ->
- emit_encode_func(atom_to_list(Name),Constraint,Value,Asis,Tags);
-emit_encode_func(Name,Constraint,Value,Asis,Tags) ->
- Fname = "?RT_BER:encode_" ++ Name,
- emit([Fname,"(",{asis,Constraint},", ",Value,
- ", ",{asis,Asis},
- ", ",Tags,")"]).
-
-emit_enc_enumerated_cases({L1,L2}, Tags) ->
- emit_enc_enumerated_cases(L1++L2, Tags, ext);
-emit_enc_enumerated_cases(L, Tags) ->
- emit_enc_enumerated_cases(L, Tags, noext).
-
-emit_enc_enumerated_cases([{EnumName,EnumVal},H2|T], Tags, Ext) ->
- emit([{asis,EnumName}," -> ?RT_BER:encode_enumerated(",EnumVal,",",Tags,");",nl]),
-%% emit(["'",{asis,EnumName},"' -> ?RT_BER:encode_enumerated(",EnumVal,",",Tags,");",nl]),
- emit_enc_enumerated_cases([H2|T], Tags, Ext);
-emit_enc_enumerated_cases([{EnumName,EnumVal}], Tags, Ext) ->
- emit([{asis,EnumName}," -> ?RT_BER:encode_enumerated(",EnumVal,",",Tags,")"]),
-%% emit(["'",{asis,EnumName},"' -> ?RT_BER:encode_enumerated(",EnumVal,",",Tags,")"]),
- case Ext of
- noext -> emit([";",nl]);
- ext ->
-%% emit([";",nl,"{asn1_enum,",{curr,enumval},"} -> ",
-%% "?RT_BER:encode_enumerated(",{curr,enumval},",",Tags,");",nl]),
-%% asn1ct_name:new(enumval)
- emit([";",nl])
- end,
- emit([{curr,enumval}," -> exit({error,{asn1, {enumerated_not_in_range,",{curr, enumval},"}}})"]),
- emit([nl,"end"]).
-
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Generate DECODING
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-%%===============================================================================
-%% decode #{typedef, {pos, name, typespec}}
-%%===============================================================================
-
-gen_decode(Erules,Type) when is_record(Type,typedef) ->
- D = Type,
- emit({nl,nl}),
- emit({"'dec_",Type#typedef.name,"'(Bytes, OptOrMand) ->",nl}),
- emit({" 'dec_",Type#typedef.name,"'(Bytes, OptOrMand, []).",nl,nl}),
- emit({"'dec_",Type#typedef.name,"'(Bytes, ",
- unused_optormand_var("OptOrMand",(Type#typedef.typespec)#type.def),", TagIn) ->",nl}),
- dbdec(Type#typedef.name),
- gen_decode_user(Erules,D).
-
-
-%%===============================================================================
-%% decode #{type, {tag, def, constraint}}
-%%===============================================================================
-
-gen_decode(Erules,Tname,Type) when is_record(Type,type) ->
- Typename = Tname,
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- case asn1ct_gen:type(InnerType) of
- {constructed,bif} ->
- ObjFun =
- case Type#type.tablecinf of
- [{objfun,_}|_R] ->
- ", ObjFun";
- _ ->
- ""
- end,
- emit({"'dec_",asn1ct_gen:list2name(Typename),"'(Bytes, OptOrMand, TagIn",ObjFun,") ->",nl}),
- dbdec(Typename),
- asn1ct_gen:gen_decode_constructed(Erules,Typename,InnerType,Type);
- _ ->
- true
- end;
-
-
-%%===============================================================================
-%% decode ComponentType
-%%===============================================================================
-
-gen_decode(Erules,Tname,#'ComponentType'{name=Cname,typespec=Type}) ->
- NewTname = [Cname|Tname],
- %% The tag is set to [] to avoid that it is
- %% taken into account twice, both as a component/alternative (passed as
- %% argument to the encode decode function and within the encode decode
- %% function it self.
- NewType = Type#type{tag=[]},
- gen_decode(Erules,NewTname,NewType).
-
-
-gen_decode_user(Erules,D) when is_record(D,typedef) ->
- Typename = [D#typedef.name],
- Def = D#typedef.typespec,
- InnerType = asn1ct_gen:get_inner(Def#type.def),
- InnerTag = Def#type.tag ,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- InnerTag],
- case asn1ct_gen:type(InnerType) of
- 'ASN1_OPEN_TYPE' ->
- BytesVar = asn1ct_gen:mk_var(asn1ct_name:curr(bytes)),
- asn1ct_name:new(len),
- gen_dec_prim(Erules, Def#type{def='ASN1_OPEN_TYPE'},
- BytesVar, Tag, "TagIn",no_length,
- ?PRIMITIVE,"OptOrMand"),
- emit({".",nl,nl});
- {primitive,bif} ->
- BytesVar = asn1ct_gen:mk_var(asn1ct_name:curr(bytes)),
- asn1ct_name:new(len),
- gen_dec_prim(Erules, Def, BytesVar, Tag, "TagIn",no_length,
- ?PRIMITIVE,"OptOrMand"),
- emit({".",nl,nl});
- {constructed,bif} ->
- asn1ct_gen:gen_decode_constructed(Erules,Typename,InnerType,D);
- TheType ->
- DecFunName = mkfuncname(TheType,dec),
- emit({DecFunName,"(",{curr,bytes},
- ", OptOrMand, TagIn++",{asis,Tag},")"}),
- emit({".",nl,nl})
- end.
-
-
-gen_dec_prim(Erules,Att,BytesVar,DoTag,TagIn,Length,Form,OptOrMand) ->
- Typename = Att#type.def,
-%% Currently not used for BER replaced with [] as place holder
-%% Constraint = Att#type.constraint,
-%% Constraint = [],
- Constraint =
- case get_constraint(Att#type.constraint,'SizeConstraint') of
- no -> [];
- Tc -> Tc
- end,
- ValueRange =
- case get_constraint(Att#type.constraint,'ValueRange') of
- no -> [];
- Tv -> Tv
- end,
- SingleValue =
- case get_constraint(Att#type.constraint,'SingleValue') of
- no -> [];
- Sv -> Sv
- end,
- AsBin = case get(binary_strings) of
- true -> "_as_bin";
- _ -> ""
- end,
- NewTypeName = case Typename of
- 'ANY' -> 'ASN1_OPEN_TYPE';
- _ -> Typename
- end,
- DoLength =
- case NewTypeName of
- 'BOOLEAN'->
- emit({"?RT_BER:decode_boolean(",BytesVar,","}),
- false;
- 'INTEGER' ->
- emit({"?RT_BER:decode_integer(",BytesVar,",",
- {asis,int_constr(SingleValue,ValueRange)},","}),
- false;
- {'INTEGER',NamedNumberList} ->
- emit({"?RT_BER:decode_integer(",BytesVar,",",
- {asis,int_constr(SingleValue,ValueRange)},",",
- {asis,NamedNumberList},","}),
- false;
- {'ENUMERATED',NamedNumberList} ->
- emit({"?RT_BER:decode_enumerated(",BytesVar,",",
- {asis,Constraint},",",
- {asis,NamedNumberList},","}),
- false;
- 'REAL' ->
- emit({"?RT_BER:decode_real(",BytesVar,",",
- {asis,Constraint},","}),
- false;
- {'BIT STRING',NamedNumberList} ->
- case get(compact_bit_string) of
- true ->
- emit({"?RT_BER:decode_compact_bit_string(",
- BytesVar,",",{asis,Constraint},",",
- {asis,NamedNumberList},","});
- _ ->
- emit({"?RT_BER:decode_bit_string(",BytesVar,",",
- {asis,Constraint},",",
- {asis,NamedNumberList},","})
- end,
- true;
- 'NULL' ->
- emit({"?RT_BER:decode_null(",BytesVar,","}),
- false;
- 'OBJECT IDENTIFIER' ->
- emit({"?RT_BER:decode_object_identifier(",BytesVar,","}),
- false;
- 'RELATIVE-OID' ->
- emit({"?RT_BER:decode_relative_oid(",BytesVar,","}),
- false;
- 'ObjectDescriptor' ->
- emit({"?RT_BER:decode_restricted_string(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_ObjectDescriptor},","}),
- true;
- 'OCTET STRING' ->
- emit({"?RT_BER:decode_octet_string",AsBin,"(",BytesVar,",",{asis,Constraint},","}),
- true;
- 'NumericString' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_NumericString},","}),true;
- TString when TString == 'TeletexString';
- TString == 'T61String' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_TeletexString},","}),
- true;
- 'VideotexString' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_VideotexString},","}),
- true;
- 'GraphicString' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_GraphicString},","})
- ,true;
- 'VisibleString' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_VisibleString},","}),
- true;
- 'GeneralString' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_GeneralString},","}),
- true;
- 'PrintableString' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_PrintableString},","}),
- true;
- 'IA5String' ->
- emit({"?RT_BER:decode_restricted_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},",",{asis,?T_IA5String},","}),
- true;
- 'UniversalString' ->
- emit({"?RT_BER:decode_universal_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},","}),
- true;
- 'UTF8String' ->
- emit({"?RT_BER:decode_UTF8_string",AsBin,"(",
- BytesVar,","}),
- false;
- 'BMPString' ->
- emit({"?RT_BER:decode_BMP_string",AsBin,"(",
- BytesVar,",",{asis,Constraint},","}),
- true;
- 'UTCTime' ->
- emit({"?RT_BER:decode_utc_time",AsBin,"(",
- BytesVar,",",{asis,Constraint},","}),
- true;
- 'GeneralizedTime' ->
- emit({"?RT_BER:decode_generalized_time",AsBin,"(",
- BytesVar,",",{asis,Constraint},","}),
- true;
- 'ASN1_OPEN_TYPE' ->
- emit(["?RT_BER:decode_open_type(",re_wrap_erule(Erules),",",
- BytesVar,","]),
- false;
- #'ObjectClassFieldType'{} ->
- case asn1ct_gen:get_inner(Att#type.def) of
- {fixedtypevaluefield,_,InnerType} ->
- gen_dec_prim(Erules,InnerType,BytesVar,DoTag,TagIn,Length,Form,OptOrMand),
- false;
- 'ASN1_OPEN_TYPE' ->
- emit(["?RT_BER:decode_open_type(",
- re_wrap_erule(Erules),",",
- BytesVar,","]),
- false;
- XX ->
- exit({'can not decode' ,XX})
- end;
- Other ->
- exit({'can not decode' ,Other})
- end,
-
- NewLength = case DoLength of
- true -> [", ", Length];
- false -> ""
- end,
- NewOptOrMand = case OptOrMand of
- _ when is_list(OptOrMand) -> OptOrMand;
- mandatory -> {asis,mandatory};
- _ -> {asis,opt_or_default}
- end,
- case {TagIn,NewTypeName} of
- {_,#'ObjectClassFieldType'{}} ->
- case asn1ct_gen:get_inner(Att#type.def) of
- 'ASN1_OPEN_TYPE' ->
- emit([{asis,DoTag},")"]);
- _ -> ok
- end;
- {[],'ASN1_OPEN_TYPE'} ->
- emit([{asis,DoTag},")"]);
- {_,'ASN1_OPEN_TYPE'} ->
- emit([TagIn,"++",{asis,DoTag},")"]);
- {[],_} ->
- emit([{asis,DoTag},NewLength,", ",NewOptOrMand,")"]);
- _ when is_list(TagIn) ->
- emit([TagIn,"++",{asis,DoTag},NewLength,", ",NewOptOrMand,")"])
- end.
-
-
-int_constr([],[]) ->
- [];
-int_constr([],ValueRange) ->
- ValueRange;
-int_constr(SingleValue,[]) ->
- SingleValue;
-int_constr(SV,VR) ->
- [SV,VR].
-
-%% Object code generating for encoding and decoding
-%% ------------------------------------------------
-
-gen_obj_code(Erules,_Module,Obj) when is_record(Obj,typedef) ->
- ObjName = Obj#typedef.name,
- Def = Obj#typedef.typespec,
- #'Externaltypereference'{module=M,type=ClName} = Def#'Object'.classname,
- Class = asn1_db:dbget(M,ClName),
-
- {object,_,Fields} = Def#'Object'.def,
- emit({nl,nl,nl,"%%================================"}),
- emit({nl,"%% ",ObjName}),
- emit({nl,"%%================================",nl}),
- EncConstructed =
- gen_encode_objectfields(ClName,get_class_fields(Class),
- ObjName,Fields,[]),
- emit(nl),
- gen_encode_constr_type(Erules,EncConstructed),
- emit(nl),
- DecConstructed =
- gen_decode_objectfields(ClName,get_class_fields(Class),
- ObjName,Fields,[]),
- emit(nl),
- gen_decode_constr_type(Erules,DecConstructed);
-gen_obj_code(_Erules,_Module,Obj) when is_record(Obj,pobjectdef) ->
- ok.
-
-
-gen_encode_objectfields(ClassName,[{typefield,Name,OptOrMand}|Rest],
- ObjName,ObjectFields,ConstrAcc) ->
- EmitFuncClause =
- fun(Args) ->
- emit(["'enc_",ObjName,"'(",{asis,Name},
- ", ",Args,", _RestPrimFieldName) ->",nl])
- end,
-% emit(["'enc_",ObjName,"'(",{asis,Name},
-% ", Val, TagIn, _RestPrimFieldName) ->",nl]),
- MaybeConstr=
- case {get_object_field(Name,ObjectFields),OptOrMand} of
- {false,'MANDATORY'} -> %% this case is illegal
- exit({error,{asn1,{"missing mandatory field in object",
- ObjName}}});
- {false,'OPTIONAL'} -> %% OPTIONAL field in class
- EmitFuncClause("Val, _"), %% Value must be anything
- %% already encoded
- emit([" {Val,0}"]),
- [];
- {false,{'DEFAULT',DefaultType}} ->
- EmitFuncClause("Val, TagIn"),
- gen_encode_default_call(ClassName,Name,DefaultType);
- {{Name,TypeSpec},_} ->
- %% A specified field owerwrites any 'DEFAULT' or
- %% 'OPTIONAL' field in the class
- EmitFuncClause("Val, TagIn"),
- gen_encode_field_call(ObjName,Name,TypeSpec)
- end,
- case more_genfields(Rest) of
- true ->
- emit([";",nl]);
- false ->
- emit([".",nl])
- end,
- gen_encode_objectfields(ClassName,Rest,ObjName,ObjectFields,
- MaybeConstr++ConstrAcc);
-gen_encode_objectfields(ClassName,[{objectfield,Name,_,_,OptOrMand}|Rest],
- ObjName,ObjectFields,ConstrAcc) ->
- CurrentMod = get(currmod),
- EmitFuncClause =
- fun(Args) ->
- emit(["'enc_",ObjName,"'(",{asis,Name},
- ", ",Args,") ->",nl])
- end,
-% emit(["'enc_",ObjName,"'(",{asis,Name},
-% ", Val, TagIn, [H|T]) ->",nl]),
- case {get_object_field(Name,ObjectFields),OptOrMand} of
- {false,'MANDATORY'} ->
- exit({error,{asn1,{"missing mandatory field in object",
- ObjName}}});
- {false,'OPTIONAL'} ->
- EmitFuncClause("_,_,_"),
- emit([" exit({error,{'use of missing field in object', ",{asis,Name},
- "}})"]);
- {false,{'DEFAULT',_DefaultObject}} ->
- exit({error,{asn1,{"not implemented yet",Name}}});
- {{Name,#'Externalvaluereference'{module=CurrentMod,
- value=TypeName}},_} ->
- EmitFuncClause(" Val, TagIn, [H|T]"),
- emit({indent(3),"'enc_",TypeName,"'(H, Val, TagIn, T)"});
- {{Name,#'Externalvaluereference'{module=M,value=TypeName}},_} ->
- EmitFuncClause(" Val, TagIn, [H|T]"),
- emit({indent(3),"'",M,"':'enc_",TypeName,"'(H, Val, TagIn, T)"});
- {{Name,TypeSpec},_} ->
- EmitFuncClause(" Val, TagIn, [H|T]"),
- case TypeSpec#typedef.name of
- {ExtMod,TypeName} ->
- emit({indent(3),"'",ExtMod,"':'enc_",TypeName,
- "'(H, Val, TagIn, T)"});
- TypeName ->
- emit({indent(3),"'enc_",TypeName,"'(H, Val, TagIn, T)"})
- end
- end,
- case more_genfields(Rest) of
- true ->
- emit([";",nl]);
- false ->
- emit([".",nl])
- end,
- gen_encode_objectfields(ClassName,Rest,ObjName,ObjectFields,ConstrAcc);
-gen_encode_objectfields(ClassName,[_|Cs],O,OF,Acc) ->
- gen_encode_objectfields(ClassName,Cs,O,OF,Acc);
-gen_encode_objectfields(_,[],_,_,Acc) ->
- Acc.
-
-
-% gen_encode_objectfields(Class,ObjName,[{FieldName,Type}|Rest],ConstrAcc) ->
-% Fields = Class#objectclass.fields,
-% MaybeConstr=
-% case is_typefield(Fields,FieldName) of
-% true ->
-% Def = Type#typedef.typespec,
-% OTag = Def#type.tag,
-% Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
-% emit({"'enc_",ObjName,"'(",{asis,FieldName},
-% ", Val, TagIn, RestPrimFieldName) ->",nl}),
-% CAcc=
-% case Type#typedef.name of
-% {primitive,bif} ->
-% gen_encode_prim(ber,Def,["TagIn ++ ",{asis,Tag}],
-% "Val"),
-% [];
-% {constructed,bif} ->
-% %%InnerType = asn1ct_gen:get_inner(Def#type.def),
-% %%asn1ct_gen:gen_encode_constructed(ber,[ObjName],
-% %% InnerType,Def);
-% emit({" 'enc_",ObjName,'_',FieldName,
-% "'(Val, TagIn ++ ",{asis,Tag},")"}),
-% [{['enc_',ObjName,'_',FieldName],Def}];
-% {ExtMod,TypeName} ->
-% emit({" '",ExtMod,"':'enc_",TypeName,
-% "'(Val, TagIn ++ ",{asis,Tag},")"}),
-% [];
-% TypeName ->
-% emit({" 'enc_",TypeName,"'(Val, TagIn ++ ",
-% {asis,Tag},")"}),
-% []
-% end,
-% case more_genfields(Fields,Rest) of
-% true ->
-% emit({";",nl});
-% false ->
-% emit({".",nl})
-% end,
-% CAcc;
-% {false,objectfield} ->
-% emit({"'enc_",ObjName,"'(",{asis,FieldName},
-% ", Val, TagIn, [H|T]) ->",nl}),
-% case Type#typedef.name of
-% {ExtMod,TypeName} ->
-% emit({indent(3),"'",ExtMod,"':'enc_",TypeName,
-% "'(H, Val, TagIn, T)"});
-% TypeName ->
-% emit({indent(3),"'enc_",TypeName,"'(H, Val, TagIn, T)"})
-% end,
-% case more_genfields(Fields,Rest) of
-% true ->
-% emit({";",nl});
-% false ->
-% emit({".",nl})
-% end,
-% [];
-% {false,_} -> []
-% end,
-% gen_encode_objectfields(Class,ObjName,Rest,MaybeConstr ++ ConstrAcc);
-% gen_encode_objectfields(C,O,[H|T],Acc) ->
-% gen_encode_objectfields(C,O,T,Acc);
-% gen_encode_objectfields(_,_,[],Acc) ->
-% Acc.
-
-% gen_encode_constr_type([{Name,Def}|Rest]) ->
-% emit({Name,"(Val,TagIn) ->",nl}),
-% InnerType = asn1ct_gen:get_inner(Def#type.def),
-% asn1ct_gen:gen_encode_constructed(ber,Name,InnerType,Def),
-% gen_encode_constr_type(Rest);
-gen_encode_constr_type(Erules,[TypeDef|Rest]) when is_record(TypeDef,typedef) ->
- case is_already_generated(enc,TypeDef#typedef.name) of
- true -> ok;
- _ -> gen_encode_user(Erules,TypeDef)
- end,
- gen_encode_constr_type(Erules,Rest);
-gen_encode_constr_type(_,[]) ->
- ok.
-
-gen_encode_field_call(_ObjName,_FieldName,
- #'Externaltypereference'{module=M,type=T}) ->
- CurrentMod = get(currmod),
- TDef = asn1_db:dbget(M,T),
- Def = TDef#typedef.typespec,
- OTag = Def#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- if
- M == CurrentMod ->
- emit({" 'enc_",T,"'(Val, TagIn ++ ",{asis,Tag},")"}),
- [];
- true ->
- emit({" '",M,"':'enc_",T,"'(Val, TagIn ++ ",{asis,Tag},")"}),
- []
- end;
-gen_encode_field_call(ObjName,FieldName,Type) ->
- Def = Type#typedef.typespec,
- OTag = Def#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case Type#typedef.name of
- {primitive,bif} -> %%tag should be the primitive tag
- gen_encode_prim(ber,Def,["TagIn ++ ",{asis,Tag}],
- "Val"),
- [];
- {constructed,bif} ->
- emit({" 'enc_",ObjName,'_',FieldName,
- "'(Val, TagIn ++",{asis,Tag},")"}),
- [Type#typedef{name=list_to_atom(lists:concat([ObjName,'_',FieldName]))}];
- {ExtMod,TypeName} ->
- emit({" '",ExtMod,"':'enc_",TypeName,
- "'(Val, TagIn ++ ",{asis,Tag},")"}),
- [];
- TypeName ->
- emit({" 'enc_",TypeName,"'(Val, TagIn ++ ",{asis,Tag},")"}),
- []
- end.
-
-gen_encode_default_call(ClassName,FieldName,Type) ->
- CurrentMod = get(currmod),
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case asn1ct_gen:type(InnerType) of
- {constructed,bif} ->
-%% asn1ct_gen:gen_encode_constructed(Erules,Typename,InnerType,Type);
- emit([" 'enc_",ClassName,'_',FieldName,"'(Bytes, TagIn ++ ",
- {asis,Tag},")"]),
- [#typedef{name=list_to_atom(lists:concat([ClassName,'_',FieldName])),
- typespec=Type}];
- {primitive,bif} ->
- gen_encode_prim(ber,Type,["TagIn ++ ",{asis,Tag}],"Val"),
- [];
- #'Externaltypereference'{module=CurrentMod,type=Etype} ->
- emit([" 'enc_",Etype,"'(Val, TagIn ++ ",{asis,Tag},")",nl]),
- [];
- #'Externaltypereference'{module=Emod,type=Etype} ->
- emit([" '",Emod,"':'enc_",Etype,"'(Val, TagIn ++ ",{asis,Tag},")",nl]),
- []
- end.
-
-
-
-gen_decode_objectfields(ClassName,[{typefield,Name,OptOrMand}|Rest],
- ObjName,ObjectFields,ConstrAcc) ->
- EmitFuncClause =
- fun(Args) ->
- emit(["'dec_",ObjName,"'(",{asis,Name},
- ", ",Args,"_) ->",nl])
- end,
-% emit(["'dec_",ObjName,"'(",{asis,Name},
-% ", Bytes, TagIn, RestPrimFieldName) ->",nl]),
- MaybeConstr=
- case {get_object_field(Name,ObjectFields),OptOrMand} of
- {false,'MANDATORY'} -> %% this case is illegal
- exit({error,{asn1,{"missing mandatory field in object",
- ObjName}}});
- {false,'OPTIONAL'} ->
- EmitFuncClause("Bytes, _,"),
-% emit([" asn1_NOVALUE"]),
- emit([" {Bytes,[],0}"]),
- [];
- {false,{'DEFAULT',DefaultType}} ->
- EmitFuncClause("Bytes, TagIn,"),
- gen_decode_default_call(ClassName,Name,"Bytes",DefaultType);
- {{Name,TypeSpec},_} ->
- %% A specified field owerwrites any 'DEFAULT' or
- %% 'OPTIONAL' field in the class
- EmitFuncClause("Bytes, TagIn,"),
- gen_decode_field_call(ObjName,Name,"Bytes",TypeSpec)
- end,
- case more_genfields(Rest) of
- true ->
- emit([";",nl]);
- false ->
- emit([".",nl])
- end,
- gen_decode_objectfields(ClassName,Rest,ObjName,ObjectFields,MaybeConstr++ConstrAcc);
-gen_decode_objectfields(ClassName,[{objectfield,Name,_,_,OptOrMand}|Rest],
- ObjName,ObjectFields,ConstrAcc) ->
- CurrentMod = get(currmod),
- EmitFuncClause =
- fun(Args) ->
- emit(["'dec_",ObjName,"'(",{asis,Name},
- ", ",Args,") ->",nl])
- end,
-% emit(["'dec_",ObjName,"'(",{asis,Name},
-% ", Bytes,TagIn,[H|T]) ->",nl]),
- case {get_object_field(Name,ObjectFields),OptOrMand} of
- {false,'MANDATORY'} ->
- exit({error,{asn1,{"missing mandatory field in object",
- ObjName}}});
- {false,'OPTIONAL'} ->
- EmitFuncClause("_,_,_"),
- emit([" exit({error,{'illegal use of missing field in object', ",{asis,Name},
- "}})"]);
- {false,{'DEFAULT',_DefaultObject}} ->
- exit({error,{asn1,{"not implemented yet",Name}}});
- {{Name,#'Externalvaluereference'{module=CurrentMod,
- value=TypeName}},_} ->
- EmitFuncClause("Bytes,TagIn,[H|T]"),
- emit({indent(3),"'dec_",TypeName,"'(H, Bytes, TagIn, T)"});
- {{Name,#'Externalvaluereference'{module=M,value=TypeName}},_} ->
- EmitFuncClause("Bytes,TagIn,[H|T]"),
- emit({indent(3),"'",M,"':'dec_",TypeName,
- "'(H, Bytes, TagIn, T)"});
- {{Name,TypeSpec},_} ->
- EmitFuncClause("Bytes,TagIn,[H|T]"),
- case TypeSpec#typedef.name of
- {ExtMod,TypeName} ->
- emit({indent(3),"'",ExtMod,"':'dec_",TypeName,
- "'(H, Bytes, TagIn, T)"});
- TypeName ->
- emit({indent(3),"'dec_",TypeName,"'(H, Bytes, TagIn, T)"})
- end
- end,
- case more_genfields(Rest) of
- true ->
- emit([";",nl]);
- false ->
- emit([".",nl])
- end,
- gen_decode_objectfields(ClassName,Rest,ObjName,ObjectFields,ConstrAcc);
-gen_decode_objectfields(CN,[_|Cs],O,OF,CAcc) ->
- gen_decode_objectfields(CN,Cs,O,OF,CAcc);
-gen_decode_objectfields(_,[],_,_,CAcc) ->
- CAcc.
-
-
-gen_decode_constr_type(Erules,[TypeDef|Rest]) when is_record(TypeDef,typedef) ->
- case is_already_generated(dec,TypeDef#typedef.name) of
- true -> ok;
- _ ->
- gen_decode(Erules,TypeDef)
- end,
- gen_decode_constr_type(Erules,Rest);
-gen_decode_constr_type(_,[]) ->
- ok.
-
-gen_decode_field_call(_ObjName,_FieldName,Bytes,
- #'Externaltypereference'{module=M,type=T}) ->
- CurrentMod = get(currmod),
- TDef = asn1_db:dbget(M,T),
- Def = TDef#typedef.typespec,
- OTag = Def#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- if
- M == CurrentMod ->
- emit({" 'dec_",T,"'(",Bytes,
- ", opt_or_default,TagIn ++ ",{asis,Tag},")"}),
- [];
- true ->
- emit({" '",M,"':'dec_",T,
- "'(",Bytes,", opt_or_default,TagIn ++ ",{asis,Tag},")"}),
- []
- end;
-gen_decode_field_call(ObjName,FieldName,Bytes,Type) ->
- Def = Type#typedef.typespec,
- OTag = Def#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case Type#typedef.name of
- {primitive,bif} -> %%tag should be the primitive tag
- gen_dec_prim(ber,Def,Bytes,Tag,"TagIn",no_length,
- ?PRIMITIVE,opt_or_default),
- [];
- {constructed,bif} ->
- emit({" 'dec_",ObjName,'_',FieldName,
- "'(",Bytes,",opt_or_default, TagIn ++ ",{asis,Tag},")"}),
- [Type#typedef{name=list_to_atom(lists:concat([ObjName,'_',FieldName]))}];
- {ExtMod,TypeName} ->
- emit({" '",ExtMod,"':'dec_",TypeName,
- "'(",Bytes,", opt_or_default,TagIn ++ ",{asis,Tag},")"}),
- [];
- TypeName ->
- emit({" 'dec_",TypeName,"'(",Bytes,
- ", opt_or_default,TagIn ++ ",{asis,Tag},")"}),
- []
- end.
-
-gen_decode_default_call(ClassName,FieldName,Bytes,Type) ->
- CurrentMod = get(currmod),
- InnerType = asn1ct_gen:get_inner(Type#type.def),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case asn1ct_gen:type(InnerType) of
- {constructed,bif} ->
- emit([" 'dec_",ClassName,'_',FieldName,"'(",Bytes,
- ",opt_or_default, TagIn ++ ",{asis,Tag},")"]),
- [#typedef{name=list_to_atom(lists:concat([ClassName,'_',FieldName])),
- typespec=Type}];
- {primitive,bif} ->
- gen_dec_prim(ber,Type,Bytes,Tag,"TagIn",no_length,
- ?PRIMITIVE,opt_or_default),
- [];
- #'Externaltypereference'{module=CurrentMod,type=Etype} ->
- emit([" 'dec_",Etype,"'(",Bytes,
- " ,opt_or_default, TagIn ++ ",{asis,Tag},")",nl]),
- [];
- #'Externaltypereference'{module=Emod,type=Etype} ->
- emit([" '",Emod,"':'dec_",Etype,"'(",Bytes,
- ", opt_or_defualt, TagIn ++ ",{asis,Tag},")",nl]),
- []
- end.
-
-
-more_genfields([]) ->
- false;
-more_genfields([Field|Fields]) ->
- case element(1,Field) of
- typefield ->
- true;
- objectfield ->
- true;
- _ ->
- more_genfields(Fields)
- end.
-
-
-
-%% Object Set code generating for encoding and decoding
-%% ----------------------------------------------------
-gen_objectset_code(Erules,ObjSet) ->
- ObjSetName = ObjSet#typedef.name,
- Def = ObjSet#typedef.typespec,
-% {ClassName,ClassDef} = Def#'ObjectSet'.class,
- #'Externaltypereference'{module=ClassModule,
- type=ClassName} = Def#'ObjectSet'.class,
- ClassDef = asn1_db:dbget(ClassModule,ClassName),
- UniqueFName = Def#'ObjectSet'.uniquefname,
- Set = Def#'ObjectSet'.set,
- emit({nl,nl,nl,"%%================================"}),
- emit({nl,"%% ",ObjSetName}),
- emit({nl,"%%================================",nl}),
- case ClassName of
- {_Module,ExtClassName} ->
- gen_objset_code(Erules,ObjSetName,UniqueFName,Set,
- ExtClassName,ClassDef);
- _ ->
- gen_objset_code(Erules,ObjSetName,UniqueFName,Set,
- ClassName,ClassDef)
- end,
- emit(nl).
-
-gen_objset_code(Erules,ObjSetName,UniqueFName,Set,ClassName,ClassDef)->
- ClassFields = (ClassDef#classdef.typespec)#objectclass.fields,
- InternalFuncs=gen_objset_enc(ObjSetName,UniqueFName,Set,ClassName,ClassFields,1,[]),
- gen_objset_dec(Erules,ObjSetName,UniqueFName,Set,ClassName,ClassFields,1),
- gen_internal_funcs(Erules,InternalFuncs).
-
-
-%% gen_objset_enc iterates over the objects of the object set
-gen_objset_enc(_,{unique,undefined},_,_,_,_,_) ->
- %% There is no unique field in the class of this object set
- %% don't bother about the constraint
- [];
-gen_objset_enc(ObjSName,UniqueName,[{_,no_unique_value,_},T|Rest],
- ClName,ClFields,NthObj,Acc) ->
- %% No need to check that this class has property OPTIONAL for the
- %% unique field, it was detected in the previous phase
- gen_objset_enc(ObjSName,UniqueName,[T|Rest],ClName,ClFields,NthObj,Acc);
-gen_objset_enc(ObjSetName,UniqueName,[{_,no_unique_value,_}],
- _ClName,_ClFields,_NthObj,Acc) ->
- %% No need to check that this class has property OPTIONAL for the
- %% unique field, it was detected in the previous phase
- emit_default_getenc(ObjSetName,UniqueName),
- emit({".",nl,nl}),
- Acc;
-gen_objset_enc(ObjSName,UniqueName,
- [{ObjName,Val,Fields},T|Rest],ClName,ClFields,NthObj,Acc)->
- emit({"'getenc_",ObjSName,"'(",{asis,UniqueName},",",{asis,Val},") ->",nl}),
- CurrMod = get(currmod),
- {InternalFunc,NewNthObj}=
- case ObjName of
- {no_mod,no_name} ->
- gen_inlined_enc_funs(Fields,ClFields,ObjSName,NthObj);
- {CurrMod,Name} ->
- emit({" fun 'enc_",Name,"'/4"}),
- {[],NthObj};
- {ModuleName,Name} ->
- emit_ext_fun(enc,ModuleName,Name),
-% emit([" {'",ModuleName,"', 'enc_",Name,"'}"]),
- {[],NthObj};
- _Other ->
- emit({" fun 'enc_",ObjName,"'/4"}),
- {[],NthObj}
- end,
- emit({";",nl}),
- gen_objset_enc(ObjSName,UniqueName,[T|Rest],ClName,ClFields,
- NewNthObj,InternalFunc ++ Acc);
-gen_objset_enc(ObjSetName,UniqueName,
- [{ObjName,Val,Fields}],_ClName,ClFields,NthObj,Acc) ->
- emit({"'getenc_",ObjSetName,"'(",{asis,UniqueName},",",{asis,Val},") ->",nl}),
- CurrMod = get(currmod),
- {InternalFunc,_}=
- case ObjName of
- {no_mod,no_name} ->
- gen_inlined_enc_funs(Fields,ClFields,ObjSetName,NthObj);
- {CurrMod,Name} ->
- emit({" fun 'enc_",Name,"'/4"}),
- {[],NthObj};
- {ModuleName,Name} ->
- emit_ext_fun(enc,ModuleName,Name),
-% emit([" {'",ModuleName,"', 'enc_",Name,"'}"]),
- {[],NthObj};
- _Other ->
- emit({" fun 'enc_",ObjName,"'/4"}),
- {[],NthObj}
- end,
- emit([";",nl]),
- emit_default_getenc(ObjSetName,UniqueName),
- emit({".",nl,nl}),
- InternalFunc ++ Acc;
-%% See X.681 Annex E for the following case
-gen_objset_enc(ObjSetName,_UniqueName,['EXTENSIONMARK'],
- _ClName,_ClFields,_NthObj,Acc) ->
- emit({"'getenc_",ObjSetName,"'(_, _) ->",nl}),
- emit({indent(3),"fun(_Attr, Val, _TagIn, _RestPrimFieldName) ->",nl}),
- emit({indent(6),"Len = case Val of",nl,indent(9),
- "Bin when is_binary(Bin) -> size(Bin);",nl,indent(9),
- "_ -> length(Val)",nl,indent(6),"end,"}),
- emit({indent(6),"{Val,Len}",nl}),
- emit({indent(3),"end.",nl,nl}),
- Acc;
-gen_objset_enc(ObjSetName,UniqueName,['EXTENSIONMARK','EXTENSIONMARK'|Rest],
- ClName,ClFields,NthObj,Acc) ->
- gen_objset_enc(ObjSetName,UniqueName,['EXTENSIONMARK'|Rest],
- ClName,ClFields,NthObj,Acc);
-gen_objset_enc(ObjSetName,UniqueName,['EXTENSIONMARK'|Rest],
- ClName,ClFields,NthObj,Acc) ->
- gen_objset_enc(ObjSetName,UniqueName,Rest++['EXTENSIONMARK'],
- ClName,ClFields,NthObj,Acc);
-gen_objset_enc(_,_,[],_,_,_,Acc) ->
- Acc.
-
-emit_ext_fun(EncDec,ModuleName,Name) ->
- emit([indent(3),"fun(T,V,_O1,_O2) -> '",ModuleName,"':'",EncDec,"_",
- Name,"'(T,V,_O1,_O2) end"]).
-
-emit_default_getenc(ObjSetName,UniqueName) ->
- emit(["'getenc_",ObjSetName,"'(",{asis,UniqueName},", ErrV) ->",nl]),
- emit([indent(3),"fun(C,V,_,_) -> exit({'Type not compatible with table constraint',{component,C},{value,V}, {unique_name_and_value,",{asis,UniqueName},", ErrV}}) end"]).
-
-%% gen_inlined_enc_funs for each object iterates over all fields of a
-%% class, and for each typefield it checks if the object has that
-%% field and emits the proper code.
-gen_inlined_enc_funs(Fields,[{typefield,Name,_}|Rest],ObjSetName,
- NthObj) ->
- CurrMod = get(currmod),
- InternalDefFunName = asn1ct_gen:list2name([NthObj,Name,ObjSetName]),
- case lists:keysearch(Name,1,Fields) of
- {value,{_,Type}} when is_record(Type,type) ->
- emit({indent(3),"fun(Type, Val, TagIn, _RestPrimFieldName) ->",nl,
- indent(6),"case Type of",nl}),
- {Ret,N} = emit_inner_of_fun(Type,InternalDefFunName),
- gen_inlined_enc_funs1(Fields,Rest,ObjSetName,NthObj+N,Ret);
- {value,{_,Type}} when is_record(Type,typedef) ->
- emit({indent(3),"fun(Type, Val, TagIn, _RestPrimFieldName) ->",nl,
- indent(6),"case Type of",nl}),
- emit({indent(9),{asis,Name}," ->",nl}),
- {Ret,N} = emit_inner_of_fun(Type,InternalDefFunName),
- gen_inlined_enc_funs1(Fields,Rest,ObjSetName,NthObj+N,Ret);
- {value,{_,#'Externaltypereference'{module=M,type=T}}} ->
- #typedef{typespec=Type} = asn1_db:dbget(M,T),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit([indent(3),"fun(Type, Val, TagIn, _RestPrimFieldName) ->",nl,
- indent(6),"case Type of",nl]),
- emit([indent(9),{asis,Name}," ->",nl]),
- if
- M == CurrMod ->
- emit([indent(12),"'enc_",T,"'(Val, TagIn ++ ",
- {asis,Tag},")"]);
- true ->
- emit([indent(12),"'",M,"':'enc_",T,"'(Val,TagIn ++",
- {asis,Tag},")"])
- end,
- gen_inlined_enc_funs1(Fields,Rest,ObjSetName,NthObj,[]);
- false ->
- %% This field was not present in the object thus there were no
- %% type in the table and we therefore generate code that returns
- %% the input for application treatment.
- emit([indent(3),"fun(Type, Val, TagIn, _RestPrimFieldName) ->",nl,
- indent(6),"case Type of",nl]),
- emit([indent(9),{asis,Name}," ->",nl]),
- emit([indent(12),"Len = case Val of",nl,
- indent(15),"Bin when is_binary(Bin) -> size(Bin);",nl,
- indent(15),"_ -> length(Val)",nl,indent(12),"end,",nl,
- indent(12),"{Val,Len}"]),
- gen_inlined_enc_funs1(Fields,Rest,ObjSetName,NthObj,[])
- end;
-gen_inlined_enc_funs(Fields,[_H|Rest],ObjSetName,NthObj) ->
- gen_inlined_enc_funs(Fields,Rest,ObjSetName,NthObj);
-gen_inlined_enc_funs(_,[],_,NthObj) ->
- {[],NthObj}.
-
-gen_inlined_enc_funs1(Fields,[{typefield,Name,_}|Rest],ObjSetName,
- NthObj,Acc) ->
- CurrMod = get(currmod),
- InternalDefFunName = asn1ct_gen:list2name([NthObj,Name,ObjSetName]),
- {Acc2,NAdd}=
- case lists:keysearch(Name,1,Fields) of
- {value,{_,Type}} when is_record(Type,type) ->
- emit({";",nl}),
- {Ret,N}=emit_inner_of_fun(Type,InternalDefFunName),
- {Ret++Acc,N};
- {value,{_,Type}} when is_record(Type,typedef) ->
- emit({";",nl,indent(9),{asis,Name}," ->",nl}),
- {Ret,N}=emit_inner_of_fun(Type,InternalDefFunName),
- {Ret++Acc,N};
- {value,{_,#'Externaltypereference'{module=M,type=T}}} ->
- #typedef{typespec=Type} = asn1_db:dbget(M,T),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit({";",nl,indent(9),{asis,Name}," ->",nl}),
- if
- M == CurrMod ->
- emit([indent(12),"'enc_",T,"'(Val, TagIn ++ ",
- {asis,Tag},")"]);
- true ->
- emit([indent(12),"'",M,"':'enc_",T,"'(Val,TagIn ++",
- {asis,Tag},")"])
- end,
- {Acc,0};
- false ->
- %% This field was not present in the object thus there were no
- %% type in the table and we therefore generate code that returns
- %% the input for application treatment.
- emit([";",nl,indent(9),{asis,Name}," ->",nl]),
- emit([indent(12),"Len = case Val of",nl,
- indent(15),"Bin when is_binary(Bin) -> size(Bin);",nl,
- indent(15),"_ -> length(Val)",nl,indent(12),"end,",nl,
- indent(12),"{Val,Len}"]),
- {Acc,0}
- end,
- gen_inlined_enc_funs1(Fields,Rest,ObjSetName,NthObj+NAdd,Acc2);
-gen_inlined_enc_funs1(Fields,[_H|Rest],ObjSetName,NthObj,Acc)->
- gen_inlined_enc_funs1(Fields,Rest,ObjSetName,NthObj,Acc);
-gen_inlined_enc_funs1(_,[],_,NthObj,Acc) ->
- emit({nl,indent(6),"end",nl}),
- emit({indent(3),"end"}),
- {Acc,NthObj}.
-
-
-emit_inner_of_fun(TDef = #typedef{name={ExtMod,Name},typespec=Type},
- InternalDefFunName) ->
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case {ExtMod,Name} of
- {primitive,bif} ->
- emit(indent(12)),
- gen_encode_prim(ber,Type,["TagIn ++ ",{asis,Tag}],"Val"),
- {[],0};
- {constructed,bif} ->
- emit([indent(12),"'enc_",
- InternalDefFunName,"'(Val,TagIn ++ ",
- {asis,Tag},")"]),
- {[TDef#typedef{name=InternalDefFunName}],1};
- _ ->
- emit({indent(12),"'",ExtMod,"':'enc_",Name,"'(Val, TagIn ++ ",
- {asis,Tag},")"}),
- {[],0}
- end;
-emit_inner_of_fun(#typedef{name=Name,typespec=Type},_) ->
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit({indent(12),"'enc_",Name,"'(Val, TagIn ++ ",{asis,Tag},")"}),
- {[],0};
-emit_inner_of_fun(Type,_) when is_record(Type,type) ->
- CurrMod = get(currmod),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case Type#type.def of
- Def when is_atom(Def) ->
- emit({indent(9),Def," ->",nl,indent(12)}),
- gen_encode_prim(ber,Type,["TagIn ++ ",{asis,Tag}],"Val");
- TRef when is_record(TRef,typereference) ->
- T = TRef#typereference.val,
- emit({indent(9),T," ->",nl,indent(12),"'enc_",T,
- "'(Val, TagIn ++ ",{asis,Tag},")"});
- #'Externaltypereference'{module=CurrMod,type=T} ->
- emit({indent(9),T," ->",nl,indent(12),"'enc_",T,
- "'(Val, TagIn ++ ",{asis,Tag},")"});
- #'Externaltypereference'{module=ExtMod,type=T} ->
- emit({indent(9),T," ->",nl,indent(12),ExtMod,":'enc_",
- T,"'(Val, TagIn ++ ",{asis,Tag},")"})
- end,
- {[],0}.
-
-indent(N) ->
- lists:duplicate(N,32). % 32 = space
-
-
-gen_objset_dec(_,_,{unique,undefined},_,_,_,_) ->
- %% There is no unique field in the class of this object set
- %% don't bother about the constraint
- ok;
-gen_objset_dec(Erules,ObjSName,UniqueName,[{_,no_unique_value,_},T|Rest],
- ClName,ClFields,NthObj)->
- gen_objset_dec(Erules,ObjSName,UniqueName,[T|Rest],ClName,ClFields,
- NthObj);
-gen_objset_dec(_Erules,ObjSetName,UniqueName,[{_,no_unique_value,_}],
- _ClName,_ClFields,_NthObj)->
- emit_default_getdec(ObjSetName,UniqueName),
- emit({".",nl,nl});
-gen_objset_dec(Erules,ObjSName,UniqueName,[{ObjName,Val,Fields},T|Rest],
- ClName,ClFields,NthObj)->
- emit({"'getdec_",ObjSName,"'(",{asis,UniqueName},",",{asis,Val},
- ") ->",nl}),
- CurrMod = get(currmod),
- NewNthObj=
- case ObjName of
- {no_mod,no_name} ->
- gen_inlined_dec_funs(Erules,Fields,ClFields,ObjSName,
- NthObj);
- {CurrMod,Name} ->
- emit({" fun 'dec_",Name,"'/4"}),
- NthObj;
- {ModName,Name} ->
- emit_ext_fun(dec,ModName,Name),
-% emit([" {'",ModName,"', 'dec_",Name,"'}"]),
- NthObj;
- _Other ->
- emit({" fun 'dec_",ObjName,"'/4"}),
- NthObj
- end,
- emit({";",nl}),
- gen_objset_dec(Erules,ObjSName,UniqueName,[T|Rest],ClName,ClFields,
- NewNthObj);
-gen_objset_dec(Erules,ObjSetName,UniqueName,[{ObjName,Val,Fields}],_ClName,
- ClFields,NthObj) ->
- emit({"'getdec_",ObjSetName,"'(",{asis,UniqueName},",",{asis,Val},") ->",nl}),
- CurrMod = get(currmod),
- case ObjName of
- {no_mod,no_name} ->
- gen_inlined_dec_funs(Erules,Fields,ClFields,ObjSetName,
- NthObj);
- {CurrMod,Name} ->
- emit({" fun 'dec_",Name,"'/4"});
- {ModName,Name} ->
- emit_ext_fun(dec,ModName,Name);
-% emit([" {'",ModName,"', 'dec_",Name,"'}"]);
- _Other ->
- emit({" fun 'dec_",ObjName,"'/4"})
- end,
- emit({";",nl}),
- emit_default_getdec(ObjSetName,UniqueName),
- emit({".",nl,nl});
-gen_objset_dec(_,ObjSetName,_UniqueName,['EXTENSIONMARK'],_ClName,_ClFields,
- _NthObj) ->
- emit({"'getdec_",ObjSetName,"'(_, _) ->",nl}),
- emit({indent(3),"fun(_, Bytes, _, _) ->",nl}),
- emit({indent(6),"Len = case Bytes of",nl,indent(9),
- "Bin when is_binary(Bin) -> size(Bin);",nl,indent(9),
- "_ -> length(Bytes)",nl,indent(6),"end,"}),
- emit({indent(6),"{Bytes,[],Len}",nl}),
- emit({indent(3),"end.",nl,nl}),
- ok;
-gen_objset_dec(Erule,ObjSetName,UniqueName,
- ['EXTENSIONMARK','EXTENSIONMARK'|Rest],
- ClName,ClFields,NthObj) ->
- gen_objset_dec(Erule,ObjSetName,UniqueName,['EXTENSIONMARK'|Rest],
- ClName,ClFields,NthObj);
-gen_objset_dec(Erule,ObjSetName,UniqueName,['EXTENSIONMARK'|Rest],
- ClName,ClFields,NthObj) ->
- gen_objset_dec(Erule,ObjSetName,UniqueName,Rest++['EXTENSIONMARK'],
- ClName,ClFields,NthObj);
-gen_objset_dec(_,_,_,[],_,_,_) ->
- ok.
-
-emit_default_getdec(ObjSetName,UniqueName) ->
- emit(["'getdec_",ObjSetName,"'(",{asis,UniqueName},", ErrV) ->",nl]),
- emit([indent(3),"fun(C,V,_,_) -> exit({{component,C},{value,V}, {unique_name_and_value,",{asis,UniqueName},", ErrV}}) end"]).
-
-gen_inlined_dec_funs(Erules,Fields,[{typefield,Name,Prop}|Rest],
- ObjSetName,NthObj) ->
- DecProp = case Prop of
- 'OPTIONAL' -> opt_or_default;
- {'DEFAULT',_} -> opt_or_default;
- _ -> mandatory
- end,
- CurrMod = get(currmod),
- InternalDefFunName = [NthObj,Name,ObjSetName],
- case lists:keysearch(Name,1,Fields) of
- {value,{_,Type}} when is_record(Type,type) ->
- emit({indent(3),"fun(Type, Bytes, TagIn, _RestPrimFieldName) ->",
- nl,indent(6),"case Type of",nl}),
- N=emit_inner_of_decfun(Erules,Type,DecProp,InternalDefFunName),
- gen_inlined_dec_funs1(Erules,Fields,Rest,ObjSetName,NthObj+N);
- {value,{_,Type}} when is_record(Type,typedef) ->
- emit({indent(3),"fun(Type, Bytes, TagIn, _RestPrimFieldName) ->",
- nl,indent(6),"case Type of",nl}),
- emit({indent(9),{asis,Name}," ->",nl}),
- N=emit_inner_of_decfun(Erules,Type,DecProp,InternalDefFunName),
- gen_inlined_dec_funs1(Erules,Fields,Rest,ObjSetName,NthObj+N);
- {value,{_,#'Externaltypereference'{module=M,type=T}}} ->
- #typedef{typespec=Type} = asn1_db:dbget(M,T),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit({indent(3),"fun(Type, Bytes, TagIn, _RestPrimFieldName) ->",
- nl,indent(6),"case Type of",nl}),
- emit({indent(9),{asis,Name}," ->",nl}),
- if
- M == CurrMod ->
- emit([indent(12),"'dec_",T,"'(Bytes, ",DecProp,
- ", TagIn ++ ",{asis,Tag},")"]);
- true ->
- emit([indent(12),"'",M,"':'dec_",T,"'(Bytes, ",
- DecProp,", TagIn ++ ",{asis,Tag},")"])
- end,
- gen_inlined_dec_funs1(Erules,Fields,Rest,ObjSetName,NthObj);
- false ->
- emit([indent(3),"fun(Type, Bytes, TagIn, _RestPrimFieldName) ->",
- nl,indent(6),"case Type of",nl,
- indent(9),{asis,Name}," ->",nl,
- indent(12),"Len = case Bytes of",nl,
- indent(15),"B when is_binary(B) -> size(B);",nl,
- indent(15),"_ -> length(Bytes)",nl,
- indent(12),"end,",nl,
- indent(12),"{Bytes,[],Len}"]),
- gen_inlined_dec_funs1(Erules,Fields,Rest,ObjSetName,NthObj)
- end;
-gen_inlined_dec_funs(Erules,Fields,[_H|Rest],ObjSetName,NthObj) ->
- gen_inlined_dec_funs(Erules,Fields,Rest,ObjSetName,NthObj);
-gen_inlined_dec_funs(_,_,[],_,NthObj) ->
- NthObj.
-
-gen_inlined_dec_funs1(Erules,Fields,[{typefield,Name,Prop}|Rest],
- ObjSetName,NthObj) ->
- DecProp = case Prop of
- 'OPTIONAL' -> opt_or_default;
- {'DEFAULT',_} -> opt_or_default;
- _ -> mandatory
- end,
- CurrMod = get(currmod),
- InternalDefFunName = [NthObj,Name,ObjSetName],
- N=
- case lists:keysearch(Name,1,Fields) of
- {value,{_,Type}} when is_record(Type,type) ->
- emit({";",nl}),
- emit_inner_of_decfun(Erules,Type,DecProp,InternalDefFunName);
- {value,{_,Type}} when is_record(Type,typedef) ->
- emit({";",nl,indent(9),{asis,Name}," ->",nl}),
- emit_inner_of_decfun(Erules,Type,DecProp,InternalDefFunName);
- {value,{_,#'Externaltypereference'{module=M,type=T}}} ->
- #typedef{typespec=Type} = asn1_db:dbget(M,T),
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit({";",nl,indent(9),{asis,Name}," ->",nl}),
- if
- M == CurrMod ->
- emit([indent(12),"'dec_",T,"'(Bytes, ",DecProp,
- ", TagIn ++ ",{asis,Tag},")"]);
- true ->
- emit([indent(12),"'",M,"':'dec_",T,"'(Bytes, ",
- DecProp,", TagIn ++ ",{asis,Tag},")"])
- end,
- 0;
- false ->
- emit([";",nl,
- indent(9),{asis,Name}," ->",nl,
- indent(12),"Len = case Bytes of",nl,
- indent(15),"B when is_binary(B) -> size(B);",nl,
- indent(15),"_ -> length(Bytes)",nl,
- indent(12),"end,",nl,
- indent(12),"{Bytes,[],Len}"]),
- 0
- end,
- gen_inlined_dec_funs1(Erules,Fields,Rest,ObjSetName,NthObj+N);
-gen_inlined_dec_funs1(Erules,Fields,[_H|Rest],ObjSetName,NthObj)->
- gen_inlined_dec_funs1(Erules,Fields,Rest,ObjSetName,NthObj);
-gen_inlined_dec_funs1(_,_,[],_,NthObj) ->
- emit({nl,indent(6),"end",nl}),
- emit({indent(3),"end"}),
- NthObj.
-
-emit_inner_of_decfun(Erules,#typedef{name={ExtName,Name},typespec=Type},
- Prop,InternalDefFunName) ->
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- case {ExtName,Name} of
- {primitive,bif} ->
- emit(indent(12)),
- gen_dec_prim(Erules,Type,"Bytes",Tag,"TagIn",no_length,
- ?PRIMITIVE,Prop),
- 0;
- {constructed,bif} ->
- emit({indent(12),"'dec_",
- asn1ct_gen:list2name(InternalDefFunName),"'(Bytes, ",Prop,
- ", TagIn ++ ",{asis,Tag},")"}),
- 1;
- _ ->
- emit({indent(12),"'",ExtName,"':'dec_",Name,"'(Bytes, ",Prop,
- ", TagIn ++ ",{asis,Tag},")"}),
- 0
- end;
-emit_inner_of_decfun(_,#typedef{name=Name,typespec=Type},Prop,_) ->
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- emit({indent(12),"'dec_",Name,"'(Bytes, ",Prop,", TagIn ++ ",
- {asis,Tag},")"}),
- 0;
-emit_inner_of_decfun(Erules,Type,Prop,_) when is_record(Type,type) ->
- OTag = Type#type.tag,
- Tag = [X#tag{class=decode_class(X#tag.class)}|| X <- OTag],
- CurrMod = get(currmod),
- Def = Type#type.def,
- InnerType = asn1ct_gen:get_inner(Def),
- WhatKind = asn1ct_gen:type(InnerType),
- case WhatKind of
- {primitive,bif} ->
- emit({indent(9),Def," ->",nl,indent(12)}),
- gen_dec_prim(Erules,Type,"Bytes",Tag,"TagIn",no_length,
- ?PRIMITIVE,Prop);
-% TRef when is_record(TRef,typereference) ->
-% T = TRef#typereference.val,
-% emit({indent(9),T," ->",nl,indent(12),"'dec_",T,"'(Val)"});
- #'Externaltypereference'{module=CurrMod,type=T} ->
- emit({indent(9),T," ->",nl,indent(12),"'dec_",T,
- "'(Bytes, ",Prop,", TagIn ++ ",{asis,Tag},")"});
- #'Externaltypereference'{module=ExtMod,type=T} ->
- emit({indent(9),T," ->",nl,indent(12),ExtMod,":'dec_",
- T,"'(Bytes, ",Prop,", TagIn ++ ",{asis,Tag},")"})
- end,
- 0.
-
-
-gen_internal_funcs(_,[]) ->
- ok;
-gen_internal_funcs(Erules,[TypeDef|Rest]) ->
- gen_encode_user(Erules,TypeDef),
- emit({"'dec_",TypeDef#typedef.name,"'(Bytes, ",
- unused_optormand_var("OptOrMand",(TypeDef#typedef.typespec)#type.def),", TagIn) ->",nl}),
- gen_decode_user(Erules,TypeDef),
- gen_internal_funcs(Erules,Rest).
-
-
-dbdec(Type) ->
- demit({"io:format(\"decoding: ",{asis,Type},"~w~n\",[Bytes]),",nl}).
-
-
-decode_class('UNIVERSAL') ->
- ?UNIVERSAL;
-decode_class('APPLICATION') ->
- ?APPLICATION;
-decode_class('CONTEXT') ->
- ?CONTEXT;
-decode_class('PRIVATE') ->
- ?PRIVATE.
-
-decode_type('BOOLEAN') -> 1;
-decode_type('INTEGER') -> 2;
-decode_type('BIT STRING') -> 3;
-decode_type('OCTET STRING') -> 4;
-decode_type('NULL') -> 5;
-decode_type('OBJECT IDENTIFIER') -> 6;
-decode_type('ObjectDescriptor') -> 7;
-decode_type('EXTERNAL') -> 8;
-decode_type('REAL') -> 9;
-decode_type('ENUMERATED') -> 10;
-decode_type('EMBEDDED_PDV') -> 11;
-decode_type('UTF8String') -> 12;
-decode_type('RELATIVE-OID') -> 13;
-decode_type('SEQUENCE') -> 16;
-decode_type('SEQUENCE OF') -> 16;
-decode_type('SET') -> 17;
-decode_type('SET OF') -> 17;
-decode_type('NumericString') -> 18;
-decode_type('PrintableString') -> 19;
-decode_type('TeletexString') -> 20;
-decode_type('T61String') -> 20;
-decode_type('VideotexString') -> 21;
-decode_type('IA5String') -> 22;
-decode_type('UTCTime') -> 23;
-decode_type('GeneralizedTime') -> 24;
-decode_type('GraphicString') -> 25;
-decode_type('VisibleString') -> 26;
-decode_type('GeneralString') -> 27;
-decode_type('UniversalString') -> 28;
-decode_type('BMPString') -> 30;
-decode_type('CHOICE') -> 'CHOICE'; % choice gets the tag from the actual alternative
-decode_type(Else) -> exit({error,{asn1,{unrecognized_type,Else}}}).
-
-add_removed_bytes() ->
- asn1ct_name:delete(rb),
- add_removed_bytes(asn1ct_name:all(rb)).
-
-add_removed_bytes([H,T1|T]) ->
- emit({{var,H},"+"}),
- add_removed_bytes([T1|T]);
-add_removed_bytes([H|T]) ->
- emit({{var,H}}),
- add_removed_bytes(T);
-add_removed_bytes([]) ->
- true.
-
-mkfuncname(WhatKind,DecOrEnc) ->
- case WhatKind of
- #'Externaltypereference'{module=Mod,type=EType} ->
- CurrMod = get(currmod),
- case CurrMod of
- Mod ->
- lists:concat(["'",DecOrEnc,"_",EType,"'"]);
- _ ->
-% io:format("CurrMod: ~p, Mod: ~p~n",[CurrMod,Mod]),
- lists:concat(["'",Mod,"':'",DecOrEnc,"_",EType,"'"])
- end;
- #'typereference'{val=EType} ->
- lists:concat(["'",DecOrEnc,"_",EType,"'"]);
- 'ASN1_OPEN_TYPE' ->
- lists:concat(["'",DecOrEnc,"_",WhatKind,"'"])
-
- end.
-
-optionals(L) -> optionals(L,[],1).
-
-optionals([{'EXTENSIONMARK',_,_}|Rest],Acc,Pos) ->
- optionals(Rest,Acc,Pos); % optionals in extension are currently not handled
-optionals([#'ComponentType'{name=Name,prop='OPTIONAL'}|Rest],Acc,Pos) ->
- optionals(Rest,[{Name,Pos}|Acc],Pos+1);
-optionals([#'ComponentType'{name=Name,prop={'DEFAULT',_}}|Rest],Acc,Pos) ->
- optionals(Rest,[{Name,Pos}|Acc],Pos+1);
-optionals([#'ComponentType'{}|Rest],Acc,Pos) ->
- optionals(Rest,Acc,Pos+1);
-optionals([],Acc,_) ->
- lists:reverse(Acc).
-
-get_constraint(C,Key) ->
- case lists:keysearch(Key,1,C) of
- false ->
- no;
- {value,{_,V}} ->
- V
- end.
-
-%% if the original option was ber and it has been wrapped to ber_bin
-%% turn it back to ber
-re_wrap_erule(ber_bin) ->
- case get(encoding_options) of
- Options when is_list(Options) ->
- case lists:member(ber,Options) of
- true -> ber;
- _ -> ber_bin
- end;
- _ -> ber_bin
- end;
-re_wrap_erule(Erule) ->
- Erule.
-
-is_already_generated(Operation,Name) ->
- case get(class_default_type) of
- undefined ->
- put(class_default_type,[{Operation,Name}]),
- false;
- GeneratedList ->
- case lists:member({Operation,Name},GeneratedList) of
- true ->
- true;
- false ->
- put(class_default_type,[{Operation,Name}|GeneratedList]),
- false
- end
- end.
-
-get_class_fields(#classdef{typespec=ObjClass}) ->
- ObjClass#objectclass.fields;
-get_class_fields(#objectclass{fields=Fields}) ->
- Fields;
-get_class_fields(_) ->
- [].
-
-get_object_field(Name,ObjectFields) ->
- case lists:keysearch(Name,1,ObjectFields) of
- {value,Field} -> Field;
- false -> false
- end.
-
-%% For BER the ExtensionAdditionGroup notation has no impact on the encoding/decoding
-%% and therefore we only filter away the ExtensionAdditionGroup start and end markers
-%%
-extaddgroup2sequence(ExtList) when is_list(ExtList) ->
- lists:filter(fun(#'ExtensionAdditionGroup'{}) ->
- false;
- ('ExtensionAdditionGroupEnd') ->
- false;
- (_) ->
- true
- end, ExtList).
diff --git a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
index 3ccfca3784..00c3dd98b2 100644
--- a/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1ct_gen_ber_bin_v2.erl
@@ -116,22 +116,7 @@ gen_encode(Erules,Typename,Type) when is_record(Type,type) ->
end,
case lists:member(InnerType,['SET','SEQUENCE']) of
true ->
- case get(asn_keyed_list) of
- true ->
- CompList =
- case Type#type.def of
- #'SEQUENCE'{components=Cl} -> Cl;
- #'SET'{components=Cl} -> Cl
- end,
- emit([nl,"'enc_",asn1ct_gen:list2name(Typename),
- "'(Val, TagIn",ObjFun,
- ") when is_list(Val) ->",nl]),
- emit([" 'enc_",asn1ct_gen:list2name(Typename),
- "'(?RT_BER:fixoptionals(",
- {asis,optionals(CompList)},
- ",Val), TagIn",ObjFun,");",nl,nl]);
- _ -> true
- end;
+ true;
_ ->
emit([nl,"'enc_",asn1ct_gen:list2name(Typename),
"'({'",asn1ct_gen:list2name(Typename),
@@ -175,22 +160,7 @@ gen_encode_user(Erules,D) when is_record(D,typedef) ->
case lists:member(InnerType,['SET','SEQUENCE']) of
true ->
- case get(asn_keyed_list) of
- true ->
- CompList =
- case Type#type.def of
- #'SEQUENCE'{components=Cl} -> Cl;
- #'SET'{components=Cl} -> Cl
- end,
-
- emit([nl,"'enc_",asn1ct_gen:list2name(Typename),
- "'(Val, TagIn) when is_list(Val) ->",nl]),
- emit([" 'enc_",asn1ct_gen:list2name(Typename),
- "'(?RT_BER:fixoptionals(",
- {asis,optionals(CompList)},
- ",Val), TagIn);",nl,nl]);
- _ -> true
- end;
+ true;
_ ->
emit({nl,"'enc_",asn1ct_gen:list2name(Typename),
"'({'",asn1ct_gen:list2name(Typename),"',Val}, TagIn) ->",nl}),
@@ -1504,7 +1474,7 @@ gen_objset_dec(Erules,ObjSetName,_UniqueName,['EXTENSIONMARK'],_ClName,
emit([indent(2),"fun(_,Bytes, _RestPrimFieldName) ->",nl]),
case Erules of
- ber_bin_v2 ->
+ ber ->
emit([indent(4),"case Bytes of",nl,
indent(6),"Bin when is_binary(Bin) -> ",nl,
indent(8),"Bin;",nl,
@@ -1772,19 +1742,6 @@ mkfuncname(WhatKind,DecOrEnc) ->
end.
-optionals(L) -> optionals(L,[],1).
-
-optionals([{'EXTENSIONMARK',_,_}|Rest],Acc,Pos) ->
- optionals(Rest,Acc,Pos); % optionals in extension are currently not handled
-optionals([#'ComponentType'{name=Name,prop='OPTIONAL'}|Rest],Acc,Pos) ->
- optionals(Rest,[{Name,Pos}|Acc],Pos+1);
-optionals([#'ComponentType'{name=Name,prop={'DEFAULT',_}}|Rest],Acc,Pos) ->
- optionals(Rest,[{Name,Pos}|Acc],Pos+1);
-optionals([#'ComponentType'{}|Rest],Acc,Pos) ->
- optionals(Rest,Acc,Pos+1);
-optionals([],Acc,_) ->
- lists:reverse(Acc).
-
get_constraint(C,Key) ->
case lists:keysearch(Key,1,C) of
false ->
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index bd5b81991d..3e100fc833 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -155,7 +155,7 @@ gen_encode_prim(Erules,D,DoTag,Value) when is_record(D,type) ->
NewList = lists:concat([[{0,X}||{X,_} <- Nlist1],['EXT_MARK'],[{1,X}||{X,_} <- Nlist2]]),
NewC = [{'ValueRange',{0,length(Nlist1)-1}}],
case Erules of
- uper_bin ->
+ uper ->
emit(["case ",Value," of",nl]);
_ ->
emit(["case (case ",Value," of {_,",{curr,enumval},"}-> ",
@@ -168,7 +168,7 @@ gen_encode_prim(Erules,D,DoTag,Value) when is_record(D,type) ->
NewList = [X||{X,_} <- NamedNumberList],
NewC = [{'ValueRange',{0,length(NewList)-1}}],
case Erules of
- uper_bin ->
+ uper ->
emit(["case ",Value," of",nl]);
_ ->
emit(["case (case ",Value," of {_,",{curr,enumval},
@@ -274,7 +274,7 @@ emit_enc_enumerated_cases(Erule, C, [H1,H2|T], Count) ->
-emit_enc_enumerated_case(uper_bin,_C, {asn1_enum,High}, _) ->
+emit_enc_enumerated_case(uper,_C, {asn1_enum,High}, _) ->
emit([
"{asn1_enum,EnumV} when is_integer(EnumV), EnumV > ",High," -> ",
"[<<1:1>>,?RT_PER:encode_small_number(EnumV)]"]);
@@ -284,11 +284,11 @@ emit_enc_enumerated_case(_Per,_C, {asn1_enum,High}, _) ->
"[{bit,1},?RT_PER:encode_small_number(EnumV)]"]);
emit_enc_enumerated_case(_Erule, _C, 'EXT_MARK', _Count) ->
true;
-emit_enc_enumerated_case(uper_bin,_C, {1,EnumName}, Count) ->
+emit_enc_enumerated_case(uper,_C, {1,EnumName}, Count) ->
emit(["'",EnumName,"' -> [<<1:1>>,?RT_PER:encode_small_number(",Count,")]"]);
emit_enc_enumerated_case(_Per,_C, {1,EnumName}, Count) ->
emit(["'",EnumName,"' -> [{bit,1},?RT_PER:encode_small_number(",Count,")]"]);
-emit_enc_enumerated_case(uper_bin,C, {0,EnumName}, Count) ->
+emit_enc_enumerated_case(uper,C, {0,EnumName}, Count) ->
emit(["'",EnumName,"' -> [<<0:1>>,?RT_PER:encode_integer(",{asis,C},", ",Count,")]"]);
emit_enc_enumerated_case(_Per,C, {0,EnumName}, Count) ->
emit(["'",EnumName,"' -> [{bit,0},?RT_PER:encode_integer(",{asis,C},", ",Count,")]"]);
@@ -442,7 +442,7 @@ gen_encode_objectfields(Erule,ClassName,[{typefield,Name,OptOrMand}|Rest],
{false,'OPTIONAL'} ->
EmitFuncClause("Val"),
case Erule of
- uper_bin ->
+ uper ->
emit(" Val");
_ ->
emit(" [{octets,Val}]")
@@ -833,7 +833,7 @@ gen_objset_enc(Erule,ObjSetName,_UniqueName,['EXTENSIONMARK'],_ClName,
emit({"'getenc_",ObjSetName,"'(_, _) ->",nl}),
emit({indent(3),"fun(_, Val, _) ->",nl}),
case Erule of
- uper_bin ->
+ uper ->
emit([indent(6),"Val",nl]);
_ ->
emit([indent(6),"[{octets,Val}]",nl])
@@ -883,7 +883,7 @@ gen_inlined_enc_funs(Erule,Fields,[{typefield,Name,_}|Rest],ObjSetName,NthObj) -
emit({indent(9),{asis,Name}," ->",nl}),
emit([indent(12),"'",M,"'",":'enc_",T,"'(Val)"]),
gen_inlined_enc_funs1(Erule,Fields,Rest,ObjSetName,NthObj,[]);
- false when Erule == uper_bin ->
+ false when Erule =:= uper ->
emit([indent(3),"fun(Type,Val,_) ->",nl,
indent(6),"case Type of",nl,
indent(9),{asis,Name}," -> Val",nl]),
@@ -921,7 +921,7 @@ gen_inlined_enc_funs1(Erule,Fields,[{typefield,Name,_}|Rest],ObjSetName,
emit({";",nl,indent(9),{asis,Name}," ->",nl}),
emit([indent(12),"'",M,"'",":'enc_",T,"'(Val)"]),
{Acc,0};
- false when Erule == uper_bin ->
+ false when Erule =:= uper ->
emit([";",nl,
indent(9),{asis,Name}," -> ",nl,
"Val",nl]),
diff --git a/lib/asn1/src/asn1ct_value.erl b/lib/asn1/src/asn1ct_value.erl
index 9013baef92..6057e27b63 100644
--- a/lib/asn1/src/asn1ct_value.erl
+++ b/lib/asn1/src/asn1ct_value.erl
@@ -54,7 +54,7 @@ from_type(M,Typename,Type) when is_record(Type,type) ->
{notype,_} ->
true;
{primitive,bif} ->
- from_type_prim(Type,get_encoding_rule(M));
+ from_type_prim(Type);
'ASN1_OPEN_TYPE' ->
case Type#type.constraint of
[#'Externaltypereference'{type=TrefConstraint}] ->
@@ -164,7 +164,7 @@ gen_list(_,_,_,0) ->
gen_list(M,Typename,Oftype,N) ->
[from_type(M,Typename,Oftype)|gen_list(M,Typename,Oftype,N-1)].
-from_type_prim(D,Erule) ->
+from_type_prim(D) ->
C = D#type.constraint,
case D#type.def of
'INTEGER' ->
@@ -303,12 +303,7 @@ from_type_prim(D,Erule) ->
adjust_list(size_random(C),c_string(C,"BMPString"));
'UTF8String' ->
{ok,Res}=asn1rt:utf8_list_to_binary(adjust_list(random(50),[$U,$T,$F,$8,$S,$t,$r,$i,$n,$g,16#ffff,16#fffffff,16#ffffff,16#fffff,16#fff])),
- case Erule of
- per ->
- binary_to_list(Res);
- _ ->
- Res
- end;
+ Res;
'UniversalString' ->
adjust_list(size_random(C),c_string(C,"UniversalString"));
XX ->
@@ -440,17 +435,9 @@ get_encoding_rule(M) ->
end.
open_type_value(ber) ->
- [4,9,111,112,101,110,95,116,121,112,101];
-open_type_value(ber_bin) ->
-% [4,9,111,112,101,110,95,116,121,112,101];
- <<4,9,111,112,101,110,95,116,121,112,101>>;
-open_type_value(ber_bin_v2) ->
-% [4,9,111,112,101,110,95,116,121,112,101];
<<4,9,111,112,101,110,95,116,121,112,101>>;
open_type_value(per) ->
- "\n\topen_type"; %octet string value "open_type"
-open_type_value(per_bin) ->
- <<"\n\topen_type">>;
+ <<"\n\topen_type">>; %octet string value "open_type"
% <<10,9,111,112,101,110,95,116,121,112,101>>;
open_type_value(_) ->
[4,9,111,112,101,110,95,116,121,112,101].
diff --git a/lib/asn1/src/asn1rt_ber_bin.erl b/lib/asn1/src/asn1rt_ber_bin.erl
index 22f9f2ecfd..ec1549804b 100644
--- a/lib/asn1/src/asn1rt_ber_bin.erl
+++ b/lib/asn1/src/asn1rt_ber_bin.erl
@@ -19,337 +19,30 @@
%%
-module(asn1rt_ber_bin).
-%% encoding / decoding of BER
-
--export([decode/1]).
--export([fixoptionals/2,split_list/2,cindex/3,restbytes2/3,
- list_to_record/2,
- encode_tag_val/1,decode_tag/1,peek_tag/1,
- check_tags/3, encode_tags/3]).
--export([encode_boolean/2,decode_boolean/3,
- encode_integer/3,encode_integer/4,
- decode_integer/4,decode_integer/5,encode_enumerated/2,
- encode_enumerated/4,decode_enumerated/5,
+-export([decode_length/1,
encode_real/2, encode_real/3,
decode_real/2, decode_real/4,
- encode_bit_string/4,decode_bit_string/6,
- decode_compact_bit_string/6,
- encode_octet_string/3,decode_octet_string/5,
- encode_null/2,decode_null/3,
- encode_object_identifier/2,decode_object_identifier/3,
- encode_relative_oid/2,decode_relative_oid/3,
- encode_restricted_string/4,decode_restricted_string/6,
- encode_universal_string/3,decode_universal_string/5,
- encode_UTF8_string/3, decode_UTF8_string/3,
- encode_BMP_string/3,decode_BMP_string/5,
- encode_generalized_time/3,decode_generalized_time/5,
- encode_utc_time/3,decode_utc_time/5,
- encode_length/1,decode_length/1,
- check_if_valid_tag/3,
- decode_tag_and_length/1, decode_components/6,
- decode_components/7, decode_set/6]).
-
--export([encode_open_type/1,encode_open_type/2,decode_open_type/1,decode_open_type/2,decode_open_type/3]).
--export([skipvalue/1, skipvalue/2,skip_ExtensionAdditions/2]).
+ decode_tag/1]).
-include("asn1_records.hrl").
-% the encoding of class of tag bits 8 and 7
+%% the encoding of class of tag bits 8 and 7
-define(UNIVERSAL, 0).
--define(APPLICATION, 16#40).
--define(CONTEXT, 16#80).
--define(PRIVATE, 16#C0).
%%% primitive or constructed encoding % bit 6
-define(PRIMITIVE, 0).
-define(CONSTRUCTED, 2#00100000).
%%% The tag-number for universal types
--define(N_BOOLEAN, 1).
--define(N_INTEGER, 2).
--define(N_BIT_STRING, 3).
--define(N_OCTET_STRING, 4).
--define(N_NULL, 5).
--define(N_OBJECT_IDENTIFIER, 6).
--define(N_OBJECT_DESCRIPTOR, 7).
--define(N_EXTERNAL, 8).
-define(N_REAL, 9).
--define(N_ENUMERATED, 10).
--define(N_EMBEDDED_PDV, 11).
--define(N_UTF8String, 12).
--define('N_RELATIVE-OID',13).
--define(N_SEQUENCE, 16).
--define(N_SET, 17).
--define(N_NumericString, 18).
--define(N_PrintableString, 19).
--define(N_TeletexString, 20).
--define(N_VideotexString, 21).
--define(N_IA5String, 22).
--define(N_UTCTime, 23).
--define(N_GeneralizedTime, 24).
--define(N_GraphicString, 25).
--define(N_VisibleString, 26).
--define(N_GeneralString, 27).
--define(N_UniversalString, 28).
--define(N_BMPString, 30).
-
-
-% the complete tag-word of built-in types
--define(T_BOOLEAN, ?UNIVERSAL bor ?PRIMITIVE bor 1).
--define(T_INTEGER, ?UNIVERSAL bor ?PRIMITIVE bor 2).
--define(T_BIT_STRING, ?UNIVERSAL bor ?PRIMITIVE bor 3). % can be CONSTRUCTED
--define(T_OCTET_STRING, ?UNIVERSAL bor ?PRIMITIVE bor 4). % can be CONSTRUCTED
--define(T_NULL, ?UNIVERSAL bor ?PRIMITIVE bor 5).
--define(T_OBJECT_IDENTIFIER,?UNIVERSAL bor ?PRIMITIVE bor 6).
--define(T_OBJECT_DESCRIPTOR,?UNIVERSAL bor ?PRIMITIVE bor 7).
--define(T_EXTERNAL, ?UNIVERSAL bor ?PRIMITIVE bor 8).
--define(T_REAL, ?UNIVERSAL bor ?PRIMITIVE bor 9).
--define(T_ENUMERATED, ?UNIVERSAL bor ?PRIMITIVE bor 10).
--define(T_EMBEDDED_PDV, ?UNIVERSAL bor ?PRIMITIVE bor 11).
--define(T_SEQUENCE, ?UNIVERSAL bor ?CONSTRUCTED bor 16).
--define(T_SET, ?UNIVERSAL bor ?CONSTRUCTED bor 17).
--define(T_NumericString, ?UNIVERSAL bor ?PRIMITIVE bor 18). %can be constructed
--define(T_PrintableString, ?UNIVERSAL bor ?PRIMITIVE bor 19). %can be constructed
--define(T_TeletexString, ?UNIVERSAL bor ?PRIMITIVE bor 20). %can be constructed
--define(T_VideotexString, ?UNIVERSAL bor ?PRIMITIVE bor 21). %can be constructed
--define(T_IA5String, ?UNIVERSAL bor ?PRIMITIVE bor 22). %can be constructed
--define(T_UTCTime, ?UNIVERSAL bor ?PRIMITIVE bor 23).
--define(T_GeneralizedTime, ?UNIVERSAL bor ?PRIMITIVE bor 24).
--define(T_GraphicString, ?UNIVERSAL bor ?PRIMITIVE bor 25). %can be constructed
--define(T_VisibleString, ?UNIVERSAL bor ?PRIMITIVE bor 26). %can be constructed
--define(T_GeneralString, ?UNIVERSAL bor ?PRIMITIVE bor 27). %can be constructed
--define(T_UniversalString, ?UNIVERSAL bor ?PRIMITIVE bor 28). %can be constructed
--define(T_BMPString, ?UNIVERSAL bor ?PRIMITIVE bor 30). %can be constructed
-
-
-decode(Bin) ->
- decode_primitive(Bin).
-
-decode_primitive(Bin) ->
- {Tlv = {Tag,Len,V},<<>>} = decode_tlv(Bin),
- case element(2,Tag) of
- ?CONSTRUCTED ->
- {Tag,Len,decode_constructed(V)};
- _ ->
- Tlv
- end.
-
-decode_constructed(<<>>) ->
- [];
-decode_constructed(Bin) ->
- {Tlv = {Tag,Len,V},Rest} = decode_tlv(Bin),
- NewTlv =
- case element(2,Tag) of
- ?CONSTRUCTED ->
- {Tag,Len,decode_constructed(V)};
- _ ->
- Tlv
- end,
- [NewTlv|decode_constructed(Rest)].
-
-decode_tlv(Bin) ->
- {Tag,Bin1,_Rb1} = decode_tag(Bin),
- {{Len,Bin2},_Rb2} = decode_length(Bin1),
- <<V:Len/binary,Bin3/binary>> = Bin2,
- {{Tag,Len,V},Bin3}.
-
-
-
-%%%%%%%%%%%%%
-% split_list(List,HeadLen) -> {HeadList,TailList}
-%
-% splits List into HeadList (Length=HeadLen) and TailList
-% if HeadLen == indefinite -> return {List,indefinite}
-split_list(List,indefinite) ->
- {List, indefinite};
-split_list(Bin, Len) when is_binary(Bin) ->
- split_binary(Bin,Len);
-split_list(List,Len) ->
- {lists:sublist(List,Len),lists:nthtail(Len,List)}.
-
-%%% new function which fixes a bug regarding indefinite length decoding
-restbytes2(indefinite,<<0,0,RemBytes/binary>>,_) ->
- {RemBytes,2};
-restbytes2(indefinite,RemBytes,ext) ->
- skipvalue(indefinite,RemBytes);
-restbytes2(RemBytes,<<>>,_) ->
- {RemBytes,0};
-restbytes2(_RemBytes,Bytes,noext) ->
- exit({error,{asn1, {unexpected,Bytes}}});
-restbytes2(RemBytes,Bytes,ext) ->
-%% {RemBytes,0}.
- {RemBytes,byte_size(Bytes)}.
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% skipvalue(Length, Bytes) -> {RemainingBytes, RemovedNumberOfBytes}
-%%
-%% skips the one complete (could be nested) TLV from Bytes
-%% handles both definite and indefinite length encodings
-%%
-
-skipvalue(L, Bytes) ->
- skipvalue(L, Bytes, 0).
-
-skipvalue(L, Bytes, Rb) ->
- skipvalue(L, Bytes, Rb, 0).
-
-skipvalue(indefinite, Bytes, Rb, IndefLevel) ->
- {T,Bytes2,R2} = decode_tag(Bytes),
- {{L,Bytes3},R3} = decode_length(Bytes2),
- case {T,L} of
- {_,indefinite} ->
- skipvalue(indefinite,Bytes3,Rb+R2+R3,IndefLevel+1);
- {{0,0,0},0} when IndefLevel =:= 0 ->
- %% See X690 8.1.5 NOTE, end of indefinite content
- {Bytes3,Rb+2};
- {{0,0,0},0} ->
- skipvalue(indefinite,Bytes3,Rb+2,IndefLevel - 1);
- _ ->
- <<_:L/binary, RestBytes/binary>> = Bytes3,
- skipvalue(indefinite,RestBytes,Rb+R2+R3+L, IndefLevel)
- %%{RestBytes, R2+R3+L}
- end;
-%% case Bytes4 of
-%% <<0,0,Bytes5/binary>> ->
-%% {Bytes5,Rb+Rb4+2};
-%% _ -> skipvalue(indefinite,Bytes4,Rb+Rb4)
-%% end;
-skipvalue(L, Bytes, Rb, _) ->
-% <<Skip:L/binary, RestBytes/binary>> = Bytes,
- <<_:L/binary, RestBytes/binary>> = Bytes,
- {RestBytes,Rb+L}.
-
-
-skipvalue(Bytes) ->
- {_T,Bytes2,R2} = decode_tag(Bytes),
- {{L,Bytes3},R3} = decode_length(Bytes2),
- skipvalue(L,Bytes3,R2+R3).
-
-
-cindex(Ix,Val,Cname) ->
- case element(Ix,Val) of
- {Cname,Val2} -> Val2;
- X -> X
- end.
-
-%%%
-%% skips byte sequence of Bytes that do not match a tag in Tags
-skip_ExtensionAdditions(Bytes,Tags) ->
- skip_ExtensionAdditions(Bytes,Tags,0).
-skip_ExtensionAdditions(<<>>,_Tags,RmB) ->
- {<<>>,RmB};
-skip_ExtensionAdditions(Bytes,Tags,RmB) ->
- case catch decode_tag(Bytes) of
- {'EXIT',_Reason} ->
- tag_error(no_data,Tags,Bytes,'OPTIONAL');
- {_T={Class,_Form,TagNo},_Bytes2,_R2} ->
- case [X||X=#tag{class=Cl,number=TN} <- Tags,Cl==Class,TN==TagNo] of
- [] ->
- %% skip this TLV and continue with next
- {Bytes3,R3} = skipvalue(Bytes),
- skip_ExtensionAdditions(Bytes3,Tags,RmB+R3);
- _ ->
- {Bytes,RmB}
- end
- end.
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Optionals, preset not filled optionals with asn1_NOVALUE
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-% converts a list to a record if necessary
-list_to_record(Name,List) when is_list(List) ->
- list_to_tuple([Name|List]);
-list_to_record(_Name,Tuple) when is_tuple(Tuple) ->
- Tuple.
-
-
-fixoptionals(OptList,Val) when is_list(Val) ->
- fixoptionals(OptList,Val,1,[],[]).
-
-fixoptionals([{Name,Pos}|Ot],[{Name,Val}|Vt],_Opt,Acc1,Acc2) ->
- fixoptionals(Ot,Vt,Pos+1,[1|Acc1],[{Name,Val}|Acc2]);
-fixoptionals([{_Name,Pos}|Ot],V,Pos,Acc1,Acc2) ->
- fixoptionals(Ot,V,Pos+1,[0|Acc1],[asn1_NOVALUE|Acc2]);
-fixoptionals(O,[Vh|Vt],Pos,Acc1,Acc2) ->
- fixoptionals(O,Vt,Pos+1,Acc1,[Vh|Acc2]);
-fixoptionals([],[Vh|Vt],Pos,Acc1,Acc2) ->
- fixoptionals([],Vt,Pos+1,Acc1,[Vh|Acc2]);
-fixoptionals([],[],_,_Acc1,Acc2) ->
- % return Val as a record
- list_to_tuple([asn1_RECORDNAME|lists:reverse(Acc2)]).
-
-
-%%encode_tag(TagClass(?UNI, APP etc), Form (?PRIM etx), TagInteger) ->
-%% 8bit Int | binary
encode_tag_val({Class, Form, TagNo}) when (TagNo =< 30) ->
<<(Class bsr 6):2,(Form bsr 5):1,TagNo:5>>;
encode_tag_val({Class, Form, TagNo}) ->
{Octets,_Len} = mk_object_val(TagNo),
BinOct = list_to_binary(Octets),
- <<(Class bsr 6):2, (Form bsr 5):1, 31:5,BinOct/binary>>;
-
-%% asumes whole correct tag bitpattern, multiple of 8
-encode_tag_val(Tag) when (Tag =< 255) -> Tag; %% anv�nds denna funktion??!!
-%% asumes correct bitpattern of 0-5
-encode_tag_val(Tag) -> encode_tag_val2(Tag,[]).
-
-encode_tag_val2(Tag, OctAck) when (Tag =< 255) ->
- [Tag | OctAck];
-encode_tag_val2(Tag, OctAck) ->
- encode_tag_val2(Tag bsr 8, [255 band Tag | OctAck]).
-
-
-%%%encode_tag(TagClass(?UNI, APP etc), Form (?PRIM etx), TagInteger) ->
-%%% 8bit Int | [list of octets]
-%encode_tag_val({Class, Form, TagNo}) when (TagNo =< 30) ->
-%%% <<Class:2,Form:1,TagNo:5>>;
-% [Class bor Form bor TagNo];
-%encode_tag_val({Class, Form, TagNo}) ->
-% {Octets,L} = mk_object_val(TagNo),
-% [Class bor Form bor 31 | Octets];
-
-
-%%============================================================================\%% Peek on the initial tag
-%% peek_tag(Bytes) -> TagBytes
-%% interprets the first byte and possible second, third and fourth byte as
-%% a tag and returns all the bytes comprising the tag, the constructed/primitive bit (6:th bit of first byte) is normalised to 0
-%%
-
-peek_tag(<<B7_6:2,_:1,31:5,Buffer/binary>>) ->
- Bin = peek_tag(Buffer, <<>>),
- <<B7_6:2,31:6,Bin/binary>>;
-%% single tag (tagno < 31)
-peek_tag(<<B7_6:2,_:1,B4_0:5,_Buffer/binary>>) ->
- <<B7_6:2,B4_0:6>>.
-
-peek_tag(<<0:1,PartialTag:7,_Buffer/binary>>, TagAck) ->
- <<TagAck/binary,PartialTag>>;
-peek_tag(<<PartialTag,Buffer/binary>>, TagAck) ->
- peek_tag(Buffer,<<TagAck/binary,PartialTag>>);
-peek_tag(_,TagAck) ->
- exit({error,{asn1, {invalid_tag,TagAck}}}).
-%%peek_tag([Tag|Buffer]) when (Tag band 31) =:= 31 ->
-%% [Tag band 2#11011111 | peek_tag(Buffer,[])];
-%%%% single tag (tagno < 31)
-%%peek_tag([Tag|Buffer]) ->
-%% [Tag band 2#11011111].
-
-%%peek_tag([PartialTag|Buffer], TagAck) when (PartialTag < 128 ) ->
-%% lists:reverse([PartialTag|TagAck]);
-%%peek_tag([PartialTag|Buffer], TagAck) ->
-%% peek_tag(Buffer,[PartialTag|TagAck]);
-%%peek_tag(Buffer,TagAck) ->
-%% exit({error,{asn1, {invalid_tag,lists:reverse(TagAck)}}}).
-
+ <<(Class bsr 6):2, (Form bsr 5):1, 31:5,BinOct/binary>>.
%%===============================================================================
%% Decode a tag
@@ -403,33 +96,11 @@ check_tags_i([Tag1|TagRest], Buffer, Rb, OptOrMand) ->
_ ->
check_tags_i(TagRest, Buffer2, Rb + Rb1, mandatory)
end
- end;
-
-check_tags_i([], Buffer, Rb, _) ->
- {[],{{0,0},Buffer,Rb}}.
+ end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This function is called from generated code
-check_tags([Tag], Buffer, OptOrMand) -> % optimized very usual case
- check_one_tag(Tag, Buffer, OptOrMand);
-check_tags(Tags, Buffer, OptOrMand) ->
- check_tags(Tags, Buffer, 0, OptOrMand).
-
-check_tags([Tag1,Tag2|TagRest], Buffer, Rb, OptOrMand)
- when Tag1#tag.type == 'IMPLICIT' ->
- check_tags([Tag1#tag{type=Tag2#tag.type}|TagRest], Buffer, Rb, OptOrMand);
-
-check_tags([Tag1|TagRest], Buffer, Rb, OptOrMand) ->
- {Form_Length,Buffer2,Rb1} = check_one_tag(Tag1, Buffer, OptOrMand),
- case TagRest of
- [] -> {Form_Length, Buffer2, Rb + Rb1};
- _ -> check_tags(TagRest, Buffer2, Rb + Rb1, mandatory)
- end;
-
-check_tags([], Buffer, Rb, _) ->
- {{0,0},Buffer,Rb}.
-
check_one_tag(Tag=#tag{class=ExpectedClass,number=ExpectedNumber}, Buffer, OptOrMand) ->
case catch decode_tag(Buffer) of
{'EXIT',_Reason} ->
@@ -491,382 +162,6 @@ encode_one_tag(#tag{class=Class,number=No,type=Type, form = Form}) ->
Bytes = encode_tag_val({Class,NewForm,No}),
{Bytes,size(Bytes)}.
-%%===============================================================================
-%% Change the tag (used when an implicit tagged type has a reference to something else)
-%% The constructed bit in the tag is taken from the tag to be replaced.
-%%
-%% change_tag(NewTag,[Tag,Buffer]) -> [NewTag,Buffer]
-%%===============================================================================
-
-%change_tag({NewClass,NewTagNr}, Buffer) ->
-% {{OldClass, OldForm, OldTagNo}, Buffer1, RemovedBytes} = decode_tag(lists:flatten(Buffer)),
-% [encode_tag_val({NewClass, OldForm, NewTagNr}) | Buffer1].
-
-
-%%===============================================================================
-%%
-%% This comment is valid for all the encode/decode functions
-%%
-%% C = Constraint -> typically {'ValueRange',LowerBound,UpperBound}
-%% used for PER-coding but not for BER-coding.
-%%
-%% Val = Value. If Val is an atom then it is a symbolic integer value
-%% (i.e the atom must be one of the names in the NamedNumberList).
-%% The NamedNumberList is used to translate the atom to an integer value
-%% before encoding.
-%%
-%%===============================================================================
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% encode_open_type(Value) -> CompleteList
-%% Value = list of bytes of an already encoded value (the list must be flat)
-%% | binary
-
-%% This version does not consider Explicit tagging of the open type. It
-%% is only left because of backward compatibility.
-encode_open_type(Val) when is_list(Val) ->
- {Val, byte_size(list_to_binary(Val))};
-encode_open_type(Val) ->
- {Val, byte_size(Val)}.
-
-%%
-encode_open_type(Val, []) when is_list(Val) ->
- {Val, byte_size(list_to_binary(Val))};
-encode_open_type(Val, []) ->
- {Val, byte_size(Val)};
-encode_open_type(Val, Tag) when is_list(Val) ->
- encode_tags(Tag, Val, byte_size(list_to_binary(Val)));
-encode_open_type(Val, Tag) ->
- encode_tags(Tag, Val, byte_size(Val)).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_open_type(Buffer) -> Value
-%% Bytes = [byte] with BER encoded data
-%% Value = [byte] with decoded data (which must be decoded again as some type)
-%%
-decode_open_type(Bytes) ->
-% {_Tag, Len, _RemainingBuffer, RemovedBytes} = decode_tag_and_length(Bytes),
-% N = Len + RemovedBytes,
- {_Tag, Len, RemainingBuffer, RemovedBytes} = decode_tag_and_length(Bytes),
- {_RemainingBuffer2, RemovedBytes2} = skipvalue(Len, RemainingBuffer, RemovedBytes),
- N = RemovedBytes2,
- <<Val:N/binary, RemainingBytes/binary>> = Bytes,
-% {Val, RemainingBytes, Len + RemovedBytes}.
- {Val,RemainingBytes,N}.
-
-decode_open_type(<<>>,[]=ExplTag) -> % R9C-0.patch-40
- exit({error, {asn1,{no_optional_tag, ExplTag}}});
-decode_open_type(Bytes,ExplTag) ->
- {Tag, Len, RemainingBuffer, RemovedBytes} = decode_tag_and_length(Bytes),
- case {Tag,ExplTag} of
-% {{Class,Form,32},[#tag{class=Class,number=No,form=32}]} ->
-% {_Tag2, Len2, RemainingBuffer2, RemovedBytes2} = decode_tag_and_length(RemainingBuffer),
-% {_RemainingBuffer3, RemovedBytes3} = skipvalue(Len2, RemainingBuffer2, RemovedBytes2),
-% N = RemovedBytes3,
-% <<_:RemovedBytes/unit:8,Val:N/binary,RemainingBytes/binary>> = Bytes,
-% {Val, RemainingBytes, N + RemovedBytes};
- {{Class,Form,No},[#tag{class=Class,number=No,form=Form}]} ->
- {_RemainingBuffer2, RemovedBytes2} =
- skipvalue(Len, RemainingBuffer),
- N = RemovedBytes2,
- <<_:RemovedBytes/unit:8,Val:N/binary,RemainingBytes/binary>> = Bytes,
- {Val, RemainingBytes, N + RemovedBytes};
- _ ->
- {_RemainingBuffer2, RemovedBytes2} =
- skipvalue(Len, RemainingBuffer, RemovedBytes),
- N = RemovedBytes2,
- <<Val:N/binary, RemainingBytes/binary>> = Bytes,
- {Val, RemainingBytes, N}
- end.
-
-decode_open_type(ber_bin,Bytes,ExplTag) ->
- decode_open_type(Bytes,ExplTag);
-decode_open_type(ber,Bytes,ExplTag) ->
- {Val,RemBytes,Len}=decode_open_type(Bytes,ExplTag),
- {binary_to_list(Val),RemBytes,Len}.
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Boolean, ITU_T X.690 Chapter 8.2
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-%%===============================================================================
-%% encode_boolean(Integer, tag | notag) -> [octet list]
-%%===============================================================================
-
-encode_boolean({Name, Val}, DoTag) when is_atom(Name) ->
- dotag(DoTag, ?N_BOOLEAN, encode_boolean(Val));
-encode_boolean(true,[]) ->
- {[1,1,16#FF],3};
-encode_boolean(false,[]) ->
- {[1,1,0],3};
-encode_boolean(Val, DoTag) ->
- dotag(DoTag, ?N_BOOLEAN, encode_boolean(Val)).
-
-%% encode_boolean(Boolean) -> [Len, Boolean] = [1, $FF | 0]
-encode_boolean(true) -> {[16#FF],1};
-encode_boolean(false) -> {[0],1};
-encode_boolean(X) -> exit({error,{asn1, {encode_boolean, X}}}).
-
-
-%%===============================================================================
-%% decode_boolean(BuffList, HasTag, TotalLen) -> {true, Remain, RemovedBytes} |
-%% {false, Remain, RemovedBytes}
-%%===============================================================================
-
-decode_boolean(Buffer, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_BOOLEAN}),
- decode_boolean_notag(Buffer, NewTags, OptOrMand).
-
-decode_boolean_notag(Buffer, Tags, OptOrMand) ->
- {RestTags, {FormLen,Buffer0,Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val,Buffer1,Rb1} = decode_boolean_notag(Buffer00, RestTags, OptOrMand),
- {Buffer2, Rb2} = restbytes2(RestBytes,Buffer1,noext),
- {Val, Buffer2, Rb0+Rb1+Rb2};
- {_,_} ->
- decode_boolean2(Buffer0, Rb0)
- end.
-
-decode_boolean2(<<0:8, Buffer/binary>>, RemovedBytes) ->
- {false, Buffer, RemovedBytes + 1};
-decode_boolean2(<<_:8, Buffer/binary>>, RemovedBytes) ->
- {true, Buffer, RemovedBytes + 1};
-decode_boolean2(Buffer, _) ->
- exit({error,{asn1, {decode_boolean, Buffer}}}).
-
-
-%%===========================================================================
-%% Integer, ITU_T X.690 Chapter 8.3
-
-%% encode_integer(Constraint, Value, Tag) -> [octet list]
-%% encode_integer(Constraint, Name, NamedNumberList, Tag) -> [octet list]
-%% Value = INTEGER | {Name,INTEGER}
-%% Tag = tag | notag
-%%===========================================================================
-
-encode_integer(C, Val, []) when is_integer(Val) ->
- {EncVal,Len} = encode_integer(C, Val),
- dotag_universal(?N_INTEGER,EncVal,Len);
-encode_integer(C, Val, Tag) when is_integer(Val) ->
- dotag(Tag, ?N_INTEGER, encode_integer(C, Val));
-encode_integer(C,{Name,Val},Tag) when is_atom(Name) ->
- encode_integer(C,Val,Tag);
-encode_integer(_, Val, _) ->
- exit({error,{asn1, {encode_integer, Val}}}).
-
-
-encode_integer(C, Val, NamedNumberList, Tag) when is_atom(Val) ->
- case lists:keyfind(Val, 1, NamedNumberList) of
- {_, NewVal} ->
- dotag(Tag, ?N_INTEGER, encode_integer(C, NewVal));
- _ ->
- exit({error,{asn1, {encode_integer_namednumber, Val}}})
- end;
-encode_integer(C,{_,Val},NamedNumberList,Tag) ->
- encode_integer(C,Val,NamedNumberList,Tag);
-encode_integer(C, Val, _NamedNumberList, Tag) ->
- dotag(Tag, ?N_INTEGER, encode_integer(C, Val)).
-
-
-encode_integer(_C, Val) ->
- Bytes =
- if
- Val >= 0 ->
- encode_integer_pos(Val, []);
- true ->
- encode_integer_neg(Val, [])
- end,
- {Bytes,length(Bytes)}.
-
-encode_integer_pos(0, L=[B|_Acc]) when B < 128 ->
- L;
-encode_integer_pos(N, Acc) ->
- encode_integer_pos((N bsr 8), [N band 16#ff| Acc]).
-
-encode_integer_neg(-1, L=[B1|_T]) when B1 > 127 ->
- L;
-encode_integer_neg(N, Acc) ->
- encode_integer_neg(N bsr 8, [N band 16#ff|Acc]).
-
-%%===============================================================================
-%% decode integer
-%% (Buffer, Range, HasTag, TotalLen) -> {Integer, Remain, RemovedBytes}
-%% (Buffer, Range, NamedNumberList, HasTag, TotalLen) -> {Integer, Remain, RemovedBytes}
-%%===============================================================================
-
-decode_integer(Buffer, Range, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_INTEGER}),
- decode_integer_notag(Buffer, Range, [], NewTags, OptOrMand).
-
-decode_integer(Buffer, Range, NamedNumberList, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_INTEGER}),
- decode_integer_notag(Buffer, Range, NamedNumberList, NewTags, OptOrMand).
-
-decode_integer_notag(Buffer, Range, NamedNumberList, NewTags, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(NewTags, Buffer, OptOrMand),
-% Result = {Val, Buffer2, RemovedBytes} =
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00, RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_integer_notag(Buffer00, Range, NamedNumberList,
- RestTags, OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_, Len} ->
- Result =
- decode_integer2(Len,Buffer0,Rb0+Len),
- Result2 = check_integer_constraint(Result,Range),
- resolve_named_value(Result2,NamedNumberList)
- end.
-
-resolve_named_value(Result={Val,Buffer,RemBytes},NamedNumberList) ->
- case NamedNumberList of
- [] -> Result;
- _ ->
- NewVal = case lists:keyfind(Val, 2, NamedNumberList) of
- {NamedVal, _} ->
- NamedVal;
- _ ->
- Val
- end,
- {NewVal, Buffer, RemBytes}
- end.
-
-check_integer_constraint(Result={Val, _Buffer,_},Range) ->
- case Range of
- [] -> % No length constraint
- Result;
- {Lb,Ub} when Val >= Lb, Ub >= Val -> % variable length constraint
- Result;
- Val -> % fixed value constraint
- Result;
- {_,_} ->
- exit({error,{asn1,{integer_range,Range,Val}}});
- SingleValue when is_integer(SingleValue) ->
- exit({error,{asn1,{integer_range,Range,Val}}});
- _ -> % some strange constraint that we don't support yet
- Result
- end.
-
-%%============================================================================
-%% Enumerated value, ITU_T X.690 Chapter 8.4
-
-%% encode enumerated value
-%%============================================================================
-encode_enumerated(Val, []) when is_integer(Val) ->
- {EncVal,Len} = encode_integer(false,Val),
- dotag_universal(?N_ENUMERATED,EncVal,Len);
-encode_enumerated(Val, DoTag) when is_integer(Val) ->
- dotag(DoTag, ?N_ENUMERATED, encode_integer(false,Val));
-encode_enumerated({Name,Val}, DoTag) when is_atom(Name) ->
- encode_enumerated(Val, DoTag).
-
-%% The encode_enumerated functions below this line can be removed when the
-%% new code generation is stable. (the functions might have to be kept here
-%% a while longer for compatibility reasons)
-
-encode_enumerated(C, Val, {NamedNumberList,ExtList}, DoTag) when is_atom(Val) ->
- case catch encode_enumerated(C, Val, NamedNumberList, DoTag) of
- {'EXIT',_} -> encode_enumerated(C, Val, ExtList, DoTag);
- Result -> Result
- end;
-
-encode_enumerated(C, Val, NamedNumberList, DoTag) when is_atom(Val) ->
- case lists:keyfind(Val, 1, NamedNumberList) of
- {_, NewVal} when DoTag =:= [] ->
- {EncVal,Len} = encode_integer(C,NewVal),
- dotag_universal(?N_ENUMERATED,EncVal,Len);
- {_, NewVal} ->
- dotag(DoTag, ?N_ENUMERATED, encode_integer(C, NewVal));
- _ ->
- exit({error,{asn1, {enumerated_not_in_range, Val}}})
- end;
-
-encode_enumerated(C, {asn1_enum, Val}, {_,_}, DoTag) when is_integer(Val) ->
- dotag(DoTag, ?N_ENUMERATED, encode_integer(C,Val));
-
-encode_enumerated(C, {Name,Val}, NamedNumberList, DoTag) when is_atom(Name) ->
- encode_enumerated(C, Val, NamedNumberList, DoTag);
-
-encode_enumerated(_, Val, _, _) ->
- exit({error,{asn1, {enumerated_not_namednumber, Val}}}).
-
-
-
-%%============================================================================
-%% decode enumerated value
-%% (Buffer, Range, NamedNumberList, HasTag, TotalLen) ->
-%% {Value, RemainingBuffer, RemovedBytes}
-%%===========================================================================
-decode_enumerated(Buffer, Range, NamedNumberList, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_ENUMERATED}),
- decode_enumerated_notag(Buffer, Range, NamedNumberList,
- NewTags, OptOrMand).
-
-decode_enumerated_notag(Buffer, Range, NNList = {NamedNumberList,ExtList}, Tags, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
-
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_enumerated_notag(Buffer00, Range, NNList, RestTags, OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,Len} ->
- {Val01, Buffer01, Rb01} =
- decode_integer2(Len, Buffer0, Rb0+Len),
- case decode_enumerated1(Val01, NamedNumberList) of
- {asn1_enum,Val01} ->
- {decode_enumerated1(Val01,ExtList), Buffer01, Rb01};
- Result01 ->
- {Result01, Buffer01, Rb01}
- end
- end;
-
-decode_enumerated_notag(Buffer, Range, NNList, Tags, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
-
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_enumerated_notag(Buffer00, Range, NNList, RestTags, OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,Len} ->
- {Val01, Buffer02, Rb02} =
- decode_integer2(Len, Buffer0, Rb0+Len),
- case decode_enumerated1(Val01, NNList) of
- {asn1_enum,_} ->
- exit({error,{asn1, {illegal_enumerated, Val01}}});
- Result01 ->
- {Result01, Buffer02, Rb02}
- end
- end.
-
-decode_enumerated1(Val, NamedNumberList) ->
- %% it must be a named integer
- case lists:keyfind(Val, 2, NamedNumberList) of
- {NamedVal, _} ->
- NamedVal;
- _ ->
- {asn1_enum,Val}
- end.
-
-
%%============================================================================
%%
%% Real value, ITU_T X.690 Chapter 8.5
@@ -1117,513 +412,15 @@ decode_real2(Buffer0, _C, Len, RemBytes1) ->
{{Mantissa, Base, Exp}, Buffer4, RemBytes2+RemBytes3}
end.
+encode_integer_pos(0, L=[B|_Acc]) when B < 128 ->
+ L;
+encode_integer_pos(N, Acc) ->
+ encode_integer_pos((N bsr 8), [N band 16#ff| Acc]).
-%%============================================================================
-%% Bitstring value, ITU_T X.690 Chapter 8.6
-%%
-%% encode bitstring value
-%%
-%% bitstring NamedBitList
-%% Val can be of:
-%% - [identifiers] where only named identifers are set to one,
-%% the Constraint must then have some information of the
-%% bitlength.
-%% - [list of ones and zeroes] all bits
-%% - integer value representing the bitlist
-%% C is constrint Len, only valid when identifiers
-%%============================================================================
-
-encode_bit_string(C,Bin={Unused,BinBits},NamedBitList,DoTag) when is_integer(Unused), is_binary(BinBits) ->
- encode_bin_bit_string(C,Bin,NamedBitList,DoTag);
-encode_bit_string(C, [FirstVal | RestVal], NamedBitList, DoTag) when is_atom(FirstVal) ->
- encode_bit_string_named(C, [FirstVal | RestVal], NamedBitList, DoTag);
-
-encode_bit_string(C, [{bit,X} | RestVal], NamedBitList, DoTag) ->
- encode_bit_string_named(C, [{bit,X} | RestVal], NamedBitList, DoTag);
-
-encode_bit_string(C, [FirstVal| RestVal], NamedBitList, DoTag) when is_integer(FirstVal) ->
- encode_bit_string_bits(C, [FirstVal | RestVal], NamedBitList, DoTag);
-
-encode_bit_string(_, 0, _, []) ->
- {[?N_BIT_STRING,1,0],3};
-
-encode_bit_string(_, 0, _, DoTag) ->
- dotag(DoTag, ?N_BIT_STRING, {<<0>>,1});
-
-encode_bit_string(_, [], _, []) ->
- {[?N_BIT_STRING,1,0],3};
-
-encode_bit_string(_, [], _, DoTag) ->
- dotag(DoTag, ?N_BIT_STRING, {<<0>>,1});
-
-encode_bit_string(C, IntegerVal, NamedBitList, DoTag) when is_integer(IntegerVal) ->
- BitListVal = int_to_bitlist(IntegerVal),
- encode_bit_string_bits(C, BitListVal, NamedBitList, DoTag);
-
-encode_bit_string(C, {Name,BitList}, NamedBitList, DoTag) when is_atom(Name) ->
- encode_bit_string(C, BitList, NamedBitList, DoTag).
-
-
-
-int_to_bitlist(0) ->
- [];
-int_to_bitlist(Int) when is_integer(Int), Int >= 0 ->
- [Int band 1 | int_to_bitlist(Int bsr 1)].
-
-
-%%=================================================================
-%% Encode BIT STRING of the form {Unused,BinBits}.
-%% Unused is the number of unused bits in the last byte in BinBits
-%% and BinBits is a binary representing the BIT STRING.
-%%=================================================================
-encode_bin_bit_string(C,{Unused,BinBits},_NamedBitList,DoTag)->
- case get_constraint(C,'SizeConstraint') of
- no ->
- remove_unused_then_dotag(DoTag,?N_BIT_STRING,Unused,BinBits);
- {_Min,Max} ->
- BBLen = (size(BinBits)*8)-Unused,
- if
- BBLen > Max ->
- exit({error,{asn1,
- {bitstring_length,
- {{was,BBLen},{maximum,Max}}}}});
- true ->
- remove_unused_then_dotag(DoTag,?N_BIT_STRING,
- Unused,BinBits)
- end;
- Size ->
- case ((size(BinBits)*8)-Unused) of
- BBSize when BBSize =< Size ->
- remove_unused_then_dotag(DoTag,?N_BIT_STRING,
- Unused,BinBits);
- BBSize ->
- exit({error,{asn1,
- {bitstring_length,
- {{was,BBSize},{should_be,Size}}}}})
- end
- end.
-
-remove_unused_then_dotag(DoTag,StringType,Unused,BinBits) ->
- case Unused of
- 0 when (byte_size(BinBits) =:= 0), DoTag =:= [] ->
- %% time optimization of next case
- {[StringType,1,0],3};
- 0 when (byte_size(BinBits) =:= 0) ->
- dotag(DoTag,StringType,{<<0>>,1});
- 0 when DoTag =:= [] -> % time optimization of next case
- dotag_universal(StringType,[Unused|[BinBits]],size(BinBits)+1);
-% {LenEnc,Len} = encode_legth(size(BinBits)+1),
-% {[StringType,LenEnc,[Unused|BinBits]],size(BinBits)+1+Len+1};
- 0 ->
- dotag(DoTag,StringType,<<Unused,BinBits/binary>>);
- Num when DoTag =:= [] -> % time optimization of next case
- N = byte_size(BinBits) - 1,
- <<BBits:N/binary,LastByte>> = BinBits,
- dotag_universal(StringType,
- [Unused,BBits,(LastByte bsr Num) bsl Num],
- byte_size(BinBits) + 1);
-% {LenEnc,Len} = encode_legth(size(BinBits)+1),
-% {[StringType,LenEnc,[Unused,BBits,(LastByte bsr Num) bsl Num],
-% 1+Len+size(BinBits)+1};
- Num ->
- N = byte_size(BinBits) - 1,
- <<BBits:N/binary,LastByte>> = BinBits,
- dotag(DoTag,StringType,{[Unused,binary_to_list(BBits) ++
- [(LastByte bsr Num) bsl Num]],
- byte_size(BinBits) + 1})
- end.
-
-
-%%=================================================================
-%% Encode named bits
-%%=================================================================
-
-encode_bit_string_named(C, [FirstVal | RestVal], NamedBitList, DoTag) ->
- {Len,Unused,OctetList} =
- case get_constraint(C,'SizeConstraint') of
- no ->
- ToSetPos = get_all_bitposes([FirstVal | RestVal],
- NamedBitList, []),
- BitList = make_and_set_list(lists:max(ToSetPos)+1,
- ToSetPos, 0),
- encode_bitstring(BitList);
- {_Min,Max} ->
- ToSetPos = get_all_bitposes([FirstVal | RestVal],
- NamedBitList, []),
- BitList = make_and_set_list(Max, ToSetPos, 0),
- encode_bitstring(BitList);
- Size ->
- ToSetPos = get_all_bitposes([FirstVal | RestVal],
- NamedBitList, []),
- BitList = make_and_set_list(Size, ToSetPos, 0),
- encode_bitstring(BitList)
- end,
- case DoTag of
- [] ->
- dotag_universal(?N_BIT_STRING,[Unused|OctetList],Len+1);
-% {EncLen,LenLen} = encode_length(Len+1),
-% {[?N_BIT_STRING,EncLen,Unused,OctetList],1+LenLen+Len+1};
- _ ->
- dotag(DoTag, ?N_BIT_STRING, {[Unused|OctetList],Len+1})
- end.
-
-
-%%----------------------------------------
-%% get_all_bitposes([list of named bits to set], named_bit_db, []) ->
-%% [sorted_list_of_bitpositions_to_set]
-%%----------------------------------------
-
-get_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) ->
- get_all_bitposes(Rest, NamedBitList, [ValPos | Ack ]);
-get_all_bitposes([Val | Rest], NamedBitList, Ack) when is_atom(Val) ->
- case lists:keyfind(Val, 1, NamedBitList) of
- {_ValName, ValPos} ->
- get_all_bitposes(Rest, NamedBitList, [ValPos | Ack]);
- _ ->
- exit({error,{asn1, {bitstring_namedbit, Val}}})
- end;
-get_all_bitposes([], _NamedBitList, Ack) ->
- lists:sort(Ack).
-
-
-%%----------------------------------------
-%% make_and_set_list(Len of list to return, [list of positions to set to 1])->
-%% returns list of Len length, with all in SetPos set.
-%% in positioning in list the first element is 0, the second 1 etc.., but
-%% Len will make a list of length Len, not Len + 1.
-%% BitList = make_and_set_list(C, ToSetPos, 0),
-%%----------------------------------------
-
-make_and_set_list(0, [], _) -> [];
-make_and_set_list(0, _, _) ->
- exit({error,{asn1,bitstring_sizeconstraint}});
-make_and_set_list(Len, [XPos|SetPos], XPos) ->
- [1 | make_and_set_list(Len - 1, SetPos, XPos + 1)];
-make_and_set_list(Len, [Pos|SetPos], XPos) ->
- [0 | make_and_set_list(Len - 1, [Pos | SetPos], XPos + 1)];
-make_and_set_list(Len, [], XPos) ->
- [0 | make_and_set_list(Len - 1, [], XPos + 1)].
-
-
-%%=================================================================
-%% Encode bit string for lists of ones and zeroes
-%%=================================================================
-encode_bit_string_bits(C, BitListVal, _NamedBitList, DoTag) when is_list(BitListVal) ->
- {Len,Unused,OctetList} =
- case get_constraint(C,'SizeConstraint') of
- no ->
- encode_bitstring(BitListVal);
- Constr={Min,_Max} when is_integer(Min) ->
- encode_constr_bit_str_bits(Constr,BitListVal,DoTag);
- {Constr={_,_},[]} ->
- %% constraint with extension mark
- encode_constr_bit_str_bits(Constr,BitListVal,DoTag);
- Constr={{_,_},{_,_}} ->%{{Min1,Max1},{Min2,Max2}}
- %% constraint with extension mark
- encode_constr_bit_str_bits(Constr,BitListVal,DoTag);
- Size ->
- case length(BitListVal) of
- BitSize when BitSize =:= Size ->
- encode_bitstring(BitListVal);
- BitSize when BitSize < Size ->
- PaddedList =
- pad_bit_list(Size-BitSize,BitListVal),
- encode_bitstring(PaddedList);
- BitSize ->
- exit({error,
- {asn1,
- {bitstring_length,
- {{was,BitSize},
- {should_be,Size}}}}})
- end
- end,
- %%add unused byte to the Len
- case DoTag of
- [] ->
- dotag_universal(?N_BIT_STRING,[Unused|OctetList],Len+1);
-% {EncLen,LenLen}=encode_length(Len+1),
-% {[?N_BIT_STRING,EncLen,Unused|OctetList],1+LenLen+Len+1};
- _ ->
- dotag(DoTag, ?N_BIT_STRING,
- {[Unused | OctetList],Len+1})
- end.
-
-
-encode_constr_bit_str_bits({{_Min1,Max1},{Min2,Max2}},BitListVal,_DoTag) ->
- BitLen = length(BitListVal),
- case BitLen of
- Len when Len > Max2 ->
- exit({error,{asn1,{bitstring_length,{{was,BitLen},
- {maximum,Max2}}}}});
- Len when Len > Max1, Len < Min2 ->
- exit({error,{asn1,{bitstring_length,{{was,BitLen},
- {not_allowed_interval,
- Max1,Min2}}}}});
- _ ->
- encode_bitstring(BitListVal)
- end;
-encode_constr_bit_str_bits({Min,Max},BitListVal,_DoTag) ->
- BitLen = length(BitListVal),
- if
- BitLen > Max ->
- exit({error,{asn1,{bitstring_length,{{was,BitLen},
- {maximum,Max}}}}});
- BitLen < Min ->
- exit({error,{asn1,{bitstring_length,{{was,BitLen},
- {minimum,Min}}}}});
- true ->
- encode_bitstring(BitListVal)
- end.
-
-
-%% returns a list of length Size + length(BitListVal), with BitListVal
-%% as the most significant elements followed by padded zero elements
-pad_bit_list(Size,BitListVal) ->
- Tail = lists:duplicate(Size,0),
- BitListVal ++ Tail.
-
-%%=================================================================
-%% Do the actual encoding
-%% ([bitlist]) -> {ListLen, UnusedBits, OctetList}
-%%=================================================================
-
-encode_bitstring([B8, B7, B6, B5, B4, B3, B2, B1 | Rest]) ->
- Val = (B8 bsl 7) bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4) bor
- (B4 bsl 3) bor (B3 bsl 2) bor (B2 bsl 1) bor B1,
- encode_bitstring(Rest, [Val], 1);
-encode_bitstring(Val) ->
- {Unused, Octet} = unused_bitlist(Val, 7, 0),
- {1, Unused, [Octet]}.
-
-encode_bitstring([B8, B7, B6, B5, B4, B3, B2, B1 | Rest], Ack, Len) ->
- Val = (B8 bsl 7) bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4) bor
- (B4 bsl 3) bor (B3 bsl 2) bor (B2 bsl 1) bor B1,
- encode_bitstring(Rest, [Ack | [Val]], Len + 1);
-%%even multiple of 8 bits..
-encode_bitstring([], Ack, Len) ->
- {Len, 0, Ack};
-%% unused bits in last octet
-encode_bitstring(Rest, Ack, Len) ->
-% io:format("uneven ~w ~w ~w~n",[Rest, Ack, Len]),
- {Unused, Val} = unused_bitlist(Rest, 7, 0),
- {Len + 1, Unused, [Ack | [Val]]}.
-
-%%%%%%%%%%%%%%%%%%
-%% unused_bitlist([list of ones and zeros <= 7], 7, []) ->
-%% {Unused bits, Last octet with bits moved to right}
-unused_bitlist([], Trail, Ack) ->
- {Trail + 1, Ack};
-unused_bitlist([Bit | Rest], Trail, Ack) ->
-%% io:format("trail Bit: ~w Rest: ~w Trail: ~w Ack:~w~n",[Bit, Rest, Trail, Ack]),
- unused_bitlist(Rest, Trail - 1, (Bit bsl Trail) bor Ack).
-
-
-%%============================================================================
-%% decode bitstring value
-%% (Buffer, Range, NamedNumberList, HasTag, TotalLen) -> {Integer, Remain, RemovedBytes}
-%%============================================================================
-
-decode_compact_bit_string(Buffer, Range, NamedNumberList, Tags, LenIn, OptOrMand) ->
-% NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_BIT_STRING}),
- decode_restricted_string(Buffer, Range, ?N_BIT_STRING, Tags, LenIn,
- NamedNumberList, OptOrMand,bin).
-
-decode_bit_string(Buffer, Range, NamedNumberList, Tags, LenIn, OptOrMand) ->
-% NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_BIT_STRING}),
- decode_restricted_string(Buffer, Range, ?N_BIT_STRING, Tags, LenIn,
- NamedNumberList, OptOrMand,old).
-
-
-decode_bit_string2(1,<<0 ,Buffer/binary>>,_NamedNumberList,RemovedBytes,BinOrOld) ->
- case BinOrOld of
- bin ->
- {{0,<<>>},Buffer,RemovedBytes};
- _ ->
- {[], Buffer, RemovedBytes}
- end;
-decode_bit_string2(Len,<<Unused,Buffer/binary>>,NamedNumberList,
- RemovedBytes,BinOrOld) ->
- L = Len - 1,
- <<Bits:L/binary,BufferTail/binary>> = Buffer,
- case NamedNumberList of
- [] ->
- case BinOrOld of
- bin ->
- {{Unused,Bits},BufferTail,RemovedBytes};
- _ ->
- BitString = decode_bitstring2(L, Unused, Buffer),
- {BitString,BufferTail, RemovedBytes}
- end;
- _ ->
- BitString = decode_bitstring2(L, Unused, Buffer),
- {decode_bitstring_NNL(BitString,NamedNumberList),
- BufferTail,
- RemovedBytes}
- end.
-
-%%----------------------------------------
-%% Decode the in buffer to bits
-%%----------------------------------------
-decode_bitstring2(1,Unused,<<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,_/binary>>) ->
- lists:sublist([B7,B6,B5,B4,B3,B2,B1,B0],8-Unused);
-decode_bitstring2(Len, Unused,
- <<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,Buffer/binary>>) ->
- [B7, B6, B5, B4, B3, B2, B1, B0 |
- decode_bitstring2(Len - 1, Unused, Buffer)].
-
-%%decode_bitstring2(1, Unused, Buffer) ->
-%% make_bits_of_int(hd(Buffer), 128, 8-Unused);
-%%decode_bitstring2(Len, Unused, [BitVal | Buffer]) ->
-%% [B7, B6, B5, B4, B3, B2, B1, B0] = make_bits_of_int(BitVal, 128, 8),
-%% [B7, B6, B5, B4, B3, B2, B1, B0 |
-%% decode_bitstring2(Len - 1, Unused, Buffer)].
-
-
-%%make_bits_of_int(_, _, 0) ->
-%% [];
-%%make_bits_of_int(BitVal, MaskVal, Unused) when Unused > 0 ->
-%% X = case MaskVal band BitVal of
-%% 0 -> 0 ;
-%% _ -> 1
-%% end,
-%% [X | make_bits_of_int(BitVal, MaskVal bsr 1, Unused - 1)].
-
-
-
-%%----------------------------------------
-%% Decode the bitlist to names
-%%----------------------------------------
-
-decode_bitstring_NNL(BitList,NamedNumberList) ->
- decode_bitstring_NNL(BitList,NamedNumberList,0,[]).
-
-
-decode_bitstring_NNL([],_,_No,Result) ->
- lists:reverse(Result);
-
-decode_bitstring_NNL([B|BitList],[{Name,No}|NamedNumberList],No,Result) ->
- if
- B =:= 0 ->
- decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result);
- true ->
- decode_bitstring_NNL(BitList,NamedNumberList,No+1,[Name|Result])
- end;
-decode_bitstring_NNL([1|BitList],NamedNumberList,No,Result) ->
- decode_bitstring_NNL(BitList,NamedNumberList,No+1,[{bit,No}|Result]);
-decode_bitstring_NNL([0|BitList],NamedNumberList,No,Result) ->
- decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result).
-
-
-%%============================================================================
-%% Octet string, ITU_T X.690 Chapter 8.7
-%%
-%% encode octet string
-%% The OctetList must be a flat list of integers in the range 0..255
-%% the function does not check this because it takes to much time
-%%============================================================================
-encode_octet_string(_C, OctetList, []) when is_binary(OctetList) ->
- dotag_universal(?N_OCTET_STRING,OctetList,byte_size(OctetList));
-encode_octet_string(_C, OctetList, DoTag) when is_binary(OctetList) ->
- dotag(DoTag, ?N_OCTET_STRING, {OctetList,byte_size(OctetList)});
-encode_octet_string(_C, OctetList, DoTag) when is_list(OctetList) ->
- case length(OctetList) of
- Len when DoTag =:= [] ->
- dotag_universal(?N_OCTET_STRING,OctetList,Len);
- Len ->
- dotag(DoTag, ?N_OCTET_STRING, {OctetList,Len})
- end;
-%% encode_octet_string(C, OctetList, DoTag) when is_list(OctetList) ->
-%% dotag(DoTag, ?N_OCTET_STRING, {OctetList,length(OctetList)});
-encode_octet_string(C, {Name,OctetList}, DoTag) when is_atom(Name) ->
- encode_octet_string(C, OctetList, DoTag).
-
-
-%%============================================================================
-%% decode octet string
-%% (Buffer, Range, HasTag, TotalLen) -> {String, Remain, RemovedBytes}
-%%
-%% Octet string is decoded as a restricted string
-%%============================================================================
-decode_octet_string(Buffer, Range, Tags, TotalLen, OptOrMand) ->
-%% NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_OCTET_STRING}),
- decode_restricted_string(Buffer, Range, ?N_OCTET_STRING,
- Tags, TotalLen, [], OptOrMand,old).
-
-%%============================================================================
-%% Null value, ITU_T X.690 Chapter 8.8
-%%
-%% encode NULL value
-%%============================================================================
-
-encode_null(_, []) ->
- {[?N_NULL,0],2};
-encode_null(_, DoTag) ->
- dotag(DoTag, ?N_NULL, {[],0}).
-
-%%============================================================================
-%% decode NULL value
-%% (Buffer, HasTag, TotalLen) -> {NULL, Remain, RemovedBytes}
-%%============================================================================
-decode_null(Buffer, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_NULL}),
- decode_null_notag(Buffer, NewTags, OptOrMand).
-
-decode_null_notag(Buffer, Tags, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
-
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {_Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} = decode_null_notag(Buffer0, RestTags,
- OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,0} ->
- {'NULL', Buffer0, Rb0};
- {_,Len} ->
- exit({error,{asn1,{invalid_length,'NULL',Len}}})
- end.
-
-
-%%============================================================================
-%% Object identifier, ITU_T X.690 Chapter 8.19
-%%
-%% encode Object Identifier value
-%%============================================================================
-
-encode_object_identifier({Name,Val}, DoTag) when is_atom(Name) ->
- encode_object_identifier(Val, DoTag);
-encode_object_identifier(Val, []) ->
- {EncVal,Len} = e_object_identifier(Val),
- dotag_universal(?N_OBJECT_IDENTIFIER,EncVal,Len);
-encode_object_identifier(Val, DoTag) ->
- dotag(DoTag, ?N_OBJECT_IDENTIFIER, e_object_identifier(Val)).
-
-e_object_identifier({'OBJECT IDENTIFIER', V}) ->
- e_object_identifier(V);
-e_object_identifier({Cname, V}) when is_atom(Cname), is_tuple(V) ->
- e_object_identifier(tuple_to_list(V));
-e_object_identifier({Cname, V}) when is_atom(Cname), is_list(V) ->
- e_object_identifier(V);
-e_object_identifier(V) when is_tuple(V) ->
- e_object_identifier(tuple_to_list(V));
-
-%%%%%%%%%%%%%%%
-%% e_object_identifier([List of Obect Identifiers]) ->
-%% {[Encoded Octetlist of ObjIds], IntLength}
-%%
-e_object_identifier([E1, E2 | Tail]) ->
- Head = 40*E1 + E2, % wow!
- {H,Lh} = mk_object_val(Head),
- {R,Lr} = enc_obj_id_tail(Tail, [], 0),
- {[H|R], Lh+Lr}.
-
-enc_obj_id_tail([], Ack, Len) ->
- {lists:reverse(Ack), Len};
-enc_obj_id_tail([H|T], Ack, Len) ->
- {B, L} = mk_object_val(H),
- enc_obj_id_tail(T, [B|Ack], Len+L).
+encode_integer_neg(-1, L=[B1|_T]) when B1 > 127 ->
+ L;
+encode_integer_neg(N, Acc) ->
+ encode_integer_neg(N bsr 8, [N band 16#ff|Acc]).
%%%%%%%%%%%
@@ -1643,476 +440,6 @@ mk_object_val(Val, Ack, Len) ->
mk_object_val(Val bsr 7, [((Val band 127) bor 128) | Ack], Len + 1).
-
-%%============================================================================
-%% decode Object Identifier value
-%% (Buffer, HasTag, TotalLen) -> {{ObjId}, Remain, RemovedBytes}
-%%============================================================================
-
-decode_object_identifier(Buffer, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,
- number=?N_OBJECT_IDENTIFIER}),
- decode_object_identifier_notag(Buffer, NewTags, OptOrMand).
-
-decode_object_identifier_notag(Buffer, Tags, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
-
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_object_identifier_notag(Buffer00,
- RestTags, OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,Len} ->
- {[AddedObjVal|ObjVals],Buffer01} =
- dec_subidentifiers(Buffer0,0,[],Len),
- {Val1, Val2} = if
- AddedObjVal < 40 ->
- {0, AddedObjVal};
- AddedObjVal < 80 ->
- {1, AddedObjVal - 40};
- true ->
- {2, AddedObjVal - 80}
- end,
- {list_to_tuple([Val1, Val2 | ObjVals]), Buffer01,
- Rb0+Len}
- end.
-
-dec_subidentifiers(Buffer,_Av,Al,0) ->
- {lists:reverse(Al),Buffer};
-dec_subidentifiers(<<1:1,H:7,T/binary>>,Av,Al,Len) ->
- dec_subidentifiers(T,(Av bsl 7) + H,Al,Len-1);
-dec_subidentifiers(<<H,T/binary>>,Av,Al,Len) ->
- dec_subidentifiers(T,0,[((Av bsl 7) + H)|Al],Len-1).
-
-%%============================================================================
-%% RELATIVE-OID, ITU_T X.690 Chapter 8.20
-%%
-%% encode Relative Object Identifier
-%%============================================================================
-encode_relative_oid({Name,Val},TagIn) when is_atom(Name) ->
- encode_relative_oid(Val,TagIn);
-encode_relative_oid(Val,TagIn) when is_tuple(Val) ->
- encode_relative_oid(tuple_to_list(Val),TagIn);
-encode_relative_oid(Val,[]) ->
- {EncVal,Len} = enc_relative_oid(Val),
- dotag_universal(?'N_RELATIVE-OID',EncVal,Len);
-encode_relative_oid(Val, DoTag) ->
- dotag(DoTag, ?'N_RELATIVE-OID', enc_relative_oid(Val)).
-
-enc_relative_oid(Val) ->
- lists:mapfoldl(fun(X,AccIn) ->
- {SO,L}=mk_object_val(X),
- {SO,L+AccIn}
- end
- ,0,Val).
-
-%%============================================================================
-%% decode Relative Object Identifier value
-%% (Buffer, HasTag, TotalLen) -> {{ObjId}, Remain, RemovedBytes}
-%%============================================================================
-decode_relative_oid(Buffer, Tags, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,
- number=?'N_RELATIVE-OID'}),
- decode_relative_oid_notag(Buffer, NewTags, OptOrMand).
-
-decode_relative_oid_notag(Buffer, Tags, OptOrMand) ->
- {_RestTags, {_FormLen={_,Len}, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
- {ObjVals,Buffer01} =
- dec_subidentifiers(Buffer0,0,[],Len),
- {list_to_tuple(ObjVals), Buffer01, Rb0+Len}.
-
-%%============================================================================
-%% Restricted character string types, ITU_T X.690 Chapter 8.21
-%%
-%% encode Numeric Printable Teletex Videotex Visible IA5 Graphic General strings
-%%============================================================================
-encode_restricted_string(_C, OctetList, StringType, [])
- when is_binary(OctetList) ->
- dotag_universal(StringType, OctetList, byte_size(OctetList));
-encode_restricted_string(_C, OctetList, StringType, DoTag)
- when is_binary(OctetList) ->
- dotag(DoTag, StringType, {OctetList, byte_size(OctetList)});
-encode_restricted_string(_C, OctetList, StringType, [])
- when is_list(OctetList) ->
- dotag_universal(StringType, OctetList, length(OctetList));
-encode_restricted_string(_C, OctetList, StringType, DoTag)
- when is_list(OctetList) ->
- dotag(DoTag, StringType, {OctetList, length(OctetList)});
-encode_restricted_string(C,{Name,OctetL},StringType,DoTag) when is_atom(Name) ->
- encode_restricted_string(C, OctetL, StringType, DoTag).
-
-%%============================================================================
-%% decode Numeric Printable Teletex Videotex Visible IA5 Graphic General strings
-%% (Buffer, Range, StringType, HasTag, TotalLen) ->
-%% {String, Remain, RemovedBytes}
-%%============================================================================
-
-decode_restricted_string(Buffer, Range, StringType, Tags, LenIn, OptOrMand) ->
- {Val,Buffer2,Rb} =
- decode_restricted_string_tag(Buffer, Range, StringType, Tags,
- LenIn, [], OptOrMand,old),
- {check_and_convert_restricted_string(Val,StringType,Range,[],old),
- Buffer2,Rb}.
-
-
-decode_restricted_string(Buffer, Range, StringType, Tags, LenIn, NNList, OptOrMand, BinOrOld ) ->
- {Val,Buffer2,Rb} =
- decode_restricted_string_tag(Buffer, Range, StringType, Tags,
- LenIn, NNList, OptOrMand, BinOrOld),
- {check_and_convert_restricted_string(Val,StringType,Range,NNList,BinOrOld),
- Buffer2,Rb}.
-
-decode_restricted_string_tag(Buffer, Range, StringType, TagsIn, LenIn, NNList, OptOrMand, BinOrOld ) ->
- NewTags = new_tags(TagsIn, #tag{class=?UNIVERSAL,number=StringType}),
- decode_restricted_string_notag(Buffer, Range, StringType, NewTags,
- LenIn, NNList, OptOrMand, BinOrOld).
-
-
-check_and_convert_restricted_string(Val,StringType,Range,NamedNumberList,_BinOrOld) ->
- {StrLen,NewVal} = case StringType of
- ?N_BIT_STRING when NamedNumberList =/= [] ->
- {no_check,Val};
- ?N_BIT_STRING when is_list(Val) ->
- {length(Val),Val};
- ?N_BIT_STRING when is_tuple(Val) ->
- {(size(element(2,Val))*8) - element(1,Val),Val};
- _ when is_binary(Val) ->
- {byte_size(Val),binary_to_list(Val)};
- _ when is_list(Val) ->
- {length(Val), Val}
- end,
- case Range of
- _ when StrLen =:= no_check ->
- NewVal;
- [] -> % No length constraint
- NewVal;
- {Lb,Ub} when StrLen >= Lb, Ub >= StrLen -> % variable length constraint
- NewVal;
- {{Lb,_Ub},[]} when StrLen >= Lb ->
- NewVal;
- {{Lb,_Ub},_Ext=[MinExt|_]} when StrLen >= Lb; StrLen >= MinExt ->
- NewVal;
- {{Lb1,Ub1},{Lb2,Ub2}} when StrLen >= Lb1, StrLen =< Ub1;
- StrLen =< Ub2, StrLen >= Lb2 ->
- NewVal;
- StrLen -> % fixed length constraint
- NewVal;
- {_,_} ->
- exit({error,{asn1,{length,Range,Val}}});
- _Len when is_integer(_Len) ->
- exit({error,{asn1,{length,Range,Val}}});
- _ -> % some strange constraint that we don't support yet
- NewVal
- end.
-
-%%=============================================================================
-%% Common routines for several string types including bit string
-%% handles indefinite length
-%%=============================================================================
-
-
-decode_restricted_string_notag(Buffer, _Range, StringType, TagsIn,
- _, NamedNumberList, OptOrMand, BinOrOld) ->
- %%-----------------------------------------------------------
- %% Get inner (the implicit tag or no tag) and
- %% outer (the explicit tag) lengths.
- %%-----------------------------------------------------------
- {RestTags, {FormLength={_,_Len01}, Buffer0, Rb0}} =
- check_tags_i(TagsIn, Buffer, OptOrMand),
-
- case FormLength of
- {?CONSTRUCTED,Len} ->
- {Buffer00, RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_restricted_parts(Buffer00, RestBytes, [], StringType,
- RestTags,
- Len, NamedNumberList,
- OptOrMand,
- BinOrOld, 0, []),
- {Val01, Buffer01, Rb0+Rb01};
- {_, Len} ->
- {Val01, Buffer01, Rb01} =
- decode_restricted(Buffer0, Len, StringType,
- NamedNumberList, BinOrOld),
- {Val01, Buffer01, Rb0+Rb01}
- end.
-
-
-decode_restricted_parts(Buffer, RestBytes, [], StringType, RestTags, Len, NNList,
- OptOrMand, BinOrOld, AccRb, AccVal) ->
- DecodeFun = case RestTags of
- [] -> fun decode_restricted_string_tag/8;
- _ -> fun decode_restricted_string_notag/8
- end,
- {Val, Buffer1, Rb} =
- DecodeFun(Buffer, [], StringType, RestTags,
- no_length, NNList,
- OptOrMand, BinOrOld),
- {Buffer2,More} =
- case Buffer1 of
- <<0,0,Buffer10/binary>> when Len == indefinite ->
- {Buffer10,false};
- <<>> ->
- {RestBytes,false};
- _ ->
- {Buffer1,true}
- end,
- {NewVal, NewRb} =
- case StringType of
- ?N_BIT_STRING when BinOrOld == bin ->
- {concat_bit_binaries(AccVal, Val), AccRb+Rb};
- _ when is_binary(Val),is_binary(AccVal) ->
- {<<AccVal/binary,Val/binary>>,AccRb+Rb};
- _ when is_binary(Val), AccVal =:= [] ->
- {Val,AccRb+Rb};
- _ ->
- {AccVal++Val, AccRb+Rb}
- end,
- case More of
- false ->
- {NewVal, Buffer2, NewRb};
- true ->
- decode_restricted_parts(Buffer2, RestBytes, [], StringType, RestTags, Len, NNList,
- OptOrMand, BinOrOld, NewRb, NewVal)
- end.
-
-
-
-decode_restricted(Buffer, InnerLen, StringType, NamedNumberList,BinOrOld) ->
-
- case StringType of
- ?N_BIT_STRING ->
- decode_bit_string2(InnerLen,Buffer,NamedNumberList,InnerLen,BinOrOld);
-
- ?N_UniversalString ->
- <<PreBuff:InnerLen/binary,RestBuff/binary>> = Buffer,%%added for binary
- UniString = mk_universal_string(binary_to_list(PreBuff)),
- {UniString,RestBuff,InnerLen};
- ?N_BMPString ->
- <<PreBuff:InnerLen/binary,RestBuff/binary>> = Buffer,%%added for binary
- BMP = mk_BMP_string(binary_to_list(PreBuff)),
- {BMP,RestBuff,InnerLen};
- _ ->
- <<PreBuff:InnerLen/binary,RestBuff/binary>> = Buffer,%%added for binary
- {PreBuff, RestBuff, InnerLen}
- end.
-
-
-
-%%============================================================================
-%% encode Universal string
-%%============================================================================
-
-encode_universal_string(C, {Name, Universal}, DoTag) when is_atom(Name) ->
- encode_universal_string(C, Universal, DoTag);
-encode_universal_string(_C, Universal, []) ->
- OctetList = mk_uni_list(Universal),
- dotag_universal(?N_UniversalString,OctetList,length(OctetList));
-encode_universal_string(_C, Universal, DoTag) ->
- OctetList = mk_uni_list(Universal),
- dotag(DoTag, ?N_UniversalString, {OctetList,length(OctetList)}).
-
-mk_uni_list(In) ->
- mk_uni_list(In,[]).
-
-mk_uni_list([],List) ->
- lists:reverse(List);
-mk_uni_list([{A,B,C,D}|T],List) ->
- mk_uni_list(T,[D,C,B,A|List]);
-mk_uni_list([H|T],List) ->
- mk_uni_list(T,[H,0,0,0|List]).
-
-%%===========================================================================
-%% decode Universal strings
-%% (Buffer, Range, StringType, HasTag, LenIn) ->
-%% {String, Remain, RemovedBytes}
-%%===========================================================================
-
-decode_universal_string(Buffer, Range, Tags, LenIn, OptOrMand) ->
-% NewTags = new_tags(HasTag, #tag{class=?UNIVERSAL,number=?N_UniversalString}),
- decode_restricted_string(Buffer, Range, ?N_UniversalString,
- Tags, LenIn, [], OptOrMand,old).
-
-
-mk_universal_string(In) ->
- mk_universal_string(In,[]).
-
-mk_universal_string([],Acc) ->
- lists:reverse(Acc);
-mk_universal_string([0,0,0,D|T],Acc) ->
- mk_universal_string(T,[D|Acc]);
-mk_universal_string([A,B,C,D|T],Acc) ->
- mk_universal_string(T,[{A,B,C,D}|Acc]).
-
-
-%%============================================================================
-%% encode UTF8 string
-%%============================================================================
-encode_UTF8_string(_,UTF8String,[]) when is_binary(UTF8String) ->
- dotag_universal(?N_UTF8String,UTF8String,byte_size(UTF8String));
-encode_UTF8_string(_,UTF8String,DoTag) when is_binary(UTF8String) ->
- dotag(DoTag,?N_UTF8String,{UTF8String,byte_size(UTF8String)});
-encode_UTF8_string(_,UTF8String,[]) ->
- dotag_universal(?N_UTF8String,UTF8String,length(UTF8String));
-encode_UTF8_string(_,UTF8String,DoTag) ->
- dotag(DoTag,?N_UTF8String,{UTF8String,length(UTF8String)}).
-
-%%============================================================================
-%% decode UTF8 string
-%%============================================================================
-
-decode_UTF8_string(Buffer, Tags, OptOrMand) ->
- NewTags = new_tags(Tags, #tag{class=?UNIVERSAL,number=?N_UTF8String}),
- decode_UTF8_string_notag(Buffer, NewTags, OptOrMand).
-
-decode_UTF8_string_notag(Buffer, Tags, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
- case FormLen of
- {?CONSTRUCTED,Len} ->
- %% an UTF8String may be encoded as a constructed type
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_UTF8_string_notag(Buffer00,RestTags,OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,Len} ->
- <<Result:Len/binary,RestBuff/binary>> = Buffer0,
- {Result,RestBuff,Rb0 + Len}
- end.
-
-
-%%============================================================================
-%% encode BMP string
-%%============================================================================
-
-encode_BMP_string(C, {Name,BMPString}, DoTag) when is_atom(Name) ->
- encode_BMP_string(C, BMPString, DoTag);
-encode_BMP_string(_C, BMPString, []) ->
- OctetList = mk_BMP_list(BMPString),
- dotag_universal(?N_BMPString,OctetList,length(OctetList));
-encode_BMP_string(_C, BMPString, DoTag) ->
- OctetList = mk_BMP_list(BMPString),
- dotag(DoTag, ?N_BMPString, {OctetList,length(OctetList)}).
-
-mk_BMP_list(In) ->
- mk_BMP_list(In,[]).
-
-mk_BMP_list([],List) ->
- lists:reverse(List);
-mk_BMP_list([{0,0,C,D}|T],List) ->
- mk_BMP_list(T,[D,C|List]);
-mk_BMP_list([H|T],List) ->
- mk_BMP_list(T,[H,0|List]).
-
-%%============================================================================
-%% decode (OctetList, Range(ignored), tag|notag) -> {ValList, RestList}
-%% (Buffer, Range, StringType, HasTag, TotalLen) ->
-%% {String, Remain, RemovedBytes}
-%%============================================================================
-decode_BMP_string(Buffer, Range, Tags, LenIn, OptOrMand) ->
-% NewTags = new_tags(HasTag, #tag{class=?UNIVERSAL,number=?N_BMPString}),
- decode_restricted_string(Buffer, Range, ?N_BMPString,
- Tags, LenIn, [], OptOrMand,old).
-
-mk_BMP_string(In) ->
- mk_BMP_string(In,[]).
-
-mk_BMP_string([],US) ->
- lists:reverse(US);
-mk_BMP_string([0,B|T],US) ->
- mk_BMP_string(T,[B|US]);
-mk_BMP_string([C,D|T],US) ->
- mk_BMP_string(T,[{0,0,C,D}|US]).
-
-
-%%============================================================================
-%% Generalized time, ITU_T X.680 Chapter 39
-%%
-%% encode Generalized time
-%%============================================================================
-
-encode_generalized_time(C, {Name,OctetList}, DoTag) when is_atom(Name) ->
- encode_generalized_time(C, OctetList, DoTag);
-encode_generalized_time(_C, OctetList, []) ->
- dotag_universal(?N_GeneralizedTime,OctetList,length(OctetList));
-encode_generalized_time(_C, OctetList, DoTag) ->
- dotag(DoTag, ?N_GeneralizedTime, {OctetList,length(OctetList)}).
-
-%%============================================================================
-%% decode Generalized time
-%% (Buffer, Range, HasTag, TotalLen) -> {String, Remain, RemovedBytes}
-%%============================================================================
-
-decode_generalized_time(Buffer, Range, Tags, TotalLen, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,
- number=?N_GeneralizedTime}),
- decode_generalized_time_notag(Buffer, Range, NewTags, TotalLen, OptOrMand).
-
-decode_generalized_time_notag(Buffer, Range, Tags, TotalLen, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
-
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_generalized_time_notag(Buffer00, Range,
- RestTags, TotalLen,
- OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,Len} ->
- <<PreBuff:Len/binary,RestBuff/binary>> = Buffer0,
- {binary_to_list(PreBuff), RestBuff, Rb0+Len}
- end.
-
-%%============================================================================
-%% Universal time, ITU_T X.680 Chapter 40
-%%
-%% encode UTC time
-%%============================================================================
-
-encode_utc_time(C, {Name,OctetList}, DoTag) when is_atom(Name) ->
- encode_utc_time(C, OctetList, DoTag);
-encode_utc_time(_C, OctetList, []) ->
- dotag_universal(?N_UTCTime, OctetList,length(OctetList));
-encode_utc_time(_C, OctetList, DoTag) ->
- dotag(DoTag, ?N_UTCTime, {OctetList,length(OctetList)}).
-
-%%============================================================================
-%% decode UTC time
-%% (Buffer, Range, HasTag, TotalLen) -> {String, Remain, RemovedBytes}
-%%============================================================================
-
-decode_utc_time(Buffer, Range, Tags, TotalLen, OptOrMand) ->
- NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_UTCTime}),
- decode_utc_time_notag(Buffer, Range, NewTags, TotalLen, OptOrMand).
-
-decode_utc_time_notag(Buffer, Range, Tags, TotalLen, OptOrMand) ->
- {RestTags, {FormLen, Buffer0, Rb0}} =
- check_tags_i(Tags, Buffer, OptOrMand),
-
- case FormLen of
- {?CONSTRUCTED,Len} ->
- {Buffer00,RestBytes} = split_list(Buffer0,Len),
- {Val01, Buffer01, Rb01} =
- decode_utc_time_notag(Buffer00, Range,
- RestTags, TotalLen,
- OptOrMand),
- {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
- {Val01, Buffer02, Rb0+Rb01+Rb02};
- {_,Len} ->
- <<PreBuff:Len/binary,RestBuff/binary>> = Buffer0,
- {binary_to_list(PreBuff), RestBuff, Rb0+Len}
- end.
-
-
%%============================================================================
%% Length handling
%%
@@ -2122,8 +449,6 @@ decode_utc_time_notag(Buffer, Range, Tags, TotalLen, OptOrMand) ->
%% [<127]| [128 + Int (<127),OctetList] | [16#80]
%%============================================================================
-encode_length(indefinite) ->
- {[16#80],1}; % 128
encode_length(L) when L =< 16#7F ->
{[L],1};
encode_length(L) ->
@@ -2162,242 +487,12 @@ decode_length(<<1:1,LL:7,T/binary>>) ->
<<Length:LL/unit:8,Rest/binary>> = T,
{{Length,Rest}, LL+1}.
-%decode_length([128 | T]) ->
-% {{indefinite, T},1};
-%decode_length([H | T]) when H =< 127 ->
-% {{H, T},1};
-%decode_length([H | T]) ->
-% dec_long_length(H band 16#7F, T, 0, 1).
-
-
-%%dec_long_length(0, Buffer, Acc, Len) ->
-%% {{Acc, Buffer},Len};
-%%dec_long_length(Bytes, [H | T], Acc, Len) ->
-%% dec_long_length(Bytes - 1, T, (Acc bsl 8) + H, Len+1).
-
-%%===========================================================================
-%% Decode tag and length
-%%
-%% decode_tag_and_length(Buffer) -> {Tag, Len, RemainingBuffer, RemovedBytes}
-%%
-%%===========================================================================
-
-decode_tag_and_length(Buffer) ->
- {Tag, Buffer2, RemBytesTag} = decode_tag(Buffer),
- {{Len, Buffer3}, RemBytesLen} = decode_length(Buffer2),
- {Tag, Len, Buffer3, RemBytesTag+RemBytesLen}.
-
-
-%%============================================================================
-%% Check if valid tag
-%%
-%% check_if_valid_tag(Tag, List_of_valid_tags, OptOrMand) -> name of the tag
-%%============================================================================
-
-check_if_valid_tag(<<0,0,_/binary>>,_,_) ->
- asn1_EOC;
-check_if_valid_tag(<<>>, _, OptOrMand) ->
- check_if_valid_tag2_error([], OptOrMand);
-check_if_valid_tag(Bytes, ListOfTags, OptOrMand) when is_binary(Bytes) ->
- {Tag, _, _} = decode_tag(Bytes),
- check_if_valid_tag(Tag, ListOfTags, OptOrMand);
-
-%% This alternative should be removed in the near future
-%% Bytes as input should be the only necessary call
-check_if_valid_tag(Tag, ListOfTags, OptOrMand) ->
- {Class, _Form, TagNo} = Tag,
- C = code_class(Class),
- T = case C of
- 'UNIVERSAL' ->
- code_type(TagNo);
- _ ->
- TagNo
- end,
- check_if_valid_tag2({C,T}, ListOfTags, Tag, OptOrMand).
-
-check_if_valid_tag2(_Class_TagNo, [], Tag, MandOrOpt) ->
- check_if_valid_tag2_error(Tag,MandOrOpt);
-check_if_valid_tag2(Class_TagNo, [{TagName,TagList}|T], Tag, OptOrMand) ->
- case check_if_valid_tag_loop(Class_TagNo, TagList) of
- true ->
- TagName;
- false ->
- check_if_valid_tag2(Class_TagNo, T, Tag, OptOrMand)
- end.
-
--spec check_if_valid_tag2_error(term(), atom()) -> no_return().
-
-check_if_valid_tag2_error(Tag,mandatory) ->
- exit({error,{asn1,{invalid_tag,Tag}}});
-check_if_valid_tag2_error(Tag,_) ->
- exit({error,{asn1,{no_optional_tag,Tag}}}).
-
-check_if_valid_tag_loop(_Class_TagNo,[]) ->
- false;
-check_if_valid_tag_loop(Class_TagNo,[H|T]) ->
- %% It is not possible to distinguish between SEQUENCE OF and SEQUENCE, and
- %% between SET OF and SET because both are coded as 16 and 17, respectively.
- H_without_OF = case H of
- {C, 'SEQUENCE OF'} ->
- {C, 'SEQUENCE'};
- {C, 'SET OF'} ->
- {C, 'SET'};
- Else ->
- Else
- end,
-
- case H_without_OF of
- Class_TagNo ->
- true;
- {_,_} ->
- check_if_valid_tag_loop(Class_TagNo,T);
- _ ->
- check_if_valid_tag_loop(Class_TagNo,H),
- check_if_valid_tag_loop(Class_TagNo,T)
- end.
-
-
-
-code_class(0) -> 'UNIVERSAL';
-code_class(16#40) -> 'APPLICATION';
-code_class(16#80) -> 'CONTEXT';
-code_class(16#C0) -> 'PRIVATE'.
-
-
-code_type(1) -> 'BOOLEAN';
-code_type(2) -> 'INTEGER';
-code_type(3) -> 'BIT STRING';
-code_type(4) -> 'OCTET STRING';
-code_type(5) -> 'NULL';
-code_type(6) -> 'OBJECT IDENTIFIER';
-code_type(7) -> 'ObjectDescriptor';
-code_type(8) -> 'EXTERNAL';
-code_type(9) -> 'REAL';
-code_type(10) -> 'ENUMERATED';
-code_type(11) -> 'EMBEDDED_PDV';
-code_type(16) -> 'SEQUENCE';
-% code_type(16) -> 'SEQUENCE OF';
-code_type(17) -> 'SET';
-% code_type(17) -> 'SET OF';
-code_type(18) -> 'NumericString';
-code_type(19) -> 'PrintableString';
-code_type(20) -> 'TeletexString';
-code_type(21) -> 'VideotexString';
-code_type(22) -> 'IA5String';
-code_type(23) -> 'UTCTime';
-code_type(24) -> 'GeneralizedTime';
-code_type(25) -> 'GraphicString';
-code_type(26) -> 'VisibleString';
-code_type(27) -> 'GeneralString';
-code_type(28) -> 'UniversalString';
-code_type(30) -> 'BMPString';
-code_type(Else) -> exit({error,{asn1,{unrecognized_type,Else}}}).
-
-%%-------------------------------------------------------------------------
-%% decoding of the components of a SET
-%%-------------------------------------------------------------------------
-
-decode_set(Rb, indefinite, <<0,0,Bytes/binary>>, _OptOrMand, _Fun3, Acc) ->
- {lists:reverse(Acc),Bytes,Rb+2};
-
-decode_set(Rb, indefinite, Bytes, OptOrMand, Fun3, Acc) ->
- case Fun3(Bytes, OptOrMand) of
- {_Term, _Remain, 0} ->
- {lists:reverse(Acc),Bytes,Rb};
- {Term, Remain, Rb1} ->
- Fun3(Bytes, OptOrMand),
- decode_set(Rb+Rb1, indefinite, Remain, OptOrMand, Fun3, [Term|Acc])
- end;
-%% {Term, Remain, Rb1} = Fun3(Bytes, OptOrMand),
-%% decode_set(Rb+Rb1, indefinite, Remain, OptOrMand, Fun3, [Term|Acc]);
-
-decode_set(Rb, Num, Bytes, _OptOrMand, _Fun3, Acc) when Num == 0 ->
- {lists:reverse(Acc), Bytes, Rb};
-
-decode_set(_, Num, _, _, _, _) when Num < 0 ->
- exit({error,{asn1,{length_error,'SET'}}});
-
-decode_set(Rb, Num, Bytes, OptOrMand, Fun3, Acc) ->
- case Fun3(Bytes, OptOrMand) of
- {_Term, _Remain, 0} ->
- {lists:reverse(Acc),Bytes,Rb};
- {Term, Remain, Rb1} ->
- Fun3(Bytes, OptOrMand),
- decode_set(Rb+Rb1, Num-Rb1, Remain, OptOrMand, Fun3, [Term|Acc])
- end.
-%% {Term, Remain, Rb1} = Fun3(Bytes, OptOrMand),
-%% decode_set(Rb+Rb1, Num-Rb1, Remain, OptOrMand, Fun3, [Term|Acc]).
-
-
-%%-------------------------------------------------------------------------
-%% decoding of SEQUENCE OF and SET OF
-%%-------------------------------------------------------------------------
-
-decode_components(Rb, indefinite, <<0,0,Bytes/binary>>, _Fun3, _TagIn, Acc) ->
- {lists:reverse(Acc),Bytes,Rb+2};
-
-decode_components(Rb, indefinite, Bytes, Fun3, TagIn, Acc) ->
- {Term, Remain, Rb1} = Fun3(Bytes, mandatory, TagIn),
- decode_components(Rb+Rb1, indefinite, Remain, Fun3, TagIn, [Term|Acc]);
-
-decode_components(Rb, Num, Bytes, _Fun3, _TagIn, Acc) when Num == 0 ->
- {lists:reverse(Acc), Bytes, Rb};
-
-decode_components(_, Num, _, _, _, _) when Num < 0 ->
- exit({error,{asn1,{length_error,'SET/SEQUENCE OF'}}});
-
-decode_components(Rb, Num, Bytes, Fun3, TagIn, Acc) ->
- {Term, Remain, Rb1} = Fun3(Bytes, mandatory, TagIn),
- decode_components(Rb+Rb1, Num-Rb1, Remain, Fun3, TagIn, [Term|Acc]).
-
-%%decode_components(Rb, indefinite, [0,0|Bytes], _Fun3, _TagIn, Acc) ->
-%% {lists:reverse(Acc),Bytes,Rb+2};
-
-decode_components(Rb, indefinite, <<0,0,Bytes/binary>>, _Fun4, _TagIn, _Fun, Acc) ->
- {lists:reverse(Acc),Bytes,Rb+2};
-
-decode_components(Rb, indefinite, Bytes, _Fun4, TagIn, _Fun, Acc) ->
- {Term, Remain, Rb1} = _Fun4(Bytes, mandatory, TagIn, _Fun),
- decode_components(Rb+Rb1, indefinite, Remain, _Fun4, TagIn, _Fun, [Term|Acc]);
-
-decode_components(Rb, Num, Bytes, _Fun4, _TagIn, _Fun, Acc) when Num == 0 ->
- {lists:reverse(Acc), Bytes, Rb};
-
-decode_components(_, Num, _, _, _, _, _) when Num < 0 ->
- exit({error,{asn1,{length_error,'SET/SEQUENCE OF'}}});
-
-decode_components(Rb, Num, Bytes, _Fun4, TagIn, _Fun, Acc) ->
- {Term, Remain, Rb1} = _Fun4(Bytes, mandatory, TagIn, _Fun),
- decode_components(Rb+Rb1, Num-Rb1, Remain, _Fun4, TagIn, _Fun, [Term|Acc]).
-
-
-
-%%-------------------------------------------------------------------------
-%% INTERNAL HELPER FUNCTIONS (not exported)
-%%-------------------------------------------------------------------------
-
-
-%%==========================================================================
-%% Encode tag
-%%
-%% dotag(tag | notag, TagValpattern | TagValTuple, [Length, Value]) -> [Tag]
-%% TagValPattern is a correct bitpattern for a tag
-%% TagValTuple is a tuple of three bitpatterns, Class, Form and TagNo where
-%% Class = UNIVERSAL | APPLICATION | CONTEXT | PRIVATE
-%% Form = Primitive | Constructed
-%% TagNo = Number of tag
-%%==========================================================================
-
dotag([], Tag, {Bytes,Len}) ->
dotag_universal(Tag,Bytes,Len);
dotag(Tags, Tag, {Bytes,Len}) ->
encode_tags(Tags ++ [#tag{class=?UNIVERSAL,number=Tag,form=?PRIMITIVE}],
- Bytes, Len);
-
-dotag(Tags, Tag, Bytes) ->
- encode_tags(Tags ++ [#tag{class=?UNIVERSAL,number=Tag,form=?PRIMITIVE}],
- Bytes, size(Bytes)).
+ Bytes, Len).
dotag_universal(UniversalTag,Bytes,Len) when Len =< 16#7F->
{[UniversalTag,Len,Bytes],2+Len};
@@ -2415,47 +510,6 @@ decode_integer2(Len,<<1:1,B2:7,Bs/binary>>,RemovedBytes) ->
Int = N - (1 bsl (8 * Len - 1)),
{Int,Buffer2,RemovedBytes}.
-%%decode_integer2(Len,Buffer,Acc,RemovedBytes) when (hd(Buffer) band 16#FF) =< 16#7F ->
-%% {decode_integer_pos(Buffer, 8 * (Len - 1)),skip(Buffer,Len),RemovedBytes};
-%%decode_integer2(Len,Buffer,Acc,RemovedBytes) ->
-%% {decode_integer_neg(Buffer, 8 * (Len - 1)),skip(Buffer,Len),RemovedBytes}.
-
-%%decode_integer_pos([Byte|Tail], Shift) ->
-%% (Byte bsl Shift) bor decode_integer_pos(Tail, Shift-8);
-%%decode_integer_pos([], _) -> 0.
-
-
-%%decode_integer_neg([Byte|Tail], Shift) ->
-%% (-128 + (Byte band 127) bsl Shift) bor decode_integer_pos(Tail, Shift-8).
-
-
-concat_bit_binaries([],Bin={_,_}) ->
- Bin;
-concat_bit_binaries({0,B1},{U2,B2}) ->
- {U2,<<B1/binary,B2/binary>>};
-concat_bit_binaries({U1,B1},{U2,B2}) ->
- S1 = (size(B1) * 8) - U1,
- S2 = (size(B2) * 8) - U2,
- PadBits = 8 - ((S1+S2) rem 8),
- {PadBits, <<B1:S1/binary-unit:1,B2:S2/binary-unit:1,0:PadBits>>};
-concat_bit_binaries(L1,L2) when is_list(L1), is_list(L2) ->
- %% this case occur when decoding with NNL
- L1 ++ L2.
-
-
-get_constraint(C,Key) ->
- case lists:keyfind(Key,1,C) of
- false ->
- no;
- {_, V} ->
- V
- end.
-
-%%skip(Buffer, 0) ->
-%% Buffer;
-%%skip([H | T], Len) ->
-%% skip(T, Len-1).
-
new_tags([],LastTag) ->
[LastTag];
new_tags(Tags = [#tag{type='IMPLICIT'}],_LastTag) ->
diff --git a/lib/asn1/src/asn1rt_ber_bin_v2.erl b/lib/asn1/src/asn1rt_ber_bin_v2.erl
index 9ff5017c68..92ca11cf89 100644
--- a/lib/asn1/src/asn1rt_ber_bin_v2.erl
+++ b/lib/asn1/src/asn1rt_ber_bin_v2.erl
@@ -22,8 +22,7 @@
%% encoding / decoding of BER
-export([decode/1, decode/2, match_tags/2, encode/1, encode/2]).
--export([fixoptionals/2, cindex/3,
- list_to_record/2,
+-export([fixoptionals/2,
encode_tag_val/1,
encode_tags/3,
skip_ExtensionAdditions/2]).
@@ -54,8 +53,6 @@
decode_open_type_as_binary/3]).
-export([decode_primitive_incomplete/2,decode_selective/2]).
-
--export([is_nif_loadable/0]).
% the encoding of class of tag bits 8 and 7
-define(UNIVERSAL, 0).
@@ -135,12 +132,7 @@ encode(Tlv,_) when is_binary(Tlv) ->
encode([Tlv],Method) ->
encode(Tlv,Method);
encode(Tlv, nif) ->
- case is_nif_loadable() of
- true ->
- asn1rt_nif:encode_ber_tlv(Tlv);
- false ->
- encode_erl(Tlv)
- end;
+ asn1rt_nif:encode_ber_tlv(Tlv);
encode(Tlv, _) ->
encode_erl(Tlv).
@@ -178,36 +170,15 @@ decode(B) ->
%% asn1-1.7
decode(B, nif) ->
- case is_nif_loadable() of
- true ->
- case asn1rt_nif:decode_ber_tlv(B) of
- {error, Reason} -> handle_error(Reason, B);
- Else -> Else
- end;
- false ->
- decode(B)
+ case asn1rt_nif:decode_ber_tlv(B) of
+ {error, Reason} -> handle_error(Reason, B);
+ Else -> Else
end;
decode(B,erlang) when is_binary(B) ->
decode_primitive(B);
decode(Tlv,erlang) ->
{Tlv,<<>>}.
-%% Have to check this since asn1 is not guaranteed to be available
-is_nif_loadable() ->
- case application:get_env(asn1, nif_loadable) of
- {ok,R} ->
- R;
- undefined ->
- case catch code:load_file(asn1rt_nif) of
- {module, asn1rt_nif} ->
- application:set_env(asn1, nif_loadable, true),
- true;
- _Else ->
- application:set_env(asn1, nif_loadable, false),
- false
- end
- end.
-
handle_error([],_)->
exit({error,{asn1,{"memory allocation problem"}}});
handle_error({$1,_},L) -> % error in nif
@@ -612,13 +583,6 @@ match_tags(Tlv, []) ->
Tlv;
match_tags(Tlv = {Tag,_V},[T|_Tt]) ->
exit({error,{asn1,{wrong_tag,{{expected,T},{got,Tag,Tlv}}}}}).
-
-
-cindex(Ix,Val,Cname) ->
- case element(Ix,Val) of
- {Cname,Val2} -> Val2;
- X -> X
- end.
%%%
%% skips components that do not match a tag in Tags
@@ -642,13 +606,6 @@ skip_ExtensionAdditions(TLV=[{Tag,_}|Rest],Tags) ->
%%===============================================================================
%%===============================================================================
-% converts a list to a record if necessary
-list_to_record(Name,List) when is_list(List) ->
- list_to_tuple([Name|List]);
-list_to_record(_Name,Tuple) when is_tuple(Tuple) ->
- Tuple.
-
-
fixoptionals(OptList,Val) when is_list(Val) ->
fixoptionals(OptList,Val,1,[],[]).
diff --git a/lib/asn1/src/asn1rt_per_bin.erl b/lib/asn1/src/asn1rt_per_bin.erl
deleted file mode 100644
index 5772f09bf4..0000000000
--- a/lib/asn1/src/asn1rt_per_bin.erl
+++ /dev/null
@@ -1,2285 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2012. All Rights Reserved.
-%%
-%% The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-%%
--module(asn1rt_per_bin).
-%% encoding / decoding of PER aligned
-
--include("asn1_records.hrl").
-
--export([dec_fixup/3, cindex/3, list_to_record/2]).
--export([setchoiceext/1, setext/1, fixoptionals/2, fixoptionals/3,
- fixextensions/2,
- getext/1, getextension/2, skipextensions/3, getbit/1, getchoice/3 ]).
--export([getoptionals/2, getoptionals2/2, set_choice/3, encode_integer/2, encode_integer/3 ]).
--export([decode_integer/2, decode_integer/3, encode_small_number/1, encode_boolean/1,
- decode_boolean/1, encode_length/2, decode_length/1, decode_length/2,
- encode_small_length/1, decode_small_length/1,
- decode_compact_bit_string/3]).
--export([decode_enumerated/3,
- encode_bit_string/3, decode_bit_string/3 ]).
--export([encode_octet_string/2, decode_octet_string/2,
- encode_null/1, decode_null/1,
- encode_object_identifier/1, decode_object_identifier/1,
- encode_real/1, decode_real/1,
- encode_relative_oid/1, decode_relative_oid/1,
- complete/1]).
-
-
--export([encode_open_type/2, decode_open_type/2]).
-
--export([encode_UniversalString/2, decode_UniversalString/2,
- encode_PrintableString/2, decode_PrintableString/2,
- encode_GeneralString/2, decode_GeneralString/2,
- encode_GraphicString/2, decode_GraphicString/2,
- encode_TeletexString/2, decode_TeletexString/2,
- encode_VideotexString/2, decode_VideotexString/2,
- encode_VisibleString/2, decode_VisibleString/2,
- encode_UTF8String/1, decode_UTF8String/1,
- encode_BMPString/2, decode_BMPString/2,
- encode_IA5String/2, decode_IA5String/2,
- encode_NumericString/2, decode_NumericString/2,
- encode_ObjectDescriptor/2, decode_ObjectDescriptor/1
- ]).
--export([complete_bytes/1, getbits/2, getoctets/2, minimum_bits/1]).
-
--define('16K',16384).
--define('32K',32768).
--define('64K',65536).
-
-dec_fixup(Terms,Cnames,RemBytes) ->
- dec_fixup(Terms,Cnames,RemBytes,[]).
-
-dec_fixup([novalue|T],[_Hc|Tc],RemBytes,Acc) ->
- dec_fixup(T,Tc,RemBytes,Acc);
-dec_fixup([{_Name,novalue}|T],[_Hc|Tc],RemBytes,Acc) ->
- dec_fixup(T,Tc,RemBytes,Acc);
-dec_fixup([H|T],[Hc|Tc],RemBytes,Acc) ->
- dec_fixup(T,Tc,RemBytes,[{Hc,H}|Acc]);
-dec_fixup([],_Cnames,RemBytes,Acc) ->
- {lists:reverse(Acc),RemBytes}.
-
-cindex(Ix,Val,Cname) ->
- case element(Ix,Val) of
- {Cname,Val2} -> Val2;
- X -> X
- end.
-
-%% converts a list to a record if necessary
-list_to_record(_Name,Tuple) when is_tuple(Tuple) ->
- Tuple;
-list_to_record(Name,List) when is_list(List) ->
- list_to_tuple([Name|List]).
-
-%%--------------------------------------------------------
-%% setchoiceext(InRootSet) -> [{bit,X}]
-%% X is set to 1 when InRootSet==false
-%% X is set to 0 when InRootSet==true
-%%
-setchoiceext(true) ->
- [{debug,choiceext},{bits,1,0}];
-setchoiceext(false) ->
- [{debug,choiceext},{bits,1,1}].
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% setext(true|false) -> CompleteList
-%%
-
-setext(false) ->
- [{debug,ext},{bits,1,0}];
-setext(true) ->
- [{debug,ext},{bits,1,1}].
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% This version of fixoptionals/2 are left only because of
-%% backward compatibility with older generates
-
-fixoptionals(OptList,Val) when is_tuple(Val) ->
- fixoptionals1(OptList,Val,[]);
-
-fixoptionals(OptList,Val) when is_list(Val) ->
- fixoptionals1(OptList,Val,1,[],[]).
-
-fixoptionals1([],Val,Acc) ->
- %% return {Val,Opt}
- {Val,lists:reverse(Acc)};
-fixoptionals1([{_,Pos}|Ot],Val,Acc) ->
- case element(Pos+1,Val) of
- asn1_NOVALUE -> fixoptionals1(Ot,Val,[0|Acc]);
- asn1_DEFAULT -> fixoptionals1(Ot,Val,[0|Acc]);
- _ -> fixoptionals1(Ot,Val,[1|Acc])
- end.
-
-
-fixoptionals1([{Name,Pos}|Ot],[{Name,Val}|Vt],_Opt,Acc1,Acc2) ->
- fixoptionals1(Ot,Vt,Pos+1,[1|Acc1],[{Name,Val}|Acc2]);
-fixoptionals1([{_Name,Pos}|Ot],V,Pos,Acc1,Acc2) ->
- fixoptionals1(Ot,V,Pos+1,[0|Acc1],[asn1_NOVALUE|Acc2]);
-fixoptionals1(O,[Vh|Vt],Pos,Acc1,Acc2) ->
- fixoptionals1(O,Vt,Pos+1,Acc1,[Vh|Acc2]);
-fixoptionals1([],[Vh|Vt],Pos,Acc1,Acc2) ->
- fixoptionals1([],Vt,Pos+1,Acc1,[Vh|Acc2]);
-fixoptionals1([],[],_,Acc1,Acc2) ->
- % return {Val,Opt}
- {list_to_tuple([asn1_RECORDNAME|lists:reverse(Acc2)]),lists:reverse(Acc1)}.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% This is the new fixoptionals/3 which is used by the new generates
-%%
-fixoptionals(OptList,OptLength,Val) when is_tuple(Val) ->
- Bits = fixoptionals(OptList,Val,0),
- {Val,{bits,OptLength,Bits}};
-
-fixoptionals([],_Val,Acc) ->
- %% Optbits
- Acc;
-fixoptionals([{Pos,DefVal}|Ot],Val,Acc) ->
- case element(Pos,Val) of
- asn1_DEFAULT -> fixoptionals(Ot,Val,Acc bsl 1);
- DefVal -> fixoptionals(Ot,Val,Acc bsl 1);
- _ -> fixoptionals(Ot,Val,(Acc bsl 1) + 1)
- end;
-fixoptionals([Pos|Ot],Val,Acc) ->
- case element(Pos,Val) of
- asn1_NOVALUE -> fixoptionals(Ot,Val,Acc bsl 1);
- asn1_DEFAULT -> fixoptionals(Ot,Val,Acc bsl 1);
- _ -> fixoptionals(Ot,Val,(Acc bsl 1) + 1)
- end.
-
-
-getext(Bytes) when is_tuple(Bytes) ->
- getbit(Bytes);
-getext(Bytes) when is_binary(Bytes) ->
- getbit({0,Bytes}).
-
-getextension(0, Bytes) ->
- {{},Bytes};
-getextension(1, Bytes) ->
- {Len,Bytes2} = decode_small_length(Bytes),
- {Blist, Bytes3} = getbits_as_list(Len,Bytes2),
- {list_to_tuple(Blist),Bytes3}.
-
-fixextensions({ext,ExtPos,ExtNum},Val) ->
- case fixextensions(ExtPos,ExtNum+ExtPos,Val,0) of
- 0 -> [];
- ExtBits ->
- [encode_small_length(ExtNum),{bits,ExtNum,ExtBits}]
- end.
-
-fixextensions(Pos,MaxPos,_,Acc) when Pos >= MaxPos ->
- Acc;
-fixextensions(Pos,ExtPos,Val,Acc) ->
- Bit = case catch(element(Pos+1,Val)) of
- asn1_NOVALUE ->
- 0;
- asn1_NOEXTVALUE ->
- 0;
- {'EXIT',_} ->
- 0;
- _ ->
- 1
- end,
- fixextensions(Pos+1,ExtPos,Val,(Acc bsl 1)+Bit).
-
-skipextensions(Bytes,Nr,ExtensionBitPattern) ->
- case (catch element(Nr,ExtensionBitPattern)) of
- 1 ->
- {_,Bytes2} = decode_open_type(Bytes,[]),
- skipextensions(Bytes2, Nr+1, ExtensionBitPattern);
- 0 ->
- skipextensions(Bytes, Nr+1, ExtensionBitPattern);
- {'EXIT',_} -> % badarg, no more extensions
- Bytes
- end.
-
-
-getchoice(Bytes,1,0) -> % only 1 alternative is not encoded
- {0,Bytes};
-getchoice(Bytes,_,1) ->
- decode_small_number(Bytes);
-getchoice(Bytes,NumChoices,0) ->
- decode_constrained_number(Bytes,{0,NumChoices-1}).
-
-%% old version kept for backward compatibility with generates from R7B
-getoptionals(Bytes,NumOpt) ->
- {Blist,Bytes1} = getbits_as_list(NumOpt,Bytes),
- {list_to_tuple(Blist),Bytes1}.
-
-%% new version used in generates from r8b_patch/3 and later
-getoptionals2(Bytes,NumOpt) ->
- getbits(Bytes,NumOpt).
-
-
-%% getbits_as_binary(Num,Bytes) -> {{Unused,BinBits},RestBytes},
-%% Num = integer(),
-%% Bytes = list() | tuple(),
-%% Unused = integer(),
-%% BinBits = binary(),
-%% RestBytes = tuple()
-getbits_as_binary(Num,Bytes) when is_binary(Bytes) ->
- getbits_as_binary(Num,{0,Bytes});
-getbits_as_binary(0,Buffer) ->
- {{0,<<>>},Buffer};
-getbits_as_binary(Num,{0,Bin}) when Num > 16 ->
- Used = Num rem 8,
- Pad = (8 - Used) rem 8,
-% Nbytes = Num div 8,
- <<Bits:Num,_:Pad,RestBin/binary>> = Bin,
- {{Pad,<<Bits:Num,0:Pad>>},RestBin};
-getbits_as_binary(Num,Buffer={_Used,_Bin}) -> % Unaligned buffer
- %% Num =< 16,
- {Bits2,Buffer2} = getbits(Buffer,Num),
- Pad = (8 - (Num rem 8)) rem 8,
- {{Pad,<<Bits2:Num,0:Pad>>},Buffer2}.
-
-
-% integer_from_list(Int,[],BigInt) ->
-% BigInt;
-% integer_from_list(Int,[H|T],BigInt) when Int < 8 ->
-% (BigInt bsl Int) bor (H bsr (8-Int));
-% integer_from_list(Int,[H|T],BigInt) ->
-% integer_from_list(Int-8,T,(BigInt bsl 8) bor H).
-
-getbits_as_list(Num,Bytes) when is_binary(Bytes) ->
- getbits_as_list(Num,{0,Bytes},[]);
-getbits_as_list(Num,Bytes) ->
- getbits_as_list(Num,Bytes,[]).
-
-%% If buffer is empty and nothing more will be picked.
-getbits_as_list(0, B, Acc) ->
- {lists:reverse(Acc),B};
-%% If first byte in buffer is full and at least one byte will be picked,
-%% then pick one byte.
-getbits_as_list(N,{0,Bin},Acc) when N >= 8 ->
- <<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,Rest/binary>> = Bin,
- getbits_as_list(N-8,{0,Rest},[B0,B1,B2,B3,B4,B5,B6,B7|Acc]);
-getbits_as_list(N,{Used,Bin},Acc) when N >= 4, Used =< 4 ->
- NewUsed = Used + 4,
- Rem = 8 - NewUsed,
- <<_:Used,B3:1,B2:1,B1:1,B0:1,_:Rem, Rest/binary>> = Bin,
- NewRest = case Rem of 0 -> Rest; _ -> Bin end,
- getbits_as_list(N-4,{NewUsed rem 8,NewRest},[B0,B1,B2,B3|Acc]);
-getbits_as_list(N,{Used,Bin},Acc) when N >= 2, Used =< 6 ->
- NewUsed = Used + 2,
- Rem = 8 - NewUsed,
- <<_:Used,B1:1,B0:1,_:Rem, Rest/binary>> = Bin,
- NewRest = case Rem of 0 -> Rest; _ -> Bin end,
- getbits_as_list(N-2,{NewUsed rem 8,NewRest},[B0,B1|Acc]);
-getbits_as_list(N,{Used,Bin},Acc) when Used =< 7 ->
- NewUsed = Used + 1,
- Rem = 8 - NewUsed,
- <<_:Used,B0:1,_:Rem, Rest/binary>> = Bin,
- NewRest = case Rem of 0 -> Rest; _ -> Bin end,
- getbits_as_list(N-1,{NewUsed rem 8,NewRest},[B0|Acc]).
-
-
-getbit({7,<<_:7,B:1,Rest/binary>>}) ->
- {B,{0,Rest}};
-getbit({0,Buffer = <<B:1,_:7,_/binary>>}) ->
- {B,{1,Buffer}};
-getbit({Used,Buffer}) ->
- Unused = (8 - Used) - 1,
- <<_:Used,B:1,_:Unused,_/binary>> = Buffer,
- {B,{Used+1,Buffer}};
-getbit(Buffer) when is_binary(Buffer) ->
- getbit({0,Buffer}).
-
-
-getbits({0,Buffer},Num) when (Num rem 8) == 0 ->
- <<Bits:Num,Rest/binary>> = Buffer,
- {Bits,{0,Rest}};
-getbits({Used,Bin},Num) ->
- NumPlusUsed = Num + Used,
- NewUsed = NumPlusUsed rem 8,
- Unused = (8-NewUsed) rem 8,
- case Unused of
- 0 ->
- <<_:Used,Bits:Num,Rest/binary>> = Bin,
- {Bits,{0,Rest}};
- _ ->
- Bytes = NumPlusUsed div 8,
- <<_:Used,Bits:Num,_UBits:Unused,_/binary>> = Bin,
- <<_:Bytes/binary,Rest/binary>> = Bin,
- {Bits,{NewUsed,Rest}}
- end;
-getbits(Bin,Num) when is_binary(Bin) ->
- getbits({0,Bin},Num).
-
-
-
-% getoctet(Bytes) when is_list(Bytes) ->
-% getoctet({0,Bytes});
-% getoctet(Bytes) ->
-% %% io:format("getoctet:Buffer = ~p~n",[Bytes]),
-% getoctet1(Bytes).
-
-% getoctet1({0,[H|T]}) ->
-% {H,{0,T}};
-% getoctet1({Pos,[_,H|T]}) ->
-% {H,{0,T}}.
-
-align({0,L}) ->
- {0,L};
-align({_Pos,<<_H,T/binary>>}) ->
- {0,T};
-align(Bytes) ->
- {0,Bytes}.
-
-%% First align buffer, then pick the first Num octets.
-%% Returns octets as an integer with bit significance as in buffer.
-getoctets({0,Buffer},Num) ->
- <<Val:Num/integer-unit:8,RestBin/binary>> = Buffer,
- {Val,{0,RestBin}};
-getoctets({U,<<_Padding,Rest/binary>>},Num) when U /= 0 ->
- getoctets({0,Rest},Num);
-getoctets(Buffer,Num) when is_binary(Buffer) ->
- getoctets({0,Buffer},Num).
-% getoctets(Buffer,Num) ->
-% %% io:format("getoctets:Buffer = ~p~nNum = ~p~n",[Buffer,Num]),
-% getoctets(Buffer,Num,0).
-
-% getoctets(Buffer,0,Acc) ->
-% {Acc,Buffer};
-% getoctets(Buffer,Num,Acc) ->
-% {Oct,NewBuffer} = getoctet(Buffer),
-% getoctets(NewBuffer,Num-1,(Acc bsl 8)+Oct).
-
-% getoctets_as_list(Buffer,Num) ->
-% getoctets_as_list(Buffer,Num,[]).
-
-% getoctets_as_list(Buffer,0,Acc) ->
-% {lists:reverse(Acc),Buffer};
-% getoctets_as_list(Buffer,Num,Acc) ->
-% {Oct,NewBuffer} = getoctet(Buffer),
-% getoctets_as_list(NewBuffer,Num-1,[Oct|Acc]).
-
-%% First align buffer, then pick the first Num octets.
-%% Returns octets as a binary
-getoctets_as_bin({0,Bin},Num)->
- <<Octets:Num/binary,RestBin/binary>> = Bin,
- {Octets,{0,RestBin}};
-getoctets_as_bin({_U,Bin},Num) ->
- <<_Padding,Octets:Num/binary,RestBin/binary>> = Bin,
- {Octets,{0,RestBin}};
-getoctets_as_bin(Bin,Num) when is_binary(Bin) ->
- getoctets_as_bin({0,Bin},Num).
-
-%% same as above but returns octets as a List
-getoctets_as_list(Buffer,Num) ->
- {Bin,Buffer2} = getoctets_as_bin(Buffer,Num),
- {binary_to_list(Bin),Buffer2}.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% set_choice(Alt,Choices,Altnum) -> ListofBitSettings
-%% Alt = atom()
-%% Altnum = integer() | {integer(),integer()}% number of alternatives
-%% Choices = [atom()] | {[atom()],[atom()]}
-%% When Choices is a tuple the first list is the Rootset and the
-%% second is the Extensions and then Altnum must also be a tuple with the
-%% lengths of the 2 lists
-%%
-set_choice(Alt,{L1,L2},{Len1,_Len2}) ->
- case set_choice_tag(Alt,L1) of
- N when is_integer(N), Len1 > 1 ->
- [{bits,1,0}, % the value is in the root set
- encode_integer([{'ValueRange',{0,Len1-1}}],N)];
- N when is_integer(N) ->
- [{bits,1,0}]; % no encoding if only 0 or 1 alternative
- false ->
- [{bits,1,1}, % extension value
- case set_choice_tag(Alt,L2) of
- N2 when is_integer(N2) ->
- encode_small_number(N2);
- false ->
- unknown_choice_alt
- end]
- end;
-set_choice(Alt,L,Len) ->
- case set_choice_tag(Alt,L) of
- N when is_integer(N), Len > 1 ->
- encode_integer([{'ValueRange',{0,Len-1}}],N);
- N when is_integer(N) ->
- []; % no encoding if only 0 or 1 alternative
- false ->
- [unknown_choice_alt]
- end.
-
-set_choice_tag(Alt,Choices) ->
- set_choice_tag(Alt,Choices,0).
-
-set_choice_tag(Alt,[Alt|_Rest],Tag) ->
- Tag;
-set_choice_tag(Alt,[_H|Rest],Tag) ->
- set_choice_tag(Alt,Rest,Tag+1);
-set_choice_tag(_Alt,[],_Tag) ->
- false.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_fragmented_XXX; decode of values encoded fragmented according
-%% to ITU-T X.691 clause 10.9.3.8. The unit (XXX) is either bits, octets,
-%% characters or number of components (in a choice,sequence or similar).
-%% Buffer is a buffer {Used, Bin}.
-%% C is the constrained length.
-%% If the buffer is not aligned, this function does that.
-decode_fragmented_bits({0,Buffer},C) ->
- decode_fragmented_bits(Buffer,C,[]);
-decode_fragmented_bits({_N,<<_,Bs/binary>>},C) ->
- decode_fragmented_bits(Bs,C,[]).
-
-decode_fragmented_bits(<<3:2,Len:6,Bin/binary>>,C,Acc) ->
- {Value,Bin2} = split_binary(Bin, Len * ?'16K'),
- decode_fragmented_bits(Bin2,C,[Value,Acc]);
-decode_fragmented_bits(<<0:1,0:7,Bin/binary>>,C,Acc) ->
- BinBits = list_to_binary(lists:reverse(Acc)),
- case C of
- Int when is_integer(Int),C == size(BinBits) ->
- {BinBits,{0,Bin}};
- Int when is_integer(Int) ->
- exit({error,{asn1,{illegal_value,C,BinBits}}})
- end;
-decode_fragmented_bits(<<0:1,Len:7,Bin/binary>>,C,Acc) ->
- Result = {BinBits,{Used,_Rest}} =
- case (Len rem 8) of
- 0 ->
- <<Value:Len/binary-unit:1,Bin2/binary>> = Bin,
- {list_to_binary(lists:reverse([Value|Acc])),{0,Bin2}};
- Rem ->
- Bytes = Len div 8,
- U = 8 - Rem,
- <<Value:Bytes/binary-unit:8,Bits1:Rem,Bits2:U,Bin2/binary>> = Bin,
- {list_to_binary(lists:reverse([Bits1 bsl U,Value|Acc])),
- {Rem,<<Bits2,Bin2/binary>>}}
- end,
- case C of
- Int when is_integer(Int),C == (size(BinBits) - ((8 - Used) rem 8)) ->
- Result;
- Int when is_integer(Int) ->
- exit({error,{asn1,{illegal_value,C,BinBits}}})
- end.
-
-
-decode_fragmented_octets({0,Bin},C) ->
- decode_fragmented_octets(Bin,C,[]).
-
-decode_fragmented_octets(<<3:2,Len:6,Bin/binary>>,C,Acc) ->
- {Value,Bin2} = split_binary(Bin,Len * ?'16K'),
- decode_fragmented_octets(Bin2,C,[Value,Acc]);
-decode_fragmented_octets(<<0:1,0:7,Bin/binary>>,C,Acc) ->
- Octets = list_to_binary(lists:reverse(Acc)),
- case C of
- Int when is_integer(Int), C == size(Octets) ->
- {Octets,{0,Bin}};
- Int when is_integer(Int) ->
- exit({error,{asn1,{illegal_value,C,Octets}}})
- end;
-decode_fragmented_octets(<<0:1,Len:7,Bin/binary>>,C,Acc) ->
- <<Value:Len/binary-unit:8,Bin2/binary>> = Bin,
- BinOctets = list_to_binary(lists:reverse([Value|Acc])),
- case C of
- Int when is_integer(Int),size(BinOctets) == Int ->
- {BinOctets,Bin2};
- Int when is_integer(Int) ->
- exit({error,{asn1,{illegal_value,C,BinOctets}}})
- end.
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% encode_open_type(Constraint, Value) -> CompleteList
-%% Value = list of bytes of an already encoded value (the list must be flat)
-%% | binary
-%% Contraint = not used in this version
-%%
-encode_open_type(_C, Val) when is_list(Val) ->
- Bin = list_to_binary(Val),
- [encode_length(undefined,size(Bin)),{octets,Bin}]; % octets implies align
-encode_open_type(_C, Val) when is_binary(Val) ->
- [encode_length(undefined,size(Val)),{octets,Val}]. % octets implies align
-%% the binary_to_list is not optimal but compatible with the current solution
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_open_type(Buffer,Constraint) -> Value
-%% Constraint is not used in this version
-%% Buffer = [byte] with PER encoded data
-%% Value = [byte] with decoded data (which must be decoded again as some type)
-%%
-decode_open_type(Bytes, _C) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- getoctets_as_bin(Bytes2,Len).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% encode_integer(Constraint,Value,NamedNumberList) -> CompleteList
-%% encode_integer(Constraint,Value) -> CompleteList
-%% encode_integer(Constraint,{Name,Value}) -> CompleteList
-%%
-%%
-encode_integer(C,V,NamedNumberList) when is_atom(V) ->
- case lists:keysearch(V,1,NamedNumberList) of
- {value,{_,NewV}} ->
- encode_integer(C,NewV);
- _ ->
- exit({error,{asn1,{namednumber,V}}})
- end;
-encode_integer(C,V,_NamedNumberList) when is_integer(V) ->
- encode_integer(C,V);
-encode_integer(C,{Name,V},NamedNumberList) when is_atom(Name) ->
- encode_integer(C,V,NamedNumberList).
-
-encode_integer(C,{Name,Val}) when is_atom(Name) ->
- encode_integer(C,Val);
-
-encode_integer([{Rc,_Ec}],Val) when is_tuple(Rc) -> % XXX when is this invoked? First argument most often a list,...Ok this is the extension case...but it doesn't work.
- case (catch encode_integer([Rc],Val)) of
- {'EXIT',{error,{asn1,_}}} ->
- [{bits,1,1},encode_unconstrained_number(Val)];
- Encoded ->
- [{bits,1,0},Encoded]
- end;
-encode_integer(C,Val ) when is_list(C) ->
- case get_constraint(C,'SingleValue') of
- no ->
- encode_integer1(C,Val);
- V when is_integer(V),V == Val ->
- []; % a type restricted to a single value encodes to nothing
- V when is_list(V) ->
- case lists:member(Val,V) of
- true ->
- encode_integer1(C,Val);
- _ ->
- exit({error,{asn1,{illegal_value,Val}}})
- end;
- _ ->
- exit({error,{asn1,{illegal_value,Val}}})
- end.
-
-encode_integer1(C, Val) ->
- case VR = get_constraint(C,'ValueRange') of
- no ->
- encode_unconstrained_number(Val);
- {Lb,'MAX'} ->
- encode_semi_constrained_number(Lb,Val);
- %% positive with range
- {Lb,Ub} when Val >= Lb,
- Ub >= Val ->
- encode_constrained_number(VR,Val);
- _ ->
- exit({error,{asn1,{illegal_value,VR,Val}}})
- end.
-
-decode_integer(Buffer,Range,NamedNumberList) ->
- {Val,Buffer2} = decode_integer(Buffer,Range),
- case lists:keysearch(Val,2,NamedNumberList) of
- {value,{NewVal,_}} -> {NewVal,Buffer2};
- _ -> {Val,Buffer2}
- end.
-
-decode_integer(Buffer,[{Rc,_Ec}]) when is_tuple(Rc) ->
- {Ext,Buffer2} = getext(Buffer),
- case Ext of
- 0 -> decode_integer(Buffer2,[Rc]);
- 1 -> decode_unconstrained_number(Buffer2)
- end;
-decode_integer(Buffer,undefined) ->
- decode_unconstrained_number(Buffer);
-decode_integer(Buffer,C) ->
- case get_constraint(C,'SingleValue') of
- V when is_integer(V) ->
- {V,Buffer};
- V when is_list(V) ->
- {Val,Buffer2} = decode_integer1(Buffer,C),
- case lists:member(Val,V) of
- true ->
- {Val,Buffer2};
- _ ->
- exit({error,{asn1,{illegal_value,Val}}})
- end;
- _ ->
- decode_integer1(Buffer,C)
- end.
-
-decode_integer1(Buffer,C) ->
- case VR = get_constraint(C,'ValueRange') of
- no ->
- decode_unconstrained_number(Buffer);
- {Lb, 'MAX'} ->
- decode_semi_constrained_number(Buffer,Lb);
- {_,_} ->
- decode_constrained_number(Buffer,VR)
- end.
-
- % X.691:10.6 Encoding of a normally small non-negative whole number
- % Use this for encoding of CHOICE index if there is an extension marker in
- % the CHOICE
-encode_small_number({Name,Val}) when is_atom(Name) ->
- encode_small_number(Val);
-encode_small_number(Val) when Val =< 63 ->
-% [{bits,1,0},{bits,6,Val}];
- [{bits,7,Val}]; % same as above but more efficient
-encode_small_number(Val) ->
- [{bits,1,1},encode_semi_constrained_number(0,Val)].
-
-decode_small_number(Bytes) ->
- {Bit,Bytes2} = getbit(Bytes),
- case Bit of
- 0 ->
- getbits(Bytes2,6);
- 1 ->
- decode_semi_constrained_number(Bytes2,0)
- end.
-
-%% X.691:10.7 Encoding of a semi-constrained whole number
-%% might be an optimization encode_semi_constrained_number(0,Val) ->
-encode_semi_constrained_number(C,{Name,Val}) when is_atom(Name) ->
- encode_semi_constrained_number(C,Val);
-encode_semi_constrained_number({Lb,'MAX'},Val) ->
- encode_semi_constrained_number(Lb,Val);
-encode_semi_constrained_number(Lb,Val) ->
- Val2 = Val - Lb,
- Oct = eint_positive(Val2),
- Len = length(Oct),
- if
- Len < 128 ->
- {octets,[Len|Oct]}; % equiv with encode_length(undefined,Len) but faster
- true ->
- [encode_length(undefined,Len),{octets,Oct}]
- end.
-
-decode_semi_constrained_number(Bytes,{Lb,_}) ->
- decode_semi_constrained_number(Bytes,Lb);
-decode_semi_constrained_number(Bytes,Lb) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {V,Bytes3} = getoctets(Bytes2,Len),
- {V+Lb,Bytes3}.
-
-encode_constrained_number(Range,{Name,Val}) when is_atom(Name) ->
- encode_constrained_number(Range,Val);
-encode_constrained_number({Lb,Ub},Val) when Val >= Lb, Ub >= Val ->
- Range = Ub - Lb + 1,
- Val2 = Val - Lb,
- if
- Range == 1 ->
- [];
- Range == 2 ->
- {bits,1,Val2};
- Range =< 4 ->
- {bits,2,Val2};
- Range =< 8 ->
- {bits,3,Val2};
- Range =< 16 ->
- {bits,4,Val2};
- Range =< 32 ->
- {bits,5,Val2};
- Range =< 64 ->
- {bits,6,Val2};
- Range =< 128 ->
- {bits,7,Val2};
- Range =< 255 ->
- {bits,8,Val2};
- Range =< 256 ->
- {octets,[Val2]};
- Range =< 65536 ->
- {octets,<<Val2:16>>};
- Range =< (1 bsl (255*8)) ->
- Octs = binary:encode_unsigned(Val2),
- RangeOcts = binary:encode_unsigned(Range - 1),
- OctsLen = erlang:byte_size(Octs),
- RangeOctsLen = erlang:byte_size(RangeOcts),
- LengthBitsNeeded = minimum_bits(RangeOctsLen - 1),
- [{bits, LengthBitsNeeded, OctsLen - 1}, {octets, Octs}];
- true ->
- exit({not_supported,{integer_range,Range}})
- end;
-encode_constrained_number(Range,Val) ->
- exit({error,{asn1,{integer_range,Range,value,Val}}}).
-
-%% For some reason the minimum bits needed in the length field in encoding of
-%% constrained whole numbers must always be atleast 2?
-minimum_bits(N) when N < 4 -> 2;
-minimum_bits(N) when N < 8 -> 3;
-minimum_bits(N) when N < 16 -> 4;
-minimum_bits(N) when N < 32 -> 5;
-minimum_bits(N) when N < 64 -> 6;
-minimum_bits(N) when N < 128 -> 7;
-minimum_bits(_N) -> 8.
-
-decode_constrained_number(Buffer,{Lb,Ub}) ->
- Range = Ub - Lb + 1,
- % Val2 = Val - Lb,
- {Val,Remain} =
- if
- Range == 1 ->
- {0,Buffer};
- Range == 2 ->
- getbits(Buffer,1);
- Range =< 4 ->
- getbits(Buffer,2);
- Range =< 8 ->
- getbits(Buffer,3);
- Range =< 16 ->
- getbits(Buffer,4);
- Range =< 32 ->
- getbits(Buffer,5);
- Range =< 64 ->
- getbits(Buffer,6);
- Range =< 128 ->
- getbits(Buffer,7);
- Range =< 255 ->
- getbits(Buffer,8);
- Range =< 256 ->
- getoctets(Buffer,1);
- Range =< 65536 ->
- getoctets(Buffer,2);
- Range =< (1 bsl (255*8)) ->
- OList = binary:bin_to_list(binary:encode_unsigned(Range - 1)),
- RangeOctLen = length(OList),
- {Len, Bytes} = decode_length(Buffer, {1, RangeOctLen}),
- {Octs, RestBytes} = getoctets_as_list(Bytes, Len),
- {binary:decode_unsigned(binary:list_to_bin(Octs)), RestBytes};
- true ->
- exit({not_supported,{integer_range,Range}})
- end,
- {Val+Lb,Remain}.
-
-%% X.691:10.8 Encoding of an unconstrained whole number
-
-encode_unconstrained_number(Val) when Val >= 0 ->
- Oct = eint(Val,[]),
- Len = length(Oct),
- if
- Len < 128 ->
- {octets,[Len|Oct]}; % equiv with encode_length(undefined,Len) but faster
- true ->
- [encode_length(undefined,Len),{octets,Oct}]
- end;
-encode_unconstrained_number(Val) -> % negative
- Oct = enint(Val,[]),
- Len = length(Oct),
- if
- Len < 128 ->
- {octets,[Len|Oct]}; % equiv with encode_length(undefined,Len) but faster
- true ->
- [encode_length(undefined,Len),{octets,Oct}]
- end.
-
-
-%% used for positive Values which don't need a sign bit
-%% returns a binary
-eint_positive(Val) ->
- case eint(Val,[]) of
- [0,B1|T] ->
- [B1|T];
- T ->
- T
- end.
-
-
-eint(0, [B|Acc]) when B < 128 ->
- [B|Acc];
-eint(N, Acc) ->
- eint(N bsr 8, [N band 16#ff| Acc]).
-
-enint(-1, [B1|T]) when B1 > 127 ->
- [B1|T];
-enint(N, Acc) ->
- enint(N bsr 8, [N band 16#ff|Acc]).
-
-decode_unconstrained_number(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {Ints,Bytes3} = getoctets_as_list(Bytes2,Len),
- {dec_integer(Ints),Bytes3}.
-
-dec_integer(Ints) when hd(Ints) band 255 =< 127 -> %% Positive number
- decpint(Ints, 8 * (length(Ints) - 1));
-dec_integer(Ints) -> %% Negative
- decnint(Ints, 8 * (length(Ints) - 1)).
-
-decpint([Byte|Tail], Shift) ->
- (Byte bsl Shift) bor decpint(Tail, Shift-8);
-decpint([], _) -> 0.
-
-decnint([Byte|Tail], Shift) ->
- (-128 + (Byte band 127) bsl Shift) bor decpint(Tail, Shift-8).
-
-% minimum_octets(Val) ->
-% minimum_octets(Val,[]).
-
-% minimum_octets(Val,Acc) when Val > 0 ->
-% minimum_octets((Val bsr 8),[Val band 16#FF|Acc]);
-% minimum_octets(0,Acc) ->
-% Acc.
-
-
-%% X.691:10.9 Encoding of a length determinant
-%%encode_small_length(undefined,Len) -> % null means no UpperBound
-%% encode_small_number(Len).
-
-%% X.691:10.9.3.5
-%% X.691:10.9.3.7
-encode_length(undefined,Len) -> % un-constrained
- if
- Len < 128 ->
- {octets,[Len]};
- Len < 16384 ->
- {octets,<<2:2,Len:14>>};
- true -> % should be able to endode length >= 16384
- exit({error,{asn1,{encode_length,{nyi,above_16k}}}})
- end;
-
-encode_length({0,'MAX'},Len) ->
- encode_length(undefined,Len);
-encode_length(Vr={Lb,Ub},Len) when Ub =< 65535 ,Lb >= 0 -> % constrained
- encode_constrained_number(Vr,Len);
-encode_length({Lb,_Ub},Len) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
- encode_length(undefined,Len);
-encode_length({Vr={Lb,Ub},Ext},Len)
- when Ub =< 65535 ,Lb >= 0, Len=<Ub, is_list(Ext) ->
- %% constrained extensible
- [{bits,1,0},encode_constrained_number(Vr,Len)];
-encode_length({{Lb,_Ub},Ext},Len) when is_list(Ext) ->
- [{bits,1,1},encode_semi_constrained_number(Lb,Len)];
-encode_length(SingleValue,_Len) when is_integer(SingleValue) ->
- [].
-
-%% X.691 10.9.3.4 (only used for length of bitmap that prefixes extension
-%% additions in a sequence or set
-encode_small_length(Len) when Len =< 64 ->
-%% [{bits,1,0},{bits,6,Len-1}];
- {bits,7,Len-1}; % the same as above but more efficient
-encode_small_length(Len) ->
- [{bits,1,1},encode_length(undefined,Len)].
-
-% decode_small_length({Used,<<_:Used,0:1,Num:6,_:((8-Used+1) rem 8),Rest/binary>>}) ->
-% case Buffer of
-% <<_:Used,0:1,Num:6,_:((8-Used+1) rem 8),Rest/binary>> ->
-% {Num,
-% case getbit(Buffer) of
-% {0,Remain} ->
-% {Bits,Remain2} = getbits(Remain,6),
-% {Bits+1,Remain2};
-% {1,Remain} ->
-% decode_length(Remain,undefined)
-% end.
-
-decode_small_length(Buffer) ->
- case getbit(Buffer) of
- {0,Remain} ->
- {Bits,Remain2} = getbits(Remain,6),
- {Bits+1,Remain2};
- {1,Remain} ->
- decode_length(Remain,undefined)
- end.
-
-decode_length(Buffer) ->
- decode_length(Buffer,undefined).
-
-decode_length(Buffer,undefined) -> % un-constrained
- {0,Buffer2} = align(Buffer),
- case Buffer2 of
- <<0:1,Oct:7,Rest/binary>> ->
- {Oct,{0,Rest}};
- <<2:2,Val:14,Rest/binary>> ->
- {Val,{0,Rest}};
- <<3:2,_:14,_Rest/binary>> ->
- %% this case should be fixed
- exit({error,{asn1,{decode_length,{nyi,above_16k}}}})
- end;
-%% {Bits,_} = getbits(Buffer2,2),
-% case Bits of
-% 2 ->
-% {Val,Bytes3} = getoctets(Buffer2,2),
-% {(Val band 16#3FFF),Bytes3};
-% 3 ->
-% exit({error,{asn1,{decode_length,{nyi,above_16k}}}});
-% _ ->
-% {Val,Bytes3} = getoctet(Buffer2),
-% {Val band 16#7F,Bytes3}
-% end;
-
-decode_length(Buffer,{Lb,Ub}) when Ub =< 65535 ,Lb >= 0 -> % constrained
- decode_constrained_number(Buffer,{Lb,Ub});
-decode_length(Buffer,{Lb,_}) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
- decode_length(Buffer,undefined);
-decode_length(Buffer,{VR={_Lb,_Ub},Ext}) when is_list(Ext) ->
- case getbit(Buffer) of
- {0,Buffer2} ->
- decode_length(Buffer2, VR);
- {1,Buffer2} ->
- decode_length(Buffer2, undefined)
- end;
-%% {0,Buffer2} = getbit(Buffer),
-%% decode_length(Buffer2, VR);
-
-
-%When does this case occur with {_,_Lb,Ub} ??
-% X.691:10.9.3.5
-decode_length({Used,Bin},{_,_Lb,_Ub}) -> %when Len =< 127 -> % Unconstrained or large Ub NOTE! this case does not cover case when Ub > 65535
- Unused = (8-Used) rem 8,
- case Bin of
- <<_:Used,0:1,Val:7,R:Unused,Rest/binary>> ->
- {Val,{Used,<<R,Rest/binary>>}};
- <<_:Used,_:Unused,2:2,Val:14,Rest/binary>> ->
- {Val, {0,Rest}};
- <<_:Used,_:Unused,3:2,_:14,_Rest/binary>> ->
- exit({error,{asn1,{decode_length,{nyi,length_above_64K}}}})
- end;
-% decode_length(Buffer,{_,_Lb,Ub}) -> %when Len =< 127 -> % Unconstrained or large Ub
-% case getbit(Buffer) of
-% {0,Remain} ->
-% getbits(Remain,7);
-% {1,Remain} ->
-% {Val,Remain2} = getoctets(Buffer,2),
-% {Val band 2#0111111111111111, Remain2}
-% end;
-decode_length(Buffer,SingleValue) when is_integer(SingleValue) ->
- {SingleValue,Buffer}.
-
-
- % X.691:11
-encode_boolean(true) ->
- {bits,1,1};
-encode_boolean(false) ->
- {bits,1,0};
-encode_boolean({Name,Val}) when is_atom(Name) ->
- encode_boolean(Val);
-encode_boolean(Val) ->
- exit({error,{asn1,{encode_boolean,Val}}}).
-
-decode_boolean(Buffer) -> %when record(Buffer,buffer)
- case getbit(Buffer) of
- {1,Remain} -> {true,Remain};
- {0,Remain} -> {false,Remain}
- end.
-
-
-%% ENUMERATED with extension marker
-decode_enumerated(Buffer,C,{Ntup1,Ntup2}) when is_tuple(Ntup1), is_tuple(Ntup2) ->
- {Ext,Buffer2} = getext(Buffer),
- case Ext of
- 0 -> % not an extension value
- {Val,Buffer3} = decode_integer(Buffer2,C),
- case catch (element(Val+1,Ntup1)) of
- NewVal when is_atom(NewVal) -> {NewVal,Buffer3};
- _Error -> exit({error,{asn1,{decode_enumerated,{Val,[Ntup1,Ntup2]}}}})
- end;
- 1 -> % this an extension value
- {Val,Buffer3} = decode_small_number(Buffer2),
- case catch (element(Val+1,Ntup2)) of
- NewVal when is_atom(NewVal) -> {NewVal,Buffer3};
- _ -> {{asn1_enum,Val},Buffer3}
- end
- end;
-
-decode_enumerated(Buffer,C,NamedNumberTup) when is_tuple(NamedNumberTup) ->
- {Val,Buffer2} = decode_integer(Buffer,C),
- case catch (element(Val+1,NamedNumberTup)) of
- NewVal when is_atom(NewVal) -> {NewVal,Buffer2};
- _Error -> exit({error,{asn1,{decode_enumerated,{Val,NamedNumberTup}}}})
- end.
-
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-%% Bitstring value, ITU_T X.690 Chapter 8.5
-%%===============================================================================
-%%===============================================================================
-%%===============================================================================
-
-%%===============================================================================
-%% encode bitstring value
-%%===============================================================================
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% bitstring NamedBitList
-%% Val can be of:
-%% - [identifiers] where only named identifers are set to one,
-%% the Constraint must then have some information of the
-%% bitlength.
-%% - [list of ones and zeroes] all bits
-%% - integer value representing the bitlist
-%% C is constraint Len, only valid when identifiers
-
-
-%% when the value is a list of {Unused,BinBits}, where
-%% Unused = integer(),
-%% BinBits = binary().
-
-encode_bit_string(C,Bin={Unused,BinBits},NamedBitList) when is_integer(Unused),
- is_binary(BinBits) ->
- encode_bin_bit_string(C,Bin,NamedBitList);
-
-%% when the value is a list of named bits
-encode_bit_string(C, LoNB=[FirstVal | _RestVal], NamedBitList) when is_atom(FirstVal) ->
- ToSetPos = get_all_bitposes(LoNB, NamedBitList, []),
- BitList = make_and_set_list(ToSetPos,0),
- encode_bit_string(C,BitList,NamedBitList);
-
-encode_bit_string(C, BL=[{bit,_No} | _RestVal], NamedBitList) ->
- ToSetPos = get_all_bitposes(BL, NamedBitList, []),
- BitList = make_and_set_list(ToSetPos,0),
- encode_bit_string(C,BitList,NamedBitList);
-
-%% when the value is a list of ones and zeroes
-
-% encode_bit_string(C, BitListValue, NamedBitList) when is_list(BitListValue) ->
-% Bl1 =
-% case NamedBitList of
-% [] -> % dont remove trailing zeroes
-% BitListValue;
-% _ -> % first remove any trailing zeroes
-% lists:reverse(lists:dropwhile(fun(0)->true;(1)->false end,
-% lists:reverse(BitListValue)))
-% end,
-% BitList = [{bit,X} || X <- Bl1],
-% %% BListLen = length(BitList),
-% case get_constraint(C,'SizeConstraint') of
-% 0 -> % fixed length
-% []; % nothing to encode
-% V when is_integer(V),V=<16 -> % fixed length 16 bits or less
-% pad_list(V,BitList);
-% V when is_integer(V) -> % fixed length 16 bits or more
-% [align,pad_list(V,BitList)]; % should be another case for V >= 65537
-% {Lb,Ub} when is_integer(Lb),is_integer(Ub) ->
-% [encode_length({Lb,Ub},length(BitList)),align,BitList];
-% no ->
-% [encode_length(undefined,length(BitList)),align,BitList];
-% Sc -> % extension marker
-% [encode_length(Sc,length(BitList)),align,BitList]
-% end;
-encode_bit_string(C, BitListValue, NamedBitList) when is_list(BitListValue) ->
- BitListToBinary =
- %% fun that transforms a list of 1 and 0 to a tuple:
- %% {UnusedBitsInLastByte, Binary}
- fun([1|T],Acc,N,Fun) ->
- Fun(T,(Acc bsl 1)+1,N+1,Fun);
- ([0|T],Acc,N,Fun) ->
- Fun(T,(Acc bsl 1),N+1,Fun);
- ([_H|_T],_,_,_) ->
- exit({error,{asn1,{bitstring_bitlist,BitListValue}}});
- ([],Acc,N,_) ->
- Unused = (8 - (N rem 8)) rem 8,
- {Unused,<<Acc:N,0:Unused>>}
- end,
- UnusedAndBin =
- case NamedBitList of
- [] -> % dont remove trailing zeroes
- BitListToBinary(BitListValue,0,0,BitListToBinary);
- _ ->
- BitListToBinary(lists:reverse(
- lists:dropwhile(fun(0)->true;(_)->false end,
- lists:reverse(BitListValue))),
- 0,0,BitListToBinary)
- end,
- encode_bin_bit_string(C,UnusedAndBin,NamedBitList);
-
-%% when the value is an integer
-encode_bit_string(C, IntegerVal, NamedBitList) when is_integer(IntegerVal)->
- BitList = int_to_bitlist(IntegerVal),
- encode_bit_string(C,BitList,NamedBitList);
-
-%% when the value is a tuple
-encode_bit_string(C,{Name,Val}, NamedBitList) when is_atom(Name) ->
- encode_bit_string(C,Val,NamedBitList).
-
-
-%% encode_bin_bit_string/3, when value is a tuple of Unused and BinBits.
-%% Unused = integer(),i.e. number unused bits in least sign. byte of
-%% BinBits = binary().
-
-
-encode_bin_bit_string(C,UnusedAndBin={_Unused,_BinBits},NamedBitList) ->
- Constr = get_constraint(C,'SizeConstraint'),
- UnusedAndBin1 = {Unused1,Bin1} =
- remove_trailing_bin(NamedBitList,UnusedAndBin,lower_bound(Constr)),
- case Constr of
- 0 ->
- [];
- V when is_integer(V),V=<16 ->
- {Unused2,Bin2} = pad_list(V,UnusedAndBin1),
- <<BitVal:V,_:Unused2>> = Bin2,
- {bits,V,BitVal};
- V when is_integer(V) ->
- [align, pad_list(V, UnusedAndBin1)];
- {Lb,Ub} when is_integer(Lb),is_integer(Ub) ->
- [encode_length({Lb,Ub},size(Bin1)*8 - Unused1),
- align,UnusedAndBin1];
- {{Fix,Fix},L} when is_integer(Fix),is_list(L) ->
- %% X.691 � 15.6, the rest of this paragraph is covered by
- %% the last, ie. Sc, clause in this case
- case (size(Bin1)*8)-Unused1 of
- Size when Size =< Fix, Fix =< 16 ->
- {Unused2,Bin2} = pad_list(Fix,UnusedAndBin),
- <<BitVal:Fix,_:Unused2>> = Bin2,
- [{bits,1,0},{bits,Fix,BitVal}];
- Size when Size =< Fix ->
- [{bits,1,0},align, pad_list(Fix, UnusedAndBin1)];
- Size ->
- [{bits,1,1},encode_length(undefined,Size),
- align,UnusedAndBin1]
- end;
- no ->
- [encode_length(undefined,size(Bin1)*8 - Unused1),
- align,UnusedAndBin1];
- Sc ->
- [encode_length(Sc,size(Bin1)*8 - Unused1),
- align,UnusedAndBin1]
- end.
-
-
-remove_trailing_bin([], {Unused,Bin},_) ->
- {Unused,Bin};
-remove_trailing_bin(_NamedNumberList,{_Unused,<<>>},C) ->
- case C of
- Int when is_integer(Int),Int > 0 ->
- %% this padding see OTP-4353
- pad_list(Int,{0,<<>>});
- _ -> {0,<<>>}
- end;
-remove_trailing_bin(NamedNumberList, {_Unused,Bin},C) ->
- Size = size(Bin)-1,
- <<Bfront:Size/binary, LastByte:8>> = Bin,
- %% clear the Unused bits to be sure
- Unused1 = trailingZeroesInNibble(LastByte band 15),
- Unused2 =
- case Unused1 of
- 4 ->
- 4 + trailingZeroesInNibble(LastByte bsr 4);
- _ -> Unused1
- end,
- case Unused2 of
- 8 ->
- remove_trailing_bin(NamedNumberList,{0,Bfront},C);
- _ ->
- case C of
- Int when is_integer(Int),Int > ((size(Bin)*8)-Unused2) ->
- %% this padding see OTP-4353
- pad_list(Int,{Unused2,Bin});
- _ -> {Unused2,Bin}
- end
- end.
-
-
-trailingZeroesInNibble(0) ->
- 4;
-trailingZeroesInNibble(1) ->
- 0;
-trailingZeroesInNibble(2) ->
- 1;
-trailingZeroesInNibble(3) ->
- 0;
-trailingZeroesInNibble(4) ->
- 2;
-trailingZeroesInNibble(5) ->
- 0;
-trailingZeroesInNibble(6) ->
- 1;
-trailingZeroesInNibble(7) ->
- 0;
-trailingZeroesInNibble(8) ->
- 3;
-trailingZeroesInNibble(9) ->
- 0;
-trailingZeroesInNibble(10) ->
- 1;
-trailingZeroesInNibble(11) ->
- 0;
-trailingZeroesInNibble(12) -> %#1100
- 2;
-trailingZeroesInNibble(13) ->
- 0;
-trailingZeroesInNibble(14) ->
- 1;
-trailingZeroesInNibble(15) ->
- 0.
-
-lower_bound({{Lb,_},_}) when is_integer(Lb) ->
- Lb;
-lower_bound({Lb,_}) when is_integer(Lb) ->
- Lb;
-lower_bound(C) ->
- C.
-
-%%%%%%%%%%%%%%%
-%% The result is presented as a list of named bits (if possible)
-%% else as a tuple {Unused,Bits}. Unused is the number of unused
-%% bits, least significant bits in the last byte of Bits. Bits is
-%% the BIT STRING represented as a binary.
-%%
-decode_compact_bit_string(Buffer, C, NamedNumberList) ->
- case get_constraint(C,'SizeConstraint') of
- 0 -> % fixed length
- {{8,0},Buffer};
- V when is_integer(V),V=<16 -> %fixed length 16 bits or less
- compact_bit_string(Buffer,V,NamedNumberList);
- V when is_integer(V),V=<65536 -> %fixed length > 16 bits
- Bytes2 = align(Buffer),
- compact_bit_string(Bytes2,V,NamedNumberList);
- V when is_integer(V) -> % V > 65536 => fragmented value
- {Bin,Buffer2} = decode_fragmented_bits(Buffer,V),
- case Buffer2 of
- {0,_} -> {{0,Bin},Buffer2};
- {U,_} -> {{8-U,Bin},Buffer2}
- end;
- {Lb,Ub} when is_integer(Lb),is_integer(Ub) ->
- %% This case may demand decoding of fragmented length/value
- {Len,Bytes2} = decode_length(Buffer,{Lb,Ub}),
- Bytes3 = align(Bytes2),
- compact_bit_string(Bytes3,Len,NamedNumberList);
- no ->
- %% This case may demand decoding of fragmented length/value
- {Len,Bytes2} = decode_length(Buffer,undefined),
- Bytes3 = align(Bytes2),
- compact_bit_string(Bytes3,Len,NamedNumberList);
- {{Fix,Fix},L} = Sc when is_list(L), is_integer(Fix), Fix =< 16 ->
- %% X.691 �15.6, special case of extension marker
- case decode_length(Buffer,Sc) of
- {Len,Bytes2} when Len > Fix ->
- Bytes3 = align(Bytes2),
- compact_bit_string(Bytes3,Len,NamedNumberList);
- {Len,Bytes2} ->
- compact_bit_string(Bytes2,Len,NamedNumberList)
- end;
- Sc ->
- {Len,Bytes2} = decode_length(Buffer,Sc),
- Bytes3 = align(Bytes2),
- compact_bit_string(Bytes3,Len,NamedNumberList)
- end.
-
-
-%%%%%%%%%%%%%%%
-%% The result is presented as a list of named bits (if possible)
-%% else as a list of 0 and 1.
-%%
-decode_bit_string(Buffer, C, NamedNumberList) ->
- case get_constraint(C,'SizeConstraint') of
- {Lb,Ub} when is_integer(Lb),is_integer(Ub) ->
- {Len,Bytes2} = decode_length(Buffer,{Lb,Ub}),
- Bytes3 = align(Bytes2),
- bit_list_or_named(Bytes3,Len,NamedNumberList);
- no ->
- {Len,Bytes2} = decode_length(Buffer,undefined),
- Bytes3 = align(Bytes2),
- bit_list_or_named(Bytes3,Len,NamedNumberList);
- 0 -> % fixed length
- {[],Buffer}; % nothing to encode
- V when is_integer(V),V=<16 -> % fixed length 16 bits or less
- bit_list_or_named(Buffer,V,NamedNumberList);
- V when is_integer(V),V=<65536 ->
- Bytes2 = align(Buffer),
- bit_list_or_named(Bytes2,V,NamedNumberList);
- V when is_integer(V) ->
- Bytes2 = align(Buffer),
- {BinBits,_} = decode_fragmented_bits(Bytes2,V),
- bit_list_or_named(BinBits,V,NamedNumberList);
- {{Fix,Fix},L} = Sc when is_list(L), is_integer(Fix), Fix =< 16 ->
- %% X.691 �15.6, special case of extension marker
- case decode_length(Buffer,Sc) of
- {Len,Bytes2} when Len > Fix ->
- Bytes3 = align(Bytes2),
- bit_list_or_named(Bytes3,Len,NamedNumberList);
- {Len,Bytes2} when Len > 16 ->
- Bytes3 = align(Bytes2),
- bit_list_or_named(Bytes3,Len,NamedNumberList);
- {Len,Bytes2} ->
- bit_list_or_named(Bytes2,Len,NamedNumberList)
- end;
- Sc -> %% X.691 �15.6, extension marker
- {Len,Bytes2} = decode_length(Buffer,Sc),
- Bytes3 = align(Bytes2),
- bit_list_or_named(Bytes3,Len,NamedNumberList)
- end.
-
-
-%% if no named bits are declared we will return a
-%% {Unused,Bits}. Unused = integer(),
-%% Bits = binary().
-compact_bit_string(Buffer,Len,[]) ->
- getbits_as_binary(Len,Buffer); % {{Unused,BinBits},NewBuffer}
-compact_bit_string(Buffer,Len,NamedNumberList) ->
- bit_list_or_named(Buffer,Len,NamedNumberList).
-
-
-%% if no named bits are declared we will return a
-%% BitList = [0 | 1]
-
-bit_list_or_named(Buffer,Len,[]) ->
- getbits_as_list(Len,Buffer);
-
-%% if there are named bits declared we will return a named
-%% BitList where the names are atoms and unnamed bits represented
-%% as {bit,Pos}
-%% BitList = [atom() | {bit,Pos}]
-%% Pos = integer()
-
-bit_list_or_named(Buffer,Len,NamedNumberList) ->
- {BitList,Rest} = getbits_as_list(Len,Buffer),
- {bit_list_or_named1(0,BitList,NamedNumberList,[]), Rest}.
-
-bit_list_or_named1(Pos,[0|Bt],Names,Acc) ->
- bit_list_or_named1(Pos+1,Bt,Names,Acc);
-bit_list_or_named1(Pos,[1|Bt],Names,Acc) ->
- case lists:keysearch(Pos,2,Names) of
- {value,{Name,_}} ->
- bit_list_or_named1(Pos+1,Bt,Names,[Name|Acc]);
- _ ->
- bit_list_or_named1(Pos+1,Bt,Names,[{bit,Pos}|Acc])
- end;
-bit_list_or_named1(_,[],_,Acc) ->
- lists:reverse(Acc).
-
-
-
-%%%%%%%%%%%%%%%
-%%
-
-int_to_bitlist(Int) when is_integer(Int), Int > 0 ->
- [Int band 1 | int_to_bitlist(Int bsr 1)];
-int_to_bitlist(0) ->
- [].
-
-
-%%%%%%%%%%%%%%%%%%
-%% get_all_bitposes([list of named bits to set], named_bit_db, []) ->
-%% [sorted_list_of_bitpositions_to_set]
-
-get_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) ->
- get_all_bitposes(Rest, NamedBitList, [ValPos | Ack ]);
-
-get_all_bitposes([Val | Rest], NamedBitList, Ack) ->
- case lists:keysearch(Val, 1, NamedBitList) of
- {value, {_ValName, ValPos}} ->
- get_all_bitposes(Rest, NamedBitList, [ValPos | Ack]);
- _ ->
- exit({error,{asn1, {bitstring_namedbit, Val}}})
- end;
-get_all_bitposes([], _NamedBitList, Ack) ->
- lists:sort(Ack).
-
-%%%%%%%%%%%%%%%%%%
-%% make_and_set_list([list of positions to set to 1])->
-%% returns list with all in SetPos set.
-%% in positioning in list the first element is 0, the second 1 etc.., but
-%%
-
-make_and_set_list([XPos|SetPos], XPos) ->
- [1 | make_and_set_list(SetPos, XPos + 1)];
-make_and_set_list([Pos|SetPos], XPos) ->
- [0 | make_and_set_list([Pos | SetPos], XPos + 1)];
-make_and_set_list([], _) ->
- [].
-
-%%%%%%%%%%%%%%%%%
-%% pad_list(N,BitList) -> PaddedList
-%% returns a padded (with trailing {bit,0} elements) list of length N
-%% if Bitlist contains more than N significant bits set an exit asn1_error
-%% is generated
-
-pad_list(N,In={Unused,Bin}) ->
- pad_list(N, size(Bin)*8 - Unused, In).
-
-pad_list(N,Size,In={_,_}) when N < Size ->
- exit({error,{asn1,{range_error,{bit_string,In}}}});
-pad_list(N,Size,{Unused,Bin}) when N > Size, Unused > 0 ->
- pad_list(N,Size+1,{Unused-1,Bin});
-pad_list(N,Size,{_Unused,Bin}) when N > Size ->
- pad_list(N,Size+1,{7,<<Bin/binary,0>>});
-pad_list(N,N,In={_,_}) ->
- In.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% X.691:16
-%% encode_octet_string(Constraint,ExtensionMarker,Val)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-encode_octet_string(C,Val) ->
- encode_octet_string2(C,Val).
-
-encode_octet_string2(C,{_Name,Val}) ->
- encode_octet_string2(C,Val);
-encode_octet_string2(C,Val) ->
- case get_constraint(C,'SizeConstraint') of
- 0 ->
- [];
- 1 ->
- [V] = Val,
- {bits,8,V};
- 2 ->
- [V1,V2] = Val,
- [{bits,8,V1},{bits,8,V2}];
- Sv when Sv =<65535, Sv == length(Val) -> % fixed length
- {octets,Val};
- {Lb,Ub} ->
- [encode_length({Lb,Ub},length(Val)),{octets,Val}];
- Sv when is_list(Sv) ->
- [encode_length({hd(Sv),lists:max(Sv)},length(Val)),{octets,Val}];
- no ->
- [encode_length(undefined,length(Val)),{octets,Val}]
- end.
-
-decode_octet_string(Bytes,Range) ->
- decode_octet_string(Bytes,Range,false).
-
-decode_octet_string(Bytes,C,false) ->
- case get_constraint(C,'SizeConstraint') of
- 0 ->
- {[],Bytes};
- 1 ->
- {B1,Bytes2} = getbits(Bytes,8),
- {[B1],Bytes2};
- 2 ->
- {Bs,Bytes2}= getbits(Bytes,16),
- {binary_to_list(<<Bs:16>>),Bytes2};
- {_,0} ->
- {[],Bytes};
- Sv when is_integer(Sv), Sv =<65535 -> % fixed length
- getoctets_as_list(Bytes,Sv);
- Sv when is_integer(Sv) -> % fragmented encoding
- Bytes2 = align(Bytes),
- decode_fragmented_octets(Bytes2,Sv);
- {Lb,Ub} ->
- {Len,Bytes2} = decode_length(Bytes,{Lb,Ub}),
- getoctets_as_list(Bytes2,Len);
- Sv when is_list(Sv) ->
- {Len,Bytes2} = decode_length(Bytes,{hd(Sv),lists:max(Sv)}),
- getoctets_as_list(Bytes2,Len);
- no ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- getoctets_as_list(Bytes2,Len)
- end.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Restricted char string types
-%% (NumericString, PrintableString,VisibleString,IA5String,BMPString,UniversalString)
-%% X.691:26 and X.680:34-36
-%%encode_restricted_string(aligned,'BMPString',Constraints,Extension,Val)
-
-
-encode_restricted_string(aligned,{Name,Val}) when is_atom(Name) ->
- encode_restricted_string(aligned,Val);
-
-encode_restricted_string(aligned,Val) when is_list(Val)->
- [encode_length(undefined,length(Val)),{octets,Val}].
-
-encode_known_multiplier_string(aligned,StringType,C,_Ext,{Name,Val}) when is_atom(Name) ->
- encode_known_multiplier_string(aligned,StringType,C,false,Val);
-
-encode_known_multiplier_string(aligned,StringType,C,_Ext,Val) ->
- Result = chars_encode(C,StringType,Val),
- NumBits = get_NumBits(C,StringType),
- case get_constraint(C,'SizeConstraint') of
- Ub when is_integer(Ub), Ub*NumBits =< 16 ->
- Result;
- 0 ->
- [];
- Ub when is_integer(Ub),Ub =<65535 -> % fixed length
- [align,Result];
- {Ub,Lb} ->
- [encode_length({Ub,Lb},length(Val)),align,Result];
- Vl when is_list(Vl) ->
- [encode_length({lists:min(Vl),lists:max(Vl)},length(Val)),align,Result];
- no ->
- [encode_length(undefined,length(Val)),align,Result]
- end.
-
-decode_restricted_string(Bytes,aligned) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- getoctets_as_list(Bytes2,Len).
-
-decode_known_multiplier_string(Bytes,aligned,StringType,C,_Ext) ->
- NumBits = get_NumBits(C,StringType),
- case get_constraint(C,'SizeConstraint') of
- Ub when is_integer(Ub), Ub*NumBits =< 16 ->
- chars_decode(Bytes,NumBits,StringType,C,Ub);
- Ub when is_integer(Ub),Ub =<65535 -> % fixed length
- Bytes1 = align(Bytes),
- chars_decode(Bytes1,NumBits,StringType,C,Ub);
- 0 ->
- {[],Bytes};
- Vl when is_list(Vl) ->
- {Len,Bytes1} = decode_length(Bytes,{hd(Vl),lists:max(Vl)}),
- Bytes2 = align(Bytes1),
- chars_decode(Bytes2,NumBits,StringType,C,Len);
- no ->
- {Len,Bytes1} = decode_length(Bytes,undefined),
- Bytes2 = align(Bytes1),
- chars_decode(Bytes2,NumBits,StringType,C,Len);
- {Lb,Ub}->
- {Len,Bytes1} = decode_length(Bytes,{Lb,Ub}),
- Bytes2 = align(Bytes1),
- chars_decode(Bytes2,NumBits,StringType,C,Len)
- end.
-
-
-encode_NumericString(C,Val) ->
- encode_known_multiplier_string(aligned,'NumericString',C,false,Val).
-decode_NumericString(Bytes,C) ->
- decode_known_multiplier_string(Bytes,aligned,'NumericString',C,false).
-
-encode_PrintableString(C,Val) ->
- encode_known_multiplier_string(aligned,'PrintableString',C,false,Val).
-decode_PrintableString(Bytes,C) ->
- decode_known_multiplier_string(Bytes,aligned,'PrintableString',C,false).
-
-encode_VisibleString(C,Val) -> % equivalent with ISO646String
- encode_known_multiplier_string(aligned,'VisibleString',C,false,Val).
-decode_VisibleString(Bytes,C) ->
- decode_known_multiplier_string(Bytes,aligned,'VisibleString',C,false).
-
-encode_IA5String(C,Val) ->
- encode_known_multiplier_string(aligned,'IA5String',C,false,Val).
-decode_IA5String(Bytes,C) ->
- decode_known_multiplier_string(Bytes,aligned,'IA5String',C,false).
-
-encode_BMPString(C,Val) ->
- encode_known_multiplier_string(aligned,'BMPString',C,false,Val).
-decode_BMPString(Bytes,C) ->
- decode_known_multiplier_string(Bytes,aligned,'BMPString',C,false).
-
-encode_UniversalString(C,Val) ->
- encode_known_multiplier_string(aligned,'UniversalString',C,false,Val).
-decode_UniversalString(Bytes,C) ->
- decode_known_multiplier_string(Bytes,aligned,'UniversalString',C,false).
-
-
-%% end of known-multiplier strings for which PER visible constraints are
-%% applied
-
-encode_GeneralString(_C,Val) ->
- encode_restricted_string(aligned,Val).
-decode_GeneralString(Bytes,_C) ->
- decode_restricted_string(Bytes,aligned).
-
-encode_GraphicString(_C,Val) ->
- encode_restricted_string(aligned,Val).
-decode_GraphicString(Bytes,_C) ->
- decode_restricted_string(Bytes,aligned).
-
-encode_ObjectDescriptor(_C,Val) ->
- encode_restricted_string(aligned,Val).
-decode_ObjectDescriptor(Bytes) ->
- decode_restricted_string(Bytes,aligned).
-
-encode_TeletexString(_C,Val) -> % equivalent with T61String
- encode_restricted_string(aligned,Val).
-decode_TeletexString(Bytes,_C) ->
- decode_restricted_string(Bytes,aligned).
-
-encode_VideotexString(_C,Val) ->
- encode_restricted_string(aligned,Val).
-decode_VideotexString(Bytes,_C) ->
- decode_restricted_string(Bytes,aligned).
-
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% getBMPChars(Bytes,Len) ->{BMPcharList,RemainingBytes}
-%%
-getBMPChars(Bytes,1) ->
- {O1,Bytes2} = getbits(Bytes,8),
- {O2,Bytes3} = getbits(Bytes2,8),
- if
- O1 == 0 ->
- {[O2],Bytes3};
- true ->
- {[{0,0,O1,O2}],Bytes3}
- end;
-getBMPChars(Bytes,Len) ->
- getBMPChars(Bytes,Len,[]).
-
-getBMPChars(Bytes,0,Acc) ->
- {lists:reverse(Acc),Bytes};
-getBMPChars(Bytes,Len,Acc) ->
- {Octs,Bytes1} = getoctets_as_list(Bytes,2),
- case Octs of
- [0,O2] ->
- getBMPChars(Bytes1,Len-1,[O2|Acc]);
- [O1,O2]->
- getBMPChars(Bytes1,Len-1,[{0,0,O1,O2}|Acc])
- end.
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% chars_encode(C,StringType,Value) -> ValueList
-%%
-%% encodes chars according to the per rules taking the constraint PermittedAlphabet
-%% into account.
-%% This function does only encode the value part and NOT the length
-
-chars_encode(C,StringType,Value) ->
- case {StringType,get_constraint(C,'PermittedAlphabet')} of
- {'UniversalString',{_,_Sv}} ->
- exit({error,{asn1,{'not implemented',"UniversalString with PermittedAlphabet constraint"}}});
- {'BMPString',{_,_Sv}} ->
- exit({error,{asn1,{'not implemented',"BMPString with PermittedAlphabet constraint"}}});
- _ ->
- {NumBits,CharOutTab} = {get_NumBits(C,StringType),get_CharOutTab(C,StringType)},
- chars_encode2(Value,NumBits,CharOutTab)
- end.
-
-chars_encode2([H|T],NumBits,{Min,Max,notab}) when H =< Max, H >= Min ->
- [{bits,NumBits,H-Min}|chars_encode2(T,NumBits,{Min,Max,notab})];
-chars_encode2([H|T],NumBits,{Min,Max,Tab}) when H =< Max, H >= Min ->
- [{bits,NumBits,exit_if_false(H,element(H-Min+1,Tab))}|chars_encode2(T,NumBits,{Min,Max,Tab})];
-chars_encode2([{A,B,C,D}|T],NumBits,{Min,Max,notab}) ->
- %% no value range check here (ought to be, but very expensive)
-% [{bits,NumBits,(A*B*C*D)-Min}|chars_encode2(T,NumBits,{Min,Max,notab})];
- [{bits,NumBits,((((((A bsl 8)+B) bsl 8)+C) bsl 8)+D)-Min}|chars_encode2(T,NumBits,{Min,Max,notab})];
-chars_encode2([{A,B,C,D}|T],NumBits,{Min,Max,Tab}) ->
- %% no value range check here (ought to be, but very expensive)
-% [{bits,NumBits,element((A*B*C*D)-Min,Tab)}|chars_encode2(T,NumBits,{Min,Max,notab})];
- [{bits,NumBits,exit_if_false({A,B,C,D},element(((((((A bsl 8)+B) bsl 8)+C) bsl 8)+D)-Min,Tab))}|chars_encode2(T,NumBits,{Min,Max,notab})];
-chars_encode2([H|_T],_,{_,_,_}) ->
- exit({error,{asn1,{illegal_char_value,H}}});
-chars_encode2([],_,_) ->
- [].
-
-exit_if_false(V,false)->
- exit({error,{asn1,{"illegal value according to Permitted alphabet constraint",V}}});
-exit_if_false(_,V) ->V.
-
-
-get_NumBits(C,StringType) ->
- case get_constraint(C,'PermittedAlphabet') of
- {'SingleValue',Sv} ->
- charbits(length(Sv),aligned);
- no ->
- case StringType of
- 'IA5String' ->
- charbits(128,aligned); % 16#00..16#7F
- 'VisibleString' ->
- charbits(95,aligned); % 16#20..16#7E
- 'PrintableString' ->
- charbits(74,aligned); % [$\s,$',$(,$),$+,$,,$-,$.,$/,"0123456789",$:,$=,$?,$A..$Z,$a..$z
- 'NumericString' ->
- charbits(11,aligned); % $ ,"0123456789"
- 'UniversalString' ->
- 32;
- 'BMPString' ->
- 16
- end
- end.
-
-%%Maybe used later
-%%get_MaxChar(C,StringType) ->
-%% case get_constraint(C,'PermittedAlphabet') of
-%% {'SingleValue',Sv} ->
-%% lists:nth(length(Sv),Sv);
-%% no ->
-%% case StringType of
-%% 'IA5String' ->
-%% 16#7F; % 16#00..16#7F
-%% 'VisibleString' ->
-%% 16#7E; % 16#20..16#7E
-%% 'PrintableString' ->
-%% $z; % [$\s,$',$(,$),$+,$,,$-,$.,$/,"0123456789",$:,$=,$?,$A..$Z,$a..$z
-%% 'NumericString' ->
-%% $9; % $ ,"0123456789"
-%% 'UniversalString' ->
-%% 16#ffffffff;
-%% 'BMPString' ->
-%% 16#ffff
-%% end
-%% end.
-
-%%Maybe used later
-%%get_MinChar(C,StringType) ->
-%% case get_constraint(C,'PermittedAlphabet') of
-%% {'SingleValue',Sv} ->
-%% hd(Sv);
-%% no ->
-%% case StringType of
-%% 'IA5String' ->
-%% 16#00; % 16#00..16#7F
-%% 'VisibleString' ->
-%% 16#20; % 16#20..16#7E
-%% 'PrintableString' ->
-%% $\s; % [$\s,$',$(,$),$+,$,,$-,$.,$/,"0123456789",$:,$=,$?,$A..$Z,$a..$z
-%% 'NumericString' ->
-%% $\s; % $ ,"0123456789"
-%% 'UniversalString' ->
-%% 16#00;
-%% 'BMPString' ->
-%% 16#00
-%% end
-%% end.
-
-get_CharOutTab(C,StringType) ->
- get_CharTab(C,StringType,out).
-
-get_CharInTab(C,StringType) ->
- get_CharTab(C,StringType,in).
-
-get_CharTab(C,StringType,InOut) ->
- case get_constraint(C,'PermittedAlphabet') of
- {'SingleValue',Sv} ->
- get_CharTab2(C,StringType,hd(Sv),lists:max(Sv),Sv,InOut);
- no ->
- case StringType of
- 'IA5String' ->
- {0,16#7F,notab};
- 'VisibleString' ->
- get_CharTab2(C,StringType,16#20,16#7F,notab,InOut);
- 'PrintableString' ->
- Chars = lists:sort(
- " '()+,-./0123456789:=?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"),
- get_CharTab2(C,StringType,hd(Chars),lists:max(Chars),Chars,InOut);
- 'NumericString' ->
- get_CharTab2(C,StringType,16#20,$9," 0123456789",InOut);
- 'UniversalString' ->
- {0,16#FFFFFFFF,notab};
- 'BMPString' ->
- {0,16#FFFF,notab}
- end
- end.
-
-get_CharTab2(C,StringType,Min,Max,Chars,InOut) ->
- BitValMax = (1 bsl get_NumBits(C,StringType))-1,
- if
- Max =< BitValMax ->
- {0,Max,notab};
- true ->
- case InOut of
- out ->
- {Min,Max,create_char_tab(Min,Chars)};
- in ->
- {Min,Max,list_to_tuple(Chars)}
- end
- end.
-
-create_char_tab(Min,L) ->
- list_to_tuple(create_char_tab(Min,L,0)).
-create_char_tab(Min,[Min|T],V) ->
- [V|create_char_tab(Min+1,T,V+1)];
-create_char_tab(_Min,[],_V) ->
- [];
-create_char_tab(Min,L,V) ->
- [false|create_char_tab(Min+1,L,V)].
-
-%% This very inefficient and should be moved to compiletime
-charbits(NumOfChars,aligned) ->
- case charbits(NumOfChars) of
- 1 -> 1;
- 2 -> 2;
- B when B =< 4 -> 4;
- B when B =< 8 -> 8;
- B when B =< 16 -> 16;
- B when B =< 32 -> 32
- end.
-
-charbits(NumOfChars) when NumOfChars =< 2 -> 1;
-charbits(NumOfChars) when NumOfChars =< 4 -> 2;
-charbits(NumOfChars) when NumOfChars =< 8 -> 3;
-charbits(NumOfChars) when NumOfChars =< 16 -> 4;
-charbits(NumOfChars) when NumOfChars =< 32 -> 5;
-charbits(NumOfChars) when NumOfChars =< 64 -> 6;
-charbits(NumOfChars) when NumOfChars =< 128 -> 7;
-charbits(NumOfChars) when NumOfChars =< 256 -> 8;
-charbits(NumOfChars) when NumOfChars =< 512 -> 9;
-charbits(NumOfChars) when NumOfChars =< 1024 -> 10;
-charbits(NumOfChars) when NumOfChars =< 2048 -> 11;
-charbits(NumOfChars) when NumOfChars =< 4096 -> 12;
-charbits(NumOfChars) when NumOfChars =< 8192 -> 13;
-charbits(NumOfChars) when NumOfChars =< 16384 -> 14;
-charbits(NumOfChars) when NumOfChars =< 32768 -> 15;
-charbits(NumOfChars) when NumOfChars =< 65536 -> 16;
-charbits(NumOfChars) when is_integer(NumOfChars) ->
- 16 + charbits1(NumOfChars bsr 16).
-
-charbits1(0) ->
- 0;
-charbits1(NumOfChars) ->
- 1 + charbits1(NumOfChars bsr 1).
-
-
-chars_decode(Bytes,_,'BMPString',C,Len) ->
- case get_constraint(C,'PermittedAlphabet') of
- no ->
- getBMPChars(Bytes,Len);
- _ ->
- exit({error,{asn1,
- {'not implemented',
- "BMPString with PermittedAlphabet constraint"}}})
- end;
-chars_decode(Bytes,NumBits,StringType,C,Len) ->
- CharInTab = get_CharInTab(C,StringType),
- chars_decode2(Bytes,CharInTab,NumBits,Len).
-
-
-chars_decode2(Bytes,CharInTab,NumBits,Len) ->
- chars_decode2(Bytes,CharInTab,NumBits,Len,[]).
-
-chars_decode2(Bytes,_CharInTab,_NumBits,0,Acc) ->
- {lists:reverse(Acc),Bytes};
-chars_decode2(Bytes,{Min,Max,notab},NumBits,Len,Acc) when NumBits > 8 ->
- {Char,Bytes2} = getbits(Bytes,NumBits),
- Result =
- if
- Char < 256 -> Char;
- true ->
- list_to_tuple(binary_to_list(<<Char:32>>))
- end,
- chars_decode2(Bytes2,{Min,Max,notab},NumBits,Len -1,[Result|Acc]);
-% chars_decode2(Bytes,{Min,Max,notab},NumBits,Len,Acc) when NumBits > 8 ->
-% {Char,Bytes2} = getbits(Bytes,NumBits),
-% Result = case minimum_octets(Char+Min) of
-% [NewChar] -> NewChar;
-% [C1,C2] -> {0,0,C1,C2};
-% [C1,C2,C3] -> {0,C1,C2,C3};
-% [C1,C2,C3,C4] -> {C1,C2,C3,C4}
-% end,
-% chars_decode2(Bytes2,{Min,Max,notab},NumBits,Len -1,[Result|Acc]);
-chars_decode2(Bytes,{Min,Max,notab},NumBits,Len,Acc) ->
- {Char,Bytes2} = getbits(Bytes,NumBits),
- chars_decode2(Bytes2,{Min,Max,notab},NumBits,Len -1,[Char+Min|Acc]);
-
-%% BMPString and UniversalString with PermittedAlphabet is currently not supported
-chars_decode2(Bytes,{Min,Max,CharInTab},NumBits,Len,Acc) ->
- {Char,Bytes2} = getbits(Bytes,NumBits),
- chars_decode2(Bytes2,{Min,Max,CharInTab},NumBits,Len -1,[element(Char+1,CharInTab)|Acc]).
-
-
-%% UTF8String
-encode_UTF8String(Val) when is_binary(Val) ->
- [encode_length(undefined,size(Val)),{octets,Val}];
-encode_UTF8String(Val) ->
- Bin = list_to_binary(Val),
- encode_UTF8String(Bin).
-
-decode_UTF8String(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {Octs,Bytes3} = getoctets_as_list(Bytes2,Len),
- {list_to_binary(Octs),Bytes3}.
-
-
- % X.691:17
-encode_null(_) -> []. % encodes to nothing
-%encode_null({Name,Val}) when is_atom(Name) ->
-% encode_null(Val).
-
-decode_null(Bytes) ->
- {'NULL',Bytes}.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% encode_object_identifier(Val) -> CompleteList
-%% encode_object_identifier({Name,Val}) -> CompleteList
-%% Val -> {Int1,Int2,...,IntN} % N >= 2
-%% Name -> atom()
-%% Int1 -> integer(0..2)
-%% Int2 -> integer(0..39) when Int1 (0..1) else integer()
-%% Int3-N -> integer()
-%% CompleteList -> [{bits,8,Val}|{octets,Ol}|align|...]
-%%
-encode_object_identifier({Name,Val}) when is_atom(Name) ->
- encode_object_identifier(Val);
-encode_object_identifier(Val) ->
- OctetList = e_object_identifier(Val),
- Octets = list_to_binary(OctetList), % performs a flatten at the same time
- [{debug,object_identifier},encode_length(undefined,size(Octets)),{octets,Octets}].
-
-%% This code is copied from asn1_encode.erl (BER) and corrected and modified
-
-e_object_identifier({'OBJECT IDENTIFIER',V}) ->
- e_object_identifier(V);
-e_object_identifier({Cname,V}) when is_atom(Cname),is_tuple(V) ->
- e_object_identifier(tuple_to_list(V));
-e_object_identifier({Cname,V}) when is_atom(Cname),is_list(V) ->
- e_object_identifier(V);
-e_object_identifier(V) when is_tuple(V) ->
- e_object_identifier(tuple_to_list(V));
-
-%% E1 = 0|1|2 and (E2 < 40 when E1 = 0|1)
-e_object_identifier([E1,E2|Tail]) when E1 >= 0, E1 < 2, E2 < 40 ; E1==2 ->
- Head = 40*E1 + E2, % weird
- e_object_elements([Head|Tail],[]);
-e_object_identifier(Oid=[_,_|_Tail]) ->
- exit({error,{asn1,{'illegal_value',Oid}}}).
-
-e_object_elements([],Acc) ->
- lists:reverse(Acc);
-e_object_elements([H|T],Acc) ->
- e_object_elements(T,[e_object_element(H)|Acc]).
-
-e_object_element(Num) when Num < 128 ->
- [Num];
-e_object_element(Num) ->
- [e_o_e(Num bsr 7)|[Num band 2#1111111]].
-e_o_e(Num) when Num < 128 ->
- Num bor 2#10000000;
-e_o_e(Num) ->
- [e_o_e(Num bsr 7)|[(Num band 2#1111111) bor 2#10000000]].
-
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_object_identifier(Bytes) -> {ObjId,RemainingBytes}
-%% ObjId -> {integer(),integer(),...} % at least 2 integers
-%% RemainingBytes -> [integer()] when integer() (0..255)
-decode_object_identifier(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {Octs,Bytes3} = getoctets_as_list(Bytes2,Len),
- [First|Rest] = dec_subidentifiers(Octs,0,[]),
- Idlist = if
- First < 40 ->
- [0,First|Rest];
- First < 80 ->
- [1,First - 40|Rest];
- true ->
- [2,First - 80|Rest]
- end,
- {list_to_tuple(Idlist),Bytes3}.
-
-dec_subidentifiers([H|T],Av,Al) when H >=16#80 ->
- dec_subidentifiers(T,(Av bsl 7) + (H band 16#7F),Al);
-dec_subidentifiers([H|T],Av,Al) ->
- dec_subidentifiers(T,0,[(Av bsl 7) + H |Al]);
-dec_subidentifiers([],_Av,Al) ->
- lists:reverse(Al).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% encode_relative_oid(Val) -> CompleteList
-%% encode_relative_oid({Name,Val}) -> CompleteList
-encode_relative_oid({Name,Val}) when is_atom(Name) ->
- encode_relative_oid(Val);
-encode_relative_oid(Val) when is_tuple(Val) ->
- encode_relative_oid(tuple_to_list(Val));
-encode_relative_oid(Val) when is_list(Val) ->
- Octets = list_to_binary([e_object_element(X)||X <- Val]),
- [encode_length(undefined,size(Octets)),{octets,Octets}].
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_relative_oid(Val) -> {ROID,Rest}
-%% decode_relative_oid({Name,Val}) -> {ROID,Rest}
-decode_relative_oid(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes,undefined),
- {Octs,Bytes3} = getoctets_as_list(Bytes2,Len),
- ObjVals = dec_subidentifiers(Octs,0,[]),
- {list_to_tuple(ObjVals),Bytes3}.
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% encode_real(Val) -> CompleteList
-%% encode_real({Name,Val}) -> CompleteList
-encode_real({Name,Val}) when is_atom(Name) ->
- encode_real(Val);
-encode_real(Real) ->
- {EncVal,Len} = ?RT_COMMON:encode_real([],Real),
- [encode_length(undefined,Len),{octets,EncVal}].
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% decode_real(Val) -> {REALvalue,Rest}
-%% decode_real({Name,Val}) -> {REALvalue,Rest}
-decode_real(Bytes) ->
- {Len,{0,Bytes2}} = decode_length(Bytes,undefined),
- {RealVal,Rest,Len} = ?RT_COMMON:decode_real(Bytes2,Len),
- {RealVal,{0,Rest}}.
-
-
-get_constraint([{Key,V}],Key) ->
- V;
-get_constraint([],_Key) ->
- no;
-get_constraint(C,Key) ->
- case lists:keysearch(Key,1,C) of
- false ->
- no;
- {value,{_,V}} ->
- V
- end.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% complete(InList) -> ByteList
-%% Takes a coded list with bits and bytes and converts it to a list of bytes
-%% Should be applied as the last step at encode of a complete ASN.1 type
-%%
-
-% complete(L) ->
-% case complete1(L) of
-% {[],0} ->
-% <<0>>;
-% {Acc,0} ->
-% lists:reverse(Acc);
-% {[Hacc|Tacc],Acclen} -> % Acclen >0
-% Rest = 8 - Acclen,
-% NewHacc = Hacc bsl Rest,
-% lists:reverse([NewHacc|Tacc])
-% end.
-
-
-% complete1(InList) when is_list(InList) ->
-% complete1(InList,[]);
-% complete1(InList) ->
-% complete1([InList],[]).
-
-% complete1([{debug,_}|T], Acc) ->
-% complete1(T,Acc);
-% complete1([H|T],Acc) when is_list(H) ->
-% {NewH,NewAcclen} = complete1(H,Acc),
-% complete1(T,NewH,NewAcclen);
-
-% complete1([{0,Bin}|T],Acc,0) when is_binary(Bin) ->
-% complete1(T,[Bin|Acc],0);
-% complete1([{Unused,Bin}|T],Acc,0) when is_integer(Unused),is_binary(Bin) ->
-% Size = size(Bin)-1,
-% <<Bs:Size/binary,B>> = Bin,
-% complete1(T,[(B bsr Unused),Bs|Acc],8-Unused);
-% complete1([{Unused,Bin}|T],[Hacc|Tacc],Acclen) when is_integer(Unused),is_binary(Bin) ->
-% Rest = 8 - Acclen,
-% Used = 8 - Unused,
-% case size(Bin) of
-% 1 ->
-% if
-% Rest >= Used ->
-% <<B:Used,_:Unused>> = Bin,
-% complete1(T,[(Hacc bsl Used) + B|Tacc],
-% (Acclen+Used) rem 8);
-% true ->
-% LeftOver = 8 - Rest - Unused,
-% <<Val2:Rest,Val1:LeftOver,_:Unused>> = Bin,
-% complete1(T,[Val1,(Hacc bsl Rest) + Val2|Tacc],
-% (Acclen+Used) rem 8)
-% end;
-% N ->
-% if
-% Rest == Used ->
-% N1 = N - 1,
-% <<B:Rest,Bs:N1/binary,_:Unused>> = Bin,
-% complete1(T,[Bs,(Hacc bsl Rest) + B|Tacc],0);
-% Rest > Used ->
-% N1 = N - 2,
-% N2 = (8 - Rest) + Used,
-% <<B1:Rest,Bytes:N1/binary,B2:N2,_:Unused>> = Bin,
-% complete1(T,[B2,Bytes,(Hacc bsl Rest) + B1|Tacc],
-% (Acclen + Used) rem 8);
-% true -> % Rest < Used
-% N1 = N - 1,
-% N2 = Used - Rest,
-% <<B1:Rest,Bytes:N1/binary,B2:N2,_:Unused>> = Bin,
-% complete1(T,[B2,Bytes,(Hacc bsl Rest) + B1|Tacc],
-% (Acclen + Used) rem 8)
-% end
-% end;
-
-% %complete1([{octets,N,Val}|T],Acc,Acclen) when N =< 4 ,is_integer(Val) ->
-% % complete1([{octets,<<Val:N/unit:8>>}|T],Acc,Acclen);
-% complete1([{octets,N,Val}|T],Acc,Acclen) when N =< 4 ,is_integer(Val) ->
-% Newval = case N of
-% 1 ->
-% Val4 = Val band 16#FF,
-% [Val4];
-% 2 ->
-% Val3 = (Val bsr 8) band 16#FF,
-% Val4 = Val band 16#FF,
-% [Val3,Val4];
-% 3 ->
-% Val2 = (Val bsr 16) band 16#FF,
-% Val3 = (Val bsr 8) band 16#FF,
-% Val4 = Val band 16#FF,
-% [Val2,Val3,Val4];
-% 4 ->
-% Val1 = (Val bsr 24) band 16#FF,
-% Val2 = (Val bsr 16) band 16#FF,
-% Val3 = (Val bsr 8) band 16#FF,
-% Val4 = Val band 16#FF,
-% [Val1,Val2,Val3,Val4]
-% end,
-% complete1([{octets,Newval}|T],Acc,Acclen);
-
-% complete1([{octets,Bin}|T],Acc,Acclen) when is_binary(Bin) ->
-% Rest = 8 - Acclen,
-% if
-% Rest == 8 ->
-% complete1(T,[Bin|Acc],0);
-% true ->
-% [Hacc|Tacc]=Acc,
-% complete1(T,[Bin, Hacc bsl Rest|Tacc],0)
-% end;
-
-% complete1([{octets,Oct}|T],Acc,Acclen) when is_list(Oct) ->
-% Rest = 8 - Acclen,
-% if
-% Rest == 8 ->
-% complete1(T,[list_to_binary(Oct)|Acc],0);
-% true ->
-% [Hacc|Tacc]=Acc,
-% complete1(T,[list_to_binary(Oct), Hacc bsl Rest|Tacc],0)
-% end;
-
-% complete1([{bit,Val}|T], Acc, Acclen) ->
-% complete1([{bits,1,Val}|T],Acc,Acclen);
-% complete1([{octet,Val}|T], Acc, Acclen) ->
-% complete1([{octets,1,Val}|T],Acc,Acclen);
-
-% complete1([{bits,N,Val}|T], Acc, 0) when N =< 8 ->
-% complete1(T,[Val|Acc],N);
-% complete1([{bits,N,Val}|T], [Hacc|Tacc], Acclen) when N =< 8 ->
-% Rest = 8 - Acclen,
-% if
-% Rest >= N ->
-% complete1(T,[(Hacc bsl N) + Val|Tacc],(Acclen+N) rem 8);
-% true ->
-% Diff = N - Rest,
-% NewHacc = (Hacc bsl Rest) + (Val bsr Diff),
-% Mask = element(Diff,{1,3,7,15,31,63,127,255}),
-% complete1(T,[(Val band Mask),NewHacc|Tacc],(Acclen+N) rem 8)
-% end;
-% complete1([{bits,N,Val}|T], Acc, Acclen) -> % N > 8
-% complete1([{bits,N-8,Val bsr 8},{bits,8,Val band 255}|T],Acc,Acclen);
-
-% complete1([align|T],Acc,0) ->
-% complete1(T,Acc,0);
-% complete1([align|T],[Hacc|Tacc],Acclen) ->
-% Rest = 8 - Acclen,
-% complete1(T,[Hacc bsl Rest|Tacc],0);
-% complete1([{octets,N,Val}|T],Acc,Acclen) when is_list(Val) -> % no security check here
-% complete1([{octets,Val}|T],Acc,Acclen);
-
-% complete1([],Acc,Acclen) ->
-% {Acc,Acclen}.
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% complete(InList) -> ByteList
-%% Takes a coded list with bits and bytes and converts it to a list of bytes
-%% Should be applied as the last step at encode of a complete ASN.1 type
-%%
-
-complete(L) ->
- case complete1(L) of
- {[],[]} ->
- <<0>>;
- {Acc,[]} ->
- Acc;
- {Acc,Bacc} ->
- [Acc|complete_bytes(Bacc)]
- end.
-
-%% this function builds the ugly form of lists [E1|E2] to avoid having to reverse it at the end.
-%% this is done because it is efficient and that the result always will be sent on a port or
-%% converted by means of list_to_binary/1
-complete1(InList) when is_list(InList) ->
- complete1(InList,[],[]);
-complete1(InList) ->
- complete1([InList],[],[]).
-
-complete1([],Acc,Bacc) ->
- {Acc,Bacc};
-complete1([H|T],Acc,Bacc) when is_list(H) ->
- {NewH,NewBacc} = complete1(H,Acc,Bacc),
- complete1(T,NewH,NewBacc);
-
-complete1([{octets,Bin}|T],Acc,[]) ->
- complete1(T,[Acc|Bin],[]);
-
-complete1([{octets,Bin}|T],Acc,Bacc) ->
- complete1(T,[Acc|[complete_bytes(Bacc),Bin]],[]);
-
-complete1([{debug,_}|T], Acc,Bacc) ->
- complete1(T,Acc,Bacc);
-
-complete1([{bits,N,Val}|T],Acc,Bacc) ->
- complete1(T,Acc,complete_update_byte(Bacc,Val,N));
-
-complete1([{bit,Val}|T],Acc,Bacc) ->
- complete1(T,Acc,complete_update_byte(Bacc,Val,1));
-
-complete1([align|T],Acc,[]) ->
- complete1(T,Acc,[]);
-complete1([align|T],Acc,Bacc) ->
- complete1(T,[Acc|complete_bytes(Bacc)],[]);
-complete1([{0,Bin}|T],Acc,[]) when is_binary(Bin) ->
- complete1(T,[Acc|Bin],[]);
-complete1([{Unused,Bin}|T],Acc,[]) when is_integer(Unused),is_binary(Bin) ->
- Size = size(Bin)-1,
- <<Bs:Size/binary,B>> = Bin,
- NumBits = 8-Unused,
- complete1(T,[Acc|Bs],[[B bsr Unused]|NumBits]);
-complete1([{Unused,Bin}|T],Acc,Bacc) when is_integer(Unused),is_binary(Bin) ->
- Size = size(Bin)-1,
- <<Bs:Size/binary,B>> = Bin,
- NumBits = 8 - Unused,
- Bf = complete_bytes(Bacc),
- complete1(T,[Acc|[Bf,Bs]],[[B bsr Unused]|NumBits]).
-
-
-complete_update_byte([],Val,Len) ->
- complete_update_byte([[0]|0],Val,Len);
-complete_update_byte([[Byte|Bacc]|NumBits],Val,Len) when NumBits + Len == 8 ->
- [[0,((Byte bsl Len) + Val) band 255|Bacc]|0];
-complete_update_byte([[Byte|Bacc]|NumBits],Val,Len) when NumBits + Len > 8 ->
- Rem = 8 - NumBits,
- Rest = Len - Rem,
- complete_update_byte([[0,((Byte bsl Rem) + (Val bsr Rest)) band 255 |Bacc]|0],Val,Rest);
-complete_update_byte([[Byte|Bacc]|NumBits],Val,Len) ->
- [[((Byte bsl Len) + Val) band 255|Bacc]|NumBits+Len].
-
-
-complete_bytes([[_Byte|Bacc]|0]) ->
- lists:reverse(Bacc);
-complete_bytes([[Byte|Bacc]|NumBytes]) ->
- lists:reverse([(Byte bsl (8-NumBytes)) band 255|Bacc]);
-complete_bytes([]) ->
- [].
-
-% complete_bytes(L) ->
-% complete_bytes1(lists:reverse(L),[],[],0,0).
-
-% complete_bytes1([H={V,B}|T],Acc,ReplyAcc,NumBits,NumFields) when ((NumBits+B) rem 8) == 0 ->
-% NewReplyAcc = [complete_bytes2([H|Acc],0)|ReplyAcc],
-% complete_bytes1(T,[],NewReplyAcc,0,0);
-% complete_bytes1([H={V,B}|T],Acc,ReplyAcc,NumBits,NumFields) when NumFields == 7; (NumBits+B) div 8 > 0 ->
-% Rem = (NumBits+B) rem 8,
-% NewReplyAcc = [complete_bytes2([{V bsr Rem,B - Rem}|Acc],0)|ReplyAcc],
-% complete_bytes1([{V,Rem}|T],[],NewReplyAcc,0,0);
-% complete_bytes1([H={V,B}|T],Acc,ReplyAcc,NumBits,NumFields) ->
-% complete_bytes1(T,[H|Acc],ReplyAcc,NumBits+B,NumFields+1);
-% complete_bytes1([],[],ReplyAcc,_,_) ->
-% lists:reverse(ReplyAcc);
-% complete_bytes1([],Acc,ReplyAcc,NumBits,_) ->
-% PadBits = case NumBits rem 8 of
-% 0 -> 0;
-% Rem -> 8 - Rem
-% end,
-% lists:reverse([complete_bytes2(Acc,PadBits)|ReplyAcc]).
-
-
-% complete_bytes2([{V1,B1}],PadBits) ->
-% <<V1:B1,0:PadBits>>;
-% complete_bytes2([{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,0:PadBits>>;
-% complete_bytes2([{V3,B3},{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,V3:B3,0:PadBits>>;
-% complete_bytes2([{V4,B4},{V3,B3},{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,V3:B3,V4:B4,0:PadBits>>;
-% complete_bytes2([{V5,B5},{V4,B4},{V3,B3},{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,V3:B3,V4:B4,V5:B5,0:PadBits>>;
-% complete_bytes2([{V6,B6},{V5,B5},{V4,B4},{V3,B3},{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,V3:B3,V4:B4,V5:B5,V6:B6,0:PadBits>>;
-% complete_bytes2([{V7,B7},{V6,B6},{V5,B5},{V4,B4},{V3,B3},{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,V3:B3,V4:B4,V5:B5,V6:B6,V7:B7,0:PadBits>>;
-% complete_bytes2([{V8,B8},{V7,B7},{V6,B6},{V5,B5},{V4,B4},{V3,B3},{V2,B2},{V1,B1}],PadBits) ->
-% <<V1:B1,V2:B2,V3:B3,V4:B4,V5:B5,V6:B6,V7:B7,V8:B8,0:PadBits>>.
-
-
-
-
-
-
diff --git a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
index 1df757a47f..01e1cb23d7 100644
--- a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
+++ b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
@@ -22,7 +22,7 @@
-include("asn1_records.hrl").
--export([dec_fixup/3, cindex/3, list_to_record/2]).
+-export([dec_fixup/3]).
-export([setchoiceext/1, setext/1, fixoptionals/3, fixextensions/2,
getext/1, getextension/2, skipextensions/3, getbit/1, getchoice/3 ]).
-export([getoptionals/2, getoptionals2/2,
@@ -87,18 +87,6 @@ dec_fixup([H|T],[Hc|Tc],RemBytes,Acc) ->
dec_fixup([],_Cnames,RemBytes,Acc) ->
{lists:reverse(Acc),RemBytes}.
-cindex(Ix,Val,Cname) ->
- case element(Ix,Val) of
- {Cname,Val2} -> Val2;
- X -> X
- end.
-
-%% converts a list to a record if necessary
-list_to_record(_,Tuple) when is_tuple(Tuple) ->
- Tuple;
-list_to_record(Name,List) when is_list(List) ->
- list_to_tuple([Name|List]).
-
%%--------------------------------------------------------
%% setchoiceext(InRootSet) -> [{bit,X}]
%% X is set to 1 when InRootSet==false
@@ -609,7 +597,7 @@ encode_constrained_number({Lb,Ub},Val) when Val >= Lb, Ub >= Val ->
RangeOcts = binary:encode_unsigned(Range - 1),
OctsLen = erlang:byte_size(Octs),
RangeOctsLen = erlang:byte_size(RangeOcts),
- LengthBitsNeeded = asn1rt_per_bin:minimum_bits(RangeOctsLen - 1),
+ LengthBitsNeeded = minimum_bits(RangeOctsLen - 1),
[10,LengthBitsNeeded,OctsLen-1,20,OctsLen,Octs];
true ->
exit({not_supported,{integer_range,Range}})
@@ -665,6 +653,16 @@ decode_constrained_number(Buffer,{Lb,_Ub},Range) ->
end,
{Val+Lb,Remain}.
+%% For some reason the minimum bits needed in the length field in
+%% the encoding of constrained whole numbers must always be at least 2?
+minimum_bits(N) when N < 4 -> 2;
+minimum_bits(N) when N < 8 -> 3;
+minimum_bits(N) when N < 16 -> 4;
+minimum_bits(N) when N < 32 -> 5;
+minimum_bits(N) when N < 64 -> 6;
+minimum_bits(N) when N < 128 -> 7;
+minimum_bits(_N) -> 8.
+
%% X.691:10.8 Encoding of an unconstrained whole number
encode_unconstrained_number(Val) when Val >= 0 ->
diff --git a/lib/asn1/src/asn1rt_uper_bin.erl b/lib/asn1/src/asn1rt_uper_bin.erl
index abe178a69e..e1f96416a9 100644
--- a/lib/asn1/src/asn1rt_uper_bin.erl
+++ b/lib/asn1/src/asn1rt_uper_bin.erl
@@ -25,7 +25,6 @@
%%-compile(export_all).
- -export([cindex/3, list_to_record/2]).
-export([setext/1, fixoptionals/3,
fixextensions/2,
getext/1, getextension/2, skipextensions/3, getbit/1, getchoice/3 ]).
@@ -65,19 +64,6 @@
-define('64K',65536).
-cindex(Ix,Val,Cname) ->
- case element(Ix,Val) of
- {Cname,Val2} -> Val2;
- X -> X
- end.
-
-%% converts a list to a record if necessary
-list_to_record(_Name,Tuple) when is_tuple(Tuple) ->
- Tuple;
-list_to_record(Name,List) when is_list(List) ->
- list_to_tuple([Name|List]).
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% setext(true|false) -> CompleteList
%%
diff --git a/lib/asn1/test/Makefile b/lib/asn1/test/Makefile
index 6e6374baf1..1794d6bb71 100644
--- a/lib/asn1/test/Makefile
+++ b/lib/asn1/test/Makefile
@@ -83,6 +83,7 @@ MODULES= \
testInfObj \
testParameterizedInfObj \
testMergeCompile \
+ testMultipleLevels \
testDeepTConstr \
testTimer \
testMegaco \
diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl
index 79c7bf1476..fd5ea15323 100644
--- a/lib/asn1/test/asn1_SUITE.erl
+++ b/lib/asn1/test/asn1_SUITE.erl
@@ -21,27 +21,17 @@
-module(asn1_SUITE).
-define(only_per(Func),
- if Rule == per orelse Rule == per_bin -> Func;
- true -> ok
+ if Rule =:= per -> Func;
+ true -> ok
end).
-define(only_ber(Func),
- if Rule == ber orelse Rule == ber_bin orelse Rule == ber_bin_v2 -> Func;
- true -> ok
+ if Rule =:= ber -> Func;
+ true -> ok
end).
-define(only_uper(Func),
case Rule of
- uper_bin -> Func;
- _ -> ok
- end).
--define(only_per_nif(Func),
- case {Rule, lists:member(optimize, Opts)} of
- {per_bin, true} -> Func;
- _ -> ok
- end).
--define(only_ber_nif(Func),
- case {Rule, lists:member(nif, Opts)} of
- {ber_bin_v2, true} -> Func;
- _ -> ok
+ uper -> Func;
+ _ -> ok
end).
-compile(export_all).
@@ -55,7 +45,8 @@
suite() -> [{ct_hooks, [ts_install_cth]}].
all() ->
- [{group, parallel},
+ [{group, compile},
+ {group, parallel},
{group, app_test},
{group, appup_test},
@@ -76,16 +67,14 @@ groups() ->
{ber, parallel([]),
[ber_choiceinseq,
% Uses 'SOpttest'
- {group, [], [ber_optional,
- ber_optional_keyed_list]}]},
+ ber_optional]},
{app_test, [], [{asn1_app_test, all}]},
{appup_test, [], [{asn1_appup_test, all}]},
{parallel, parallel([]),
- [{group, compile},
- {group, ber},
+ [{group, ber},
% Uses 'P-Record', 'Constraints', 'MEDIA-GATEWAY-CONTROL'...
{group, [], [parse,
test_driver_load,
@@ -116,6 +105,7 @@ groups() ->
testChoTypeRefPrim,
testChoTypeRefSeq,
testChoTypeRefSet,
+ testMultipleLevels,
testDef,
testOpt,
testSeqDefault,
@@ -203,13 +193,8 @@ groups() ->
{performance, [],
[testTimer_ber,
- testTimer_ber_bin,
- testTimer_ber_bin_opt,
- testTimer_ber_bin_opt_driver,
testTimer_per,
- testTimer_per_bin,
- testTimer_per_bin_opt,
- testTimer_uper_bin,
+ testTimer_uper,
smp]}].
parallel(Options) ->
@@ -257,14 +242,8 @@ end_per_testcase(_Func, Config) ->
test(Config, TestF) ->
test(Config, TestF, [per,
- per_bin,
- {per_bin, [optimize]},
- uper_bin,
- ber,
- ber_bin,
- ber_bin_v2,
- % TODO: {ber_bin_v2, [optimize, nif]} ?
- {ber_bin_v2, [nif]}]).
+ uper,
+ ber]).
test(Config, TestF, Rules) ->
Fun = fun(C, R, O) ->
@@ -344,10 +323,10 @@ testCompactBitString(Config, Rule, Opts) ->
testCompactBitString:compact_bit_string(Rule),
?only_uper(testCompactBitString:bit_string_unnamed(Rule)),
?only_per(testCompactBitString:bit_string_unnamed(Rule)),
- ?only_per_nif(testCompactBitString:ticket_7734(Rule)),
- ?only_per_nif(asn1_test_lib:compile("Constraints", Config,
+ ?only_per(testCompactBitString:ticket_7734(Rule)),
+ ?only_per(asn1_test_lib:compile("Constraints", Config,
[Rule, compact_bit_string|Opts])),
- ?only_per_nif(testCompactBitString:otp_4869(Rule)).
+ ?only_per(testCompactBitString:otp_4869(Rule)).
testPrimStrings(Config) -> test(Config, fun testPrimStrings/3).
testPrimStrings(Config, Rule, Opts) ->
@@ -371,10 +350,10 @@ testPrimExternal(Config, Rule, Opts) ->
asn1_test_lib:compile_all(["External", "PrimExternal"], Config,
[Rule|Opts]),
testPrimExternal:external(Rule),
- ?only_ber_nif(asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config,
+ ?only_ber(asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config,
[Rule|Opts])),
- ?only_ber_nif(testPrimStrings_cases(Rule)),
- ?only_ber_nif(testPrimStrings:more_strings(Rule)).
+ ?only_ber(testPrimStrings_cases(Rule)),
+ ?only_ber(testPrimStrings:more_strings(Rule)).
testChoPrim(Config) -> test(Config, fun testChoPrim/3).
testChoPrim(Config, Rule, Opts) ->
@@ -399,7 +378,7 @@ testChoOptional(Config, Rule, Opts) ->
testChoOptionalImplicitTag(Config) ->
test(Config, fun testChoOptionalImplicitTag/3,
- [ber, ber_bin, ber_bin_v2]).
+ [ber]).
testChoOptionalImplicitTag(Config, Rule, Opts) ->
%% Only meaningful for ber & co
asn1_test_lib:compile("ChoOptionalImplicitTag", Config, [Rule|Opts]),
@@ -430,6 +409,11 @@ testChoTypeRefSet(Config, Rule, Opts) ->
asn1_test_lib:compile("ChoTypeRefSet", Config, [Rule|Opts]),
testChoTypeRefSet:set(Rule).
+testMultipleLevels(Config) -> test(Config, fun testMultipleLevels/3).
+testMultipleLevels(Config, Rule, Opts) ->
+ asn1_test_lib:compile("MultipleLevels", Config, [Rule|Opts]),
+ testMultipleLevels:main(Rule).
+
testDef(Config) -> test(Config, fun testDef/3).
testDef(Config, Rule, Opts) ->
asn1_test_lib:compile("Def", Config, [Rule|Opts]),
@@ -515,8 +499,7 @@ testSeqOfCho(Config, Rule, Opts) ->
testSeqOfCho:main(Rule).
testSeqOfIndefinite(Config) ->
- test(Config, fun testSeqOfIndefinite/3,
- [ber, ber_bin, ber_bin_v2, {ber_bin_v2, [nif]}]).
+ test(Config, fun testSeqOfIndefinite/3, [ber]).
testSeqOfIndefinite(Config, Rule, Opts) ->
Files = ["Mvrasn-Constants-1", "Mvrasn-DataTypes-1", "Mvrasn-21-4",
"Mvrasn-20-4", "Mvrasn-19-4", "Mvrasn-18-4", "Mvrasn-17-4",
@@ -632,13 +615,12 @@ c_syntax(Config) ->
"SeqBadComma"]].
c_string(Config) ->
- test(Config, fun c_string/3, [per, per_bin, ber, ber_bin, ber_bin_v2]).
+ test(Config, fun c_string/3, [per, ber]).
c_string(Config, Rule, Opts) ->
asn1_test_lib:compile("String", Config, [Rule|Opts]).
c_implicit_before_choice(Config) ->
- test(Config, fun c_implicit_before_choice/3,
- [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun c_implicit_before_choice/3, [ber]).
c_implicit_before_choice(Config, Rule, Opts) ->
DataDir = ?config(data_dir, Config),
CaseDir = ?config(case_dir, Config),
@@ -649,12 +631,13 @@ parse(Config) ->
[asn1_test_lib:compile(M, Config, [abs]) || M <- test_modules()].
per(Config) ->
- test(Config, fun per/3, [per, per_bin, {per_bin, [optimize]}]).
+ test(Config, fun per/3, [per]).
per(Config, Rule, Opts) ->
[module_test(M, Config, Rule, Opts) || M <- per_modules()].
ber_other(Config) ->
- test(Config, fun ber_other/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun ber_other/3, [ber]).
+
ber_other(Config, Rule, Opts) ->
[module_test(M, Config, Rule, Opts) || M <- ber_modules()].
@@ -669,12 +652,12 @@ module_test(M, Config, Rule, Opts) ->
ber_choiceinseq(Config) ->
- test(Config, fun ber_choiceinseq/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun ber_choiceinseq/3, [ber]).
ber_choiceinseq(Config, Rule, Opts) ->
asn1_test_lib:compile("ChoiceInSeq", Config, [Rule|Opts]).
ber_optional(Config) ->
- test(Config, fun ber_optional/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun ber_optional/3, [ber]).
ber_optional(Config, Rule, Opts) ->
asn1_test_lib:compile("SOpttest", Config, [Rule|Opts]),
V = {'S', {'A', 10, asn1_NOVALUE, asn1_NOVALUE},
@@ -685,21 +668,6 @@ ber_optional(Config, Rule, Opts) ->
V2 = asn1_wrapper:decode('SOpttest', 'S', Bytes),
V = element(2, V2).
-ber_optional_keyed_list(Config) ->
- test(Config, fun ber_optional_keyed_list/3, [ber, ber_bin]).
-ber_optional_keyed_list(Config, Rule, Opts) ->
- asn1_test_lib:compile("SOpttest", Config, [Rule, keyed_list|Opts]),
- Vrecord = {'S', {'A', 10, asn1_NOVALUE, asn1_NOVALUE},
- {'B', asn1_NOVALUE, asn1_NOVALUE, asn1_NOVALUE},
- {'C', asn1_NOVALUE, 111, asn1_NOVALUE}},
- V = [{a, [{scriptKey, 10}]},
- {b, []},
- {c, [{callingPartysCategory, 111}]}],
- {ok, B} = asn1_wrapper:encode('SOpttest', 'S', V),
- Bytes = lists:flatten(B),
- V2 = asn1_wrapper:decode('SOpttest', 'S', Bytes),
- Vrecord = element(2, V2).
-
%% records used by test-case default
-record('Def1', {bool0,
bool1 = asn1_DEFAULT,
@@ -734,7 +702,7 @@ value_bad_enum_test(Config) ->
end.
constructed(Config) ->
- test(Config, fun constructed/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun constructed/3, [ber]).
constructed(Config, Rule, Opts) ->
asn1_test_lib:compile("Constructed", Config, [Rule|Opts]),
{ok, B} = asn1_wrapper:encode('Constructed', 'S', {'S', false}),
@@ -745,7 +713,7 @@ constructed(Config, Rule, Opts) ->
[136, 1, 10] = lists:flatten(B2).
ber_decode_error(Config) ->
- test(Config, fun ber_decode_error/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun ber_decode_error/3, [ber]).
ber_decode_error(Config, Rule, Opts) ->
asn1_test_lib:compile("Constructed", Config, [Rule|Opts]),
ber_decode_error:run(Opts).
@@ -758,14 +726,14 @@ h323test(Config, Rule, Opts) ->
h323test:run(Rule).
per_GeneralString(Config) ->
- test(Config, fun per_GeneralString/3, [per, per_bin]).
+ test(Config, fun per_GeneralString/3, [per]).
per_GeneralString(Config, Rule, Opts) ->
asn1_test_lib:compile("MULTIMEDIA-SYSTEM-CONTROL", Config, [Rule|Opts]),
UI = [109, 64, 1, 57],
{ok, _V} = asn1_wrapper:decode('MULTIMEDIA-SYSTEM-CONTROL',
'MultimediaSystemControlMessage', UI).
-per_open_type(Config) -> test(Config, fun per_open_type/3, [per, per_bin]).
+per_open_type(Config) -> test(Config, fun per_open_type/3, [per]).
per_open_type(Config, Rule, Opts) ->
asn1_test_lib:compile("OpenType", Config, [Rule|Opts]),
{ok, _} = asn1ct:test('OpenType', 'Ot', {'Stype', 10, true}).
@@ -778,24 +746,24 @@ testConstraints(Config, Rule, Opts) ->
testSeqIndefinite(Config) ->
- test(Config, fun testSeqIndefinite/3, [ber, ber_bin, ber_bin_v2,
- {ber_bin_v2, [nif]}]).
+ test(Config, fun testSeqIndefinite/3, [ber]).
+
testSeqIndefinite(Config, Rule, Opts) ->
asn1_test_lib:compile("SeqSetIndefinite", Config, [Rule|Opts]),
testSeqIndefinite:main(Rule).
testSetIndefinite(Config) ->
- test(Config, fun testSetIndefinite/3, [ber, ber_bin, ber_bin_v2,
- {ber_bin_v2, [nif]}]).
+ test(Config, fun testSetIndefinite/3, [ber]).
+
testSetIndefinite(Config, Rule, Opts) ->
asn1_test_lib:compile("SeqSetIndefinite", Config, [Rule|Opts]),
testSetIndefinite:main(Rule).
testChoiceIndefinite(Config) ->
- test(Config, fun testChoiceIndefinite/3, [ber, ber_bin, ber_bin_v2,
- {ber_bin_v2, [nif]}]).
+ test(Config, fun testChoiceIndefinite/3, [ber]).
+
testChoiceIndefinite(Config, Rule, Opts) ->
asn1_test_lib:compile("ChoiceIndef", Config, [Rule|Opts]),
testChoiceIndefinite:main(Rule).
@@ -857,7 +825,7 @@ testExport(Config) ->
end.
testImport(Config) ->
- test(Config, fun testImport/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun testImport/3, [ber]).
testImport(Config, Rule, Opts) ->
{error, _} = asn1ct:compile(filename:join(?config(data_dir, Config),
"ImportsFrom"),
@@ -906,8 +874,7 @@ duplicate_tags(Config) ->
{skip, "Runs in asn1_SUITE only"}
end.
-rtUI(Config) -> test(Config, fun rtUI/3, [per, per_bin, ber,
- ber_bin, ber_bin_v2]).
+rtUI(Config) -> test(Config, fun rtUI/3, [per,ber]).
rtUI(Config, Rule, Opts) ->
asn1_test_lib:compile("Prim", Config, [Rule|Opts]),
{ok, _} = asn1rt:info('Prim').
@@ -923,19 +890,19 @@ testINSTANCE_OF(Config, Rule, Opts) ->
testINSTANCE_OF:main(Rule).
testTCAP(Config) ->
- test(Config, fun testTCAP/3,
- [ber, ber_bin, ber_bin_v2, {ber_bin_v2, [nif]}]).
+ test(Config, fun testTCAP/3, [ber]).
testTCAP(Config, Rule, Opts) ->
testTCAP:compile(Config, [Rule|Opts]),
testTCAP:test(Rule, Config),
case Rule of
- ber_bin_v2 -> testTCAP:compile_asn1config(Config, [Rule, asn1config]),
- testTCAP:test_asn1config();
- _ -> ok
+ ber ->
+ testTCAP:compile_asn1config(Config, [Rule, asn1config]),
+ testTCAP:test_asn1config();
+ _ -> ok
end.
testDER(Config) ->
- test(Config, fun testDER/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun testDER/3, [ber]).
testDER(Config, Rule, Opts) ->
asn1_test_lib:compile("DERSpec", Config, [Rule, der|Opts]),
testDER:test(),
@@ -945,7 +912,7 @@ testDER(Config, Rule, Opts) ->
testSeqSetDefaultVal:main(Rule).
specialized_decodes(Config) ->
- test(Config, fun specialized_decodes/3, [ber_bin_v2]).
+ test(Config, fun specialized_decodes/3, [ber]).
specialized_decodes(Config, Rule, Opts) ->
asn1_test_lib:compile_all(["PartialDecSeq.asn",
"PartialDecSeq2.asn",
@@ -953,13 +920,12 @@ specialized_decodes(Config, Rule, Opts) ->
"PartialDecMyHTTP.asn",
"MEDIA-GATEWAY-CONTROL.asn",
"P-Record"],
- Config, [Rule, optimize, asn1config|Opts]),
+ Config, [Rule, asn1config|Opts]),
test_partial_incomplete_decode:test(Config),
test_selective_decode:test().
special_decode_performance(Config) ->
- test(Config, fun special_decode_performance/3,
- [{ber_bin, [optimize]}, {ber_bin_v2, [optimize, nif]}]).
+ test(Config, fun special_decode_performance/3, [ber]).
special_decode_performance(Config, Rule, Opts) ->
Files = ["MEDIA-GATEWAY-CONTROL", "PartialDecSeq"],
asn1_test_lib:compile_all(Files, Config, [Rule, asn1config|Opts]),
@@ -967,19 +933,19 @@ special_decode_performance(Config, Rule, Opts) ->
test_driver_load(Config) ->
- test(Config, fun test_driver_load/3, [{per_bin, [optimize]}]).
+ test(Config, fun test_driver_load/3, [per]).
test_driver_load(Config, Rule, Opts) ->
asn1_test_lib:compile("P-Record", Config, [Rule|Opts]),
test_driver_load:test(5).
test_ParamTypeInfObj(Config) ->
- asn1_test_lib:compile("IN-CS-1-Datatypes", Config, [ber_bin]).
+ asn1_test_lib:compile("IN-CS-1-Datatypes", Config, [ber]).
test_WS_ParamClass(Config) ->
- asn1_test_lib:compile("InformationFramework", Config, [ber_bin]).
+ asn1_test_lib:compile("InformationFramework", Config, [ber]).
test_Defed_ObjectIdentifier(Config) ->
- asn1_test_lib:compile("UsefulDefinitions", Config, [ber_bin]).
+ asn1_test_lib:compile("UsefulDefinitions", Config, [ber]).
testSelectionType(Config) -> test(Config, fun testSelectionType/3).
testSelectionType(Config, Rule, Opts) ->
@@ -987,7 +953,7 @@ testSelectionType(Config, Rule, Opts) ->
{ok, _} = testSelectionTypes:test().
testSSLspecs(Config) ->
- test(Config, fun testSSLspecs/3, [ber, ber_bin, ber_bin_v2, {ber_bin_v2, [optimize]}]).
+ test(Config, fun testSSLspecs/3, [ber]).
testSSLspecs(Config, Rule, Opts) ->
ok = testSSLspecs:compile(Config,
[Rule, compact_bit_string, der|Opts]),
@@ -1011,12 +977,12 @@ test_undecoded_rest(Config, Rule, Opts) ->
ok = test_undecoded_rest:test([], Config),
asn1_test_lib:compile("P-Record", Config, [Rule,undec_rest|Opts]),
case Rule of
- ber_bin_v2 -> ok;
+ ber -> ok;
_ -> test_undecoded_rest:test(undec_rest, Config)
end.
test_inline(Config) ->
- test(Config, fun test_inline/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun test_inline/3, [ber]).
test_inline(Config, Rule, Opts) ->
case code:which(asn1ct) of
cover_compiled ->
@@ -1029,12 +995,11 @@ test_inline(Config, Rule, Opts) ->
end.
testTcapsystem(Config) ->
- test(Config, fun testTcapsystem/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun testTcapsystem/3, [ber]).
testTcapsystem(Config, Rule, Opts) ->
testTcapsystem:compile(Config, [Rule|Opts]).
-testNBAPsystem(Config) -> test(Config, fun testNBAPsystem/3,
- [per, per_bin, {per_bin, [optimize]}]).
+testNBAPsystem(Config) -> test(Config, fun testNBAPsystem/3, [per]).
testNBAPsystem(Config, Rule, Opts) ->
testNBAPsystem:compile(Config, [Rule|Opts]),
testNBAPsystem:test(Rule, Config).
@@ -1068,20 +1033,19 @@ test_modified_x420(Config) ->
testX420() ->
[{timetrap,{minutes,90}}].
testX420(Config) ->
- test(Config, fun testX420/3, [ber, ber_bin, ber_bin_v2]).
+ test(Config, fun testX420/3, [ber]).
testX420(Config, Rule, Opts) ->
testX420:compile(Rule, [der|Opts], Config),
ok = testX420:ticket7759(Rule, Config),
testX420:compile(Rule, Opts, Config).
test_x691(Config) ->
- test(Config, fun test_x691/3,
- [per, per_bin, uper_bin, {per_bin, [optimize]}]).
+ test(Config, fun test_x691/3, [per, uper]).
test_x691(Config, Rule, Opts) ->
Files = ["P-RecordA1", "P-RecordA2", "P-RecordA3"],
asn1_test_lib:compile_all(Files, Config, [Rule|Opts]),
test_x691:cases(Rule, case Rule of
- uper_bin -> unaligned;
+ uper -> unaligned;
_ -> aligned
end),
asn1_test_lib:ticket_7708(Config, []),
@@ -1092,8 +1056,7 @@ ticket_6143(Config) ->
testExtensionAdditionGroup(Config) ->
%% FIXME problems with automatic tags [ber_bin], [ber_bin, optimize]
- test(Config, fun testExtensionAdditionGroup/3,
- [per_bin, {per_bin, [optimize]}, uper_bin]).
+ test(Config, fun testExtensionAdditionGroup/3, [per, uper]).
testExtensionAdditionGroup(Config, Rule, Opts) ->
asn1_test_lib:compile("Extension-Addition-Group", Config, [Rule|Opts]),
asn1_test_lib:compile_erlang("extensionAdditionGroup", Config,
@@ -1182,46 +1145,17 @@ timer_compile(Config, Rule, Opts) ->
asn1_test_lib:compile_all(["H235-SECURITY-MESSAGES", "H323-MESSAGES"],
Config, [Rule|Opts]).
-testTimer_ber(suite) -> [];
testTimer_ber(Config) ->
timer_compile(Config,ber,[]),
testTimer:go(Config,ber).
-testTimer_ber_bin(suite) -> [];
-testTimer_ber_bin(Config) ->
- timer_compile(Config,ber_bin,[]),
- testTimer:go(Config,ber_bin).
-
-testTimer_ber_bin_opt(suite) -> [];
-testTimer_ber_bin_opt(Config) ->
- timer_compile(Config,ber_bin,[optimize]),
- testTimer:go(Config,ber_bin).
-
-testTimer_ber_bin_opt_driver(suite) -> [];
-testTimer_ber_bin_opt_driver(Config) ->
- timer_compile(Config,ber_bin,[optimize,driver]),
- testTimer:go(Config,ber_bin).
-
-testTimer_per(suite) -> [];
testTimer_per(Config) ->
timer_compile(Config,per,[]),
testTimer:go(Config,per).
-testTimer_per_bin(suite) -> [];
-testTimer_per_bin(Config) ->
- timer_compile(Config,per_bin,[]),
- testTimer:go(Config,per_bin).
-
-testTimer_per_bin_opt(suite) -> [];
-testTimer_per_bin_opt(Config) ->
- timer_compile(Config,per_bin,[optimize]),
- testTimer:go(Config,per_bin).
-
-
-testTimer_uper_bin(suite) -> [];
-testTimer_uper_bin(Config) ->
- timer_compile(Config,uper_bin,[]),
- {comment,_} = testTimer:go(Config,uper_bin).
+testTimer_uper(Config) ->
+ timer_compile(Config,uper,[]),
+ {comment,_} = testTimer:go(Config,uper).
%% Test of multiple-line comment, OTP-8043
testComment(suite) -> [];
@@ -1264,11 +1198,11 @@ testName2Number(Config) ->
ok.
ticket_7407(Config) ->
- asn1_test_lib:compile("EUTRA-extract-7407", Config, [uper_bin]),
+ asn1_test_lib:compile("EUTRA-extract-7407", Config, [uper]),
asn1_test_lib:ticket_7407_code(true),
asn1_test_lib:compile("EUTRA-extract-7407", Config,
- [uper_bin, no_final_padding]),
+ [uper, no_final_padding]),
asn1_test_lib:ticket_7407_code(false).
smp(suite) -> [];
@@ -1279,7 +1213,7 @@ smp(Config) ->
io:format("smp starting ~p workers\n",[NumOfProcs]),
Msg = {initiatingMessage, testNBAPsystem:cell_setup_req_msg()},
- ok = testNBAPsystem:compile(Config, [per_bin, optimize]),
+ ok = testNBAPsystem:compile(Config, [per]),
enc_dec(NumOfProcs,Msg,2),
@@ -1288,7 +1222,7 @@ smp(Config) ->
{Time1,ok} = timer:tc(?MODULE,enc_dec,[NumOfProcs,Msg, N]),
{Time1S,ok} = timer:tc(?MODULE,enc_dec,[1, Msg, NumOfProcs * N]),
- ok = testNBAPsystem:compile(Config, [ber_bin, optimize, nif]),
+ ok = testNBAPsystem:compile(Config, [ber]),
{Time3,ok} = timer:tc(?MODULE,enc_dec,[NumOfProcs,Msg, N]),
{Time3S,ok} = timer:tc(?MODULE,enc_dec,[1, Msg, NumOfProcs * N]),
@@ -1309,10 +1243,8 @@ per_performance(Config) ->
file:make_dir(NifDir),file:make_dir(ErlDir),
Msg = {initiatingMessage, testNBAPsystem:cell_setup_req_msg()},
- ok = testNBAPsystem:compile([{priv_dir,NifDir}|Config],
- [per_bin, optimize]),
- ok = testNBAPsystem:compile([{priv_dir,ErlDir}|Config],
- [per_bin]),
+ ok = testNBAPsystem:compile([{priv_dir,NifDir}|Config], [per]),
+ ok = testNBAPsystem:compile([{priv_dir,ErlDir}|Config], [per]),
Modules = ['NBAP-CommonDataTypes',
'NBAP-Constants',
@@ -1350,7 +1282,7 @@ per_performance(Config) ->
ber_performance(Config) ->
Msg = {initiatingMessage, testNBAPsystem:cell_setup_req_msg()},
- ok = testNBAPsystem:compile(Config, [ber_bin, optimize, nif]),
+ ok = testNBAPsystem:compile(Config, [ber]),
BerFun = fun() ->
@@ -1524,7 +1456,7 @@ pforeach(_Fun,[],[]) ->
-record('Iu-ReleaseCommand',{first,second}).
ticket7904(Config) ->
- asn1_test_lib:compile("RANAPextract1", Config, [per_bin, optimize]),
+ asn1_test_lib:compile("RANAPextract1", Config, [per]),
Val1 = #'InitiatingMessage'{procedureCode=1,
criticality=ignore,
diff --git a/lib/asn1/test/asn1_SUITE_data/MultipleLevels.asn b/lib/asn1/test/asn1_SUITE_data/MultipleLevels.asn
new file mode 100644
index 0000000000..1824e1fa5a
--- /dev/null
+++ b/lib/asn1/test/asn1_SUITE_data/MultipleLevels.asn
@@ -0,0 +1,19 @@
+MultipleLevels DEFINITIONS AUTOMATIC TAGS ::=
+
+BEGIN
+
+Top ::= SEQUENCE {
+ country CountryName,
+ region Name
+}
+
+CountryName ::= CountryName0
+
+CountryName0 ::= Name
+
+Name ::= CHOICE {
+ short PrintableString (SIZE (0..10)),
+ long PrintableString
+}
+
+END
diff --git a/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config b/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config
index 19fa3c990e..d388f6cd02 100644
--- a/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config
+++ b/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config
@@ -17,6 +17,6 @@
{decode_D_incomplete,['D',[{a,undecoded}]]},
{decode_F_fb_exclusive2,['F',[{fb,[{b,parts},{d,[{da,parts}]}]}]]}, {decode_F_fb_exclusive3,['F',[{fb,[{b,parts},{d,[{da,parts},{dc,[{dcc,undecoded}]}]}]}]]}]}}.
{module_name,'Seq.asn1'}.
-{compile_options,[ber_bin,optimize,debug_info]}.
+{compile_options,[ber,debug_info]}.
{multifile_compile,['M1.asn','M2.asn']}.
diff --git a/lib/asn1/test/asn1_SUITE_data/testobj.erl b/lib/asn1/test/asn1_SUITE_data/testobj.erl
index be7ceee7d1..80942f7e38 100644
--- a/lib/asn1/test/asn1_SUITE_data/testobj.erl
+++ b/lib/asn1/test/asn1_SUITE_data/testobj.erl
@@ -1420,24 +1420,7 @@ wrapper_encode(Module,Type,Value) ->
Error
end.
-wrapper_decode(Module,Type,Bytes) ->
- case Module:encoding_rule() of
- ber ->
- asn1rt:decode(Module,Type,Bytes);
- ber_bin when binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- ber_bin ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes));
- ber_bin_v2 when binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- ber_bin_v2 ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes));
- per ->
- asn1rt:decode(Module,Type,Bytes);
- per_bin when binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- per_bin ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes));
- uper_bin ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes))
- end.
+wrapper_decode(Module, Type, Bytes) when is_binary(Bytes) ->
+ asn1rt:decode(Module, Type, Bytes);
+wrapper_decode(Module, Type, Bytes) when is_list(Bytes) ->
+ asn1rt:decode(Module, Type, list_to_binary(Bytes)).
diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl
index 96c04a9436..fda635d0eb 100644
--- a/lib/asn1/test/asn1_test_lib.erl
+++ b/lib/asn1/test/asn1_test_lib.erl
@@ -87,14 +87,14 @@ ticket_7407_compile(Config,Option) ->
?line OutDir = ?config(priv_dir,Config),
?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-7407",
- [uper_bin, {outdir,OutDir}]++Option).
+ [uper, {outdir,OutDir}]++Option).
ticket_7708(Config,Option) ->
?line DataDir = ?config(data_dir,Config),
?line OutDir = ?config(priv_dir,Config),
?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-55",
- [uper_bin, {outdir,OutDir}]++Option).
+ [uper, {outdir,OutDir}]++Option).
ticket_7407_code(FinalPadding) ->
@@ -154,7 +154,7 @@ ticket_7678(Config, Option) ->
?line OutDir = ?config(priv_dir,Config),
?line ok = asn1ct:compile(DataDir ++ "UPERDefault",
- [uper_bin, {outdir,OutDir}]++Option),
+ [uper, {outdir,OutDir}]++Option),
?line Val = 'UPERDefault':seq(),
?line {ok,<<0,6,0>>} = 'UPERDefault':encode('Seq',Val),
@@ -167,12 +167,12 @@ ticket_7763(Config) ->
?line OutDir = ?config(priv_dir,Config),
?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-55",
- [uper_bin, {outdir,OutDir}]),
+ [uper, {outdir,OutDir}]),
Val = {'Seq',15,lists:duplicate(8,0),[0],lists:duplicate(28,0),15,true},
?line {ok,Bin} = 'EUTRA-extract-55':encode('Seq',Val),
?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-55",
- [uper_bin,compact_bit_string,{outdir,OutDir}]),
+ [uper,compact_bit_string,{outdir,OutDir}]),
CompactVal = {'Seq',15,{0,<<0>>},{7,<<0>>},{4,<<0,0,0,0>>},15,true},
{ok,CompactBin} = 'EUTRA-extract-55':encode('Seq',CompactVal),
diff --git a/lib/asn1/test/asn1_wrapper.erl b/lib/asn1/test/asn1_wrapper.erl
index d515b99ac2..e764d8b4ca 100644
--- a/lib/asn1/test/asn1_wrapper.erl
+++ b/lib/asn1/test/asn1_wrapper.erl
@@ -34,41 +34,16 @@ encode(Module,Type,Value) ->
Error
end.
-decode(Module,Type,Bytes) ->
- case Module:encoding_rule() of
- ber ->
- asn1rt:decode(Module,Type,Bytes);
- ber_bin when is_binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- ber_bin ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes));
- ber_bin_v2 when is_binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- ber_bin_v2 ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes));
- per ->
- asn1rt:decode(Module,Type,Bytes);
- per_bin when is_binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- per_bin ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes));
- uper_bin when is_binary(Bytes) ->
- asn1rt:decode(Module,Type,Bytes);
- uper_bin ->
- asn1rt:decode(Module,Type,list_to_binary(Bytes))
- end.
+decode(Module, Type, Bytes) when is_binary(Bytes) ->
+ asn1rt:decode(Module, Type, Bytes);
+decode(Module, Type, Bytes) when is_list(Bytes) ->
+ asn1rt:decode(Module, Type, list_to_binary(Bytes)).
erule(ber) ->
ber;
-erule(ber_bin) ->
- ber;
-erule(ber_bin_v2) ->
- ber;
erule(per) ->
per;
-erule(per_bin) ->
- per;
-erule(uper_bin) ->
+erule(uper) ->
per.
diff --git a/lib/asn1/test/h323test.erl b/lib/asn1/test/h323test.erl
index b7a7d6e4df..426ae16994 100644
--- a/lib/asn1/test/h323test.erl
+++ b/lib/asn1/test/h323test.erl
@@ -22,7 +22,6 @@
-export([run/1]).
-include_lib("test_server/include/test_server.hrl").
-run(per_bin) -> run();
run(per) -> run();
run(_Rules) -> ok.
diff --git a/lib/asn1/test/testChoiceIndefinite.erl b/lib/asn1/test/testChoiceIndefinite.erl
index 630efcf27a..b5832c985a 100644
--- a/lib/asn1/test/testChoiceIndefinite.erl
+++ b/lib/asn1/test/testChoiceIndefinite.erl
@@ -23,12 +23,7 @@
-include_lib("test_server/include/test_server.hrl").
-main(per_bin) -> ok;
main(per) -> ok;
-main(ber_bin_v2) ->
- main(ber);
-main(ber_bin) ->
- main(ber);
main(ber) ->
%% Test case related to OTP-4358
%% normal encoding
diff --git a/lib/asn1/test/testCompactBitString.erl b/lib/asn1/test/testCompactBitString.erl
index 9563a31bf3..db102a3bda 100644
--- a/lib/asn1/test/testCompactBitString.erl
+++ b/lib/asn1/test/testCompactBitString.erl
@@ -233,7 +233,7 @@ compact_bit_string(Rules) ->
ok.
-ticket_7734(per_bin) ->
+ticket_7734(per) ->
?line BS = {0,list_to_binary(lists:duplicate(128,0))},
?line {ok,BSEnc} = asn1_wrapper:encode('PrimStrings','BS1024',BS),
?line {ok,BS} = asn1_wrapper:decode('PrimStrings','BS1024',BSEnc).
@@ -251,7 +251,7 @@ bit_string_unnamed(Rules) ->
lists:flatten(Bytes1))
end.
-otp_4869(per_bin) ->
+otp_4869(per) ->
?line Val1={'IP',[0],{0,<<62,235,90,50,0,0,0,0,0,0,0,0,0,0,0,0>>},asn1_NOVALUE},
?line Val2 = {'IP',[0],[0,0,1,1,1,1,1,0,1,1,1,0,1,0,1,1,0,1,0,1,1,0,1,0,0,0,1,1,0,0,1,0] ++ lists:duplicate(128 - 32,0),asn1_NOVALUE},
diff --git a/lib/asn1/test/testEnumExt.erl b/lib/asn1/test/testEnumExt.erl
index c97116413a..bb975a1d13 100644
--- a/lib/asn1/test/testEnumExt.erl
+++ b/lib/asn1/test/testEnumExt.erl
@@ -23,8 +23,8 @@
-include_lib("test_server/include/test_server.hrl").
-main(Rules) when Rules == per; Rules == per_bin; Rules == uper_bin ->
- io:format("main(~p)~n",[Rules]),
+main(Rule) when Rule =:= per; Rule =:= uper ->
+ io:format("main(~p)~n",[Rule]),
B32=[32],B64=[64],
%% ENUMERATED with extensionmark (value is in root set)
?line {ok,B32} = asn1_wrapper:encode('EnumExt','Ext',red),
@@ -42,10 +42,6 @@ main(Rules) when Rules == per; Rules == per_bin; Rules == uper_bin ->
?line {ok,red} = asn1_wrapper:decode('EnumExt','Noext',B64),
ok;
-main(ber_bin_v2) ->
- main(ber);
-main(ber_bin) ->
- main(ber);
main(ber) ->
io:format("main(ber)~n",[]),
%% ENUMERATED with extensionmark (value is in root set)
diff --git a/lib/asn1/test/testINSTANCE_OF.erl b/lib/asn1/test/testINSTANCE_OF.erl
index 5986a00ec5..ce411beb92 100644
--- a/lib/asn1/test/testINSTANCE_OF.erl
+++ b/lib/asn1/test/testINSTANCE_OF.erl
@@ -26,7 +26,7 @@
main(Erule) ->
?line {ok,Integer} = asn1_wrapper:encode('INSTANCEOF','Int',3),
- Int = wrap(Erule,Integer),
+ Int = list_to_binary(Integer),
ValotherName = {otherName,{'INSTANCE OF',{2,4},Int}},
VallastName1 = {lastName,{'GeneralName_lastName',{2,4},12}},
VallastName2 = {lastName,{'GeneralName_lastName',{2,3,4},
@@ -61,18 +61,3 @@ test_encdec(_Erule,{lastName,{'GeneralName_lastName',{2,3,4},
ok;
test_encdec(Erule,Res) ->
{error,{Erule,Res}}.
-
-wrap(ber,Int) when is_list(Int) ->
- binary_to_list(list_to_binary(Int));
-wrap(per,Int) when is_list(Int) ->
- binary_to_list(list_to_binary(Int));
-wrap(ber_bin,Int) when is_list(Int) ->
- list_to_binary(Int);
-wrap(ber_bin_v2,Int) when is_list(Int) ->
- list_to_binary(Int);
-wrap(per_bin,Int) when is_list(Int) ->
- list_to_binary(Int);
-wrap(uper_bin,Int) when is_list(Int) ->
- list_to_binary(Int);
-wrap(_,Int) ->
- Int.
diff --git a/lib/asn1/test/testInfObjectClass.erl b/lib/asn1/test/testInfObjectClass.erl
index e639066246..98408502c6 100644
--- a/lib/asn1/test/testInfObjectClass.erl
+++ b/lib/asn1/test/testInfObjectClass.erl
@@ -37,15 +37,12 @@ main(Rule) ->
{component,'ArgumentType'},
{value,_},_}}} = asn1_wrapper:encode('InfClass','Seq',
{'Seq',12,13,1}),
- Bytes2 =
- if
- Rule==per;Rule==per_bin ->
- [1,12,1,11,1,1];
- Rule == uper_bin ->
- <<1,12,1,11,1,1>>;
- true ->
- [48,9,2,1,12,2,1,11,2,1,1]
- end,
+ Bytes2 = case Rule of
+ ber ->
+ <<48,9,2,1,12,2,1,11,2,1,1>>;
+ _ ->
+ <<1,12,1,11,1,1>>
+ end,
?line {error,{asn1,{'Type not compatible with table constraint',
{{component,_},
{value,_B},_}}}} =
diff --git a/lib/asn1/test/testMergeCompile.erl b/lib/asn1/test/testMergeCompile.erl
index 31aa3518f6..d63df28c31 100644
--- a/lib/asn1/test/testMergeCompile.erl
+++ b/lib/asn1/test/testMergeCompile.erl
@@ -43,17 +43,11 @@ main(Erule) ->
?line EncVal =
case Erule of
per ->
- [1,100];
- per_bin ->
<<1,100>>;
- uper_bin ->
+ uper ->
<<1,100>>;
ber ->
- [2,1,1];
- ber_bin ->
- <<2,1,1>>;
- ber_bin_v2 ->
- <<2,1,1>>
+ [2,1,1]
end,
?line PEVal2 = [{dummy,1,ignore,EncVal},{dummy,2,reject,EncVal}],
?line Val2 =
@@ -76,7 +70,7 @@ main(Erule) ->
mvrasn(Erule) ->
case Erule of
- Ber when Ber == ber;Ber == ber_bin ->
+ ber ->
?line ok = test(isd),
?line ok = test(isd2),
?line ok = test(dsd),
diff --git a/lib/asn1/test/testMultipleLevels.erl b/lib/asn1/test/testMultipleLevels.erl
new file mode 100644
index 0000000000..ff6d023440
--- /dev/null
+++ b/lib/asn1/test/testMultipleLevels.erl
@@ -0,0 +1,27 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2012. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+
+-module(testMultipleLevels).
+-export([main/1]).
+
+main(_) ->
+ Data = {'Top',{short,"abc"},{long,"a long string follows here"}},
+ {ok,B} = 'MultipleLevels':encode('Top', Data),
+ {ok,Data} = 'MultipleLevels':decode('Top', iolist_to_binary(B)).
diff --git a/lib/asn1/test/testParameterizedInfObj.erl b/lib/asn1/test/testParameterizedInfObj.erl
index 68faf08a61..6f53595132 100644
--- a/lib/asn1/test/testParameterizedInfObj.erl
+++ b/lib/asn1/test/testParameterizedInfObj.erl
@@ -98,7 +98,7 @@ ranap(_Erule) ->
ok.
-open_type(uper_bin,Val) when is_list(Val) ->
+open_type(uper,Val) when is_list(Val) ->
list_to_binary(Val);
open_type(_,Val) ->
Val.
diff --git a/lib/asn1/test/testSSLspecs.erl b/lib/asn1/test/testSSLspecs.erl
index 51ef134e5f..45c5da50f0 100644
--- a/lib/asn1/test/testSSLspecs.erl
+++ b/lib/asn1/test/testSSLspecs.erl
@@ -42,11 +42,11 @@ compile(Config, Options) ->
asn1_test_lib:compile_all(["PKIX1Explicit93", "PKIX1Implicit93"],
Config, NewOptions).
-compile_inline(Config, Rule) when Rule == ber_bin; Rule == ber_bin_v2 ->
+compile_inline(Config, ber=Rule) ->
DataDir = ?config(data_dir, Config),
CaseDir = ?config(case_dir, Config),
Options = [{i, CaseDir}, {i, DataDir}, Rule,
- der, compact_bit_string, optimize, asn1config, inline],
+ der, compact_bit_string, asn1config, inline],
ok = remove_db_file_inline(CaseDir),
asn1_test_lib:compile("OTP-PKIX.set.asn", Config, Options);
compile_inline(_Config, _Rule) ->
@@ -73,7 +73,7 @@ remove_db_file_inline(Dir) ->
?line ok = remove_db_file(Dir ++ "PKIX1Explicit88.asn1db"),
?line ok = remove_db_file(Dir ++ "PKIX1Implicit88.asn1db").
-run(BER) when BER==ber_bin;BER==ber_bin_v2 ->
+run(ber) ->
run1(1);
run(_) ->
ok.
@@ -100,20 +100,20 @@ transform1(ATAV) ->
?line {ok, ATAVEnc} = 'PKIX1Explicit88':encode('AttributeTypeAndValue',
ATAV),
?line {ok, _ATAVDec} = 'SSL-PKIX':decode('AttributeTypeAndValue',
- list_to_binary(ATAVEnc)).
+ ATAVEnc).
transform2(ATAV) ->
?line {ok, ATAVEnc} = 'PKIX1Explicit88':encode('AttributeTypeAndValue',
ATAV),
?line {ok, _ATAVDec} = 'PKIX1Explicit88':decode('AttributeTypeAndValue',
- list_to_binary(ATAVEnc)).
+ ATAVEnc).
transform4(ATAV) ->
?line {ok, ATAVEnc} = 'PKIX1Explicit88':encode('Attribute',
ATAV),
?line {ok, _ATAVDec} = 'PKIX1Explicit88':decode('Attribute',
- list_to_binary(ATAVEnc)).
+ ATAVEnc).
ex(1) ->
@@ -146,7 +146,7 @@ ex(7) ->
{1,2,840,113549,1,9,1},
[[19,5,111,116,112,67,65]]}.
-run_inline(Rule) when Rule==ber_bin;Rule==ber_bin_v2 ->
+run_inline(ber) ->
Cert = cert(),
?line {ok,{'CertificatePKIX1Explicit88',{Type,UnDec},_,_}} = 'OTP-PKIX':decode_TBSCert_exclusive(Cert),
?line {ok,_} = 'OTP-PKIX':decode_part(Type,UnDec),
diff --git a/lib/asn1/test/testSeqIndefinite.erl b/lib/asn1/test/testSeqIndefinite.erl
index 25742474bb..c7b8aba523 100644
--- a/lib/asn1/test/testSeqIndefinite.erl
+++ b/lib/asn1/test/testSeqIndefinite.erl
@@ -23,13 +23,7 @@
-include_lib("test_server/include/test_server.hrl").
-
-main(per_bin) -> ok;
main(per) -> ok;
-main(ber_bin_v2) ->
- main(ber);
-main(ber_bin) ->
- main(ber);
main(ber) ->
%% normal encoding
diff --git a/lib/asn1/test/testSeqOf.erl b/lib/asn1/test/testSeqOf.erl
index 0c0bbc3e66..1aa1eab26d 100644
--- a/lib/asn1/test/testSeqOf.erl
+++ b/lib/asn1/test/testSeqOf.erl
@@ -198,19 +198,10 @@ main(Rules) ->
?line {ok,Bytes51} = asn1_wrapper:encode('SeqOf','SeqEmp',#'SeqEmp'{seq1 = [#'Empty'{}]}),
?line {ok,{'SeqEmp',[{'Empty'}]}} = asn1_wrapper:decode('SeqOf','SeqEmp',lists:flatten(Bytes51)),
-
- case Rules of
- ber ->
- ?line {ok,Bytes52} = asn1_wrapper:encode('SeqOfEnum','SeqOfEnum',
- {'SeqOfEnum',[{'Enum',a},{'Enum',b}]}),
- ?line {ok,[a,b]} = asn1_wrapper:decode('SeqOfEnum','SeqOfEnum',
- lists:flatten(Bytes52));
- _ -> ok
- end,
%% tests of OTP-4590
case Rules of
- PER when PER == per; PER == per_bin ->
+ per ->
DayNames = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
?line {ok,Bytes60} = asn1_wrapper:encode('XSeqOf','DayNames2',DayNames),
?line {ok,Bytes60} = asn1_wrapper:encode('XSeqOf','DayNames4',DayNames),
diff --git a/lib/asn1/test/testSetIndefinite.erl b/lib/asn1/test/testSetIndefinite.erl
index d8e2b6a9cf..73006da62b 100644
--- a/lib/asn1/test/testSetIndefinite.erl
+++ b/lib/asn1/test/testSetIndefinite.erl
@@ -24,12 +24,7 @@
-include_lib("test_server/include/test_server.hrl").
-main(per_bin) -> ok;
main(per) -> ok;
-main(ber_bin_v2) ->
- main(ber);
-main(ber_bin) ->
- main(ber);
main(ber) ->
%% normal encoding
diff --git a/lib/asn1/test/testSetOptional.erl b/lib/asn1/test/testSetOptional.erl
index 4692941524..cef90bc843 100644
--- a/lib/asn1/test/testSetOptional.erl
+++ b/lib/asn1/test/testSetOptional.erl
@@ -181,7 +181,7 @@ main(_Rules) ->
ok.
-ticket_7533(Ber) when Ber == ber; Ber == ber_bin ->
+ticket_7533(Ber) when Ber == ber ->
Val = #'SetOpt1'{bool1 = true,int1=12,set1=#'SetIn'{boolIn=false,intIn=13}},
?line {ok,B} = asn1_wrapper:encode('SetOptional','SetOpt1',Val),
?line {ok,Val} = asn1_wrapper:decode('SetOptional','SetOpt1',B),
diff --git a/lib/asn1/test/testTCAP.erl b/lib/asn1/test/testTCAP.erl
index 878ce7c070..b723995e40 100644
--- a/lib/asn1/test/testTCAP.erl
+++ b/lib/asn1/test/testTCAP.erl
@@ -37,7 +37,7 @@ compile_asn1config(Config, Options) ->
asn1_test_lib:compile_all(Files, Config, Options),
asn1_test_lib:compile_erlang("TCAPPackage_msg", Config, []).
-test(Erule,_Config) when Erule==ber;Erule==ber_bin;Erule==ber_bin_v2 ->
+test(ber=Erule,_Config) ->
% ?line OutDir = ?config(priv_dir,Config),
%% testing OTP-4798, open type encoded with indefinite length
?line {ok,_Res} = asn1_wrapper:decode('TCAPMessages-simple','MessageType', val_OTP_4798(Erule)),
@@ -81,7 +81,7 @@ test_asn1config() ->
?line Val2 = 'TCAPPackage_msg':val('TransactionPDU'),
?line {ok,B2} = 'TCAPPackage':encode('TransactionPDU',Val2),
- ?line {ok,ExMsg2}='TCAPPackage':decode_TransactionPDU(list_to_binary(B2)),
+ {ok,ExMsg2}='TCAPPackage':decode_TransactionPDU(B2),
?line {_,_,_,{Key2,ExVal2}}=ExMsg2,
?line {ok,_Parts2}='TCAPPackage':decode_part(Key2,ExVal2),
diff --git a/lib/asn1/test/testTimer.erl b/lib/asn1/test/testTimer.erl
index 2d3b777558..cd7ceb5630 100644
--- a/lib/asn1/test/testTimer.erl
+++ b/lib/asn1/test/testTimer.erl
@@ -133,23 +133,7 @@ go(Config,Enc) ->
Module = 'H323-MESSAGES',
Type = 'H323-UserInformation',
Value = val(),
-%% ok = asn1ct:compile(HelpModule,[Enc]),
-
-%% ok = asn1ct:compile(Module,[Enc]),
- ?line {ok,B} = asn1rt:encode(Module,Type,Value),
- Bytes = case Enc of
- ber_bin ->
- list_to_binary(B);
- per_bin when is_list(B) ->
- list_to_binary(B);
- per_bin ->
- B;
- uper_bin ->
- B;
- _ ->
- %%lists:flatten(B)
- list_to_binary(B)
- end,
+ {ok,Bytes} = asn1rt:encode(Module,Type,Value),
CompileOptions = compile_options(),
@@ -181,35 +165,18 @@ encode(N, Module,Type,Value) ->
decode(0, _Module,_Type,_Value,_Erule) ->
done;
decode(N, Module,Type,Value,Erule) ->
- case Erule of
- ber ->
- ?line {ok,_B} = asn1rt:decode(Module,Type,binary_to_list(Value));
- per ->
- ?line {ok,_B} = asn1rt:decode(Module,Type,binary_to_list(Value));
- _ ->
- ?line {ok,_B} = asn1rt:decode(Module,Type,Value)
- end,
+ {ok,_B} = asn1rt:decode(Module,Type,Value),
decode(N-1, Module,Type,Value,Erule).
compile_options() ->
- ?line {ok,Info} = asn1rt:info('H323-MESSAGES'),
- case lists:keysearch(options,1,Info) of
- {_,{_,Opts}} ->
- Opts2 =
- case lists:member(ber_bin_v2,Opts) of
- true ->
- [ber_bin,optimize] ++ lists:delete(optimize,Opts);
- _ ->
- Opts
- end,
- Opts3 = [X||X <- Opts2,
- (X == ber orelse
- X == ber_bin orelse
- X == per orelse
- X == per_bin orelse
- X == optimize orelse
- X == driver)],
- lists:flatten(io_lib:format("~p",[Opts3]));
+ {ok,Info} = asn1rt:info('H323-MESSAGES'),
+ case lists:keyfind(options, 1, Info) of
+ {_,Opts0} ->
+ Opts1 = [X || X <- Opts0,
+ (X =:= ber orelse
+ X =:= per orelse
+ X =:= uper)],
+ lists:flatten(io_lib:format("~p", [Opts1]));
_ ->
"[]"
end.
diff --git a/lib/asn1/test/testTypeValueNotation.erl b/lib/asn1/test/testTypeValueNotation.erl
index cd5223ef23..59f7385f08 100644
--- a/lib/asn1/test/testTypeValueNotation.erl
+++ b/lib/asn1/test/testTypeValueNotation.erl
@@ -21,11 +21,9 @@
-export([main/2]).
--include_lib("test_server/include/test_server.hrl").
-
-record('Seq', {octstr, int, bool, enum, bitstr, null, oid, vstr}).
-main(Rule, Option) ->
+main(_Rule, _Option) ->
Value1 = #'Seq'{octstr = [1, 2, 3, 4],
int = 12,
bool = true,
@@ -34,28 +32,5 @@ main(Rule, Option) ->
null = 'NULL',
oid = {1, 2, 55},
vstr = "Hello World"},
- Value2 = #'Seq'{octstr = {'OctStr', [1, 2, 3, 4]},
- int = {'Int', 12},
- bool = {'Bool', true},
- enum = {'Enum', a},
- bitstr = {'BitStr', [1, 0, 1, 0]},
- null = {'Null', 'NULL'},
- oid = {'OId', {1, 2, 55}},
- vstr = {'VStr', "Hello World"}},
- main(Rule, Option, Value1, Value2).
-
-%% Value2 will fail for ber_bin_v2, per_bin with nifs (optimize) and uper_bin
-main(ber_bin_v2, _, Value1, Value2) -> encode_fail(Value1, Value2);
-main(per_bin, [optimize], Value1, Value2) -> encode_fail(Value1, Value2);
-main(uper_bin, [], Value1, Value2) -> encode_fail(Value1, Value2);
-main(_, _, Value1, Value2) -> encode_normal(Value1, Value2).
-
-encode_normal(Value1, Value2) ->
- {ok, Bytes} = asn1_wrapper:encode('SeqTypeRefPrim', 'Seq', Value1),
- {ok, Bytes} = asn1_wrapper:encode('SeqTypeRefPrim', 'Seq', Value2),
- {ok, Value1} = asn1_wrapper:decode('SeqTypeRefPrim', 'Seq', Bytes).
-
-encode_fail(Value1, Value2) ->
- {ok, Bytes} = asn1_wrapper:encode('SeqTypeRefPrim', 'Seq', Value1),
- {error, _Reason} = asn1_wrapper:encode('SeqTypeRefPrim', 'Seq', Value2),
- {ok, Value1} = asn1_wrapper:decode('SeqTypeRefPrim', 'Seq', Bytes).
+ {ok, Bytes} = asn1_wrapper:encode('SeqTypeRefPrim', 'Seq', Value1),
+ {ok, Value1} = asn1_wrapper:decode('SeqTypeRefPrim', 'Seq', Bytes).
diff --git a/lib/asn1/test/testX420.erl b/lib/asn1/test/testX420.erl
index abdbbfe536..52b20a2c70 100644
--- a/lib/asn1/test/testX420.erl
+++ b/lib/asn1/test/testX420.erl
@@ -34,7 +34,7 @@ compile(Erule, Options, Config) ->
compile_loop(_Erule, [], _Options, _Config) ->
ok;
compile_loop(Erule, [Spec|Specs], Options, Config)
- when Erule == ber; Erule == ber_bin; Erule == ber_bin_v2; Erule == per ->
+ when Erule =:= ber; Erule =:= per ->
CaseDir = ?config(case_dir, Config),
asn1_test_lib:compile(filename:join([x420, Spec]), Config,
[Erule, {i, CaseDir}]),
diff --git a/lib/asn1/test/test_compile_options.erl b/lib/asn1/test/test_compile_options.erl
index 4e732308d8..b973c5fbcc 100644
--- a/lib/asn1/test/test_compile_options.erl
+++ b/lib/asn1/test/test_compile_options.erl
@@ -92,7 +92,8 @@ noobj(Config) ->
file:delete(filename:join([OutDir,'P-Record.beam'])),
file:delete(filename:join([OutDir,'p_record.erl'])),
file:delete(filename:join([OutDir,'p_record.beam'])),
- ?line ok=asn1ct:compile(filename:join([DataDir,"p_record.set.asn"]),[asn1config,ber_bin,optimize,noobj,{outdir,OutDir}]),
+ ok = asn1ct:compile(filename:join([DataDir,"p_record.set.asn"]),
+ [asn1config,ber,noobj,{outdir,OutDir}]),
%% ?line false = code:is_loaded('P-Record'),
%% ?line false = code:is_loaded('p_record'),
?line {error,enoent} =
diff --git a/lib/asn1/test/test_inline.erl b/lib/asn1/test/test_inline.erl
index 62625572e3..e03ad739f9 100644
--- a/lib/asn1/test/test_inline.erl
+++ b/lib/asn1/test/test_inline.erl
@@ -41,16 +41,16 @@ inline1(Config, Rule, Opt) ->
asn1_test_lib:compile("P-Record", Config, [{inline, 'inlined_P_Record'}|Opt]),
test_inline1(),
- ok=remove_inlined_files2(CaseDir, ber_bin_v2),
+ ok=remove_inlined_files2(CaseDir, ber),
case Rule of
- ber_bin_v2 ->
+ ber ->
asn1_test_lib:compile("P-Record", Config,
- [ber_bin, inline, asn1config, optimize|Opt]),
+ [ber, inline, asn1config|Opt]),
test_inline2(Rule, 'P-Record'),
remove_inlined_files3(CaseDir, Rule),
asn1_test_lib:compile("p_record.set.asn", Config,
- [ber_bin, inline, asn1config, optimize|Opt]),
+ [ber, inline, asn1config|Opt]),
test_inline2(Rule, 'p_record'),
remove_inlined_files4(CaseDir, Rule);
_ ->
@@ -71,12 +71,12 @@ test_inline1() ->
?line {ok,_}=asn1_wrapper:decode('inlined_P_Record',
'PersonnelRecord',Bytes).
-test_inline2(ber_bin_v2,Mod) ->
+test_inline2(ber,Mod) ->
PRecMsg = {'PersonnelRecord',{'Name',"Sven","S","Svensson"},
"manager",123,"20000202",{'Name',"Inga","K","Svensson"},
asn1_DEFAULT},
?line {ok,Bytes} = Mod:encode('PersonnelRecord',PRecMsg),
- ?line {ok,_} = Mod:sel_dec(list_to_binary(Bytes));
+ {ok,_} = Mod:sel_dec(Bytes);
test_inline2(_,_) ->
ok.
@@ -243,7 +243,7 @@ remove_inlined_files2(Dir,Rule) ->
?line ok=file:delete(X)
end,[TargetErl,TargetBeam]),
ok.
-remove_inlined_files3(Dir,ber_bin_v2) ->
+remove_inlined_files3(Dir,ber) ->
Erl=filename:join([Dir,"P-Record.erl"]),
Beam=filename:join([Dir,"P-Record.beam"]),
Asn1DB=filename:join([Dir,"P-Record.asn1db"]),
@@ -255,7 +255,7 @@ remove_inlined_files3(Dir,ber_bin_v2) ->
remove_inlined_files3(_,_) ->
ok.
-remove_inlined_files4(Dir,ber_bin_v2) ->
+remove_inlined_files4(Dir,ber) ->
Erl=filename:join([Dir,"p_record.erl"]),
Beam=filename:join([Dir,"p_record.beam"]),
Asn1DB=filename:join([Dir,"p_record.asn1db"]),
diff --git a/lib/asn1/test/test_special_decode_performance.erl b/lib/asn1/test/test_special_decode_performance.erl
index 4ac0ff2b27..dd56d29b28 100644
--- a/lib/asn1/test/test_special_decode_performance.erl
+++ b/lib/asn1/test/test_special_decode_performance.erl
@@ -33,7 +33,7 @@ go(all) ->
go(N,Mod) ->
?line Val = val(Mod),
?line {ok,B} = Mod:encode(element(1,Val),Val),
- ?line go(Mod,list_to_binary(B),N).
+ ?line go(Mod,B,N).
go(Mod,Bin,N) ->
?line FsS = get_selective_funcs(Mod),
diff --git a/lib/common_test/doc/src/notes.xml b/lib/common_test/doc/src/notes.xml
index abe8cb2041..7e33b71de1 100644
--- a/lib/common_test/doc/src/notes.xml
+++ b/lib/common_test/doc/src/notes.xml
@@ -32,6 +32,100 @@
<file>notes.xml</file>
</header>
+<section><title>Common_Test 1.6.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ The ct:run_test/1 option 'config' only worked with a
+ single config file, not a list of files. This has been
+ fixed.</p>
+ <p>
+ Own Id: OTP-10495</p>
+ </item>
+ <item>
+ <p>
+ ct_netconfc:close_session sometimes returned
+ {error,closed} because the ssh connection was closed
+ (from the server side) before the rpc-reply was received
+ by the client. This is normal and can not be helped. It
+ has been corrected so the return will be 'ok' in this
+ case. Other error situations will still give
+ {error,Reason}.</p>
+ <p>
+ Own Id: OTP-10510 Aux Id: kunagi-320 [231] </p>
+ </item>
+ <item>
+ <p>
+ ct_netconfc:close_session sometimes returned
+ {error,closed} or (if the connection was named)
+ {error,{process_down,Pid,normal}} because the ssh
+ connection was closed (from the server side) before the
+ rpc-reply was received by the client. This is normal and
+ can not be helped. It has been corrected so the return
+ will be 'ok' in this situation.</p>
+ <p>
+ Own Id: OTP-10570</p>
+ </item>
+ <item>
+ <p>
+ Fix bug where ct:require of same name with same config
+ would return name_in_use.</p>
+ <p>
+ Own Id: OTP-10572</p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ A new test case group search functionality has been
+ implemented that makes Common Test search automatically
+ through the group definitions tree (the return value of
+ groups/0) and create tests for all paths of nested groups
+ that match the specification. It also allows for
+ specifying unique paths to sub groups in order to avoid
+ execution of unwanted tests. This new feature can be used
+ whenever starting a test run by means of the ct_run
+ program, the ct:run_test/1 API function, or a Test
+ Specification. Details can be found in the Test Case
+ Group Execution section in the Running Tests chapter.</p>
+ <p>
+ Own Id: OTP-10466 Aux Id: kunagi-276 [187] </p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Known Bugs and Problems</title>
+ <list>
+ <item>
+ <p>
+ Restore Config data if lost when test case fails.</p>
+ <p>
+ Own Id: OTP-10070 Aux Id: kunagi-175 [86] </p>
+ </item>
+ <item>
+ <p>
+ IO server error in test_server.</p>
+ <p>
+ Own Id: OTP-10125 Aux Id: OTP-10101, kunagi-177 [88] </p>
+ </item>
+ <item>
+ <p>
+ Faulty connection handling in common_test.</p>
+ <p>
+ Own Id: OTP-10126 Aux Id: kunagi-178 [89] </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Common_Test 1.6.2.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/common_test/src/ct_groups.erl b/lib/common_test/src/ct_groups.erl
index 24ca3826a8..74ab5e5439 100644
--- a/lib/common_test/src/ct_groups.erl
+++ b/lib/common_test/src/ct_groups.erl
@@ -176,7 +176,7 @@ find(Mod, GrNames, all, [{M,TC} | Gs], Known,
%% Check if test case should be saved
find(Mod, GrNames, TCs, [TC | Gs], Known,
Defs, FindAll) when is_atom(TC) orelse
- ((size(TC) == 2) and (hd(TC) /= group)) ->
+ ((size(TC) == 2) and (element(1,TC) /= group)) ->
Case =
if is_atom(TC) ->
Tuple = {Mod,TC},
diff --git a/lib/common_test/src/ct_slave.erl b/lib/common_test/src/ct_slave.erl
index cb05423497..58633b7de6 100644
--- a/lib/common_test/src/ct_slave.erl
+++ b/lib/common_test/src/ct_slave.erl
@@ -37,7 +37,7 @@
-record(options, {username, password, boot_timeout, init_timeout,
startup_timeout, startup_functions, monitor_master,
- kill_if_fail, erl_flags}).
+ kill_if_fail, erl_flags, env}).
%%%-----------------------------------------------------------------
%%% @spec start(Node) -> Result
@@ -85,7 +85,8 @@ start(Host, Node) ->
%%% {startup_functions, StartupFunctions} |
%%% {monitor_master, Monitor} |
%%% {kill_if_fail, KillIfFail} |
-%%% {erl_flags, ErlangFlags}
+%%% {erl_flags, ErlangFlags} |
+%%% {env, [{EnvVar,Value}]}
%%% Username = string()
%%% Password = string()
%%% BootTimeout = integer()
@@ -99,6 +100,8 @@ start(Host, Node) ->
%%% Monitor = bool()
%%% KillIfFail = bool()
%%% ErlangFlags = string()
+%%% EnvVar = string()
+%%% Value = string()
%%% Result = {ok, NodeName} | {error, already_started, NodeName} |
%%% {error, started_not_connected, NodeName} |
%%% {error, boot_timeout, NodeName} |
@@ -152,6 +155,9 @@ start(Host, Node) ->
%%% <p>Option <code>erlang_flags</code> specifies, which flags will be added
%%% to the parameters of the <code>erl</code> executable.</p>
%%%
+%%% <p>Option <code>env</code> specifies a list of environment variables
+%%% that will extended the environment.</p>
+%%%
%%% <p>Special return values are:
%%% <list>
%%% <item><code>{error, already_started, NodeName}</code> - if the node with
@@ -233,10 +239,12 @@ fetch_options(Options) ->
Monitor = get_option_value(monitor_master, Options, false),
KillIfFail = get_option_value(kill_if_fail, Options, true),
ErlFlags = get_option_value(erl_flags, Options, []),
+ EnvVars = get_option_value(env, Options, []),
#options{username=UserName, password=Password,
boot_timeout=BootTimeout, init_timeout=InitTimeout,
startup_timeout=StartupTimeout, startup_functions=StartupFunctions,
- monitor_master=Monitor, kill_if_fail=KillIfFail, erl_flags=ErlFlags}.
+ monitor_master=Monitor, kill_if_fail=KillIfFail,
+ erl_flags=ErlFlags, env=EnvVars}.
% send a message when slave node is started
% @hidden
@@ -306,6 +314,7 @@ do_start(Host, Node, Options) ->
true->
spawn_remote_node(Host, Node, Options)
end,
+
BootTimeout = Options#options.boot_timeout,
InitTimeout = Options#options.init_timeout,
StartupTimeout = Options#options.startup_timeout,
@@ -372,9 +381,9 @@ get_cmd(Node, Flags) ->
% spawn node locally
spawn_local_node(Node, Options) ->
- ErlFlags = Options#options.erl_flags,
+ #options{env=Env,erl_flags=ErlFlags} = Options,
Cmd = get_cmd(Node, ErlFlags),
- open_port({spawn, Cmd}, [stream]).
+ open_port({spawn, Cmd}, [stream,{env,Env}]).
% start crypto and ssh if not yet started
check_for_ssh_running() ->
@@ -393,9 +402,10 @@ check_for_ssh_running() ->
% spawn node remotely
spawn_remote_node(Host, Node, Options) ->
- Username = Options#options.username,
- Password = Options#options.password,
- ErlFlags = Options#options.erl_flags,
+ #options{username=Username,
+ password=Password,
+ erl_flags=ErlFlags,
+ env=Env} = Options,
SSHOptions = case {Username, Password} of
{[], []}->
[];
@@ -407,8 +417,17 @@ spawn_remote_node(Host, Node, Options) ->
check_for_ssh_running(),
{ok, SSHConnRef} = ssh:connect(atom_to_list(Host), 22, SSHOptions),
{ok, SSHChannelId} = ssh_connection:session_channel(SSHConnRef, infinity),
+ ssh_setenv(SSHConnRef, SSHChannelId, Env),
ssh_connection:exec(SSHConnRef, SSHChannelId, get_cmd(Node, ErlFlags), infinity).
+
+ssh_setenv(SSHConnRef, SSHChannelId, [{Var, Value} | Vars])
+ when is_list(Var), is_list(Value) ->
+ success = ssh_connection:setenv(SSHConnRef, SSHChannelId,
+ Var, Value, infinity),
+ ssh_setenv(SSHConnRef, SSHChannelId, Vars);
+ssh_setenv(_SSHConnRef, _SSHChannelId, []) -> ok.
+
% call functions on a remote Erlang node
call_functions(_Node, []) ->
ok;
diff --git a/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_1_SUITE.erl b/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_1_SUITE.erl
index 6f6922e686..1c5b572f92 100644
--- a/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_1_SUITE.erl
+++ b/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_1_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_2_SUITE.erl b/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_2_SUITE.erl
index ac3c000079..060012de29 100644
--- a/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_2_SUITE.erl
+++ b/lib/common_test/test/ct_groups_search_SUITE_data/groups_search_dummy_2_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/common_test/test/ct_master_SUITE.erl b/lib/common_test/test/ct_master_SUITE.erl
index 27243a0067..56a343a96f 100644
--- a/lib/common_test/test/ct_master_SUITE.erl
+++ b/lib/common_test/test/ct_master_SUITE.erl
@@ -117,14 +117,8 @@ ct_master_test(Config) when is_list(Config) ->
reformat(Events, ?eh),
PrivDir, []),
- find_events(NodeNames, [{tc_start,{master_SUITE,init_per_suite}},
- {tc_start,{master_SUITE,first_testcase}},
- {tc_start,{master_SUITE,second_testcase}},
- {tc_start,{master_SUITE,third_testcase}},
- {tc_start,{master_SUITE,end_per_suite}}],
- Events),
-
- ok.
+ TestEvents = events_to_check(ct_master_test),
+ ok = find_events(NodeNames, TestEvents, Events, Config).
%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
@@ -153,13 +147,15 @@ make_spec(DataDir, FileName, NodeNames, Suites, Config) ->
CM = [{config,master,filename:join(DataDir,"master/config.txt")}],
+ Env = [{"THIS_MUST_BE_SET","yes"},
+ {"SO_MUST_THIS","value"}],
NS = lists:map(
fun(NodeName) ->
{init,NodeName,[
{node_start,[{startup_functions,[]},
- {monitor_master,true}]},
- {eval,{erlang,nodes,[]}}
- ]
+ {monitor_master,true},
+ {env,Env}]},
+ {eval,{erlang,nodes,[]}}]
}
end,
NodeNames),
@@ -199,7 +195,6 @@ run_test(_Name, FileName, Config) ->
[{FileName,ok}] = ct_test_support:run({ct_master,run,[FileName]},
[{ct_master,basic_html,[true]}],
Config),
- timer:sleep(5000),
[{FileName,ok}] = ct_test_support:run({ct_master,run,[FileName]},
[{ct_master,basic_html,[false]}],
Config).
@@ -210,28 +205,26 @@ reformat(Events, EH) ->
%%%-----------------------------------------------------------------
%%% TEST EVENTS
%%%-----------------------------------------------------------------
-find_events([], _CheckEvents, _) ->
- ok;
-find_events([NodeName|NodeNames],CheckEvents,AllEvents) ->
- find_events(NodeNames, CheckEvents,
- remove_events(add_host(NodeName),CheckEvents, AllEvents, [])).
-
-remove_events(Node,[{Name,Data} | RestChecks],
- [{?eh,#event{ name = Name, node = Node, data = Data }}|RestEvs],
- Acc) ->
- remove_events(Node, RestChecks, RestEvs, Acc);
-remove_events(Node, Checks, [Event|RestEvs], Acc) ->
- remove_events(Node, Checks, RestEvs, [Event | Acc]);
-remove_events(_Node, [], [], Acc) ->
- lists:reverse(Acc);
-remove_events(Node, Events, [], Acc) ->
- test_server:format("Could not find events: ~p in ~p for node ~p",
- [Events, lists:reverse(Acc), Node]),
- exit(event_not_found).
+
+find_events(NodeNames, TestEvents, Events, Config) ->
+ [begin
+ Node = add_host(Node0),
+ io:format("Searching for events for node: ~s", [Node]),
+ ok = ct_test_support:verify_events(TestEvents, Events, Node, Config),
+ io:nl()
+ end || Node0 <- NodeNames],
+ ok.
add_host(NodeName) ->
{ok, HostName} = inet:gethostname(),
list_to_atom(atom_to_list(NodeName)++"@"++HostName).
-expected_events(_) ->
- [].
+events_to_check(_) ->
+ [{?eh,tc_start,{master_SUITE,first_testcase}},
+ {?eh,tc_done,{master_SUITE,first_testcase,ok}},
+ {?eh,tc_start,{master_SUITE,second_testcase}},
+ {?eh,tc_done,{master_SUITE,second_testcase,ok}},
+ {?eh,tc_start,{master_SUITE,third_testcase}},
+ {?eh,tc_done,{master_SUITE,third_testcase,ok}},
+ {?eh,tc_start,{master_SUITE,env_vars}},
+ {?eh,tc_done,{master_SUITE,env_vars,ok}}].
diff --git a/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl
index 032d69ad9f..8a5009ad62 100644
--- a/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl
+++ b/lib/common_test/test/ct_master_SUITE_data/master/master_SUITE.erl
@@ -39,7 +39,8 @@ init_per_suite(Config) ->
end_per_suite(_) ->
ok.
-all() -> [first_testcase, second_testcase, third_testcase].
+all() -> [first_testcase, second_testcase, third_testcase,
+ env_vars].
init_per_testcase(_, Config) ->
Config.
@@ -56,3 +57,9 @@ second_testcase(_)->
third_testcase(_)->
A = 4,
A = 2*2.
+
+env_vars(_) ->
+ io:format("~p\n", [os:getenv()]),
+ "yes" = os:getenv("THIS_MUST_BE_SET"),
+ "value" = os:getenv("SO_MUST_THIS"),
+ ok.
diff --git a/lib/common_test/test/ct_test_support.erl b/lib/common_test/test/ct_test_support.erl
index 901e53c71d..e5e2e68fcb 100644
--- a/lib/common_test/test/ct_test_support.erl
+++ b/lib/common_test/test/ct_test_support.erl
@@ -32,7 +32,7 @@
run/2, run/3, run/4, get_opts/1, wait_for_ct_stop/1]).
-export([handle_event/2, start_event_receiver/1, get_events/2,
- verify_events/3, reformat/2, log_events/4,
+ verify_events/3, verify_events/4, reformat/2, log_events/4,
join_abs_dirs/2]).
-export([ct_test_halt/1]).
@@ -370,6 +370,14 @@ verify_events(TEvs, Evs, Config) ->
ok
end.
+verify_events(TEvs, Evs, Node, Config) ->
+ case catch verify_events1(TEvs, Evs, Node, Config) of
+ {'EXIT',Reason} ->
+ Reason;
+ _ ->
+ ok
+ end.
+
verify_events1([TestEv|_], [{TEH,#event{name=stop_logging,node=Node,data=_}}|_], Node, _)
when element(1,TestEv) == TEH, element(2,TestEv) =/= stop_logging ->
test_server:format("Failed to find ~p in the list of events!~n", [TestEv]),
diff --git a/lib/common_test/vsn.mk b/lib/common_test/vsn.mk
index 5c9fdfc47e..f9bb22867e 100644
--- a/lib/common_test/vsn.mk
+++ b/lib/common_test/vsn.mk
@@ -1 +1 @@
-COMMON_TEST_VSN = 1.6.2.1
+COMMON_TEST_VSN = 1.6.3
diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl
index bcceb889ed..e8f5c55c1a 100644
--- a/lib/compiler/test/bs_match_SUITE.erl
+++ b/lib/compiler/test/bs_match_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/crypto/c_src/Makefile.in b/lib/crypto/c_src/Makefile.in
index ffd556ca1a..e19d6617f3 100644
--- a/lib/crypto/c_src/Makefile.in
+++ b/lib/crypto/c_src/Makefile.in
@@ -59,8 +59,6 @@ TYPE_FLAGS = $(CFLAGS)
endif
endif
-ALL_CFLAGS = $(TYPE_FLAGS) $(INCLUDES)
-
# ----------------------------------------------------
# Release directory specification
# ----------------------------------------------------
@@ -69,13 +67,16 @@ RELSYSDIR = $(RELEASE_PATH)/lib/crypto-$(VSN)
# ----------------------------------------------------
# Misc Macros
# ----------------------------------------------------
-OBJS = $(OBJDIR)/crypto$(TYPEMARKER).o
+CRYPTO_OBJS = $(OBJDIR)/crypto$(TYPEMARKER).o
+CALLBACK_OBJS = $(OBJDIR)/crypto_callback$(TYPEMARKER).o
NIF_MAKEFILE = $(PRIVDIR)/Makefile
ifeq ($(findstring win32,$(TARGET)), win32)
NIF_LIB = $(LIBDIR)/crypto$(TYPEMARKER).dll
+CALLBACK_LIB = $(LIBDIR)/crypto_callback$(TYPEMARKER).dll
else
NIF_LIB = $(LIBDIR)/crypto$(TYPEMARKER).so
+CALLBACK_LIB = $(LIBDIR)/crypto_callback$(TYPEMARKER).so
endif
ifeq ($(HOST_OS),)
@@ -86,43 +87,69 @@ DYNAMIC_CRYPTO_LIB=@SSL_DYNAMIC_ONLY@
ifeq ($(DYNAMIC_CRYPTO_LIB),yes)
SSL_DED_LD_RUNTIME_LIBRARY_PATH = @SSL_DED_LD_RUNTIME_LIBRARY_PATH@
CRYPTO_LINK_LIB=$(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) -l$(SSL_CRYPTO_LIBNAME)
+EXTRA_FLAGS = -DHAVE_DYNAMIC_CRYPTO_LIB
else
SSL_DED_LD_RUNTIME_LIBRARY_PATH=
CRYPTO_LINK_LIB=$(SSL_LIBDIR)/lib$(SSL_CRYPTO_LIBNAME).a
+EXTRA_FLAGS =
+CRYPTO_OBJS := $(CRYPTO_OBJS) $(CALLBACK_OBJS)
+CALLBACK_OBJS =
+CALLBACK_LIB =
endif
+ALL_CFLAGS = $(TYPE_FLAGS) $(EXTRA_FLAGS) $(INCLUDES)
+
# ----------------------------------------------------
# Targets
# ----------------------------------------------------
_create_dirs := $(shell mkdir -p $(OBJDIR) $(LIBDIR))
-debug opt valgrind: $(NIF_LIB)
+debug opt valgrind: $(NIF_LIB) $(CALLBACK_LIB)
$(OBJDIR)/%$(TYPEMARKER).o: %.c
$(INSTALL_DIR) $(OBJDIR)
$(CC) -c -o $@ $(ALL_CFLAGS) $<
-$(LIBDIR)/crypto$(TYPEMARKER).so: $(OBJS)
- $(INSTALL_DIR) $(LIBDIR)
+$(LIBDIR)/crypto$(TYPEMARKER).so: $(CRYPTO_OBJS)
+ $(INSTALL_DIR) $(LIBDIR)
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) $(CRYPTO_LINK_LIB)
-$(LIBDIR)/crypto$(TYPEMARKER).dll: $(OBJS)
+$(LIBDIR)/crypto$(TYPEMARKER).dll: $(CRYPTO_OBJS)
+ $(INSTALL_DIR) $(LIBDIR)
+ $(LD) $(LDFLAGS) -o $@ $(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) $(CRYPTO_OBJS) -l$(SSL_CRYPTO_LIBNAME) -l$(SSL_SSL_LIBNAME)
+
+ifeq ($(DYNAMIC_CRYPTO_LIB),yes)
+$(LIBDIR)/crypto_callback$(TYPEMARKER).so: $(CALLBACK_OBJS)
+ $(INSTALL_DIR) $(LIBDIR)
+ $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
+$(LIBDIR)/crypto_callback$(TYPEMARKER).dll: $(CALLBACK_OBJS)
$(INSTALL_DIR) $(LIBDIR)
- $(LD) $(LDFLAGS) -o $@ $(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) $(OBJS) -l$(SSL_CRYPTO_LIBNAME) -l$(SSL_SSL_LIBNAME)
+ $(LD) $(LDFLAGS) -o $@ $(CALLBACK_OBJS)
+endif
+
clean:
ifeq ($(findstring win32,$(TARGET)), win32)
rm -f $(LIBDIR)/crypto.dll
rm -f $(LIBDIR)/crypto.debug.dll
+ rm -f $(LIBDIR)/crypto_callback.dll
+ rm -f $(LIBDIR)/crypto_callback.debug.dll
else
rm -f $(LIBDIR)/crypto.so
rm -f $(LIBDIR)/crypto.debug.so
rm -f $(LIBDIR)/crypto.valgrind.so
+ rm -f $(LIBDIR)/crypto_callback.so
+ rm -f $(LIBDIR)/crypto_callback.debug.so
+ rm -f $(LIBDIR)/crypto_callback.valgrind.so
endif
rm -f $(OBJDIR)/crypto.o
rm -f $(OBJDIR)/crypto.debug.o
rm -f $(OBJDIR)/crypto.valgrind.o
+ rm -f $(OBJDIR)/crypto_callback.o
+ rm -f $(OBJDIR)/crypto_callback.debug.o
+ rm -f $(OBJDIR)/crypto_callback.valgrind.o
rm -f core *~
docs:
@@ -136,8 +163,12 @@ release_spec: opt
$(INSTALL_DIR) "$(RELSYSDIR)/priv/obj"
$(INSTALL_DIR) "$(RELSYSDIR)/priv/lib"
$(INSTALL_DATA) $(NIF_MAKEFILE) "$(RELSYSDIR)/priv/obj"
- $(INSTALL_PROGRAM) $(OBJS) "$(RELSYSDIR)/priv/obj"
+ $(INSTALL_PROGRAM) $(CRYPTO_OBJS) "$(RELSYSDIR)/priv/obj"
$(INSTALL_PROGRAM) $(NIF_LIB) "$(RELSYSDIR)/priv/lib"
+ifeq ($(DYNAMIC_CRYPTO_LIB),yes)
+ $(INSTALL_PROGRAM) $(CALLBACK_OBJS) "$(RELSYSDIR)/priv/obj"
+ $(INSTALL_PROGRAM) $(CALLBACK_LIB) "$(RELSYSDIR)/priv/lib"
+endif
release_docs_spec:
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 91ab244620..5dc088dcff 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -53,6 +53,8 @@
#include <openssl/evp.h>
#include <openssl/hmac.h>
+#include "crypto_callback.h"
+
#if OPENSSL_VERSION_NUMBER >= 0x00908000L && !defined(OPENSSL_NO_SHA224) && defined(NID_sha224)\
&& !defined(OPENSSL_NO_SHA256) /* disabled like this in my sha.h (?) */
# define HAVE_SHA224
@@ -125,7 +127,6 @@
/* NIF interface declarations */
static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info);
-static int reload(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info);
static int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info);
static void unload(ErlNifEnv* env, void* priv_data);
@@ -204,17 +205,6 @@ static ERL_NIF_TERM bf_ecb_crypt(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar
static ERL_NIF_TERM blowfish_ofb64_encrypt(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
-/* openssl callbacks */
-#ifdef OPENSSL_THREADS
-static void locking_function(int mode, int n, const char *file, int line);
-static unsigned long id_function(void);
-static struct CRYPTO_dynlock_value* dyn_create_function(const char *file,
- int line);
-static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value* ptr,
- const char *file, int line);
-static void dyn_destroy_function(struct CRYPTO_dynlock_value *ptr,
- const char *file, int line);
-#endif /* OPENSSL_THREADS */
/* helpers */
static void init_digest_types(ErlNifEnv* env);
@@ -325,7 +315,7 @@ static ErlNifFunc nif_funcs[] = {
{"blowfish_ofb64_encrypt", 3, blowfish_ofb64_encrypt}
};
-ERL_NIF_INIT(crypto,nif_funcs,load,reload,upgrade,unload)
+ERL_NIF_INIT(crypto,nif_funcs,load,NULL,upgrade,unload)
#define MD5_CTX_LEN (sizeof(MD5_CTX))
@@ -347,7 +337,6 @@ ERL_NIF_INIT(crypto,nif_funcs,load,reload,upgrade,unload)
#define HMAC_OPAD 0x5c
-static ErlNifRWLock** lock_vec = NULL; /* Static locks used by openssl */
static ERL_NIF_TERM atom_true;
static ERL_NIF_TERM atom_false;
static ERL_NIF_TERM atom_sha;
@@ -374,55 +363,60 @@ static ERL_NIF_TERM atom_none;
static ERL_NIF_TERM atom_notsup;
static ERL_NIF_TERM atom_digest;
+/*
+#define PRINTF_ERR0(FMT) enif_fprintf(stderr, FMT "\n")
+#define PRINTF_ERR1(FMT, A1) enif_fprintf(stderr, FMT "\n", A1)
+*/
+#define PRINTF_ERR0(FMT)
+#define PRINTF_ERR1(FMT,A1)
-static int is_ok_load_info(ErlNifEnv* env, ERL_NIF_TERM load_info)
+#ifdef HAVE_DYNAMIC_CRYPTO_LIB
+static int change_basename(char* buf, int bufsz, const char* newfile)
{
- int i;
- return enif_get_int(env,load_info,&i) && i == 101;
-}
-static void* crypto_alloc(size_t size)
-{
- return enif_alloc(size);
+ char* p = strrchr(buf, '/');
+ p = (p == NULL) ? buf : p + 1;
+
+ if ((p - buf) + strlen(newfile) >= bufsz) {
+ PRINTF_ERR0("CRYPTO: lib name too long");
+ return 0;
+ }
+ strcpy(p, newfile);
+ return 1;
}
-static void* crypto_realloc(void* ptr, size_t size)
+
+static void error_handler(void* null, const char* errstr)
{
- return enif_realloc(ptr, size);
-}
-static void crypto_free(void* ptr)
-{
- enif_free(ptr);
+ PRINTF_ERR1("CRYPTO LOADING ERROR: '%s'", errstr);
}
+#endif /* HAVE_DYNAMIC_CRYPTO_LIB */
-static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
+static int init(ErlNifEnv* env, ERL_NIF_TERM load_info)
{
ErlNifSysInfo sys_info;
- CRYPTO_set_mem_functions(crypto_alloc, crypto_realloc, crypto_free);
-
- if (!is_ok_load_info(env, load_info)) {
- return -1;
+ get_crypto_callbacks_t* funcp;
+ struct crypto_callbacks* ccb;
+ int nlocks = 0;
+ int tpl_arity;
+ const ERL_NIF_TERM* tpl_array;
+ int vernum;
+ char lib_buf[1000];
+
+ /* load_info: {201, "/full/path/of/this/library"} */
+ if (!enif_get_tuple(env, load_info, &tpl_arity, &tpl_array)
+ || tpl_arity != 2
+ || !enif_get_int(env, tpl_array[0], &vernum)
+ || vernum != 201
+ || enif_get_string(env, tpl_array[1], lib_buf, sizeof(lib_buf), ERL_NIF_LATIN1) <= 0) {
+
+ PRINTF_ERR1("CRYPTO: Invalid load_info '%T'", load_info);
+ return 0;
}
-
-#ifdef OPENSSL_THREADS
- enif_system_info(&sys_info, sizeof(sys_info));
-
- if (sys_info.scheduler_threads > 1) {
- int i;
- lock_vec = enif_alloc(CRYPTO_num_locks()*sizeof(*lock_vec));
- if (lock_vec==NULL) return -1;
- memset(lock_vec,0,CRYPTO_num_locks()*sizeof(*lock_vec));
-
- for (i=CRYPTO_num_locks()-1; i>=0; --i) {
- lock_vec[i] = enif_rwlock_create("crypto_stat");
- if (lock_vec[i]==NULL) return -1;
- }
- CRYPTO_set_locking_callback(locking_function);
- CRYPTO_set_id_callback(id_function);
- CRYPTO_set_dynlock_create_callback(dyn_create_function);
- CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
- CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);
+ if (library_refc > 0) {
+ /* Repeated loading of this library (module upgrade).
+ * Atoms and callbacks are already set, we are done.
+ */
+ return 1;
}
- /* else no need for locks */
-#endif /* OPENSSL_THREADS */
atom_true = enif_make_atom(env,"true");
atom_false = enif_make_atom(env,"false");
@@ -451,37 +445,75 @@ static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
init_digest_types(env);
- *priv_data = NULL;
- library_refc++;
- return 0;
-}
-
-static int reload(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
-{
- if (*priv_data != NULL) {
- return -1; /* Don't know how to do that */
+#ifdef HAVE_DYNAMIC_CRYPTO_LIB
+ {
+ void* handle;
+ if (!change_basename(lib_buf, sizeof(lib_buf), "crypto_callback")) {
+ return 0;
+ }
+ if (!(handle = enif_dlopen(lib_buf, &error_handler, NULL))) {
+ return 0;
+ }
+ if (!(funcp = (get_crypto_callbacks_t*) enif_dlsym(handle, "get_crypto_callbacks",
+ &error_handler, NULL))) {
+ return 0;
+ }
}
- if (library_refc == 0) {
- /* No support for real library upgrade. The tricky thing is to know
- when to (re)set the callbacks for allocation and locking. */
- return -2;
+#else /* !HAVE_DYNAMIC_CRYPTO_LIB */
+ funcp = &get_crypto_callbacks;
+#endif
+
+#ifdef OPENSSL_THREADS
+ enif_system_info(&sys_info, sizeof(sys_info));
+ if (sys_info.scheduler_threads > 1) {
+ nlocks = CRYPTO_num_locks();
}
- if (!is_ok_load_info(env, load_info)) {
+ /* else no need for locks */
+#endif
+
+ ccb = (*funcp)(nlocks);
+
+ if (!ccb || ccb->sizeof_me != sizeof(*ccb)) {
+ PRINTF_ERR0("Invalid 'crypto_callbacks'");
+ return 0;
+ }
+
+ CRYPTO_set_mem_functions(ccb->crypto_alloc, ccb->crypto_realloc, ccb->crypto_free);
+
+#ifdef OPENSSL_THREADS
+ if (nlocks > 0) {
+ CRYPTO_set_locking_callback(ccb->locking_function);
+ CRYPTO_set_id_callback(ccb->id_function);
+ CRYPTO_set_dynlock_create_callback(ccb->dyn_create_function);
+ CRYPTO_set_dynlock_lock_callback(ccb->dyn_lock_function);
+ CRYPTO_set_dynlock_destroy_callback(ccb->dyn_destroy_function);
+ }
+#endif /* OPENSSL_THREADS */
+ return 1;
+}
+
+static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
+{
+ if (!init(env, load_info)) {
return -1;
}
- return 0;
+
+ *priv_data = NULL;
+ library_refc++;
+ return 0;
}
static int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data,
ERL_NIF_TERM load_info)
{
- int i;
if (*old_priv_data != NULL) {
return -1; /* Don't know how to do that */
}
- i = reload(env,priv_data,load_info);
- if (i != 0) {
- return i;
+ if (*priv_data != NULL) {
+ return -1; /* Don't know how to do that */
+ }
+ if (!init(env, load_info)) {
+ return -1;
}
library_refc++;
return 0;
@@ -489,20 +521,7 @@ static int upgrade(ErlNifEnv* env, void** priv_data, void** old_priv_data,
static void unload(ErlNifEnv* env, void* priv_data)
{
- if (--library_refc <= 0) {
- CRYPTO_cleanup_all_ex_data();
-
- if (lock_vec != NULL) {
- int i;
- for (i=CRYPTO_num_locks()-1; i>=0; --i) {
- if (lock_vec[i] != NULL) {
- enif_rwlock_destroy(lock_vec[i]);
- }
- }
- enif_free(lock_vec);
- }
- }
- /*else NIF library still used by other (new) module code */
+ --library_refc;
}
static ERL_NIF_TERM info_lib(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
@@ -2338,59 +2357,6 @@ static ERL_NIF_TERM blowfish_ofb64_encrypt(ErlNifEnv* env, int argc, const ERL_N
-#ifdef OPENSSL_THREADS /* vvvvvvvvvvvvvvv OPENSSL_THREADS vvvvvvvvvvvvvvvv */
-
-static INLINE void locking(int mode, ErlNifRWLock* lock)
-{
- switch (mode) {
- case CRYPTO_LOCK|CRYPTO_READ:
- enif_rwlock_rlock(lock);
- break;
- case CRYPTO_LOCK|CRYPTO_WRITE:
- enif_rwlock_rwlock(lock);
- break;
- case CRYPTO_UNLOCK|CRYPTO_READ:
- enif_rwlock_runlock(lock);
- break;
- case CRYPTO_UNLOCK|CRYPTO_WRITE:
- enif_rwlock_rwunlock(lock);
- break;
- default:
- ASSERT(!"Invalid lock mode");
- }
-}
-
-/* Callback from openssl for static locking
- */
-static void locking_function(int mode, int n, const char *file, int line)
-{
- ASSERT(n>=0 && n<CRYPTO_num_locks());
-
- locking(mode, lock_vec[n]);
-}
-
-/* Callback from openssl for thread id
- */
-static unsigned long id_function(void)
-{
- return(unsigned long) enif_thread_self();
-}
-
-/* Callbacks for dynamic locking, not used by current openssl version (0.9.8)
- */
-static struct CRYPTO_dynlock_value* dyn_create_function(const char *file, int line) {
- return(struct CRYPTO_dynlock_value*) enif_rwlock_create("crypto_dyn");
-}
-static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value* ptr,const char *file, int line)
-{
- locking(mode, (ErlNifRWLock*)ptr);
-}
-static void dyn_destroy_function(struct CRYPTO_dynlock_value *ptr, const char *file, int line)
-{
- enif_rwlock_destroy((ErlNifRWLock*)ptr);
-}
-
-#endif /* ^^^^^^^^^^^^^^^^^^^^^^ OPENSSL_THREADS ^^^^^^^^^^^^^^^^^^^^^^ */
/* HMAC */
diff --git a/lib/crypto/c_src/crypto_callback.c b/lib/crypto/c_src/crypto_callback.c
new file mode 100644
index 0000000000..81106b4cc2
--- /dev/null
+++ b/lib/crypto/c_src/crypto_callback.c
@@ -0,0 +1,165 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 2012. All Rights Reserved.
+ *
+ * The contents of this file are subject to the Erlang Public License,
+ * Version 1.1, (the "License"); you may not use this file except in
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ */
+
+#include <string.h>
+#include <openssl/opensslconf.h>
+
+#include "erl_nif.h"
+#include "crypto_callback.h"
+
+#ifdef DEBUG
+ # define ASSERT(e) \
+ ((void) ((e) ? 1 : (fprintf(stderr,"Assert '%s' failed at %s:%d\n",\
+ #e, __FILE__, __LINE__), abort(), 0)))
+#else
+ # define ASSERT(e) ((void) 1)
+#endif
+
+#ifdef __GNUC__
+ # define INLINE __inline__
+#elif defined(__WIN32__)
+ # define INLINE __forceinline
+#else
+ # define INLINE
+#endif
+
+#ifdef __WIN32__
+# define DLLEXPORT __declspec(dllexport)
+#else
+# define DLLEXPORT
+#endif
+
+/* to be dlsym'ed */
+DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks);
+
+
+static ErlNifRWLock** lock_vec = NULL; /* Static locks used by openssl */
+
+static void* crypto_alloc(size_t size)
+{
+ return enif_alloc(size);
+}
+static void* crypto_realloc(void* ptr, size_t size)
+{
+ return enif_realloc(ptr, size);
+}
+static void crypto_free(void* ptr)
+{
+ enif_free(ptr);
+}
+
+
+#ifdef OPENSSL_THREADS /* vvvvvvvvvvvvvvv OPENSSL_THREADS vvvvvvvvvvvvvvvv */
+
+#include <openssl/crypto.h>
+
+static INLINE void locking(int mode, ErlNifRWLock* lock)
+{
+ switch (mode) {
+ case CRYPTO_LOCK|CRYPTO_READ:
+ enif_rwlock_rlock(lock);
+ break;
+ case CRYPTO_LOCK|CRYPTO_WRITE:
+ enif_rwlock_rwlock(lock);
+ break;
+ case CRYPTO_UNLOCK|CRYPTO_READ:
+ enif_rwlock_runlock(lock);
+ break;
+ case CRYPTO_UNLOCK|CRYPTO_WRITE:
+ enif_rwlock_rwunlock(lock);
+ break;
+ default:
+ ASSERT(!"Invalid lock mode");
+ }
+}
+
+static void locking_function(int mode, int n, const char *file, int line)
+{
+ ASSERT(n>=0 && n<CRYPTO_num_locks());
+
+ locking(mode, lock_vec[n]);
+}
+
+static unsigned long id_function(void)
+{
+ return (unsigned long) enif_thread_self();
+}
+
+/* Dynamic locking, not used by current openssl version (0.9.8)
+ */
+static struct CRYPTO_dynlock_value* dyn_create_function(const char *file, int line)
+{
+ return (struct CRYPTO_dynlock_value*) enif_rwlock_create("crypto_dyn");
+}
+static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value* ptr,const char *file, int line)
+{
+ locking(mode, (ErlNifRWLock*)ptr);
+}
+static void dyn_destroy_function(struct CRYPTO_dynlock_value *ptr, const char *file, int line)
+{
+ enif_rwlock_destroy((ErlNifRWLock*)ptr);
+}
+
+#endif /* ^^^^^^^^^^^^^^^^^^^^^^ OPENSSL_THREADS ^^^^^^^^^^^^^^^^^^^^^^ */
+
+DLLEXPORT struct crypto_callbacks* get_crypto_callbacks(int nlocks)
+{
+ static int is_initialized = 0;
+ static struct crypto_callbacks the_struct = {
+ sizeof(struct crypto_callbacks),
+
+ &crypto_alloc,
+ &crypto_realloc,
+ &crypto_free,
+
+#ifdef OPENSSL_THREADS
+ &locking_function,
+ &id_function,
+ &dyn_create_function,
+ &dyn_lock_function,
+ &dyn_destroy_function
+#endif /* OPENSSL_THREADS */
+ };
+
+ if (!is_initialized) {
+#ifdef OPENSSL_THREADS
+ if (nlocks > 0) {
+ int i;
+ lock_vec = enif_alloc(nlocks*sizeof(*lock_vec));
+ if (lock_vec==NULL) return NULL;
+ memset(lock_vec, 0, nlocks*sizeof(*lock_vec));
+
+ for (i=nlocks-1; i>=0; --i) {
+ lock_vec[i] = enif_rwlock_create("crypto_stat");
+ if (lock_vec[i]==NULL) return NULL;
+ }
+ }
+#endif
+ is_initialized = 1;
+ }
+ return &the_struct;
+}
+
+#ifdef HAVE_DYNAMIC_CRYPTO_LIB
+/* This is not really a NIF library, but we use ERL_NIF_INIT in order to
+ * get access to the erl_nif API (on Windows).
+ */
+ERL_NIF_INIT(dummy, (ErlNifFunc*)NULL , NULL, NULL, NULL, NULL)
+#endif
+
diff --git a/lib/crypto/c_src/crypto_callback.h b/lib/crypto/c_src/crypto_callback.h
new file mode 100644
index 0000000000..23ecba3e5d
--- /dev/null
+++ b/lib/crypto/c_src/crypto_callback.h
@@ -0,0 +1,46 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 2012. All Rights Reserved.
+ *
+ * The contents of this file are subject to the Erlang Public License,
+ * Version 1.1, (the "License"); you may not use this file except in
+ * compliance with the License. You should have received a copy of the
+ * Erlang Public License along with this software. If not, it can be
+ * retrieved online at http://www.erlang.org/.
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * %CopyrightEnd%
+ */
+
+struct crypto_callbacks
+{
+ size_t sizeof_me;
+
+ void* (*crypto_alloc)(size_t size);
+ void* (*crypto_realloc)(void* ptr, size_t size);
+ void (*crypto_free)(void* ptr);
+
+ /* openssl callbacks */
+ #ifdef OPENSSL_THREADS
+ void (*locking_function)(int mode, int n, const char *file, int line);
+ unsigned long (*id_function)(void);
+ struct CRYPTO_dynlock_value* (*dyn_create_function)(const char *file,
+ int line);
+ void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value* ptr,
+ const char *file, int line);
+ void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *ptr,
+ const char *file, int line);
+ #endif /* OPENSSL_THREADS */
+};
+
+typedef struct crypto_callbacks* get_crypto_callbacks_t(int nlocks);
+
+#ifndef HAVE_DYNAMIC_CRYPTO_LIB
+struct crypto_callbacks* get_crypto_callbacks(int nlocks);
+#endif
+
diff --git a/lib/crypto/doc/src/notes.xml b/lib/crypto/doc/src/notes.xml
index a9f8dd84af..4178ca2b08 100644
--- a/lib/crypto/doc/src/notes.xml
+++ b/lib/crypto/doc/src/notes.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>1999</year><year>2011</year>
+ <year>1999</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 0089e79a4f..21f507f153 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -114,7 +114,7 @@
-on_load(on_load/0).
--define(CRYPTO_NIF_VSN,101).
+-define(CRYPTO_NIF_VSN,201).
on_load() ->
LibBaseName = "crypto",
@@ -140,7 +140,7 @@ on_load() ->
end
end,
Lib = filename:join([PrivDir, "lib", LibName]),
- Status = case erlang:load_nif(Lib, ?CRYPTO_NIF_VSN) of
+ Status = case erlang:load_nif(Lib, {?CRYPTO_NIF_VSN,Lib}) of
ok -> ok;
{error, {load_failed, _}}=Error1 ->
ArchLibDir =
@@ -152,7 +152,7 @@ on_load() ->
[] -> Error1;
_ ->
ArchLib = filename:join([ArchLibDir, LibName]),
- erlang:load_nif(ArchLib, ?CRYPTO_NIF_VSN)
+ erlang:load_nif(ArchLib, {?CRYPTO_NIF_VSN,ArchLib})
end;
Error1 -> Error1
end,
diff --git a/lib/dialyzer/doc/src/notes.xml b/lib/dialyzer/doc/src/notes.xml
index 0c1556308c..f485e4d03b 100644
--- a/lib/dialyzer/doc/src/notes.xml
+++ b/lib/dialyzer/doc/src/notes.xml
@@ -31,6 +31,24 @@
<p>This document describes the changes made to the Dialyzer
application.</p>
+<section><title>Dialyzer 2.5.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>Fix a crash in race condition detection</p> <p>Remove
+ old untested experimental extension</p> <p>Respect
+ {plt_check,false} option when using dialyzer:run/1</p>
+ <p>Fix handling of tuple set remote types appearing in
+ tuple sets</p>
+ <p>
+ Own Id: OTP-10464</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Dialyzer 2.5.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/dialyzer/vsn.mk b/lib/dialyzer/vsn.mk
index 64d05156b1..f344fe0604 100644
--- a/lib/dialyzer/vsn.mk
+++ b/lib/dialyzer/vsn.mk
@@ -1 +1 @@
-DIALYZER_VSN = 2.5.2
+DIALYZER_VSN = 2.5.3
diff --git a/lib/diameter/doc/src/diameter.xml b/lib/diameter/doc/src/diameter.xml
index bc42b75c7a..b7669b760b 100644
--- a/lib/diameter/doc/src/diameter.xml
+++ b/lib/diameter/doc/src/diameter.xml
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY make_ref
+ '<seealso marker="erts:erlang#make_ref-0">erlang:make_ref/0</seealso>'>
+ <!ENTITY transport_module
+ '<seealso marker="diameter_transport">transport module</seealso>'>
+ <!ENTITY dictionary
+ '<seealso marker="diameter_dict">dictionary</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -50,7 +56,7 @@ under the License.
<p>
This module provides the interface with which a user can
implement a Diameter node that sends and receives messages using the
-Diameter protocol as defined in RFC 3588.</p>
+Diameter protocol as defined in &the_rfc;.</p>
<p>
Basic usage consists of creating a representation of a
@@ -67,7 +73,7 @@ Beware the difference between <em>diameter</em> (not capitalised) and
<em>Diameter</em> (capitalised).
The former refers to the Erlang application named diameter whose main
api is defined here, the latter to Diameter protocol in the sense of
-RFC 3588.</p>
+&the_rfc;.</p>
<p>
The diameter application must be started before calling most functions
@@ -91,7 +97,7 @@ in this module.</p>
<tag><c>UTF8String()</c></tag>
<item>
<p>
-Types corresponding to RFC 3588 AVP Data Formats.
+Types corresponding to &the_rfc; AVP Data Formats.
Defined in &dict_data_types;.</p>
<marker id="application_alias"/>
@@ -298,7 +304,7 @@ Has one of the following types.</p>
<item>
<p>
An address list is available to the start function of a
-<seealso marker="diameter_transport">transport module</seealso>, which
+&transport_module;, which
can return a new list for use in the subsequent CER or CEA.
Host-IP-Address need not be specified if the transport start function
returns an address list.</p>
@@ -312,7 +318,7 @@ returns an address list.</p>
Origin-State-Id is optional but will be included in outgoing messages
sent by diameter itself: CER/CEA, DWR/DWA and DPR/DPA.
Setting a value of <c>0</c> (zero) is equivalent to not setting a
-value as documented in RFC 3588.
+value as documented in &the_rfc;.
The function &origin_state_id;
can be used as to retrieve a value that is computed when the diameter
application is started.</p>
@@ -464,7 +470,7 @@ that matches no peer.</p>
<p>
The <c>host</c> and <c>realm</c> filters examine the
outgoing request as passed to &call;,
-assuming that this is a record- or list-valued <c>&app_message;</c>,
+assuming that this is a record- or list-valued <c>&codec_message;</c>,
and that the message contains at most one of each AVP.
If this is not the case then the <c>{host|realm, &dict_DiameterIdentity;}</c>
filters must be used to achieve the desired result.
@@ -529,8 +535,7 @@ connectivity.</p>
<p>
Note that a single <c>up</c>/<c>down</c> event for a given peer
-corresponds to one
-<seealso marker="diameter_app#Mod:peer_up-3">peer_up/peer_down</seealso>
+corresponds to one &app_peer_up;/&app_peer_down;
callback for each of the Diameter applications negotiated during
capablilities exchange.
That is, the event communicates connectivity with the
@@ -677,7 +682,7 @@ info fields of forms other than the above.</p>
The name of a service as passed to &start_service; and with which the
service is identified.
There can be at most one service with a given name on a given node.
-Note that <seealso marker="erts:erlang#make_ref-0">erlang:make_ref/0</seealso>
+Note that &make_ref;
can be used to generate a service name that is somewhat unique.</p>
<marker id="service_opt"/>
@@ -703,8 +708,7 @@ For an outgoing Diameter request, the relevant <c>&application_alias;</c> is
passed to &call;, while for an
incoming request the application identifier in the message
header determines the application, the identifier being specified in
-the application's <seealso marker="diameter_dict">dictionary</seealso>
-file.</p>
+the application's &dictionary; file.</p>
</item>
<tag><c>{restrict_connections, false
@@ -749,7 +753,7 @@ as follows.</p>
(H bsl N) bor (Id band ((1 bsl N) - 1))
</pre>
<p>
-Note that RFC 3588 requires that End-to-End identifiers remain unique
+Note that &the_rfc; requires that End-to-End identifiers remain unique
for a period of at least 4 minutes and that this and the call rate
places a lower bound on the appropriate values of <c>N</c>:
at a rate of <c>R</c> requests per second an <c>N</c>-bit counter
@@ -951,7 +955,7 @@ Tc = &dict_Unsigned32;
</pre>
<p>
-For a connecting transport, the RFC 3588 Tc timer, in milliseconds.
+For a connecting transport, the &the_rfc; Tc timer, in milliseconds.
Note that this timer determines the frequency with which a transport
will attempt to establish a connection with its peer only <em>before</em>
an initial connection is established: once there is an initial
@@ -1125,7 +1129,7 @@ its transports.</p>
<type>
<v>SvcName = &service_name;</v>
<v>App = &application_alias;</v>
-<v>Request = &app_message;</v>
+<v>Request = &codec_message;</v>
<v>Answer = term()</v>
<v>Opt = &call_opt;</v>
</type>
@@ -1618,7 +1622,7 @@ Return the list of started services.</p>
Return a value for a Session-Id AVP.</p>
<p>
-The value has the form required by section 8.8 of RFC 3588.
+The value has the form required by section 8.8 of &the_rfc;.
Ident should be the Origin-Host of the peer from which
the message containing the returned value will be sent.</p>
diff --git a/lib/diameter/doc/src/diameter_app.xml b/lib/diameter/doc/src/diameter_app.xml
index 304c69ebda..f4db625c71 100644
--- a/lib/diameter/doc/src/diameter_app.xml
+++ b/lib/diameter/doc/src/diameter_app.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY message '<seealso marker="#message">message()</seealso>'>
+ <!ENTITY dict
+ '<seealso marker="diameter_dict#MESSAGE_RECORDS">diameter_dict(4)</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -124,39 +127,17 @@ mandatory values as the bare value.</p>
<marker id="message"/>
-<tag><c>message() = record() | list()</c></tag>
+<tag><c>message() = &codec_message;</c></tag>
<item>
<p>
The representation of a Diameter message as passed to
-&mod_call;.
-The record representation is as outlined in
-<seealso
-marker="diameter_dict#MESSAGE_RECORDS">diameter_dict(4)</seealso>:
-a message as defined in a dictionary file is encoded as a record with
-one field for each component AVP.
-Equivalently, a message can also be encoded as a list whose head is
-the atom-valued message name (the record name minus any
-prefix specified in the relevant dictionary file) and whose tail is a
-list of <c>{FieldName, FieldValue}</c> pairs.</p>
-
-<p>
-A third representation allows a message to be specified as a list
-whose head is a <c>#diameter_header{}</c> record and whose tail is a list
-of <c>#diameter_avp{}</c> records.
-This representation is used by diameter itself when relaying requests
-as directed by the return value of a
-&handle_request;
-callback.
-It differs from the other other two in that it bypasses the checks for
-messages that do not agree with their definitions in the dictionary in
-question (since relays agents must handle arbitrary request): messages
-are sent exactly as specified.</p>
+&mod_call; or returned from a &handle_request; callback.</p>
</item>
<marker id="packet"/>
-<tag><c>packet() = #diameter_packet{}</c></tag>
+<tag><c>packet() = &codec_packet;</c></tag>
<item>
<p>
A container for incoming and outgoing Diameter messages that's passed
@@ -505,8 +486,7 @@ The application in which the callback takes place (that is, the
callback module as configured with &mod_start_service;)
is determined by the Application Identifier in the header of the
incoming request message, the selected module being the one
-whose corresponding <seealso
-marker="diameter_dict#MESSAGE_RECORDS">dictionary</seealso> declares
+whose corresponding dictionary declares
itself as defining either the application in question or the Relay
application.</p>
@@ -526,8 +506,7 @@ The argument &packet; has the following signature.</p>
The <c>msg</c> field will be <c>undefined</c> in case the request has
been received in the relay application.
Otherwise it contains the record representing the request as outlined
-in <seealso
-marker="diameter_dict#MESSAGE_RECORDS">diameter_dict(4)</seealso>.</p>
+in &dict;.</p>
<p>
The <c>errors</c> field specifies any Result-Code's identifying errors
@@ -579,7 +558,7 @@ where <c>Avps</c> sets the Origin-Host, Origin-Realm, the specified
Result-Code and (if the request sent one) Session-Id AVP's.</p>
<p>
-Note that RFC 3588 mandates that only answers with a 3xxx series
+Note that &the_rfc; mandates that only answers with a 3xxx series
Result-Code (protocol errors) may set the E bit.
Returning a non-3xxx value in a <c>protocol_error</c> tuple
will cause the request process in question to fail.</p>
diff --git a/lib/diameter/doc/src/diameter_codec.xml b/lib/diameter/doc/src/diameter_codec.xml
new file mode 100644
index 0000000000..4a77d5435b
--- /dev/null
+++ b/lib/diameter/doc/src/diameter_codec.xml
@@ -0,0 +1,389 @@
+<?xml version="1.0" encoding="latin1" ?>
+<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY records
+ '<seealso marker="diameter_dict#MESSAGE_RECORDS">diameter_dict(4)</seealso>'>
+ <!ENTITY types
+ '<seealso marker="diameter_dict#DATA_TYPES">diameter_dict(4)</seealso>'>
+ <!ENTITY % also SYSTEM "seealso.ent" >
+ <!ENTITY % here SYSTEM "seehere.ent" >
+ %also;
+ %here;
+]>
+
+<erlref>
+<header>
+<copyright>
+<year>2012</year>
+<holder>Ericsson AB. All Rights Reserved.</holder>
+</copyright>
+<legalnotice>
+The contents of this file are subject to the Erlang Public License,
+Version 1.1, (the "License"); you may not use this file except in
+compliance with the License. You should have received a copy of the
+Erlang Public License along with this software. If not, it can be
+retrieved online at http://www.erlang.org/.
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+the License for the specific language governing rights and limitations
+under the License.
+
+</legalnotice>
+
+<title>diameter_codec(3)</title>
+<prepared>Anders Svensson</prepared>
+<responsible></responsible>
+<docno></docno>
+<approved></approved>
+<checked></checked>
+<date></date>
+<rev></rev>
+<file>diameter_codec.xml</file>
+</header>
+
+<module>diameter_codec</module>
+<modulesummary>Decode and encode of Diameter messages.</modulesummary>
+
+<description>
+
+<p>
+Incoming Diameter messages are decoded from binary() before being
+communicated to &man_app; callbacks.
+Similarly, outgoing Diameter messages are encoded into binary() before
+being passed to the appropriate &man_transport; module for
+transmission.
+The functions in this module implement this encode/decode.</p>
+
+<note>
+<p>
+Calls to this module are made by diameter itself as a consequence of
+configuration passed to &mod_start_service;.
+The encode/decode functions may also be useful for other purposes (eg.
+test) but the diameter user does not need to call them explicitly when
+sending and receiving messages using &mod_call; and the callback
+interface documented in &man_app;.</p>
+</note>
+
+<p>
+The &header; and &packet; records below
+are defined in diameter.hrl, which can be included as follows.</p>
+
+<pre>
+-include_lib("diameter/include/diameter.hrl").
+</pre>
+
+<p>
+Application-specific records are definied in the hrl
+files resulting from dictionary file compilation.</p>
+
+</description>
+
+<!-- ===================================================================== -->
+
+<section>
+<title>DATA TYPES</title>
+
+<p></p>
+
+<taglist>
+
+<marker id="integers"/>
+
+<tag><c>uint8()&nbsp; = 0..255</c></tag>
+<tag><c>uint24() = 0..16777215</c></tag>
+<tag><c>uint32() = 0..4294967295</c></tag>
+<item>
+<p>
+8-bit, 24-bit and 32-bit integers occurring in Diameter and AVP
+headers.</p>
+</item>
+
+<marker id="avp"/>
+
+<tag><c>avp() = #diameter_avp{}</c></tag>
+<item>
+<p>
+The application-neutral representation of an AVP.
+Primarily intended for use by relay applications that need to handle
+arbitrary Diameter applications.
+A service implementing a specific Diameter application
+(for which it configures a dictionary) can manipulate values of type
+&message; instead.</p>
+
+<p>
+Fields have the following types.</p>
+
+<taglist>
+
+<tag><c>code = uint32()</c></tag>
+<tag><c>is_mandatory = boolean()</c></tag>
+<tag><c>need_encryption = boolean()</c></tag>
+<tag><c>vendor_id = uint32() | undefined</c></tag>
+<item>
+<p>
+Values in the AVP header, corresponding to AVP Code, the M flag, P
+flags and Vendor-ID respectivelty.
+A Vendor-ID other than <c>undefined</c> implies a set V flag.</p>
+</item>
+
+<tag><c>data = iolist()</c></tag>
+<item>
+<p>
+The data bytes of the AVP.</p>
+</item>
+
+<tag><c>name = atom()</c></tag>
+<item>
+<p>
+The name of the AVP as defined in the dictionary file in question, or
+<c>undefined</c> if the AVP is unknown to the dictionary file in
+question.</p>
+</item>
+
+<tag><c>value = term()</c></tag>
+<item>
+<p>
+The decoded value of an AVP.
+Will be <c>undefined</c> on decode if the data bytes could
+not be decoded or the AVP is unknown.
+The type of a decoded value is as document in &types;.</p>
+</item>
+
+<tag><c>type = atom()</c></tag>
+<item>
+<p>
+The type of the AVP as specified in the dictionary file in question
+(or one it inherits).
+Possible types are <c>undefined</c> and the Diameter types:
+<c>OctetString</c>, <c>Integer32</c>, <c>Integer64</c>,
+<c>Unsigned32</c>, <c>Unsigned64</c>, <c>Float32</c>, <c>Float64</c>,
+<c>Grouped</c>, <c>Enumerated</c>, <c>Address</c>, <c>Time</c>,
+<c>UTF8String</c>, <c>DiameterIdentity</c>, <c>DiameterURI</c>,
+<c>IPFilterRule</c> and <c>QoSFilterRule</c>.</p>
+</item>
+
+</taglist>
+
+</item>
+
+<marker id="dictionary"/>
+
+<tag><c>dictionary() = module()</c></tag>
+<item>
+
+<p>
+The name of a generated dictionary module as generated by &man_compile;
+or &make_codec;.
+The interface provided by a dictionary module is an
+implementation detail that may change.</p>
+</item>
+
+<marker id="header"/>
+
+<tag><c>header() = #diameter_header{}</c></tag>
+<item>
+<p>
+The record representation of the Diameter header.
+Values in a &packet; returned by &decode; are as extracted from the
+incoming message.
+Values set in an &packet; passed to &encode; are preserved in the
+encoded binary(), with the exception of <c>length</c>, <c>cmd_code</c>
+and <c>application_id</c>, all of which are determined by the
+&dictionary; in question.</p>
+
+<note>
+<p>
+It is not necessary to set header fields explicitly in outgoing
+messages as diameter itself will set appropriate values.
+Setting inappropriate values can be useful for test purposes.</p>
+</note>
+
+<p>
+Fields have the following types.</p>
+
+<taglist>
+
+<tag><c>version = uint8()</c></tag>
+<tag><c>length = uint24()</c></tag>
+<tag><c>cmd_code = uint24()</c></tag>
+<tag><c>application_id = uint32()</c></tag>
+<tag><c>hop_by_hop_id = uint32()</c></tag>
+<tag><c>end_to_end_id = uint32()</c></tag>
+<item>
+<p>
+Values of the Version, Message Length, Command-Code, Application-ID,
+Hop-by-Hop Identifier and End-to-End Identifier fields of the Diameter
+header.</p>
+</item>
+
+<tag><c>is_request = boolean()</c></tag>
+<tag><c>is_proxiable = boolean()</c></tag>
+<tag><c>is_error = boolean()</c></tag>
+<tag><c>is_retransmitted = boolean()</c></tag>
+<item>
+<p>
+Values correspoding to the R(equest), P(roxiable), E(rror)
+and T(Potentially re-transmitted message) flags of the Diameter
+header.</p>
+</item>
+
+</taglist>
+
+</item>
+
+<marker id="message"/>
+
+<tag><c>message() = record() | list()</c></tag>
+<item>
+<p>
+The representation of a Diameter message as passed to
+&mod_call; or returned from a &app_handle_request; callback.
+The record representation is as outlined in &records;:
+a message as defined in a dictionary file is encoded as a record with
+one field for each component AVP.
+Equivalently, a message can also be encoded as a list whose head is
+the atom-valued message name (as specified in the relevant dictionary
+file) and whose tail is a list of <c>{AvpName, AvpValue}</c> pairs.</p>
+
+<p>
+Another list-valued representation allows a message to be specified
+as a list whose head is a &header; and whose tail is an &avp; list.
+This representation is used by diameter itself when relaying requests
+as directed by the return value of a &app_handle_request; callback.
+It differs from the other other two in that it bypasses the checks for
+messages that do not agree with their definitions in the dictionary in
+question: messages are sent exactly as specified.</p>
+
+</item>
+
+<marker id="packet"/>
+
+<tag><c>packet() = #diameter_packet{}</c></tag>
+<item>
+<p>
+A container for incoming and outgoing Diameter messages.
+Fields have the following types.</p>
+
+<taglist>
+
+<tag><c>header = &header; | undefined</c></tag>
+<item>
+<p>
+The Diameter header of the message.
+Can be (and typically should be) <c>undefined</c> for an outgoing
+message in a non-relay application, in which case diameter provides
+appropriate values.</p>
+</item>
+
+<tag><c>avps = [&avp;] | undefined</c></tag>
+<item>
+<p>
+The AVPs of the message.
+Ignored for an outgoing message if the <c>msg</c> field is set to a
+value other than <c>undefined</c>.</p>
+</item>
+
+<tag><c>msg = &message; | undefined</c></tag>
+<item>
+<p>
+The incoming/outgoing message.
+For an incoming message, a record if the message can be
+decoded in a non-relay application, <c>undefined</c> otherwise.
+For an outgoing message, setting a <c>[&header; | &avp;]</c> list is
+equivalent to setting the <c>header</c> and <c>avps</c> fields to the
+corresponding values.</p>
+
+<warning>
+<p>
+A record-valued <c>msg</c> field does <b>not</b> imply an absence of
+decode errors.
+The <c>errors</c> field should also be examined.</p>
+</warning>
+
+</item>
+
+<tag><c>bin = binary()</c></tag>
+<item>
+<p>
+The incoming message prior to encode or the outgoing message after
+encode.</p>
+</item>
+
+<tag><c>errors = [5000..5999 | {5000..5999, avp()}]</c></tag>
+<item>
+<p>
+Errors detected at decode of an incoming message, as identified by
+a corresponding 5xxx series Result-Code (Permanent Failures).
+For an incoming request, these should be used to formulate an
+appropriate answer as documented for the &app_handle_request;
+callback in &man_app;.
+For an incoming answer, the &mod_application_opt;
+<c>answer_errors</c> determines the behaviour.</p>
+</item>
+
+<tag><c>transport_data = term()</c></tag>
+<item>
+<p>
+An arbitrary term of meaning only to the transport process in
+question, as documented in &man_transport;.</p>
+</item>
+
+</taglist>
+
+</item>
+
+</taglist>
+
+</section>
+
+<!-- ===================================================================== -->
+
+<funcs>
+
+<func>
+<name>decode(Mod, Bin) -> Pkt</name>
+<fsummary>Decode a Diameter message.</fsummary>
+<type>
+<v>Mod = &dictionary;</v>
+<v>Bin = binary()</v>
+<v>Pkt = &packet;</v>
+</type>
+<desc>
+
+<p>
+Decode a Diameter message.</p>
+
+</desc>
+</func>
+
+<func>
+<name>encode(Mod, Msg) -> Pkt</name>
+<fsummary>Encode a Diameter message.</fsummary>
+<type>
+<v>Mod = &dictionary;</v>
+<v>Msg = &message; | &packet;</v>
+<v>Pkt = &packet;</v>
+</type>
+<desc>
+
+<p>
+Encode a Diameter message.
+</p>
+
+</desc>
+</func>
+
+</funcs>
+
+<!-- ===================================================================== -->
+<!-- ===================================================================== -->
+
+<section>
+<title>SEE ALSO</title>
+
+<p>
+&man_compile;, &man_app;, &man_dict;, &man_make;</p>
+
+</section>
+
+</erlref>
diff --git a/lib/diameter/doc/src/diameter_compile.xml b/lib/diameter/doc/src/diameter_compile.xml
index eb6de80c11..0bd7ad1789 100644
--- a/lib/diameter/doc/src/diameter_compile.xml
+++ b/lib/diameter/doc/src/diameter_compile.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE comref SYSTEM "comref.dtd" [
+ <!ENTITY dictionary
+ '<seealso marker="diameter_dict">dictionary file</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -36,12 +38,14 @@ supplied.
<description>
<p>
-The diameterc utility is used to compile diameter
-<seealso marker="diameter_dict">dictionary files</seealso>
-into Erlang source.
-The resulting source implements the interface diameter requires
+The diameterc utility is used to compile a diameter
+&dictionary; into Erlang source.
+The resulting source implements the interface diameter required
to encode and decode the dictionary's messages and AVP's.</p>
+<p>
+The module &man_make; provides an alternate compilation interface.</p>
+
</description>
<section>
@@ -52,53 +56,52 @@ to encode and decode the dictionary's messages and AVP's.</p>
<tag><![CDATA[diameterc [<options>] <file>]]></tag>
<item>
<p>
-Compiles a single dictionary file. Valid options are as follows.</p>
-
-<!-- Leave -h/d/v undocumented, except for the usage message from the
- utility itself. -->
-
-<taglist>
-<tag><![CDATA[-o <dir>]]></tag>
-<item>
-<p>
-Specifies the directory into which the generated source should be written.
-Defaults to the current working directory.</p>
-</item>
+Compile a single dictionary file to Erlang source.
+Valid options are as follows.</p>
<tag><![CDATA[-i <dir>]]></tag>
<item>
<p>
-Specifies a directory to add to the code path.
+Prepend the specified directory to the code path.
Use to point at beam files compiled from inherited dictionaries,
-<c>@inherits</c> in a dictionary file creating a beam dependency, not
-an erl/hrl dependency.</p>
+<c>&dict_inherits;</c> in a dictionary file creating a beam
+dependency, not an erl/hrl dependency.</p>
<p>
Multiple <c>-i</c> options can be specified.</p>
</item>
+<taglist>
+<tag><![CDATA[-o <dir>]]></tag>
+<item>
+<p>
+Write generated source to the specified directory.
+Defaults to the current working directory.</p>
+</item>
+
<tag><![CDATA[-E]]></tag>
<tag><![CDATA[-H]]></tag>
<item>
<p>
-Supresses erl and hrl generation, respectively.</p>
+Supress erl and hrl generation, respectively.</p>
</item>
<tag><![CDATA[--name <name>]]></tag>
<tag><![CDATA[--prefix <prefix>]]></tag>
<item>
<p>
-Set <c>@name</c> and <c>@prefix</c> in the dictionary,
-respectively.
+Set <c>&dict_name;</c> or <c>&dict_prefix;</c> to the specified
+string.
Overrides any setting in the file itself.</p>
</item>
<tag><![CDATA[--inherits <dict>]]></tag>
<item>
<p>
-Append an <c>@inherits</c> to the dictionary before compiling.
-Specifying <c>'-'</c> as the dictionary has the effect of clearing any
-previous inherits, causing them to be ignored.</p>
+Append &dict_inherits; of the specified module.
+Specifying <c>"-"</c> has the effect of discarding clearing any
+previous inherits, both in the dictionary file and on the options
+list.</p>
<p>
Multiple <c>--inherits</c> options can be specified.</p>
@@ -127,7 +130,7 @@ Returns 0 on success, non-zero on failure.</p>
<title>SEE ALSO</title>
<p>
-&man_dict;</p>
+&man_make;, &man_dict;</p>
</section>
diff --git a/lib/diameter/doc/src/diameter_dict.xml b/lib/diameter/doc/src/diameter_dict.xml
index 4a6cccc276..8b0687a22e 100644
--- a/lib/diameter/doc/src/diameter_dict.xml
+++ b/lib/diameter/doc/src/diameter_dict.xml
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "fileref.dtd" [
+ <!ENTITY format
+ '<seealso marker="#FILE_FORMAT">FILE FORMAT</seealso>'>
+ <!ENTITY records
+ '<seealso marker="#MESSAGE_RECORDS">MESSAGE RECORDS</seealso>'>
+ <!ENTITY types
+ '<seealso marker="#DATA_TYPES">DATA TYPES</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -45,34 +51,33 @@ under the License.
<description>
<p>
-A diameter service as configured with &mod_start_service;
+A diameter service, as configured with &mod_start_service;,
specifies one or more supported Diameter applications.
Each Diameter application specifies a dictionary module that knows how
to encode and decode its messages and AVPs.
The dictionary module is in turn generated from a file that defines
these messages and AVPs.
-The format of such a file is defined in
-<seealso marker="#FILE_FORMAT">FILE FORMAT</seealso> below.
+The format of such a file is defined in &format; below.
Users add support for their specific applications by creating
dictionary files, compiling them to Erlang modules using
-<seealso marker="diameterc">diameterc</seealso> and configuring the
+either &man_compile; or &man_make; and configuring the
resulting dictionaries modules on a service.</p>
<p>
-The codec generation also results in a hrl file that defines records
-for the messages and grouped AVPs defined for the application, these
-records being what a user of the diameter application sends and receives.
-(Modulo other available formats as discussed in &man_app;.)
+Dictionary module generation also results in a hrl file that defines
+records for the messages and Grouped AVPs defined by the
+dictionary, these records being what a user of the diameter
+application sends and receives, modulo other possible formats as
+discussed in &man_app;.
These records and the underlying Erlang data types corresponding to
-Diameter data formats are discussed in <seealso
-marker="#MESSAGE_RECORDS">MESSAGE RECORDS</seealso> and <seealso
-marker="#DATA_TYPES">DATA TYPES</seealso> respectively.
-The generated hrl also contains defines for the possible values of
+Diameter data formats are discussed in &records; and &types;
+respectively.
+The generated hrl also contains macro definitions for the possible values of
AVPs of type Enumerated.</p>
<p>
The diameter application includes three dictionary modules
-corresponding to applications defined in section 2.4 of RFC 3588:
+corresponding to applications defined in section 2.4 of &the_rfc;:
<c>diameter_gen_base_rfc3588</c> for the Diameter Common Messages
application with application identifier 0,
<c>diameter_gen_accounting</c> for the Diameter Base Accounting
@@ -111,6 +116,8 @@ The order in which sections are specified is unimportant.</p>
<taglist>
+<marker id="id"/>
+
<tag><c>@id Number</c></tag>
<item>
<p>
@@ -134,6 +141,8 @@ Example:</p>
</item>
+<marker id="name"/>
+
<tag><c>@name Mod</c></tag>
<item>
<p>
@@ -155,6 +164,8 @@ Example:</p>
</item>
+<marker id="prefix"/>
+
<tag><c>@prefix Name</c></tag>
<item>
<p>
@@ -178,6 +189,8 @@ Example:</p>
</item>
+<marker id="vendor"/>
+
<tag><c>@vendor Number Name</c></tag>
<item>
<p>
@@ -198,6 +211,8 @@ Example:</p>
</item>
+<marker id="avp_vendor_id"/>
+
<tag><c>@avp_vendor_id Number</c></tag>
<item>
<p>
@@ -218,6 +233,8 @@ Region-Set
</item>
+<marker id="inherits"/>
+
<tag><c>@inherits Mod</c></tag>
<item>
<p>
@@ -241,7 +258,7 @@ is equivalent to using <c>@avp_vendor_id</c> with a copy of the
dictionary's definitions but the former makes for easier reuse.</p>
<p>
-All dictionaries should typically inherit RFC3588 AVPs from
+All dictionaries should typically inherit &the_rfc; AVPs from
<c>diameter_gen_base_rfc3588</c>.</p>
<p>
@@ -253,6 +270,8 @@ Example:</p>
</item>
+<marker id="avp_types"/>
+
<tag><c>@avp_types</c></tag>
<item>
<p>
@@ -263,7 +282,7 @@ The section consists of definitions of the form</p>
<p>
where Code is the integer AVP code, Type identifies an AVP Data Format
-as defined in <seealso marker="#DATA_TYPES">DATA TYPES</seealso> below,
+as defined in section &types; below,
and Flags is a string of V, M and P characters indicating the flags to be
set on an outgoing AVP or a single <c>'-'</c> (minus) character if
none are to be set.</p>
@@ -280,13 +299,13 @@ Requested-Information 353 Enumerated V
<warning>
<p>
-The P flag has been deprecated by the Diameter Maintenance
-and Extensions Working Group of the IETF and should be omitted
-to conform to the current draft standard.</p>
+The P flag has been deprecated by &the_rfc;.</p>
</warning>
</item>
+<marker id="custom_types"/>
+
<tag><c>@custom_types Mod</c></tag>
<item>
<p>
@@ -308,6 +327,8 @@ Framed-IP-Address
</pre>
</item>
+<marker id="codecs"/>
+
<tag><c>@codecs Mod</c></tag>
<item>
<p>
@@ -325,12 +346,14 @@ Framed-IP-Address
</pre>
</item>
+<marker id="messages"/>
+
<tag><c>@messages</c></tag>
<item>
<p>
Defines the messages of the application.
The section content consists of definitions of the form specified in
-section 3.2 of RFC 3588, "Command Code ABNF specification".</p>
+section 3.2 of &the_rfc;, "Command Code Format Specification".</p>
<!-- RFC 4740 RTR/RTA -->
<pre>
@@ -370,13 +393,15 @@ RTA ::= &lt; Diameter Header: 287, PXY >
</item>
+<marker id="grouped"/>
+
<tag><c>@grouped</c></tag>
<item>
<p>
Defines the contents of the AVPs of the application having type
Grouped.
The section content consists of definitions of the form specified in
-section 4.4 of RFC 3588, "Grouped AVP Values".</p>
+section 4.4 of &the_rfc;, "Grouped AVP Values".</p>
<p>
Example:</p>
@@ -395,6 +420,8 @@ Specifying a Vendor-Id in the definition of a grouped AVP is
equivalent to specifying it with <c>@avp_vendor_id</c>.</p>
</item>
+<marker id="enum"/>
+
<tag><c>@enum Name</c></tag>
<item>
<p>
@@ -421,6 +448,8 @@ REMOVE_SIP_SERVER 3
</pre>
</item>
+<marker id="end"/>
+
<tag><c>@end</c></tag>
<item>
<p>
@@ -447,8 +476,8 @@ The hrl generated from a dictionary specification defines records for the
messages and grouped AVPs defined in <c>@messages</c> and
<c>@grouped</c> sections.
For each message or grouped AVP definition, a record is defined whose
-name is the message or AVP name prefixed with any dictionary prefix
-defined with <c>@prefix</c> and whose fields are the names of the AVPs
+name is the message or AVP name, prefixed with any dictionary prefix
+defined with <c>@prefix</c>, and whose fields are the names of the AVPs
contained in the message or grouped AVP in the order specified in the
definition in question.
For example, the grouped AVP</p>
@@ -476,7 +505,7 @@ type and number of times the AVP can occur.
In particular, an AVP which is specified as occurring exactly once is
encoded as a value of the AVP's type while an AVP with any other
specification is encoded as a list of values of the AVP's type.
-The AVP's type is as specified in the AVP definition, the RFC 3588
+The AVP's type is as specified in the AVP definition, the &the_rfc;
types being described below.</p>
<marker id="DATA_TYPES"/>
@@ -489,7 +518,7 @@ types being described below.</p>
<p>
The data formats defined in sections 4.2 ("Basic AVP Data
-Formats") and 4.3 ("Derived AVP Data Formats") of RFC 3588 are encoded
+Formats") and 4.3 ("Derived AVP Data Formats") of &the_rfc; are encoded
as values of the types defined here.
Values are passed to &mod_call;
in a request record when sending a request, returned in a resulting
@@ -564,8 +593,8 @@ where
<p>
Additionally, values that can be encoded are
-limited by way of their encoding as four octets as required by RFC
-3588 with the required extension from RFC 2030.
+limited by way of their encoding as four octets as required by
+&the_rfc; with the required extension from RFC 2030.
In particular, only values between <c>{{1968,1,20},{3,14,8}}</c>
and <c>{{2104,2,26},{9,42,23}}</c> (both inclusive) can be encoded.</p>
@@ -609,7 +638,7 @@ where
On encode, fields port, transport and protocol default to 3868, sctp
and diameter respectively.
The grammar of an OctetString-valued DiameterURI() is as specified in
-section 4.3 of RFC 3588.
+section 4.3 of &the_rfc;.
The record representation is used on decode.</p>
<marker id="Enumerated"/>
@@ -640,7 +669,7 @@ Values of these types are not currently parsed by diameter.</p>
<title>SEE ALSO</title>
<p>
-&man_compile;, &man_main;, &man_app;</p>
+&man_compile;, &man_main;, &man_app;, &man_codec;, &man_make;</p>
</section>
diff --git a/lib/diameter/doc/src/diameter_intro.xml b/lib/diameter/doc/src/diameter_intro.xml
index bc2afbd453..fd578ccf45 100644
--- a/lib/diameter/doc/src/diameter_intro.xml
+++ b/lib/diameter/doc/src/diameter_intro.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="latin1" ?>
-<!DOCTYPE chapter SYSTEM "chapter.dtd">
+<!DOCTYPE chapter SYSTEM "chapter.dtd" [
+ <!ENTITY % also SYSTEM "seealso.ent">
+ %also;
+]>
<chapter>
<header>
@@ -35,7 +38,7 @@ under the License.
<p>
The diameter application is an implementation of the Diameter protocol
-as defined by RFC 3588.
+as defined by &the_rfc;.
It supports arbitrary Diameter applications by way of a
<em>dictionary</em> interface that allows messages and AVP's to be
defined and input into diameter as configuration.
@@ -86,9 +89,9 @@ dictionary module
that provide encode/decode functionality for outgoing/incoming
Diameter messages belonging to the application.
A dictionary module is generated from a <seealso
-marker="diameter_dict">specification file</seealso> using the <seealso
+marker="diameter_dict">dictionary file</seealso> using the <seealso
marker="diameterc">diameterc</seealso> utility.
-Dictionaries for the RFC 3588 Diameter Common Messages, Base
+Dictionaries for the &the_rfc; Diameter Common Messages, Base
Accounting and Relay applications are provided with the diameter
application.</p>
diff --git a/lib/diameter/doc/src/diameter_make.xml b/lib/diameter/doc/src/diameter_make.xml
new file mode 100644
index 0000000000..da6124310e
--- /dev/null
+++ b/lib/diameter/doc/src/diameter_make.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="latin1" ?>
+<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY filename
+ '<seealso marker="kernel:file#type-name">file:name()</seealso>'>
+ <!ENTITY dictionary
+ '<seealso marker="diameter_dict">dictionary file</seealso>'>
+ <!ENTITY % also SYSTEM "seealso.ent" >
+ <!ENTITY % here SYSTEM "seehere.ent" >
+ %also;
+ %here;
+]>
+
+<erlref>
+<header>
+<copyright>
+<year>2012</year>
+<holder>Ericsson AB. All Rights Reserved.</holder>
+</copyright>
+<legalnotice>
+The contents of this file are subject to the Erlang Public License,
+Version 1.1, (the "License"); you may not use this file except in
+compliance with the License. You should have received a copy of the
+Erlang Public License along with this software. If not, it can be
+retrieved online at http://www.erlang.org/.
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+the License for the specific language governing rights and limitations
+under the License.
+
+</legalnotice>
+
+<title>diameter_make(3)</title>
+<prepared>Anders Svensson</prepared>
+<responsible></responsible>
+<docno></docno>
+<approved></approved>
+<checked></checked>
+<date></date>
+<rev></rev>
+<file>diameter_make.xml</file>
+</header>
+
+<module>diameter_make</module>
+<modulesummary>Diameter dictionary compilation.</modulesummary>
+
+<description>
+
+<p>
+The function &codec; is used to compile a diameter
+&dictionary; into Erlang source.
+The resulting source implements the interface diameter required
+to encode and decode the dictionary's messages and AVP's.</p>
+
+<p>
+The utility &man_compile; provides an alternate compilation
+interface.</p>
+
+</description>
+
+<!-- ===================================================================== -->
+
+<funcs>
+
+<func>
+<name>codec(Path::string(), [Opt]) -> ok | {error, Reason}</name>
+<fsummary>Compile a dictionary file into Erlang source.</fsummary>
+<desc>
+
+<p>
+Compile a single dictionary file to Erlang source.
+<c>Opt</c> can have the following types.</p>
+
+<taglist>
+
+<tag><c>{include, Dir::string()}</c></tag>
+<item>
+<p>
+Prepend the specified directory to the code path.
+Use to point at beam files compiled from inherited dictionaries,
+<c>&dict_inherits;</c> in a dictionary file creating a beam
+dependency, not an erl/hrl dependency.</p>
+
+<p>
+Multiple <c>include</c> options can be specified.</p>
+</item>
+
+<tag><c>{outdir, Dir::string()}</c></tag>
+<item>
+<p>
+Write generated source to the specified directory.
+Defaults to the current working directory.</p>
+</item>
+
+<tag><c>{name|prefix, string()}</c></tag>
+<item>
+<p>
+Set <c>&dict_name;</c> or <c>&dict_prefix;</c> to the specified
+string.
+Overrides any setting in the file itself.</p>
+</item>
+
+<tag><c>{inherits, Mod::string()}</c></tag>
+<item>
+<p>
+Append &dict_inherits; of the specified module.
+Specifying <c>"-"</c> has the effect of discarding clearing any
+previous inherits, both in the dictionary file and on the options
+list.</p>
+
+<p>
+Multiple <c>inherits</c> options can be specified.</p>
+</item>
+
+</taglist>
+
+</desc>
+</func>
+
+</funcs>
+
+<!-- ===================================================================== -->
+
+<section>
+<title>BUGS</title>
+
+<p>
+All options are string-valued.
+In particular, it is not currently possible to
+an &dict_inherits; module as an atom() or a path as a &filename;</p>
+
+</section>
+
+<!-- ===================================================================== -->
+
+<section>
+<title>SEE ALSO</title>
+
+<p>
+&man_compile;, &man_dict;</p>
+
+</section>
+
+</erlref>
diff --git a/lib/diameter/doc/src/diameter_sctp.xml b/lib/diameter/doc/src/diameter_sctp.xml
index a023a9bc08..5e3fd5eaf1 100644
--- a/lib/diameter/doc/src/diameter_sctp.xml
+++ b/lib/diameter/doc/src/diameter_sctp.xml
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY gen_sctp '<seealso marker="kernel:gen_sctp">gen_sctp(3)</seealso>'>
+ <!ENTITY gen_sctp_open1
+ '<seealso marker="kernel:gen_sctp#open-1">gen_sctp:open/1</seealso>'>
+ <!ENTITY ip_address
+ '<seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>'>
+ <!ENTITY inet '<seealso marker="kernel:inet">inet(3)</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -43,8 +49,7 @@ under the License.
<description>
<p>
-This module implements diameter transport over SCTP using <seealso
-marker="kernel:gen_sctp">gen_sctp</seealso>.
+This module implements diameter transport over SCTP using &gen_sctp;.
It can be specified as the value of a transport_module option to
&mod_add_transport;
and implements the behaviour documented in
@@ -65,9 +70,9 @@ and implements the behaviour documented in
<v>Type = connect | accept</v>
<v>Ref = &mod_transport_ref;</v>
<v>Svc = #diameter_service{}</v>
-<v>Opt = {raddr, <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>} | {rport, integer()} | term()</v>
+<v>Opt = {raddr, &ip_address;} | {rport, integer()} | term()</v>
<v>Pid = pid()</v>
-<v>LAddr = <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso></v>
+<v>LAddr = &ip_address;</v>
<v>Reason = term()</v>
</type>
<desc>
@@ -84,8 +89,7 @@ unspecified.
More than one <c>raddr</c> option can be specified, in which case the
connecting transport in question attempts each in sequence until
an association is established.
-Remaining options are any accepted by <seealso
-marker="kernel:gen_sctp#open-1">gen_sctp:open/1</seealso>, with the exception
+Remaining options are any accepted by &gen_sctp_open1;, with the exception
of options <c>mode</c>, <c>binary</c>, <c>list</c>, <c>active</c>
and <c>sctp_events</c>.
Note that options <c>ip</c> and <c>port</c> specify the local address
@@ -102,14 +106,12 @@ connecting transport.</p>
<warning>
<p>
An insufficiently large receive buffer may result in a peer having to
-resend incoming messages: set the <seealso
-marker="kernel:inet">inet(3)</seealso> option <c>recbuf</c> to increase
+resend incoming messages: set the &inet; option <c>recbuf</c> to increase
the buffer size.</p>
<p>
An insufficiently large send buffer may result in outgoing messages
-being discarded: set the <seealso
-marker="kernel:inet">inet(3)</seealso> option <c>sndbuf</c> to increase
+being discarded: set the &inet; option <c>sndbuf</c> to increase
the buffer size.</p>
</warning>
@@ -145,10 +147,7 @@ outbound streams.</p>
<title>SEE ALSO</title>
<p>
-&man_main;,
-&man_transport;,
-<seealso marker="kernel:gen_sctp">gen_sctp(3)</seealso>,
-<seealso marker="kernel:inet">inet(3)</seealso></p>
+&man_main;, &man_transport;, &gen_sctp;, &inet;</p>
</section>
diff --git a/lib/diameter/doc/src/diameter_soc.xml b/lib/diameter/doc/src/diameter_soc.xml
index 6b9ef9f756..16f6b9d5bb 100644
--- a/lib/diameter/doc/src/diameter_soc.xml
+++ b/lib/diameter/doc/src/diameter_soc.xml
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="latin1" ?>
-<!DOCTYPE chapter SYSTEM "chapter.dtd">
+<!DOCTYPE chapter SYSTEM "chapter.dtd" [
+ <!ENTITY % also SYSTEM "seealso.ent" >
+ %also;
+]>
<chapter>
<header>
<copyright>
<year>2011</year>
+<year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
@@ -41,38 +45,20 @@ Known points of questionable or non-compliance.</p>
<!-- ===================================================================== -->
<section>
-<title>RFC 3588</title>
+<title>&the_rfc;</title>
<list>
<item>
<p>
-The End-to-End Security framework (section 2.9) isn't implemented
-since it is largely unspecified.
-The document that was to describe it
-(reference [AAACMS]) was abandoned in an uncompleted state several
-years ago and the current draft RFC deprecates the framework,
-including the P Flag in the AVP header.</p>
-</item>
-
-<item>
-<p>
-There is no TLS support over SCTP.
-RFC 3588 requires that a Diameter server support TLS but in
-practise this seems to mean TLS over SCTP since there are limitations
-with running over SCTP: see RFC 6083 (DTLS over SCTP), which is a
-response to RFC 3436 (TLS over SCTP).
-The current RFC 3588 draft acknowledges this by equating
-TLS with TLS/TCP and DTLS/SCTP but we do not yet support DTLS.</p>
+There is no support for DTLS over SCTP.</p>
</item>
<item>
<p>
There is no explicit support for peer discovery (section 5.2).
It can possibly be implemented on top of diameter as is but this is
-probably something that diameter should do.
-The current draft deprecates portions of the original RFC's mechanisms
-however.</p>
+probably something that diameter should do.</p>
</item>
<item>
diff --git a/lib/diameter/doc/src/diameter_tcp.xml b/lib/diameter/doc/src/diameter_tcp.xml
index be8a938115..e3b8c733b7 100644
--- a/lib/diameter/doc/src/diameter_tcp.xml
+++ b/lib/diameter/doc/src/diameter_tcp.xml
@@ -1,5 +1,22 @@
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY gen_tcp_connect3
+ '<seealso marker="kernel:gen_tcp#connect-3">gen_tcp:connect/3</seealso>'>
+ <!ENTITY gen_tcp_listen2
+ '<seealso marker="kernel:gen_tcp#listen-2">gen_tcp:listen/2</seealso>'>
+ <!ENTITY ip_address
+ '<seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>'>
+ <!ENTITY ssl_connect2
+ '<seealso marker="ssl:ssl#connect-2">ssl:connect/2</seealso>'>
+ <!ENTITY ssl_connect3
+ '<seealso marker="ssl:ssl#connect-3">ssl:connect/3</seealso>'>
+ <!ENTITY ssl_accept2
+ '<seealso marker="ssl:ssl#ssl_accept-2">ssl:ssl_accept/2</seealso>'>
+ <!ENTITY ssl_listen2
+ '<seealso marker="ssl:ssl#listen-2">ssl:listen/2</seealso>'>
+ <!ENTITY gen_tcp '<seealso marker="kernel:gen_tcp">gen_tcp(3)</seealso>'>
+ <!ENTITY inet '<seealso marker="kernel:inet">inet(3)</seealso>'>
+ <!ENTITY ssl '<seealso marker="ssl:ssl">ssl(3)</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -43,14 +60,13 @@ under the License.
<description>
<p>
-This module implements diameter transport over TCP using <seealso
-marker="kernel:gen_tcp">gen_tcp</seealso>.
+This module implements diameter transport over TCP using &gen_tcp;.
It can be specified as the value of a <c>transport_module</c> option to
&mod_add_transport;
and implements the behaviour documented in
&man_transport;.
TLS security is supported, both as an upgrade following
-capabilities exchange as specified by RFC 3588 and
+capabilities exchange as specified by &the_rfc; and
at connection establishment as in the current draft standard.</p>
<p>
@@ -74,9 +90,9 @@ before configuring TLS capability on diameter transports.</p>
<v>Svc = #diameter_service{}</v>
<v>Opt = OwnOpt | SslOpt | TcpOpt</v>
<v>Pid = pid()</v>
-<v>LAddr = <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso></v>
+<v>LAddr = &ip_address;</v>
<v>Reason = term()</v>
-<v>OwnOpt = {raddr, <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>}
+<v>OwnOpt = {raddr, &ip_address;}
| {rport, integer()}
| {port, integer()}</v>
<v>SslOpt = {ssl_options, true | list()}</v>
@@ -95,16 +111,12 @@ transport.
Option <c>ssl_options</c> must be specified for a transport
that should support TLS: a value of <c>true</c> results in a
TLS handshake immediately upon connection establishment while
-<c>list()</c> specifies options to be passed to <seealso
-marker="ssl:ssl#connect-2">ssl:connect/2</seealso> or
-<seealso marker="ssl:ssl#ssl_accept-2">ssl:ssl_accept/2</seealso>
+<c>list()</c> specifies options to be passed to &ssl_connect2; or
+&ssl_accept2;
after capabilities exchange if TLS is negotiated.
-Remaining options are any accepted by <seealso
-marker="ssl:ssl#connect-3">ssl:connect/3</seealso> or <seealso
-marker="kernel:gen_tcp#connect-3">gen_tcp:connect/3</seealso> for
-a connecting transport, or <seealso
-marker="ssl:ssl#listen-2">ssl:listen/2</seealso> or <seealso
-marker="kernel:gen_tcp#listen-2">gen_tcp:listen/2</seealso> for
+Remaining options are any accepted by &ssl_connect3; or
+&gen_tcp_connect3; for
+a connecting transport, or &ssl_listen2; or &gen_tcp_listen2; for
a listening transport, depending on whether or not <c>{ssl_options, true}</c>
has been specified.
Options <c>binary</c>,
@@ -150,11 +162,7 @@ The returned local address list has length one.</p>
<title>SEE ALSO</title>
<p>
-&man_main;,
-&man_transport;,
-<seealso marker="kernel:gen_tcp">gen_tcp(3)</seealso>,
-<seealso marker="kernel:inet">inet(3)</seealso>,
-<seealso marker="ssl:ssl">ssl(3)</seealso></p>
+&man_main;, &man_transport;, &gen_tcp;, &inet;, &ssl;</p>
</section>
diff --git a/lib/diameter/doc/src/diameter_transport.xml b/lib/diameter/doc/src/diameter_transport.xml
index 0507af63a8..55b531155f 100644
--- a/lib/diameter/doc/src/diameter_transport.xml
+++ b/lib/diameter/doc/src/diameter_transport.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd" [
+ <!ENTITY message '<seealso marker="#message">message()</seealso>'>
+ <!ENTITY ip_address
+ '<seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>'>
<!ENTITY % also SYSTEM "seealso.ent" >
<!ENTITY % here SYSTEM "seehere.ent" >
%also;
@@ -50,16 +53,49 @@ diameter starts a transport process and a message interface with which
the transport process communicates with the process that starts it (aka its
parent).</p>
-<marker id="start"/>
</description>
<!-- ===================================================================== -->
+<section>
+<title>DATA TYPES</title>
+
+<taglist>
+
+<marker id="message"/>
+
+<tag><c>message() = binary() | &codec_packet;</c></tag>
+<item>
+<p>
+A Diameter message as passed over the transport interface.</p>
+
+<p>
+For an inbound message from a transport process, a &codec_packet; must
+contain the received message in its <c>bin</c> field.
+In the case of an inbound request, any value set in the
+<c>transport_data</c> field will passed back to the transport module
+in the corresponding answer message, unless the sender supplies
+another value.</p>
+
+<p>
+For an outbound message to a transport process, a &codec_packet; has a
+value other than <c>undefined</c> in its <c>transport_data</c> field
+and has the binary() to send in its <c>bin</c> field.</p>
+</item>
+
+</taglist>
+
+</section>
+
+<!-- ===================================================================== -->
+
<funcs>
<func>
<name>Mod:start({Type, Ref}, Svc, Config)
- -> {ok, Pid} | {ok, Pid, LAddrs} | {error, Reason}</name>
+ -> {ok, Pid}
+ | {ok, Pid, LAddrs}
+ | {error, Reason}</name>
<fsummary>Start a transport process.</fsummary>
<type>
<v>Type = connect | accept</v>
@@ -67,7 +103,7 @@ parent).</p>
<v>Svc = #diameter_service{}</v>
<v>Config = term()</v>
<v>Pid = pid()</v>
-<v>LAddrs = [<seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>]</v>
+<v>LAddrs = [&ip_address;]</v>
<v>Reason = term()</v>
</type>
<desc>
@@ -79,8 +115,8 @@ A transport process maintains a connection with a single remote peer.</p>
<p>
<c>Type</c> indicates whether the transport process in question
-is being started for a connecting (<c>connect</c>) or listening
-(<c>accept</c>) transport.
+is being started for a connecting (<c>Type=connect</c>) or listening
+(<c>Type=accept</c>) transport.
In the latter case, transport processes are started as required to
accept connections from multiple peers.</p>
@@ -90,13 +126,12 @@ that has lead to starting of a transport process.</p>
<p>
<c>Svc</c> contains the capabilities passed to &mod_start_service; and
-&mod_add_transport;,
-values passed to the latter overriding those passed to the former.</p>
+&mod_add_transport;, values passed to the latter overriding those
+passed to the former.</p>
<p>
<c>Config</c> is as passed in <c>transport_config</c> tuple in the
-&mod_transport_opt;
-list passed to &mod_add_transport;.</p>
+&mod_transport_opt; list passed to &mod_add_transport;.</p>
<p>
The start function should use the <c>Host-IP-Address</c> list and/or
@@ -114,13 +149,13 @@ it dies.
It should not link to the parent.
It should exit if its transport connection with its peer is lost.</p>
-<marker id="MESSAGES"/>
</desc>
</func>
</funcs>
<!-- ===================================================================== -->
+<marker id="MESSAGES"/>
<section>
<title>MESSAGES</title>
@@ -130,19 +165,15 @@ All messages sent over the transport interface are of the
form <c>{diameter, term()}</c>.</p>
<p>
-A transport process can expect the following messages from
-diameter.</p>
+A transport process can expect messages of the following types from
+its parent.</p>
<taglist>
-<tag><c>{diameter, {send, Packet}}</c></tag>
+<tag><c>{diameter, {send, &message;}}</c></tag>
<item>
<p>
-An outbound Diameter message.
-<c>Packet</c> can be either binary() (the message to be sent)
-or a <c>#diameter_packet{}</c> record whose <c>transport_data</c>
-field contains a value other than undefined and whose <c>bin</c> field
-contains the binary to send.</p>
+An outbound Diameter message.</p>
</item>
<tag><c>{diameter, {close, Pid}}</c></tag>
@@ -185,7 +216,7 @@ TLS.</p>
</taglist>
<p>
-A transport process should send the following messages
+A transport process should send messages of the following types
to its parent.</p>
<taglist>
@@ -208,19 +239,10 @@ Not sent if the transport process has <c>Type=accept</c>.
endpoint to which the transport has connected.</p>
</item>
-<tag><c>{diameter, {recv, Packet}}</c></tag>
+<tag><c>{diameter, {recv, &message;}}</c></tag>
<item>
<p>
-An inbound Diameter message.
-<c>Packet</c> can be either binary() (the received message)
-or a <c>#diameter_packet{}</c> record
-whose <c>bin</c> field contains the received binary().
-Any value (other than <c>undefined</c>) set in
-the <c>transport_data</c> field will be passed back with a
-corresponding answer message in the case that the inbound message is a
-request unless the sender sets another value.
-How <c>transport_data</c> is used/interpreted is up to the
-transport module.</p>
+An inbound Diameter message.</p>
</item>
<tag><c>{diameter, {tls, Ref}}</c></tag>
diff --git a/lib/diameter/doc/src/files.mk b/lib/diameter/doc/src/files.mk
index 89ec1031e6..00ced3d91e 100644
--- a/lib/diameter/doc/src/files.mk
+++ b/lib/diameter/doc/src/files.mk
@@ -26,6 +26,8 @@ XML_REF1_FILES = \
XML_REF3_FILES = \
diameter.xml \
diameter_app.xml \
+ diameter_codec.xml \
+ diameter_make.xml \
diameter_transport.xml \
diameter_tcp.xml \
diameter_sctp.xml
diff --git a/lib/diameter/doc/src/notes.xml b/lib/diameter/doc/src/notes.xml
index b89d84a4f6..d448b01eba 100644
--- a/lib/diameter/doc/src/notes.xml
+++ b/lib/diameter/doc/src/notes.xml
@@ -42,6 +42,163 @@ first.</p>
<!-- ===================================================================== -->
+<section><title>Diameter 1.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ Fix faulty handling of Origin-State-Id and faulty config
+ values.</p>
+ <p>
+ The former was expected in a list despite the
+ documentation requiring (correctly) an integer. A bare
+ value for a list-valued capability was not handled.</p>
+ <p>
+ Own Id: OTP-10440</p>
+ </item>
+ <item>
+ <p>
+ Fix timing of up/down events.</p>
+ <p>
+ Previously, a call to diameter:call/4 following a peer_up
+ callback might incorrectly return {error, no_connection},
+ depending on timing. Both events now follow the
+ corresponding callbacks.</p>
+ <p>
+ Own Id: OTP-10459</p>
+ </item>
+ <item>
+ <p>
+ Make diameter:service_info/2 usable in peer_up, peer_down
+ and pick_peer callbacks.</p>
+ <p>
+ Except for in pick_peer when {call_mutates_state, false},
+ it would previously hang indefinitely.</p>
+ <p>
+ Own Id: OTP-10460</p>
+ </item>
+ <item>
+ <p>
+ Verify that End-to-End and Hop-by-Hop Identifiers in an
+ incoming CEA/DPA match those sent in the corresponding
+ CER/DPR.</p>
+ <p>
+ The values were previously ignored. Answers whose
+ identifiers do not match are handled as unexpected.</p>
+ <p>
+ Own Id: OTP-10565</p>
+ </item>
+ <item>
+ <p>
+ Fix formatting problems in PDF documentation.</p>
+ <p>
+ In particular, text corresponding to links in HTML was
+ omitted in preformatted blocks. There are still issues
+ with indentation but this is not diameter-specific.</p>
+ <p>
+ Own Id: OTP-10583</p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ Let prepare_request, prepare_retransmit and
+ handle_request callbacks return a function to be invoked
+ on outgoing messages after encode.</p>
+ <p>
+ This allows encoded messages to be logged for example.</p>
+ <p>
+ Own Id: OTP-10441</p>
+ </item>
+ <item>
+ <p>
+ Add service_opt() 'restrict_connections' to allow
+ multiple transport connections with the same peer.</p>
+ <p>
+ Own Id: OTP-10443</p>
+ </item>
+ <item>
+ <p>
+ Add service_opt() 'sequence' to allow the masking of a
+ constant onto the topmost bits of End-to-End and
+ Hop-by-Hop identifiers.</p>
+ <p>
+ This allows the same service on different nodes to use
+ distinct values in outgoing request messages.</p>
+ <p>
+ Own Id: OTP-10445</p>
+ </item>
+ <item>
+ <p>
+ Add diameter:service_info(PeerRef) to return the
+ transport_ref() and transport_opt() list of the
+ corresponding transport.</p>
+ <p>
+ This allows easy access to these from diameter_app
+ callbacks that only get peer_ref() as an argument.</p>
+ <p>
+ Own Id: OTP-10470</p>
+ </item>
+ <item>
+ <p>
+ Add reference pages diameter_codec(3) and
+ diameter_make(3).</p>
+ <p>
+ Own Id: OTP-10471</p>
+ </item>
+ <item>
+ <p>
+ Add events for service start and stop.</p>
+ <p>
+ Own Id: OTP-10492</p>
+ </item>
+ <item>
+ <p>
+ Add transport_opt() 'disconnect_cb' to make the sending
+ of DPR configurable.</p>
+ <p>
+ Whether or not DPR should be sent at application stop,
+ service stop or transport removal is determined by the
+ value returned by the callback, as is the
+ Disconnect-Cause and timeout if DPA is not received.</p>
+ <p>
+ Own Id: OTP-10493</p>
+ </item>
+ <item>
+ <p>
+ Add transport_opt() 'capx_timeout' for the timeout
+ associated with non-reception of CER/CEA.</p>
+ <p>
+ Own Id: OTP-10554</p>
+ </item>
+ <item>
+ <p>
+ Allow a handle_request callback to return a
+ #diameter_packet{}.</p>
+ <p>
+ This allows an answer to set transport_data and header
+ fields.</p>
+ <p>
+ Own Id: OTP-10566</p>
+ </item>
+ <item>
+ <p>
+ Update documentation for RFC 6733.</p>
+ <p>
+ RFC 3588 is now obsolete.</p>
+ <p>
+ Own Id: OTP-10568</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Diameter 1.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
@@ -428,7 +585,7 @@ Known issues or limitations:</p>
Some agent-related functionality is not entirely complete.
In particular, support for proxy agents, that advertise specific
Diameter applications but otherwise relay messages in much the same
-way as relay agents (for which a &handle_request;
+way as relay agents (for which a handle_request
callback can return a <c>relay</c> tuple), will be completed in an
upcoming release.
There may also be more explicit support for redirect agents, although
@@ -460,7 +617,7 @@ could likely be expanded upon.</p>
<item>
<p>
-The function &service_info;
+The function diameter:service_info/2
can be used to retrieve information about a started service
(statistics, information about connected peers, etc) but
this is not yet documented and both the input and output may change
diff --git a/lib/diameter/doc/src/ref_man.xml b/lib/diameter/doc/src/ref_man.xml
index 137ce79094..4b99fe716d 100644
--- a/lib/diameter/doc/src/ref_man.xml
+++ b/lib/diameter/doc/src/ref_man.xml
@@ -6,6 +6,7 @@
<header>
<copyright>
<year>2011</year>
+<year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -40,7 +41,9 @@ applications on top of the Diameter protocol. </p>
<xi:include href="diameter.xml"/>
<xi:include href="diameter_compile.xml"/>
<xi:include href="diameter_app.xml"/>
+<xi:include href="diameter_codec.xml"/>
<xi:include href="diameter_dict.xml"/>
+<xi:include href="diameter_make.xml"/>
<xi:include href="diameter_transport.xml"/>
<xi:include href="diameter_tcp.xml"/>
<xi:include href="diameter_sctp.xml"/>
diff --git a/lib/diameter/doc/src/seealso.ent b/lib/diameter/doc/src/seealso.ent
index 6f67630220..4647c42f85 100644
--- a/lib/diameter/doc/src/seealso.ent
+++ b/lib/diameter/doc/src/seealso.ent
@@ -32,6 +32,8 @@ significant.
-->
+<!ENTITY the_rfc 'RFC 6733'>
+
<!-- diameter -->
<!ENTITY mod_add_transport '<seealso marker="diameter#add_transport-2">diameter:add_transport/2</seealso>'>
@@ -77,12 +79,21 @@ significant.
<!ENTITY app_prepare_request '<seealso marker="diameter_app#Mod:prepare_request-3">prepare_request/3</seealso>'>
<!ENTITY app_capabilities '<seealso marker="diameter_app#capabilities">diameter_app:capabilities()</seealso>'>
-<!ENTITY app_message '<seealso marker="diameter_app#message">diameter_app:message()</seealso>'>
-<!ENTITY app_packet '<seealso marker="diameter_app#packet">diameter_app:packet()</seealso>'>
<!ENTITY app_peer '<seealso marker="diameter_app#peer">diameter_app:peer()</seealso>'>
<!ENTITY app_peer_ref '<seealso marker="diameter_app#peer_ref">diameter_app:peer_ref()</seealso>'>
<!ENTITY app_state '<seealso marker="diameter_app#state">diameter_app:state()</seealso>'>
+<!-- diameter_codec -->
+
+<!ENTITY codec_encode '<seealso marker="diameter_codec#encode-2">diameter_codec:encode/2</seealso>'>
+<!ENTITY codec_decode '<seealso marker="diameter_codec#decode-2">diameter_codec:decode/2</seealso>'>
+
+<!ENTITY codec_avp '<seealso marker="diameter_codec#avp">diameter_codec:avp()</seealso>'>
+<!ENTITY codec_header '<seealso marker="diameter_codec#header">diameter_codec:header()</seealso>'>
+<!ENTITY codec_dictionary '<seealso marker="diameter_codec#dictionary">diameter_codec:dictionary()</seealso>'>
+<!ENTITY codec_message '<seealso marker="diameter_codec#message">diameter_codec:message()</seealso>'>
+<!ENTITY codec_packet '<seealso marker="diameter_codec#packet">diameter_codec:packet()</seealso>'>
+
<!-- diameter_dict -->
<!ENTITY dict_data_types '<seealso marker="diameter_dict#DATA_TYPES">diameter_dict(4)</seealso>'>
@@ -95,6 +106,14 @@ significant.
<!ENTITY dict_UTF8String '<seealso marker="diameter_dict#DATA_TYPES">UTF8String()</seealso>'>
<!ENTITY dict_Unsigned32 '<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>'>
+<!ENTITY dict_name '<seealso marker="diameter_dict#name">@name</seealso>'>
+<!ENTITY dict_prefix '<seealso marker="diameter_dict#prefix">@prefix</seealso>'>
+<!ENTITY dict_inherits '<seealso marker="diameter_dict#inherits">@inherits</seealso>'>
+
+<!-- diameter_make -->
+
+<!ENTITY make_codec '<seealso marker="diameter_make#codec-2">diameter_make:codec/2</seealso>'>
+
<!-- diameter_transport -->
<!ENTITY transport_start
@@ -105,8 +124,9 @@ significant.
<!ENTITY man_compile '<seealso marker="diameterc">diameterc(1)</seealso>'>
<!ENTITY man_main '<seealso marker="diameter">diameter(3)</seealso>'>
<!ENTITY man_app '<seealso marker="diameter_app">diameter_app(3)</seealso>'>
+<!ENTITY man_codec '<seealso marker="diameter_codec">diameter_codec(3)</seealso>'>
<!ENTITY man_dict '<seealso marker="diameter_dict">diameter_dict(4)</seealso>'>
-<!ENTITY man_transport
- '<seealso marker="diameter_transport">diameter_transport(3)</seealso>'>
+<!ENTITY man_make '<seealso marker="diameter_make">diameter_make(3)</seealso>'>
+<!ENTITY man_transport '<seealso marker="diameter_transport">diameter_transport(3)</seealso>'>
<!ENTITY man_sctp '<seealso marker="diameter_sctp">diameter_sctp(3)</seealso>'>
<!ENTITY man_tcp '<seealso marker="diameter_tcp">diameter_tcp(3)</seealso>'>
diff --git a/lib/diameter/doc/standard/draft-ietf-dime-capablities-update-07.txt b/lib/diameter/doc/standard/draft-ietf-dime-capablities-update-07.txt
deleted file mode 100644
index bb7ec2d08c..0000000000
--- a/lib/diameter/doc/standard/draft-ietf-dime-capablities-update-07.txt
+++ /dev/null
@@ -1,392 +0,0 @@
-
-
-
-Network Working Group K. Jiao
-Internet-Draft Huawei
-Intended status: Standards Track G. Zorn
-Expires: April 27, 2011 Network Zen
- October 24, 2010
-
-
- The Diameter Capabilities Update Application
- draft-ietf-dime-capablities-update-07
-
-Abstract
-
- This document defines a new Diameter application and associated
- command codes. The Capabilities Update application is intended to
- allow the dynamic update of certain Diameter peer capabilities while
- the peer-to-peer connection is in the open state.
-
-Status of this Memo
-
- This Internet-Draft is submitted in full conformance with the
- provisions of BCP 78 and BCP 79.
-
- Internet-Drafts are working documents of the Internet Engineering
- Task Force (IETF). Note that other groups may also distribute
- working documents as Internet-Drafts. The list of current Internet-
- Drafts is at http://datatracker.ietf.org/drafts/current/.
-
- Internet-Drafts are draft documents valid for a maximum of six months
- and may be updated, replaced, or obsoleted by other documents at any
- time. It is inappropriate to use Internet-Drafts as reference
- material or to cite them other than as "work in progress."
-
- This Internet-Draft will expire on April 27, 2011.
-
-Copyright Notice
-
- Copyright (c) 2010 IETF Trust and the persons identified as the
- document authors. All rights reserved.
-
- This document is subject to BCP 78 and the IETF Trust's Legal
- Provisions Relating to IETF Documents
- (http://trustee.ietf.org/license-info) in effect on the date of
- publication of this document. Please review these documents
- carefully, as they describe your rights and restrictions with respect
- to this document. Code Components extracted from this document must
- include Simplified BSD License text as described in Section 4.e of
- the Trust Legal Provisions and are provided without warranty as
- described in the Simplified BSD License.
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 1]
-
-Internet-Draft Diameter Capabilities Update October 2010
-
-
-Table of Contents
-
- 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3
- 2. Specification of Requirements . . . . . . . . . . . . . . . . . 3
- 3. Diameter Protocol Considerations . . . . . . . . . . . . . . . 3
- 4. Capabilities Update . . . . . . . . . . . . . . . . . . . . . . 3
- 4.1. Command-Code Values . . . . . . . . . . . . . . . . . . . . 4
- 4.1.1. Capabilities-Update-Request . . . . . . . . . . . . . . 5
- 4.1.2. Capabilities-Update-Answer . . . . . . . . . . . . . . 5
- 5. Security Considerations . . . . . . . . . . . . . . . . . . . . 6
- 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 6
- 6.1. Application Identifier . . . . . . . . . . . . . . . . . . 6
- 6.2. Command Codes . . . . . . . . . . . . . . . . . . . . . . . 6
- 7. Contributors . . . . . . . . . . . . . . . . . . . . . . . . . 6
- 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 6
- 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 6
- 9.1. Normative References . . . . . . . . . . . . . . . . . . . 6
- 9.2. Informative References . . . . . . . . . . . . . . . . . . 7
- Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 7
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 2]
-
-Internet-Draft Diameter Capabilities Update October 2010
-
-
-1. Introduction
-
- Capabilities exchange is an important component of the Diameter Base
- Protocol [I-D.ietf-dime-rfc3588bis], allowing peers to exchange
- identities and Diameter capabilities (protocol version number,
- supported Diameter applications, security mechanisms, etc.). As
- defined in RFC 3588, however, the capabilities exchange process takes
- place only once, at the inception of a transport connection between a
- given pair of peers. Therefore, if a peer's capabilities change (due
- to software update, for example), the existing connection(s) must be
- torn down (along with all of the associated user sessions) and
- restarted before the modified capabilities can be advertised.
-
- This document defines a new Diameter application intended to allow
- the dynamic update of a subset of Diameter peer capabilities over an
- existing connection. Because the Capabilities Update application
- specified herein operates over an existing transport connection,
- modification of certain capabilities is prohibited. Specifically,
- modifying the security mechanism in use is not allowed; if the
- security method used between a pair of peers is changed the affected
- connection MUST be restarted.
-
-
-2. Specification of Requirements
-
- The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
- "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
- document are to be interpreted as described in RFC 2119 [RFC2119].
-
-
-3. Diameter Protocol Considerations
-
- This section details the relationship of the Diameter Capabilities
- Update application to the Diameter Base Protocol.
-
- This document specifies Diameter Application-ID <TBD1>. Diameter
- nodes conforming to this specification MUST advertise support by
- including the value <TBD1> in the Auth-Application-Id of the
- Capabilities-Exchange-Request (CER) and Capabilities-Exchange-Answer
- (CEA) commands [I-D.ietf-dime-rfc3588bis].
-
-
-4. Capabilities Update
-
- When the capabilities of a Diameter node conforming to this
- specification change, it MUST notify all of the nodes with which it
- has an open transport connection and which have also advertised
- support for the Capabilities Update application using the
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 3]
-
-Internet-Draft Diameter Capabilities Update October 2010
-
-
- Capabilities-Update-Request (CUR) message (Section 4.1.1). This
- message allows the update of a peer's capabilities (supported
- Diameter applications, etc.).
-
- A Diameter node only issues a given command to those peers that have
- advertised support for the Diameter application that defines the
- command; a Diameter node must cache the supported applications in
- order to ensure that unrecognized commands and/or Attribute-Value
- Pairs (AVPs) are not unnecessarily sent to a peer.
-
- The receiver of the CUR MUST determine common applications by
- computing the intersection of its own set of supported Application Id
- against all of the application identifier AVPs (Auth-Application-Id,
- Acct-Application-Id and Vendor-Specific- Application-Id) present in
- the CUR. The value of the Vendor-Id AVP in the Vendor-Specific-
- Application-Id MUST NOT be used during computation.
-
- If the receiver of a CUR does not have any applications in common
- with the sender then it MUST return a Capabilities-Update-Answer
- (CUA) (Section 4.1.2) with the Result-Code AVP set to
- DIAMETER_NO_COMMON_APPLICATION [I-D.ietf-dime-rfc3588bis], and SHOULD
- disconnect the transport layer connection; however, if active
- sessions are using the connection, peers MAY delay disconnection
- until the sessions can be redirected or gracefully terminated. Note
- that receiving a CUA from a peer advertising itself as a Relay (see
- [I-D.ietf-dime-rfc3588bis], Section 2.4) MUST be interpreted as
- having common applications with the peer.
-
- As for CER/CEA messages, the CUR and CUA messages MUST NOT be
- proxied, redirected or relayed.
-
- Even though the CUR/CUA messages cannot be proxied, it is still
- possible for an upstream agent to receive a message for which there
- are no peers available to handle the application that corresponds to
- the Command-Code. This could happen if, for example, the peers are
- too busy or down. In such instances, the 'E' bit MUST be set in the
- answer message with the Result-Code AVP set to
- DIAMETER_UNABLE_TO_DELIVER to inform the downstream peer to take
- action (e.g., re-routing requests to an alternate peer).
-
-4.1. Command-Code Values
-
- This section defines Command-Code [I-D.ietf-dime-rfc3588bis] values
- that MUST be supported by all Diameter implementations conforming to
- this specification. The following Command Codes are defined (using
- modified ABNF [I-D.ietf-dime-rfc3588bis]) in this document:
- Capabilities-Update-Request (CUR, Section 4.1.1) and Capabilities-
- Update-Answer (CUA, Section 4.1.2).
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 4]
-
-Internet-Draft Diameter Capabilities Update October 2010
-
-
-4.1.1. Capabilities-Update-Request
-
- The Capabilities-Update-Request (CUR), indicated by the Command-Code
- set to <CUCC> and the Command Flags' 'R' bit set, is sent to update
- local capabilities. Upon detection of a transport failure, this
- message MUST NOT be sent to an alternate peer.
-
- When Diameter is run over the Stream Control Transmission Protocol
- [RFC4960], which allows connections to span multiple interfaces and
- multiple IP addresses, the Capabilities-Update-Request message MUST
- contain one Host-IP-Address AVP for each potential IP address that
- may be locally used when transmitting Diameter messages.
-
- Message Format
-
- <CUR> ::= < Diameter Header: <CUCC>, REQ >
- { Origin-Host }
- { Origin-Realm }
- 1* { Host-IP-Address }
- { Vendor-Id }
- { Product-Name }
- [ Origin-State-Id ]
- * [ Supported-Vendor-Id ]
- * [ Auth-Application-Id ]
- * [ Acct-Application-Id ]
- * [ Vendor-Specific-Application-Id ]
- [ Firmware-Revision ]
- * [ AVP ]
-
-4.1.2. Capabilities-Update-Answer
-
- The Capabilities-Update-Answer, indicated by the Command-Code set to
- <CUCC> and the Command Flags' 'R' bit cleared, is sent in response to
- a CUR message.
-
- Message Format
-
- <CUA> ::= < Diameter Header: <CUCC> >
- { Origin-Host }
- { Origin-Realm }
- { Result-Code }
- [ Error-Message ]
- * [ AVP ]
-
-
-
-
-
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 5]
-
-Internet-Draft Diameter Capabilities Update October 2010
-
-
-5. Security Considerations
-
- The security considerations applicable to the Diameter Base Protocol
- [I-D.ietf-dime-rfc3588bis] are also applicable to this document.
-
-
-6. IANA Considerations
-
- This section explains the criteria to be used by the IANA for
- assignment of numbers within namespaces used within this document.
-
-6.1. Application Identifier
-
- This specification assigns the value <TBD1> from the Application
- Identifiers namespace [I-D.ietf-dime-rfc3588bis]. See Section 3 for
- the assignment of the namespace in this specification.
-
-6.2. Command Codes
-
- This specification assigns the value <CUCC> from the Command Codes
- namespace [I-D.ietf-dime-rfc3588bis]. See Section 4.1 for the
- assignment of the namespace in this specification.
-
-
-7. Contributors
-
- This document is based upon work done by Tina Tsou.
-
-
-8. Acknowledgements
-
- Thanks to Sebastien Decugis, Niklas Neumann, Subash Comerica, Lionel
- Morand, Dan Romascanu, Dan Harkins and Ravi for helpful review and
- discussion.
-
-
-9. References
-
-9.1. Normative References
-
- [I-D.ietf-dime-rfc3588bis]
- Fajardo, V., Arkko, J., Loughney, J., and G. Zorn,
- "Diameter Base Protocol", draft-ietf-dime-rfc3588bis-25
- (work in progress), September 2010.
-
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
- Requirement Levels", BCP 14, RFC 2119, March 1997.
-
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 6]
-
-Internet-Draft Diameter Capabilities Update October 2010
-
-
-9.2. Informative References
-
- [RFC4960] Stewart, R., "Stream Control Transmission Protocol",
- RFC 4960, September 2007.
-
-
-Authors' Addresses
-
- Jiao Kang
- Huawei Technologies
- Section B1, Huawei Industrial Base
- Bantian, Longgang District
- Shenzhen 518129
- P.R. China
-
- Phone: +86 755 2878-6690
-
-
- Glen Zorn
- Network Zen
- 227/358 Thanon Sanphawut
- Bang Na, Bangkok 10260
- Thailand
-
- Phone: +66 (0) 87-040-4617
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Jiao & Zorn Expires April 27, 2011 [Page 7]
-
diff --git a/lib/diameter/doc/standard/draft-ietf-dime-rfc3588bis-26.txt b/lib/diameter/doc/standard/rfc6733.txt
index 87b9562f93..2f5a477347 100644
--- a/lib/diameter/doc/standard/draft-ietf-dime-rfc3588bis-26.txt
+++ b/lib/diameter/doc/standard/rfc6733.txt
@@ -1,62 +1,72 @@
-DIME V. Fajardo, Ed.
-Internet-Draft Telcordia Technologies
-Obsoletes: 3588 (if approved) J. Arkko
-Intended status: Standards Track Ericsson Research
-Expires: July 24, 2011 J. Loughney
+
+
+
+Internet Engineering Task Force (IETF) V. Fajardo, Ed.
+Request for Comments: 6733 Telcordia Technologies
+Obsoletes: 3588, 5719 J. Arkko
+Category: Standards Track Ericsson Research
+ISSN: 2070-1721 J. Loughney
Nokia Research Center
- G. Zorn
+ G. Zorn, Ed.
Network Zen
- January 20, 2011
+ October 2012
Diameter Base Protocol
- draft-ietf-dime-rfc3588bis-26.txt
Abstract
The Diameter base protocol is intended to provide an Authentication,
- Authorization and Accounting (AAA) framework for applications such as
- network access or IP mobility in both local and roaming situations.
- This document specifies the message format, transport, error
- reporting, accounting and security services used by all Diameter
- applications. The Diameter base protocol as defined in this document
- must be supported by all Diameter implementations.
+ Authorization, and Accounting (AAA) framework for applications such
+ as network access or IP mobility in both local and roaming
+ situations. This document specifies the message format, transport,
+ error reporting, accounting, and security services used by all
+ Diameter applications. The Diameter base protocol as defined in this
+ document obsoletes RFC 3588 and RFC 5719, and it must be supported by
+ all new Diameter implementations.
-Status of this Memo
+Status of This Memo
- This Internet-Draft is submitted in full conformance with the
- provisions of BCP 78 and BCP 79.
+ This is an Internet Standards Track document.
- Internet-Drafts are working documents of the Internet Engineering
- Task Force (IETF). Note that other groups may also distribute
- working documents as Internet-Drafts. The list of current Internet-
- Drafts is at http://datatracker.ietf.org/drafts/current/.
+ This document is a product of the Internet Engineering Task Force
+ (IETF). It represents the consensus of the IETF community. It has
+ received public review and has been approved for publication by the
+ Internet Engineering Steering Group (IESG). Further information on
+ Internet Standards is available in Section 2 of RFC 5741.
+
+ Information about the current status of this document, any errata,
+ and how to provide feedback on it may be obtained at
+ http://www.rfc-editor.org/info/rfc6733.
- Internet-Drafts are draft documents valid for a maximum of six months
- and may be updated, replaced, or obsoleted by other documents at any
- time. It is inappropriate to use Internet-Drafts as reference
- material or to cite them other than as "work in progress."
- This Internet-Draft will expire on July 24, 2011.
-Copyright Notice
- Copyright (c) 2011 IETF Trust and the persons identified as the
- document authors. All rights reserved.
- This document is subject to BCP 78 and the IETF Trust's Legal
- Provisions Relating to IETF Documents
-Fajardo, et al. Expires July 24, 2011 [Page 1]
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 1]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+Copyright Notice
+
+ Copyright (c) 2012 IETF Trust and the persons identified as the
+ document authors. All rights reserved.
+
+ This document is subject to BCP 78 and the IETF Trust's Legal
+ Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
@@ -65,256 +75,303 @@ Internet-Draft Diameter Base Protocol January 2011
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
+ This document may contain material from IETF Documents or IETF
+ Contributions published or made publicly available before November
+ 10, 2008. The person(s) controlling the copyright in some of this
+ material may not have granted the IETF Trust the right to allow
+ modifications of such material outside the IETF Standards Process.
+ Without obtaining an adequate license from the person(s) controlling
+ the copyright in such materials, this document may not be modified
+ outside the IETF Standards Process, and derivative works of it may
+ not be created outside the IETF Standards Process, except to format
+ it for publication as an RFC or to translate it into languages other
+ than English.
Table of Contents
- 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6
- 1.1. Diameter Protocol . . . . . . . . . . . . . . . . . . . . 8
- 1.1.1. Description of the Document Set . . . . . . . . . . . 9
- 1.1.2. Conventions Used in This Document . . . . . . . . . . 10
- 1.1.3. Changes from RFC3588 . . . . . . . . . . . . . . . . 10
- 1.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 12
- 1.3. Approach to Extensibility . . . . . . . . . . . . . . . . 17
- 1.3.1. Defining New AVP Values . . . . . . . . . . . . . . . 18
- 1.3.2. Creating New AVPs . . . . . . . . . . . . . . . . . . 18
- 1.3.3. Creating New Commands . . . . . . . . . . . . . . . . 18
- 1.3.4. Creating New Diameter Applications . . . . . . . . . 19
- 2. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 21
- 2.1. Transport . . . . . . . . . . . . . . . . . . . . . . . . 22
- 2.1.1. SCTP Guidelines . . . . . . . . . . . . . . . . . . . 23
- 2.2. Securing Diameter Messages . . . . . . . . . . . . . . . 24
- 2.3. Diameter Application Compliance . . . . . . . . . . . . . 24
- 2.4. Application Identifiers . . . . . . . . . . . . . . . . . 24
- 2.5. Connections vs. Sessions . . . . . . . . . . . . . . . . 25
- 2.6. Peer Table . . . . . . . . . . . . . . . . . . . . . . . 26
- 2.7. Routing Table . . . . . . . . . . . . . . . . . . . . . . 27
- 2.8. Role of Diameter Agents . . . . . . . . . . . . . . . . . 28
- 2.8.1. Relay Agents . . . . . . . . . . . . . . . . . . . . 29
- 2.8.2. Proxy Agents . . . . . . . . . . . . . . . . . . . . 30
- 2.8.3. Redirect Agents . . . . . . . . . . . . . . . . . . . 31
- 2.8.4. Translation Agents . . . . . . . . . . . . . . . . . 32
- 2.9. Diameter Path Authorization . . . . . . . . . . . . . . . 33
- 3. Diameter Header . . . . . . . . . . . . . . . . . . . . . . . 35
- 3.1. Command Codes . . . . . . . . . . . . . . . . . . . . . . 38
- 3.2. Command Code ABNF specification . . . . . . . . . . . . . 38
- 3.3. Diameter Command Naming Conventions . . . . . . . . . . . 41
- 4. Diameter AVPs . . . . . . . . . . . . . . . . . . . . . . . . 42
- 4.1. AVP Header . . . . . . . . . . . . . . . . . . . . . . . 42
- 4.1.1. Optional Header Elements . . . . . . . . . . . . . . 43
- 4.2. Basic AVP Data Formats . . . . . . . . . . . . . . . . . 44
- 4.3. Derived AVP Data Formats . . . . . . . . . . . . . . . . 45
- 4.3.1. Common Derived AVPs . . . . . . . . . . . . . . . . . 45
- 4.4. Grouped AVP Values . . . . . . . . . . . . . . . . . . . 52
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 2]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- 4.4.1. Example AVP with a Grouped Data type . . . . . . . . 53
- 4.5. Diameter Base Protocol AVPs . . . . . . . . . . . . . . . 56
- 5. Diameter Peers . . . . . . . . . . . . . . . . . . . . . . . 59
- 5.1. Peer Connections . . . . . . . . . . . . . . . . . . . . 59
- 5.2. Diameter Peer Discovery . . . . . . . . . . . . . . . . . 60
- 5.3. Capabilities Exchange . . . . . . . . . . . . . . . . . . 61
- 5.3.1. Capabilities-Exchange-Request . . . . . . . . . . . . 63
- 5.3.2. Capabilities-Exchange-Answer . . . . . . . . . . . . 63
- 5.3.3. Vendor-Id AVP . . . . . . . . . . . . . . . . . . . . 64
- 5.3.4. Firmware-Revision AVP . . . . . . . . . . . . . . . . 64
- 5.3.5. Host-IP-Address AVP . . . . . . . . . . . . . . . . . 64
- 5.3.6. Supported-Vendor-Id AVP . . . . . . . . . . . . . . . 65
- 5.3.7. Product-Name AVP . . . . . . . . . . . . . . . . . . 65
- 5.4. Disconnecting Peer connections . . . . . . . . . . . . . 65
- 5.4.1. Disconnect-Peer-Request . . . . . . . . . . . . . . . 66
- 5.4.2. Disconnect-Peer-Answer . . . . . . . . . . . . . . . 66
- 5.4.3. Disconnect-Cause AVP . . . . . . . . . . . . . . . . 66
- 5.5. Transport Failure Detection . . . . . . . . . . . . . . . 67
- 5.5.1. Device-Watchdog-Request . . . . . . . . . . . . . . . 67
- 5.5.2. Device-Watchdog-Answer . . . . . . . . . . . . . . . 67
- 5.5.3. Transport Failure Algorithm . . . . . . . . . . . . . 68
- 5.5.4. Failover and Failback Procedures . . . . . . . . . . 68
- 5.6. Peer State Machine . . . . . . . . . . . . . . . . . . . 69
- 5.6.1. Incoming connections . . . . . . . . . . . . . . . . 71
- 5.6.2. Events . . . . . . . . . . . . . . . . . . . . . . . 72
- 5.6.3. Actions . . . . . . . . . . . . . . . . . . . . . . . 73
- 5.6.4. The Election Process . . . . . . . . . . . . . . . . 75
- 6. Diameter message processing . . . . . . . . . . . . . . . . . 76
- 6.1. Diameter Request Routing Overview . . . . . . . . . . . . 76
- 6.1.1. Originating a Request . . . . . . . . . . . . . . . . 77
- 6.1.2. Sending a Request . . . . . . . . . . . . . . . . . . 77
- 6.1.3. Receiving Requests . . . . . . . . . . . . . . . . . 78
- 6.1.4. Processing Local Requests . . . . . . . . . . . . . . 78
- 6.1.5. Request Forwarding . . . . . . . . . . . . . . . . . 78
- 6.1.6. Request Routing . . . . . . . . . . . . . . . . . . . 78
- 6.1.7. Predictive Loop Avoidance . . . . . . . . . . . . . . 79
- 6.1.8. Redirecting Requests . . . . . . . . . . . . . . . . 79
- 6.1.9. Relaying and Proxying Requests . . . . . . . . . . . 80
- 6.2. Diameter Answer Processing . . . . . . . . . . . . . . . 82
- 6.2.1. Processing received Answers . . . . . . . . . . . . . 82
- 6.2.2. Relaying and Proxying Answers . . . . . . . . . . . . 82
- 6.3. Origin-Host AVP . . . . . . . . . . . . . . . . . . . . . 83
- 6.4. Origin-Realm AVP . . . . . . . . . . . . . . . . . . . . 83
- 6.5. Destination-Host AVP . . . . . . . . . . . . . . . . . . 83
- 6.6. Destination-Realm AVP . . . . . . . . . . . . . . . . . . 84
- 6.7. Routing AVPs . . . . . . . . . . . . . . . . . . . . . . 84
- 6.7.1. Route-Record AVP . . . . . . . . . . . . . . . . . . 84
- 6.7.2. Proxy-Info AVP . . . . . . . . . . . . . . . . . . . 84
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 3]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- 6.7.3. Proxy-Host AVP . . . . . . . . . . . . . . . . . . . 85
- 6.7.4. Proxy-State AVP . . . . . . . . . . . . . . . . . . . 85
- 6.8. Auth-Application-Id AVP . . . . . . . . . . . . . . . . . 85
- 6.9. Acct-Application-Id AVP . . . . . . . . . . . . . . . . . 85
- 6.10. Inband-Security-Id AVP . . . . . . . . . . . . . . . . . 85
- 6.11. Vendor-Specific-Application-Id AVP . . . . . . . . . . . 86
- 6.12. Redirect-Host AVP . . . . . . . . . . . . . . . . . . . . 87
- 6.13. Redirect-Host-Usage AVP . . . . . . . . . . . . . . . . . 87
- 6.14. Redirect-Max-Cache-Time AVP . . . . . . . . . . . . . . . 88
- 7. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 90
- 7.1. Result-Code AVP . . . . . . . . . . . . . . . . . . . . . 92
- 7.1.1. Informational . . . . . . . . . . . . . . . . . . . . 92
- 7.1.2. Success . . . . . . . . . . . . . . . . . . . . . . . 93
- 7.1.3. Protocol Errors . . . . . . . . . . . . . . . . . . . 93
- 7.1.4. Transient Failures . . . . . . . . . . . . . . . . . 94
- 7.1.5. Permanent Failures . . . . . . . . . . . . . . . . . 95
- 7.2. Error Bit . . . . . . . . . . . . . . . . . . . . . . . . 98
- 7.3. Error-Message AVP . . . . . . . . . . . . . . . . . . . . 99
- 7.4. Error-Reporting-Host AVP . . . . . . . . . . . . . . . . 99
- 7.5. Failed-AVP AVP . . . . . . . . . . . . . . . . . . . . . 99
- 7.6. Experimental-Result AVP . . . . . . . . . . . . . . . . . 100
- 7.7. Experimental-Result-Code AVP . . . . . . . . . . . . . . 100
- 8. Diameter User Sessions . . . . . . . . . . . . . . . . . . . 101
- 8.1. Authorization Session State Machine . . . . . . . . . . . 102
- 8.2. Accounting Session State Machine . . . . . . . . . . . . 107
- 8.3. Server-Initiated Re-Auth . . . . . . . . . . . . . . . . 112
- 8.3.1. Re-Auth-Request . . . . . . . . . . . . . . . . . . . 112
- 8.3.2. Re-Auth-Answer . . . . . . . . . . . . . . . . . . . 113
- 8.4. Session Termination . . . . . . . . . . . . . . . . . . . 114
- 8.4.1. Session-Termination-Request . . . . . . . . . . . . . 115
- 8.4.2. Session-Termination-Answer . . . . . . . . . . . . . 115
- 8.5. Aborting a Session . . . . . . . . . . . . . . . . . . . 116
- 8.5.1. Abort-Session-Request . . . . . . . . . . . . . . . . 116
- 8.5.2. Abort-Session-Answer . . . . . . . . . . . . . . . . 117
- 8.6. Inferring Session Termination from Origin-State-Id . . . 118
- 8.7. Auth-Request-Type AVP . . . . . . . . . . . . . . . . . . 118
- 8.8. Session-Id AVP . . . . . . . . . . . . . . . . . . . . . 119
- 8.9. Authorization-Lifetime AVP . . . . . . . . . . . . . . . 120
- 8.10. Auth-Grace-Period AVP . . . . . . . . . . . . . . . . . . 121
- 8.11. Auth-Session-State AVP . . . . . . . . . . . . . . . . . 121
- 8.12. Re-Auth-Request-Type AVP . . . . . . . . . . . . . . . . 121
- 8.13. Session-Timeout AVP . . . . . . . . . . . . . . . . . . . 122
- 8.14. User-Name AVP . . . . . . . . . . . . . . . . . . . . . . 122
- 8.15. Termination-Cause AVP . . . . . . . . . . . . . . . . . . 122
- 8.16. Origin-State-Id AVP . . . . . . . . . . . . . . . . . . . 124
- 8.17. Session-Binding AVP . . . . . . . . . . . . . . . . . . . 124
- 8.18. Session-Server-Failover AVP . . . . . . . . . . . . . . . 125
- 8.19. Multi-Round-Time-Out AVP . . . . . . . . . . . . . . . . 126
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 4]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- 8.20. Class AVP . . . . . . . . . . . . . . . . . . . . . . . . 126
- 8.21. Event-Timestamp AVP . . . . . . . . . . . . . . . . . . . 126
- 9. Accounting . . . . . . . . . . . . . . . . . . . . . . . . . 127
- 9.1. Server Directed Model . . . . . . . . . . . . . . . . . . 127
- 9.2. Protocol Messages . . . . . . . . . . . . . . . . . . . . 128
- 9.3. Accounting Application Extension and Requirements . . . . 128
- 9.4. Fault Resilience . . . . . . . . . . . . . . . . . . . . 129
- 9.5. Accounting Records . . . . . . . . . . . . . . . . . . . 129
- 9.6. Correlation of Accounting Records . . . . . . . . . . . . 130
- 9.7. Accounting Command-Codes . . . . . . . . . . . . . . . . 131
- 9.7.1. Accounting-Request . . . . . . . . . . . . . . . . . 131
- 9.7.2. Accounting-Answer . . . . . . . . . . . . . . . . . . 132
- 9.8. Accounting AVPs . . . . . . . . . . . . . . . . . . . . . 133
- 9.8.1. Accounting-Record-Type AVP . . . . . . . . . . . . . 133
- 9.8.2. Acct-Interim-Interval AVP . . . . . . . . . . . . . . 134
- 9.8.3. Accounting-Record-Number AVP . . . . . . . . . . . . 135
- 9.8.4. Acct-Session-Id AVP . . . . . . . . . . . . . . . . . 135
- 9.8.5. Acct-Multi-Session-Id AVP . . . . . . . . . . . . . . 135
- 9.8.6. Accounting-Sub-Session-Id AVP . . . . . . . . . . . . 135
- 9.8.7. Accounting-Realtime-Required AVP . . . . . . . . . . 136
- 10. AVP Occurrence Table . . . . . . . . . . . . . . . . . . . . 137
- 10.1. Base Protocol Command AVP Table . . . . . . . . . . . . . 137
- 10.2. Accounting AVP Table . . . . . . . . . . . . . . . . . . 138
- 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 140
- 11.1. Changes to AVP Header Allocation . . . . . . . . . . . . 140
- 11.2. Diameter Header . . . . . . . . . . . . . . . . . . . . . 140
- 11.3. AVP Values . . . . . . . . . . . . . . . . . . . . . . . 140
- 11.3.1. Experimental-Result-Code AVP . . . . . . . . . . . . 140
- 11.4. Diameter TCP, SCTP, TLS/TCP and DTLS/SCTP Port Numbers . 141
- 11.5. S-NAPTR Parameters . . . . . . . . . . . . . . . . . . . 141
- 12. Diameter protocol related configurable parameters . . . . . . 142
- 13. Security Considerations . . . . . . . . . . . . . . . . . . . 143
- 13.1. TLS/TCP and DTLS/SCTP Usage . . . . . . . . . . . . . . . 143
- 13.2. Peer-to-Peer Considerations . . . . . . . . . . . . . . . 144
- 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 145
- 14.1. Normative References . . . . . . . . . . . . . . . . . . 145
- 14.2. Informational References . . . . . . . . . . . . . . . . 147
- Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . 149
- A.1. RFC3588bis . . . . . . . . . . . . . . . . . . . . . . . 149
- A.2. RFC3588 . . . . . . . . . . . . . . . . . . . . . . . . . 150
- Appendix B. S-NAPTR Example . . . . . . . . . . . . . . . . . . 151
- Appendix C. Duplicate Detection . . . . . . . . . . . . . . . . 152
- Appendix D. Internationalized Domain Names . . . . . . . . . . . 154
- Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 155
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 5]
-
-Internet-Draft Diameter Base Protocol January 2011
+ 1. Introduction ....................................................7
+ 1.1. Diameter Protocol ..........................................9
+ 1.1.1. Description of the Document Set ....................10
+ 1.1.2. Conventions Used in This Document ..................11
+ 1.1.3. Changes from RFC 3588 ..............................11
+ 1.2. Terminology ...............................................12
+ 1.3. Approach to Extensibility .................................17
+ 1.3.1. Defining New AVP Values ............................18
+ 1.3.2. Creating New AVPs ..................................18
+ 1.3.3. Creating New Commands ..............................18
+ 1.3.4. Creating New Diameter Applications .................19
+ 2. Protocol Overview ..............................................20
+ 2.1. Transport .................................................22
+ 2.1.1. SCTP Guidelines ....................................23
+ 2.2. Securing Diameter Messages ................................24
+ 2.3. Diameter Application Compliance ...........................24
+ 2.4. Application Identifiers ...................................24
+ 2.5. Connections vs. Sessions ..................................25
+ 2.6. Peer Table ................................................26
+
+
+
+Fajardo, et al. Standards Track [Page 2]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ 2.7. Routing Table .............................................27
+ 2.8. Role of Diameter Agents ...................................28
+ 2.8.1. Relay Agents .......................................30
+ 2.8.2. Proxy Agents .......................................31
+ 2.8.3. Redirect Agents ....................................31
+ 2.8.4. Translation Agents .................................32
+ 2.9. Diameter Path Authorization ...............................33
+ 3. Diameter Header ................................................34
+ 3.1. Command Codes .............................................37
+ 3.2. Command Code Format Specification .........................38
+ 3.3. Diameter Command Naming Conventions .......................40
+ 4. Diameter AVPs ..................................................40
+ 4.1. AVP Header ................................................41
+ 4.1.1. Optional Header Elements ...........................42
+ 4.2. Basic AVP Data Formats ....................................43
+ 4.3. Derived AVP Data Formats ..................................44
+ 4.3.1. Common Derived AVP Data Formats ....................44
+ 4.4. Grouped AVP Values ........................................51
+ 4.4.1. Example AVP with a Grouped Data Type ...............52
+ 4.5. Diameter Base Protocol AVPs ...............................55
+ 5. Diameter Peers .................................................58
+ 5.1. Peer Connections ..........................................58
+ 5.2. Diameter Peer Discovery ...................................59
+ 5.3. Capabilities Exchange .....................................60
+ 5.3.1. Capabilities-Exchange-Request ......................62
+ 5.3.2. Capabilities-Exchange-Answer .......................63
+ 5.3.3. Vendor-Id AVP ......................................63
+ 5.3.4. Firmware-Revision AVP ..............................64
+ 5.3.5. Host-IP-Address AVP ................................64
+ 5.3.6. Supported-Vendor-Id AVP ............................64
+ 5.3.7. Product-Name AVP ...................................64
+ 5.4. Disconnecting Peer Connections ............................64
+ 5.4.1. Disconnect-Peer-Request ............................65
+ 5.4.2. Disconnect-Peer-Answer .............................65
+ 5.4.3. Disconnect-Cause AVP ...............................66
+ 5.5. Transport Failure Detection ...............................66
+ 5.5.1. Device-Watchdog-Request ............................67
+ 5.5.2. Device-Watchdog-Answer .............................67
+ 5.5.3. Transport Failure Algorithm ........................67
+ 5.5.4. Failover and Failback Procedures ...................67
+ 5.6. Peer State Machine ........................................68
+ 5.6.1. Incoming Connections ...............................71
+ 5.6.2. Events .............................................71
+ 5.6.3. Actions ............................................72
+ 5.6.4. The Election Process ...............................74
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 3]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ 6. Diameter Message Processing ....................................74
+ 6.1. Diameter Request Routing Overview .........................74
+ 6.1.1. Originating a Request ..............................75
+ 6.1.2. Sending a Request ..................................76
+ 6.1.3. Receiving Requests .................................76
+ 6.1.4. Processing Local Requests ..........................76
+ 6.1.5. Request Forwarding .................................77
+ 6.1.6. Request Routing ....................................77
+ 6.1.7. Predictive Loop Avoidance ..........................77
+ 6.1.8. Redirecting Requests ...............................78
+ 6.1.9. Relaying and Proxying Requests .....................79
+ 6.2. Diameter Answer Processing ................................80
+ 6.2.1. Processing Received Answers ........................81
+ 6.2.2. Relaying and Proxying Answers ......................81
+ 6.3. Origin-Host AVP ...........................................81
+ 6.4. Origin-Realm AVP ..........................................82
+ 6.5. Destination-Host AVP ......................................82
+ 6.6. Destination-Realm AVP .....................................82
+ 6.7. Routing AVPs ..............................................83
+ 6.7.1. Route-Record AVP ...................................83
+ 6.7.2. Proxy-Info AVP .....................................83
+ 6.7.3. Proxy-Host AVP .....................................83
+ 6.7.4. Proxy-State AVP ....................................83
+ 6.8. Auth-Application-Id AVP ...................................83
+ 6.9. Acct-Application-Id AVP ...................................84
+ 6.10. Inband-Security-Id AVP ...................................84
+ 6.11. Vendor-Specific-Application-Id AVP .......................84
+ 6.12. Redirect-Host AVP ........................................85
+ 6.13. Redirect-Host-Usage AVP ..................................85
+ 6.14. Redirect-Max-Cache-Time AVP ..............................87
+ 7. Error Handling .................................................87
+ 7.1. Result-Code AVP ...........................................89
+ 7.1.1. Informational ......................................90
+ 7.1.2. Success ............................................90
+ 7.1.3. Protocol Errors ....................................90
+ 7.1.4. Transient Failures .................................92
+ 7.1.5. Permanent Failures .................................92
+ 7.2. Error Bit .................................................95
+ 7.3. Error-Message AVP .........................................96
+ 7.4. Error-Reporting-Host AVP ..................................96
+ 7.5. Failed-AVP AVP ............................................96
+ 7.6. Experimental-Result AVP ...................................97
+ 7.7. Experimental-Result-Code AVP ..............................97
+ 8. Diameter User Sessions .........................................98
+ 8.1. Authorization Session State Machine .......................99
+ 8.2. Accounting Session State Machine .........................104
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 4]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ 8.3. Server-Initiated Re-Auth .................................110
+ 8.3.1. Re-Auth-Request ...................................110
+ 8.3.2. Re-Auth-Answer ....................................110
+ 8.4. Session Termination ......................................111
+ 8.4.1. Session-Termination-Request .......................112
+ 8.4.2. Session-Termination-Answer ........................113
+ 8.5. Aborting a Session .......................................113
+ 8.5.1. Abort-Session-Request .............................114
+ 8.5.2. Abort-Session-Answer ..............................114
+ 8.6. Inferring Session Termination from Origin-State-Id .......115
+ 8.7. Auth-Request-Type AVP ....................................116
+ 8.8. Session-Id AVP ...........................................116
+ 8.9. Authorization-Lifetime AVP ...............................117
+ 8.10. Auth-Grace-Period AVP ...................................118
+ 8.11. Auth-Session-State AVP ..................................118
+ 8.12. Re-Auth-Request-Type AVP ................................118
+ 8.13. Session-Timeout AVP .....................................119
+ 8.14. User-Name AVP ...........................................119
+ 8.15. Termination-Cause AVP ...................................120
+ 8.16. Origin-State-Id AVP .....................................120
+ 8.17. Session-Binding AVP .....................................120
+ 8.18. Session-Server-Failover AVP .............................121
+ 8.19. Multi-Round-Time-Out AVP ................................122
+ 8.20. Class AVP ...............................................122
+ 8.21. Event-Timestamp AVP .....................................122
+ 9. Accounting ....................................................123
+ 9.1. Server Directed Model ....................................123
+ 9.2. Protocol Messages ........................................124
+ 9.3. Accounting Application Extension and Requirements ........124
+ 9.4. Fault Resilience .........................................125
+ 9.5. Accounting Records .......................................125
+ 9.6. Correlation of Accounting Records ........................126
+ 9.7. Accounting Command Codes .................................127
+ 9.7.1. Accounting-Request ................................127
+ 9.7.2. Accounting-Answer .................................128
+ 9.8. Accounting AVPs ..........................................129
+ 9.8.1. Accounting-Record-Type AVP ........................129
+ 9.8.2. Acct-Interim-Interval AVP .........................130
+ 9.8.3. Accounting-Record-Number AVP ......................131
+ 9.8.4. Acct-Session-Id AVP ...............................131
+ 9.8.5. Acct-Multi-Session-Id AVP .........................131
+ 9.8.6. Accounting-Sub-Session-Id AVP .....................131
+ 9.8.7. Accounting-Realtime-Required AVP ..................132
+ 10. AVP Occurrence Tables ........................................132
+ 10.1. Base Protocol Command AVP Table .........................133
+ 10.2. Accounting AVP Table ....................................134
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 5]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ 11. IANA Considerations ..........................................135
+ 11.1. AVP Header ..............................................135
+ 11.1.1. AVP Codes ........................................136
+ 11.1.2. AVP Flags ........................................136
+ 11.2. Diameter Header .........................................136
+ 11.2.1. Command Codes ....................................136
+ 11.2.2. Command Flags ....................................137
+ 11.3. AVP Values ..............................................137
+ 11.3.1. Experimental-Result-Code AVP .....................137
+ 11.3.2. Result-Code AVP Values ...........................137
+ 11.3.3. Accounting-Record-Type AVP Values ................137
+ 11.3.4. Termination-Cause AVP Values .....................137
+ 11.3.5. Redirect-Host-Usage AVP Values ...................137
+ 11.3.6. Session-Server-Failover AVP Values ...............137
+ 11.3.7. Session-Binding AVP Values .......................137
+ 11.3.8. Disconnect-Cause AVP Values ......................138
+ 11.3.9. Auth-Request-Type AVP Values .....................138
+ 11.3.10. Auth-Session-State AVP Values ...................138
+ 11.3.11. Re-Auth-Request-Type AVP Values .................138
+ 11.3.12. Accounting-Realtime-Required AVP Values .........138
+ 11.3.13. Inband-Security-Id AVP (code 299) ...............138
+ 11.4. _diameters Service Name and Port Number Registration ....138
+ 11.5. SCTP Payload Protocol Identifiers .......................139
+ 11.6. S-NAPTR Parameters ......................................139
+ 12. Diameter Protocol-Related Configurable Parameters ............139
+ 13. Security Considerations ......................................140
+ 13.1. TLS/TCP and DTLS/SCTP Usage .............................140
+ 13.2. Peer-to-Peer Considerations .............................141
+ 13.3. AVP Considerations ......................................141
+ 14. References ...................................................142
+ 14.1. Normative References ....................................142
+ 14.2. Informative References ..................................144
+ Appendix A. Acknowledgements .....................................147
+ A.1. This Document .............................................147
+ A.2. RFC 3588 ..................................................148
+ Appendix B. S-NAPTR Example ......................................148
+ Appendix C. Duplicate Detection ..................................149
+ Appendix D. Internationalized Domain Names .......................151
+
+
+
+
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 6]
+
+RFC 6733 Diameter Base Protocol October 2012
1. Introduction
- Authentication, Authorization and Accounting (AAA) protocols such as
+ Authentication, Authorization, and Accounting (AAA) protocols such as
TACACS [RFC1492] and RADIUS [RFC2865] were initially deployed to
provide dial-up PPP [RFC1661] and terminal server access. Over time,
AAA support was needed on many new access technologies, the scale and
complexity of AAA networks grew, and AAA was also used on new
- applications (such as voice over IP). This lead to new demands on
- AAA protocols.
+ applications (such as voice over IP). This led to new demands on AAA
+ protocols.
Network access requirements for AAA protocols are summarized in
- [RFC2989]. These include:
-
+ Aboba, et al. [RFC2989]. These include:
Failover
- [RFC2865] does not define failover mechanisms, and as a result,
+ [RFC2865] does not define failover mechanisms and, as a result,
failover behavior differs between implementations. In order to
provide well-defined failover behavior, Diameter supports
- application-layer acknowledgements, and defines failover
- algorithms and the associated state machine. This is described in
- Section 5.5 and [RFC3539].
+ application-layer acknowledgements and defines failover algorithms
+ and the associated state machine.
Transmission-level security
- [RFC2865] defines an application-layer authentication and
- integrity scheme that is required only for use with Response
+ RADIUS [RFC2865] defines an application-layer authentication and
+ integrity scheme that is required only for use with response
packets. While [RFC2869] defines an additional authentication and
integrity mechanism, use is only required during Extensible
- Authentication Protocol (EAP) sessions. While attribute-hiding is
- supported, [RFC2865] does not provide support for per-packet
- confidentiality. In accounting, [RFC2866] assumes that replay
- protection is provided by the backend billing server, rather than
- within the protocol itself.
+ Authentication Protocol (EAP) [RFC3748] sessions. While attribute
+ hiding is supported, [RFC2865] does not provide support for per-
+ packet confidentiality. In accounting, [RFC2866] assumes that
+ replay protection is provided by the backend billing server rather
+ than within the protocol itself.
While [RFC3162] defines the use of IPsec with RADIUS, support for
IPsec is not required. In order to provide universal support for
@@ -322,50 +379,48 @@ Internet-Draft Diameter Base Protocol January 2011
domain AAA deployments, Diameter provides support for TLS/TCP and
DTLS/SCTP. Security is discussed in Section 13.
-
Reliable transport
-
RADIUS runs over UDP, and does not define retransmission behavior;
as a result, reliability varies between implementations. As
described in [RFC2975], this is a major issue in accounting, where
+ packet loss may translate directly into revenue loss. In order to
-Fajardo, et al. Expires July 24, 2011 [Page 6]
-
-Internet-Draft Diameter Base Protocol January 2011
- packet loss may translate directly into revenue loss. In order to
- provide well defined transport behavior, Diameter runs over
- reliable transport mechanisms (TCP, SCTP) as defined in [RFC3539].
+Fajardo, et al. Standards Track [Page 7]
+
+RFC 6733 Diameter Base Protocol October 2012
- Agent support
- [RFC2865] does not provide for explicit support for agents,
- including Proxies, Redirects and Relays. Since the expected
- behavior is not defined, it varies between implementations.
- Diameter defines agent behavior explicitly; this is described in
- Section 2.8.
+ provide well-defined transport behavior, Diameter runs over
+ reliable transport mechanisms (TCP, Stream Control Transmission
+ Protocol (SCTP)) as defined in [RFC3539].
+
+ Agent support
+ RADIUS does not provide for explicit support for agents, including
+ proxies, redirects, and relays. Since the expected behavior is
+ not defined, it varies between implementations. Diameter defines
+ agent behavior explicitly; this is described in Section 2.8.
Server-initiated messages
- While RADIUS server-initiated messages are defined in [RFC5176],
+ While server-initiated messages are defined in RADIUS [RFC5176],
support is optional. This makes it difficult to implement
features such as unsolicited disconnect or re-authentication/
re-authorization on demand across a heterogeneous deployment. To
- tackle this issue, support for server-initiated messages is
+ address this issue, support for server-initiated messages is
mandatory in Diameter.
-
Transition support
While Diameter does not share a common protocol data unit (PDU)
with RADIUS, considerable effort has been expended in enabling
- backward compatibility with RADIUS, so that the two protocols may
+ backward compatibility with RADIUS so that the two protocols may
be deployed in the same network. Initially, it is expected that
Diameter will be deployed within new network devices, as well as
within gateways enabling communication between legacy RADIUS
@@ -373,9 +428,8 @@ Internet-Draft Diameter Base Protocol January 2011
support to be added to legacy networks, by addition of a gateway
or server speaking both RADIUS and Diameter.
- In addition to addressing the above requirements, Diameter also
- provides support for the following:
-
+ In addition to addressing the above requirements, Diameter also
+ provides support for the following:
Capability negotiation
@@ -383,19 +437,19 @@ Internet-Draft Diameter Base Protocol January 2011
a mandatory/non-mandatory flag for attributes. Since RADIUS
clients and servers are not aware of each other's capabilities,
they may not be able to successfully negotiate a mutually
- acceptable service, or in some cases, even be aware of what
+ acceptable service or, in some cases, even be aware of what
service has been implemented. Diameter includes support for error
+ handling (Section 7), capability negotiation (Section 5.3), and
+ mandatory/non-mandatory Attribute-Value Pairs (AVPs)
+ (Section 4.1).
-Fajardo, et al. Expires July 24, 2011 [Page 7]
-
-Internet-Draft Diameter Base Protocol January 2011
- handling (Section 7), capability negotiation (Section 5.3), and
- mandatory/non-mandatory Attribute-Value Pairs (AVPs) (Section
- 4.1).
+Fajardo, et al. Standards Track [Page 8]
+
+RFC 6733 Diameter Base Protocol October 2012
Peer discovery and configuration
@@ -403,7 +457,7 @@ Internet-Draft Diameter Base Protocol January 2011
RADIUS implementations typically require that the name or address
of servers or clients be manually configured, along with the
corresponding shared secrets. This results in a large
- administrative burden, and creates the temptation to reuse the
+ administrative burden and creates the temptation to reuse the
RADIUS shared secret, which can result in major security
vulnerabilities if the Request Authenticator is not globally and
temporally unique as required in [RFC2865]. Through DNS, Diameter
@@ -411,7 +465,6 @@ Internet-Draft Diameter Base Protocol January 2011
of dynamic session keys is enabled via transmission-level
security.
-
Over time, the capabilities of Network Access Server (NAS) devices
have increased substantially. As a result, while Diameter is a
considerably more sophisticated protocol than RADIUS, it remains
@@ -427,42 +480,41 @@ Internet-Draft Diameter Base Protocol January 2011
o Error notification
- o Extensibility, through addition of new applications, commands and
- AVPs (required in [RFC2989]).
+ o Extensibility, required in [RFC2989], through addition of new
+ applications, commands, and AVPs
- o Basic services necessary for applications, such as handling of
+ o Basic services necessary for applications, such as the handling of
user sessions or accounting
All data delivered by the protocol is in the form of AVPs. Some of
these AVP values are used by the Diameter protocol itself, while
others deliver data associated with particular applications that
employ Diameter. AVPs may be arbitrarily added to Diameter messages,
- the only restriction being that the Augmented Backus-Naur Form (ABNF,
- [RFC5234]) Command Code syntax specification (Section 3.2) is
- satisfied. AVPs are used by the base Diameter protocol to support
- the following required features:
+ the only restriction being that the Command Code Format (CCF)
+ specification (Section 3.2) be satisfied. AVPs are used by the base
+ Diameter protocol to support the following required features:
+ o Transporting of user authentication information, for the purposes
+ of enabling the Diameter server to authenticate the user
+ o Transporting of service-specific authorization information,
+ between client and servers, allowing the peers to decide whether a
+ user's access request should be granted
-Fajardo, et al. Expires July 24, 2011 [Page 8]
-
-Internet-Draft Diameter Base Protocol January 2011
- o Transporting of user authentication information, for the purposes
- of enabling the Diameter server to authenticate the user.
+Fajardo, et al. Standards Track [Page 9]
+
+RFC 6733 Diameter Base Protocol October 2012
- o Transporting of service-specific authorization information,
- between client and servers, allowing the peers to decide whether a
- user's access request should be granted.
o Exchanging resource usage information, which may be used for
accounting purposes, capacity planning, etc.
- o Routing, relaying, proxying and redirecting of Diameter messages
- through a server hierarchy.
+ o Routing, relaying, proxying, and redirecting of Diameter messages
+ through a server hierarchy
- The Diameter base protocol satisfies the minimum requirements for an
+ The Diameter base protocol satisfies the minimum requirements for a
AAA protocol, as specified by [RFC2989]. The base protocol may be
used by itself for accounting purposes only, or it may be used with a
Diameter application, such as Mobile IPv4 [RFC4004], or network
@@ -473,16 +525,16 @@ Internet-Draft Diameter Base Protocol January 2011
many applications might provide functionality not provided by
Diameter. Therefore, it is imperative that the designers of new
applications understand their requirements before using Diameter.
- See Section 2.4 for more information on Diameter applications.
+ See Section 1.3.4 for more information on Diameter applications.
Any node can initiate a request. In that sense, Diameter is a peer-
- to-peer protocol. In this document, a Diameter Client is a device at
+ to-peer protocol. In this document, a Diameter client is a device at
the edge of the network that performs access control, such as a
Network Access Server (NAS) or a Foreign Agent (FA). A Diameter
client generates Diameter messages to request authentication,
authorization, and accounting services for the user. A Diameter
agent is a node that does not provide local user authentication or
- authorization services; agents include proxies, redirects and relay
+ authorization services; agents include proxies, redirects, and relay
agents. A Diameter server performs authentication and/or
authorization of the user. A Diameter node may act as an agent for
certain requests while acting as a server for others.
@@ -494,33 +546,33 @@ Internet-Draft Diameter Base Protocol January 2011
The Diameter specification consists of an updated version of the base
protocol specification (this document) and the Transport Profile
- [RFC3539]. This document obsoletes RFC 3588. A summary of the base
- protocol updates included in this document can be found in
- Section 1.1.3.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 9]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ [RFC3539]. This document obsoletes both RFC 3588 and RFC 5719. A
+ summary of the base protocol updates included in this document can be
+ found in Section 1.1.3.
This document defines the base protocol specification for AAA, which
includes support for accounting. There are also a myriad of
applications documents describing applications that use this base
- specification for Authentication, Authorization and Accounting.
+ specification for Authentication, Authorization, and Accounting.
These application documents specify how to use the Diameter protocol
within the context of their application.
+
+
+Fajardo, et al. Standards Track [Page 10]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
The Transport Profile document [RFC3539] discusses transport layer
issues that arise with AAA protocols and recommendations on how to
overcome these issues. This document also defines the Diameter
failover algorithm and state machine.
- Clarifications on the Routing of Diameter Request based on Username
- and the Realm [RFC5729] defines specific behavior on how to route
- request based on the content of the User-Name AVP (Attribute Value
- Pair).
+ "Clarifications on the Routing of Diameter Request Based on the
+ Username and the Realm" [RFC5729] defines specific behavior on how to
+ route requests based on the content of the User-Name AVP (Attribute
+ Value Pair).
1.1.2. Conventions Used in This Document
@@ -528,100 +580,100 @@ Internet-Draft Diameter Base Protocol January 2011
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119].
-1.1.3. Changes from RFC3588
+1.1.3. Changes from RFC 3588
This document obsoletes RFC 3588 but is fully backward compatible
with that document. The changes introduced in this document focus on
- fixing issues that have surfaced during implementation of [RFC3588].
- An overview of some the major changes are given below.
-
- o Deprecated the use of Inband-Security AVP for negotiating
- transport layer security. It has been generally considered that
- bootstrapping of TLS via Inband-Security AVP creates certain
- security risk because it does not completely protect the
- information carried in the CER (Capabilities Exchange Request)/CEA
- (Capabilities Exchange Answer). This version of Diameter adopted
- a common approach of defining a well-known secured port that peers
- should use when communicating via TLS/TCP and DTLS/SCTP. This new
- approach augments the existing Inband-Security negotiation but
- does not completely replace it. The old method is kept for
- backwards compatibility reasons.
+ fixing issues that have surfaced during the implementation of
+ Diameter (RFC 3588). An overview of some the major changes are given
+ below.
+
+ o Deprecated the use of the Inband-Security AVP for negotiating
+ Transport Layer Security (TLS) [RFC5246]. It has been generally
+ considered that bootstrapping of TLS via Inband-Security AVP
+ creates certain security risks because it does not completely
+ protect the information carried in the CER/CEA (Capabilities-
+ Exchange-Request/Capabilities-Exchange-Answer). This version of
+ Diameter adopts the common approach of defining a well-known
+ secured port that peers should use when communicating via TLS/TCP
+ and DTLS/SCTP. This new approach augments the existing in-band
+ security negotiation, but it does not completely replace it. The
+ old method is kept for backward compatibility reasons.
o Deprecated the exchange of CER/CEA messages in the open state.
- This feature was implied in the peer state machine table of
- [RFC3588] but it was not clearly defined anywhere else in that
+ This feature was implied in the peer state machine table of RFC
+ 3588, but it was not clearly defined anywhere else in that
document. As work on this document progressed, it became clear
- that the multiplicity of meaning and use of Application Id AVPs in
+ that the multiplicity of meaning and use of Application-Id AVPs in
the CER/CEA messages (and the messages themselves) is seen as an
+ abuse of the Diameter extensibility rules and thus required
+ simplification. Capabilities exchange in the open state has been
+ re-introduced in a separate specification [RFC6737], which clearly
+ defines new commands for this feature.
-Fajardo, et al. Expires July 24, 2011 [Page 10]
-
-Internet-Draft Diameter Base Protocol January 2011
- abuse of the Diameter extensibility rules and thus required
- simplification. It is assumed that the capabilities exchange in
- the open state will be re-introduced in a separate specification
- which clearly defines new commands for this feature.
+Fajardo, et al. Standards Track [Page 11]
+
+RFC 6733 Diameter Base Protocol October 2012
+
- o Simplified Security Requirements. The use of a secured transport
+ o Simplified security requirements. The use of a secured transport
for exchanging Diameter messages remains mandatory. However, TLS/
- TCP and DTLS/SCTP has become the primary method of securing
- Diameter and IPsec is a secondary alternative. See Section 13 for
- details. The support for the End-to-End security framework
- (E2ESequence AVP and 'P'-bit in the AVP header) has also been
+ TCP and DTLS/SCTP have become the primary methods of securing
+ Diameter with IPsec as a secondary alternative. See Section 13
+ for details. The support for the End-to-End security framework
+ (E2E-Sequence AVP and 'P'-bit in the AVP header) has also been
deprecated.
- o Diameter Extensibility Changes. This includes fixes to the
+ o Changed Diameter extensibility. This includes fixes to the
Diameter extensibility description (Section 1.3 and others) to
better aid Diameter application designers; in addition, the new
specification relaxes the policy with respect to the allocation of
- command codes for vendor-specific uses.
-
- o Application Id Usage. Clarify the proper use of Application Id
- information which can be found in multiple places within a
- Diameter message. This includes correlating Application Ids found
- in the message headers and AVPs. These changes also clearly
- specify the proper Application Id value to use for specific base
- protocol messages (ASR/ASA, STR/STA) as well as clarifying the
- content and use of Vendor-Specific-Application-Id.
-
- o Routing Fixes. This document more clearly specifies what
- information (AVPs and Application Id) can be used for making
+ Command Codes for vendor-specific uses.
+
+ o Clarified Application Id usage. Clarify the proper use of
+ Application Id information, which can be found in multiple places
+ within a Diameter message. This includes correlating Application
+ Ids found in the message headers and AVPs. These changes also
+ clearly specify the proper Application Id value to use for
+ specific base protocol messages (ASR/ASA, STR/STA) as well as
+ clarify the content and use of Vendor-Specific-Application-Id.
+
+ o Clarified routing fixes. This document more clearly specifies
+ what information (AVPs and Application Ids) can be used for making
general routing decisions. A rule for the prioritization of
redirect routing criteria when multiple route entries are found
- via redirects has also been added (See Section 6.13 for details).
+ via redirects has also been added (see Section 6.13).
- o Simplification of Diameter Peer Discovery. The Diameter discovery
+ o Simplified Diameter peer discovery. The Diameter discovery
process now supports only widely used discovery schemes; the rest
have been deprecated (see Section 5.2 for details).
- There are many other many miscellaneous fixes that have been
- introduced in this document that may not be considered significant
- but they are important nonetheless. Examples are removal of obsolete
- types, fixes to command ABNFs, fixes to the state machine,
- clarification of the election process, message validation, fixes to
- Failed-AVP and Result-Code AVP values, etc. A comprehensive list of
- changes is not shown here for practical reasons.
-
-
-
+ There are many other miscellaneous fixes that have been introduced in
+ this document that may not be considered significant, but they have
+ value nonetheless. Examples are removal of obsolete types, fixes to
+ the state machine, clarification of the election process, message
+ validation, fixes to Failed-AVP and Result-Code AVP values, etc. All
+ of the errata filed against RFC 3588 prior to the publication of this
+ document have been addressed. A comprehensive list of changes is not
+ shown here for practical reasons.
+1.2. Terminology
+ AAA
+ Authentication, Authorization, and Accounting.
-Fajardo, et al. Expires July 24, 2011 [Page 11]
-
-Internet-Draft Diameter Base Protocol January 2011
-1.2. Terminology
- AAA
- Authentication, Authorization and Accounting.
+Fajardo, et al. Standards Track [Page 12]
+
+RFC 6733 Diameter Base Protocol October 2012
ABNF
@@ -631,14 +683,12 @@ Internet-Draft Diameter Base Protocol January 2011
is used to define message exchanges in a bi-directional
communications protocol.
-
Accounting
The act of collecting information on resource usage for the
- purpose of capacity planning, auditing, billing or cost
+ purpose of capacity planning, auditing, billing, or cost
allocation.
-
Accounting Record
An accounting record represents a summary of the resource
@@ -647,114 +697,102 @@ Internet-Draft Diameter Base Protocol January 2011
accounting events or accounting events from several devices
serving the same user.
-
Authentication
The act of verifying the identity of an entity (subject).
-
Authorization
The act of determining whether a requesting entity (subject) will
be allowed access to a resource (object).
-
- AVP
+ Attribute-Value Pair (AVP)
The Diameter protocol consists of a header followed by one or more
Attribute-Value-Pairs (AVPs). An AVP includes a header and is
used to encapsulate protocol-specific data (e.g., routing
- information) as well as authentication, authorization or
+ information) as well as authentication, authorization, or
+ accounting information.
+ Command Code Format (CCF)
+ A modified form of ABNF used to define Diameter commands (see
+ Section 3.2).
-Fajardo, et al. Expires July 24, 2011 [Page 12]
-
-Internet-Draft Diameter Base Protocol January 2011
+ Diameter Agent
+ A Diameter Agent is a Diameter node that provides relay, proxy,
+ redirect, or translation services.
- accounting information.
- Diameter Agent
- A Diameter Agent is a Diameter Node that provides either relay,
- proxy, redirect or translation services.
+Fajardo, et al. Standards Track [Page 13]
+
+RFC 6733 Diameter Base Protocol October 2012
Diameter Client
- A Diameter Client is a Diameter Node that supports Diameter client
- applications as well as the base protocol. Diameter Clients are
+ A Diameter client is a Diameter node that supports Diameter client
+ applications as well as the base protocol. Diameter clients are
often implemented in devices situated at the edge of a network and
provide access control services for that network. Typical
- examples of Diameter Clients include the Network Access Server
+ examples of Diameter clients include the Network Access Server
(NAS) and the Mobile IP Foreign Agent (FA).
-
Diameter Node
- A Diameter Node is a host process that implements the Diameter
- protocol, and acts either as a Client, Agent or Server.
-
+ A Diameter node is a host process that implements the Diameter
+ protocol and acts as either a client, an agent, or a server.
Diameter Peer
- If a Diameter Node shares a direct transport connection with
- another Diameter Node, it is a Diameter Peer to that Diameter
- Node.
-
+ Two Diameter nodes sharing a direct TCP or SCTP transport
+ connection are called Diameter peers.
Diameter Server
- A Diameter Server is a Diameter Node that handles authentication,
- authorization and accounting requests for a particular realm. By
- its very nature, a Diameter Server must support Diameter server
+ A Diameter server is a Diameter node that handles authentication,
+ authorization, and accounting requests for a particular realm. By
+ its very nature, a Diameter server must support Diameter server
applications in addition to the base protocol.
-
Downstream
Downstream is used to identify the direction of a particular
- Diameter message from the Home Server towards the Diameter Client.
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 13]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ Diameter message from the home server towards the Diameter client.
Home Realm
A Home Realm is the administrative domain with which the user
maintains an account relationship.
-
Home Server
- A Diameter Server which serves the Home Realm.
-
+ A Diameter server that serves the Home Realm.
- Interim accounting
+ Interim Accounting
An interim accounting message provides a snapshot of usage during
- a user's session. It is typically implemented in order to provide
- for partial accounting of a user's session in the case a device
- reboot or other network problem prevents the delivery of a session
- summary message or session record.
+ a user's session. Typically, it is implemented in order to
+ provide for partial accounting of a user's session in case a
+ device reboot or other network problem prevents the delivery of a
+ session summary message or session record.
+
+
+
+
+Fajardo, et al. Standards Track [Page 14]
+
+RFC 6733 Diameter Base Protocol October 2012
Local Realm
A local realm is the administrative domain providing services to a
user. An administrative domain may act as a local realm for
- certain users, while being a home realm for others.
-
+ certain users while being a home realm for others.
Multi-session
@@ -764,60 +802,56 @@ Internet-Draft Diameter Base Protocol January 2011
leg of the bundle would be a session while the entire bundle would
be a multi-session.
-
Network Access Identifier
The Network Access Identifier, or NAI [RFC4282], is used in the
Diameter protocol to extract a user's identity and realm. The
identity is used to identify the user during authentication and/or
- authorization, while the realm is used for message routing
+ authorization while the realm is used for message routing
purposes.
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 14]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Proxy Agent or Proxy
In addition to forwarding requests and responses, proxies make
policy decisions relating to resource usage and provisioning.
- This is typically accomplished by tracking the state of NAS
- devices. While proxies typically do not respond to client
- Requests prior to receiving a Response from the server, they may
- originate Reject messages in cases where policies are violated.
- As a result, proxies need to understand the semantics of the
- messages passing through them, and may not support all Diameter
+ Typically, this is accomplished by tracking the state of NAS
+ devices. While proxies usually do not respond to client requests
+ prior to receiving a response from the server, they may originate
+ Reject messages in cases where policies are violated. As a
+ result, proxies need to understand the semantics of the messages
+ passing through them, and they may not support all Diameter
applications.
-
Realm
The string in the NAI that immediately follows the '@' character.
- NAI realm names are required to be unique, and are piggybacked on
+ NAI realm names are required to be unique and are piggybacked on
the administration of the DNS namespace. Diameter makes use of
the realm, also loosely referred to as domain, to determine
- whether messages can be satisfied locally, or whether they must be
+ whether messages can be satisfied locally or whether they must be
routed or redirected. In RADIUS, realm names are not necessarily
piggybacked on the DNS namespace but may be independent of it.
- Real-time Accounting
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 15]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ Real-Time Accounting
Real-time accounting involves the processing of information on
- resource usage within a defined time window. Time constraints are
- typically imposed in order to limit financial risk. The Diameter
- Credit Control Application [RFC4006] is an example of an
+ resource usage within a defined time window. Typically, time
+ constraints are imposed in order to limit financial risk. The
+ Diameter Credit-Control Application [RFC4006] is an example of an
application that defines real-time accounting functionality.
-
Relay Agent or Relay
Relays forward requests and responses based on routing-related
@@ -827,20 +861,9 @@ Internet-Draft Diameter Base Protocol January 2011
the semantics of messages or non-routing AVPs, and are capable of
handling any Diameter application or message type. Since relays
make decisions based on information in routing AVPs and realm
- forwarding tables they do not keep state on NAS resource usage or
+ forwarding tables, they do not keep state on NAS resource usage or
sessions in progress.
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 15]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Redirect Agent
Rather than forwarding requests and responses between clients and
@@ -850,11 +873,10 @@ Internet-Draft Diameter Base Protocol January 2011
client and server. Redirect agents do not originate messages and
are capable of handling any message type, although they may be
configured only to redirect messages of certain types, while
- acting as relay or proxy agents for other types. As with proxy
+ acting as relay or proxy agents for other types. As with relay
agents, redirect agents do not keep state with respect to sessions
or NAS resources.
-
Session
A session is a related progression of events devoted to a
@@ -863,14 +885,19 @@ Internet-Draft Diameter Base Protocol January 2011
packets with the same Session-Id are considered to be part of the
same session.
-
Stateful Agent
A stateful agent is one that maintains session state information,
by keeping track of all authorized active sessions. Each
authorized session is bound to a particular service, and its state
- is considered active either until it is notified otherwise, or by
- expiration.
+ is considered active either until it is notified otherwise or
+ until expiration.
+
+
+
+Fajardo, et al. Standards Track [Page 16]
+
+RFC 6733 Diameter Base Protocol October 2012
Sub-session
@@ -881,53 +908,33 @@ Internet-Draft Diameter Base Protocol January 2011
during the same session) or serially. These changes in sessions
are tracked with the Accounting-Sub-Session-Id.
-
- Transaction state
+ Transaction State
The Diameter protocol requires that agents maintain transaction
state, which is used for failover purposes. Transaction state
- implies that upon forwarding a request, the Hop-by-Hop identifier
+ implies that upon forwarding a request, the Hop-by-Hop Identifier
is saved; the field is replaced with a locally unique identifier,
which is restored to its original value when the corresponding
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 16]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
answer is received. The request's state is released upon receipt
of the answer. A stateless agent is one that only maintains
transaction state.
-
Translation Agent
- A translation agent is a stateful Diameter node that performs
- protocol translation between Diameter and another AAA protocol,
- such as RADIUS.
-
-
- Transport Connection
-
- A transport connection is a TCP or SCTP connection existing
- directly between two Diameter peers, otherwise known as a Peer-to-
- Peer Connection.
-
+ A translation agent (TLA in Figure 4) is a stateful Diameter node
+ that performs protocol translation between Diameter and another
+ AAA protocol, such as RADIUS.
Upstream
Upstream is used to identify the direction of a particular
- Diameter message from the Diameter Client towards the Home Server.
-
+ Diameter message from the Diameter client towards the home server.
User
The entity or device requesting or using some resource, in support
of which a Diameter client has generated a request.
-
1.3. Approach to Extensibility
The Diameter protocol is designed to be extensible, using several
@@ -941,107 +948,108 @@ Internet-Draft Diameter Base Protocol January 2011
o Creating new applications
- From the point of view of extensibility Diameter authentication,
- authorization and accounting applications are treated in the same
- way.
-
-Fajardo, et al. Expires July 24, 2011 [Page 17]
+Fajardo, et al. Standards Track [Page 17]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- Note: Protocol designers should try to re-use existing functionality,
+ From the point of view of extensibility, Diameter authentication,
+ authorization, and accounting applications are treated in the same
+ way.
+
+ Note: Protocol designers should try to reuse existing functionality,
namely AVP values, AVPs, commands, and Diameter applications. Reuse
simplifies standardization and implementation. To avoid potential
- interoperability issues it is important to ensure that the semantics
- of the re-used features are well understood. Given that Diameter can
- also carry RADIUS attributes as Diameter AVPs, such re-use
- considerations apply also to existing RADIUS attributes that may be
+ interoperability issues, it is important to ensure that the semantics
+ of the reused features are well understood. Given that Diameter can
+ also carry RADIUS attributes as Diameter AVPs, such reuse
+ considerations also apply to existing RADIUS attributes that may be
useful in a Diameter application.
-1.3.1. Defining New AVP Values
+1.3.1. Defining New AVP Values
In order to allocate a new AVP value for AVPs defined in the Diameter
- Base protocol, the IETF needs to approve a new RFC that describes the
+ base protocol, the IETF needs to approve a new RFC that describes the
AVP value. IANA considerations for these AVP values are discussed in
- Section 11.4.
+ Section 11.3.
The allocation of AVP values for other AVPs is guided by the IANA
considerations of the document that defines those AVPs. Typically,
- allocation of new values for an AVP defined in an IETF RFC should
- require IETF Review [RFC5226], whereas values for vendor-specific
- AVPs can be allocated by the vendor.
+ allocation of new values for an AVP defined in an RFC would require
+ IETF Review [RFC5226], whereas values for vendor-specific AVPs can be
+ allocated by the vendor.
-1.3.2. Creating New AVPs
+1.3.2. Creating New AVPs
A new AVP being defined MUST use one of the data types listed in
- Section 4.2 or Section 4.3. If an appropriate derived data type is
- already defined, it SHOULD be used instead of a base data type to
- encourage reusability and good design practice.
+ Sections 4.2 or 4.3. If an appropriate derived data type is already
+ defined, it SHOULD be used instead of a base data type to encourage
+ reusability and good design practice.
In the event that a logical grouping of AVPs is necessary, and
multiple "groups" are possible in a given command, it is recommended
that a Grouped AVP be used (see Section 4.4).
The creation of new AVPs can happen in various ways. The recommended
- approach is to define a new general-purpose AVP in a standards track
- RFC approved by the IETF. However, as described in Section 11.1.1
- there are also other mechanisms.
+ approach is to define a new general-purpose AVP in a Standards Track
+ RFC approved by the IETF. However, as described in Section 11.1.1,
+ there are other mechanisms.
-1.3.3. Creating New Commands
+1.3.3. Creating New Commands
A new Command Code MUST be allocated when required AVPs (those
- indicated as {AVP} in the ABNF definition) are added to, deleted from
+ indicated as {AVP} in the CCF definition) are added to, deleted from,
or redefined in (for example, by changing a required AVP into an
optional one) an existing command.
- Furthermore, if the transport characteristics of a command are
- changed (for example, with respect to the number of round trips
- required) a new Command Code MUST be registered.
-
-Fajardo, et al. Expires July 24, 2011 [Page 18]
+Fajardo, et al. Standards Track [Page 18]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ Furthermore, if the transport characteristics of a command are
+ changed (for example, with respect to the number of round trips
+ required), a new Command Code MUST be registered.
- A change to the ABNF of a command, such as described above, MUST
+ A change to the CCF of a command, such as described above, MUST
result in the definition of a new Command Code. This subsequently
- leads to the need to define a new Diameter Application for any
- application that will use that new Command.
-
- The IANA considerations for commands are discussed in Section 11.2.1.
-
-1.3.4. Creating New Diameter Applications
-
- Every Diameter application specification MUST have an IANA assigned
- Application Id (see Section 2.4 and Section 11.3). The managed
- Application Id space is flat and there is no relationship between
- different Diameter applications with respect to their Application
- Ids. As such, there is no versioning support provided by these
- application Ids itself; every Diameter application is a standalone
- application. If the application has a relationship with other
- Diameter applications, such a relationship is not known to Diameter.
-
- Before describing the rules for creating new Diameter applications it
- is important to discuss the semantics of the AVPs occurrences as
- stated in the ABNF and the M-bit flag (Section 4.1) for an AVP.
- There is no relationship imposed between the two; they are set
+ leads to the need to define a new Diameter application for any
+ application that will use that new command.
+
+ The IANA considerations for Command Codes are discussed in
+ Section 3.1.
+
+1.3.4. Creating New Diameter Applications
+
+ Every Diameter application specification MUST have an IANA-assigned
+ Application Id (see Section 2.4). The managed Application ID space
+ is flat, and there is no relationship between different Diameter
+ applications with respect to their Application Ids. As such, there
+ is no versioning support provided by these Application Ids
+ themselves; every Diameter application is a standalone application.
+ If the application has a relationship with other Diameter
+ applications, such a relationship is not known to Diameter.
+
+ Before describing the rules for creating new Diameter applications,
+ it is important to discuss the semantics of the AVP occurrences as
+ stated in the CCF and the M-bit flag (Section 4.1) for an AVP. There
+ is no relationship imposed between the two; they are set
independently.
- o The ABNF indicates what AVPs are placed into a Diameter Command by
- the sender of that Command. Often, since there are multiple modes
- of protocol interactions many of the AVPs are indicated as
+ o The CCF indicates what AVPs are placed into a Diameter command by
+ the sender of that command. Often, since there are multiple modes
+ of protocol interactions, many of the AVPs are indicated as
optional.
o The M-bit allows the sender to indicate to the receiver whether or
not understanding the semantics of an AVP and its content is
mandatory. If the M-bit is set by the sender and the receiver
- does not understand the AVP or the values carried within that AVP
+ does not understand the AVP or the values carried within that AVP,
then a failure is generated (see Section 7).
It is the decision of the protocol designer when to develop a new
@@ -1050,77 +1058,48 @@ Internet-Draft Diameter Base Protocol January 2011
of the following criteria are met:
- M-bit Setting
- An AVP with the M-bit in the MUST column of the AVP flag table is
- added to an existing Command/Application.
- An AVP with the M-bit in the MAY column of the AVP flag table is
- added to an existing Command/Application.
-Fajardo, et al. Expires July 24, 2011 [Page 19]
+Fajardo, et al. Standards Track [Page 19]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ M-bit Setting
+
+ An AVP with the M-bit in the MUST column of the AVP flag table is
+ added to an existing Command/Application. An AVP with the M-bit
+ in the MAY column of the AVP flag table is added to an existing
+ Command/Application.
Note: The M-bit setting for a given AVP is relevant to an
- Application and each command within that application which
- includes the AVP. That is, if an AVP appears in two commands for
+ Application and each command within that application that includes
+ the AVP. That is, if an AVP appears in two commands for
application Foo and the M-bit settings are different in each
command, then there should be two AVP flag tables describing when
to set the M-bit.
Commands
- A new command is used within the existing application either
- because an additional command is added, an existing command has
+ A new command is used within the existing application because
+ either an additional command is added, an existing command has
been modified so that a new Command Code had to be registered, or
a command has been deleted.
- If the ABNF definition of a command allows it, an implementation may
+ AVP Flag bits
+
+ If an existing application changes the meaning/semantics of its
+ AVP Flags or adds new flag bits, then a new Diameter application
+ MUST be created.
+
+ If the CCF definition of a command allows it, an implementation may
add arbitrary optional AVPs with the M-bit cleared (including vendor-
specific AVPs) to that command without needing to define a new
application. Please refer to Section 11.1.1 for details.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 20]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
2. Protocol Overview
The base Diameter protocol concerns itself with establishing
@@ -1137,9 +1116,17 @@ Internet-Draft Diameter Base Protocol January 2011
The initial request for authentication and/or authorization of a user
would include the Session-Id AVP. The Session-Id is then used in all
subsequent messages to identify the user's session (see Section 8 for
- more information). The communicating party may accept the request,
- or reject it by returning an answer message with the Result-Code AVP
- set to indicate an error occurred. The specific behavior of the
+
+
+
+Fajardo, et al. Standards Track [Page 20]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ more information). The communicating party may accept the request or
+ reject it by returning an answer message with the Result-Code AVP set
+ to indicate that an error occurred. The specific behavior of the
Diameter server or client receiving a request depends on the Diameter
application employed.
@@ -1153,30 +1140,23 @@ Internet-Draft Diameter Base Protocol January 2011
applications. For authentication and authorization, it is always
extended for a particular application.
- Diameter Clients MUST support the base protocol, which includes
+ Diameter clients MUST support the base protocol, which includes
accounting. In addition, they MUST fully support each Diameter
application that is needed to implement the client's service, e.g.,
- NASREQ and/or Mobile IPv4. A Diameter Client MUST be referred to as
- "Diameter X Client" where X is the application which it supports, and
- not a "Diameter Client".
+ Network Access Server Requirements (NASREQ) [RFC2881] and/or Mobile
+ IPv4. A Diameter client MUST be referred to as "Diameter X Client"
+ where X is the application that it supports and not a "Diameter
+ Client".
- Diameter Servers MUST support the base protocol, which includes
+ Diameter servers MUST support the base protocol, which includes
accounting. In addition, they MUST fully support each Diameter
application that is needed to implement the intended service, e.g.,
- NASREQ and/or Mobile IPv4. A Diameter Server MUST be referred to as
- "Diameter X Server" where X is the application which it supports, and
+ NASREQ and/or Mobile IPv4. A Diameter server MUST be referred to as
+ "Diameter X Server" where X is the application that it supports, and
not a "Diameter Server".
- Diameter Relays and redirect agents are transparent to the Diameter
- applications but they MUST support the Diameter base protocol, which
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 21]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
+ Diameter relays and redirect agents are transparent to the Diameter
+ applications, but they MUST support the Diameter base protocol, which
includes accounting, and all Diameter applications.
Diameter proxies MUST support the base protocol, which includes
@@ -1186,55 +1166,75 @@ Internet-Draft Diameter Base Protocol January 2011
"Diameter X Proxy" where X is the application which it supports, and
not a "Diameter Proxy".
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 21]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
2.1. Transport
The Diameter Transport profile is defined in [RFC3539].
- The base Diameter protocol is run on port 3868 for both TCP [RFC793]
- and SCTP [RFC4960]. For TLS [RFC5246] and DTLS [RFC4347], a Diameter
- node that initiate a connection prior to any message exchanges MUST
- run on port [TBD]. It is assumed that TLS is run on top of TCP when
- it is used and DTLS is run on top of SCTP when it is used.
+ The base Diameter protocol is run on port 3868 for both TCP [RFC0793]
+ and SCTP [RFC4960]. For TLS [RFC5246] and Datagram Transport Layer
+ Security (DTLS) [RFC6347], a Diameter node that initiates a
+ connection prior to any message exchanges MUST run on port 5658. It
+ is assumed that TLS is run on top of TCP when it is used, and DTLS is
+ run on top of SCTP when it is used.
If the Diameter peer does not support receiving TLS/TCP and DTLS/SCTP
- connections on port [TBD], i.e. the peer complies only with
- [RFC3588], then the initiator MAY revert to using TCP or SCTP and on
- port 3868. Note that this scheme is kept for the purpose of
- backwards compatibility only and that there are inherent security
- vulnerabilities when the initial CER/CEA messages are sent un-
- protected (see Section 5.6).
+ connections on port 5658 (i.e., the peer complies only with RFC
+ 3588), then the initiator MAY revert to using TCP or SCTP on port
+ 3868. Note that this scheme is kept only for the purpose of backward
+ compatibility and that there are inherent security vulnerabilities
+ when the initial CER/CEA messages are sent unprotected (see
+ Section 5.6).
- Diameter clients MUST support either TCP or SCTP, while agents and
- servers SHOULD support both.
+ Diameter clients MUST support either TCP or SCTP; agents and servers
+ SHOULD support both.
A Diameter node MAY initiate connections from a source port other
than the one that it declares it accepts incoming connections on, and
- MUST be prepared to receive connections on port 3868 for TCP or SCTP
- and port [TBD] for TLS/TCP and DTLS/SCTP connections. A given
- Diameter instance of the peer state machine MUST NOT use more than
- one transport connection to communicate with a given peer, unless
- multiple instances exist on the peer in which case a separate
- connection per process is allowed.
+ it MUST always be prepared to receive connections on port 3868 for
+ TCP or SCTP and port 5658 for TLS/TCP and DTLS/SCTP connections.
+ When DNS-based peer discovery (Section 5.2) is used, the port numbers
+ received from SRV records take precedence over the default ports
+ (3868 and 5658).
+
+ A given Diameter instance of the peer state machine MUST NOT use more
+ than one transport connection to communicate with a given peer,
+ unless multiple instances exist on the peer, in which, case a
+ separate connection per process is allowed.
When no transport connection exists with a peer, an attempt to
- connect SHOULD be periodically made. This behavior is handled via
+ connect SHOULD be made periodically. This behavior is handled via
the Tc timer (see Section 12 for details), whose recommended value is
30 seconds. There are certain exceptions to this rule, such as when
a peer has terminated the transport connection stating that it does
not wish to communicate.
When connecting to a peer and either zero or more transports are
- specified, TLS SHOULD be tried first, followed by DTLS, then by TCP
+ specified, TLS SHOULD be tried first, followed by DTLS, then by TCP,
+ and finally by SCTP. See Section 5.2 for more information on peer
+ discovery.
-Fajardo, et al. Expires July 24, 2011 [Page 22]
-
-Internet-Draft Diameter Base Protocol January 2011
- and finally by SCTP. See Section 5.2 for more information on peer
- discovery.
+Fajardo, et al. Standards Track [Page 22]
+
+RFC 6733 Diameter Base Protocol October 2012
+
Diameter implementations SHOULD be able to interpret ICMP protocol
port unreachable messages as explicit indications that the server is
@@ -1253,18 +1253,18 @@ Internet-Draft Diameter Base Protocol January 2011
Diameter messages SHOULD be mapped into SCTP streams in a way that
avoids head-of-the-line (HOL) blocking. Among different ways of
performing the mapping that fulfill this requirement it is
- RECOMMENDED that a Diameter node sends every Diameter message
- (request or response) over the stream zero with the unordered flag
- set. However, Diameter nodes MAY select and implement other design
- alternatives for avoiding HOL blocking such as using multiple streams
- with the unordered flag cleared (as originally instructed in
- RFC3588). On the receiving side, a Diameter entity MUST be ready to
- receive Diameter messages over any stream and it is free to return
- responses over a different stream. This way, both sides manage the
- available streams in the sending direction, independently of the
- streams chosen by the other side to send a particular Diameter
- message. These messages can be out-of-order and belong to different
- Diameter sessions.
+ RECOMMENDED that a Diameter node send every Diameter message (request
+ or response) over stream zero with the unordered flag set. However,
+ Diameter nodes MAY select and implement other design alternatives for
+ avoiding HOL blocking such as using multiple streams with the
+ unordered flag cleared (as originally instructed in RFC 3588). On
+ the receiving side, a Diameter entity MUST be ready to receive
+ Diameter messages over any stream, and it is free to return responses
+ over a different stream. This way, both sides manage the available
+ streams in the sending direction, independently of the streams chosen
+ by the other side to send a particular Diameter message. These
+ messages can be out-of-order and belong to different Diameter
+ sessions.
Out-of-order delivery has special concerns during a connection
establishment and termination. When a connection is established, the
@@ -1275,30 +1275,37 @@ Internet-Draft Diameter Base Protocol January 2011
the connection. In order to avoid this race condition, the receiver
side SHOULD NOT use out-of-order delivery methods until the first
message has been received from the initiator, proving that it has
- moved to I-Open state. To trigger such message, the receiver side
- could send a DWR immediatly after sending CEA. Upon reception of the
- corresponding DWA, the receiver side should start using out-of-order
- delivery methods to counter the HOL blocking.
+ moved to I-Open state. To trigger such a message, the receiver side
+ could send a DWR immediately after sending a CEA. Upon reception of
+ the corresponding DWA, the receiver side should start using out-of-
+ order delivery methods to counter the HOL blocking.
Another race condition may occur when DPR and DPA messages are used.
+ Both DPR and DPA are small in size; thus, they may be delivered to
+ the peer faster than application messages when an out-of-order
+ delivery mechanism is used. Therefore, it is possible that a DPR/DPA
-Fajardo, et al. Expires July 24, 2011 [Page 23]
+Fajardo, et al. Standards Track [Page 23]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ exchange completes while application messages are still in transit,
+ resulting in a loss of these messages. An implementation could
+ mitigate this race condition, for example, using timers, and wait for
+ a short period of time for pending application level messages to
+ arrive before proceeding to disconnect the transport connection.
+ Eventually, lost messages are handled by the retransmission mechanism
+ described in Section 5.5.4.
- Both DPR and DPA are small in size, thus they may be delivered faster
- to the peer than application messages when out-of-order delivery
- mechanism is used. Therefore, it is possible that a DPR/DPA exchange
- completes while application messages are still in transit, resulting
- to a loss of these messages. An implementation could mitigate this
- race condition, for example, using timers and wait for a short period
- of time for pending application level messages to arrive before
- proceeding to disconnect the transport connection. Eventually, lost
- messages are handled by the retransmission mechanism described in
- Section 5.5.4.
+ A Diameter agent SHOULD use dedicated payload protocol identifiers
+ (PPIDs) for clear text and encrypted SCTP DATA chunks instead of only
+ using the unspecified payload protocol identifier (value 0). For
+ this purpose, two PPID values are allocated: the PPID value 46 is for
+ Diameter messages in clear text SCTP DATA chunks, and the PPID value
+ 47 is for Diameter messages in protected DTLS/SCTP DATA chunks.
2.2. Securing Diameter Messages
@@ -1307,7 +1314,7 @@ Internet-Draft Diameter Base Protocol January 2011
the use of TLS/TCP and DTLS/SCTP. If desired, alternative security
mechanisms that are independent of Diameter, such as IPsec [RFC4301],
can be deployed to secure connections between peers. The Diameter
- protocol MUST NOT be used without any security mechanism.
+ protocol MUST NOT be used without one of TLS, DTLS, or IPsec.
2.3. Diameter Application Compliance
@@ -1318,37 +1325,40 @@ Internet-Draft Diameter Base Protocol January 2011
Implementations MAY add arbitrary optional AVPs with the M-bit
cleared (including vendor-specific AVPs) to a command defined in an
- application, but only if the command's ABNF syntax specification
+ application, but only if the command's CCF syntax specification
allows for it. Please refer to Section 11.1.1 for details.
2.4. Application Identifiers
- Each Diameter application MUST have an IANA assigned Application Id
- (see Section 11.3). The base protocol does not require an
- Application Id since its support is mandatory. During the
- capabilities exchange, Diameter nodes inform their peers of locally
- supported applications. Furthermore, all Diameter messages contain
- an Application Id, which is used in the message forwarding process.
+ Each Diameter application MUST have an IANA-assigned Application ID.
+ The base protocol does not require an Application Id since its
+ support is mandatory. During the capabilities exchange, Diameter
+ nodes inform their peers of locally supported applications.
+ Furthermore, all Diameter messages contain an Application Id, which
+ is used in the message forwarding process.
- The following Application Id values are defined:
- Diameter Common Messages 0
- Diameter Base Accounting 3
- Relay 0xffffffff
- Relay and redirect agents MUST advertise the Relay Application
-Fajardo, et al. Expires July 24, 2011 [Page 24]
+
+Fajardo, et al. Standards Track [Page 24]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ The following Application Id values are defined:
+
+ Diameter common message 0
+ Diameter base accounting 3
+ Relay 0xffffffff
- Identifier, while all other Diameter nodes MUST advertise locally
- supported applications. The receiver of a Capabilities Exchange
- message advertising Relay service MUST assume that the sender
- supports all current and future applications.
+ Relay and redirect agents MUST advertise the Relay Application ID,
+ while all other Diameter nodes MUST advertise locally supported
+ applications. The receiver of a Capabilities Exchange message
+ advertising relay service MUST assume that the sender supports all
+ current and future applications.
Diameter relay and proxy agents are responsible for finding an
upstream server that supports the application of a particular
@@ -1358,16 +1368,15 @@ Internet-Draft Diameter Base Protocol January 2011
2.5. Connections vs. Sessions
This section attempts to provide the reader with an understanding of
- the difference between connection and session, which are terms used
- extensively throughout this document.
+ the difference between "connection" and "session", which are terms
+ used extensively throughout this document.
- A connection refers to a transport level connection between two peers
+ A connection refers to a transport-level connection between two peers
that is used to send and receive Diameter messages. A session is a
- logical concept at the application layer existing between the
+ logical concept at the application layer that exists between the
Diameter client and the Diameter server; it is identified via the
Session-Id AVP.
-
+--------+ +-------+ +--------+
| Client | | Relay | | Server |
+--------+ +-------+ +--------+
@@ -1377,100 +1386,93 @@ Internet-Draft Diameter Base Protocol January 2011
<----------------------------->
User session x
- Figure 1: Diameter connections and sessions
+ Figure 1: Diameter Connections and Sessions
In the example provided in Figure 1, peer connection A is established
- between the Client and the Relay. Peer connection B is established
- between the Relay and the Server. User session X spans from the
- Client via the Relay to the Server. Each "user" of a service causes
+ between the client and the relay. Peer connection B is established
+ between the relay and the server. User session X spans from the
+ client via the relay to the server. Each "user" of a service causes
an auth request to be sent, with a unique session identifier. Once
accepted by the server, both the client and the server are aware of
the session.
- It is important to note that there is no relationship between a
- connection and a session, and that Diameter messages for multiple
- sessions are all multiplexed through a single connection. Also note
- that Diameter messages pertaining to the session, both application
- specific and those that are defined in this document such as ASR/ASA,
- RAR/RAA and STR/STA MUST carry the Application Id of the application.
-Fajardo, et al. Expires July 24, 2011 [Page 25]
+Fajardo, et al. Standards Track [Page 25]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- Diameter messages pertaining to peer connection establishment and
- maintenance such as CER/CEA, DWR/DWA and DPR/DPA MUST carry an
- Application Id of zero (0).
+ It is important to note that there is no relationship between a
+ connection and a session, and that Diameter messages for multiple
+ sessions are all multiplexed through a single connection. Also, note
+ that Diameter messages pertaining to the session, both application-
+ specific and those that are defined in this document such as ASR/ASA,
+ RAR/RAA, and STR/STA, MUST carry the Application Id of the
+ application. Diameter messages pertaining to peer connection
+ establishment and maintenance such as CER/CEA, DWR/DWA, and DPR/DPA
+ MUST carry an Application Id of zero (0).
2.6. Peer Table
- The Diameter Peer Table is used in message forwarding, and referenced
- by the Routing Table. A Peer Table entry contains the following
- fields:
+ The Diameter peer table is used in message forwarding and is
+ referenced by the routing table. A peer table entry contains the
+ following fields:
- Host identity
+ Host Identity
- Following the conventions described for the DiameterIdentity
- derived AVP data format in Section 4.3. This field contains the
+ Following the conventions described for the DiameterIdentity-
+ derived AVP data format in Section 4.3.1, this field contains the
contents of the Origin-Host (Section 6.3) AVP found in the CER or
CEA message.
-
StatusT
- This is the state of the peer entry, and MUST match one of the
+ This is the state of the peer entry, and it MUST match one of the
values listed in Section 5.6.
-
Static or Dynamic
Specifies whether a peer entry was statically configured or
dynamically discovered.
-
- Expiration time
+ Expiration Time
Specifies the time at which dynamically discovered peer table
- entries are to be either refreshed, or expired.
-
+ entries are to be either refreshed or expired. If public key
+ certificates are used for Diameter security (e.g., with TLS), this
+ value MUST NOT be greater than the expiry times in the relevant
+ certificates.
TLS/TCP and DTLS/SCTP Enabled
Specifies whether TLS/TCP and DTLS/SCTP is to be used when
communicating with the peer.
-
Additional security information, when needed (e.g., keys,
- certificates)
-
-
+ certificates).
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 26]
+Fajardo, et al. Standards Track [Page 26]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
2.7. Routing Table
All Realm-Based routing lookups are performed against what is
- commonly known as the Routing Table (see Section 12). A Routing
- Table Entry contains the following fields:
+ commonly known as the routing table (see Section 12). Each routing
+ table entry contains the following fields:
Realm Name
- This is the field that is MUST be used as a primary key in the
+ This is the field that MUST be used as a primary key in the
routing table lookups. Note that some implementations perform
their lookups based on longest-match-from-the-right on the realm
rather than requiring an exact match.
-
Application Identifier
An application is identified by an Application Id. A route entry
@@ -1478,21 +1480,19 @@ Internet-Draft Diameter Base Protocol January 2011
the message header. This field MUST be used as a secondary key
field in routing table lookups.
-
Local Action
The Local Action field is used to identify how a message should be
treated. The following actions are supported:
-
- 1. LOCAL - Diameter messages that can be satisfied locally, and
- do not need to be routed to another Diameter entity.
+ 1. LOCAL - Diameter messages that can be satisfied locally and do
+ not need to be routed to another Diameter entity.
2. RELAY - All Diameter messages that fall within this category
- MUST be routed to a next hop Diameter entity that is indicated
+ MUST be routed to a next-hop Diameter entity that is indicated
by the identifier described below. Routing is done without
modifying any non-routing AVPs. See Section 6.1.9 for
- relaying guidelines
+ relaying guidelines.
3. PROXY - All Diameter messages that fall within this category
MUST be routed to a next Diameter entity that is indicated by
@@ -1504,47 +1504,53 @@ Internet-Draft Diameter Base Protocol January 2011
4. REDIRECT - Diameter messages that fall within this category
MUST have the identity of the home Diameter server(s)
appended, and returned to the sender of the message. See
- Section 6.1.8 for redirect guidelines.
+ Section 6.1.8 for redirection guidelines.
+
+
+
-Fajardo, et al. Expires July 24, 2011 [Page 27]
+Fajardo, et al. Standards Track [Page 27]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Server Identifier
- One or more servers to which the message is to be routed. These
- servers MUST also be present in the Peer table. When the Local
- Action is set to RELAY or PROXY, this field contains the identity
- of the server(s) the message MUST be routed to. When the Local
+ The identity of one or more servers to which the message is to be
+ routed. This identity MUST also be present in the Host Identity
+ field of the peer table (Section 2.6). When the Local Action is
+ set to RELAY or PROXY, this field contains the identity of the
+ server(s) to which the message MUST be routed. When the Local
Action field is set to REDIRECT, this field contains the identity
- of one or more servers the message MUST be redirected to.
+ of one or more servers to which the message MUST be redirected.
Static or Dynamic
Specifies whether a route entry was statically configured or
dynamically discovered.
- Expiration time
+ Expiration Time
Specifies the time at which a dynamically discovered route table
- entry expires.
+ entry expires. If public key certificates are used for Diameter
+ security (e.g., with TLS), this value MUST NOT be greater than the
+ expiry time in the relevant certificates.
It is important to note that Diameter agents MUST support at least
- one of the LOCAL, RELAY, PROXY or REDIRECT modes of operation.
+ one of the LOCAL, RELAY, PROXY, or REDIRECT modes of operation.
Agents do not need to support all modes of operation in order to
- conform with the protocol specification, but MUST follow the protocol
- compliance guidelines in Section 2. Relay agents and proxies MUST
- NOT reorder AVPs.
+ conform with the protocol specification, but they MUST follow the
+ protocol compliance guidelines in Section 2. Relay agents and
+ proxies MUST NOT reorder AVPs.
The routing table MAY include a default entry that MUST be used for
any requests not matching any of the other entries. The routing
table MAY consist of only such an entry.
When a request is routed, the target server MUST have advertised the
- Application Id (see Section 2.4) for the given message, or have
+ Application Id (see Section 2.4) for the given message or have
advertised itself as a relay or proxy agent. Otherwise, an error is
returned with the Result-Code AVP set to DIAMETER_UNABLE_TO_DELIVER.
@@ -1552,23 +1558,24 @@ Internet-Draft Diameter Base Protocol January 2011
In addition to clients and servers, the Diameter protocol introduces
relay, proxy, redirect, and translation agents, each of which is
- defined in Section 1.3. These Diameter agents are useful for several
+ defined in Section 1.2. Diameter agents are useful for several
reasons:
o They can distribute administration of systems to a configurable
grouping, including the maintenance of security associations.
- o They can be used for concentration of requests from an number of
- co-located or distributed NAS equipment sets to a set of like user
- groups.
-Fajardo, et al. Expires July 24, 2011 [Page 28]
+Fajardo, et al. Standards Track [Page 28]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ o They can be used for concentration of requests from a number of
+ co-located or distributed NAS equipment sets to a set of like user
+ groups.
+
o They can do value-added processing to the requests or responses.
o They can be used for load balancing.
@@ -1578,7 +1585,7 @@ Internet-Draft Diameter Base Protocol January 2011
The Diameter protocol requires that agents maintain transaction
state, which is used for failover purposes. Transaction state
- implies that upon forwarding a request, its Hop-by-Hop identifier is
+ implies that upon forwarding a request, its Hop-by-Hop Identifier is
saved; the field is replaced with a locally unique identifier, which
is restored to its original value when the corresponding answer is
received. The request's state is released upon receipt of the
@@ -1593,7 +1600,7 @@ Internet-Draft Diameter Base Protocol January 2011
A stateful agent is one that maintains session state information by
keeping track of all authorized active sessions. Each authorized
session is bound to a particular service, and its state is considered
- active either until the agent is notified otherwise, or the session
+ active until either the agent is notified otherwise or the session
expires. Each authorized session has an expiration, which is
communicated by Diameter servers via the Session-Timeout AVP.
@@ -1604,40 +1611,43 @@ Internet-Draft Diameter Base Protocol January 2011
o Limiting resources authorized to a particular user
- o Per user or transaction auditing
+ o Per-user or per-transaction auditing
A Diameter agent MAY act in a stateful manner for some requests and
be stateless for others. A Diameter implementation MAY act as one
- type of agent for some requests, and as another type of agent for
+ type of agent for some requests and as another type of agent for
others.
-2.8.1. Relay Agents
- Relay Agents are Diameter agents that accept requests and route
- messages to other Diameter nodes based on information found in the
- messages (e.g., Destination-Realm). This routing decision is
- performed using a list of supported realms, and known peers. This is
-Fajardo, et al. Expires July 24, 2011 [Page 29]
+
+Fajardo, et al. Standards Track [Page 29]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+2.8.1. Relay Agents
- known as the Routing Table, as is defined further in Section 2.7.
+ Relay agents are Diameter agents that accept requests and route
+ messages to other Diameter nodes based on information found in the
+ messages (e.g., the value of the Destination-Realm AVP Section 6.6).
+ This routing decision is performed using a list of supported realms
+ and known peers. This is known as the routing table, as is defined
+ further in Section 2.7.
Relays may, for example, be used to aggregate requests from multiple
Network Access Servers (NASes) within a common geographical area
- (POP). The use of Relays is advantageous since it eliminates the
- need for NASes to be configured with the necessary security
- information they would otherwise require to communicate with Diameter
- servers in other realms. Likewise, this reduces the configuration
- load on Diameter servers that would otherwise be necessary when NASes
- are added, changed or deleted.
+ (Point of Presence, POP). The use of relays is advantageous since it
+ eliminates the need for NASes to be configured with the necessary
+ security information they would otherwise require to communicate with
+ Diameter servers in other realms. Likewise, this reduces the
+ configuration load on Diameter servers that would otherwise be
+ necessary when NASes are added, changed, or deleted.
Relays modify Diameter messages by inserting and removing routing
- information, but do not modify any other portion of a message.
+ information, but they do not modify any other portion of a message.
Relays SHOULD NOT maintain session state but MUST maintain
transaction state.
@@ -1650,44 +1660,46 @@ Internet-Draft Diameter Base Protocol January 2011
Figure 2: Relaying of Diameter messages
- The example provided in Figure 2 depicts a request issued from NAS,
+ The example provided in Figure 2 depicts a request issued from a NAS,
which is an access device, for the user [email protected]. Prior to
- issuing the request, NAS performs a Diameter route lookup, using
+ issuing the request, the NAS performs a Diameter route lookup, using
"example.com" as the key, and determines that the message is to be
- relayed to DRL, which is a Diameter Relay. DRL performs the same
- route lookup as NAS, and relays the message to HMS, which is
- example.com's Home Diameter Server. HMS identifies that the request
- can be locally supported (via the realm), processes the
+ relayed to a DRL, which is a Diameter relay. The DRL performs the
+ same route lookup as the NAS, and relays the message to the HMS,
+ which is example.com's home server. The HMS identifies that the
+ request can be locally supported (via the realm), processes the
authentication and/or authorization request, and replies with an
- answer, which is routed back to NAS using saved transaction state.
-
- Since Relays do not perform any application level processing, they
- provide relaying services for all Diameter applications, and
- therefore MUST advertise the Relay Application Id.
+ answer, which is routed back to the NAS using saved transaction
+ state.
-2.8.2. Proxy Agents
+ Since relays do not perform any application-level processing, they
+ provide relaying services for all Diameter applications; therefore,
+ they MUST advertise the Relay Application Id.
- Similarly to relays, proxy agents route Diameter messages using the
- Diameter Routing Table. However, they differ since they modify
- messages to implement policy enforcement. This requires that proxies
- maintain the state of their downstream peers (e.g., access devices)
- to enforce resource usage, provide admission control, and
- provisioning.
-Fajardo, et al. Expires July 24, 2011 [Page 30]
+Fajardo, et al. Standards Track [Page 30]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+2.8.2. Proxy Agents
+
+ Similar to relays, proxy agents route Diameter messages using the
+ Diameter routing table. However, they differ since they modify
+ messages to implement policy enforcement. This requires that proxies
+ maintain the state of their downstream peers (e.g., access devices)
+ to enforce resource usage, provide admission control, and provide
+ provisioning.
Proxies may, for example, be used in call control centers or access
- ISPs that provide outsourced connections, they can monitor the number
- and types of ports in use, and make allocation and admission
- decisions according to their configuration.
+ ISPs that provide outsourced connections; they can monitor the number
+ and type of ports in use and make allocation and admission decisions
+ according to their configuration.
Since enforcing policies requires an understanding of the service
- being provided, Proxies MUST only advertise the Diameter applications
+ being provided, proxies MUST only advertise the Diameter applications
they support.
2.8.3. Redirect Agents
@@ -1709,18 +1721,12 @@ Internet-Draft Diameter Base Protocol January 2011
The example provided in Figure 3 depicts a request issued from the
access device, NAS, for the user [email protected]. The message is
forwarded by the NAS to its relay, DRL, which does not have a routing
- entry in its Diameter Routing Table for example.com. DRL has a
+ entry in its Diameter routing table for example.com. The DRL has a
default route configured to DRD, which is a redirect agent that
- returns a redirect notification to DRL, as well as HMS' contact
- information. Upon receipt of the redirect notification, DRL
- establishes a transport connection with HMS, if one doesn't already
- exist, and forwards the request to it.
-
-
-
-
-
-
+ returns a redirect notification to DRL, as well as the HMS' contact
+ information. Upon receipt of the redirect notification, the DRL
+ establishes a transport connection with the HMS, if one doesn't
+ already exist, and forwards the request to it.
@@ -1729,12 +1735,9 @@ Internet-Draft Diameter Base Protocol January 2011
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 31]
+Fajardo, et al. Standards Track [Page 31]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+------+
@@ -1755,10 +1758,10 @@ Internet-Draft Diameter Base Protocol January 2011
Figure 3: Redirecting a Diameter Message
- Since redirect agents do not perform any application level
+ Since redirect agents do not perform any application-level
processing, they provide relaying services for all Diameter
- applications, and therefore MUST advertise the Relay Application
- Identifier.
+ applications; therefore, they MUST advertise the Relay Application
+ ID.
2.8.4. Translation Agents
@@ -1773,7 +1776,7 @@ Internet-Draft Diameter Base Protocol January 2011
MUST maintain transaction state.
Translation of messages can only occur if the agent recognizes the
- application of a particular request, and therefore translation agents
+ application of a particular request; therefore, translation agents
MUST only advertise their locally supported applications.
+------+ ---------> +------+ ---------> +------+
@@ -1788,23 +1791,24 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 32]
+Fajardo, et al. Standards Track [Page 32]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
2.9. Diameter Path Authorization
- As noted in Section 2.2, Diameter provides transmission level
+ As noted in Section 2.2, Diameter provides transmission-level
security for each connection using TLS/TCP and DTLS/SCTP. Therefore,
- each connection can be authenticated, replay and integrity protected.
+ each connection can be authenticated and can be replay and integrity
+ protected.
- In addition to authenticating each connection, each connection as
- well as the entire session MUST also be authorized. Before
- initiating a connection, a Diameter Peer MUST check that its peers
- are authorized to act in their roles. For example, a Diameter peer
- may be authentic, but that does not mean that it is authorized to act
- as a Diameter Server advertising a set of Diameter applications.
+ In addition to authenticating each connection, the entire session
+ MUST also be authorized. Before initiating a connection, a Diameter
+ peer MUST check that its peers are authorized to act in their roles.
+ For example, a Diameter peer may be authentic, but that does not mean
+ that it is authorized to act as a Diameter server advertising a set
+ of Diameter applications.
Prior to bringing up a connection, authorization checks are performed
at each connection along the path. Diameter capabilities negotiation
@@ -1815,7 +1819,7 @@ Internet-Draft Diameter Base Protocol January 2011
As noted in Section 6.1.9, a relay or proxy agent MUST append a
Route-Record AVP to all requests forwarded. The AVP contains the
- identity of the peer the request was received from.
+ identity of the peer from which the request was received.
The home Diameter server, prior to authorizing a session, MUST check
the Route-Record AVPs to make sure that the route traversed by the
@@ -1823,7 +1827,7 @@ Internet-Draft Diameter Base Protocol January 2011
realm may not wish to honor requests that have been routed through an
untrusted realm. By authorizing a request, the home Diameter server
is implicitly indicating its willingness to engage in the business
- transaction as specified by the contractual relationship between the
+ transaction as specified by any contractual relationship between the
server and the previous hop. A DIAMETER_AUTHORIZATION_REJECTED error
message (see Section 7.1.5) is sent if the route traversed by the
request is unacceptable.
@@ -1839,72 +1843,24 @@ Internet-Draft Diameter Base Protocol January 2011
willingness to take on financial risk relative to the session. A
local realm may wish to limit this exposure, for example, by
establishing credit limits for intermediate realms and refusing to
- accept responses which would violate those limits. By issuing an
- accounting request corresponding to the authorization response, the
+ accept responses that would violate those limits. By issuing an
-Fajardo, et al. Expires July 24, 2011 [Page 33]
+Fajardo, et al. Standards Track [Page 33]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ accounting request corresponding to the authorization response, the
local realm implicitly indicates its agreement to provide the service
indicated in the authorization response. If the service cannot be
provided by the local realm, then a DIAMETER_UNABLE_TO_COMPLY error
message MUST be sent within the accounting request; a Diameter client
receiving an authorization response for a service that it cannot
- perform MUST NOT substitute an alternate service, and then send
+ perform MUST NOT substitute an alternate service and then send
accounting requests for the alternate service instead.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 34]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
3. Diameter Header
A summary of the Diameter header format is shown below. The fields
@@ -1915,7 +1871,7 @@ Internet-Draft Diameter Base Protocol January 2011
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Version | Message Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | command flags | Command-Code |
+ | Command Flags | Command Code |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Application-ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -1935,13 +1891,23 @@ Internet-Draft Diameter Base Protocol January 2011
The Message Length field is three octets and indicates the length
of the Diameter message including the header fields and the padded
- AVPs. Thus the message length field is always a multiple of 4.
+ AVPs. Thus, the Message Length field is always a multiple of 4.
Command Flags
The Command Flags field is eight bits. The following bits are
assigned:
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 34]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|R P E T r r r r|
@@ -1952,127 +1918,113 @@ Internet-Draft Diameter Base Protocol January 2011
If set, the message is a request. If cleared, the message is
an answer.
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 35]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
P(roxiable)
- If set, the message MAY be proxied, relayed or redirected. If
+ If set, the message MAY be proxied, relayed, or redirected. If
cleared, the message MUST be locally processed.
-
E(rror)
If set, the message contains a protocol error, and the message
- will not conform to the ABNF described for this command.
+ will not conform to the CCF described for this command.
Messages with the 'E' bit set are commonly referred to as error
- messages. This bit MUST NOT be set in request messages. See
- Section 7.2.
+ messages. This bit MUST NOT be set in request messages (see
+ Section 7.2).
-
- T(Potentially re-transmitted message)
+ T(Potentially retransmitted message)
This flag is set after a link failover procedure, to aid the
removal of duplicate requests. It is set when resending
requests not yet acknowledged, as an indication of a possible
duplicate due to a link failure. This bit MUST be cleared when
- sending a request for the first time, otherwise the sender MUST
- set this flag. Diameter agents only need to be concerned about
- the number of requests they send based on a single received
- request; retransmissions by other entities need not be tracked.
- Diameter agents that receive a request with the T flag set,
- MUST keep the T flag set in the forwarded request. This flag
- MUST NOT be set if an error answer message (e.g., a protocol
- error) has been received for the earlier message. It can be
- set only in cases where no answer has been received from the
- server for a request and the request is sent again. This flag
- MUST NOT be set in answer messages.
-
+ sending a request for the first time; otherwise, the sender
+ MUST set this flag. Diameter agents only need to be concerned
+ about the number of requests they send based on a single
+ received request; retransmissions by other entities need not be
+ tracked. Diameter agents that receive a request with the T
+ flag set, MUST keep the T flag set in the forwarded request.
+ This flag MUST NOT be set if an error answer message (e.g., a
+ protocol error) has been received for the earlier message. It
+ can be set only in cases where no answer has been received from
+ the server for a request, and the request has been sent again.
+ This flag MUST NOT be set in answer messages.
r(eserved)
- These flag bits are reserved for future use, and MUST be set to
- zero, and ignored by the receiver.
+ These flag bits are reserved for future use; they MUST be set
+ to zero and ignored by the receiver.
- Command-Code
- The Command-Code field is three octets, and is used in order to
- communicate the command associated with the message. The 24-bit
- address space is managed by IANA (see Section 11.2.1).
- Command-Code values 16,777,214 and 16,777,215 (hexadecimal values
- FFFFFE -FFFFFF) are reserved for experimental use (See Section
- 11.3).
-Fajardo, et al. Expires July 24, 2011 [Page 36]
+Fajardo, et al. Standards Track [Page 35]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ Command Code
+ The Command Code field is three octets and is used in order to
+ communicate the command associated with the message. The 24-bit
+ address space is managed by IANA (see Section 3.1). Command Code
+ values 16,777,214 and 16,777,215 (hexadecimal values FFFFFE-
+ FFFFFF) are reserved for experimental use (see Section 11.2).
- Application-ID
+ Application-ID
- Application-ID is four octets and is used to identify to which
- application the message is applicable for. The application can be
- an authentication application, an accounting application or a
- vendor specific application. See Section 11.3 for the possible
- values that the application-id may use.
+ Application-ID is four octets and is used to identify for which
+ application the message is applicable. The application can be an
+ authentication application, an accounting application, or a
+ vendor-specific application.
- The value of the application-id field in the header MUST be the
- same as any relevant application-id AVPs contained in the message.
+ The value of the Application-ID field in the header MUST be the
+ same as any relevant Application-Id AVPs contained in the message.
Hop-by-Hop Identifier
The Hop-by-Hop Identifier is an unsigned 32-bit integer field (in
- network byte order) and aids in matching requests and replies.
- The sender MUST ensure that the Hop-by-Hop identifier in a request
- is unique on a given connection at any given time, and MAY attempt
- to ensure that the number is unique across reboots. The sender of
- an Answer message MUST ensure that the Hop-by-Hop Identifier field
- contains the same value that was found in the corresponding
- request. The Hop-by-Hop identifier is normally a monotonically
- increasing number, whose start value was randomly generated. An
- answer message that is received with an unknown Hop-by-Hop
- Identifier MUST be discarded.
-
+ network byte order) that aids in matching requests and replies.
+ The sender MUST ensure that the Hop-by-Hop Identifier in a request
+ is unique on a given connection at any given time, and it MAY
+ attempt to ensure that the number is unique across reboots. The
+ sender of an answer message MUST ensure that the Hop-by-Hop
+ Identifier field contains the same value that was found in the
+ corresponding request. The Hop-by-Hop Identifier is normally a
+ monotonically increasing number, whose start value was randomly
+ generated. An answer message that is received with an unknown
+ Hop-by-Hop Identifier MUST be discarded.
End-to-End Identifier
The End-to-End Identifier is an unsigned 32-bit integer field (in
- network byte order) and is used to detect duplicate messages.
- Upon reboot implementations MAY set the high order 12 bits to
+ network byte order) that is used to detect duplicate messages.
+ Upon reboot, implementations MAY set the high order 12 bits to
contain the low order 12 bits of current time, and the low order
20 bits to a random value. Senders of request messages MUST
insert a unique identifier on each message. The identifier MUST
remain locally unique for a period of at least 4 minutes, even
- across reboots. The originator of an Answer message MUST ensure
+ across reboots. The originator of an answer message MUST ensure
that the End-to-End Identifier field contains the same value that
was found in the corresponding request. The End-to-End Identifier
MUST NOT be modified by Diameter agents of any kind. The
- combination of the Origin-Host (see Section 6.3) and this field is
+ combination of the Origin-Host AVP (Section 6.3) and this field is
used to detect duplicates. Duplicate requests SHOULD cause the
- same answer to be transmitted (modulo the hop-by-hop Identifier
- field and any routing AVPs that may be present), and MUST NOT
- affect any state that was set when the original request was
- processed. Duplicate answer messages that are to be locally
- consumed (see Section 6.2) SHOULD be silently discarded.
-
-
+ same answer to be transmitted (modulo the Hop-by-Hop Identifier
-Fajardo, et al. Expires July 24, 2011 [Page 37]
+Fajardo, et al. Standards Track [Page 36]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ field and any routing AVPs that may be present), and they MUST NOT
+ affect any state that was set when the original request was
+ processed. Duplicate answer messages that are to be locally
+ consumed (see Section 6.2) SHOULD be silently discarded.
+
AVPs
AVPs are a method of encapsulating information relevant to the
@@ -2080,17 +2032,17 @@ Internet-Draft Diameter Base Protocol January 2011
3.1. Command Codes
- Each command Request/Answer pair is assigned a command code, and the
+ Each command Request/Answer pair is assigned a Command Code, and the
sub-type (i.e., request or answer) is identified via the 'R' bit in
the Command Flags field of the Diameter header.
-
- Every Diameter message MUST contain a command code in its header's
- Command-Code field, which is used to determine the action that is to
+ Every Diameter message MUST contain a Command Code in its header's
+ Command Code field, which is used to determine the action that is to
be taken for a particular message. The following Command Codes are
defined in the Diameter base protocol:
- Command-Name Abbrev. Code Reference
+ Section
+ Command Name Abbrev. Code Reference
--------------------------------------------------------
Abort-Session-Request ASR 274 8.5.1
Abort-Session-Answer ASA 274 8.5.2
@@ -2111,140 +2063,142 @@ Internet-Draft Diameter Base Protocol January 2011
Session-Termination- STA 275 8.4.2
Answer
-3.2. Command Code ABNF specification
- Every Command Code defined MUST include a corresponding ABNF
- specification, which is used to define the AVPs that MUST or MAY be
- present when sending the message. The following format is used in
- the definition:
- command-def = <command-name> "::=" diameter-message
- command-name = diameter-name
-Fajardo, et al. Expires July 24, 2011 [Page 38]
-
-Internet-Draft Diameter Base Protocol January 2011
- diameter-name = ALPHA *(ALPHA / DIGIT / "-")
+Fajardo, et al. Standards Track [Page 37]
+
+RFC 6733 Diameter Base Protocol October 2012
- diameter-message = header [ *fixed] [ *required] [ *optional]
- header = "<" "Diameter Header:" command-id
- [r-bit] [p-bit] [e-bit] [application-id] ">"
+3.2. Command Code Format Specification
- application-id = 1*DIGIT
+ Every Command Code defined MUST include a corresponding Command Code
+ Format (CCF) specification, which is used to define the AVPs that
+ MUST or MAY be present when sending the message. The following ABNF
+ specifies the CCF used in the definition:
- command-id = 1*DIGIT
- ; The Command Code assigned to the command
+ command-def = "<" command-name ">" "::=" diameter-message
- r-bit = ", REQ"
- ; If present, the 'R' bit in the Command
- ; Flags is set, indicating that the message
- ; is a request, as opposed to an answer.
+ command-name = diameter-name
- p-bit = ", PXY"
- ; If present, the 'P' bit in the Command
- ; Flags is set, indicating that the message
- ; is proxiable.
+ diameter-name = ALPHA *(ALPHA / DIGIT / "-")
- e-bit = ", ERR"
- ; If present, the 'E' bit in the Command
- ; Flags is set, indicating that the answer
- ; message contains a Result-Code AVP in
- ; the "protocol error" class.
+ diameter-message = header *fixed *required *optional
- fixed = [qual] "<" avp-spec ">"
- ; Defines the fixed position of an AVP
+ header = "<Diameter-Header:" command-id
+ [r-bit] [p-bit] [e-bit] [application-id]">"
- required = [qual] "{" avp-spec "}"
- ; The AVP MUST be present and can appear
- ; anywhere in the message.
+ application-id = 1*DIGIT
+ command-id = 1*DIGIT
+ ; The Command Code assigned to the command.
- optional = [qual] "[" avp-name "]"
- ; The avp-name in the 'optional' rule cannot
- ; evaluate to any AVP Name which is included
- ; in a fixed or required rule. The AVP can
- ; appear anywhere in the message.
- ;
- ; NOTE: "[" and "]" have a slightly different
- ; meaning than in ABNF (RFC 5234]). These braces
- ; cannot be used to express optional fixed rules
- ; (such as an optional ICV at the end). To do this,
- ; the convention is '0*1fixed'.
+ r-bit = ", REQ"
+ ; If present, the 'R' bit in the Command
+ ; Flags is set, indicating that the message
+ ; is a request as opposed to an answer.
+ p-bit = ", PXY"
+ ; If present, the 'P' bit in the Command
+ ; Flags is set, indicating that the message
+ ; is proxiable.
+ e-bit = ", ERR"
+ ; If present, the 'E' bit in the Command
+ ; Flags is set, indicating that the answer
+ ; message contains a Result-Code AVP in
+ ; the "protocol error" class.
+ fixed = [qual] "<" avp-spec ">"
+ ; Defines the fixed position of an AVP.
-Fajardo, et al. Expires July 24, 2011 [Page 39]
-
-Internet-Draft Diameter Base Protocol January 2011
+ required = [qual] "{" avp-spec "}"
+ ; The AVP MUST be present and can appear
+ ; anywhere in the message.
- qual = [min] "*" [max]
- ; See ABNF conventions, RFC 5234 Section 4.
- ; The absence of any qualifiers depends on
- ; whether it precedes a fixed, required, or
- ; optional rule. If a fixed or required rule has
- ; no qualifier, then exactly one such AVP MUST
- ; be present. If an optional rule has no
- ; qualifier, then 0 or 1 such AVP may be
- ; present. If an optional rule has a qualifier,
- ; then the value of min MUST be 0 if present.
- min = 1*DIGIT
- ; The minimum number of times the element may
- ; be present. If absent, the default value is zero
- ; for fixed and optional rules and one for required
- ; rules. The value MUST be at least one for for
- ; required rules.
- max = 1*DIGIT
- ; The maximum number of times the element may
- ; be present. If absent, the default value is
- ; infinity. A value of zero implies the AVP MUST
- ; NOT be present.
- avp-spec = diameter-name
- ; The avp-spec has to be an AVP Name, defined
- ; in the base or extended Diameter
- ; specifications.
-
- avp-name = avp-spec / "AVP"
- ; The string "AVP" stands for *any* arbitrary AVP
- ; Name, not otherwise listed in that command code
- ; definition. Addition this AVP is recommended for
- ; all command ABNFs to allow for extensibility.
+Fajardo, et al. Standards Track [Page 38]
+
+RFC 6733 Diameter Base Protocol October 2012
- The following is a definition of a fictitious command code:
+ optional = [qual] "[" avp-name "]"
+ ; The avp-name in the 'optional' rule cannot
+ ; evaluate to any AVP Name that is included
+ ; in a fixed or required rule. The AVP can
+ ; appear anywhere in the message.
+ ;
+ ; NOTE: "[" and "]" have a slightly different
+ ; meaning than in ABNF. These braces
+ ; cannot be used to express optional fixed rules
+ ; (such as an optional ICV at the end). To do
+ ; this, the convention is '0*1fixed'.
- Example-Request ::= < Diameter Header: 9999999, REQ, PXY >
- { User-Name }
- * { Origin-Host }
- * [ AVP ]
+ qual = [min] "*" [max]
+ ; See ABNF conventions, RFC 5234, Section 4.
+ ; The absence of any qualifier depends on
+ ; whether it precedes a fixed, required, or
+ ; optional rule. If a fixed or required rule has
+ ; no qualifier, then exactly one such AVP MUST
+ ; be present. If an optional rule has no
+ ; qualifier, then 0 or 1 such AVP may be
+ ; present. If an optional rule has a qualifier,
+ ; then the value of min MUST be 0 if present.
+ min = 1*DIGIT
+ ; The minimum number of times the element may
+ ; be present. If absent, the default value is 0
+ ; for fixed and optional rules and 1 for
+ ; required rules. The value MUST be at least 1
+ ; for required rules.
+ max = 1*DIGIT
+ ; The maximum number of times the element may
+ ; be present. If absent, the default value is
+ ; infinity. A value of 0 implies the AVP MUST
+ ; NOT be present.
+ avp-spec = diameter-name
+ ; The avp-spec has to be an AVP Name, defined
+ ; in the base or extended Diameter
+ ; specifications.
+ avp-name = avp-spec / "AVP"
+ ; The string "AVP" stands for *any* arbitrary AVP
+ ; Name, not otherwise listed in that Command Code
+ ; definition. The inclusion of this string
+ ; is recommended for all CCFs to allow for
+ ; extensibility.
-Fajardo, et al. Expires July 24, 2011 [Page 40]
+Fajardo, et al. Standards Track [Page 39]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ The following is a definition of a fictitious Command Code:
+ Example-Request ::= < Diameter Header: 9999999, REQ, PXY >
+ { User-Name }
+ 1* { Origin-Host }
+ * [ AVP ]
3.3. Diameter Command Naming Conventions
Diameter command names typically includes one or more English words
- followed by the verb Request or Answer. Each English word is
+ followed by the verb "Request" or "Answer". Each English word is
delimited by a hyphen. A three-letter acronym for both the request
and answer is also normally provided.
@@ -2253,10 +2207,10 @@ Internet-Draft Diameter Base Protocol January 2011
the acronyms are STR and STA, respectively.
Both the request and the answer for a given command share the same
- command code. The request is identified by the R(equest) bit in the
+ Command Code. The request is identified by the R(equest) bit in the
Diameter header set to one (1), to ask that a particular action be
performed, such as authorizing a user or terminating a session. Once
- the receiver has completed the request it issues the corresponding
+ the receiver has completed the request, it issues the corresponding
answer, which includes a result code that communicates one of the
following:
@@ -2274,38 +2228,25 @@ Internet-Draft Diameter Base Protocol January 2011
Additional information, encoded within AVPs, may also be included in
answer messages.
+4. Diameter AVPs
+ Diameter AVPs carry specific authentication, accounting,
+ authorization, and routing information as well as configuration
+ details for the request and reply.
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 41]
+Fajardo, et al. Standards Track [Page 40]
-Internet-Draft Diameter Base Protocol January 2011
-
-
-4. Diameter AVPs
+RFC 6733 Diameter Base Protocol October 2012
- Diameter AVPs carry specific authentication, accounting,
- authorization and routing information as well as configuration
- details for the request and reply.
Each AVP of type OctetString MUST be padded to align on a 32-bit
boundary, while other AVP types align naturally. A number of zero-
- valued bytes are added to the end of the AVP Data field till a word
+ valued bytes are added to the end of the AVP Data field until a word
boundary is reached. The length of the padding is not reflected in
the AVP Length field.
@@ -2330,92 +2271,96 @@ Internet-Draft Diameter Base Protocol January 2011
The AVP Code, combined with the Vendor-Id field, identifies the
attribute uniquely. AVP numbers 1 through 255 are reserved for
- re-use of RADIUS attributes, without setting the Vendor-Id field.
+ reuse of RADIUS attributes, without setting the Vendor-Id field.
AVP numbers 256 and above are used for Diameter, which are
- allocated by IANA (see Section 11.1).
-
+ allocated by IANA (see Section 11.1.1).
AVP Flags
The AVP Flags field informs the receiver how each attribute must
- be handled. The 'r' (reserved) bits are unused and SHOULD be set
- to 0. Note that subsequent Diameter applications MAY define
- additional bits within the AVP Header, and an unrecognized bit
- SHOULD be considered an error. The 'P' bit has been reserved for
- future usage of end-to-end security. At the time of writing there
- are no end-to-end security mechanisms specified therefore the 'P'
- bit SHOULD be set to 0.
+ be handled. New Diameter applications SHOULD NOT define
+ additional AVP Flag bits. However, note that new Diameter
+ applications MAY define additional bits within the AVP header, and
+ an unrecognized bit SHOULD be considered an error. The sender of
+ the AVP MUST set 'R' (reserved) bits to 0 and the receiver SHOULD
+ ignore all 'R' (reserved) bits. The 'P' bit has been reserved for
+ future usage of end-to-end security. At the time of writing,
+ there are no end-to-end security mechanisms specified; therefore,
+ the 'P' bit SHOULD be set to 0.
+
+ The 'M' bit, known as the Mandatory bit, indicates whether the
+ receiver of the AVP MUST parse and understand the semantics of the
+ AVP including its content. The receiving entity MUST return an
+ appropriate error message if it receives an AVP that has the M-bit
-Fajardo, et al. Expires July 24, 2011 [Page 42]
+Fajardo, et al. Standards Track [Page 41]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- The 'M' Bit, known as the Mandatory bit, indicates whether the
- receiver of the AVP MUST parse and understand the semantic of the
- AVP including its content. The receiving entity MUST return an
- appropriate error message if it receives an AVP that has the M-bit
set but does not understand it. An exception applies when the AVP
is embedded within a Grouped AVP. See Section 4.4 for details.
- Diameter Relay and redirect agents MUST NOT reject messages with
+ Diameter relay and redirect agents MUST NOT reject messages with
unrecognized AVPs.
The 'M' bit MUST be set according to the rules defined in the
- application specification which introduces or re-uses this AVP.
- Within a given application, the M-bit setting for an AVP is either
- defined for all command types or for each command type.
+ application specification that introduces or reuses this AVP.
+ Within a given application, the M-bit setting for an AVP is
+ defined either for all command types or for each command type.
- AVPs with the 'M' bit cleared are informational only and a
- receiver that receives a message with such an AVP that is not
- supported, or whose value is not supported, MAY simply ignore the
- AVP.
+ AVPs with the 'M' bit cleared are informational only; a receiver
+ that receives a message with such an AVP that is not supported, or
+ whose value is not supported, MAY simply ignore the AVP.
The 'V' bit, known as the Vendor-Specific bit, indicates whether
the optional Vendor-ID field is present in the AVP header. When
- set the AVP Code belongs to the specific vendor code address
+ set, the AVP Code belongs to the specific vendor code address
space.
AVP Length
The AVP Length field is three octets, and indicates the number of
- octets in this AVP including the AVP Code, AVP Length, AVP Flags,
- Vendor-ID field (if present) and the AVP data. If a message is
- received with an invalid attribute length, the message MUST be
- rejected.
+ octets in this AVP including the AVP Code field, AVP Length field,
+ AVP Flags field, Vendor-ID field (if present), and the AVP Data
+ field. If a message is received with an invalid attribute length,
+ the message MUST be rejected.
4.1.1. Optional Header Elements
- The AVP Header contains one optional field. This field is only
+ The AVP header contains one optional field. This field is only
present if the respective bit-flag is enabled.
-
Vendor-ID
The Vendor-ID field is present if the 'V' bit is set in the AVP
Flags field. The optional four-octet Vendor-ID field contains the
- IANA assigned "SMI Network Management Private Enterprise Codes"
- [RFC3232] value, encoded in network byte order. Any vendor or
- standardization organization that are also treated like vendors in
- the IANA managed "SMI Network Management Private Enterprise Codes"
- space wishing to implement a vendor-specific Diameter AVP MUST use
- their own Vendor-ID along with their privately managed AVP address
+ IANA-assigned "SMI Network Management Private Enterprise Codes"
+ [ENTERPRISE] value, encoded in network byte order. Any vendors or
+ standardization organizations that are also treated like vendors
+ in the IANA-managed "SMI Network Management Private Enterprise
+ Codes" space wishing to implement a vendor-specific Diameter AVP
+ MUST use their own Vendor-ID along with their privately managed
+ AVP address space, guaranteeing that they will not collide with
+ any other vendor's vendor-specific AVP(s) or with future IETF
+ AVPs.
-Fajardo, et al. Expires July 24, 2011 [Page 43]
-
-Internet-Draft Diameter Base Protocol January 2011
- space, guaranteeing that they will not collide with any other
- vendor's vendor-specific AVP(s), nor with future IETF AVPs.
- A vendor ID value of zero (0) corresponds to the IETF adopted AVP
- values, as managed by the IANA. Since the absence of the vendor
- ID field implies that the AVP in question is not vendor specific,
- implementations MUST NOT use the zero (0) vendor ID.
+Fajardo, et al. Standards Track [Page 42]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ A Vendor-ID value of zero (0) corresponds to the IETF-adopted AVP
+ values, as managed by IANA. Since the absence of the Vendor-ID
+ field implies that the AVP in question is not vendor specific,
+ implementations MUST NOT use the value of zero (0) for the
+ Vendor-ID field.
4.2. Basic AVP Data Formats
@@ -2426,49 +2371,45 @@ Internet-Draft Diameter Base Protocol January 2011
type derived from the base data types. In the event that a new Basic
AVP Data Format is needed, a new version of this RFC MUST be created.
-
OctetString
The data contains arbitrary data of variable length. Unless
otherwise noted, the AVP Length field MUST be set to at least 8
- (12 if the 'V' bit is enabled). AVP Values of this type that are
- not a multiple of four-octets in length is followed by the
- necessary padding so that the next AVP (if any) will start on a
- 32-bit boundary.
-
+ (12 if the 'V' bit is enabled). AVP values of this type that are
+ not a multiple of 4 octets in length are followed by the necessary
+ padding so that the next AVP (if any) will start on a 32-bit
+ boundary.
Integer32
- 32 bit signed value, in network byte order. The AVP Length field
+ 32-bit signed value, in network byte order. The AVP Length field
MUST be set to 12 (16 if the 'V' bit is enabled).
-
Integer64
- 64 bit signed value, in network byte order. The AVP Length field
+ 64-bit signed value, in network byte order. The AVP Length field
MUST be set to 16 (20 if the 'V' bit is enabled).
-
Unsigned32
- 32 bit unsigned value, in network byte order. The AVP Length
+ 32-bit unsigned value, in network byte order. The AVP Length
field MUST be set to 12 (16 if the 'V' bit is enabled).
+ Unsigned64
+ 64-bit unsigned value, in network byte order. The AVP Length
+ field MUST be set to 16 (20 if the 'V' bit is enabled).
-Fajardo, et al. Expires July 24, 2011 [Page 44]
-
-Internet-Draft Diameter Base Protocol January 2011
- Unsigned64
- 64 bit unsigned value, in network byte order. The AVP Length
- field MUST be set to 16 (20 if the 'V' bit is enabled).
+Fajardo, et al. Standards Track [Page 43]
+
+RFC 6733 Diameter Base Protocol October 2012
Float32
@@ -2478,7 +2419,6 @@ Internet-Draft Diameter Base Protocol January 2011
network byte order. The AVP Length field MUST be set to 12 (16 if
the 'V' bit is enabled).
-
Float64
This represents floating point values of double precision as
@@ -2486,73 +2426,69 @@ Internet-Draft Diameter Base Protocol January 2011
network byte order. The AVP Length field MUST be set to 16 (20 if
the 'V' bit is enabled).
-
Grouped
- The Data field is specified as a sequence of AVPs. Each of these
- AVPs follows - in the order in which they are specified -
- including their headers and padding. The AVP Length field is set
- to 8 (12 if the 'V' bit is enabled) plus the total length of all
- included AVPs, including their headers and padding. Thus the AVP
- length field of an AVP of type Grouped is always a multiple of 4.
-
+ The Data field is specified as a sequence of AVPs. These AVPs are
+ concatenated -- including their headers and padding -- in the
+ order in which they are specified and the result encapsulated in
+ the Data field. The AVP Length field is set to 8 (12 if the 'V'
+ bit is enabled) plus the total length of all included AVPs,
+ including their headers and padding. Thus, the AVP Length field
+ of an AVP of type Grouped is always a multiple of 4.
4.3. Derived AVP Data Formats
In addition to using the Basic AVP Data Formats, applications may
define data formats derived from the Basic AVP Data Formats. An
application that defines new Derived AVP Data Formats MUST include
- them in a section entitled "Derived AVP Data Formats", using the same
+ them in a section titled "Derived AVP Data Formats", using the same
format as the definitions below. Each new definition MUST be either
defined or listed with a reference to the RFC that defines the
format.
-4.3.1. Common Derived AVPs
+4.3.1. Common Derived AVP Data Formats
The following are commonly used Derived AVP Data Formats.
+ Address
+ The Address format is derived from the OctetString Basic AVP
+ Format. It is a discriminated union representing, for example, a
+ 32-bit (IPv4) [RFC0791] or 128-bit (IPv6) [RFC4291] address, most
+ significant octet first. The first two octets of the Address AVP
+ represent the AddressType, which contains an Address Family,
+ defined in [IANAADFAM]. The AddressType is used to discriminate
+ the content and format of the remaining octets.
-Fajardo, et al. Expires July 24, 2011 [Page 45]
+Fajardo, et al. Standards Track [Page 44]
-Internet-Draft Diameter Base Protocol January 2011
-
-
- Address
-
- The Address format is derived from the OctetString AVP Base
- Format. It is a discriminated union, representing, for example a
- 32-bit (IPv4) [RFC791] or 128-bit (IPv6) [RFC4291] address, most
- significant octet first. The first two octets of the Address AVP
- represents the AddressType, which contains an Address Family
- defined in [IANAADFAM]. The AddressType is used to discriminate
- the content and format of the remaining octets.
+RFC 6733 Diameter Base Protocol October 2012
Time
- The Time format is derived from the OctetString AVP Base Format.
+ The Time format is derived from the OctetString Basic AVP Format.
The string MUST contain four octets, in the same format as the
first four bytes are in the NTP timestamp format. The NTP
- Timestamp format is defined in Chapter 3 of [RFC5905].
+ timestamp format is defined in Section 3 of [RFC5905].
This represents the number of seconds since 0h on 1 January 1900
with respect to the Coordinated Universal Time (UTC).
- On 6h 28m 16s UTC, 7 February 2036 the time value will overflow.
- SNTP [RFC5905] describes a procedure to extend the time to 2104.
- This procedure MUST be supported by all Diameter nodes.
-
+ On 6h 28m 16s UTC, 7 February 2036, the time value will overflow.
+ Simple Network Time Protocol (SNTP) [RFC5905] describes a
+ procedure to extend the time to 2104. This procedure MUST be
+ supported by all Diameter nodes.
UTF8String
- The UTF8String format is derived from the OctetString AVP Base
- Format. This is a human readable string represented using the
+ The UTF8String format is derived from the OctetString Basic AVP
+ Format. This is a human-readable string represented using the
ISO/IEC IS 10646-1 character set, encoded as an OctetString using
- the UTF-8 [RFC3629] transformation format described in RFC 3629.
+ the UTF-8 transformation format [RFC3629].
Since additional code points are added by amendments to the 10646
standard from time to time, implementations MUST be prepared to
@@ -2570,78 +2506,79 @@ Internet-Draft Diameter Base Protocol January 2011
or software, an alternative means of entry and display, such as
hexadecimal, MAY be provided.
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 46]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
For information encoded in 7-bit US-ASCII, the UTF-8 charset is
identical to the US-ASCII charset.
UTF-8 may require multiple bytes to represent a single character /
- code point; thus the length of an UTF8String in octets may be
+ code point; thus, the length of a UTF8String in octets may be
different from the number of characters encoded.
Note that the AVP Length field of an UTF8String is measured in
- octets, not characters.
+ octets not characters.
+
+
+
+
+Fajardo, et al. Standards Track [Page 45]
+
+RFC 6733 Diameter Base Protocol October 2012
+
DiameterIdentity
- The DiameterIdentity format is derived from the OctetString AVP
- Base Format.
+ The DiameterIdentity format is derived from the OctetString Basic
+ AVP Format.
DiameterIdentity = FQDN/Realm
-
- DiameterIdentity value is used to uniquely identify either:
+ The DiameterIdentity value is used to uniquely identify either:
* A Diameter node for purposes of duplicate connection and
routing loop detection.
- * A Realm to determine whether messages can be satisfied locally,
+ * A Realm to determine whether messages can be satisfied locally
or whether they must be routed or redirected.
+ When a DiameterIdentity value is used to identify a Diameter node,
+ the contents of the string MUST be the Fully Qualified Domain Name
+ (FQDN) of the Diameter node. If multiple Diameter nodes run on
+ the same host, each Diameter node MUST be assigned a unique
+ DiameterIdentity. If a Diameter node can be identified by several
+ FQDNs, a single FQDN should be picked at startup and used as the
+ only DiameterIdentity for that node, whatever the connection on
+ which it is sent. In this document, note that DiameterIdentity is
+ in ASCII form in order to be compatible with existing DNS
+ infrastructure. See Appendix D for interactions between the
+ Diameter protocol and Internationalized Domain Names (IDNs).
- When a DiameterIdentity is used to identify a Diameter node the
- contents of the string MUST be the FQDN of the Diameter node. If
- multiple Diameter nodes run on the same host, each Diameter node
- MUST be assigned a unique DiameterIdentity. If a Diameter node
- can be identified by several FQDNs, a single FQDN should be picked
- at startup, and used as the only DiameterIdentity for that node,
- whatever the connection it is sent on. Note that in this
- document, DiameterIdentity is in ASCII form in order to be
- compatible with existing DNS infrastructure. See Appendix D for
- interactions between the Diameter protocol and Internationalized
- Domain Name (IDNs).
+ DiameterURI
+ The DiameterURI MUST follow the Uniform Resource Identifiers (RFC
+ 3986) syntax [RFC3986] rules specified below:
- DiameterURI
+ "aaa://" FQDN [ port ] [ transport ] [ protocol ]
- The DiameterURI MUST follow the Uniform Resource Identifiers (URI)
- syntax [RFC3986] rules specified below:
+ ; No transport security
+ "aaas://" FQDN [ port ] [ transport ] [ protocol ]
+ ; Transport security used
+ FQDN = < Fully Qualified Domain Name >
-Fajardo, et al. Expires July 24, 2011 [Page 47]
-
-Internet-Draft Diameter Base Protocol January 2011
- "aaa://" FQDN [ port ] [ transport ] [ protocol ]
- ; No transport security
- "aaas://" FQDN [ port ] [ transport ] [ protocol ]
- ; Transport security used
- FQDN = Fully Qualified Host Name
+Fajardo, et al. Standards Track [Page 46]
+
+RFC 6733 Diameter Base Protocol October 2012
+
port = ":" 1*DIGIT
@@ -2649,8 +2586,9 @@ Internet-Draft Diameter Base Protocol January 2011
; incoming connections.
; If absent, the default Diameter port
; (3868) is assumed if no transport
- ; security is used and port (TBD) when
- ; transport security (TLS/TCP and DTLS/SCTP) is used.
+ ; security is used and port 5658 when
+ ; transport security (TLS/TCP and DTLS/SCTP)
+ ; is used.
transport = ";transport=" transport-protocol
@@ -2660,46 +2598,47 @@ Internet-Draft Diameter Base Protocol January 2011
; UDP MUST NOT be used when the aaa-protocol
; field is set to diameter.
- transport-protocol = ( "tcp" / "sctp" / "udp" )
+ transport-protocol = ( "tcp" / "sctp" / "udp" )
- protocol = ";protocol=" aaa-protocol
+ protocol = ";protocol=" aaa-protocol
; If absent, the default AAA protocol
; is Diameter.
- aaa-protocol = ( "diameter" / "radius" / "tacacs+" )
+ aaa-protocol = ( "diameter" / "radius" / "tacacs+" )
- The following are examples of valid Diameter host identities:
+ The following are examples of valid Diameter host identities:
- aaa://host.example.com;transport=tcp
- aaa://host.example.com:6666;transport=tcp
- aaa://host.example.com;protocol=diameter
- aaa://host.example.com:6666;protocol=diameter
- aaa://host.example.com:6666;transport=tcp;protocol=diameter
- aaa://host.example.com:1813;transport=udp;protocol=radius
+ aaa://host.example.com;transport=tcp
+ aaa://host.example.com:6666;transport=tcp
+ aaa://host.example.com;protocol=diameter
+ aaa://host.example.com:6666;protocol=diameter
+ aaa://host.example.com:6666;transport=tcp;protocol=diameter
+ aaa://host.example.com:1813;transport=udp;protocol=radius
+ Enumerated
+ The Enumerated format is derived from the Integer32 Basic AVP
+ Format. The definition contains a list of valid values and their
+ interpretation and is described in the Diameter application
+ introducing the AVP.
-Fajardo, et al. Expires July 24, 2011 [Page 48]
-
-Internet-Draft Diameter Base Protocol January 2011
- Enumerated
- Enumerated is derived from the Integer32 AVP Base Format. The
- definition contains a list of valid values and their
- interpretation and is described in the Diameter application
- introducing the AVP.
+
+Fajardo, et al. Standards Track [Page 47]
+
+RFC 6733 Diameter Base Protocol October 2012
IPFilterRule
- The IPFilterRule format is derived from the OctetString AVP Base
+ The IPFilterRule format is derived from the OctetString Basic AVP
Format and uses the ASCII charset. The rule syntax is a modified
subset of ipfw(8) from FreeBSD. Packets may be filtered based on
the following information that is associated with it:
@@ -2713,13 +2652,13 @@ Internet-Draft Diameter Base Protocol January 2011
IP options
ICMP types
- Rules for the appropriate direction are evaluated in order, with
- the first matched rule terminating the evaluation. Each packet is
- evaluated once. If no rule matches, the packet is dropped if the
- last rule evaluated was a permit, and passed if the last rule was
- a deny.
+ Rules for the appropriate direction are evaluated in order, with the
+ first matched rule terminating the evaluation. Each packet is
+ evaluated once. If no rule matches, the packet is dropped if the
+ last rule evaluated was a permit, and passed if the last rule was a
+ deny.
- IPFilterRule filters MUST follow the format:
+ IPFilterRule filters MUST follow the format:
action dir proto from src to dst [options]
@@ -2737,22 +2676,28 @@ Internet-Draft Diameter Base Protocol January 2011
The <address/mask> may be specified as:
ipno An IPv4 or IPv6 number in dotted-
quad or canonical IPv6 form. Only
+ this exact IP number will match the
+ rule.
+
+
+
+
+
+
-Fajardo, et al. Expires July 24, 2011 [Page 49]
+Fajardo, et al. Standards Track [Page 48]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- this exact IP number will match the
- rule.
ipno/bits An IP number as above with a mask
width of the form 192.0.2.10/24. In
this case, all IP numbers from
192.0.2.0 to 192.0.2.255 will match.
The bit width MUST be valid for the
- IP version and the IP number MUST
+ IP version, and the IP number MUST
NOT have bits set beyond the mask.
For a match to occur, the same IP
version must be present in the
@@ -2765,7 +2710,7 @@ Internet-Draft Diameter Base Protocol January 2011
is the address or set of addresses
assigned to the terminal. For IPv4,
a typical first rule is often "deny
- in ip! assigned"
+ in ip! assigned".
The sense of the match can be inverted by
preceding an address with the not modifier (!),
@@ -2773,7 +2718,7 @@ Internet-Draft Diameter Base Protocol January 2011
instead. This does not affect the selection of
port numbers.
- With the TCP, UDP and SCTP protocols, optional
+ With the TCP, UDP, and SCTP protocols, optional
ports may be specified as:
{port/port-port}[,ports[,...]]
@@ -2796,33 +2741,35 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 50]
+
+
+Fajardo, et al. Standards Track [Page 49]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- ipoptions spec
- Match if the IP header contains the comma
- separated list of options specified in spec. The
+ ipoptions spec
+ Match if the IP header contains the comma-separated
+ list of options specified in spec. The
supported IP options are:
ssrr (strict source route), lsrr (loose source
- route), rr (record packet route) and ts
+ route), rr (record packet route), and ts
(timestamp). The absence of a particular option
may be denoted with a '!'.
tcpoptions spec
- Match if the TCP header contains the comma
- separated list of options specified in spec. The
+ Match if the TCP header contains the comma-separated
+ list of options specified in spec. The
supported TCP options are:
mss (maximum segment size), window (tcp window
advertisement), sack (selective ack), ts (rfc1323
- timestamp) and cc (rfc1644 t/tcp connection
+ timestamp), and cc (rfc1644 t/tcp connection
count). The absence of a particular option may
be denoted with a '!'.
- established
+ established
TCP packets only. Match packets that have the RST
or ACK bits set.
@@ -2832,10 +2779,10 @@ Internet-Draft Diameter Base Protocol January 2011
tcpflags spec
TCP packets only. Match if the TCP header
- contains the comma separated list of flags
+ contains the comma-separated list of flags
specified in spec. The supported TCP flags are:
- fin, syn, rst, psh, ack and urg. The absence of a
+ fin, syn, rst, psh, ack, and urg. The absence of a
particular flag may be denoted with a '!'. A rule
that contains a tcpflags specification can never
match a fragmented packet that has a non-zero
@@ -2852,9 +2799,9 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 51]
+Fajardo, et al. Standards Track [Page 50]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
echo reply (0), destination unreachable (3),
@@ -2863,21 +2810,20 @@ Internet-Draft Diameter Base Protocol January 2011
solicitation (10), time-to-live exceeded (11), IP
header bad (12), timestamp request (13),
timestamp reply (14), information request (15),
- information reply (16), address mask request (17)
+ information reply (16), address mask request (17),
and address mask reply (18).
- There is one kind of packet that the access device MUST always
- discard, that is an IP fragment with a fragment offset of one.
- This is a valid packet, but it only has one use, to try to
- circumvent firewalls.
-
- An access device that is unable to interpret or apply a deny rule
- MUST terminate the session. An access device that is unable to
- interpret or apply a permit rule MAY apply a more restrictive
- rule. An access device MAY apply deny rules of its own before the
- supplied rules, for example to protect the access device owner's
- infrastructure.
+ There is one kind of packet that the access device MUST always
+ discard, that is an IP fragment with a fragment offset of one. This
+ is a valid packet, but it only has one use, to try to circumvent
+ firewalls.
+ An access device that is unable to interpret or apply a deny rule
+ MUST terminate the session. An access device that is unable to
+ interpret or apply a permit rule MAY apply a more restrictive rule.
+ An access device MAY apply deny rules of its own before the supplied
+ rules, for example to protect the access device owner's
+ infrastructure.
4.4. Grouped AVP Values
@@ -2885,75 +2831,76 @@ Internet-Draft Diameter Base Protocol January 2011
implies that the Data field is actually a sequence of AVPs. It is
possible to include an AVP with a Grouped type within a Grouped type,
that is, to nest them. AVPs within an AVP of type Grouped have the
- same padding requirements as non-Grouped AVPs, as defined in Section
- 4.
+ same padding requirements as non-Grouped AVPs, as defined in
+ Section 4.4.
The AVP Code numbering space of all AVPs included in a Grouped AVP is
- the same as for non-grouped AVPs. Receivers of a Grouped AVP that
+ the same as for non-Grouped AVPs. Receivers of a Grouped AVP that
does not have the 'M' (mandatory) bit set and one or more of the
encapsulated AVPs within the group has the 'M' (mandatory) bit set
MAY simply be ignored if the Grouped AVP itself is unrecognized. The
rule applies even if the encapsulated AVP with its 'M' (mandatory)
- bit set is further encapsulated within other sub-groups; i.e. other
+ bit set is further encapsulated within other sub-groups, i.e., other
Grouped AVPs embedded within the Grouped AVP.
- Every Grouped AVP defined MUST include a corresponding grammar, using
- ABNF [RFC5234] (with modifications), as defined below.
-
+ Every Grouped AVP definition MUST include a corresponding grammar,
+ using ABNF [RFC5234] (with modifications), as defined below.
+ grouped-avp-def = "<" name ">" "::=" avp
+ name-fmt = ALPHA *(ALPHA / DIGIT / "-")
-Fajardo, et al. Expires July 24, 2011 [Page 52]
+Fajardo, et al. Standards Track [Page 51]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- grouped-avp-def = <name> "::=" avp
-
- name-fmt = ALPHA *(ALPHA / DIGIT / "-")
-
name = name-fmt
; The name has to be the name of an AVP,
; defined in the base or extended Diameter
; specifications.
- avp = header [ *fixed] [ *required] [ *optional]
+ avp = header *fixed *required *optional
header = "<" "AVP-Header:" avpcode [vendor] ">"
avpcode = 1*DIGIT
- ; The AVP Code assigned to the Grouped AVP
+ ; The AVP Code assigned to the Grouped AVP.
vendor = 1*DIGIT
; The Vendor-ID assigned to the Grouped AVP.
; If absent, the default value of zero is
; used.
-4.4.1. Example AVP with a Grouped Data type
+4.4.1. Example AVP with a Grouped Data Type
The Example-AVP (AVP Code 999999) is of type Grouped and is used to
clarify how Grouped AVP values work. The Grouped Data field has the
- following ABNF grammar:
-
-
-
-
-
-
-
-
+ following CCF grammar:
+ Example-AVP ::= < AVP Header: 999999 >
+ { Origin-Host }
+ 1*{ Session-Id }
+ *[ AVP ]
+ An Example-AVP with Grouped Data follows.
+ The Origin-Host AVP (Section 6.3) is required. In this case:
+ Origin-Host = "example.com".
+ One or more Session-Ids must follow. Here there are two:
+ Session-Id =
+ "grump.example.com:33041;23432;893;0AF3B81"
+ Session-Id =
+ "grump.example.com:33054;23561;2358;0AF3B82"
@@ -2964,31 +2911,11 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 53]
+Fajardo, et al. Standards Track [Page 52]
-Internet-Draft Diameter Base Protocol January 2011
-
-
- Example-AVP ::= < AVP Header: 999999 >
- { Origin-Host }
- 1*{ Session-Id }
- *[ AVP ]
-
- An Example-AVP with Grouped Data follows.
-
- The Origin-Host AVP is required (Section 6.3). In this case:
-
- Origin-Host = "example.com".
+RFC 6733 Diameter Base Protocol October 2012
- One or more Session-Ids must follow. Here there are two:
-
- Session-Id =
- "grump.example.com:33041;23432;893;0AF3B81"
-
- Session-Id =
- "grump.example.com:33054;23561;2358;0AF3B82"
-
optional AVPs included are
Recovery-Policy = <binary>
@@ -3007,25 +2934,42 @@ Internet-Draft Diameter Base Protocol January 2011
41d018d56fe938f3cbf089aac12a912a2f0d1923a9390e5f789cb2e5067
d3427475e49968f841
- The data for the optional AVPs is represented in hex since the format
- of these AVPs is neither known at the time of definition of the
- Example-AVP group, nor (likely) at the time when the example instance
- of this AVP is interpreted - except by Diameter implementations which
- support the same set of AVPs. The encoding example illustrates how
- padding is used and how length fields are calculated. Also note that
- AVPs may be present in the Grouped AVP value which the receiver
- cannot interpret (here, the Recover-Policy and Futuristic-Acct-Record
- AVPs). The length of the Example-AVP is the sum of all the length of
- the member AVPs including their padding plus the Example-AVP header
+ The data for the optional AVPs is represented in hexadecimal form
+ since the format of these AVPs is not known at the time of definition
+ of the Example-AVP group nor (likely) at the time when the example
+ instance of this AVP is interpreted -- except by Diameter
+ implementations that support the same set of AVPs. The encoding
+ example illustrates how padding is used and how length fields are
+ calculated. Also, note that AVPs may be present in the Grouped AVP
+ value that the receiver cannot interpret (here, the Recover-Policy
+ and Futuristic-Acct-Record AVPs). The length of the Example-AVP is
+ the sum of all the length of the member AVPs, including their
+ padding, plus the Example-AVP header size.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-Fajardo, et al. Expires July 24, 2011 [Page 54]
-
-Internet-Draft Diameter Base Protocol January 2011
- size.
+
+Fajardo, et al. Standards Track [Page 53]
+
+RFC 6733 Diameter Base Protocol October 2012
This AVP would be encoded as follows:
@@ -3076,15 +3020,18 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 55]
+
+
+
+Fajardo, et al. Standards Track [Page 54]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
4.5. Diameter Base Protocol AVPs
The following table describes the Diameter AVPs defined in the base
- protocol, their AVP Code values, types, possible flag values.
+ protocol, their AVP Code values, types, and possible flag values.
Due to space constraints, the short form DiamIdent is used to
represent DiameterIdentity.
@@ -3132,9 +3079,9 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 56]
+Fajardo, et al. Standards Track [Page 55]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+----------+
@@ -3154,7 +3101,7 @@ Internet-Draft Diameter Base Protocol January 2011
Record-Number | | |
Accounting- 480 9.8.1 Enumerated | M | V |
Record-Type | | |
- Accounting- 44 9.8.4 OctetString| M | V |
+ Acct- 44 9.8.4 OctetString| M | V |
Session-Id | | |
Accounting- 287 9.8.6 Unsigned64 | M | V |
Sub-Session-Id | | |
@@ -3188,9 +3135,9 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 57]
+Fajardo, et al. Standards Track [Page 56]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+----------+
@@ -3244,9 +3191,9 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 58]
+Fajardo, et al. Standards Track [Page 57]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
5. Diameter Peers
@@ -3258,25 +3205,25 @@ Internet-Draft Diameter Base Protocol January 2011
Connections between diameter peers are established using their valid
DiameterIdentity. A Diameter node initiating a connection to a peer
- MUST know the peers DiameterIdentity. Methods for discovering a
+ MUST know the peer's DiameterIdentity. Methods for discovering a
Diameter peer can be found in Section 5.2.
- Although a Diameter node may have many possible peers that it is able
- to communicate with, it may not be economical to have an established
- connection to all of them. At a minimum, a Diameter node SHOULD have
- an established connection with two peers per realm, known as the
- primary and secondary peers. Of course, a node MAY have additional
- connections, if it is deemed necessary. Typically, all messages for
- a realm are sent to the primary peer, but in the event that failover
- procedures are invoked, any pending requests are sent to the
- secondary peer. However, implementations are free to load balance
- requests between a set of peers.
-
- Note that a given peer MAY act as a primary for a given realm, while
+ Although a Diameter node may have many possible peers with which it
+ is able to communicate, it may not be economical to have an
+ established connection to all of them. At a minimum, a Diameter node
+ SHOULD have an established connection with two peers per realm, known
+ as the primary and secondary peers. Of course, a node MAY have
+ additional connections, if it is deemed necessary. Typically, all
+ messages for a realm are sent to the primary peer but, in the event
+ that failover procedures are invoked, any pending requests are sent
+ to the secondary peer. However, implementations are free to load
+ balance requests between a set of peers.
+
+ Note that a given peer MAY act as a primary for a given realm while
acting as a secondary for another realm.
When a peer is deemed suspect, which could occur for various reasons,
- including not receiving a DWA within an allotted timeframe, no new
+ including not receiving a DWA within an allotted time frame, no new
requests should be forwarded to the peer, but failover procedures are
invoked. When an active peer is moved to this mode, additional
connections SHOULD be established to ensure that the necessary number
@@ -3284,15 +3231,14 @@ Internet-Draft Diameter Base Protocol January 2011
There are two ways that a peer is removed from the suspect peer list:
-
1. The peer is no longer reachable, causing the transport connection
- to be shutdown. The peer is moved to the closed state.
+ to be shut down. The peer is moved to the closed state.
- 2. Three watchdog messages are exchanged with accepted round trip
+ 2. Three watchdog messages are exchanged with accepted round-trip
times, and the connection to the peer is considered stabilized.
In the event the peer being removed is either the primary or
- secondary, an alternate peer SHOULD replace the deleted peer, and
+ secondary, an alternate peer SHOULD replace the deleted peer and
assume the role of either primary or secondary.
@@ -3300,99 +3246,106 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 59]
+
+Fajardo, et al. Standards Track [Page 58]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
5.2. Diameter Peer Discovery
- Allowing for dynamic Diameter agent discovery will make it possible
- for simpler and more robust deployment of Diameter services. In
- order to promote interoperable implementations of Diameter peer
- discovery, the following mechanisms are described. These are based
- on existing IETF standards. The first option (manual configuration)
- MUST be supported by all Diameter nodes, while the latter option
- (DNS) MAY be supported.
+ Allowing for dynamic Diameter agent discovery makes possible simpler
+ and more robust deployment of Diameter services. In order to promote
+ interoperable implementations of Diameter peer discovery, the
+ following mechanisms (manual configuration and DNS) are described.
+ These are based on existing IETF standards. Both mechanisms MUST be
+ supported by all Diameter implementations; either MAY be used.
There are two cases where Diameter peer discovery may be performed.
The first is when a Diameter client needs to discover a first-hop
Diameter agent. The second case is when a Diameter agent needs to
- discover another agent - for further handling of a Diameter
- operation. In both cases, the following 'search order' is
- recommended:
-
+ discover another agent for further handling of a Diameter operation.
+ In both cases, the following 'search order' is recommended:
- 1. The Diameter implementation consults its list of static
+ 1. The Diameter implementation consults its list of statically
(manually) configured Diameter agent locations. These will be
used if they exist and respond.
-
2. The Diameter implementation performs a NAPTR query for a server
- in a particular realm. The Diameter implementation has to know
- in advance which realm to look for a Diameter agent. This could
- be deduced, for example, from the 'realm' in a NAI that a
- Diameter implementation needed to perform a Diameter operation
- on.
+ in a particular realm. The Diameter implementation has to know,
+ in advance, in which realm to look for a Diameter agent. This
+ could be deduced, for example, from the 'realm' in an NAI on
+ which a Diameter implementation needed to perform a Diameter
+ operation.
The NAPTR usage in Diameter follows the S-NAPTR DDDS application
[RFC3958] in which the SERVICE field includes tags for the
desired application and supported application protocol. The
application service tag for a Diameter application is 'aaa' and
the supported application protocol tags are 'diameter.tcp',
- 'diameter.sctp', 'diameter.dtls' or 'diameter.tls.tcp'.
+ 'diameter.sctp', 'diameter.dtls', or 'diameter.tls.tcp'
+ [RFC6408].
The client can follow the resolution process defined by the
- S-NAPTR DDDS [RFC3958] application to find a matching SRV, A or
+ S-NAPTR DDDS [RFC3958] application to find a matching SRV, A, or
AAAA record of a suitable peer. The domain suffixes in the NAPTR
replacement field SHOULD match the domain of the original query.
An example can be found in Appendix B.
3. If no NAPTR records are found, the requester directly queries for
- SRV records '_diameter._sctp'.realm, '_diameter._dtls'.realm,
- '_diameter._tcp'.realm and '_diameter._tls'.realm depending on
- the requesters network protocol capabilities. If SRV records are
- found then the requester can perform address record query (A RR's
+ one of the following SRV records: for Diameter over TCP, use
+ "_diameter._tcp.realm"; for Diameter over TLS, use
+ "_diameters._tcp.realm"; for Diameter over SCTP, use
+ "_diameter._sctp.realm"; for Diameter over DTLS, use
+ "_diameters._sctp.realm". If SRV records are found, then the
+ requester can perform address record query (A RR's and/or AAAA
+
-Fajardo, et al. Expires July 24, 2011 [Page 60]
+Fajardo, et al. Standards Track [Page 59]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- and/or AAAA RR's) for the target hostname specified in the SRV
- records. If no SRV records are found, the requester gives up.
+ RR's) for the target hostname specified in the SRV records
+ following the rules given in [RFC2782]. If no SRV records are
+ found, the requester gives up.
If the server is using a site certificate, the domain name in the
NAPTR query and the domain name in the replacement field MUST both be
valid based on the site certificate handed out by the server in the
- TLS/TCP and DTLS/SCTP or IKE exchange. Similarly, the domain name in
- the SRV query and the domain name in the target in the SRV record
- MUST both be valid based on the same site certificate. Otherwise, an
- attacker could modify the DNS records to contain replacement values
- in a different domain, and the client could not validate that this
- was the desired behavior, or the result of an attack.
-
- Also, the Diameter Peer MUST check to make sure that the discovered
+ TLS/TCP and DTLS/SCTP or Internet Key Exchange Protocol (IKE)
+ exchange. Similarly, the domain name in the SRV query and the domain
+ name in the target in the SRV record MUST both be valid based on the
+ same site certificate. Otherwise, an attacker could modify the DNS
+ records to contain replacement values in a different domain, and the
+ client could not validate whether this was the desired behavior or
+ the result of an attack.
+
+ Also, the Diameter peer MUST check to make sure that the discovered
peers are authorized to act in its role. Authentication via IKE or
TLS/TCP and DTLS/SCTP, or validation of DNS RRs via DNSSEC is not
sufficient to conclude this. For example, a web server may have
obtained a valid TLS/TCP and DTLS/SCTP certificate, and secured RRs
may be included in the DNS, but this does not imply that it is
- authorized to act as a Diameter Server.
-
- Authorization can be achieved for example, by configuration of a
- Diameter Server CA. Alternatively this can be achieved by definition
- of OIDs within TLS/TCP and DTLS/SCTP or IKE certificates so as to
- signify Diameter Server authorization.
-
- A dynamically discovered peer causes an entry in the Peer Table (see
+ authorized to act as a Diameter server.
+
+ Authorization can be achieved, for example, by the configuration of a
+ Diameter server Certification Authority (CA). The server CA issues a
+ certificate to the Diameter server, which includes an Object
+ Identifier (OID) to indicate the subject is a Diameter server in the
+ Extended Key Usage extension [RFC5280]. This certificate is then
+ used during TLS/TCP, DTLS/SCTP, or IKE security negotiation.
+ However, note that, at the time of writing, no Diameter server
+ Certification Authorities exist.
+
+ A dynamically discovered peer causes an entry in the peer table (see
Section 2.6) to be created. Note that entries created via DNS MUST
- expire (or be refreshed) within the DNS TTL. If a peer is discovered
- outside of the local realm, a routing table entry (see Section 2.7)
- for the peer's realm is created. The routing table entry's
- expiration MUST match the peer's expiration value.
+ expire (or be refreshed) within the DNS Time to Live (TTL). If a
+ peer is discovered outside of the local realm, a routing table entry
+ (see Section 2.7) for the peer's realm is created. The routing table
+ entry's expiration MUST match the peer's expiration value.
5.3. Capabilities Exchange
@@ -3400,35 +3353,36 @@ Internet-Draft Diameter Base Protocol January 2011
exchange the Capabilities Exchange messages, as specified in the peer
state machine (see Section 5.6). This message allows the discovery
of a peer's identity and its capabilities (protocol version number,
- supported Diameter applications, security mechanisms, etc.)
+ the identifiers of supported Diameter applications, security
+ mechanisms, etc.).
- The receiver only issues commands to its peers that have advertised
- support for the Diameter application that defines the command. A
- Diameter node MUST cache the supported applications in order to
- ensure that unrecognized commands and/or AVPs are not unnecessarily
- sent to a peer.
-
- A receiver of a Capabilities-Exchange-Req (CER) message that does not
-Fajardo, et al. Expires July 24, 2011 [Page 61]
+Fajardo, et al. Standards Track [Page 60]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- have any applications in common with the sender MUST return a
+ The receiver only issues commands to its peers that have advertised
+ support for the Diameter application that defines the command. A
+ Diameter node MUST cache the supported Application Ids in order to
+ ensure that unrecognized commands and/or AVPs are not unnecessarily
+ sent to a peer.
+
+ A receiver of a Capabilities-Exchange-Request (CER) message that does
+ not have any applications in common with the sender MUST return a
Capabilities-Exchange-Answer (CEA) with the Result-Code AVP set to
- DIAMETER_NO_COMMON_APPLICATION, and SHOULD disconnect the transport
+ DIAMETER_NO_COMMON_APPLICATION and SHOULD disconnect the transport
layer connection. Note that receiving a CER or CEA from a peer
- advertising itself as a Relay (see Section 2.4) MUST be interpreted
+ advertising itself as a relay (see Section 2.4) MUST be interpreted
as having common applications with the peer.
The receiver of the Capabilities-Exchange-Request (CER) MUST
determine common applications by computing the intersection of its
- own set of supported Application Id against all of the application
- identifier AVPs (Auth-Application-Id, Acct-Application-Id and Vendor-
- Specific-Application-Id) present in the CER. The value of the
+ own set of supported Application Ids against all of the
+ Application-Id AVPs (Auth-Application-Id, Acct-Application-Id, and
+ Vendor-Specific-Application-Id) present in the CER. The value of the
Vendor-Id AVP in the Vendor-Specific-Application-Id MUST NOT be used
during computation. The sender of the Capabilities-Exchange-Answer
(CEA) SHOULD include all of its supported applications as a hint to
@@ -3438,12 +3392,13 @@ Internet-Draft Diameter Base Protocol January 2011
and DTLS/SCTP connection prior to the CER/CEA exchange. This
protects the capabilities information of both peers. To support
older Diameter implementations that do not fully conform to this
- document, the transport security MAY still be negotiated via Inband-
- Security AVP. In this case, the receiver of a Capabilities-Exchange-
- Req (CER) message that does not have any security mechanisms in
- common with the sender MUST return a Capabilities-Exchange-Answer
- (CEA) with the Result-Code AVP set to DIAMETER_NO_COMMON_SECURITY,
- and SHOULD disconnect the transport layer connection.
+ document, the transport security MAY still be negotiated via an
+ Inband-Security AVP. In this case, the receiver of a Capabilities-
+ Exchange-Request (CER) message that does not have any security
+ mechanisms in common with the sender MUST return a Capabilities-
+ Exchange-Answer (CEA) with the Result-Code AVP set to
+ DIAMETER_NO_COMMON_SECURITY and SHOULD disconnect the transport layer
+ connection.
CERs received from unknown peers MAY be silently discarded, or a CEA
MAY be issued with the Result-Code AVP set to DIAMETER_UNKNOWN_PEER.
@@ -3455,34 +3410,34 @@ Internet-Draft Diameter Base Protocol January 2011
failure, all the pending transactions destined to the unknown peer
can be discarded.
- The CER and CEA messages MUST NOT be proxied, redirected or relayed.
+ The CER and CEA messages MUST NOT be proxied, redirected, or relayed.
- Since the CER/CEA messages cannot be proxied, it is still possible
- that an upstream agent receives a message for which it has no
- available peers to handle the application that corresponds to the
- Command-Code. In such instances, the 'E' bit is set in the answer
- message (see Section 7.) with the Result-Code AVP set to
- DIAMETER_UNABLE_TO_DELIVER to inform the downstream to take action
- (e.g., re-routing request to an alternate peer).
-
-Fajardo, et al. Expires July 24, 2011 [Page 62]
+Fajardo, et al. Standards Track [Page 61]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ Since the CER/CEA messages cannot be proxied, it is still possible
+ that an upstream agent will receive a message for which it has no
+ available peers to handle the application that corresponds to the
+ Command Code. In such instances, the 'E' bit is set in the answer
+ message (Section 7) with the Result-Code AVP set to
+ DIAMETER_UNABLE_TO_DELIVER to inform the downstream agent to take
+ action (e.g., re-routing request to an alternate peer).
+
With the exception of the Capabilities-Exchange-Request message, a
message of type Request that includes the Auth-Application-Id or
Acct-Application-Id AVPs, or a message with an application-specific
- command code, MAY only be forwarded to a host that has explicitly
+ Command Code MAY only be forwarded to a host that has explicitly
advertised support for the application (or has advertised the Relay
Application Id).
5.3.1. Capabilities-Exchange-Request
- The Capabilities-Exchange-Request (CER), indicated by the Command-
+ The Capabilities-Exchange-Request (CER), indicated by the Command
Code set to 257 and the Command Flags' 'R' bit set, is sent to
exchange local capabilities. Upon detection of a transport failure,
this message MUST NOT be sent to an alternate peer.
@@ -3490,7 +3445,7 @@ Internet-Draft Diameter Base Protocol January 2011
When Diameter is run over SCTP [RFC4960] or DTLS/SCTP [RFC6083],
which allow for connections to span multiple interfaces and multiple
IP addresses, the Capabilities-Exchange-Request message MUST contain
- one Host-IP- Address AVP for each potential IP address that MAY be
+ one Host-IP-Address AVP for each potential IP address that MAY be
locally used when transmitting Diameter messages.
Message Format
@@ -3510,9 +3465,20 @@ Internet-Draft Diameter Base Protocol January 2011
[ Firmware-Revision ]
* [ AVP ]
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 62]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
5.3.2. Capabilities-Exchange-Answer
- The Capabilities-Exchange-Answer (CEA), indicated by the Command-Code
+ The Capabilities-Exchange-Answer (CEA), indicated by the Command Code
set to 257 and the Command Flags' 'R' bit cleared, is sent in
response to a CER message.
@@ -3522,13 +3488,6 @@ Internet-Draft Diameter Base Protocol January 2011
one Host-IP-Address AVP for each potential IP address that MAY be
locally used when transmitting Diameter messages.
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 63]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Message Format
<CEA> ::= < Diameter Header: 257 >
@@ -3552,22 +3511,34 @@ Internet-Draft Diameter Base Protocol January 2011
5.3.3. Vendor-Id AVP
The Vendor-Id AVP (AVP Code 266) is of type Unsigned32 and contains
- the IANA "SMI Network Management Private Enterprise Codes" [RFC3232]
- value assigned to the vendor of the Diameter device. It is
+ the IANA "SMI Network Management Private Enterprise Codes"
+ [ENTERPRISE] value assigned to the Diameter Software vendor. It is
envisioned that the combination of the Vendor-Id, Product-Name
- (Section 5.3.7) and the Firmware-Revision (Section 5.3.4) AVPs may
+ (Section 5.3.7), and Firmware-Revision (Section 5.3.4) AVPs may
provide useful debugging information.
- A Vendor-Id value of zero in the CER or CEA messages is reserved and
+ A Vendor-Id value of zero in the CER or CEA message is reserved and
indicates that this field is ignored.
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 63]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
5.3.4. Firmware-Revision AVP
The Firmware-Revision AVP (AVP Code 267) is of type Unsigned32 and is
used to inform a Diameter peer of the firmware revision of the
issuing device.
- For devices that do not have a firmware revision (general purpose
+ For devices that do not have a firmware revision (general-purpose
computers running Diameter software modules, for instance), the
revision of the Diameter software module may be reported instead.
@@ -3577,77 +3548,70 @@ Internet-Draft Diameter Base Protocol January 2011
to inform a Diameter peer of the sender's IP address. All source
addresses that a Diameter node expects to use with SCTP [RFC4960] or
DTLS/SCTP [RFC6083] MUST be advertised in the CER and CEA messages by
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 64]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
including a Host-IP-Address AVP for each address.
5.3.6. Supported-Vendor-Id AVP
The Supported-Vendor-Id AVP (AVP Code 265) is of type Unsigned32 and
contains the IANA "SMI Network Management Private Enterprise Codes"
- [RFC3232] value assigned to a vendor other than the device vendor but
- including the application vendor. This is used in the CER and CEA
- messages in order to inform the peer that the sender supports (a
- subset of) the vendor-specific AVPs defined by the vendor identified
+ [ENTERPRISE] value assigned to a vendor other than the device vendor
+ but including the application vendor. This is used in the CER and
+ CEA messages in order to inform the peer that the sender supports (a
+ subset of) the Vendor-Specific AVPs defined by the vendor identified
in this AVP. The value of this AVP MUST NOT be set to zero.
Multiple instances of this AVP containing the same value SHOULD NOT
be sent.
5.3.7. Product-Name AVP
- The Product-Name AVP (AVP Code 269) is of type UTF8String, and
- contains the vendor assigned name for the product. The Product-Name
+ The Product-Name AVP (AVP Code 269) is of type UTF8String and
+ contains the vendor-assigned name for the product. The Product-Name
AVP SHOULD remain constant across firmware revisions for the same
product.
-5.4. Disconnecting Peer connections
+5.4. Disconnecting Peer Connections
When a Diameter node disconnects one of its transport connections,
- its peer cannot know the reason for the disconnect, and will most
- likely assume that a connectivity problem occurred, or that the peer
+ its peer cannot know the reason for the disconnect and will most
+ likely assume that a connectivity problem occurred or that the peer
has rebooted. In these cases, the peer may periodically attempt to
reconnect, as stated in Section 2.1. In the event that the
- disconnect was a result of either a shortage of internal resources,
- or simply that the node in question has no intentions of forwarding
- any Diameter messages to the peer in the foreseeable future, a
- periodic connection request would not be welcomed. The
- Disconnection-Reason AVP contains the reason the Diameter node issued
- the Disconnect-Peer-Request message.
+ disconnect was a result of either a shortage of internal resources or
+ simply that the node in question has no intentions of forwarding any
+ Diameter messages to the peer in the foreseeable future, a periodic
- The Disconnect-Peer-Request message is used by a Diameter node to
- inform its peer of its intent to disconnect the transport layer, and
- that the peer shouldn't reconnect unless it has a valid reason to do
- so (e.g., message to be forwarded). Upon receipt of the message, the
- Disconnect-Peer-Answer is returned, which SHOULD contain an error if
- messages have recently been forwarded, and are likely in flight,
- which would otherwise cause a race condition.
- The receiver of the Disconnect-Peer-Answer initiates the transport
- disconnect. The sender of the Disconnect-Peer-Answer should be able
- to detect the transport closure and cleanup the connection.
+Fajardo, et al. Standards Track [Page 64]
+
+RFC 6733 Diameter Base Protocol October 2012
+ connection request would not be welcomed. The Disconnection-Reason
+ AVP contains the reason the Diameter node issued the Disconnect-Peer-
+ Request message.
-Fajardo, et al. Expires July 24, 2011 [Page 65]
-
-Internet-Draft Diameter Base Protocol January 2011
+ The Disconnect-Peer-Request message is used by a Diameter node to
+ inform its peer of its intent to disconnect the transport layer and
+ that the peer shouldn't reconnect unless it has a valid reason to do
+ so (e.g., message to be forwarded). Upon receipt of the message, the
+ Disconnect-Peer-Answer message is returned, which SHOULD contain an
+ error if messages have recently been forwarded, and are likely in
+ flight, which would otherwise cause a race condition.
+ The receiver of the Disconnect-Peer-Answer message initiates the
+ transport disconnect. The sender of the Disconnect-Peer-Answer
+ message should be able to detect the transport closure and clean up
+ the connection.
5.4.1. Disconnect-Peer-Request
- The Disconnect-Peer-Request (DPR), indicated by the Command-Code set
+ The Disconnect-Peer-Request (DPR), indicated by the Command Code set
to 282 and the Command Flags' 'R' bit set, is sent to a peer to
- inform its intentions to shutdown the transport connection. Upon
- detection of a transport failure, this message MUST NOT be sent to an
- alternate peer.
+ inform it of its intentions to shut down the transport connection.
+ Upon detection of a transport failure, this message MUST NOT be sent
+ to an alternate peer.
Message Format
@@ -3659,28 +3623,14 @@ Internet-Draft Diameter Base Protocol January 2011
5.4.2. Disconnect-Peer-Answer
- The Disconnect-Peer-Answer (DPA), indicated by the Command-Code set
+ The Disconnect-Peer-Answer (DPA), indicated by the Command Code set
to 282 and the Command Flags' 'R' bit cleared, is sent as a response
to the Disconnect-Peer-Request message. Upon receipt of this
- message, the transport connection is shutdown.
+ message, the transport connection is shut down.
- Message Format
- <DPA> ::= < Diameter Header: 282 >
- { Result-Code }
- { Origin-Host }
- { Origin-Realm }
- [ Error-Message ]
- [ Failed-AVP ]
- * [ AVP ]
-5.4.3. Disconnect-Cause AVP
- The Disconnect-Cause AVP (AVP Code 273) is of type Enumerated. A
- Diameter node MUST include this AVP in the Disconnect-Peer-Request
- message to inform the peer of the reason for its intention to
- shutdown the transport connection. The following values are
- supported:
@@ -3689,29 +3639,44 @@ Internet-Draft Diameter Base Protocol January 2011
+Fajardo, et al. Standards Track [Page 65]
+
+RFC 6733 Diameter Base Protocol October 2012
+ Message Format
+
+ <DPA> ::= < Diameter Header: 282 >
+ { Result-Code }
+ { Origin-Host }
+ { Origin-Realm }
+ [ Error-Message ]
+ [ Failed-AVP ]
+ * [ AVP ]
-Fajardo, et al. Expires July 24, 2011 [Page 66]
-
-Internet-Draft Diameter Base Protocol January 2011
+5.4.3. Disconnect-Cause AVP
+
+ The Disconnect-Cause AVP (AVP Code 273) is of type Enumerated. A
+ Diameter node MUST include this AVP in the Disconnect-Peer-Request
+ message to inform the peer of the reason for its intention to shut
+ down the transport connection. The following values are supported:
- REBOOTING 0
- A scheduled reboot is imminent. Receiver of DPR with above result
- code MAY attempt reconnection.
+ REBOOTING 0
+ A scheduled reboot is imminent. A receiver of a DPR with
+ above result code MAY attempt reconnection.
- BUSY 1
- The peer's internal resources are constrained, and it has
- determined that the transport connection needs to be closed.
- Receiver of DPR with above result code SHOULD NOT attempt
- reconnection.
+ BUSY 1
+ The peer's internal resources are constrained, and it has
+ determined that the transport connection needs to be closed.
+ A receiver of a DPR with above result code SHOULD NOT attempt
+ reconnection.
- DO_NOT_WANT_TO_TALK_TO_YOU 2
- The peer has determined that it does not see a need for the
- transport connection to exist, since it does not expect any
- messages to be exchanged in the near future. Receiver of DPR
- with above result code SHOULD NOT attempt reconnection.
+ DO_NOT_WANT_TO_TALK_TO_YOU 2
+ The peer has determined that it does not see a need for the
+ transport connection to exist, since it does not expect any
+ messages to be exchanged in the near future. A receiver of a
+ DPR with above result code SHOULD NOT attempt reconnection.
5.5. Transport Failure Detection
@@ -3723,9 +3688,21 @@ Internet-Draft Diameter Base Protocol January 2011
Watchdog-Answer messages, defined in this section, are used to pro-
actively detect transport failures.
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 66]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
5.5.1. Device-Watchdog-Request
- The Device-Watchdog-Request (DWR), indicated by the Command-Code set
+ The Device-Watchdog-Request (DWR), indicated by the Command Code set
to 280 and the Command Flags' 'R' bit set, is sent to a peer when no
traffic has been exchanged between two peers (see Section 5.5.3).
Upon detection of a transport failure, this message MUST NOT be sent
@@ -3741,18 +3718,10 @@ Internet-Draft Diameter Base Protocol January 2011
5.5.2. Device-Watchdog-Answer
- The Device-Watchdog-Answer (DWA), indicated by the Command-Code set
+ The Device-Watchdog-Answer (DWA), indicated by the Command Code set
to 280 and the Command Flags' 'R' bit cleared, is sent as a response
to the Device-Watchdog-Request message.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 67]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Message Format
<DWA> ::= < Diameter Header: 280 >
@@ -3767,7 +3736,7 @@ Internet-Draft Diameter Base Protocol January 2011
5.5.3. Transport Failure Algorithm
The transport failure algorithm is defined in [RFC3539]. All
- Diameter implementations MUST support the algorithm defined in the
+ Diameter implementations MUST support the algorithm defined in that
specification in order to be compliant to the Diameter base protocol.
5.5.4. Failover and Failback Procedures
@@ -3775,7 +3744,17 @@ Internet-Draft Diameter Base Protocol January 2011
In the event that a transport failure is detected with a peer, it is
necessary for all pending request messages to be forwarded to an
alternate agent, if possible. This is commonly referred to as
- failover.
+ "failover".
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 67]
+
+RFC 6733 Diameter Base Protocol October 2012
+
In order for a Diameter node to perform failover procedures, it is
necessary for the node to maintain a pending message queue for a
@@ -3783,16 +3762,16 @@ Internet-Draft Diameter Base Protocol January 2011
request is removed from the queue. The Hop-by-Hop Identifier field
is used to match the answer with the queued request.
- When a transport failure is detected, if possible all messages in the
- queue are sent to an alternate agent with the T flag set. On booting
- a Diameter client or agent, the T flag is also set on any records
- still remaining to be transmitted in non-volatile storage. An
- example of a case where it is not possible to forward the message to
- an alternate server is when the message has a fixed destination, and
- the unavailable peer is the message's final destination (see
- Destination-Host AVP). Such an error requires that the agent return
- an answer message with the 'E' bit set and the Result-Code AVP set to
- DIAMETER_UNABLE_TO_DELIVER.
+ When a transport failure is detected, if possible, all messages in
+ the queue are sent to an alternate agent with the T flag set. On
+ booting a Diameter client or agent, the T flag is also set on any
+ remaining records in non-volatile storage that are still waiting to
+ be transmitted. An example of a case where it is not possible to
+ forward the message to an alternate server is when the message has a
+ fixed destination, and the unavailable peer is the message's final
+ destination (see Destination-Host AVP). Such an error requires that
+ the agent return an answer message with the 'E' bit set and the
+ Result-Code AVP set to DIAMETER_UNABLE_TO_DELIVER.
It is important to note that multiple identical requests or answers
MAY be received as a result of a failover. The End-to-End Identifier
@@ -3801,17 +3780,9 @@ Internet-Draft Diameter Base Protocol January 2011
As described in Section 2.1, a connection request should be
periodically attempted with the failed peer in order to re-establish
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 68]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
the transport connection. Once a connection has been successfully
established, messages can once again be forwarded to the peer. This
- is commonly referred to as failback.
+ is commonly referred to as "failback".
5.6. Peer State Machine
@@ -3824,16 +3795,24 @@ Internet-Draft Diameter Base Protocol January 2011
This state machine is closely coupled with the state machine
described in [RFC3539], which is used to open, close, failover,
- probe, and reopen transport connections. Note in particular that
+ probe, and reopen transport connections. In particular, note that
[RFC3539] requires the use of watchdog messages to probe connections.
For Diameter, DWR and DWA messages are to be used.
- I- is used to represent the initiator (connecting) connection, while
- the R- is used to represent the responder (listening) connection.
- The lack of a prefix indicates that the event or action is the same
- regardless of the connection on which the event occurred.
+ The I- prefix is used to represent the initiator (connecting)
+ connection, while the R- prefix is used to represent the responder
+ (listening) connection. The lack of a prefix indicates that the
+ event or action is the same regardless of the connection on which the
+ event occurred.
+
+
+
+Fajardo, et al. Standards Track [Page 68]
+
+RFC 6733 Diameter Base Protocol October 2012
+
- The stable states that a state machine may be in are Closed, I-Open
+ The stable states that a state machine may be in are Closed, I-Open,
and R-Open; all other states are intermediate. Note that I-Open and
R-Open are equivalent except for whether the initiator or responder
transport connection is used for communication.
@@ -3848,23 +3827,15 @@ Internet-Draft Diameter Base Protocol January 2011
the results of an election on one peer are guaranteed to be the
inverse of the results on the other.
- For TLS/TCP and DTLS/SCTP usage, TLS/TCP and DTLS/SCTP handshake
+ For TLS/TCP and DTLS/SCTP usage, a TLS/TCP and DTLS/SCTP handshake
SHOULD begin when both ends are in the closed state prior to any
Diameter message exchanges. The TLS/TCP and DTLS/SCTP connection
SHOULD be established before sending any CER or CEA message to secure
and protect the capabilities information of both peers. The TLS/TCP
and DTLS/SCTP connection SHOULD be disconnected when the state
machine moves to the closed state. When connecting to responders
- that do not conform to this document (i.e. older Diameter
+ that do not conform to this document (i.e., older Diameter
implementations that are not prepared to received TLS/TCP and DTLS/
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 69]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
SCTP connections in the closed state), the initial TLS/TCP and DTLS/
SCTP connection attempt will fail. The initiator MAY then attempt to
connect via TCP or SCTP and initiate the TLS/TCP and DTLS/SCTP
@@ -3878,6 +3849,25 @@ Internet-Draft Diameter Base Protocol January 2011
Any implementation that produces equivalent results is considered
compliant.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 69]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
state event action next state
-----------------------------------------------------------------
Closed Start I-Snd-Conn-Req Wait-Conn-Ack
@@ -3914,13 +3904,6 @@ Internet-Draft Diameter Base Protocol January 2011
R-Conn-CER R-Reject Wait-Returns
Timeout Error Closed
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 70]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
R-Open Send-Message R-Snd-Message R-Open
R-Rcv-Message Process R-Open
R-Rcv-DWR Process-DWR, R-Open
@@ -3928,10 +3911,19 @@ Internet-Draft Diameter Base Protocol January 2011
R-Rcv-DWA Process-DWA R-Open
R-Conn-CER R-Reject R-Open
Stop R-Snd-DPR Closing
- R-Rcv-DPR R-Snd-DPA, Closed
- R-Disc
+ R-Rcv-DPR R-Snd-DPA Closing
R-Peer-Disc R-Disc Closed
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 70]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
I-Open Send-Message I-Snd-Message I-Open
I-Rcv-Message Process I-Open
I-Rcv-DWR Process-DWR, I-Open
@@ -3939,8 +3931,7 @@ Internet-Draft Diameter Base Protocol January 2011
I-Rcv-DWA Process-DWA I-Open
R-Conn-CER R-Reject I-Open
Stop I-Snd-DPR Closing
- I-Rcv-DPR I-Snd-DPA, Closed
- I-Disc
+ I-Rcv-DPR I-Snd-DPA Closing
I-Peer-Disc I-Disc Closed
Closing I-Rcv-DPA I-Disc Closed
@@ -3949,88 +3940,44 @@ Internet-Draft Diameter Base Protocol January 2011
I-Peer-Disc I-Disc Closed
R-Peer-Disc R-Disc Closed
-5.6.1. Incoming connections
+5.6.1. Incoming Connections
When a connection request is received from a Diameter peer, it is
not, in the general case, possible to know the identity of that peer
until a CER is received from it. This is because host and port
- determine the identity of a Diameter peer; and the source port of an
- incoming connection is arbitrary. Upon receipt of CER, the identity
- of the connecting peer can be uniquely determined from Origin-Host.
+ determine the identity of a Diameter peer; the source port of an
+ incoming connection is arbitrary. Upon receipt of a CER, the
+ identity of the connecting peer can be uniquely determined from the
+ Origin-Host.
For this reason, a Diameter peer must employ logic separate from the
state machine to receive connection requests, accept them, and await
- CER. Once CER arrives on a new connection, the Origin-Host that
- identifies the peer is used to locate the state machine associated
- with that peer, and the new connection and CER are passed to the
- state machine as an R-Conn-CER event.
+ the CER. Once the CER arrives on a new connection, the Origin-Host
+ that identifies the peer is used to locate the state machine
+ associated with that peer, and the new connection and CER are passed
+ to the state machine as an R-Conn-CER event.
The logic that handles incoming connections SHOULD close and discard
- the connection if any message other than CER arrives, or if an
+ the connection if any message other than a CER arrives or if an
implementation-defined timeout occurs prior to receipt of CER.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 71]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Because handling of incoming connections up to and including receipt
- of CER requires logic, separate from that of any individual state
+ of a CER requires logic, separate from that of any individual state
machine associated with a particular peer, it is described separately
in this section rather than in the state machine above.
5.6.2. Events
Transitions and actions in the automaton are caused by events. In
- this section, we will ignore the -I and -R prefix, since the actual
- event would be identical, but would occur on one of two possible
+ this section, we will ignore the I- and R- prefixes, since the actual
+ event would be identical, but it would occur on one of two possible
connections.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 72]
+Fajardo, et al. Standards Track [Page 71]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Start The Diameter application has signaled that a
@@ -4053,7 +4000,8 @@ Internet-Draft Diameter Base Protocol January 2011
Rcv-CEA A CEA message from the peer was received.
- Rcv-Non-CEA A message other than CEA from the peer was received.
+ Rcv-Non-CEA A message, other than a CEA, from the peer was
+ received.
Peer-Disc A disconnection indication from the peer was received.
@@ -4066,7 +4014,7 @@ Internet-Draft Diameter Base Protocol January 2011
Send-Message A message is to be sent.
- Rcv-Message A message other than CER, CEA, DPR, DPA, DWR or DWA
+ Rcv-Message A message other than CER, CEA, DPR, DPA, DWR, or DWA
was received.
Stop The Diameter application has signaled that a
@@ -4077,16 +4025,15 @@ Internet-Draft Diameter Base Protocol January 2011
Actions in the automaton are caused by events and typically indicate
the transmission of packets and/or an action to be taken on the
- connection. In this section we will ignore the I- and R-prefix,
- since the actual action would be identical, but would occur on one of
- two possible connections.
-
+ connection. In this section, we will ignore the I- and R- prefixes,
+ since the actual action would be identical, but it would occur on one
+ of two possible connections.
-Fajardo, et al. Expires July 24, 2011 [Page 73]
+Fajardo, et al. Standards Track [Page 72]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Snd-Conn-Req A transport connection is initiated with the peer.
@@ -4098,11 +4045,12 @@ Internet-Draft Diameter Base Protocol January 2011
is disconnected.
Process-CER The CER associated with the R-Conn-CER is processed.
+
Snd-CER A CER message is sent to the peer.
Snd-CEA A CEA message is sent to the peer.
- Cleanup If necessary, the connection is shutdown, and any
+ Cleanup If necessary, the connection is shut down, and any
local resources are freed.
Error The transport layer connection is disconnected,
@@ -4139,10 +4087,9 @@ Internet-Draft Diameter Base Protocol January 2011
-
-Fajardo, et al. Expires July 24, 2011 [Page 74]
+Fajardo, et al. Standards Track [Page 73]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
5.6.4. The Election Process
@@ -4150,134 +4097,97 @@ Internet-Draft Diameter Base Protocol January 2011
The election is performed on the responder. The responder compares
the Origin-Host received in the CER with its own Origin-Host as two
streams of octets. If the local Origin-Host lexicographically
- succeeds the received Origin-Host a Win-Election event is issued
- locally. Diameter identities are in ASCII form therefore the lexical
- comparison is consistent with DNS case insensitivity where octets
- that fall in the ASCII range 'a' through 'z' MUST compare equally to
- their upper-case counterparts between 'A' and 'Z'. See Appendix D
- for interactions between the Diameter protocol and Internationalized
- Domain Name (IDNs).
+ succeeds the received Origin-Host, a Win-Election event is issued
+ locally. Diameter identities are in ASCII form; therefore, the
+ lexical comparison is consistent with DNS case insensitivity, where
+ octets that fall in the ASCII range 'a' through 'z' MUST compare
+ equally to their uppercase counterparts between 'A' and 'Z'. See
+ Appendix D for interactions between the Diameter protocol and
+ Internationalized Domain Name (IDNs).
The winner of the election MUST close the connection it initiated.
Historically, maintaining the responder side of a connection was more
efficient than maintaining the initiator side. However, current
practices makes this distinction irrelevant.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 75]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
-6. Diameter message processing
+6. Diameter Message Processing
This section describes how Diameter requests and answers are created
and processed.
6.1. Diameter Request Routing Overview
- A request is sent towards its final destination using a combination
- of the Destination-Realm and Destination-Host AVPs, in one of these
- three combinations:
+ A request is sent towards its final destination using one of the
+ following three combinations of the Destination-Realm and
+ Destination-Host AVPs:
- o a request that is not able to be proxied (such as CER) MUST NOT
+ o A request that is not able to be proxied (such as a CER) MUST NOT
contain either Destination-Realm or Destination-Host AVPs.
- o a request that needs to be sent to a home server serving a
+ o A request that needs to be sent to a home server serving a
specific realm, but not to a specific server (such as the first
- request of a series of round-trips), MUST contain a Destination-
- Realm AVP, but MUST NOT contain a Destination-Host AVP. For
+ request of a series of round trips), MUST contain a Destination-
+ Realm AVP but MUST NOT contain a Destination-Host AVP. For
Diameter clients, the value of the Destination-Realm AVP MAY be
extracted from the User-Name AVP, or other methods.
- o otherwise, a request that needs to be sent to a specific home
- server among those serving a given realm, MUST contain both the
+ o Otherwise, a request that needs to be sent to a specific home
+ server among those serving a given realm MUST contain both the
Destination-Realm and Destination-Host AVPs.
The Destination-Host AVP is used as described above when the
destination of the request is fixed, which includes:
- o Authentication requests that span multiple round trips
+ o Authentication requests that span multiple round trips.
+
+
+
+
+Fajardo, et al. Standards Track [Page 74]
+
+RFC 6733 Diameter Base Protocol October 2012
+
o A Diameter message that uses a security mechanism that makes use
of a pre-established session key shared between the source and the
final destination of the message.
- o Server initiated messages that MUST be received by a specific
+ o Server-initiated messages that MUST be received by a specific
Diameter client (e.g., access device), such as the Abort-Session-
Request message, which is used to request that a particular user's
session be terminated.
- Note that an agent can forward a request to a host described in the
- Destination-Host AVP only if the host in question is included in its
- peer table (see Section 2.7). Otherwise, the request is routed based
- on the Destination-Realm only (see Sections 6.1.6).
+ Note that an agent can only forward a request to a host described in
+ the Destination-Host AVP if the host in question is included in its
+ peer table (see Section 2.6). Otherwise, the request is routed based
+ on the Destination-Realm only (see Section 6.1.6).
When a message is received, the message is processed in the following
order:
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 76]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
o If the message is destined for the local host, the procedures
listed in Section 6.1.4 are followed.
o If the message is intended for a Diameter peer with whom the local
host is able to directly communicate, the procedures listed in
- Section 6.1.5 are followed. This is known as Request Forwarding.
+ Section 6.1.5 are followed. This is known as "Request
+ Forwarding".
- o The procedures listed in Section 6.1.6 are followed, which is
- known as Request Routing.
+ o The procedure listed in Section 6.1.6 is followed, which is known
+ as "Request Routing".
- o If none of the above is successful, an answer is returned with the
- Result-Code set to DIAMETER_UNABLE_TO_DELIVER, with the E-bit set.
+ o If none of the above are successful, an answer is returned with
+ the Result-Code set to DIAMETER_UNABLE_TO_DELIVER, with the 'E'
+ bit set.
For routing of Diameter messages to work within an administrative
domain, all Diameter nodes within the realm MUST be peers.
- Note the processing rules contained in this section are intended to
- be used as general guidelines to Diameter developers. Certain
- implementations MAY use different methods than the ones described
- here, and still comply with the protocol specification. See Section
- 7 for more detail on error handling.
+ The overview contained in this section (6.1) is intended to provide
+ general guidelines to Diameter developers. Implementations are free
+ to use different methods than the ones described here as long as they
+ conform to the requirements specified in Sections 6.1.1 through
+ 6.1.9. See Section 7 for more details on error handling.
6.1.1. Originating a Request
@@ -4285,33 +4195,35 @@ Internet-Draft Diameter Base Protocol January 2011
described in the application definition for that specific request,
the following procedures MUST be followed:
- o the Command-Code is set to the appropriate value
- o the 'R' bit is set
- o the End-to-End Identifier is set to a locally unique value
- o the Origin-Host and Origin-Realm AVPs MUST be set to the
- appropriate values, used to identify the source of the message
- o the Destination-Host and Destination-Realm AVPs MUST be set to the
- appropriate values as described in Section 6.1.
+Fajardo, et al. Standards Track [Page 75]
+
+RFC 6733 Diameter Base Protocol October 2012
-6.1.2. Sending a Request
- When sending a request, originated either locally, or as the result
- of a forwarding or routing operation, the following procedures SHOULD
- be followed:
+ o the Command Code is set to the appropriate value;
- o The Hop-by-Hop Identifier SHOULD be set to a locally unique value.
+ o the 'R' bit is set;
+ o the End-to-End Identifier is set to a locally unique value;
+ o the Origin-Host and Origin-Realm AVPs MUST be set to the
+ appropriate values, used to identify the source of the message;
+ and
+ o the Destination-Host and Destination-Realm AVPs MUST be set to the
+ appropriate values, as described in Section 6.1.
-Fajardo, et al. Expires July 24, 2011 [Page 77]
-
-Internet-Draft Diameter Base Protocol January 2011
+6.1.2. Sending a Request
+ When sending a request, originated either locally or as the result of
+ a forwarding or routing operation, the following procedures SHOULD be
+ followed:
+
+ o The Hop-by-Hop Identifier SHOULD be set to a locally unique value.
o The message SHOULD be saved in the list of pending requests.
@@ -4328,25 +4240,34 @@ Internet-Draft Diameter Base Protocol January 2011
6.1.4. Processing Local Requests
A request is known to be for local consumption when one of the
- following conditions occur:
+ following conditions occurs:
- o The Destination-Host AVP contains the local host's identity,
+ o The Destination-Host AVP contains the local host's identity;
o The Destination-Host AVP is not present, the Destination-Realm AVP
contains a realm the server is configured to process locally, and
- the Diameter application is locally supported, or
+ the Diameter application is locally supported; or
o Both the Destination-Host and the Destination-Realm are not
present.
+
+
+
+
+Fajardo, et al. Standards Track [Page 76]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
When a request is locally processed, the rules in Section 6.2 should
be used to generate the corresponding answer.
6.1.5. Request Forwarding
- Request forwarding is done using the Diameter Peer Table. The
- Diameter peer table contains all of the peers that the local node is
- able to directly communicate with.
+ Request forwarding is done using the Diameter peer table. The
+ Diameter peer table contains all of the peers with which the local
+ node is able to directly communicate.
When a request is received, and the host encoded in the Destination-
Host AVP is one that is present in the peer table, the message SHOULD
@@ -4354,29 +4275,21 @@ Internet-Draft Diameter Base Protocol January 2011
6.1.6. Request Routing
- Diameter request message routing is done via realms and application
- identifiers. A Diameter message that may be forwarded by Diameter
- agents (proxies, redirect or relay agents) MUST include the target
+ Diameter request message routing is done via realms and Application
+ Ids. A Diameter message that may be forwarded by Diameter agents
+ (proxies, redirect agents, or relay agents) MUST include the target
realm in the Destination-Realm AVP. Request routing SHOULD rely on
the Destination-Realm AVP and the Application Id present in the
request message header to aid in the routing decision. The realm MAY
be retrieved from the User-Name AVP, which is in the form of a
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 78]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Network Access Identifier (NAI). The realm portion of the NAI is
inserted in the Destination-Realm AVP.
Diameter agents MAY have a list of locally supported realms and
- applications, and MAY have a list of externally supported realms and
- applications. When a request is received that includes a realm
+ applications, and they MAY have a list of externally supported realms
+ and applications. When a request is received that includes a realm
and/or application that is not locally supported, the message is
- routed to the peer configured in the Routing Table (see Section 2.7).
+ routed to the peer configured in the routing table (see Section 2.7).
Realm names and Application Ids are the minimum supported routing
criteria, additional information may be needed to support redirect
@@ -4385,13 +4298,23 @@ Internet-Draft Diameter Base Protocol January 2011
6.1.7. Predictive Loop Avoidance
Before forwarding or routing a request, Diameter agents, in addition
- to processing done in Section 6.1.3, SHOULD check for the presence of
- candidate route's peer identity in any of the Route-Record AVPs. In
- an event of the agent detecting the presence of a candidate route's
- peer identity in a Route-Record AVP, the agent MUST ignore such route
- for the Diameter request message and attempt alternate routes if any.
- In case all the candidate routes are eliminated by the above
- criteria, the agent SHOULD return DIAMETER_UNABLE_TO_DELIVER message.
+ to performing the processing described in Section 6.1.3, SHOULD check
+ for the presence of a candidate route's peer identity in any of the
+ Route-Record AVPs. In the event of the agent detecting the presence
+ of a candidate route's peer identity in a Route-Record AVP, the agent
+ MUST ignore such a route for the Diameter request message and attempt
+ alternate routes if any exist. In case all the candidate routes are
+ eliminated by the above criteria, the agent SHOULD return a
+ DIAMETER_UNABLE_TO_DELIVER message.
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 77]
+
+RFC 6733 Diameter Base Protocol October 2012
+
6.1.8. Redirecting Requests
@@ -4399,7 +4322,7 @@ Internet-Draft Diameter Base Protocol January 2011
to REDIRECT, it MUST reply with an answer message with the 'E' bit
set, while maintaining the Hop-by-Hop Identifier in the header, and
include the Result-Code AVP to DIAMETER_REDIRECT_INDICATION. Each of
- the servers associated with the routing entry are added in separate
+ the servers associated with the routing entry are added in a separate
Redirect-Host AVP.
+------------------+
@@ -4417,21 +4340,13 @@ Internet-Draft Diameter Base Protocol January 2011
| Agent |<-------------| Server |
+-------------+ 4. Answer +-------------+
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 79]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Figure 5: Diameter Redirect Agent
- The receiver of the answer message with the 'E' bit set, and the
- Result-Code AVP set to DIAMETER_REDIRECT_INDICATION uses the hop-by-
- hop field in the Diameter header to identify the request in the
- pending message queue (see Section 5.3) that is to be redirected. If
- no transport connection exists with the new agent, one is created,
+ The receiver of an answer message with the 'E' bit set and the
+ Result-Code AVP set to DIAMETER_REDIRECT_INDICATION uses the Hop-by-
+ Hop Identifier in the Diameter header to identify the request in the
+ pending message queue (see Section 5.5.4) that is to be redirected.
+ If no transport connection exists with the new peer, one is created,
and the request is sent directly to it.
Multiple Redirect-Host AVPs are allowed. The receiver of the answer
@@ -4440,17 +4355,26 @@ Internet-Draft Diameter Base Protocol January 2011
When the Redirect-Host-Usage AVP included in the answer message has a
non-zero value, a route entry for the redirect indications is created
- and cached by the receiver. The redirect usage for such route entry
- is set by the value of Redirect-Host-Usage AVP and the lifetime of
- the cached route entry is set by Redirect-Max-Cache-Time AVP value.
+ and cached by the receiver. The redirect usage for such a route
+ entry is set by the value of Redirect-Host-Usage AVP and the lifetime
+ of the cached route entry is set by Redirect-Max-Cache-Time AVP
+ value.
It is possible that multiple redirect indications can create multiple
cached route entries differing only in their redirect usage and the
peer to forward messages to. As an example, two(2) route entries
that are created by two(2) redirect indications results in two(2)
+
+
+
+Fajardo, et al. Standards Track [Page 78]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
cached routes for the same realm and Application Id. However, one
- has a redirect usage of ALL_SESSION where matching request will be
- forwarded to one peer and the other has a redirect usage of ALL_REALM
+ has a redirect usage of ALL_SESSION, where matching requests will be
+ forwarded to one peer; the other has a redirect usage of ALL_REALM,
where request are forwarded to another peer. Therefore, an incoming
request that matches the realm and Application Id of both routes will
need additional resolution. In such a case, a routing precedence
@@ -4460,32 +4384,24 @@ Internet-Draft Diameter Base Protocol January 2011
6.1.9. Relaying and Proxying Requests
A relay or proxy agent MUST append a Route-Record AVP to all requests
- forwarded. The AVP contains the identity of the peer the request was
- received from.
+ forwarded. The AVP contains the identity of the peer from which the
+ request was received.
- The Hop-by-Hop identifier in the request is saved, and replaced with
- a locally unique value. The source of the request is also saved,
- which includes the IP address, port and protocol.
+ The Hop-by-Hop Identifier in the request is saved and replaced with a
+ locally unique value. The source of the request is also saved, which
+ includes the IP address, port, and protocol.
A relay or proxy agent MAY include the Proxy-Info AVP in requests if
it requires access to any local state information when the
corresponding response is received. The Proxy-Info AVP has security
- implications as state information is distribute to other entities.
- As such, it is RECOMMMENDED to protect the content of the Proxy-Info
- AVP with cryptographic mechanisms, for example by using a keyed
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 80]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- message digest. Such a mechanism, however, requires the management
- of keys, although only locally at the Diameter server. Still, a full
- description of the management of the keys used to protect the Proxy-
- Info AVP is beyond the scope of this document. Below is a list of
- commonly recommended:
+ implications as state information is distributed to other entities.
+ As such, it is RECOMMENDED that the content of the Proxy-Info AVP be
+ protected with cryptographic mechanisms, for example, by using a
+ keyed message digest such as HMAC-SHA1 [RFC2104]. Such a mechanism,
+ however, requires the management of keys, although only locally at
+ the Diameter server. Still, a full description of the management of
+ the keys used to protect the Proxy-Info AVP is beyond the scope of
+ this document. Below is a list of common recommendations:
o The keys should be generated securely following the randomness
recommendations in [RFC4086].
@@ -4494,32 +4410,39 @@ Internet-Draft Diameter Base Protocol January 2011
least 128 bits in strength.
o The keys should not be used for any other purpose than generating
- and verifying tickets.
+ and verifying instances of the Proxy-Info AVP.
o The keys should be changed regularly.
- o The keys should be changed if the ticket format or cryptographic
+ o The keys should be changed if the AVP format or cryptographic
protection algorithms change.
The message is then forwarded to the next hop, as identified in the
- Routing Table.
+ routing table.
+
+
+
+
+Fajardo, et al. Standards Track [Page 79]
+
+RFC 6733 Diameter Base Protocol October 2012
+
Figure 6 provides an example of message routing using the procedures
listed in these sections.
- (Origin-Host=nas.example.net) (Origin-Host=nas.example.net)
- (Origin-Realm=example.net) (Origin-Realm=example.net)
- (Destination-Realm=example.com) (Destination-
- Realm=example.com)
+ (Origin-Host=nas.example.net) (Origin-Host=nas.example.net)
+ (Origin-Realm=example.net) (Origin-Realm=example.net)
+ (Destination-Realm=example.com) (Destination-Realm=example.com)
(Route-Record=nas.example.net)
- +------+ ------> +------+ ------> +------+
- | | (Request) | | (Request) | |
- | NAS +-------------------+ DRL +-------------------+ HMS |
- | | | | | |
- +------+ <------ +------+ <------ +------+
- example.net (Answer) example.net (Answer) example.com
- (Origin-Host=hms.example.com) (Origin-Host=hms.example.com)
- (Origin-Realm=example.com) (Origin-Realm=example.com)
+ +------+ ------> +------+ ------> +------+
+ | | (Request) | | (Request) | |
+ | NAS +-------------------+ DRL +-------------------+ HMS |
+ | | | | | |
+ +------+ <------ +------+ <------ +------+
+ example.net (Answer) example.net (Answer) example.com
+ (Origin-Host=hms.example.com) (Origin-Host=hms.example.com)
+ (Origin-Realm=example.com) (Origin-Realm=example.com)
Figure 6: Routing of Diameter messages
@@ -4527,15 +4450,7 @@ Internet-Draft Diameter Base Protocol January 2011
incoming messages. At a minimum, validation of the message header
and relevant routing AVPs has to be done when relaying messages.
Proxy agents may optionally perform more in-depth message validation
- for applications it is interested in.
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 81]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ for applications in which it is interested.
6.2. Diameter Answer Processing
@@ -4544,7 +4459,7 @@ Internet-Draft Diameter Base Protocol January 2011
additional procedures that MAY be discussed in the Diameter
application defining the command:
- o The same Hop-by-Hop identifier in the request is used in the
+ o The same Hop-by-Hop Identifier in the request is used in the
answer.
o The local host's identity is encoded in the Origin-Host AVP.
@@ -4561,15 +4476,23 @@ Internet-Draft Diameter Base Protocol January 2011
o Any Proxy-Info AVPs in the request MUST be added to the answer
message, in the same order they were present in the request.
+
+
+
+Fajardo, et al. Standards Track [Page 80]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
o The 'P' bit is set to the same value as the one in the request.
o The same End-to-End identifier in the request is used in the
answer.
- Note that the error messages (see Section 7.3) are also subjected to
+ Note that the error messages (see Section 7) are also subjected to
the above processing rules.
-6.2.1. Processing received Answers
+6.2.1. Processing Received Answers
A Diameter client or proxy MUST match the Hop-by-Hop Identifier in an
answer received against the list of pending requests. The
@@ -4579,31 +4502,23 @@ Internet-Draft Diameter Base Protocol January 2011
6.2.2. Relaying and Proxying Answers
- If the answer is for a request which was proxied or relayed, the
- agent MUST restore the original value of the Diameter header's Hop-
- by-Hop Identifier field.
+ If the answer is for a request that was proxied or relayed, the agent
+ MUST restore the original value of the Diameter header's Hop-by-Hop
+ Identifier field.
If the last Proxy-Info AVP in the message is targeted to the local
Diameter server, the AVP MUST be removed before the answer is
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 82]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
forwarded.
If a relay or proxy agent receives an answer with a Result-Code AVP
indicating a failure, it MUST NOT modify the contents of the AVP.
- Any additional local errors detected SHOULD be logged, but not
+ Any additional local errors detected SHOULD be logged but not
reflected in the Result-Code AVP. If the agent receives an answer
message with a Result-Code AVP indicating success, and it wishes to
modify the AVP to indicate an error, it MUST modify the Result-Code
AVP to contain the appropriate error in the message destined towards
- the access device as well as include the Error-Reporting-Host AVP and
- it MUST issue an STR on behalf of the access device towards the
+ the access device as well as include the Error-Reporting-Host AVP; it
+ MUST also issue an STR on behalf of the access device towards the
Diameter server.
The agent MUST then send the answer to the host that it received the
@@ -4612,10 +4527,19 @@ Internet-Draft Diameter Base Protocol January 2011
6.3. Origin-Host AVP
The Origin-Host AVP (AVP Code 264) is of type DiameterIdentity, and
- MUST be present in all Diameter messages. This AVP identifies the
+ it MUST be present in all Diameter messages. This AVP identifies the
endpoint that originated the Diameter message. Relay agents MUST NOT
modify this AVP.
+
+
+
+
+Fajardo, et al. Standards Track [Page 81]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
The value of the Origin-Host AVP is guaranteed to be unique within a
single host.
@@ -4638,17 +4562,9 @@ Internet-Draft Diameter Base Protocol January 2011
The Destination-Host AVP (AVP Code 293) is of type DiameterIdentity.
This AVP MUST be present in all unsolicited agent initiated messages,
- MAY be present in request messages, and MUST NOT be present in Answer
+ MAY be present in request messages, and MUST NOT be present in answer
messages.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 83]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
The absence of the Destination-Host AVP will cause a message to be
sent to any Diameter server supporting the application within the
realm specified in Destination-Realm AVP.
@@ -4658,20 +4574,28 @@ Internet-Draft Diameter Base Protocol January 2011
6.6. Destination-Realm AVP
- The Destination-Realm AVP (AVP Code 283) is of type DiameterIdentity,
- and contains the realm the message is to be routed to. The
- Destination-Realm AVP MUST NOT be present in Answer messages.
- Diameter Clients insert the realm portion of the User-Name AVP.
+ The Destination-Realm AVP (AVP Code 283) is of type DiameterIdentity
+ and contains the realm to which the message is to be routed. The
+ Destination-Realm AVP MUST NOT be present in answer messages.
+ Diameter clients insert the realm portion of the User-Name AVP.
Diameter servers initiating a request message use the value of the
Origin-Realm AVP from a previous message received from the intended
target host (unless it is known a priori). When present, the
Destination-Realm AVP is used to perform message routing decisions.
- An ABNF for a request message that includes the Destination-Realm AVP
+ The CCF for a request message that includes the Destination-Realm AVP
SHOULD list the Destination-Realm AVP as a required AVP (an AVP
- indicated as {AVP}) otherwise the message is inherently a non-
+ indicated as {AVP}); otherwise, the message is inherently a non-
routable message.
+
+
+
+Fajardo, et al. Standards Track [Page 82]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
This AVP SHOULD be placed as close to the Diameter header as
possible.
@@ -4692,19 +4616,11 @@ Internet-Draft Diameter Base Protocol January 2011
The Proxy-Info AVP (AVP Code 284) is of type Grouped. This AVP
contains the identity and local state information of the Diameter
node that creates and adds it to a message. The Grouped Data field
- has the following ABNF grammar:
+ has the following CCF grammar:
Proxy-Info ::= < AVP Header: 284 >
{ Proxy-Host }
{ Proxy-State }
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 84]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
* [ AVP ]
6.7.3. Proxy-Host AVP
@@ -4728,10 +4644,18 @@ Internet-Draft Diameter Base Protocol January 2011
Application-Id AVP MUST match the Application Id present in the
Diameter message header.
+
+
+
+Fajardo, et al. Standards Track [Page 83]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
6.9. Acct-Application-Id AVP
The Acct-Application-Id AVP (AVP Code 259) is of type Unsigned32 and
- is used in order to advertise support of the Accounting portion of an
+ is used in order to advertise support of the accounting portion of an
application (see Section 2.4). If present in a message other than
CER and CEA, the value of the Acct-Application-Id AVP MUST match the
Application Id present in the Diameter message header.
@@ -4740,10 +4664,10 @@ Internet-Draft Diameter Base Protocol January 2011
The Inband-Security-Id AVP (AVP Code 299) is of type Unsigned32 and
is used in order to advertise support of the security portion of the
- application. The use of this AVP in CER and CEA messages is no
- longer recommended. Instead, discovery of a Diameter entities
- security capabilities can be done either through static configuration
- or via Diameter Peer Discovery described in Section 5.2.
+ application. The use of this AVP in CER and CEA messages is NOT
+ RECOMMENDED. Instead, discovery of a Diameter entity's security
+ capabilities can be done either through static configuration or via
+ Diameter Peer Discovery as described in Section 5.2.
The following values are supported:
@@ -4753,36 +4677,37 @@ Internet-Draft Diameter Base Protocol January 2011
This peer does not support TLS/TCP and DTLS/SCTP. This is the
default value, if the AVP is omitted.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 85]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
TLS 1
- This node supports TLS/TCP and DTLS/SCTP security, as defined by
- [RFC5246].
+ This node supports TLS/TCP [RFC5246] and DTLS/SCTP [RFC6083]
+ security.
6.11. Vendor-Specific-Application-Id AVP
The Vendor-Specific-Application-Id AVP (AVP Code 260) is of type
Grouped and is used to advertise support of a vendor-specific
- Diameter Application. Exactly one instance of either Auth-
+ Diameter application. Exactly one instance of either Auth-
Application-Id or Acct-Application-Id AVP MUST be present. The
Application Id carried by either Auth-Application-Id or Acct-
- Application-Id AVP MUST comply with vendor specific Application Id
- assignment described in Sec 11.3. It MUST also match the Application
- Id present in the Diameter header except when used in a CER or CEA
- message.
+ Application-Id AVP MUST comply with vendor-specific Application Id
+ assignment described in Section 11.3. It MUST also match the
+ Application Id present in the Diameter header except when used in a
+ CER or CEA message.
The Vendor-Id AVP is an informational AVP pertaining to the vendor
who may have authorship of the vendor-specific Diameter application.
It MUST NOT be used as a means of defining a completely separate
vendor-specific Application Id space.
+
+
+
+
+Fajardo, et al. Standards Track [Page 84]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
The Vendor-Specific-Application-Id AVP SHOULD be placed as close to
the Diameter header as possible.
@@ -4795,9 +4720,9 @@ Internet-Draft Diameter Base Protocol January 2011
A Vendor-Specific-Application-Id AVP MUST contain exactly one of
either Auth-Application-Id or Acct-Application-Id. If a Vendor-
- Specific-Application-Id is received without any of these two AVPs,
+ Specific-Application-Id is received without one of these two AVPs,
then the recipient SHOULD issue an answer with a Result-Code set to
- DIAMETER_MISSING_AVP. The answer SHOULD also include a Failed-AVP
+ DIAMETER_MISSING_AVP. The answer SHOULD also include a Failed-AVP,
which MUST contain an example of an Auth-Application-Id AVP and an
Acct-Application-Id AVP.
@@ -4805,22 +4730,13 @@ Internet-Draft Diameter Base Protocol January 2011
Auth-Application-Id and Acct-Application-Id, then the recipient MUST
issue an answer with Result-Code set to
DIAMETER_AVP_OCCURS_TOO_MANY_TIMES. The answer MUST also include a
- Failed-AVP which MUST contain the received Auth-Application-Id AVP
+ Failed-AVP, which MUST contain the received Auth-Application-Id AVP
and Acct-Application-Id AVP.
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 86]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
6.12. Redirect-Host AVP
The Redirect-Host AVP (AVP Code 292) is of type DiameterURI. One or
- more of instances of this AVP MUST be present if the answer message's
+ more instances of this AVP MUST be present if the answer message's
'E' bit is set and the Result-Code AVP is set to
DIAMETER_REDIRECT_INDICATION.
@@ -4836,63 +4752,55 @@ Internet-Draft Diameter Base Protocol January 2011
This AVP MAY be present in answer messages whose 'E' bit is set and
the Result-Code AVP is set to DIAMETER_REDIRECT_INDICATION.
- When present, this AVP provides a hints about how the routing entry
+ When present, this AVP provides hints about how the routing entry
resulting from the Redirect-Host is to be used. The following values
are supported:
+
+
+Fajardo, et al. Standards Track [Page 85]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
DONT_CACHE 0
The host specified in the Redirect-Host AVP SHOULD NOT be cached.
This is the default value.
-
ALL_SESSION 1
All messages within the same session, as defined by the same value
of the Session-ID AVP SHOULD be sent to the host specified in the
Redirect-Host AVP.
-
ALL_REALM 2
All messages destined for the realm requested SHOULD be sent to
the host specified in the Redirect-Host AVP.
-
REALM_AND_APPLICATION 3
All messages for the application requested to the realm specified
SHOULD be sent to the host specified in the Redirect-Host AVP.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 87]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
ALL_APPLICATION 4
All messages for the application requested SHOULD be sent to the
host specified in the Redirect-Host AVP.
-
ALL_HOST 5
All messages that would be sent to the host that generated the
Redirect-Host SHOULD be sent to the host specified in the
- Redirect- Host AVP.
-
+ Redirect-Host AVP.
ALL_USER 6
All messages for the user requested SHOULD be sent to the host
specified in the Redirect-Host AVP.
-
-
When multiple cached routes are created by redirect indications and
they differ only in redirect usage and peers to forward requests to
(see Section 6.1.8), a precedence rule MUST be applied to the
@@ -4902,6 +4810,16 @@ Internet-Draft Diameter Base Protocol January 2011
other as they appear. The order is as follows:
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 86]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
1. ALL_SESSION
2. ALL_USER
@@ -4917,58 +4835,31 @@ Internet-Draft Diameter Base Protocol January 2011
6.14. Redirect-Max-Cache-Time AVP
The Redirect-Max-Cache-Time AVP (AVP Code 262) is of type Unsigned32.
- This AVP MUST be present in answer messages whose 'E' bit is set, the
- Result-Code AVP is set to DIAMETER_REDIRECT_INDICATION and the
- Redirect-Host-Usage AVP set to a non-zero value.
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 88]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ This AVP MUST be present in answer messages whose 'E' bit is set,
+ whose Result-Code AVP is set to DIAMETER_REDIRECT_INDICATION, and
+ whose Redirect-Host-Usage AVP set to a non-zero value.
This AVP contains the maximum number of seconds the peer and route
table entries, created as a result of the Redirect-Host, SHOULD be
cached. Note that once a host is no longer reachable, any associated
- cache, peer and routing table entries MUST be deleted.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ cache, peer, and routing table entries MUST be deleted.
+7. Error Handling
+ There are two different types of errors in Diameter; protocol errors
+ and application errors. A protocol error is one that occurs at the
+ base protocol level and MAY require per-hop attention (e.g., a
+ message routing error). Application errors, on the other hand,
+ generally occur due to a problem with a function specified in a
+ Diameter application (e.g., user authentication, missing AVP).
+ Result-Code AVP values that are used to report protocol errors MUST
+ only be present in answer messages whose 'E' bit is set. When a
+ request message is received that causes a protocol error, an answer
+ message is returned with the 'E' bit set, and the Result-Code AVP is
+ set to the appropriate protocol error value. As the answer is sent
+ back towards the originator of the request, each proxy or relay agent
+ MAY take action on the message.
@@ -4980,27 +4871,10 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 89]
+Fajardo, et al. Standards Track [Page 87]
-Internet-Draft Diameter Base Protocol January 2011
-
-
-7. Error Handling
+RFC 6733 Diameter Base Protocol October 2012
- There are two different types of errors in Diameter; protocol and
- application errors. A protocol error is one that occurs at the base
- protocol level, and MAY require per hop attention (e.g., message
- routing error). Application errors, on the other hand, generally
- occur due to a problem with a function specified in a Diameter
- application (e.g., user authentication, missing AVP).
-
- Result-Code AVP values that are used to report protocol errors MUST
- only be present in answer messages whose 'E' bit is set. When a
- request message is received that causes a protocol error, an answer
- message is returned with the 'E' bit set, and the Result-Code AVP is
- set to the appropriate protocol error value. As the answer is sent
- back towards the originator of the request, each proxy or relay agent
- MAY take action on the message.
1. Request +---------+ Link Broken
+-------------------------->|Diameter |----///----+
@@ -5014,7 +4888,7 @@ Internet-Draft Diameter Base Protocol January 2011
| Relay 3 |-----------+
+---------+
- Figure 7: Example of Protocol Error causing answer message
+ Figure 7: Example of Protocol Error Causing Answer Message
Figure 7 provides an example of a message forwarded upstream by a
Diameter relay. When the message is received by Relay 2, and it
@@ -5032,40 +4906,40 @@ Internet-Draft Diameter Base Protocol January 2011
+---------+ 4. Answer +---------+ 3. Answer +---------+
(Missing AVP) (Missing AVP)
- Figure 8: Example of Application Error Answer message
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 90]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ Figure 8: Example of Application Error Answer Message
Figure 8 provides an example of a Diameter message that caused an
application error. When application errors occur, the Diameter
- entity reporting the error clears the 'R' bit in the Command Flags,
+ entity reporting the error clears the 'R' bit in the Command Flags
and adds the Result-Code AVP with the proper value. Application
- errors do not require any proxy or relay agent involvement, and
- therefore the message would be forwarded back to the originator of
+ errors do not require any proxy or relay agent involvement;
+ therefore, the message would be forwarded back to the originator of
the request.
In the case where the answer message itself contains errors, any
related session SHOULD be terminated by sending an STR or ASR
message. The Termination-Cause AVP in the STR MAY be filled with the
appropriate value to indicate the cause of the error. An application
- MAY also send an application-specific request instead of STR or ASR
- to signal the error in the case where no state is maintained or to
- allow for some form of error recovery with the corresponding Diameter
- entity.
+ MAY also send an application-specific request instead of an STR or
+ ASR message to signal the error in the case where no state is
+ maintained or to allow for some form of error recovery with the
+ corresponding Diameter entity.
+
+
+
+Fajardo, et al. Standards Track [Page 88]
+
+RFC 6733 Diameter Base Protocol October 2012
+
There are certain Result-Code AVP application errors that require
additional AVPs to be present in the answer. In these cases, the
Diameter node that sets the Result-Code AVP to indicate the error
- MUST add the AVPs. Examples are:
+ MUST add the AVPs. Examples are as follows:
o A request with an unrecognized AVP is received with the 'M' bit
- (Mandatory bit) set, causes an answer to be sent with the Result-
- Code AVP set to DIAMETER_AVP_UNSUPPORTED, and the Failed-AVP AVP
+ (Mandatory bit) set causes an answer to be sent with the Result-
+ Code AVP set to DIAMETER_AVP_UNSUPPORTED and the Failed-AVP AVP
containing the offending AVP.
o A request with an AVP that is received with an unrecognized value
@@ -5073,46 +4947,46 @@ Internet-Draft Diameter Base Protocol January 2011
DIAMETER_INVALID_AVP_VALUE, with the Failed-AVP AVP containing the
AVP causing the error.
- o A received command which is missing AVP(s) that are defined as
- required in the commands ABNF; examples are AVPs indicated as
+ o A received command that is missing AVPs that are defined as
+ required in the commands CCF; examples are AVPs indicated as
{AVP}. The receiver issues an answer with the Result-Code set to
- DIAMETER_MISSING_AVP, and creates an AVP with the AVP Code and
+ DIAMETER_MISSING_AVP and creates an AVP with the AVP Code and
other fields set as expected in the missing AVP. The created AVP
- is then added to the Failed- AVP AVP.
+ is then added to the Failed-AVP AVP.
The Result-Code AVP describes the error that the Diameter node
encountered in its processing. In case there are multiple errors,
the Diameter node MUST report only the first error it encountered
- (detected possibly in some implementation dependent order). The
+ (detected possibly in some implementation-dependent order). The
specific errors that can be described by this AVP are described in
the following section.
+7.1. Result-Code AVP
+ The Result-Code AVP (AVP Code 268) is of type Unsigned32 and
+ indicates whether a particular request was completed successfully or
+ an error occurred. All Diameter answer messages in IETF-defined
+ Diameter application specifications MUST include one Result-Code AVP.
+ A non-successful Result-Code AVP (one containing a non-2xxx value
+ other than DIAMETER_REDIRECT_INDICATION) MUST include the Error-
+ Reporting-Host AVP if the host setting the Result-Code AVP is
+ different from the identity encoded in the Origin-Host AVP.
+ The Result-Code data field contains an IANA-managed 32-bit address
+ space representing errors (see Section 11.3.2). Diameter provides
+ the following classes of errors, all identified by the thousands
+ digit in the decimal notation:
-Fajardo, et al. Expires July 24, 2011 [Page 91]
-
-Internet-Draft Diameter Base Protocol January 2011
-7.1. Result-Code AVP
- The Result-Code AVP (AVP Code 268) is of type Unsigned32 and
- indicates whether a particular request was completed successfully or
- whether an error occurred. All Diameter answer messages in IETF
- defined Diameter application specification MUST include one Result-
- Code AVP. A non-successful Result-Code AVP (one containing a non
- 2xxx value other than DIAMETER_REDIRECT_INDICATION) MUST include the
- Error-Reporting-Host AVP if the host setting the Result-Code AVP is
- different from the identity encoded in the Origin-Host AVP.
+Fajardo, et al. Standards Track [Page 89]
+
+RFC 6733 Diameter Base Protocol October 2012
- The Result-Code data field contains an IANA-managed 32-bit address
- space representing errors (see Section 11.4). Diameter provides the
- following classes of errors, all identified by the thousands digit in
- the decimal notation:
o 1xxx (Informational)
@@ -5124,7 +4998,7 @@ Internet-Draft Diameter Base Protocol January 2011
o 5xxx (Permanent Failure)
- A non-recognized class (one whose first digit is not defined in this
+ An unrecognized class (one whose first digit is not defined in this
section) MUST be handled as a permanent failure.
7.1.1. Informational
@@ -5133,7 +5007,6 @@ Internet-Draft Diameter Base Protocol January 2011
requester that a request could not be satisfied, and additional
action is required on its part before access is granted.
-
DIAMETER_MULTI_ROUND_AUTH 1001
This informational error is returned by a Diameter server to
@@ -5141,24 +5014,11 @@ Internet-Draft Diameter Base Protocol January 2011
used requires multiple round trips, and a subsequent request needs
to be issued in order for access to be granted.
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 92]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
7.1.2. Success
Errors that fall within the Success category are used to inform a
peer that a request has been successfully completed.
-
DIAMETER_SUCCESS 2001
The request was successfully completed.
@@ -5174,27 +5034,33 @@ Internet-Draft Diameter Base Protocol January 2011
Errors that fall within the Protocol Error category SHOULD be treated
on a per-hop basis, and Diameter proxies MAY attempt to correct the
error, if it is possible. Note that these errors MUST only be used
- in answer messages whose 'E' bit is set. This document omits some
- error codes defined in [RFC3588]. To provide backward compatibility
- with [RFC3588] implementations these error code values are not re-
- used and hence the error codes values enumerated below are non-
- sequential.
+ in answer messages whose 'E' bit is set.
+
+
+Fajardo, et al. Standards Track [Page 90]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ DIAMETER_COMMAND_UNSUPPORTED 3001
+
+ This error code is used when a Diameter entity receives a message
+ with a Command Code that it does not support.
+
DIAMETER_UNABLE_TO_DELIVER 3002
- This error is given when Diameter can not deliver the message to
+ This error is given when Diameter cannot deliver the message to
the destination, either because no host within the realm
supporting the required application was available to process the
- request, or because Destination-Host AVP was given without the
+ request or because the Destination-Host AVP was given without the
associated Destination-Realm AVP.
-
DIAMETER_REALM_NOT_SERVED 3003
The intended realm of the request is not recognized.
-
DIAMETER_TOO_BUSY 3004
When returned, a Diameter node SHOULD attempt to send the message
@@ -5202,13 +5068,6 @@ Internet-Draft Diameter Base Protocol January 2011
specific server is requested, and it cannot provide the requested
service.
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 93]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
DIAMETER_LOOP_DETECTED 3005
An agent detected a loop while trying to get the message to the
@@ -5216,121 +5075,110 @@ Internet-Draft Diameter Base Protocol January 2011
if one is available, but the peer reporting the error has
identified a configuration problem.
-
DIAMETER_REDIRECT_INDICATION 3006
A redirect agent has determined that the request could not be
- satisfied locally and the initiator of the request SHOULD direct
+ satisfied locally, and the initiator of the request SHOULD direct
the request directly to the server, whose contact information has
been added to the response. When set, the Redirect-Host AVP MUST
be present.
-
DIAMETER_APPLICATION_UNSUPPORTED 3007
A request was sent for an application that is not supported.
+ DIAMETER_INVALID_HDR_BITS 3008
- DIAMETER_INVALID_BIT_IN_HEADER 3011
+ A request was received whose bits in the Diameter header were set
+ either to an invalid combination or to a value that is
+ inconsistent with the Command Code's definition.
- This error is returned when a reserved bit in the Diameter header
- is set to one (1) or the bits in the Diameter header defined in
- Section 3 are set incorrectly.
- DIAMETER_INVALID_MESSAGE_LENGTH 3012
+Fajardo, et al. Standards Track [Page 91]
+
+RFC 6733 Diameter Base Protocol October 2012
- This error is returned when a request is received with an invalid
- message length.
+ DIAMETER_INVALID_AVP_BITS 3009
+
+ A request was received that included an AVP whose flag bits are
+ set to an unrecognized value or that is inconsistent with the
+ AVP's definition.
+
+ DIAMETER_UNKNOWN_PEER 3010
+
+ A CER was received from an unknown peer.
7.1.4. Transient Failures
Errors that fall within the transient failures category are used to
inform a peer that the request could not be satisfied at the time it
- was received, but MAY be able to satisfy the request in the future.
+ was received but MAY be able to satisfy the request in the future.
Note that these errors MUST be used in answer messages whose 'E' bit
is not set.
-
DIAMETER_AUTHENTICATION_REJECTED 4001
The authentication process for the user failed, most likely due to
an invalid password used by the user. Further attempts MUST only
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 94]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
be tried after prompting the user for a new password.
-
DIAMETER_OUT_OF_SPACE 4002
A Diameter node received the accounting request but was unable to
commit it to stable storage due to a temporary lack of space.
-
ELECTION_LOST 4003
The peer has determined that it has lost the election process and
has therefore disconnected the transport connection.
-
7.1.5. Permanent Failures
Errors that fall within the permanent failures category are used to
- inform the peer that the request failed, and should not be attempted
+ inform the peer that the request failed and should not be attempted
again. Note that these errors SHOULD be used in answer messages
whose 'E' bit is not set. In error conditions where it is not
- possible or efficient to compose application-specific answer grammar
- then answer messages with E-bit set and complying to the grammar
- described in 7.2 MAY also be used for permanent errors.
+ possible or efficient to compose application-specific answer grammar,
+ answer messages with the 'E' bit set and which comply to the grammar
+ described in Section 7.2 MAY also be used for permanent errors.
- To provide backward compatibility with existing implementations that
- follow [RFC3588], some of the error values that have previously been
- used in this category by [RFC3588] will not be re-used. Therefore
- the error values enumerated here may be non-sequential.
- DIAMETER_AVP_UNSUPPORTED 5001
- The peer received a message that contained an AVP that is not
- recognized or supported and was marked with the Mandatory bit. A
- Diameter message with this error MUST contain one or more Failed-
- AVP AVP containing the AVPs that caused the failure.
- DIAMETER_UNKNOWN_SESSION_ID 5002
- The request contained an unknown Session-Id.
+Fajardo, et al. Standards Track [Page 92]
+
+RFC 6733 Diameter Base Protocol October 2012
- DIAMETER_AUTHORIZATION_REJECTED 5003
- A request was received for which the user could not be authorized.
- This error could occur if the service requested is not permitted
+ DIAMETER_AVP_UNSUPPORTED 5001
+ The peer received a message that contained an AVP that is not
+ recognized or supported and was marked with the 'M' (Mandatory)
+ bit. A Diameter message with this error MUST contain one or more
+ Failed-AVP AVPs containing the AVPs that caused the failure.
+ DIAMETER_UNKNOWN_SESSION_ID 5002
-Fajardo, et al. Expires July 24, 2011 [Page 95]
-
-Internet-Draft Diameter Base Protocol January 2011
+ The request contained an unknown Session-Id.
+ DIAMETER_AUTHORIZATION_REJECTED 5003
+ A request was received for which the user could not be authorized.
+ This error could occur if the service requested is not permitted
to the user.
-
DIAMETER_INVALID_AVP_VALUE 5004
The request contained an AVP with an invalid value in its data
portion. A Diameter message indicating this error MUST include
the offending AVPs within a Failed-AVP AVP.
-
DIAMETER_MISSING_AVP 5005
The request did not contain an AVP that is required by the Command
@@ -5340,21 +5188,28 @@ Internet-Draft Diameter Base Protocol January 2011
Vendor-Id if applicable. The value field of the missing AVP
should be of correct minimum length and contain zeroes.
-
DIAMETER_RESOURCES_EXCEEDED 5006
A request was received that cannot be authorized because the user
has already expended allowed resources. An example of this error
- condition is a user that is restricted to one dial-up PPP port,
- attempts to establish a second PPP connection.
-
+ condition is when a user that is restricted to one dial-up PPP
+ port attempts to establish a second PPP connection.
DIAMETER_CONTRADICTING_AVPS 5007
The Home Diameter server has detected AVPs in the request that
- contradicted each other, and is not willing to provide service to
- the user. The Failed-AVP AVPs MUST be present which contains the
- AVPs that contradicted each other.
+ contradicted each other, and it is not willing to provide service
+ to the user. The Failed-AVP AVP MUST be present, which contain
+ the AVPs that contradicted each other.
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 93]
+
+RFC 6733 Diameter Base Protocol October 2012
DIAMETER_AVP_NOT_ALLOWED 5008
@@ -5363,22 +5218,12 @@ Internet-Draft Diameter Base Protocol January 2011
Failed-AVP AVP MUST be included and contain a copy of the
offending AVP.
-
DIAMETER_AVP_OCCURS_TOO_MANY_TIMES 5009
A message was received that included an AVP that appeared more
often than permitted in the message definition. The Failed-AVP
AVP MUST be included and contain a copy of the first instance of
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 96]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- the offending AVP that exceeded the maximum number of occurrences
-
+ the offending AVP that exceeded the maximum number of occurrences.
DIAMETER_NO_COMMON_APPLICATION 5010
@@ -5386,18 +5231,21 @@ Internet-Draft Diameter Base Protocol January 2011
whereby no applications are common between the CER sending peer
and the CER receiving peer.
-
DIAMETER_UNSUPPORTED_VERSION 5011
This error is returned when a request was received, whose version
number is unsupported.
-
DIAMETER_UNABLE_TO_COMPLY 5012
This error is returned when a request is rejected for unspecified
reasons.
+ DIAMETER_INVALID_BIT_IN_HEADER 5013
+
+ This error is returned when a reserved bit in the Diameter header
+ is set to one (1) or the bits in the Diameter header are set
+ incorrectly.
DIAMETER_INVALID_AVP_LENGTH 5014
@@ -5407,56 +5255,41 @@ Internet-Draft Diameter Base Protocol January 2011
value exceeds the message length or is less than the minimum AVP
header length, it is sufficient to include the offending AVP
header and a zero filled payload of the minimum required length
- for the payloads data type. If the AVP is a grouped AVP, the
- grouped AVP header with an empty payload would be sufficient to
+ for the payloads data type. If the AVP is a Grouped AVP, the
+ Grouped AVP header with an empty payload would be sufficient to
indicate the offending AVP. In the case where the offending AVP
header cannot be fully decoded when the AVP length is less than
- the minimum AVP header length, it is sufficient to include an
- offending AVP header that is formulated by padding the incomplete
- AVP header with zero up to the minimum AVP header length.
-
-
- DIAMETER_NO_COMMON_SECURITY 5017
-
- This error is returned when a CER message is received, and there
- are no common security mechanisms supported between the peers. A
- Capabilities-Exchange-Answer (CEA) MUST be returned with the
- Result-Code AVP set to DIAMETER_NO_COMMON_SECURITY.
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 97]
+Fajardo, et al. Standards Track [Page 94]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- DIAMETER_UNKNOWN_PEER 5018
-
- A CER was received from an unknown peer.
-
-
- DIAMETER_COMMAND_UNSUPPORTED 5019
-
- This error code is used when a Diameter entity receives a message
- with a Command Code that it does not support.
-
+ the minimum AVP header length, it is sufficient to include an
+ offending AVP header that is formulated by padding the incomplete
+ AVP header with zero up to the minimum AVP header length.
- DIAMETER_INVALID_HDR_BITS 5020
+ DIAMETER_INVALID_MESSAGE_LENGTH 5015
- A request was received whose bits in the Diameter header were
- either set to an invalid combination, or to a value that is
- inconsistent with the command code's definition.
+ This error is returned when a request is received with an invalid
+ message length.
+ DIAMETER_INVALID_AVP_BIT_COMBO 5016
- DIAMETER_INVALID_AVP_BITS 5021
+ The request contained an AVP with which is not allowed to have the
+ given value in the AVP Flags field. A Diameter message indicating
+ this error MUST include the offending AVPs within a Failed-AVP
+ AVP.
- A request was received that included an AVP whose flag bits are
- set to an unrecognized value, or that is inconsistent with the
- AVP's definition.
+ DIAMETER_NO_COMMON_SECURITY 5017
+ This error is returned when a CER message is received, and there
+ are no common security mechanisms supported between the peers. A
+ Capabilities-Exchange-Answer (CEA) message MUST be returned with
+ the Result-Code AVP set to DIAMETER_NO_COMMON_SECURITY.
7.2. Error Bit
@@ -5465,12 +5298,12 @@ Internet-Draft Diameter Base Protocol January 2011
the 'E' bit MUST NOT be sent as a response to an answer message.
Note that a message with the 'E' bit set is still subjected to the
processing rules defined in Section 6.2. When set, the answer
- message will not conform to the ABNF specification for the command,
- and will instead conform to the following ABNF:
+ message will not conform to the CCF specification for the command;
+ instead, it and will conform to the following CCF:
Message Format
- <answer-message> ::= < Diameter Header: code, ERR [PXY] >
+ <answer-message> ::= < Diameter Header: code, ERR [, PXY] >
0*1< Session-Id >
{ Origin-Host }
{ Origin-Realm }
@@ -5481,16 +5314,16 @@ Internet-Draft Diameter Base Protocol January 2011
[ Failed-AVP ]
[ Experimental-Result ]
* [ Proxy-Info ]
+ * [ AVP ]
-Fajardo, et al. Expires July 24, 2011 [Page 98]
+
+Fajardo, et al. Standards Track [Page 95]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- * [ AVP ]
-
Note that the code used in the header is the same than the one found
in the request message, but with the 'R' bit cleared and the 'E' bit
set. The 'P' bit in the header is set to the same value as the one
@@ -5499,10 +5332,10 @@ Internet-Draft Diameter Base Protocol January 2011
7.3. Error-Message AVP
The Error-Message AVP (AVP Code 281) is of type UTF8String. It MAY
- accompany a Result-Code AVP as a human readable error message. The
+ accompany a Result-Code AVP as a human-readable error message. The
Error-Message AVP is not intended to be useful in an environment
where error messages are processed automatically. It SHOULD NOT be
- expected that the content of this AVP is parsed by network entities.
+ expected that the content of this AVP be parsed by network entities.
7.4. Error-Reporting-Host AVP
@@ -5511,8 +5344,8 @@ Internet-Draft Diameter Base Protocol January 2011
host that sent the Result-Code AVP to a value other than 2001
(Success), only if the host setting the Result-Code is different from
the one encoded in the Origin-Host AVP. This AVP is intended to be
- used for troubleshooting purposes, and MUST be set when the Result-
- Code AVP indicates a failure.
+ used for troubleshooting purposes, and it MUST be set when the
+ Result-Code AVP indicates a failure.
7.5. Failed-AVP AVP
@@ -5520,43 +5353,44 @@ Internet-Draft Diameter Base Protocol January 2011
debugging information in cases where a request is rejected or not
fully processed due to erroneous information in a specific AVP. The
value of the Result-Code AVP will provide information on the reason
- for the Failed-AVP AVP. A Diameter message SHOULD contain only one
- Failed-AVP that corresponds to the error indicated by the Result-Code
- AVP. For practical purposes, this Failed-AVP would typically refer
- to the first AVP processing error that a Diameter node encounters.
+ for the Failed-AVP AVP. A Diameter answer message SHOULD contain an
+ instance of the Failed-AVP AVP that corresponds to the error
+ indicated by the Result-Code AVP. For practical purposes, this
+ Failed-AVP would typically refer to the first AVP processing error
+ that a Diameter node encounters.
The possible reasons for this AVP are the presence of an improperly
constructed AVP, an unsupported or unrecognized AVP, an invalid AVP
value, the omission of a required AVP, the presence of an explicitly
- excluded AVP (see tables in Section 10), or the presence of two or
- more occurrences of an AVP which is restricted to 0, 1, or 0-1
+ excluded AVP (see tables in Section 10) or the presence of two or
+ more occurrences of an AVP that is restricted to 0, 1, or 0-1
occurrences.
A Diameter message SHOULD contain one Failed-AVP AVP, containing the
entire AVP that could not be processed successfully. If the failure
reason is omission of a required AVP, an AVP with the missing AVP
- code, the missing vendor id, and a zero filled payload of the minimum
+ code, the missing Vendor-Id, and a zero-filled payload of the minimum
required length for the omitted AVP will be added. If the failure
+ reason is an invalid AVP length where the reported length is less
-Fajardo, et al. Expires July 24, 2011 [Page 99]
+Fajardo, et al. Standards Track [Page 96]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- reason is an invalid AVP length where the reported length is less
than the minimum AVP header length or greater than the reported
- message length, a copy of the offending AVP header and a zero filled
+ message length, a copy of the offending AVP header and a zero-filled
payload of the minimum required length SHOULD be added.
- In the case where the offending AVP is embedded within a grouped AVP,
- the Failed-AVP MAY contain the grouped AVP which in turn contains the
- single offending AVP. The same method MAY be employed if the grouped
- AVP itself is embedded in yet another grouped AVP and so on. In this
- case, the Failed-AVP MAY contain the grouped AVP hierarchy up to the
- single offending AVP. This enables the recipient to detect the
- location of the offending AVP when embedded in a group.
+ In the case where the offending AVP is embedded within a Grouped AVP,
+ the Failed-AVP MAY contain the grouped AVP, which in turn contains
+ the single offending AVP. The same method MAY be employed if the
+ grouped AVP itself is embedded in yet another grouped AVP and so on.
+ In this case, the Failed-AVP MAY contain the grouped AVP hierarchy up
+ to the single offending AVP. This enables the recipient to detect
+ the location of the offending AVP when embedded in a group.
AVP Format
@@ -5577,7 +5411,7 @@ Internet-Draft Diameter Base Protocol January 2011
{ Experimental-Result-Code }
The Vendor-Id AVP (see Section 5.3.3) in this grouped AVP identifies
- the vendor responsible for the assignment of the result code which
+ the vendor responsible for the assignment of the result code that
follows. All Diameter answer messages defined in vendor-specific
applications MUST include either one Result-Code AVP or one
Experimental-Result AVP.
@@ -5590,23 +5424,24 @@ Internet-Draft Diameter Base Protocol January 2011
It is recommended that vendor-specific result codes follow the same
conventions given for the Result-Code AVP regarding the different
- types of result codes and the handling of errors (for non 2xxx
+ types of result codes and the handling of errors (for non-2xxx
values).
-Fajardo, et al. Expires July 24, 2011 [Page 100]
+
+Fajardo, et al. Standards Track [Page 97]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
8. Diameter User Sessions
In general, Diameter can provide two different types of services to
applications. The first involves authentication and authorization,
- and can optionally make use of accounting. The second only makes use
- of accounting.
+ and it can optionally make use of accounting. The second only makes
+ use of accounting.
When a service makes use of the authentication and/or authorization
portion of an application, and a user requests access to the network,
@@ -5614,27 +5449,28 @@ Internet-Draft Diameter Base Protocol January 2011
auth request is defined in a service-specific Diameter application
(e.g., NASREQ). The request contains a Session-Id AVP, which is used
in subsequent messages (e.g., subsequent authorization, accounting,
- etc) relating to the user's session. The Session-Id AVP is a means
+ etc.) relating to the user's session. The Session-Id AVP is a means
for the client and servers to correlate a Diameter message with a
user session.
- When a Diameter server authorizes a user to use network resources for
- a finite amount of time, and it is willing to extend the
- authorization via a future request, it MUST add the Authorization-
- Lifetime AVP to the answer message. The Authorization-Lifetime AVP
- defines the maximum number of seconds a user MAY make use of the
- resources before another authorization request is expected by the
- server. The Auth-Grace-Period AVP contains the number of seconds
- following the expiration of the Authorization-Lifetime, after which
- the server will release all state information related to the user's
- session. Note that if payment for services is expected by the
- serving realm from the user's home realm, the Authorization-Lifetime
- AVP, combined with the Auth-Grace-Period AVP, implies the maximum
- length of the session the home realm is willing to be fiscally
- responsible for. Services provided past the expiration of the
- Authorization-Lifetime and Auth-Grace-Period AVPs are the
- responsibility of the access device. Of course, the actual cost of
- services rendered is clearly outside the scope of the protocol.
+ When a Diameter server authorizes a user to implement network
+ resources for a finite amount of time, and it is willing to extend
+ the authorization via a future request, it MUST add the
+ Authorization- Lifetime AVP to the answer message. The
+ Authorization-Lifetime AVP defines the maximum number of seconds a
+ user MAY make use of the resources before another authorization
+ request is expected by the server. The Auth-Grace-Period AVP
+ contains the number of seconds following the expiration of the
+ Authorization-Lifetime, after which the server will release all state
+ information related to the user's session. Note that if payment for
+ services is expected by the serving realm from the user's home realm,
+ the Authorization-Lifetime AVP, combined with the Auth-Grace-Period
+ AVP, implies the maximum length of the session for which the home
+ realm is willing to be fiscally responsible. Services provided past
+ the expiration of the Authorization-Lifetime and Auth-Grace-Period
+ AVPs are the responsibility of the access device. Of course, the
+ actual cost of services rendered is clearly outside the scope of the
+ protocol.
An access device that does not expect to send a re-authorization or a
session termination request to the server MAY include the Auth-
@@ -5648,32 +5484,33 @@ Internet-Draft Diameter Base Protocol January 2011
value NO_STATE_MAINTAINED MUST NOT be set in subsequent re-
authorization requests and answers.
- The base protocol does not include any authorization request
-Fajardo, et al. Expires July 24, 2011 [Page 101]
+Fajardo, et al. Standards Track [Page 98]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ The base protocol does not include any authorization request
messages, since these are largely application-specific and are
defined in a Diameter application document. However, the base
protocol does define a set of messages that are used to terminate
user sessions. These are used to allow servers that maintain state
information to free resources.
- When a service only makes use of the Accounting portion of the
+ When a service only makes use of the accounting portion of the
Diameter protocol, even in combination with an application, the
Session-Id is still used to identify user sessions. However, the
session termination messages are not used, since a session is
signaled as being terminated by issuing an accounting stop message.
Diameter may also be used for services that cannot be easily
- categorized as authentication, authorization or accounting (e.g.,
- certain 3GPP IMS interfaces). In such cases, the finite state
+ categorized as authentication, authorization, or accounting (e.g.,
+ certain Third Generation Partnership Project Internet Multimedia
+ System (3GPP IMS) interfaces). In such cases, the finite state
machine defined in subsequent sections may not be applicable.
- Therefore, the applications itself MAY need to define its own finite
+ Therefore, the application itself MAY need to define its own finite
state machine. However, such application-specific state machines
SHOULD follow the general state machine framework outlined in this
document such as the use of Session-Id AVPs and the use of STR/STA,
@@ -5681,12 +5518,12 @@ Internet-Draft Diameter Base Protocol January 2011
8.1. Authorization Session State Machine
- This section contains a set of finite state machines, representing
- the life cycle of Diameter sessions, and which MUST be observed by
- all Diameter implementations that make use of the authentication
- and/or authorization portion of a Diameter application. The term
- Service-Specific below refers to a message defined in a Diameter
- application (e.g., Mobile IPv4, NASREQ).
+ This section contains a set of finite state machines, which represent
+ the life cycle of Diameter sessions and which MUST be observed by all
+ Diameter implementations that make use of the authentication and/or
+ authorization portion of a Diameter application. The term "Service-
+ Specific" below refers to a message defined in a Diameter application
+ (e.g., Mobile IPv4, NASREQ).
There are four different authorization session state machines
supported in the Diameter base protocol. The first two describe a
@@ -5700,26 +5537,25 @@ Internet-Draft Diameter Base Protocol January 2011
When a session is moved to the Idle state, any resources that were
allocated for the particular session must be released. Any event not
- listed in the state machines MUST be considered as an error
- condition, and an answer, if applicable, MUST be returned to the
- originator of the message.
+ listed in the state machines MUST be considered an error condition,
+ and an answer, if applicable, MUST be returned to the originator of
+ the message.
- In the case that an application does not support re-auth, the state
-
-Fajardo, et al. Expires July 24, 2011 [Page 102]
+Fajardo, et al. Standards Track [Page 99]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- transitions related to server-initiated re-auth when both client and
- server session maintains state (e.g., Send RAR, Pending, Receive RAA)
- MAY be ignored.
+ In the case that an application does not support re-auth, the state
+ transitions related to server-initiated re-auth, when both client and
+ server sessions maintain state (e.g., Send RAR, Pending, Receive
+ RAA), MAY be ignored.
- In the state table, the event 'Failure to send X' means that the
+ In the state table, the event "Failure to send X" means that the
Diameter agent is unable to send command X to the desired
- destination. This could be due to the peer being down, or due to the
+ destination. This could be due to the peer being down or due to the
peer sending back a transient failure or temporary protocol error
notification DIAMETER_TOO_BUSY or DIAMETER_LOOP_DETECTED in the
Result-Code AVP of the corresponding Answer command. The event 'X
@@ -5731,8 +5567,8 @@ Internet-Draft Diameter Base Protocol January 2011
CLIENT, STATEFUL
State Event Action New State
---------------------------------------------------------------
- Idle Client or Device Requests Send Pending
- access service
+ Idle Client or device requests Send Pending
+ access service-
specific
auth req
@@ -5748,39 +5584,38 @@ Internet-Draft Diameter Base Protocol January 2011
UNKNOWN_
SESSION_ID
- Pending Successful Service-specific Grant Open
+ Pending Successful service-specific Grant Open
authorization answer Access
received with default
Auth-Session-State value
- Pending Successful Service-specific Sent STR Discon
- authorization answer received
+ Pending Successful service-specific Sent STR Discon
+ authorization answer received,
but service not provided
Pending Error processing successful Sent STR Discon
- Service-specific authorization
+ service-specific authorization
answer
-
-Fajardo, et al. Expires July 24, 2011 [Page 103]
+Fajardo, et al. Standards Track [Page 100]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- Pending Failed Service-specific Cleanup Idle
+ Pending Failed service-specific Clean up Idle
authorization answer received
Open User or client device Send Open
- requests access to service service
+ requests access to service service-
specific
auth req
- Open Successful Service-specific Provide Open
- authorization answer received Service
+ Open Successful service-specific Provide Open
+ authorization answer received service
- Open Failed Service-specific Discon. Idle
+ Open Failed service-specific Discon. Idle
authorization answer user/device
received.
@@ -5796,10 +5631,10 @@ Internet-Draft Diameter Base Protocol January 2011
Discon.
user/device
- Open Session-Timeout Expires on Send STR Discon
- Access Device
+ Open Session-Timeout expires on Send STR Discon
+ access device
- Open ASR Received, Send ASA Discon
+ Open ASR received, Send ASA Discon
client will comply with
with request to end the Result-Code =
session = SUCCESS,
@@ -5814,17 +5649,18 @@ Internet-Draft Diameter Base Protocol January 2011
Auth-Grace-Period expires on
access device
- Discon ASR Received Send ASA Discon
+ Discon ASR received Send ASA Discon
+
- Discon STA Received Discon. Idle
-Fajardo, et al. Expires July 24, 2011 [Page 104]
+Fajardo, et al. Standards Track [Page 101]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ Discon STA received Discon. Idle
user/device
The following state machine is observed by a server when it is
@@ -5835,31 +5671,34 @@ Internet-Draft Diameter Base Protocol January 2011
---------------------------------------------------------------
Idle Service-specific authorization Send Open
request received, and successful
- user is authorized serv.
+ user is authorized service-
specific
answer
Idle Service-specific authorization Send Idle
- request received, and failed serv.
- user is not authorized specific
+ request received, and failed
+ user is not authorized service-
+ specific
answer
Open Service-specific authorization Send Open
request received, and user successful
- is authorized serv. specific
+ is authorized service-
+ specific
answer
Open Service-specific authorization Send Idle
- request received, and user failed serv.
- is not authorized specific
+ request received, and user failed
+ is not authorized service-
+ specific
answer,
- Cleanup
+ Clean up
Open Home server wants to confirm Send RAR Pending
authentication and/or
authorization of the user
- Pending Received RAA with a failed Cleanup Idle
+ Pending Received RAA with a failed Clean up Idle
Result-Code
Pending Received RAA with Result-Code Update Open
@@ -5868,32 +5707,33 @@ Internet-Draft Diameter Base Protocol January 2011
Open Home server wants to Send ASR Discon
terminate the service
- Open Authorization-Lifetime (and Cleanup Idle
- Auth-Grace-Period) expires
- on home server.
- Open Session-Timeout expires on Cleanup Idle
-Fajardo, et al. Expires July 24, 2011 [Page 105]
+Fajardo, et al. Standards Track [Page 102]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+ Open Authorization-Lifetime (and Clean up Idle
+ Auth-Grace-Period) expires
+ on home server
+
+ Open Session-Timeout expires on Clean up Idle
home server
Discon Failure to send ASR Wait, Discon
resend ASR
- Discon ASR successfully sent and Cleanup Idle
+ Discon ASR successfully sent and Clean up Idle
ASA Received with Result-Code
- Not ASA Received None No Change.
+ Not ASA Received None No Change
Discon
Any STR Received Send STA, Idle
- Cleanup.
+ Clean up
The following state machine is observed by a client when state is not
maintained on the server:
@@ -5901,48 +5741,47 @@ Internet-Draft Diameter Base Protocol January 2011
CLIENT, STATELESS
State Event Action New State
---------------------------------------------------------------
- Idle Client or Device Requests Send Pending
- access service
+ Idle Client or device requests Send Pending
+ access service-
specific
auth req
- Pending Successful Service-specific Grant Open
- authorization answer Access
+ Pending Successful service-specific Grant Open
+ authorization answer access
received with Auth-Session-
State set to
NO_STATE_MAINTAINED
- Pending Failed Service-specific Cleanup Idle
+ Pending Failed service-specific Clean up Idle
authorization answer
received
- Open Session-Timeout Expires on Discon. Idle
- Access Device user/device
+ Open Session-Timeout expires on Discon. Idle
+ access device user/device
Open Service to user is terminated Discon. Idle
user/device
- The following state machine is observed by a server when it is not
- maintaining state for the session:
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 106]
+Fajardo, et al. Standards Track [Page 103]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ The following state machine is observed by a server when it is not
+ maintaining state for the session:
SERVER, STATELESS
State Event Action New State
---------------------------------------------------------------
- Idle Service-specific authorization Send serv. Idle
- request received, and specific
- successfully processed answer
+ Idle Service-specific authorization Send Idle
+ request received, and service-
+ successfully processed specific
+ answer
8.2. Accounting Session State Machine
@@ -5960,8 +5799,8 @@ Internet-Draft Diameter Base Protocol January 2011
machine in this section described below.
The default server side state machine requires the reception of
- accounting records in any order and at any time, and does not place
- any standards requirement on the processing of these records.
+ accounting records in any order and at any time, and it does not
+ place any standards requirement on the processing of these records.
Implementations of Diameter may perform checking, ordering,
correlation, fraud detection, and other tasks based on these records.
AVPs may need to be inspected as a part of these tasks. The tasks
@@ -5970,7 +5809,7 @@ Internet-Draft Diameter Base Protocol January 2011
or even policy dependent, they are not standardized by the Diameter
specifications. Applications MAY define requirements on when to
accept accounting records based on the used value of Accounting-
- Realtime-Required AVP, credit limits checks, and so on.
+ Realtime-Required AVP, credit-limit checks, and so on.
However, the Diameter base protocol defines one optional server side
state machine that MAY be followed by applications that require
@@ -5978,31 +5817,31 @@ Internet-Draft Diameter Base Protocol January 2011
that such tracking is incompatible with the ability to sustain long
duration connectivity problems. Therefore, the use of this state
machine is recommended only in applications where the value of the
- Accounting-Realtime-Required AVP is DELIVER_AND_GRANT, and hence
+ Accounting-Realtime-Required AVP is DELIVER_AND_GRANT; hence,
accounting connectivity problems are required to cause the serviced
user to be disconnected. Otherwise, records produced by the client
- may be lost by the server which no longer accepts them after the
- connectivity is re-established. This state machine is the third
- state machine in this section. The state machine is supervised by a
- supervision session timer Ts, which the value should be reasonably
-Fajardo, et al. Expires July 24, 2011 [Page 107]
+Fajardo, et al. Standards Track [Page 104]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- higher than the Acct_Interim_Interval value. Ts MAY be set to two
- times the value of the Acct_Interim_Interval so as to avoid the
- accounting session in the Diameter server to change to Idle state in
- case of short transient network failure.
+ may be lost by the server, which no longer accepts them after the
+ connectivity is re-established. This state machine is the third
+ state machine in this section. The state machine is supervised by a
+ supervision session timer Ts, whose value should be reasonably higher
+ than the Acct_Interim_Interval value. Ts MAY be set to two times the
+ value of the Acct_Interim_Interval so as to avoid the accounting
+ session in the Diameter server to change to Idle state in case of
+ short transient network failure.
Any event not listed in the state machines MUST be considered as an
error condition, and a corresponding answer, if applicable, MUST be
returned to the originator of the message.
- In the state table, the event 'Failure to send' means that the
+ In the state table, the event "Failure to send" means that the
Diameter client is unable to communicate with the desired
destination. This could be due to the peer being down, or due to the
peer sending back a transient failure or temporary protocol error
@@ -6010,17 +5849,17 @@ Internet-Draft Diameter Base Protocol January 2011
DIAMETER_LOOP_DETECTED in the Result-Code AVP of the Accounting
Answer command.
- The event 'Failed answer' means that the Diameter client received a
+ The event "Failed answer" means that the Diameter client received a
non-transient failure notification in the Accounting Answer command.
- Note that the action 'Disconnect user/dev' MUST have an effect also
- to the authorization session state table, e.g., cause the STR message
+ Note that the action "Disconnect user/dev" MUST also have an effect
+ on the authorization session state table, e.g., cause the STR message
to be sent, if the given application has both authentication/
authorization and accounting portions.
- The states PendingS, PendingI, PendingL, PendingE and PendingB stand
+ The states PendingS, PendingI, PendingL, PendingE, and PendingB stand
for pending states to wait for an answer to an accounting request
- related to a Start, Interim, Stop, Event or buffered record,
+ related to a Start, Interim, Stop, Event, or buffered record,
respectively.
CLIENT, ACCOUNTING
@@ -6037,36 +5876,36 @@ Internet-Draft Diameter Base Protocol January 2011
Idle Records in storage Send PendingB
record
- PendingS Successful accounting Open
- start answer received
-
- PendingS Failure to send and buffer Store Open
-Fajardo, et al. Expires July 24, 2011 [Page 108]
+Fajardo, et al. Standards Track [Page 105]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- space available and realtime Start
+ PendingS Successful accounting Open
+ start answer received
+
+ PendingS Failure to send and buffer Store Open
+ space available and real time Start
not equal to DELIVER_AND_GRANT Record
PendingS Failure to send and no buffer Open
- space available and realtime
+ space available and real time
equal to GRANT_AND_LOSE
PendingS Failure to send and no Disconnect Idle
buffer space available and user/dev
- realtime not equal to
+ real time not equal to
GRANT_AND_LOSE
PendingS Failed accounting start answer Open
- received and realtime equal
+ received and real time equal
to GRANT_AND_LOSE
PendingS Failed accounting start answer Disconnect Idle
- received and realtime not user/dev
+ received and real time not user/dev
equal to GRANT_AND_LOSE
PendingS User service terminated Store PendingS
@@ -6077,6 +5916,7 @@ Internet-Draft Diameter Base Protocol January 2011
accounting
interim
record
+
Open User service terminated Send PendingL
accounting
stop req.
@@ -6087,34 +5927,35 @@ Internet-Draft Diameter Base Protocol January 2011
PendingI Failure to send and (buffer Store Open
space available or old interim
record can be overwritten) record
- and realtime not equal to
+ and real time not equal to
DELIVER_AND_GRANT
- PendingI Failure to send and no buffer Open
- space available and realtime
- equal to GRANT_AND_LOSE
- PendingI Failure to send and no Disconnect Idle
- buffer space available and user/dev
-Fajardo, et al. Expires July 24, 2011 [Page 109]
+Fajardo, et al. Standards Track [Page 106]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ PendingI Failure to send and no buffer Open
+ space available and real time
+ equal to GRANT_AND_LOSE
- realtime not equal to
+ PendingI Failure to send and no Disconnect Idle
+ buffer space available and user/dev
+ real time not equal to
GRANT_AND_LOSE
PendingI Failed accounting interim Open
- answer received and realtime
+ answer received and real time
equal to GRANT_AND_LOSE
PendingI Failed accounting interim Disconnect Idle
answer received and user/dev
- realtime not equal to
+ real time not equal to
GRANT_AND_LOSE
PendingI User service terminated Store PendingI
@@ -6148,6 +5989,13 @@ Internet-Draft Diameter Base Protocol January 2011
space available stop
record
+
+
+Fajardo, et al. Standards Track [Page 107]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
PendingL Failure to send and no buffer Idle
space available
@@ -6155,124 +6003,133 @@ Internet-Draft Diameter Base Protocol January 2011
received
-
-Fajardo, et al. Expires July 24, 2011 [Page 110]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
SERVER, STATELESS ACCOUNTING
State Event Action New State
---------------------------------------------------------------
Idle Accounting start request Send Idle
- received, and successfully accounting
+ received and successfully accounting
processed. start
answer
Idle Accounting event request Send Idle
- received, and successfully accounting
+ received and successfully accounting
processed. event
answer
- Idle Interim record received, Send Idle
+ Idle Interim record received Send Idle
and successfully processed. accounting
interim
answer
Idle Accounting stop request Send Idle
- received, and successfully accounting
+ received and successfully accounting
processed stop answer
- Idle Accounting request received, Send Idle
+ Idle Accounting request received; Send Idle
no space left to store accounting
- records answer,
+ records answer;
Result-Code =
OUT_OF_
SPACE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 108]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
SERVER, STATEFUL ACCOUNTING
State Event Action New State
---------------------------------------------------------------
Idle Accounting start request Send Open
- received, and successfully accounting
+ received and successfully accounting
processed. start
- answer,
+ answer;
Start Ts
Idle Accounting event request Send Idle
- received, and successfully accounting
+ received and successfully accounting
processed. event
answer
-
- Idle Accounting request received, Send Idle
+ Idle Accounting request received; Send Idle
no space left to store accounting
- records answer,
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 111]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
+ records answer;
Result-Code =
OUT_OF_
SPACE
- Open Interim record received, Send Open
+ Open Interim record received Send Open
and successfully processed. accounting
interim
- answer,
+ answer;
Restart Ts
Open Accounting stop request Send Idle
- received, and successfully accounting
- processed stop answer,
+ received and successfully accounting
+ processed stop answer;
Stop Ts
- Open Accounting request received, Send Idle
+ Open Accounting request received; Send Idle
no space left to store accounting
- records answer,
+ records answer;
Result-Code =
OUT_OF_
- SPACE,
+ SPACE;
Stop Ts
Open Session supervision timer Ts Stop Ts Idle
expired
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 109]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
8.3. Server-Initiated Re-Auth
A Diameter server may initiate a re-authentication and/or re-
authorization service for a particular session by issuing a Re-Auth-
Request (RAR).
- For example, for pre-paid services, the Diameter server that
+ For example, for prepaid services, the Diameter server that
originally authorized a session may need some confirmation that the
user is still using the services.
- An access device that receives a RAR message with Session-Id equal to
- a currently active session MUST initiate a re-auth towards the user,
- if the service supports this particular feature. Each Diameter
- application MUST state whether server-initiated re-auth is supported,
- since some applications do not allow access devices to prompt the
- user for re-auth.
+ An access device that receives an RAR message with the Session-Id
+ equal to a currently active session MUST initiate a re-auth towards
+ the user, if the service supports this particular feature. Each
+ Diameter application MUST state whether server-initiated re-auth is
+ supported, since some applications do not allow access devices to
+ prompt the user for re-auth.
8.3.1. Re-Auth-Request
- The Re-Auth-Request (RAR), indicated by the Command-Code set to 258
+ The Re-Auth-Request (RAR), indicated by the Command Code set to 258
and the message flags' 'R' bit set, may be sent by any server to the
access device that is providing session service, to request that the
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 112]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
user be re-authenticated and/or re-authorized.
@@ -6294,15 +6151,22 @@ Internet-Draft Diameter Base Protocol January 2011
8.3.2. Re-Auth-Answer
- The Re-Auth-Answer (RAA), indicated by the Command-Code set to 258
+ The Re-Auth-Answer (RAA), indicated by the Command Code set to 258
and the message flags' 'R' bit clear, is sent in response to the RAR.
- The Result-Code AVP MUST be present, and indicates the disposition of
- the request.
+ The Result-Code AVP MUST be present, and it indicates the disposition
+ of the request.
+
+
+
+
+Fajardo, et al. Standards Track [Page 110]
+
+RFC 6733 Diameter Base Protocol October 2012
+
A successful RAA message MUST be followed by an application-specific
authentication and/or authorization message.
-
Message Format
<RAA> ::= < Diameter Header: 258, PXY >
@@ -6321,14 +6185,6 @@ Internet-Draft Diameter Base Protocol January 2011
* [ Proxy-Info ]
* [ AVP ]
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 113]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
8.4. Session Termination
It is necessary for a Diameter server that authorized a session, for
@@ -6356,6 +6212,14 @@ Internet-Draft Diameter Base Protocol January 2011
It is also possible that a session that was authorized is never
actually started due to action of a proxy. For example, a proxy may
+
+
+
+Fajardo, et al. Standards Track [Page 111]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
modify an authorization answer, converting the result from success to
failure, prior to forwarding the message to the access device. If
the answer did not contain an Auth-Session-State AVP with the value
@@ -6366,36 +6230,27 @@ Internet-Draft Diameter Base Protocol January 2011
A Diameter server that receives an STR message MUST clean up
resources (e.g., session state) associated with the Session-Id
- specified in the STR, and return a Session-Termination-Answer.
+ specified in the STR and return a Session-Termination-Answer.
A Diameter server also MUST clean up resources when the Session-
Timeout expires, or when the Authorization-Lifetime and the Auth-
- Grace-Period AVPs expires without receipt of a re-authorization
+ Grace-Period AVPs expire without receipt of a re-authorization
request, regardless of whether an STR for that session is received.
The access device is not expected to provide service beyond the
expiration of these timers; thus, expiration of either of these
timers implies that the access device may have unexpectedly shut
down.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 114]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
8.4.1. Session-Termination-Request
- The Session-Termination-Request (STR), indicated by the Command-Code
+ The Session-Termination-Request (STR), indicated by the Command Code
set to 275 and the Command Flags' 'R' bit set, is sent by a Diameter
- client or by a Diameter proxy to inform the Diameter Server that an
+ client or by a Diameter proxy to inform the Diameter server that an
authenticated and/or authorized session is being terminated.
+ Message Format
- Message Format
-
- <STR> ::= < Diameter Header: 275, REQ, PXY >
+ <STR> ::= < Diameter Header: 275, REQ, PXY >
< Session-Id >
{ Origin-Host }
{ Origin-Realm }
@@ -6410,40 +6265,33 @@ Internet-Draft Diameter Base Protocol January 2011
* [ Route-Record ]
* [ AVP ]
-8.4.2. Session-Termination-Answer
-
- The Session-Termination-Answer (STA), indicated by the Command-Code
- set to 275 and the message flags' 'R' bit clear, is sent by the
- Diameter Server to acknowledge the notification that the session has
- been terminated. The Result-Code AVP MUST be present, and MAY
- contain an indication that an error occurred while servicing the STR.
-
- Upon sending or receipt of the STA, the Diameter Server MUST release
- all resources for the session indicated by the Session-Id AVP. Any
- intermediate server in the Proxy-Chain MAY also release any
- resources, if necessary.
-
-
-
-
-
+Fajardo, et al. Standards Track [Page 112]
+
+RFC 6733 Diameter Base Protocol October 2012
+8.4.2. Session-Termination-Answer
-Fajardo, et al. Expires July 24, 2011 [Page 115]
-
-Internet-Draft Diameter Base Protocol January 2011
+ The Session-Termination-Answer (STA), indicated by the Command Code
+ set to 275 and the message flags' 'R' bit clear, is sent by the
+ Diameter server to acknowledge the notification that the session has
+ been terminated. The Result-Code AVP MUST be present, and it MAY
+ contain an indication that an error occurred while servicing the STR.
+ Upon sending or receipt of the STA, the Diameter server MUST release
+ all resources for the session indicated by the Session-Id AVP. Any
+ intermediate server in the Proxy-Chain MAY also release any
+ resources, if necessary.
- Message Format
+ Message Format
- <STA> ::= < Diameter Header: 275, PXY >
+ <STA> ::= < Diameter Header: 275, PXY >
< Session-Id >
{ Result-Code }
{ Origin-Host }
@@ -6473,31 +6321,29 @@ Internet-Draft Diameter Base Protocol January 2011
An access device that receives an ASR with Session-ID equal to a
currently active session MAY stop the session. Whether the access
- device stops the session or not is implementation- and/or
- configuration-dependent. For example, an access device may honor
+ device stops the session or not is implementation and/or
+ configuration dependent. For example, an access device may honor
ASRs from certain agents only. In any case, the access device MUST
+
+
+
+Fajardo, et al. Standards Track [Page 113]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
respond with an Abort-Session-Answer, including a Result-Code AVP to
indicate what action it took.
8.5.1. Abort-Session-Request
- The Abort-Session-Request (ASR), indicated by the Command-Code set to
+ The Abort-Session-Request (ASR), indicated by the Command Code set to
274 and the message flags' 'R' bit set, may be sent by any Diameter
server or any Diameter proxy to the access device that is providing
session service, to request that the session identified by the
Session-Id be stopped.
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 116]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- Message Format
+ Message Format
<ASR> ::= < Diameter Header: 274, REQ, PXY >
< Session-Id >
@@ -6514,20 +6360,35 @@ Internet-Draft Diameter Base Protocol January 2011
8.5.2. Abort-Session-Answer
- The Abort-Session-Answer (ASA), indicated by the Command-Code set to
+ The Abort-Session-Answer (ASA), indicated by the Command Code set to
274 and the message flags' 'R' bit clear, is sent in response to the
- ASR. The Result-Code AVP MUST be present, and indicates the
+ ASR. The Result-Code AVP MUST be present and indicates the
disposition of the request.
If the session identified by Session-Id in the ASR was successfully
- terminated, Result-Code is set to DIAMETER_SUCCESS. If the session
- is not currently active, Result-Code is set to
+ terminated, the Result-Code is set to DIAMETER_SUCCESS. If the
+ session is not currently active, the Result-Code is set to
DIAMETER_UNKNOWN_SESSION_ID. If the access device does not stop the
- session for any other reason, Result-Code is set to
+ session for any other reason, the Result-Code is set to
DIAMETER_UNABLE_TO_COMPLY.
- Message Format
+
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 114]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ Message Format
<ASA> ::= < Diameter Header: 274, PXY >
< Session-Id >
@@ -6545,14 +6406,6 @@ Internet-Draft Diameter Base Protocol January 2011
* [ Proxy-Info ]
* [ AVP ]
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 117]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
8.6. Inferring Session Termination from Origin-State-Id
The Origin-State-Id is used to allow detection of terminated sessions
@@ -6560,94 +6413,96 @@ Internet-Draft Diameter Base Protocol January 2011
shutdown of an access device.
A Diameter client or access device increments the value of the
- Origin-State-Id every time it is started or powered-up. The new
+ Origin-State-Id every time it is started or powered up. The new
Origin-State-Id is then sent in the CER/CEA message immediately upon
connection to the server. The Diameter server receiving the new
Origin-State-Id can determine whether the sending Diameter client had
- abruptly shutdown by comparing the old value of the Origin-State-Id
+ abruptly shut down by comparing the old value of the Origin-State-Id
it has kept for that specific client is less than the new value and
whether it has un-terminated sessions originating from that client.
An access device can also include the Origin-State-Id in request
- messages other than CER if there are relays or proxies in between the
- access device and the server. In this case, however, the server
+ messages other than the CER if there are relays or proxies in between
+ the access device and the server. In this case, however, the server
cannot discover that the access device has been restarted unless and
- until it receives a new request from it. Therefore this mechanism is
- more opportunistic across proxies and relays.
+ until it receives a new request from it. Therefore, this mechanism
+ is more opportunistic across proxies and relays.
The Diameter server may assume that all sessions that were active
prior to detection of a client restart have been terminated. The
Diameter server MAY clean up all session state associated with such
- lost sessions, and MAY also issues STRs for all such lost sessions
+ lost sessions, and it MAY also issue STRs for all such lost sessions
that were authorized on upstream servers, to allow session state to
be cleaned up globally.
+
+
+
+
+Fajardo, et al. Standards Track [Page 115]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
8.7. Auth-Request-Type AVP
The Auth-Request-Type AVP (AVP Code 274) is of type Enumerated and is
included in application-specific auth requests to inform the peers
- whether a user is to be authenticated only, authorized only or both.
+ whether a user is to be authenticated only, authorized only, or both.
Note any value other than both MAY cause RADIUS interoperability
issues. The following values are defined:
-
AUTHENTICATE_ONLY 1
- The request being sent is for authentication only, and MUST
- contain the relevant application specific authentication AVPs that
+ The request being sent is for authentication only, and it MUST
+ contain the relevant application-specific authentication AVPs that
are needed by the Diameter server to authenticate the user.
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 118]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
AUTHORIZE_ONLY 2
- The request being sent is for authorization only, and MUST contain
- the application-specific authorization AVPs that are necessary to
- identify the service being requested/offered.
-
+ The request being sent is for authorization only, and it MUST
+ contain the application-specific authorization AVPs that are
+ necessary to identify the service being requested/offered.
AUTHORIZE_AUTHENTICATE 3
The request contains a request for both authentication and
authorization. The request MUST include both the relevant
- application-specific authentication information, and authorization
+ application-specific authentication information and authorization
information necessary to identify the service being requested/
offered.
-
8.8. Session-Id AVP
The Session-Id AVP (AVP Code 263) is of type UTF8String and is used
to identify a specific session (see Section 8). All messages
- pertaining to a specific session MUST include only one Session-Id AVP
- and the same value MUST be used throughout the life of a session.
- When present, the Session-Id SHOULD appear immediately following the
- Diameter Header (see Section 3).
+ pertaining to a specific session MUST include only one Session-Id
+ AVP, and the same value MUST be used throughout the life of a
+ session. When present, the Session-Id SHOULD appear immediately
+ following the Diameter header (see Section 3).
The Session-Id MUST be globally and eternally unique, as it is meant
to uniquely identify a user session without reference to any other
- information, and may be needed to correlate historical authentication
- information with accounting information. The Session-Id includes a
- mandatory portion and an implementation-defined portion; a
- recommended format for the implementation-defined portion is outlined
- below.
+ information, and it may be needed to correlate historical
+ authentication information with accounting information. The
+ Session-Id includes a mandatory portion and an implementation-defined
+ portion; a recommended format for the implementation-defined portion
+ is outlined below.
The Session-Id MUST begin with the sender's identity encoded in the
- DiameterIdentity type (see Section 4.4). The remainder of the
- Session-Id is delimited by a ";" character, and MAY be any sequence
- that the client can guarantee to be eternally unique; however, the
- following format is recommended, (square brackets [] indicate an
- optional element):
+ DiameterIdentity type (see Section 4.3.1). The remainder of the
+ Session-Id is delimited by a ";" character, and it MAY be any
+
+
+
+Fajardo, et al. Standards Track [Page 116]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ sequence that the client can guarantee to be eternally unique;
+ however, the following format is recommended, (square brackets []
+ indicate an optional element):
<DiameterIdentity>;<high 32 bits>;<low 32 bits>[;<optional value>]
@@ -6657,22 +6512,14 @@ Internet-Draft Diameter Base Protocol January 2011
processors. At startup, the high 32 bits of the 64-bit value MAY be
initialized to the time in NTP format [RFC5905], and the low 32 bits
MAY be initialized to zero. This will for practical purposes
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 119]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
eliminate the possibility of overlapping Session-Ids after a reboot,
assuming the reboot process takes longer than a second.
Alternatively, an implementation MAY keep track of the increasing
value in non-volatile memory.
- <optional value> is implementation specific but may include a modem's
- device Id, a layer 2 address, timestamp, etc.
+ <optional value> is implementation specific, but it may include a
+ modem's device Id, a Layer 2 address, timestamp, etc.
Example, in which there is no optional value:
@@ -6683,45 +6530,44 @@ Internet-Draft Diameter Base Protocol January 2011
accesspoint7.example.com;1876543210;523;[email protected]
The Session-Id is created by the Diameter application initiating the
- session, which in most cases is done by the client. Note that a
- Session-Id MAY be used for both the authentication, authorization and
- accounting commands of a given application.
+ session, which, in most cases, is done by the client. Note that a
+ Session-Id MAY be used for both the authentication, authorization,
+ and accounting commands of a given application.
8.9. Authorization-Lifetime AVP
The Authorization-Lifetime AVP (AVP Code 291) is of type Unsigned32
and contains the maximum number of seconds of service to be provided
to the user before the user is to be re-authenticated and/or re-
- authorized. Care should be taken when the Authorization- Lifetime
- value is determined, since a low, non-zero, value could create
+ authorized. Care should be taken when the Authorization-Lifetime
+ value is determined, since a low, non-zero value could create
significant Diameter traffic, which could congest both the network
and the agents.
A value of zero (0) means that immediate re-auth is necessary by the
access device. The absence of this AVP, or a value of all ones
- (meaning all bits in the 32 bit field are set to one) means no re-
+ (meaning all bits in the 32-bit field are set to one) means no re-
auth is expected.
+
+
+Fajardo, et al. Standards Track [Page 117]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
If both this AVP and the Session-Timeout AVP are present in a
message, the value of the latter MUST NOT be smaller than the
Authorization-Lifetime AVP.
An Authorization-Lifetime AVP MAY be present in re-authorization
- messages, and contains the number of seconds the user is authorized
- to receive service from the time the re-auth answer message is
- received by the access device.
+ messages, and it contains the number of seconds the user is
+ authorized to receive service from the time the re-auth answer
+ message is received by the access device.
This AVP MAY be provided by the client as a hint of the maximum
lifetime that it is willing to accept. The server MUST return a
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 120]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
- value that is equal to, or smaller, than the one provided by the
+ value that is equal to, or smaller than, the one provided by the
client.
8.10. Auth-Grace-Period AVP
@@ -6739,7 +6585,6 @@ Internet-Draft Diameter Base Protocol January 2011
the value in the server's answer message is binding. The following
values are supported:
-
STATE_MAINTAINED 0
This value is used to specify that session state is being
@@ -6747,46 +6592,42 @@ Internet-Draft Diameter Base Protocol January 2011
message when service to the user is terminated. This is the
default value.
-
NO_STATE_MAINTAINED 1
This value is used to specify that no session termination messages
will be sent by the access device upon expiration of the
Authorization-Lifetime.
-
8.12. Re-Auth-Request-Type AVP
The Re-Auth-Request-Type AVP (AVP Code 285) is of type Enumerated and
is included in application-specific auth answers to inform the client
of the action expected upon expiration of the Authorization-Lifetime.
- If the answer message contains an Authorization-Lifetime AVP with a
- positive value, the Re-Auth-Request-Type AVP MUST be present in an
- answer message. The following values are defined:
- AUTHORIZE_ONLY 0
- An authorization only re-auth is expected upon expiration of the
- Authorization-Lifetime. This is the default value if the AVP is
+Fajardo, et al. Standards Track [Page 118]
+
+RFC 6733 Diameter Base Protocol October 2012
-Fajardo, et al. Expires July 24, 2011 [Page 121]
-
-Internet-Draft Diameter Base Protocol January 2011
+ If the answer message contains an Authorization-Lifetime AVP with a
+ positive value, the Re-Auth-Request-Type AVP MUST be present in an
+ answer message. The following values are defined:
+ AUTHORIZE_ONLY 0
+ An authorization only re-auth is expected upon expiration of the
+ Authorization-Lifetime. This is the default value if the AVP is
not present in answer messages that include the Authorization-
Lifetime.
-
AUTHORIZE_AUTHENTICATE 1
An authentication and authorization re-auth is expected upon
expiration of the Authorization-Lifetime.
-
8.13. Session-Timeout AVP
The Session-Timeout AVP (AVP Code 27) [RFC2865] is of type Unsigned32
@@ -6799,10 +6640,10 @@ Internet-Draft Diameter Base Protocol January 2011
A session that terminates on an access device due to the expiration
of the Session-Timeout MUST cause an STR to be issued, unless both
the access device and the home server had previously agreed that no
- session termination messages would be sent (see Section 8.11).
+ session termination messages would be sent (see Section 8).
A Session-Timeout AVP MAY be present in a re-authorization answer
- message, and contains the remaining number of seconds from the
+ message, and it contains the remaining number of seconds from the
beginning of the re-auth.
A value of zero, or the absence of this AVP, means that this session
@@ -6810,7 +6651,7 @@ Internet-Draft Diameter Base Protocol January 2011
This AVP MAY be provided by the client as a hint of the maximum
timeout that it is willing to accept. However, the server MAY return
- a value that is equal to, or smaller, than the one provided by the
+ a value that is equal to, or smaller than, the one provided by the
client.
8.14. User-Name AVP
@@ -6819,83 +6660,29 @@ Internet-Draft Diameter Base Protocol January 2011
contains the User-Name, in a format consistent with the NAI
specification [RFC4282].
-8.15. Termination-Cause AVP
-
- The Termination-Cause AVP (AVP Code 295) is of type Enumerated, and
- is used to indicate the reason why a session was terminated on the
- access device. The following values are defined:
-
-Fajardo, et al. Expires July 24, 2011 [Page 122]
+Fajardo, et al. Standards Track [Page 119]
-Internet-Draft Diameter Base Protocol January 2011
-
-
- DIAMETER_LOGOUT 1
-
- The user initiated a disconnect
-
-
- DIAMETER_SERVICE_NOT_PROVIDED 2
-
- This value is used when the user disconnected prior to the receipt
- of the authorization answer message.
-
-
- DIAMETER_BAD_ANSWER 3
-
- This value indicates that the authorization answer received by the
- access device was not processed successfully.
-
-
- DIAMETER_ADMINISTRATIVE 4
-
- The user was not granted access, or was disconnected, due to
- administrative reasons, such as the receipt of a Abort-Session-
- Request message.
-
-
- DIAMETER_LINK_BROKEN 5
-
- The communication to the user was abruptly disconnected.
-
-
- DIAMETER_AUTH_EXPIRED 6
-
- The user's access was terminated since its authorized session time
- has expired.
-
-
- DIAMETER_USER_MOVED 7
-
- The user is receiving services from another access device.
-
-
- DIAMETER_SESSION_TIMEOUT 8
+RFC 6733 Diameter Base Protocol October 2012
- The user's session has timed out, and service has been terminated.
+8.15. Termination-Cause AVP
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 123]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ The Termination-Cause AVP (AVP Code 295) is of type Enumerated, and
+ is used to indicate the reason why a session was terminated on the
+ access device. The currently assigned values for this AVP can be
+ found in the IANA registry for Termination-Cause AVP Values
+ [IANATCV].
8.16. Origin-State-Id AVP
The Origin-State-Id AVP (AVP Code 278), of type Unsigned32, is a
monotonically increasing value that is advanced whenever a Diameter
- entity restarts with loss of previous state, for example upon reboot.
- Origin-State-Id MAY be included in any Diameter message, including
- CER.
+ entity restarts with loss of previous state, for example, upon
+ reboot. Origin-State-Id MAY be included in any Diameter message,
+ including CER.
A Diameter entity issuing this AVP MUST create a higher value for
this AVP each time its state is reset. A Diameter entity MAY set
@@ -6911,20 +6698,34 @@ Internet-Draft Diameter Base Protocol January 2011
message, it allows other Diameter entities to infer that sessions
associated with a lower Origin-State-Id are no longer active. If an
access device does not intend for such inferences to be made, it MUST
- either not include Origin-State-Id in any message, or set its value
- to 0.
+ either not include Origin-State-Id in any message or set its value to
+ 0.
8.17. Session-Binding AVP
- The Session-Binding AVP (AVP Code 270) is of type Unsigned32, and MAY
- be present in application-specific authorization answer messages. If
- present, this AVP MAY inform the Diameter client that all future
+ The Session-Binding AVP (AVP Code 270) is of type Unsigned32, and it
+ MAY be present in application-specific authorization answer messages.
+ If present, this AVP MAY inform the Diameter client that all future
application-specific re-auth and Session-Termination-Request messages
for this session MUST be sent to the same authorization server.
- This field is a bit mask, and the following bits have been defined:
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 120]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ This field is a bit mask, and the following bits have been defined:
+
RE_AUTH 1
When set, future re-auth messages for this session MUST NOT
@@ -6932,23 +6733,13 @@ Internet-Draft Diameter Base Protocol January 2011
value, the Destination-Host AVP MUST be present in all re-auth
messages for this session.
-
STR 2
When set, the STR message for this session MUST NOT include the
Destination-Host AVP. When cleared, the default value, the
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 124]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Destination-Host AVP MUST be present in the STR message for this
session.
-
ACCOUNTING 4
When set, all accounting messages for this session MUST NOT
@@ -6956,10 +6747,9 @@ Internet-Draft Diameter Base Protocol January 2011
value, the Destination-Host AVP, if known, MUST be present in all
accounting messages for this session.
-
8.18. Session-Server-Failover AVP
- The Session-Server-Failover AVP (AVP Code 271) is of type Enumerated,
+ The Session-Server-Failover AVP (AVP Code 271) is of type Enumerated
and MAY be present in application-specific authorization answer
messages that either do not include the Session-Binding AVP or
include the Session-Binding AVP with any of the bits set to a zero
@@ -6970,11 +6760,24 @@ Internet-Draft Diameter Base Protocol January 2011
The following values are supported:
-
REFUSE_SERVICE 0
If either the re-auth or the STR message delivery fails, terminate
- service with the user, and do not attempt any subsequent attempts.
+ service with the user and do not attempt any subsequent attempts.
+
+
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 121]
+
+RFC 6733 Diameter Base Protocol October 2012
TRY_AGAIN 1
@@ -6982,34 +6785,23 @@ Internet-Draft Diameter Base Protocol January 2011
If either the re-auth or the STR message delivery fails, resend
the failed message without the Destination-Host AVP present.
-
ALLOW_SERVICE 2
If re-auth message delivery fails, assume that re-authorization
succeeded. If STR message delivery fails, terminate the session.
-
TRY_AGAIN_ALLOW_SERVICE 3
If either the re-auth or the STR message delivery fails, resend
the failed message without the Destination-Host AVP present. If
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 125]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
the second delivery fails for re-auth, assume re-authorization
succeeded. If the second delivery fails for STR, terminate the
session.
-
8.19. Multi-Round-Time-Out AVP
- The Multi-Round-Time-Out AVP (AVP Code 272) is of type Unsigned32,
- and SHOULD be present in application-specific authorization answer
+ The Multi-Round-Time-Out AVP (AVP Code 272) is of type Unsigned32 and
+ SHOULD be present in application-specific authorization answer
messages whose Result-Code AVP is set to DIAMETER_MULTI_ROUND_AUTH.
This AVP contains the maximum number of seconds that the access
device MUST provide the user in responding to an authentication
@@ -7031,37 +6823,24 @@ Internet-Draft Diameter Base Protocol January 2011
8.21. Event-Timestamp AVP
- The Event-Timestamp (AVP Code 55) is of type Time, and MAY be
- included in an Accounting-Request and Accounting-Answer messages to
- record the time that the reported event occurred, in seconds since
- January 1, 1900 00:00 UTC.
-
-
+ The Event-Timestamp (AVP Code 55) is of type Time and MAY be included
+ in an Accounting-Request and Accounting-Answer messages to record the
+ time that the reported event occurred, in seconds since January 1,
+ 1900 00:00 UTC.
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 126]
+Fajardo, et al. Standards Track [Page 122]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
9. Accounting
This accounting protocol is based on a server directed model with
capabilities for real-time delivery of accounting information.
- Several fault resilience methods [RFC2975] have been built in to the
+ Several fault resilience methods [RFC2975] have been built into the
protocol in order minimize loss of accounting data in various fault
situations and under different assumptions about the capabilities of
the used devices.
@@ -7075,15 +6854,16 @@ Internet-Draft Diameter Base Protocol January 2011
timeliness requirements.
As discussed in [RFC2975], real-time transfer of accounting records
- is a requirement, such as the need to perform credit limit checks and
+ is a requirement, such as the need to perform credit-limit checks and
fraud detection. Note that batch accounting is not a requirement,
and is therefore not supported by Diameter. Should batched
accounting be required in the future, a new Diameter application will
need to be created, or it could be handled using another protocol.
- Note, however, that even if at the Diameter layer accounting requests
- are processed one by one, transport protocols used under Diameter
- typically batch several requests in the same packet under heavy
- traffic conditions. This may be sufficient for many applications.
+ Note, however, that even if at the Diameter layer, accounting
+ requests are processed one by one; transport protocols used under
+ Diameter typically batch several requests in the same packet under
+ heavy traffic conditions. This may be sufficient for many
+ applications.
The authorization server (chain) directs the selection of proper
transfer strategy, based on its knowledge of the user and
@@ -7097,7 +6877,7 @@ Internet-Draft Diameter Base Protocol January 2011
records from the Diameter client is delayed or unsuccessful.
The Diameter accounting server MAY override the interim interval or
- the realtime requirements by including the Acct-Interim-Interval or
+ the real-time requirements by including the Acct-Interim-Interval or
Accounting-Realtime-Required AVP in the Accounting-Answer message.
When one of these AVPs is present, the latest value received SHOULD
be used in further accounting activities for the same session.
@@ -7107,16 +6887,15 @@ Internet-Draft Diameter Base Protocol January 2011
-
-Fajardo, et al. Expires July 24, 2011 [Page 127]
+Fajardo, et al. Standards Track [Page 123]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
9.2. Protocol Messages
A Diameter node that receives a successful authentication and/or
- authorization messages from the Diameter server SHOULD collect
+ authorization message from the Diameter server SHOULD collect
accounting information for the session. The Accounting-Request
message is used to transmit the accounting information to the
Diameter server, which MUST reply with the Accounting-Answer message
@@ -7129,12 +6908,12 @@ Internet-Draft Diameter Base Protocol January 2011
9.3. Accounting Application Extension and Requirements
- Each Diameter application (e.g., NASREQ, MobileIP), SHOULD define
- their Service-Specific AVPs that MUST be present in the Accounting-
- Request message in a section entitled "Accounting AVPs". The
- application MUST assume that the AVPs described in this document will
- be present in all Accounting messages, so only their respective
- service-specific AVPs need to be defined in that section.
+ Each Diameter application (e.g., NASREQ, Mobile IP) SHOULD define its
+ service-specific AVPs that MUST be present in the Accounting-Request
+ message in a section titled "Accounting AVPs". The application MUST
+ assume that the AVPs described in this document will be present in
+ all Accounting messages, so only their respective service-specific
+ AVPs need to be defined in that section.
Applications have the option of using one or both of the following
accounting application extension models:
@@ -7150,40 +6929,37 @@ Internet-Draft Diameter Base Protocol January 2011
advertise the Diameter base accounting Application Id during
capabilities exchange.
-
Coupled Accounting Service
- The accounting messages will carry the Application Id of the
+ The accounting message will carry the Application Id of the
application that is using it. The application itself will process
the received accounting records or forward them to an accounting
server. There is no accounting application advertisement required
- during capabilities exchange and the accounting messages will be
- routed the same as any of the other application messages.
-
+ during capabilities exchange, and the accounting messages will be
+ routed the same way as any of the other application messages.
+ In cases where an application does not define its own accounting
+ service, it is preferred that the split accounting model be used.
-Fajardo, et al. Expires July 24, 2011 [Page 128]
+Fajardo, et al. Standards Track [Page 124]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- In cases where an application does not define its own accounting
- service, it is preferred that the split accounting model be used.
-
9.4. Fault Resilience
- Diameter Base protocol mechanisms are used to overcome small message
- loss and network faults of temporary nature.
+ Diameter base protocol mechanisms are used to overcome small message
+ loss and network faults of a temporary nature.
Diameter peers acting as clients MUST implement the use of failover
to guard against server failures and certain network failures.
Diameter peers acting as agents or related off-line processing
systems MUST detect duplicate accounting records caused by the
- sending of same record to several servers and duplication of messages
- in transit. This detection MUST be based on the inspection of the
- Session-Id and Accounting-Record-Number AVP pairs. Appendix C
+ sending of the same record to several servers and duplication of
+ messages in transit. This detection MUST be based on the inspection
+ of the Session-Id and Accounting-Record-Number AVP pairs. Appendix C
discusses duplicate detection needs and implementation issues.
Diameter clients MAY have non-volatile memory for the safe storage of
@@ -7191,23 +6967,23 @@ Internet-Draft Diameter Base Protocol January 2011
partitions, and server failures. If such memory is available, the
client SHOULD store new accounting records there as soon as the
records are created and until a positive acknowledgement of their
- reception from the Diameter Server has been received. Upon a reboot,
- the client MUST starting sending the records in the non-volatile
- memory to the accounting server with appropriate modifications in
+ reception from the Diameter server has been received. Upon a reboot,
+ the client MUST start sending the records in the non-volatile memory
+ to the accounting server with the appropriate modifications in
termination cause, session length, and other relevant information in
the records.
A further application of this protocol may include AVPs to control
- how many accounting records may at most be stored in the Diameter
- client without committing them to the non-volatile memory or
+ the maximum number of accounting records that may be stored in the
+ Diameter client without committing them to the non-volatile memory or
transferring them to the Diameter server.
The client SHOULD NOT remove the accounting data from any of its
memory areas before the correct Accounting-Answer has been received.
- The client MAY remove oldest, undelivered or yet unacknowledged
- accounting data if it runs out of resources such as memory. It is an
- implementation dependent matter for the client to accept new sessions
- under this condition.
+ The client MAY remove the oldest, undelivered, or as yet
+ unacknowledged accounting data if it runs out of resources such as
+ memory. It is an implementation-dependent matter for the client to
+ accept new sessions under this condition.
9.5. Accounting Records
@@ -7217,15 +6993,17 @@ Internet-Draft Diameter Base Protocol January 2011
Different types of accounting records are sent depending on the
actual type of accounted service and the authorization server's
+ directions for interim accounting. If the accounted service is a
+
+
-Fajardo, et al. Expires July 24, 2011 [Page 129]
+Fajardo, et al. Standards Track [Page 125]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- directions for interim accounting. If the accounted service is a
one-time event, meaning that the start and stop of the event are
simultaneous, then the Accounting-Record-Type AVP MUST be present and
set to the value EVENT_RECORD.
@@ -7251,11 +7029,11 @@ Internet-Draft Diameter Base Protocol January 2011
session.
A particular value of Accounting-Sub-Session-Id MUST appear only in
- one sequence of accounting records from a DIAMETER client, except for
+ one sequence of accounting records from a Diameter client, except for
the purposes of retransmission. The one sequence that is sent MUST
be either one record with Accounting-Record-Type AVP set to the value
- EVENT_RECORD, or several records starting with one having the value
- START_RECORD, followed by zero or more INTERIM_RECORD and a single
+ EVENT_RECORD or several records starting with one having the value
+ START_RECORD, followed by zero or more INTERIM_RECORDs and a single
STOP_RECORD. A particular Diameter application specification MUST
define the type of sequences that MUST be used.
@@ -7265,20 +7043,21 @@ Internet-Draft Diameter Base Protocol January 2011
accounting records with a specific application session by using the
Session-Id of the particular application session in the accounting
messages. Accounting messages MAY also use a different Session-Id
- from that of the application sessions in which case other session
+ from that of the application sessions, in which case, other session-
related information is needed to perform correlation.
In cases where an application requires multiple accounting sub-
- session, an Accounting-Sub-Session-Id AVP is used to differentiate
+ sessions, an Accounting-Sub-Session-Id AVP is used to differentiate
each sub-session. The Session-Id would remain constant for all sub-
- sessions and is be used to correlate all the sub-sessions to a
+ sessions and is used to correlate all the sub-sessions to a
particular application session. Note that receiving a STOP_RECORD
-Fajardo, et al. Expires July 24, 2011 [Page 130]
+
+Fajardo, et al. Standards Track [Page 126]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
with no Accounting-Sub-Session-Id AVP when sub-sessions were
@@ -7290,36 +7069,36 @@ Internet-Draft Diameter Base Protocol January 2011
record may span multiple different Diameter applications and sessions
used by the same user at a given time. In such cases, the Acct-
Multi-Session-Id AVP is used. The Acct-Multi-Session-Id AVP SHOULD
- be signaled by the server to the access device (typically during
+ be signaled by the server to the access device (typically, during
authorization) when it determines that a request belongs to an
existing session. The access device MUST then include the Acct-
Multi-Session-Id AVP in all subsequent accounting messages.
The Acct-Multi-Session-Id AVP MAY include the value of the original
- Session-Id. It's contents are implementation specific, but MUST be
- globally unique across other Acct-Multi-Session-Id, and MUST NOT
+ Session-Id. Its contents are implementation specific, but the MUST
+ be globally unique across other Acct-Multi-Session-Ids and MUST NOT
change during the life of a session.
A Diameter application document MUST define the exact concept of a
- session that is being accounted, and MAY define the concept of a
+ session that is being accounted, and it MAY define the concept of a
multi-session. For instance, the NASREQ DIAMETER application treats
- a single PPP connection to a Network Access Server as one session,
- and a set of Multilink PPP sessions as one multi-session.
+ a single PPP connection to a Network Access Server as one session and
+ a set of Multilink PPP sessions as one multi-session.
-9.7. Accounting Command-Codes
+9.7. Accounting Command Codes
- This section defines Command-Code values that MUST be supported by
- all Diameter implementations that provide Accounting services.
+ This section defines Command Code values that MUST be supported by
+ all Diameter implementations that provide accounting services.
9.7.1. Accounting-Request
- The Accounting-Request (ACR) command, indicated by the Command-Code
+ The Accounting-Request (ACR) command, indicated by the Command Code
field set to 271 and the Command Flags' 'R' bit set, is sent by a
Diameter node, acting as a client, in order to exchange accounting
information with a peer.
- The AVP listed below SHOULD include service-specific accounting AVPs,
- as described in Section 9.3.
+ In addition to the AVPs listed below, Accounting-Request messages
+ SHOULD include service-specific accounting AVPs.
@@ -7332,9 +7111,9 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 131]
+Fajardo, et al. Standards Track [Page 127]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Message Format
@@ -7363,16 +7142,16 @@ Internet-Draft Diameter Base Protocol January 2011
9.7.2. Accounting-Answer
- The Accounting-Answer (ACA) command, indicated by the Command-Code
+ The Accounting-Answer (ACA) command, indicated by the Command Code
field set to 271 and the Command Flags' 'R' bit cleared, is used to
acknowledge an Accounting-Request command. The Accounting-Answer
command contains the same Session-Id as the corresponding request.
- Only the target Diameter Server, known as the home Diameter Server,
+ Only the target Diameter server, known as the home Diameter server,
SHOULD respond with the Accounting-Answer command.
- The AVP listed below SHOULD include service-specific accounting AVPs,
- as described in Section 9.3.
+ In addition to the AVPs listed below, Accounting-Answer messages
+ SHOULD include service-specific accounting AVPs.
@@ -7388,9 +7167,9 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 132]
+Fajardo, et al. Standards Track [Page 128]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Message Format
@@ -7429,13 +7208,12 @@ Internet-Draft Diameter Base Protocol January 2011
and contains the type of accounting record being sent. The following
values are currently defined for the Accounting-Record-Type AVP:
-
EVENT_RECORD 1
An Accounting Event Record is used to indicate that a one-time
event has occurred (meaning that the start and end of the event
are simultaneous). This record contains all information relevant
- to the service, and is the only record of the service.
+ to the service, and it is the only record of the service.
@@ -7444,20 +7222,20 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 133]
+
+Fajardo, et al. Standards Track [Page 129]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
START_RECORD 2
- An Accounting Start, Interim, and Stop Records are used to
- indicate that a service of a measurable length has been given. An
- Accounting Start Record is used to initiate an accounting session,
+ Accounting Start, Interim, and Stop Records are used to indicate
+ that a service of a measurable length has been given. An
+ Accounting Start Record is used to initiate an accounting session
and contains accounting information that is relevant to the
initiation of the session.
-
INTERIM_RECORD 3
An Interim Accounting Record contains cumulative accounting
@@ -7468,14 +7246,12 @@ Internet-Draft Diameter Base Protocol January 2011
applications. The selection of whether to use INTERIM_RECORD
records is done by the Acct-Interim-Interval AVP.
-
STOP_RECORD 4
An Accounting Stop Record is sent to terminate an accounting
session and contains cumulative accounting information relevant to
the existing session.
-
9.8.2. Acct-Interim-Interval AVP
The Acct-Interim-Interval AVP (AVP Code 85) is of type Unsigned32 and
@@ -7483,31 +7259,31 @@ Internet-Draft Diameter Base Protocol January 2011
client. The client uses information in this AVP to decide how and
when to produce accounting records. With different values in this
AVP, service sessions can result in one, two, or two+N accounting
- records, based on the needs of the home-organization. The following
+ records, based on the needs of the home organization. The following
accounting record production behavior is directed by the inclusion of
this AVP:
-
1. The omission of the Acct-Interim-Interval AVP or its inclusion
with Value field set to 0 means that EVENT_RECORD, START_RECORD,
and STOP_RECORD are produced, as appropriate for the service.
-
2. The inclusion of the AVP with Value field set to a non-zero value
means that INTERIM_RECORD records MUST be produced between the
START_RECORD and STOP_RECORD records. The Value field of this
AVP is the nominal interval between these records in seconds.
+ The Diameter node that originates the accounting information,
+ known as the client, MUST produce the first INTERIM_RECORD record
+ roughly at the time when this nominal interval has elapsed from
+
+
-Fajardo, et al. Expires July 24, 2011 [Page 134]
+Fajardo, et al. Standards Track [Page 130]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- The Diameter node that originates the accounting information,
- known as the client, MUST produce the first INTERIM_RECORD record
- roughly at the time when this nominal interval has elapsed from
the START_RECORD, the next one again as the interval has elapsed
once more, and so on until the session ends and a STOP_RECORD
record is produced.
@@ -7522,10 +7298,10 @@ Internet-Draft Diameter Base Protocol January 2011
The Accounting-Record-Number AVP (AVP Code 485) is of type Unsigned32
and identifies this record within one session. As Session-Id AVPs
are globally unique, the combination of Session-Id and Accounting-
- Record-Number AVPs is also globally unique, and can be used in
+ Record-Number AVPs is also globally unique and can be used in
matching accounting records with confirmations. An easy way to
produce unique numbers is to set the value to 0 for records of type
- EVENT_RECORD and START_RECORD, and set the value to 1 for the first
+ EVENT_RECORD and START_RECORD and set the value to 1 for the first
INTERIM_RECORD, 2 for the second, and so on until the value for
STOP_RECORD is one more than for the last INTERIM_RECORD.
@@ -7539,10 +7315,10 @@ Internet-Draft Diameter Base Protocol January 2011
The Acct-Multi-Session-Id AVP (AVP Code 50) is of type UTF8String,
following the format specified in Section 8.8. The Acct-Multi-
- Session-Id AVP is used to link together multiple related accounting
- sessions, where each session would have a unique Session-Id, but the
- same Acct-Multi-Session-Id AVP. This AVP MAY be returned by the
- Diameter server in an authorization answer, and MUST be used in all
+ Session-Id AVP is used to link multiple related accounting sessions,
+ where each session would have a unique Session-Id but the same Acct-
+ Multi-Session-Id AVP. This AVP MAY be returned by the Diameter
+ server in an authorization answer, and it MUST be used in all
accounting messages for the given session.
9.8.6. Accounting-Sub-Session-Id AVP
@@ -7553,18 +7329,17 @@ Internet-Draft Diameter Base Protocol January 2011
session, and the value of this AVP MUST be monotonically increased by
one for all new sub-sessions. The absence of this AVP implies no
sub-sessions are in use, with the exception of an Accounting-Request
+ whose Accounting-Record-Type is set to STOP_RECORD. A STOP_RECORD
+ message with no Accounting-Sub-Session-Id AVP present will signal the
+ termination of all sub-sessions for a given Session-Id.
-Fajardo, et al. Expires July 24, 2011 [Page 135]
+Fajardo, et al. Standards Track [Page 131]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
- whose Accounting-Record-Type is set to STOP_RECORD. A STOP_RECORD
- message with no Accounting-Sub-Session-Id AVP present will signal the
- termination of all sub-sessions for a given Session-Id.
-
9.8.7. Accounting-Realtime-Required AVP
The Accounting-Realtime-Required AVP (AVP Code 483) is of type
@@ -7574,7 +7349,6 @@ Internet-Draft Diameter Base Protocol January 2011
if the sending of accounting records to the accounting server has
been temporarily prevented due to, for instance, a network problem.
-
DELIVER_AND_GRANT 1
The AVP with Value field set to DELIVER_AND_GRANT means that the
@@ -7584,7 +7358,6 @@ Internet-Draft Diameter Base Protocol January 2011
the accounting record stream to a backup server is not a reason to
discontinue the service to the user.
-
GRANT_AND_STORE 2
The AVP with Value field set to GRANT_AND_STORE means that service
@@ -7594,60 +7367,51 @@ Internet-Draft Diameter Base Protocol January 2011
This is the default behavior if the AVP isn't included in the
reply from the authorization server.
-
GRANT_AND_LOSE 3
The AVP with Value field set to GRANT_AND_LOSE means that service
SHOULD be granted even if the records cannot be delivered or
stored.
+10. AVP Occurrence Tables
+ The following tables present the AVPs defined in this document and
+ specify in which Diameter messages they MAY or MAY NOT be present.
+ AVPs that occur only inside a Grouped AVP are not shown in these
+ tables.
+ The tables use the following symbols:
+ 0 The AVP MUST NOT be present in the message.
+ 0+ Zero or more instances of the AVP MAY be present in the
+ message.
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 136]
+Fajardo, et al. Standards Track [Page 132]
-Internet-Draft Diameter Base Protocol January 2011
-
-
-10. AVP Occurrence Table
-
- The following tables presents the AVPs defined in this document, and
- specifies in which Diameter messages they MAY be present or not.
- AVPs that occur only inside a Grouped AVP are not shown in this
- table.
+RFC 6733 Diameter Base Protocol October 2012
- The table uses the following symbols:
+ 0-1 Zero or one instance of the AVP MAY be present in the message.
+ It is considered an error if there are more than one instance
+ of the AVP.
- 0 The AVP MUST NOT be present in the message.
+ 1 One instance of the AVP MUST be present in the message.
- 0+ Zero or more instances of the AVP MAY be present in the
- message.
-
- 0-1 Zero or one instance of the AVP MAY be present in the message.
- It is considered an error if there are more than one instance of
- the AVP.
-
- 1 One instance of the AVP MUST be present in the message.
-
- 1+ At least one instance of the AVP MUST be present in the
- message.
+ 1+ At least one instance of the AVP MUST be present in the
+ message.
10.1. Base Protocol Command AVP Table
- The table in this section is limited to the non-accounting Command
+ The table in this section is limited to the non-Accounting Command
Codes defined in this specification.
+-----------------------------------------------+
- | Command-Code |
+ | Command Code |
+---+---+---+---+---+---+---+---+---+---+---+---+
Attribute Name |CER|CEA|DPR|DPA|DWR|DWA|RAR|RAA|ASR|ASA|STR|STA|
--------------------+---+---+---+---+---+---+---+---+---+---+---+---+
@@ -7665,22 +7429,29 @@ Internet-Draft Diameter Base Protocol January 2011
Class |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |0+ |0+ |
Destination-Host |0 |0 |0 |0 |0 |0 |1 |0 |1 |0 |0-1|0 |
Destination-Realm |0 |0 |0 |0 |0 |0 |1 |0 |1 |0 |1 |0 |
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 137]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Disconnect-Cause |0 |0 |1 |0 |0 |0 |0 |0 |0 |0 |0 |0 |
Error-Message |0 |0-1|0 |0-1|0 |0-1|0 |0-1|0 |0-1|0 |0-1|
Error-Reporting-Host|0 |0 |0 |0 |0 |0 |0 |0-1|0 |0-1|0 |0-1|
- Failed-AVP |0 |0+ |0 |0+ |0 |0+ |0 |0+ |0 |0+ |0 |0+ |
+ Failed-AVP |0 |0-1|0 |0-1|0 |0-1|0 |0-1|0 |0-1|0 |0-1|
Firmware-Revision |0-1|0-1|0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |
Host-IP-Address |1+ |1+ |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |
Inband-Security-Id |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |
Multi-Round-Time-Out|0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |0 |
+
+
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 133]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
Origin-Host |1 |1 |1 |1 |1 |1 |1 |1 |1 |1 |1 |1 |
Origin-Realm |1 |1 |1 |1 |1 |1 |1 |1 |1 |1 |1 |1 |
Origin-State-Id |0-1|0-1|0 |0 |0-1|0-1|0-1|0-1|0-1|0-1|0-1|0-1|
@@ -7724,9 +7495,17 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 138]
+
+
+
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 134]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+-----------+
@@ -7749,6 +7528,7 @@ Internet-Draft Diameter Base Protocol January 2011
Destination-Realm | 1 | 0 |
Error-Reporting-Host | 0 | 0+ |
Event-Timestamp | 0-1 | 0-1 |
+ Failed-AVP | 0 | 0-1 |
Origin-Host | 1 | 1 |
Origin-Realm | 1 | 1 |
Proxy-Info | 0+ | 0+ |
@@ -7760,144 +7540,220 @@ Internet-Draft Diameter Base Protocol January 2011
Vendor-Specific-Application-Id| 0-1 | 0-1 |
------------------------------+-----+-----+
+11. IANA Considerations
+ This section provides guidance to the Internet Assigned Numbers
+ Authority (IANA) regarding registration of values related to the
+ Diameter protocol, in accordance with [RFC5226]. Existing IANA
+ registries and assignments put in place by RFC 3588 remain the same
+ unless explicitly updated or deprecated in this section.
+11.1. AVP Header
+ As defined in Section 4, the AVP header contains three fields that
+ require IANA namespace management: the AVP Code, Vendor-ID, and Flags
+ fields.
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 139]
+Fajardo, et al. Standards Track [Page 135]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
-11. IANA Considerations
+11.1.1. AVP Codes
- This section provides guidance to the Internet Assigned Numbers
- Authority (IANA) regarding registration of values related to the
- Diameter protocol, in accordance with BCP 26 [RFC5226]. The policies
- and procedures for the IANA put in place by [RFC3588] applies here.
- The criteria used by the IANA for assignment of numbers within this
- namespace remains the same unless otherwise stated in this section.
- Existing assignments remains the same unless explicitly updated or
- deprecated in this secion.
+ There are multiple namespaces. Vendors can have their own AVP Codes
+ namespace that will be identified by their Vendor-ID (also known as
+ Enterprise-Number), and they control the assignments of their vendor-
+ specific AVP Codes within their own namespace. The absence of a
+ Vendor-ID or a Vendor-ID value of zero (0) identifies the IETF AVP
+ Codes namespace, which is under IANA control. The AVP Codes and
+ sometimes possible values in an AVP are controlled and maintained by
+ IANA. AVP Code 0 is not used. AVP Codes 1-255 are managed
+ separately as RADIUS Attribute Types. Where a Vendor-Specific AVP is
+ implemented by more than one vendor, allocation of global AVPs should
+ be encouraged instead.
+
+ AVPs may be allocated following Expert Review (by a Designated
+ Expert) with Specification Required [RFC5226]. A block allocation
+ (release of more than three AVPs at a time for a given purpose)
+ requires IETF Review [RFC5226].
-11.1. Changes to AVP Header Allocation
+11.1.2. AVP Flags
- For AVP Headers, the only change is the AVP code block allocations.
- Block allocation (release of more than 3 at a time for a given
- purpose) now only require IETF Review as opposed to an IETF
- Consensus.
+ Section 4.1 describes the existing AVP Flags. The remaining bits can
+ only be assigned via a Standards Action [RFC5226].
11.2. Diameter Header
- For the Diameter Header, the command code namespace allocation has
+11.2.1. Command Codes
+
+ For the Diameter header, the Command Code namespace allocation has
changed. The new allocation rules are as follows:
- The command code values 256 - 8,388,607 (0x100 to 0x7fffff) are
+ The Command Code values 256 - 8,388,607 (0x100 to 0x7fffff) are
for permanent, standard commands, allocated by IETF Review
[RFC5226].
The values 8,388,608 - 16,777,213 (0x800000 - 0xfffffd) are
- reserved for vendor-specific command codes, to be allocated on a
+ reserved for vendor-specific Command Codes, to be allocated on a
First Come, First Served basis by IANA [RFC5226]. The request to
IANA for a Vendor-Specific Command Code SHOULD include a reference
- to a publicly available specification which documents the command
+ to a publicly available specification that documents the command
in sufficient detail to aid in interoperability between
independent implementations. If the specification cannot be made
- publicly available, the request for a vendor-specific command code
+ publicly available, the request for a vendor-specific Command Code
MUST include the contact information of persons and/or entities
responsible for authoring and maintaining the command.
+
+
+
+
+
+Fajardo, et al. Standards Track [Page 136]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ The values 16,777,214 and 16,777,215 (hexadecimal values 0xfffffe
+ - 0xffffff) are reserved for experimental commands. As these
+ codes are only for experimental and testing purposes, no guarantee
+ is made for interoperability between Diameter peers using
+ experimental commands.
+
+11.2.2. Command Flags
+
+ Section 3 describes the existing Command Flags field. The remaining
+ bits can only be assigned via a Standards Action [RFC5226].
+
11.3. AVP Values
For AVP values, the Experimental-Result-Code AVP value allocation has
- been added. The new rule is as follows:
+ been added; see Section 11.3.1. The old AVP value allocation rule,
+ IETF Consensus, has been updated to IETF Review as per [RFC5226], and
+ affected AVPs are listed as reminders.
11.3.1. Experimental-Result-Code AVP
Values for this AVP are purely local to the indicated vendor, and no
IANA registry is maintained for them.
+11.3.2. Result-Code AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
+11.3.3. Accounting-Record-Type AVP Values
-Fajardo, et al. Expires July 24, 2011 [Page 140]
-
-Internet-Draft Diameter Base Protocol January 2011
+ New values are available for assignment via IETF Review [RFC5226].
+
+11.3.4. Termination-Cause AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
-11.4. Diameter TCP, SCTP, TLS/TCP and DTLS/SCTP Port Numbers
+11.3.5. Redirect-Host-Usage AVP Values
- Updated port number assignments are described in this section. The
- IANA has assigned port number 3868 for TCP and SCTP. The port number
- [TBD] has been assigned for TLS/TCP and DTLS/SCTP.
+ New values are available for assignment via IETF Review [RFC5226].
-11.5. S-NAPTR Parameters
+11.3.6. Session-Server-Failover AVP Values
- This document registers a new S-NAPTR Application Service Tag value
- of "aaa".
+ New values are available for assignment via IETF Review [RFC5226].
- This document also registers the following S-NAPTR Application
- Protocol Tags:
+11.3.7. Session-Binding AVP Values
- Tag | Protocol
- -------------------|---------
- diameter.tcp | TCP
- diameter.sctp | SCTP
- diameter.tls.tcp | TLS/TCP
- diameter.dtls.sctp | DTLS/SCTP
+ New values are available for assignment via IETF Review [RFC5226].
+Fajardo, et al. Standards Track [Page 137]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+11.3.8. Disconnect-Cause AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
+11.3.9. Auth-Request-Type AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
+11.3.10. Auth-Session-State AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
+11.3.11. Re-Auth-Request-Type AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
+11.3.12. Accounting-Realtime-Required AVP Values
+ New values are available for assignment via IETF Review [RFC5226].
+11.3.13. Inband-Security-Id AVP (code 299)
+ The use of this AVP has been deprecated.
+11.4. _diameters Service Name and Port Number Registration
+ IANA has registered the "_diameters" service name and assigned port
+ numbers for TLS/TCP and DTLS/SCTP according to the guidelines given
+ in [RFC6335].
+ Service Name: _diameters
+ Transport Protocols: TCP, SCTP
+ Assignee: IESG <[email protected]>
+ Contact: IETF Chair <[email protected]>
+ Description: Diameter over TLS/TCP and DTLS/SCTP
+ Reference: RFC 6733
+ Port Number: 5868, from the User Range
-Fajardo, et al. Expires July 24, 2011 [Page 141]
+
+
+Fajardo, et al. Standards Track [Page 138]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+
+11.5. SCTP Payload Protocol Identifiers
+
+ Two SCTP payload protocol identifiers have been registered in the
+ SCTP Payload Protocol Identifiers registry:
+
+
+ Value | SCTP Payload Protocol Identifier
+ -------|-----------------------------------
+ 46 | Diameter in a SCTP DATA chunk
+ 47 | Diameter in a DTLS/SCTP DATA chunk
+
+11.6. S-NAPTR Parameters
-12. Diameter protocol related configurable parameters
+ The following tag has been registered in the S-NAPTR Application
+ Protocol Tags registry:
+
+ Tag | Protocol
+ -------------------|---------
+ diameter.dtls.sctp | DTLS/SCTP
+
+12. Diameter Protocol-Related Configurable Parameters
This section contains the configurable parameters that are found
throughout this document:
@@ -7915,8 +7771,8 @@ Internet-Draft Diameter Base Protocol January 2011
A Diameter proxy server routes messages based on the realm portion
of a Network Access Identifier (NAI). The server MUST have a
table of Realm Names, and the address of the peer to which the
- message must be forwarded to. The routing table MAY also include
- a "default route", which is typically used for all messages that
+ message must be forwarded. The routing table MAY also include a
+ "default route", which is typically used for all messages that
cannot be locally processed.
Tc timer
@@ -7927,30 +7783,9 @@ Internet-Draft Diameter Base Protocol January 2011
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 142]
+Fajardo, et al. Standards Track [Page 139]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
13. Security Considerations
@@ -7959,34 +7794,34 @@ Internet-Draft Diameter Base Protocol January 2011
[RFC5246] or DTLS/SCTP [RFC6083]. Additional security mechanisms
such as IPsec [RFC4301] MAY also be deployed to secure connections
between peers. However, all Diameter base protocol implementations
- MUST support the use of TLS/TCP and DTLS/SCTP and the Diameter
- protocol MUST NOT be used without any security mechanism.
+ MUST support the use of TLS/TCP and DTLS/SCTP, and the Diameter
+ protocol MUST NOT be used without one of TLS, DTLS, or IPsec.
If a Diameter connection is to be protected via TLS/TCP and DTLS/SCTP
or IPsec, then TLS/TCP and DTLS/SCTP or IPsec/IKE SHOULD begin prior
to any Diameter message exchange. All security parameters for TLS/
TCP and DTLS/SCTP or IPsec are configured independent of the Diameter
- protocol. All Diameter message will be sent through the TLS/TCP and
+ protocol. All Diameter messages will be sent through the TLS/TCP and
DTLS/SCTP or IPsec connection after a successful setup.
For TLS/TCP and DTLS/SCTP connections to be established in the open
state, the CER/CEA exchange MUST include an Inband-Security-ID AVP
with a value of TLS/TCP and DTLS/SCTP. The TLS/TCP and DTLS/SCTP
- handshake will begin when both ends successfully reached the open
+ handshake will begin when both ends successfully reach the open
state, after completion of the CER/CEA exchange. If the TLS/TCP and
DTLS/SCTP handshake is successful, all further messages will be sent
- via TLS/TCP and DTLS/SCTP. If the handshake fails, both ends move to
- the closed state. See Sections 13.1 for more details.
+ via TLS/TCP and DTLS/SCTP. If the handshake fails, both ends MUST
+ move to the closed state. See Section 13.1 for more details.
13.1. TLS/TCP and DTLS/SCTP Usage
Diameter nodes using TLS/TCP and DTLS/SCTP for security MUST mutually
authenticate as part of TLS/TCP and DTLS/SCTP session establishment.
In order to ensure mutual authentication, the Diameter node acting as
- TLS/TCP and DTLS/SCTP server MUST request a certificate from the
+ the TLS/TCP and DTLS/SCTP server MUST request a certificate from the
Diameter node acting as TLS/TCP and DTLS/SCTP client, and the
- Diameter node acting as TLS/TCP and DTLS/SCTP client MUST be prepared
- to supply a certificate on request.
+ Diameter node acting as the TLS/TCP and DTLS/SCTP client MUST be
+ prepared to supply a certificate on request.
Diameter nodes MUST be able to negotiate the following TLS/TCP and
DTLS/SCTP cipher suites:
@@ -8000,16 +7835,24 @@ Internet-Draft Diameter Base Protocol January 2011
TLS_RSA_WITH_AES_128_CBC_SHA
- Diameter nodes MAY negotiate other TLS/TCP and DTLS/SCTP cipher
-Fajardo, et al. Expires July 24, 2011 [Page 143]
+
+Fajardo, et al. Standards Track [Page 140]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
+
+ Note that it is quite possible that support for the
+ TLS_RSA_WITH_AES_128_CBC_SHA cipher suite will be REQUIRED at some
+ future date. Diameter nodes MAY negotiate other TLS/TCP and DTLS/
+ SCTP cipher suites.
- suites.
+ If public key certificates are used for Diameter security (for
+ example, with TLS), the value of the expiration times in the routing
+ and peer tables MUST NOT be greater than the expiry time in the
+ relevant certificates.
13.2. Peer-to-Peer Considerations
@@ -8027,67 +7870,105 @@ Internet-Draft Diameter Base Protocol January 2011
peers may not be known beforehand and therefore peer discovery may be
required.
+13.3. AVP Considerations
+ Diameter AVPs often contain security-sensitive data; for example,
+ user passwords and location data, network addresses and cryptographic
+ keys. The following AVPs defined in this document are considered to
+ be security-sensitive:
+ o Acct-Interim-Interval
+ o Accounting-Realtime-Required
+ o Acct-Multi-Session-Id
+ o Accounting-Record-Number
+ o Accounting-Record-Type
+ o Accounting-Session-Id
+ o Accounting-Sub-Session-Id
+ o Class
+Fajardo, et al. Standards Track [Page 141]
+
+RFC 6733 Diameter Base Protocol October 2012
+ o Session-Id
+ o Session-Binding
+ o Session-Server-Failover
+ o User-Name
+ Diameter messages containing these or any other AVPs considered to be
+ security-sensitive MUST only be sent protected via mutually
+ authenticated TLS or IPsec. In addition, those messages MUST NOT be
+ sent via intermediate nodes unless there is end-to-end security
+ between the originator and recipient or the originator has locally
+ trusted configuration that indicates that end-to-end security is not
+ needed. For example, end-to-end security may not be required in the
+ case where an intermediary node is known to be operated as part of
+ the same administrative domain as the endpoints so that an ability to
+ successfully compromise the intermediary would imply a high
+ probability of being able to compromise the endpoints as well. Note
+ that no end-to-end security mechanism is specified in this document.
+14. References
+14.1. Normative References
+ [FLOATPOINT]
+ Institute of Electrical and Electronics Engineers, "IEEE
+ Standard for Binary Floating-Point Arithmetic, ANSI/IEEE
+ Standard 754-1985", August 1985.
+ [IANAADFAM]
+ IANA, "Address Family Numbers",
+ <http://www.iana.org/assignments/address-family-numbers>.
+ [RFC0791] Postel, J., "Internet Protocol", STD 5, RFC 791,
+ September 1981.
+ [RFC0793] Postel, J., "Transmission Control Protocol", STD 7,
+ RFC 793, September 1981.
+ [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
+ Requirement Levels", BCP 14, RFC 2119, March 1997.
+ [RFC3492] Costello, A., "Punycode: A Bootstring encoding of Unicode
+ for Internationalized Domain Names in Applications
+ (IDNA)", RFC 3492, March 2003.
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 144]
+Fajardo, et al. Standards Track [Page 142]
-Internet-Draft Diameter Base Protocol January 2011
-
-
-14. References
-
-14.1. Normative References
-
- [FLOATPOINT]
- Institute of Electrical and Electronics Engineers, "IEEE
- Standard for Binary Floating-Point Arithmetic, ANSI/IEEE
- Standard 754-1985", August 1985.
+RFC 6733 Diameter Base Protocol October 2012
- [IANAADFAM]
- IANA,, "Address Family Numbers",
- http://www.iana.org/assignments/address-family-numbers.
- [RADTYPE] IANA,, "RADIUS Types",
- http://www.iana.org/assignments/radius-types.
+ [RFC3539] Aboba, B. and J. Wood, "Authentication, Authorization and
+ Accounting (AAA) Transport Profile", RFC 3539, June 2003.
- [RFC791] Postel, J., "Internet Protocol", RFC 791, September 1981.
+ [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
+ 10646", STD 63, RFC 3629, November 2003.
- [RFC793] Postel, J., "Transmission Control Protocol", RFC 793,
- January 1981.
+ [RFC3958] Daigle, L. and A. Newton, "Domain-Based Application
+ Service Location Using SRV RRs and the Dynamic Delegation
+ Discovery Service (DDDS)", RFC 3958, January 2005.
- [RFC3539] Aboba, B. and J. Wood, "Authentication, Authorization and
- Accounting (AAA) Transport Profile", RFC 3539, June 2003.
+ [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
+ Resource Identifier (URI): Generic Syntax", STD 66,
+ RFC 3986, January 2005.
[RFC4004] Calhoun, P., Johansson, T., Perkins, C., Hiller, T., and
P. McCann, "Diameter Mobile IPv4 Application", RFC 4004,
@@ -8101,51 +7982,44 @@ Internet-Draft Diameter Base Protocol January 2011
Loughney, "Diameter Credit-Control Application", RFC 4006,
August 2005.
- [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
- Specifications: ABNF", STD 68, RFC 5234, January 2008.
-
- [RFC3588] Calhoun, P., Loughney, J., Guttman, E., Zorn, G., and J.
- Arkko, "Diameter Base Protocol", RFC 3588, September 2003.
+ [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness
+ Requirements for Security", BCP 106, RFC 4086, June 2005.
- [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
- IANA Considerations Section in RFCs", BCP 26, RFC 5226,
- May 2008.
+ [RFC4282] Aboba, B., Beadles, M., Arkko, J., and P. Eronen, "The
+ Network Access Identifier", RFC 4282, December 2005.
[RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing
Architecture", RFC 4291, February 2006.
+ [RFC4960] Stewart, R., "Stream Control Transmission Protocol",
+ RFC 4960, September 2007.
+ [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
+ IANA Considerations Section in RFCs", BCP 26, RFC 5226,
+ May 2008.
-Fajardo, et al. Expires July 24, 2011 [Page 145]
-
-Internet-Draft Diameter Base Protocol January 2011
-
+ [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
+ Specifications: ABNF", STD 68, RFC 5234, January 2008.
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
- Requirement Levels", BCP 14, RFC 2119, March 1997.
+ [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
+ (TLS) Protocol Version 1.2", RFC 5246, August 2008.
- [RFC4282] Aboba, B., Beadles, M., Arkko, J., and P. Eronen, "The
- Network Access Identifier", RFC 4282, December 2005.
- [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness
- Requirements for Security", BCP 106, RFC 4086, June 2005.
- [RFC4960] Stewart, R., "Stream Control Transmission Protocol",
- RFC 4960, September 2007.
- [RFC3958] Daigle, L. and A. Newton, "Domain-Based Application
- Service Location Using SRV RRs and the Dynamic Delegation
- Discovery Service (DDDS)", RFC 3958, January 2005.
+Fajardo, et al. Standards Track [Page 143]
+
+RFC 6733 Diameter Base Protocol October 2012
- [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security
- (TLS) Protocol Version 1.2", RFC 5246, August 2008.
- [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
- Resource Identifier (URI): Generic Syntax", STD 66,
- RFC 3986, January 2005.
+ [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
+ Housley, R., and W. Polk, "Internet X.509 Public Key
+ Infrastructure Certificate and Certificate Revocation List
+ (CRL) Profile", RFC 5280, May 2008.
- [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
- 10646", STD 63, RFC 3629, November 2003.
+ [RFC5729] Korhonen, J., Jones, M., Morand, L., and T. Tsou,
+ "Clarifications on the Routing of Diameter Requests Based
+ on the Username and the Realm", RFC 5729, December 2009.
[RFC5890] Klensin, J., "Internationalized Domain Names for
Applications (IDNA): Definitions and Document Framework",
@@ -8154,103 +8028,120 @@ Internet-Draft Diameter Base Protocol January 2011
[RFC5891] Klensin, J., "Internationalized Domain Names in
Applications (IDNA): Protocol", RFC 5891, August 2010.
- [RFC3492] Costello, A., "Punycode: A Bootstring encoding of Unicode
- for Internationalized Domain Names in Applications
- (IDNA)", RFC 3492, March 2003.
-
- [RFC5729] Korhonen, J., Jones, M., Morand, L., and T. Tsou,
- "Clarifications on the Routing of Diameter Requests Based
- on the Username and the Realm", RFC 5729, December 2009.
-
- [RFC4347] Rescorla, E. and N. Modadugu, "Datagram Transport Layer
- Security", RFC 4347, April 2006.
-
[RFC6083] Tuexen, M., Seggelmann, R., and E. Rescorla, "Datagram
Transport Layer Security (DTLS) for Stream Control
Transmission Protocol (SCTP)", RFC 6083, January 2011.
+ [RFC6347] Rescorla, E. and N. Modadugu, "Datagram Transport Layer
+ Security Version 1.2", RFC 6347, January 2012.
+ [RFC6408] Jones, M., Korhonen, J., and L. Morand, "Diameter
+ Straightforward-Naming Authority Pointer (S-NAPTR) Usage",
+ RFC 6408, November 2011.
+14.2. Informative References
-Fajardo, et al. Expires July 24, 2011 [Page 146]
-
-Internet-Draft Diameter Base Protocol January 2011
+ [ENTERPRISE] IANA, "SMI Network Management Private Enterprise
+ Codes",
+ <http://www.iana.org/assignments/enterprise-numbers>.
+ [IANATCV] IANA, "Termination-Cause AVP Values (code 295)",
+ <http://www.iana.org/assignments/aaa-parameters/
+ aaa-parameters.xml#aaa-parameters-16>.
-14.2. Informational References
+ [RFC1492] Finseth, C., "An Access Control Protocol, Sometimes
+ Called TACACS", RFC 1492, July 1993.
- [RFC2989] Aboba, B., Calhoun, P., Glass, S., Hiller, T., McCann, P.,
- Shiino, H., Walsh, P., Zorn, G., Dommety, G., Perkins, C.,
- Patil, B., Mitton, D., Manning, S., Beadles, M., Chen, X.,
- Sivalingham, S., Hameed, A., Munson, M., Jacobs, S., Lim,
- B., Hirschman, B., Hsu, R., Koo, H., Lipford, M.,
- Campbell, E., Xu, Y., Baba, S., and E. Jaques, "Criteria
- for Evaluating AAA Protocols for Network Access",
- RFC 2989, November 2000.
+ [RFC1661] Simpson, W., "The Point-to-Point Protocol (PPP)",
+ STD 51, RFC 1661, July 1994.
- [RFC2975] Aboba, B., Arkko, J., and D. Harrington, "Introduction to
- Accounting Management", RFC 2975, October 2000.
+ [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC:
+ Keyed-Hashing for Message Authentication", RFC 2104,
+ February 1997.
- [RFC3232] Reynolds, J., "Assigned Numbers: RFC 1700 is Replaced by
- an On-line Database", RFC 3232, January 2002.
- [RFC5176] Chiba, M., Dommety, G., Eklund, M., Mitton, D., and B.
- Aboba, "Dynamic Authorization Extensions to Remote
- Authentication Dial In User Service (RADIUS)", RFC 5176,
- January 2008.
- [RFC1661] Simpson, W., "The Point-to-Point Protocol (PPP)", STD 51,
- RFC 1661, July 1994.
- [RFC2866] Rigney, C., "RADIUS Accounting", RFC 2866, June 2000.
- [RFC2869] Rigney, C., Willats, W., and P. Calhoun, "RADIUS
- Extensions", RFC 2869, June 2000.
+Fajardo, et al. Standards Track [Page 144]
+
+RFC 6733 Diameter Base Protocol October 2012
- [RFC2865] Rigney, C., Willens, S., Rubens, A., and W. Simpson,
- "Remote Authentication Dial In User Service (RADIUS)",
- RFC 2865, June 2000.
- [RFC3162] Aboba, B., Zorn, G., and D. Mitton, "RADIUS and IPv6",
- RFC 3162, August 2001.
+ [RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR
+ for specifying the location of services (DNS SRV)",
+ RFC 2782, February 2000.
- [RFC4301] Kent, S. and K. Seo, "Security Architecture for the
- Internet Protocol", RFC 4301, December 2005.
+ [RFC2865] Rigney, C., Willens, S., Rubens, A., and W. Simpson,
+ "Remote Authentication Dial In User Service (RADIUS)",
+ RFC 2865, June 2000.
- [RFC5905] Mills, D., Martin, J., Burbank, J., and W. Kasch, "Network
- Time Protocol Version 4: Protocol and Algorithms
- Specification", RFC 5905, June 2010.
+ [RFC2866] Rigney, C., "RADIUS Accounting", RFC 2866, June 2000.
- [RFC1492] Finseth, C., "An Access Control Protocol, Sometimes Called
- TACACS", RFC 1492, July 1993.
+ [RFC2869] Rigney, C., Willats, W., and P. Calhoun, "RADIUS
+ Extensions", RFC 2869, June 2000.
- [RFC4690] Klensin, J., Faltstrom, P., Karp, C., and IAB, "Review and
+ [RFC2881] Mitton, D. and M. Beadles, "Network Access Server
+ Requirements Next Generation (NASREQNG) NAS Model",
+ RFC 2881, July 2000.
+ [RFC2975] Aboba, B., Arkko, J., and D. Harrington, "Introduction
+ to Accounting Management", RFC 2975, October 2000.
+ [RFC2989] Aboba, B., Calhoun, P., Glass, S., Hiller, T., McCann,
+ P., Shiino, H., Walsh, P., Zorn, G., Dommety, G.,
+ Perkins, C., Patil, B., Mitton, D., Manning, S.,
+ Beadles, M., Chen, X., Sivalingham, S., Hameed, A.,
+ Munson, M., Jacobs, S., Lim, B., Hirschman, B., Hsu,
+ R., Koo, H., Lipford, M., Campbell, E., Xu, Y., Baba,
+ S., and E. Jaques, "Criteria for Evaluating AAA
+ Protocols for Network Access", RFC 2989, November 2000.
-Fajardo, et al. Expires July 24, 2011 [Page 147]
-
-Internet-Draft Diameter Base Protocol January 2011
+ [RFC3162] Aboba, B., Zorn, G., and D. Mitton, "RADIUS and IPv6",
+ RFC 3162, August 2001.
+ [RFC3748] Aboba, B., Blunk, L., Vollbrecht, J., Carlson, J., and
+ H. Levkowetz, "Extensible Authentication Protocol
+ (EAP)", RFC 3748, June 2004.
- Recommendations for Internationalized Domain Names
- (IDNs)", RFC 4690, September 2006.
+ [RFC4301] Kent, S. and K. Seo, "Security Architecture for the
+ Internet Protocol", RFC 4301, December 2005.
- [RFC5461] Gont, F., "TCP's Reaction to Soft Errors", RFC 5461,
- February 2009.
+ [RFC4690] Klensin, J., Faltstrom, P., Karp, C., and IAB, "Review
+ and Recommendations for Internationalized Domain Names
+ (IDNs)", RFC 4690, September 2006.
- [RFC5927] Gont, F., "ICMP Attacks against TCP", RFC 5927, July 2010.
+ [RFC5176] Chiba, M., Dommety, G., Eklund, M., Mitton, D., and B.
+ Aboba, "Dynamic Authorization Extensions to Remote
+ Authentication Dial In User Service (RADIUS)",
+ RFC 5176, January 2008.
- [RFC3692] Narten, T., "Assigning Experimental and Testing Numbers
- Considered Useful", BCP 82, RFC 3692, January 2004.
+Fajardo, et al. Standards Track [Page 145]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+ [RFC5461] Gont, F., "TCP's Reaction to Soft Errors", RFC 5461,
+ February 2009.
+ [RFC5905] Mills, D., Martin, J., Burbank, J., and W. Kasch,
+ "Network Time Protocol Version 4: Protocol and
+ Algorithms Specification", RFC 5905, June 2010.
+ [RFC5927] Gont, F., "ICMP Attacks against TCP", RFC 5927,
+ July 2010.
+ [RFC6335] Cotton, M., Eggert, L., Touch, J., Westerlund, M., and
+ S. Cheshire, "Internet Assigned Numbers Authority
+ (IANA) Procedures for the Management of the Service
+ Name and Transport Protocol Port Number Registry",
+ BCP 165, RFC 6335, August 2011.
+ [RFC6737] Kang, J. and G. Zorn, "The Diameter Capabilities Update
+ Application", RFC 6737, October 2012.
@@ -8284,80 +8175,83 @@ Internet-Draft Diameter Base Protocol January 2011
-Fajardo, et al. Expires July 24, 2011 [Page 148]
+Fajardo, et al. Standards Track [Page 146]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Appendix A. Acknowledgements
-A.1. RFC3588bis
+A.1. This Document
The authors would like to thank the following people that have
provided proposals and contributions to this document:
To Vishnu Ram and Satendra Gera for their contributions on
- Capabilities Updates, Predictive Loop Avoidance as well as many other
- technical proposals. To Tolga Asveren for his insights and
+ capabilities updates, predictive loop avoidance, as well as many
+ other technical proposals. To Tolga Asveren for his insights and
contributions on almost all of the proposed solutions incorporated
- into this document. To Timothy Smith for helping on the Capabilities
- Updates and other topics. To Tony Zhang for providing fixes to loop
- holes on composing Failed-AVPs as well as many other issues and
+ into this document. To Timothy Smith for helping on the capabilities
+ Update and other topics. To Tony Zhang for providing fixes to
+ loopholes on composing Failed-AVPs as well as many other issues and
topics. To Jan Nordqvist for clearly stating the usage of
- Application Ids. To Anders Kristensen for providing needed technical
+ Application Ids. To Anders Kristensen for providing needed technical
opinions. To David Frascone for providing invaluable review of the
document. To Mark Jones for providing clarifying text on vendor
- command codes and other vendor specific indicators.
+ command codes and other vendor-specific indicators. To Victor
+ Pascual and Sebastien Decugis for new text and recommendations on
+ SCTP/DTLS. To Jouni Korhonen for taking over the editing task and
+ resolving last bits from versions 27 through 29.
- Special thanks to the Diameter extensibility design team which helped
- resolve the tricky question of mandatory AVPs and ABNF semantics.
- The members of this team are as follows:
+ Special thanks to the Diameter extensibility design team, which
+ helped resolve the tricky question of mandatory AVPs and ABNF
+ semantics. The members of this team are as follows:
Avi Lior, Jari Arkko, Glen Zorn, Lionel Morand, Mark Jones, Tolga
- Asveren Jouni Korhonen, Glenn McGregor.
+ Asveren, Jouni Korhonen, and Glenn McGregor.
Special thanks also to people who have provided invaluable comments
and inputs especially in resolving controversial issues:
- Glen Zorn, Yoshihiro Ohba, Marco Stura, and Pasi Eronen.
+ Glen Zorn, Yoshihiro Ohba, Marco Stura, Stephen Farrel, Pete Resnick,
+ Peter Saint-Andre, Robert Sparks, Krishna Prasad, Sean Turner, Barry
+ Leiba, and Pasi Eronen.
Finally, we would like to thank the original authors of this
document:
- Pat Calhoun, John Loughney, Jari Arkko, Erik Guttman and Glen Zorn.
+ Pat Calhoun, John Loughney, Jari Arkko, Erik Guttman, and Glen Zorn.
Their invaluable knowledge and experience has given us a robust and
flexible AAA protocol that many people have seen great value in
adopting. We greatly appreciate their support and stewardship for
the continued improvements of Diameter as a protocol. We would also
like to extend our gratitude to folks aside from the authors who have
- assisted and contributed to the original version of this document.
- Their efforts significantly contributed to the success of Diameter.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 149]
+Fajardo, et al. Standards Track [Page 147]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
-A.2. RFC3588
+ assisted and contributed to the original version of this document.
+ Their efforts significantly contributed to the success of Diameter.
+
+A.2. RFC 3588
The authors would like to thank Nenad Trifunovic, Tony Johansson and
Pankaj Patel for their participation in the pre-IETF Document Reading
- Party. Allison Mankin, Jonathan Wood and Bernard Aboba provided
- invaluable assistance in working out transport issues, and similarly
- with Steven Bellovin in the security area.
+ Party. Allison Mankin, Jonathan Wood, and Bernard Aboba provided
+ invaluable assistance in working out transport issues and this was
+ also the case with Steven Bellovin in the security area.
Paul Funk and David Mitton were instrumental in getting the Peer
State Machine correct, and our deep thanks go to them for their time.
Text in this document was also provided by Paul Funk, Mark Eklund,
- Mark Jones and Dave Spence. Jacques Caron provided many great
+ Mark Jones, and Dave Spence. Jacques Caron provided many great
comments as a result of a thorough review of the spec.
The authors would also like to acknowledge the following people for
@@ -8367,96 +8261,57 @@ A.2. RFC3588
David Frascone, Daniel C. Fox, Lol Grant, Ignacio Goyret, Nancy
Greene, Peter Heitman, Fredrik Johansson, Mark Jones, Martin Julien,
Bob Kopacz, Paul Krumviede, Fergal Ladley, Ryan Moats, Victor Muslin,
- Kenneth Peirce, John Schnizlein, Sumit Vakil, John R. Vollbrecht and
+ Kenneth Peirce, John Schnizlein, Sumit Vakil, John R. Vollbrecht, and
Jeff Weisberg.
Finally, Pat Calhoun would like to thank Sun Microsystems since most
of the effort put into this document was done while he was in their
employ.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 150]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Appendix B. S-NAPTR Example
As an example, consider a client that wishes to resolve aaa:
- example1.com. The client performs a NAPTR query for that domain, and
- the following NAPTR records are returned:
+ ex1.example.com. The client performs a NAPTR query for that domain,
+ and the following NAPTR records are returned:
;; order pref flags service regexp replacement
IN NAPTR 50 50 "s" "aaa:diameter.tls.tcp" ""
- _diameter._tls.example1.com
+ _diameter._tls.ex1.example.com
IN NAPTR 100 50 "s" "aaa:diameter.tcp" ""
- _aaa._tcp.example1.com
+ _aaa._tcp.ex1.example.com
IN NAPTR 150 50 "s" "aaa:diameter.sctp" ""
- _diameter._sctp.example1.com
+ _diameter._sctp.ex1.example.com
- This indicates that the server supports TLS, TCP and SCTP in that
+ This indicates that the server supports TLS, TCP, and SCTP in that
order. If the client supports TLS, TLS will be used, targeted to a
- host determined by an SRV lookup of _diameter._tls.example1.com.
+
+
+
+Fajardo, et al. Standards Track [Page 148]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
+ host determined by an SRV lookup of _diameter._tls.ex1.example.com.
That lookup would return:
;; Priority Weight Port Target
- IN SRV 0 1 5060 server1.example1.com
- IN SRV 0 2 5060 server2.example1.com
+ IN SRV 0 1 5060 server1.ex1.example.com
+ IN SRV 0 2 5060 server2.ex1.example.com
As an alternative example, a client that wishes to resolve aaa:
- example2.com. The client performs a NAPTR query for that domain, and
- the following NAPTR records are returned:
+ ex2.example.com. The client performs a NAPTR query for that domain,
+ and the following NAPTR records are returned:
;; order pref flags service regexp replacement
IN NAPTR 150 50 "a" "aaa:diameter.tls.tcp" ""
- server1.example2.com
+ server1.ex2.example.com
IN NAPTR 150 50 "a" "aaa:diameter.tls.tcp" ""
- server2.example2.com
+ server2.ex2.example.com
This indicates that the server supports TCP available at the returned
host names.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 151]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Appendix C. Duplicate Detection
As described in Section 9.4, accounting record duplicate detection is
@@ -8464,14 +8319,14 @@ Appendix C. Duplicate Detection
reasons:
o Failover to an alternate server. Where close to real-time
- performance is required, failover thresholds need to be kept low
- and this may lead to an increased likelihood of duplicates.
- Failover can occur at the client or within Diameter agents.
-
- o Failure of a client or agent after sending of a record from non-
- volatile memory, but prior to receipt of an application layer ACK
- and deletion of the record. record to be sent. This will result
- in retransmission of the record soon after the client or agent has
+ performance is required, failover thresholds need to be kept low.
+ This may lead to an increased likelihood of duplicates. Failover
+ can occur at the client or within Diameter agents.
+
+ o Failure of a client or agent after sending a record from non-
+ volatile memory, but prior to receipt of an application-layer ACK
+ and deletion of the record to be sent. This will result in
+ retransmission of the record soon after the client or agent has
rebooted.
o Duplicates received from RADIUS gateways. Since the
@@ -8481,48 +8336,48 @@ Appendix C. Duplicate Detection
o Implementation problems and misconfiguration.
- The T flag is used as an indication of an application layer
+ The T flag is used as an indication of an application-layer
retransmission event, e.g., due to failover to an alternate server.
It is defined only for request messages sent by Diameter clients or
agents. For instance, after a reboot, a client may not know whether
+
+
+
+Fajardo, et al. Standards Track [Page 149]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
it has already tried to send the accounting records in its non-
volatile memory before the reboot occurred. Diameter servers MAY use
the T flag as an aid when processing requests and detecting duplicate
messages. However, servers that do this MUST ensure that duplicates
are found even when the first transmitted request arrives at the
server after the retransmitted request. It can be used only in cases
- where no answer has been received from the Server for a request and
+ where no answer has been received from the server for a request and
the request is sent again, (e.g., due to a failover to an alternate
peer, due to a recovered primary peer or due to a client re-sending a
stored record from non-volatile memory such as after reboot of a
client or agent).
- In some cases the Diameter accounting server can delay the duplicate
+ In some cases, the Diameter accounting server can delay the duplicate
detection and accounting record processing until a post-processing
phase takes place. At that time records are likely to be sorted
according to the included User-Name and duplicate elimination is easy
- in this case. In other situations it may be necessary to perform
+ in this case. In other situations, it may be necessary to perform
real-time duplicate detection, such as when credit limits are imposed
or real-time fraud detection is desired.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 152]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
In general, only generation of duplicates due to failover or re-
sending of records in non-volatile storage can be reliably detected
- by Diameter clients or agents. In such cases the Diameter client or
- agents can mark the message as possible duplicate by setting the T
+ by Diameter clients or agents. In such cases, the Diameter client or
+ agents can mark the message as a possible duplicate by setting the T
flag. Since the Diameter server is responsible for duplicate
- detection, it can choose to make use of the T flag or not, in order
- to optimize duplicate detection. Since the T flag does not affect
- interoperability, and may not be needed by some servers, generation
- of the T flag is REQUIRED for Diameter clients and agents, but MAY be
- implemented by Diameter servers.
+ detection, it can choose whether or not to make use of the T flag, in
+ order to optimize duplicate detection. Since the T flag does not
+ affect interoperability, and it may not be needed by some servers,
+ generation of the T flag is REQUIRED for Diameter clients and agents,
+ but it MAY be implemented by Diameter servers.
As an example, it can be usually be assumed that duplicates appear
within a time window of longest recorded network partition or device
@@ -8535,40 +8390,39 @@ Internet-Draft Diameter Base Protocol January 2011
The following is an example of how the T flag may be used by the
server to detect duplicate requests.
-
A Diameter server MAY check the T flag of the received message to
determine if the record is a possible duplicate. If the T flag is
set in the request message, the server searches for a duplicate
within a configurable duplication time window backward and
forward. This limits database searching to those records where
- the T flag is set. In a well run network, network partitions and
+ the T flag is set. In a well-run network, network partitions and
+
+
+
+Fajardo, et al. Standards Track [Page 150]
+
+RFC 6733 Diameter Base Protocol October 2012
+
+
device faults will presumably be rare events, so this approach
represents a substantial optimization of the duplicate detection
process. During failover, it is possible for the original record
- to be received after the T flag marked record, due to differences
+ to be received after the T-flag-marked record, due to differences
in network delays experienced along the path by the original and
duplicate transmissions. The likelihood of this occurring
increases as the failover interval is decreased. In order to be
- able to detect out of order duplicates, the Diameter server should
- use backward and forward time windows when performing duplicate
- checking for the T flag marked request. For example, in order to
- allow time for the original record to exit the network and be
- recorded by the accounting server, the Diameter server can delay
- processing records with the T flag set until a time period
- TIME_WAIT + RECORD_PROCESSING_TIME has elapsed after the closing
- of the original transport connection. After this time period has
- expired, then it may check the T flag marked records against the
+ able to detect duplicates that are out of order, the Diameter
+ server should use backward and forward time windows when
+ performing duplicate checking for the T-flag-marked request. For
+ example, in order to allow time for the original record to exit
+ the network and be recorded by the accounting server, the Diameter
+ server can delay processing records with the T flag set until a
+ time period TIME_WAIT + RECORD_PROCESSING_TIME has elapsed after
+ the closing of the original transport connection. After this time
+ period, it may check the T-flag-marked records against the
database with relative assurance that the original records, if
sent, have been received and recorded.
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 153]
-
-Internet-Draft Diameter Base Protocol January 2011
-
-
Appendix D. Internationalized Domain Names
To be compatible with the existing DNS infrastructure and simplify
@@ -8579,14 +8433,7 @@ Appendix D. Internationalized Domain Names
recommendations in [RFC4690] and [RFC5890]. Applications that
provide support for IDNs outside of the Diameter protocol but
interacting with it SHOULD use the representation and conversion
- framework described in [RFC5890], [RFC5891] and [RFC3492].
-
-
-
-
-
-
-
+ framework described in [RFC5890], [RFC5891], and [RFC3492].
@@ -8608,21 +8455,9 @@ Appendix D. Internationalized Domain Names
-
-
-
-
-
-
-
-
-
-
-
-
-Fajardo, et al. Expires July 24, 2011 [Page 154]
+Fajardo, et al. Standards Track [Page 151]
-Internet-Draft Diameter Base Protocol January 2011
+RFC 6733 Diameter Base Protocol October 2012
Authors' Addresses
@@ -8634,7 +8469,7 @@ Authors' Addresses
USA
Phone: +1-908-421-1845
Jari Arkko
@@ -8643,7 +8478,7 @@ Authors' Addresses
Finland
Phone: +358 40 5079256
John Loughney
@@ -8653,17 +8488,17 @@ Authors' Addresses
US
Phone: +1-650-283-8068
- Glenn Zorn
+ Glen Zorn (editor)
Network Zen
- 1310 East Thomas Street
- Seattle, WA 98102
- US
+ 227/358 Thanon Sanphawut
+ Bang Na, Bangkok 10260
+ Thailand
- Phone:
+ Phone: +66 (0) 87-0404617
@@ -8676,6 +8511,5 @@ Authors' Addresses
-Fajardo, et al. Expires July 24, 2011 [Page 155]
+Fajardo, et al. Standards Track [Page 152]
-
diff --git a/lib/diameter/doc/standard/rfc6737.txt b/lib/diameter/doc/standard/rfc6737.txt
new file mode 100644
index 0000000000..50aa33e98f
--- /dev/null
+++ b/lib/diameter/doc/standard/rfc6737.txt
@@ -0,0 +1,339 @@
+
+
+
+
+
+
+Internet Engineering Task Force (IETF) K. Jiao
+Request for Comments: 6737 Huawei
+Category: Standards Track G. Zorn
+ISSN: 2070-1721 Network Zen
+ October 2012
+
+
+ The Diameter Capabilities Update Application
+
+Abstract
+
+ This document defines a new Diameter application and associated
+ Command Codes. The Capabilities Update application is intended to
+ allow the dynamic update of certain Diameter peer capabilities while
+ the peer-to-peer connection is in the open state.
+
+Status of This Memo
+
+ This is an Internet Standards Track document.
+
+ This document is a product of the Internet Engineering Task Force
+ (IETF). It represents the consensus of the IETF community. It has
+ received public review and has been approved for publication by the
+ Internet Engineering Steering Group (IESG). Further information on
+ Internet Standards is available in Section 2 of RFC 5741.
+
+ Information about the current status of this document, any errata,
+ and how to provide feedback on it may be obtained at
+ http://www.rfc-editor.org/info/rfc6737.
+
+Copyright Notice
+
+ Copyright (c) 2012 IETF Trust and the persons identified as the
+ document authors. All rights reserved.
+
+ This document is subject to BCP 78 and the IETF Trust's Legal
+ Provisions Relating to IETF Documents
+ (http://trustee.ietf.org/license-info) in effect on the date of
+ publication of this document. Please review these documents
+ carefully, as they describe your rights and restrictions with respect
+ to this document. Code Components extracted from this document must
+ include Simplified BSD License text as described in Section 4.e of
+ the Trust Legal Provisions and are provided without warranty as
+ described in the Simplified BSD License.
+
+
+
+
+
+
+
+Jiao & Zorn Standards Track [Page 1]
+
+RFC 6737 Diameter Capabilities Update October 2012
+
+
+Table of Contents
+
+ 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
+ 2. Specification of Requirements . . . . . . . . . . . . . . . . . 2
+ 3. Diameter Protocol Considerations . . . . . . . . . . . . . . . 3
+ 4. Capabilities Update . . . . . . . . . . . . . . . . . . . . . . 3
+ 4.1. Command Code Values . . . . . . . . . . . . . . . . . . . . 4
+ 4.1.1. Capabilities-Update-Request . . . . . . . . . . . . . . 4
+ 4.1.2. Capabilities-Update-Answer . . . . . . . . . . . . . . 5
+ 5. Security Considerations . . . . . . . . . . . . . . . . . . . . 5
+ 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . . 5
+ 6.1. Application Identifier . . . . . . . . . . . . . . . . . . 5
+ 6.2. Command Codes . . . . . . . . . . . . . . . . . . . . . . . 5
+ 7. Contributors . . . . . . . . . . . . . . . . . . . . . . . . . 5
+ 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 5
+ 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 6
+ 9.1. Normative References . . . . . . . . . . . . . . . . . . . 6
+ 9.2. Informative References . . . . . . . . . . . . . . . . . . 6
+
+1. Introduction
+
+ Capabilities exchange is an important component of the Diameter base
+ protocol [RFC6733], allowing peers to exchange identities and
+ Diameter capabilities (protocol version number, supported Diameter
+ applications, security mechanisms, etc.). As defined in RFC 3588,
+ however, the capabilities exchange process takes place only once, at
+ the inception of a transport connection between a given pair of
+ peers. Therefore, if a peer's capabilities change (due to a software
+ update, for example), the existing connection(s) must be torn down
+ (along with all of the associated user sessions) and restarted before
+ the modified capabilities can be advertised.
+
+ This document defines a new Diameter application intended to allow
+ the dynamic update of a subset of Diameter peer capabilities over an
+ existing connection. Because the Capabilities Update application
+ specified herein operates over an existing transport connection,
+ modification of certain capabilities is prohibited. Specifically,
+ modifying the security mechanism in use is not allowed; if the
+ security method used between a pair of peers is changed, the affected
+ connection MUST be restarted.
+
+2. Specification of Requirements
+
+ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+ document are to be interpreted as described in RFC 2119 [RFC2119].
+
+
+
+
+
+Jiao & Zorn Standards Track [Page 2]
+
+RFC 6737 Diameter Capabilities Update October 2012
+
+
+3. Diameter Protocol Considerations
+
+ This section details the relationship of the Diameter Capabilities
+ Update application to the Diameter base protocol.
+
+ This document specifies Diameter Application-Id 10. Diameter nodes
+ conforming to this specification MUST advertise support by including
+ the value 10 in the Auth-Application-Id of the Capabilities-Exchange-
+ Request (CER) and Capabilities-Exchange-Answer (CEA) commands
+ [RFC6733].
+
+4. Capabilities Update
+
+ When the capabilities of a Diameter node conforming to this
+ specification change, the node MUST notify all of the nodes with
+ which it has an open transport connection and which have also
+ advertised support for the Capabilities Update application using the
+ Capabilities-Update-Request (CUR) message (Section 4.1.1). This
+ message allows the update of a peer's capabilities (supported
+ Diameter applications, etc.).
+
+ A Diameter node only issues a given command to those peers that have
+ advertised support for the Diameter application that defines the
+ command; a Diameter node must cache the supported applications in
+ order to ensure that unrecognized commands and/or Attribute-Value
+ Pairs (AVPs) are not unnecessarily sent to a peer.
+
+ The receiver of the CUR MUST determine common applications by
+ computing the intersection of its own set of supported Application
+ Ids against all of the Application-Id AVPs (Auth-Application-Id,
+ Acct-Application-Id, and Vendor-Specific-Application-Id) present in
+ the CUR. The value of the Vendor-Id AVP in the Vendor-Specific-
+ Application-Id MUST NOT be used during computation.
+
+ If the receiver of a CUR does not have any applications in common
+ with the sender, then it MUST return a Capabilities-Update-Answer
+ (CUA) (Section 4.1.2) with the Result-Code AVP set to
+ DIAMETER_NO_COMMON_APPLICATION [RFC6733], and it SHOULD disconnect
+ the transport-layer connection. However, if active sessions are
+ using the connection, peers MAY delay disconnection until the
+ sessions can be redirected or gracefully terminated. Note that
+ receiving a CUA from a peer advertising itself as a relay (see
+ [RFC6733], Section 2.4) MUST be interpreted as having common
+ applications with the peer.
+
+ As for CER/CEA messages, the CUR and CUA messages MUST NOT be
+ proxied, redirected, or relayed.
+
+
+
+
+Jiao & Zorn Standards Track [Page 3]
+
+RFC 6737 Diameter Capabilities Update October 2012
+
+
+ Even though the CUR/CUA messages cannot be proxied, it is still
+ possible for an upstream agent to receive a message for which there
+ are no peers available to handle the application that corresponds to
+ the Command Code. This could happen if, for example, the peers are
+ too busy or down. In such instances, the 'E' bit MUST be set in the
+ answer message with the Result-Code AVP set to
+ DIAMETER_UNABLE_TO_DELIVER to inform the downstream peer to take
+ action (e.g., re-routing requests to an alternate peer).
+
+4.1. Command Code Values
+
+ This section defines Command Code [RFC6733] values that MUST be
+ supported by all Diameter implementations conforming to this
+ specification. The following Command Codes are defined in this
+ document: Capabilities-Update-Request (CUR, Section 4.1.1), and
+ Capabilities-Update-Answer (CUA, Section 4.1.2). The Diameter
+ Command Code Format (CCF) ([RFC6733], Section 3.2) is used in the
+ definitions.
+
+4.1.1. Capabilities-Update-Request
+
+ The Capabilities-Update-Request (CUR), indicated by the Command Code
+ set to 328 and the Command Flags' 'R' bit set, is sent to update
+ local capabilities. Upon detection of a transport failure, this
+ message MUST NOT be sent to an alternate peer.
+
+ When Diameter is run over the Stream Control Transmission Protocol
+ (SCTP) [RFC4960], which allows connections to span multiple
+ interfaces and multiple IP addresses, the Capabilities-Update-Request
+ message MUST contain one Host-IP-Address AVP for each potential IP
+ address that may be locally used when transmitting Diameter messages.
+
+ Message Format
+
+ <CUR> ::= < Diameter Header: 328, REQ >
+ { Origin-Host }
+ { Origin-Realm }
+ 1* { Host-IP-Address }
+ { Vendor-Id }
+ { Product-Name }
+ [ Origin-State-Id ]
+ * [ Supported-Vendor-Id ]
+ * [ Auth-Application-Id ]
+ * [ Acct-Application-Id ]
+ * [ Vendor-Specific-Application-Id ]
+ [ Firmware-Revision ]
+ * [ AVP ]
+
+
+
+
+Jiao & Zorn Standards Track [Page 4]
+
+RFC 6737 Diameter Capabilities Update October 2012
+
+
+4.1.2. Capabilities-Update-Answer
+
+ The Capabilities-Update-Answer, indicated by the Command Code set to
+ 328 and the Command Flags' 'R' bit cleared, is sent in response to a
+ CUR message.
+
+ Message Format
+
+ <CUA> ::= < Diameter Header: 328 >
+ { Origin-Host }
+ { Origin-Realm }
+ { Result-Code }
+ [ Error-Message ]
+ * [ AVP ]
+
+5. Security Considerations
+
+ The security considerations applicable to the Diameter base protocol
+ [RFC6733] are also applicable to this document.
+
+6. IANA Considerations
+
+ This section explains the criteria to be used by the IANA for
+ assignment of numbers within namespaces used within this document.
+
+6.1. Application Identifier
+
+ This specification assigns the value 10 (Diameter Capabilities
+ Update) from the Application Identifiers namespace [RFC6733]. See
+ Section 3 for the assignment of the namespace in this specification.
+
+6.2. Command Codes
+
+ This specification assigns the value 328 (Capabilities-Update-
+ Request/Capabilities-Update-Answer (CUR/CUA)) from the Command Codes
+ namespace [RFC6733]. See Section 4.1 for the assignment of the
+ namespace in this specification.
+
+7. Contributors
+
+ This document is based upon work done by Tina Tsou.
+
+8. Acknowledgements
+
+ Thanks to Sebastien Decugis, Niklas Neumann, Subash Comerica, Lionel
+ Morand, Dan Romascanu, Dan Harkins, and Ravi for helpful review and
+ discussion.
+
+
+
+
+Jiao & Zorn Standards Track [Page 5]
+
+RFC 6737 Diameter Capabilities Update October 2012
+
+
+9. References
+
+9.1. Normative References
+
+ [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
+ Requirement Levels", BCP 14, RFC 2119, March 1997.
+
+ [RFC6733] Fajardo, V., Arkko, J., Loughney, J., and G. Zorn,
+ "Diameter Base Protocol", RFC 6733, October 2012.
+
+9.2. Informative References
+
+ [RFC4960] Stewart, R., "Stream Control Transmission Protocol",
+ RFC 4960, September 2007.
+
+Authors' Addresses
+
+ Jiao Kang
+ Huawei Technologies
+ Section F1, Huawei Industrial Base
+ Bantian, Longgang District
+ Shenzhen 518129
+ P.R. China
+
+
+
+ Glen Zorn
+ Network Zen
+ 227/358 Thanon Sanphawut
+ Bang Na, Bangkok 10260
+ Thailand
+
+ Phone: +66 (0) 909-201060
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Jiao & Zorn Standards Track [Page 6]
+
diff --git a/lib/diameter/src/base/diameter_capx.erl b/lib/diameter/src/base/diameter_capx.erl
index 190d37262b..c6c3d2934d 100644
--- a/lib/diameter/src/base/diameter_capx.erl
+++ b/lib/diameter/src/base/diameter_capx.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2010-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2010-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/edoc/doc/src/notes.xml b/lib/edoc/doc/src/notes.xml
index e01a6d6675..472b3bfc34 100644
--- a/lib/edoc/doc/src/notes.xml
+++ b/lib/edoc/doc/src/notes.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>2007</year><year>2011</year>
+ <year>2007</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/eldap/src/Makefile b/lib/eldap/src/Makefile
index 39a41d08e2..46fb805bcc 100644
--- a/lib/eldap/src/Makefile
+++ b/lib/eldap/src/Makefile
@@ -88,7 +88,7 @@ $(TARGET_FILES): $(HRL_FILES)
# Special Build Targets
# ----------------------------------------------------
$(ASN1_HRL): ../asn1/$(ASN1_FILES)
- $(ERLC) -o $(EBIN) -bber_bin +optimize +nif $(ERL_COMPILE_FLAGS) ../asn1/ELDAPv3.asn1
+ $(ERLC) -o $(EBIN) -bber $(ERL_COMPILE_FLAGS) ../asn1/ELDAPv3.asn1
# ----------------------------------------------------
# Release Target
diff --git a/lib/erl_docgen/doc/src/notes.xml b/lib/erl_docgen/doc/src/notes.xml
index ee62de86b1..9775909d76 100644
--- a/lib/erl_docgen/doc/src/notes.xml
+++ b/lib/erl_docgen/doc/src/notes.xml
@@ -30,7 +30,23 @@
</header>
<p>This document describes the changes made to the <em>erl_docgen</em> application.</p>
- <section><title>Erl_Docgen 0.3.2</title>
+ <section><title>Erl_Docgen 0.3.3</title>
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p> A possibility to configure erl_docgen so it can
+ generate documentation for other products than
+ Erlang/OTP. </p>
+ <p>
+ Own Id: OTP-9040</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
+<section><title>Erl_Docgen 0.3.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
diff --git a/lib/erl_interface/configure.in b/lib/erl_interface/configure.in
index f1c9ebbb6f..97f1cff345 100644
--- a/lib/erl_interface/configure.in
+++ b/lib/erl_interface/configure.in
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2000-2011. All Rights Reserved.
+# Copyright Ericsson AB 2000-2012. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/erl_interface/doc/src/notes.xml b/lib/erl_interface/doc/src/notes.xml
index 6791c39c7d..f0a9b336ff 100644
--- a/lib/erl_interface/doc/src/notes.xml
+++ b/lib/erl_interface/doc/src/notes.xml
@@ -30,6 +30,24 @@
</header>
<p>This document describes the changes made to the Erl_interface application.</p>
+<section><title>Erl_Interface 3.7.9</title>
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>Teach lib/erl_interface/configure.in to look for
+ pthreads support in libc (where it can be found on
+ QNX)</p> <p>A minor tweak such that this configure
+ *fails* if you pass --enable-threads and no pthreads
+ support can be found.</p> (Thanks to Per Hedeland)
+ <p>
+ Own Id: OTP-10581</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Erl_Interface 3.7.8</title>
<section><title>Improvements and New Features</title>
diff --git a/lib/erl_interface/src/connect/ei_resolve.c b/lib/erl_interface/src/connect/ei_resolve.c
index ba8f8fbce3..79d259b92d 100644
--- a/lib/erl_interface/src/connect/ei_resolve.c
+++ b/lib/erl_interface/src/connect/ei_resolve.c
@@ -186,11 +186,11 @@ static int verify_dns_configuration(void)
* advance: increment buf by n bytes, reduce len by same amount .
*/
#if defined SIZEOF_VOID_P
-#define ALIGNBYTES (SIZEOF_VOID_P - 1)
+#define EI_ALIGNBYTES (SIZEOF_VOID_P - 1)
#else
-#define ALIGNBYTES (sizeof(void*) - 1)
+#define EI_ALIGNBYTES (sizeof(void*) - 1)
#endif
-#define align_buf(buf,len) for (;(((unsigned)buf) & ALIGNBYTES); (buf)++, len--)
+#define align_buf(buf,len) for (;(((unsigned)buf) & EI_ALIGNBYTES); (buf)++, len--)
#define advance_buf(buf,len,n) ((buf)+=(n),(len)-=(n))
/* "and now the tricky part..." */
@@ -282,6 +282,8 @@ static int copy_hostent(struct hostent *dest, const struct hostent *src, char *b
return 0;
}
+#undef EI_ALIGNBYTES
+
/* This function is a pseudo-reentrant version of gethostbyname(). It
* uses locks to serialize the call to the regular (non-reentrant)
* gethostbyname() and then copies the data into the user-provided
diff --git a/lib/erl_interface/vsn.mk b/lib/erl_interface/vsn.mk
index 4e401c874e..1718f38069 100644
--- a/lib/erl_interface/vsn.mk
+++ b/lib/erl_interface/vsn.mk
@@ -1 +1 @@
-EI_VSN = 3.7.8
+EI_VSN = 3.7.9
diff --git a/lib/eunit/doc/src/notes.xml b/lib/eunit/doc/src/notes.xml
index 814580e228..b797be0ccb 100644
--- a/lib/eunit/doc/src/notes.xml
+++ b/lib/eunit/doc/src/notes.xml
@@ -5,7 +5,7 @@
<header>
<copyright>
<year>2008</year>
- <year>2011</year>
+ <year>2012</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/hipe/doc/src/notes.xml b/lib/hipe/doc/src/notes.xml
index 1841c7d9de..cfd22a9d8d 100644
--- a/lib/hipe/doc/src/notes.xml
+++ b/lib/hipe/doc/src/notes.xml
@@ -30,6 +30,22 @@
</header>
<p>This document describes the changes made to HiPE.</p>
+<section><title>Hipe 3.9.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ A faulty spec for process_info/2 could cause false
+ dialyzer warnings. The spec is corrected.</p>
+ <p>
+ Own Id: OTP-10584</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Hipe 3.9.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/hipe/vsn.mk b/lib/hipe/vsn.mk
index 144167f5d1..f3e2e695b5 100644
--- a/lib/hipe/vsn.mk
+++ b/lib/hipe/vsn.mk
@@ -1 +1 @@
-HIPE_VSN = 3.9.2
+HIPE_VSN = 3.9.3
diff --git a/lib/ic/test/java_client_erl_server_SUITE.erl b/lib/ic/test/java_client_erl_server_SUITE.erl
index c2bec94697..9e49305c3c 100644
--- a/lib/ic/test/java_client_erl_server_SUITE.erl
+++ b/lib/ic/test/java_client_erl_server_SUITE.erl
@@ -62,9 +62,14 @@ init_per_suite(Config) when is_list(Config) ->
case case code:priv_dir(jinterface) of
{error,bad_name} ->
false;
- P ->
- filelib:is_dir(P)
- end
+ P ->
+ case filelib:wildcard(filename:join(P, "*.jar")) of
+ [_|_] ->
+ true;
+ [] ->
+ false
+ end
+ end
of
true ->
case find_executable(["java"]) of
diff --git a/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src b/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src
index ac8f2e619f..3143ab427b 100644
--- a/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src
+++ b/lib/ic/test/java_client_erl_server_SUITE_data/Makefile.src
@@ -68,7 +68,7 @@ EBINS = $(ERL_FILES:.erl=.@EMULATOR@)
@IFEQ@ (@jinterface_classpath@,)
all:
-@ELSE
+@ELSE@
all: $(CLASS_FILES) $(EBINS)
@ENDIF@
diff --git a/lib/inets/doc/src/httpd.xml b/lib/inets/doc/src/httpd.xml
index 8497d91549..3fced5dfcd 100644
--- a/lib/inets/doc/src/httpd.xml
+++ b/lib/inets/doc/src/httpd.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1997</year><year>2011</year>
+ <year>1997</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/inets/doc/src/notes.xml b/lib/inets/doc/src/notes.xml
index 3aae1ff70a..e0d6ae3454 100644
--- a/lib/inets/doc/src/notes.xml
+++ b/lib/inets/doc/src/notes.xml
@@ -33,7 +33,27 @@
</header>
- <section>
+ <section><title>Inets 5.9.2</title>
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ Minimum bytes per second</p>
+ <p>
+ New option to http server, {minimum_bytes_per_second,
+ integer()}, for a connection, if it is not reached the
+ socket will close for that specific connection. Can be
+ used to prevent hanging requests from faulty clients.</p>
+ <p>
+ Own Id: OTP-10392</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
+<section>
<title>Inets 5.9.1</title>
<section>
diff --git a/lib/inets/src/http_server/httpd_request_handler.erl b/lib/inets/src/http_server/httpd_request_handler.erl
index 5e0bd39cb3..0f47d785ef 100644
--- a/lib/inets/src/http_server/httpd_request_handler.erl
+++ b/lib/inets/src/http_server/httpd_request_handler.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/inets/test/erl_make_certs.erl b/lib/inets/test/erl_make_certs.erl
index 254aa6d2f9..d6bdd05d01 100644
--- a/lib/inets/test/erl_make_certs.erl
+++ b/lib/inets/test/erl_make_certs.erl
@@ -137,10 +137,10 @@ decode_key(PemBin, Pw) ->
encode_key(Key = #'RSAPrivateKey'{}) ->
{ok, Der} = 'OTP-PUB-KEY':encode('RSAPrivateKey', Key),
- {'RSAPrivateKey', list_to_binary(Der), not_encrypted};
+ {'RSAPrivateKey', Der, not_encrypted};
encode_key(Key = #'DSAPrivateKey'{}) ->
{ok, Der} = 'OTP-PUB-KEY':encode('DSAPrivateKey', Key),
- {'DSAPrivateKey', list_to_binary(Der), not_encrypted}.
+ {'DSAPrivateKey', Der, not_encrypted}.
make_tbs(SubjectKey, Opts) ->
Version = list_to_atom("v"++integer_to_list(proplists:get_value(version, Opts, 3))),
diff --git a/lib/inets/test/inets_app_test.erl b/lib/inets/test/inets_app_test.erl
index d32f7e290b..eabfa69f7c 100644
--- a/lib/inets/test/inets_app_test.erl
+++ b/lib/inets/test/inets_app_test.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/jinterface/test/jitu.erl b/lib/jinterface/test/jitu.erl
index fb262cf9d7..571a2dc9c7 100644
--- a/lib/jinterface/test/jitu.erl
+++ b/lib/jinterface/test/jitu.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2004-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/kernel/doc/src/heart.xml b/lib/kernel/doc/src/heart.xml
index 2826d3d00a..2856d84dcf 100644
--- a/lib/kernel/doc/src/heart.xml
+++ b/lib/kernel/doc/src/heart.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2011</year>
+ <year>1996</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/notes.xml b/lib/kernel/doc/src/notes.xml
index 8e911a406b..78bc533464 100644
--- a/lib/kernel/doc/src/notes.xml
+++ b/lib/kernel/doc/src/notes.xml
@@ -30,6 +30,44 @@
</header>
<p>This document describes the changes made to the Kernel application.</p>
+<section><title>Kernel 2.15.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ Ensure 'erl_crash.dump' when asked for it. This will
+ change erl_crash.dump behaviour.</p>
+ <p>
+ * Not setting ERL_CRASH_DUMP_SECONDS will now terminate
+ beam immediately on a crash without writing a crash dump
+ file.</p>
+ <p>
+ * Setting ERL_CRASH_DUMP_SECONDS to 0 will also terminate
+ beam immediately on a crash without writing a crash dump
+ file, i.e. same as not setting ERL_CRASH_DUMP_SECONDS
+ environment variable.</p>
+ <p>
+ * Setting ERL_CRASH_DUMP_SECONDS to a negative value will
+ let the beam wait indefinitely on the crash dump file
+ being written.</p>
+ <p>
+ * Setting ERL_CRASH_DUMP_SECONDS to a positive value will
+ let the beam wait that many seconds on the crash dump
+ file being written.</p>
+ <p>
+ A positive value will set an alarm/timeout for restart
+ both in beam and in heart if heart is running.</p>
+ <p>
+ *** POTENTIAL INCOMPATIBILITY ***</p>
+ <p>
+ Own Id: OTP-10422 Aux Id: kunagi-250 [161] </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Kernel 2.15.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl
index de287bfa43..87cb9d7f51 100644
--- a/lib/kernel/src/heart.erl
+++ b/lib/kernel/src/heart.erl
@@ -46,6 +46,7 @@
-define(TIMEOUT, 5000).
-define(CYCLE_TIMEOUT, 10000).
+-define(HEART_PORT_NAME, heart_port).
%%---------------------------------------------------------------------
@@ -132,7 +133,7 @@ start_portprogram() ->
case wait_ack(Port) of
ok ->
%% register port so the vm can find it if need be
- register(heart_port, Port),
+ register(?HEART_PORT_NAME, Port),
{ok, Port};
{error, Reason} ->
report_problem({{port_problem, Reason},
@@ -228,6 +229,7 @@ no_reboot_shutdown(Port) ->
end.
do_cycle_port_program(Caller, Parent, Port, Cmd) ->
+ unregister(?HEART_PORT_NAME),
case catch start_portprogram() of
{ok, NewPort} ->
send_shutdown(Port),
diff --git a/lib/kernel/test/global_SUITE.erl b/lib/kernel/test/global_SUITE.erl
index 6eb2134644..1cc3eb7c79 100644
--- a/lib/kernel/test/global_SUITE.erl
+++ b/lib/kernel/test/global_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/kernel/test/heart_SUITE.erl b/lib/kernel/test/heart_SUITE.erl
index 970a03cfd5..2ec3b7c297 100644
--- a/lib/kernel/test/heart_SUITE.erl
+++ b/lib/kernel/test/heart_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/kernel/test/wrap_log_reader_SUITE.erl b/lib/kernel/test/wrap_log_reader_SUITE.erl
index 6c47fda9c5..16b3a7cc1e 100644
--- a/lib/kernel/test/wrap_log_reader_SUITE.erl
+++ b/lib/kernel/test/wrap_log_reader_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/megaco/doc/src/megaco_encode.xml b/lib/megaco/doc/src/megaco_encode.xml
index 410e4f3b31..4a9d63c2e3 100644
--- a/lib/megaco/doc/src/megaco_encode.xml
+++ b/lib/megaco/doc/src/megaco_encode.xml
@@ -224,22 +224,11 @@
messages.</p>
</item>
<item>
- <p>megaco_ber_bin_encoder - encode/decode ASN.1 BER
- messages. This encoder uses ASN.1 ber_bin which
- has been optimized using the bit syntax.</p>
- </item>
- <item>
<p>megaco_per_encoder - encode/decode ASN.1 PER
messages. N.B. that this format is not included in the
Megaco standard.</p>
</item>
<item>
- <p>megaco_per_bin_encoder - encode/decode ASN.1 PER
- messages. N.B. that this format is not included in the
- Megaco standard. This encoder uses ASN.1 per_bin which
- has been optimized using the bit syntax.</p>
- </item>
- <item>
<p>megaco_erl_dist_encoder - encodes messages into Erlangs
distribution format. It is rather verbose but encoding and
decoding is blinding fast. N.B. that this format is not
@@ -370,18 +359,6 @@
needs to be specified.</p>
<list type="bulleted">
<item>
- <p><c><![CDATA[[driver|_]]]></c> - make use of the asn1 driver for decode
- (ber_bin) and encode (per_bin). This option is only available for
- encoding modules: <c><![CDATA[megaco_binary_encoder]]></c>,
- <c><![CDATA[megaco_ber_bin_encoder]]></c> and <c><![CDATA[megaco_per_bin_encoder]]></c>.</p>
- <p>If this option is present in the encoding config, it <em>must</em>
- to be the <em>first</em>, unless the
- <seealso marker="#handling_versions">version3</seealso> encoding
- config is present, in which case it must come second, after
- the version3 encoding config,
- e.g. <c><![CDATA[[{version3,prev3b},driver]]]></c>.</p>
- </item>
- <item>
<p><c><![CDATA[[native]]]></c> - skips the transformation phase, i.e.
the decoded message(s) will not be transformed into our internal
form.</p>
diff --git a/lib/megaco/examples/meas/megaco_codec_meas.erl b/lib/megaco/examples/meas/megaco_codec_meas.erl
index 51ee396338..65b986ccd1 100644
--- a/lib/megaco/examples/meas/megaco_codec_meas.erl
+++ b/lib/megaco/examples/meas/megaco_codec_meas.erl
@@ -176,7 +176,7 @@ display_megaco_info() ->
io:format("Megaco version: ~s (~s)~n", [Ver, FlexStr]).
display_asn1_info() ->
- AI = megaco_ber_bin_drv_media_gateway_control_v1:info(),
+ AI = megaco_ber_media_gateway_control_v1:info(),
Vsn =
case lists:keysearch(vsn, 1, AI) of
{value, {vsn, V}} when is_atom(V) ->
@@ -281,15 +281,11 @@ expand_codec(Codec) ->
[{Codec, megaco_compact_text_encoder, [flex_scanner], 3000},
{Codec, megaco_compact_text_encoder, [], 1500}];
ber ->
- [{Codec, megaco_ber_bin_encoder, [driver,native], 4000},
- {Codec, megaco_ber_bin_encoder, [native], 3000},
- {Codec, megaco_ber_bin_encoder, [driver], 3000},
- {Codec, megaco_ber_bin_encoder, [], 1000}];
+ [{Codec, megaco_ber_encoder, [native], 3000},
+ {Codec, megaco_ber_encoder, [], 1000}];
per ->
- [{Codec, megaco_per_bin_encoder, [driver,native], 4000},
- {Codec, megaco_per_bin_encoder, [native], 3000},
- {Codec, megaco_per_bin_encoder, [driver], 3000},
- {Codec, megaco_per_bin_encoder, [], 1000}];
+ [{Codec, megaco_per_encoder, [native], 3000},
+ {Codec, megaco_per_encoder, [], 1000}];
erlang ->
[
{Codec, megaco_erl_dist_encoder, [megaco_compressed,compressed], 500},
diff --git a/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl b/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl
index 9af88d9f50..b527ff2e89 100644
--- a/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl
+++ b/lib/megaco/examples/meas/megaco_codec_mstone_lib.erl
@@ -268,7 +268,7 @@ display_megaco_info() ->
io:format("Megaco version: ~s~n", [Ver]).
display_asn1_info() ->
- AI = megaco_ber_bin_drv_media_gateway_control_v1:info(),
+ AI = megaco_ber__media_gateway_control_v1:info(),
Vsn =
case lists:keysearch(vsn, 1, AI) of
{value, {vsn, V}} when is_atom(V) ->
@@ -361,15 +361,11 @@ expand_codec(Codec, only_drv) ->
[{Codec, megaco_compact_text_encoder, [flex_scanner]},
{Codec, megaco_compact_text_encoder, [flex_scanner]}];
ber ->
- [{Codec, megaco_ber_bin_encoder, [driver,native]},
- {Codec, megaco_ber_bin_encoder, [driver]},
- {Codec, megaco_ber_bin_encoder, [driver,native]},
- {Codec, megaco_ber_bin_encoder, [driver]}];
+ [{Codec, megaco_ber_encoder, [native]},
+ {Codec, megaco_ber_encoder, []}];
per ->
- [{Codec, megaco_per_bin_encoder, [driver,native]},
- {Codec, megaco_per_bin_encoder, [native]},
- {Codec, megaco_per_bin_encoder, [driver,native]},
- {Codec, megaco_per_bin_encoder, [native]}];
+ [{Codec, megaco_per_encoder, [native]},
+ {Codec, megaco_per_encoder, []}];
erlang ->
Encoder = megaco_erl_dist_encoder,
[
@@ -390,15 +386,11 @@ expand_codec(Codec, no_drv) ->
[{Codec, megaco_compact_text_encoder, []},
{Codec, megaco_compact_text_encoder, []}];
ber ->
- [{Codec, megaco_ber_bin_encoder, [native]},
- {Codec, megaco_ber_bin_encoder, []},
- {Codec, megaco_ber_bin_encoder, [native]},
- {Codec, megaco_ber_bin_encoder, []}];
+ [{Codec, megaco_ber_encoder, [native]},
+ {Codec, megaco_ber_encoder, []}];
per ->
- [{Codec, megaco_per_bin_encoder, [native]},
- {Codec, megaco_per_bin_encoder, []},
- {Codec, megaco_per_bin_encoder, [native]},
- {Codec, megaco_per_bin_encoder, []}];
+ [{Codec, megaco_per_encoder, [native]},
+ {Codec, megaco_per_encoder, []}];
erlang ->
Encoder = megaco_erl_dist_encoder,
[
@@ -419,15 +411,11 @@ expand_codec(Codec, _) ->
[{Codec, megaco_compact_text_encoder, [flex_scanner]},
{Codec, megaco_compact_text_encoder, []}];
ber ->
- [{Codec, megaco_ber_bin_encoder, [driver,native]},
- {Codec, megaco_ber_bin_encoder, [native]},
- {Codec, megaco_ber_bin_encoder, [driver]},
- {Codec, megaco_ber_bin_encoder, []}];
+ [{Codec, megaco_ber_encoder, [native]},
+ {Codec, megaco_ber_encoder, []}];
per ->
- [{Codec, megaco_per_bin_encoder, [driver,native]},
- {Codec, megaco_per_bin_encoder, [native]},
- {Codec, megaco_per_bin_encoder, [driver]},
- {Codec, megaco_per_bin_encoder, []}];
+ [{Codec, megaco_per_encoder, [native]},
+ {Codec, megaco_per_encoder, []}];
erlang ->
Encoder = megaco_erl_dist_encoder,
[
diff --git a/lib/megaco/examples/meas/megaco_codec_transform.erl b/lib/megaco/examples/meas/megaco_codec_transform.erl
index cfe832ff26..15db165566 100644
--- a/lib/megaco/examples/meas/megaco_codec_transform.erl
+++ b/lib/megaco/examples/meas/megaco_codec_transform.erl
@@ -213,11 +213,11 @@ decode_message(compact, BinMsg) ->
Conf = [{version3,?V3}],
do_decode(Mod, Conf, BinMsg);
decode_message(ber, BinMsg) ->
- Mod = megaco_ber_bin_encoder,
+ Mod = megaco_ber_encoder,
Conf = [{version3,?V3}],
do_decode(Mod, Conf, BinMsg);
decode_message(per, BinMsg) ->
- Mod = megaco_per_bin_encoder,
+ Mod = megaco_per_encoder,
Conf = [{version3,?V3}],
do_decode(Mod, Conf, BinMsg);
decode_message(erlang, BinMsg) ->
diff --git a/lib/megaco/src/app/megaco.app.src b/lib/megaco/src/app/megaco.app.src
index c0d8218ac8..0ba2a866f9 100644
--- a/lib/megaco/src/app/megaco.app.src
+++ b/lib/megaco/src/app/megaco.app.src
@@ -23,19 +23,6 @@
{modules,
[
megaco,
- megaco_ber_bin_encoder,
- megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3a,
- megaco_ber_bin_drv_media_gateway_control_prev3b,
- megaco_ber_bin_drv_media_gateway_control_prev3c,
- megaco_ber_bin_drv_media_gateway_control_v3,
- megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3a,
- megaco_ber_bin_media_gateway_control_prev3b,
- megaco_ber_bin_media_gateway_control_prev3c,
- megaco_ber_bin_media_gateway_control_v3,
megaco_ber_encoder,
megaco_ber_media_gateway_control_v1,
megaco_ber_media_gateway_control_v2,
@@ -87,19 +74,6 @@
megaco_per_media_gateway_control_prev3b,
megaco_per_media_gateway_control_prev3c,
megaco_per_media_gateway_control_v3,
- megaco_per_bin_encoder,
- megaco_per_bin_drv_media_gateway_control_v1,
- megaco_per_bin_drv_media_gateway_control_v2,
- megaco_per_bin_drv_media_gateway_control_prev3a,
- megaco_per_bin_drv_media_gateway_control_prev3b,
- megaco_per_bin_drv_media_gateway_control_prev3c,
- megaco_per_bin_drv_media_gateway_control_v3,
- megaco_per_bin_media_gateway_control_v1,
- megaco_per_bin_media_gateway_control_v2,
- megaco_per_bin_media_gateway_control_prev3a,
- megaco_per_bin_media_gateway_control_prev3b,
- megaco_per_bin_media_gateway_control_prev3c,
- megaco_per_bin_media_gateway_control_v3,
megaco_pretty_text_encoder,
megaco_pretty_text_encoder_v1,
megaco_pretty_text_encoder_v2,
diff --git a/lib/megaco/src/binary/Makefile b/lib/megaco/src/binary/Makefile
index 695599b9dc..660713605e 100644
--- a/lib/megaco/src/binary/Makefile
+++ b/lib/megaco/src/binary/Makefile
@@ -50,46 +50,22 @@ ASN1_SPECS = $(ASN1_V1_SPEC) \
ASN1_FILES = $(ASN1_SPECS:%=%.asn)
V1_SPECS = $(BER_ASN1_V1_SPEC) \
- $(BER_BIN_ASN1_V1_SPEC) \
- $(BER_BIN_DRV_ASN1_V1_SPEC) \
- $(PER_ASN1_V1_SPEC) \
- $(PER_BIN_ASN1_V1_SPEC) \
- $(PER_BIN_DRV_ASN1_V1_SPEC)
+ $(PER_ASN1_V1_SPEC)
V2_SPECS = $(BER_ASN1_V2_SPEC) \
- $(BER_BIN_ASN1_V2_SPEC) \
- $(BER_BIN_DRV_ASN1_V2_SPEC) \
- $(PER_ASN1_V2_SPEC) \
- $(PER_BIN_ASN1_V2_SPEC) \
- $(PER_BIN_DRV_ASN1_V2_SPEC)
+ $(PER_ASN1_V2_SPEC)
PREV3A_SPECS = $(BER_ASN1_PREV3A_SPEC) \
- $(BER_BIN_ASN1_PREV3A_SPEC) \
- $(BER_BIN_DRV_ASN1_PREV3A_SPEC) \
- $(PER_ASN1_PREV3A_SPEC) \
- $(PER_BIN_ASN1_PREV3A_SPEC) \
- $(PER_BIN_DRV_ASN1_PREV3A_SPEC)
+ $(PER_ASN1_PREV3A_SPEC)
PREV3B_SPECS = $(BER_ASN1_PREV3B_SPEC) \
- $(BER_BIN_ASN1_PREV3B_SPEC) \
- $(BER_BIN_DRV_ASN1_PREV3B_SPEC) \
- $(PER_ASN1_PREV3B_SPEC) \
- $(PER_BIN_ASN1_PREV3B_SPEC) \
- $(PER_BIN_DRV_ASN1_PREV3B_SPEC)
+ $(PER_ASN1_PREV3B_SPEC)
PREV3C_SPECS = $(BER_ASN1_PREV3C_SPEC) \
- $(BER_BIN_ASN1_PREV3C_SPEC) \
- $(BER_BIN_DRV_ASN1_PREV3C_SPEC) \
- $(PER_ASN1_PREV3C_SPEC) \
- $(PER_BIN_ASN1_PREV3C_SPEC) \
- $(PER_BIN_DRV_ASN1_PREV3C_SPEC)
+ $(PER_ASN1_PREV3C_SPEC)
V3_SPECS = $(BER_ASN1_V3_SPEC) \
- $(BER_BIN_ASN1_V3_SPEC) \
- $(BER_BIN_DRV_ASN1_V3_SPEC) \
$(PER_ASN1_V3_SPEC) \
- $(PER_BIN_ASN1_V3_SPEC) \
- $(PER_BIN_DRV_ASN1_V3_SPEC) \
$(PREV3A_SPECS) $(PREV3B_SPECS) $(PREV3C_SPECS)
SPECS = $(V1_SPECS) $(V2_SPECS) $(V3_SPECS)
diff --git a/lib/megaco/src/binary/depend.mk b/lib/megaco/src/binary/depend.mk
index c9ca34bcf6..a1318079be 100644
--- a/lib/megaco/src/binary/depend.mk
+++ b/lib/megaco/src/binary/depend.mk
@@ -19,17 +19,8 @@
# Flag description:
#
-# +optimize
-# For ber_bin this means "optimize" (whatever that is),
-# but for per_bin it means that a stage in the encode
-# is done in the asn1 driver.
-#
-# +nif
-# For ber_bin this means that part of the decode is done
-# in the asn1 nif.
-#
# +asn1config
-# This is only used by the ber_bin, and means that
+# This is only used by the ber, and means that
# some partial decode functions will be created
# (as described by the asn1config file).
#
@@ -43,42 +34,18 @@ ifeq ($(MEGACO_INLINE_ASN1_RT),true)
ASN1_CT_OPTS += +inline
endif
-BER_V1_FLAGS = $(ASN1_CT_OPTS)
-BER_BIN_V1_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize
-BER_BIN_DRV_V1_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize +nif
-BER_V2_FLAGS = $(ASN1_CT_OPTS)
-BER_BIN_V2_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize
-BER_BIN_DRV_V2_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize +nif
-BER_PREV3A_FLAGS = $(ASN1_CT_OPTS)
-BER_BIN_PREV3A_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize
-BER_BIN_DRV_PREV3A_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize +nif
-BER_PREV3B_FLAGS = $(ASN1_CT_OPTS)
-BER_BIN_PREV3B_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize
-BER_BIN_DRV_PREV3B_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize +nif
-BER_PREV3C_FLAGS = $(ASN1_CT_OPTS)
-BER_BIN_PREV3C_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize
-BER_BIN_DRV_PREV3C_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize +nif
-BER_V3_FLAGS = $(ASN1_CT_OPTS)
-BER_BIN_V3_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize
-BER_BIN_DRV_V3_FLAGS = $(ASN1_CT_OPTS) +asn1config +optimize +nif
+BER_V1_FLAGS = $(ASN1_CT_OPTS) +asn1config
+BER_V2_FLAGS = $(ASN1_CT_OPTS) +asn1config
+BER_PREV3A_FLAGS = $(ASN1_CT_OPTS) +asn1config
+BER_PREV3B_FLAGS = $(ASN1_CT_OPTS) +asn1config
+BER_PREV3C_FLAGS = $(ASN1_CT_OPTS) +asn1config
+BER_V3_FLAGS = $(ASN1_CT_OPTS) +asn1config
PER_V1_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_V1_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_DRV_V1_FLAGS = $(ASN1_CT_OPTS) +optimize
PER_V2_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_V2_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_DRV_V2_FLAGS = $(ASN1_CT_OPTS) +optimize
PER_PREV3A_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_PREV3A_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_DRV_PREV3A_FLAGS = $(ASN1_CT_OPTS) +optimize
PER_PREV3B_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_PREV3B_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_DRV_PREV3B_FLAGS = $(ASN1_CT_OPTS) +optimize
PER_PREV3C_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_PREV3C_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_DRV_PREV3C_FLAGS = $(ASN1_CT_OPTS) +optimize
PER_V3_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_V3_FLAGS = $(ASN1_CT_OPTS)
-PER_BIN_DRV_V3_FLAGS = $(ASN1_CT_OPTS) +optimize
# --- Version 1 ---
@@ -92,26 +59,6 @@ $(BER_ASN1_V1_SPEC).erl: \
$(EBIN)/$(BER_ASN1_V1_SPEC).$(EMULATOR): \
$(BER_ASN1_V1_SPEC).erl
-$(BER_BIN_ASN1_V1_SPEC).erl: \
- $(BER_BIN_ASN1_V1_SPEC).set.asn \
- $(BER_BIN_ASN1_V1_SPEC).asn1config \
- $(ASN1_V1_SPEC).asn
- @echo "$(BER_BIN_ASN1_V1_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_V1_FLAGS) $(BER_BIN_ASN1_V1_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_ASN1_V1_SPEC).$(EMULATOR): \
- $(BER_BIN_ASN1_V1_SPEC).erl
-
-$(BER_BIN_DRV_ASN1_V1_SPEC).erl: \
- $(BER_BIN_DRV_ASN1_V1_SPEC).set.asn \
- $(BER_BIN_DRV_ASN1_V1_SPEC).asn1config \
- $(ASN1_V1_SPEC).asn
- @echo "$(BER_BIN_DRV_ASN1_V1_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_DRV_V1_FLAGS) $(BER_BIN_DRV_ASN1_V1_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_DRV_ASN1_V1_SPEC).$(EMULATOR): \
- $(BER_BIN_DRV_ASN1_V1_SPEC).erl
-
$(PER_ASN1_V1_SPEC).erl: \
$(PER_ASN1_V1_SPEC).set.asn \
$(ASN1_V1_SPEC).asn
@@ -121,24 +68,6 @@ $(PER_ASN1_V1_SPEC).erl: \
$(EBIN)/$(PER_ASN1_V1_SPEC).$(EMULATOR): \
$(PER_ASN1_V1_SPEC).erl
-$(PER_BIN_ASN1_V1_SPEC).erl: \
- $(PER_BIN_ASN1_V1_SPEC).set.asn \
- $(ASN1_V1_SPEC).asn
- @echo "$(PER_BIN_ASN1_V1_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_V1_FLAGS) $(PER_BIN_ASN1_V1_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_ASN1_V1_SPEC).$(EMULATOR): \
- $(PER_BIN_ASN1_V1_SPEC).erl
-
-$(PER_BIN_DRV_ASN1_V1_SPEC).erl: \
- $(PER_BIN_DRV_ASN1_V1_SPEC).set.asn \
- $(ASN1_V1_SPEC).asn
- @echo "$(PER_BIN_DRV_ASN1_V1_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_DRV_V1_FLAGS) $(PER_BIN_DRV_ASN1_V1_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_DRV_ASN1_V1_SPEC).$(EMULATOR): \
- $(PER_BIN_DRV_ASN1_V1_SPEC).erl
-
# --- Version 2 ---
@@ -151,26 +80,6 @@ $(BER_ASN1_V2_SPEC).erl: \
$(EBIN)/$(BER_ASN1_V2_SPEC).$(EMULATOR): \
$(BER_ASN1_V2_SPEC).erl
-$(BER_BIN_ASN1_V2_SPEC).erl: \
- $(BER_BIN_ASN1_V2_SPEC).set.asn \
- $(BER_BIN_ASN1_V2_SPEC).asn1config \
- $(ASN1_V2_SPEC).asn
- @echo "$(BER_BIN_ASN1_V2_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_V2_FLAGS) $(BER_BIN_ASN1_V2_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_ASN1_V2_SPEC).$(EMULATOR): \
- $(BER_BIN_ASN1_V2_SPEC).erl
-
-$(BER_BIN_DRV_ASN1_V2_SPEC).erl: \
- $(BER_BIN_DRV_ASN1_V2_SPEC).set.asn \
- $(BER_BIN_DRV_ASN1_V2_SPEC).asn1config \
- $(ASN1_V2_SPEC).asn
- @echo "$(BER_BIN_DRV_ASN1_V2_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_DRV_V2_FLAGS) $(BER_BIN_DRV_ASN1_V2_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_DRV_ASN1_V2_SPEC).$(EMULATOR): \
- $(BER_BIN_DRV_ASN1_V2_SPEC).erl
-
$(PER_ASN1_V2_SPEC).erl: \
$(PER_ASN1_V2_SPEC).set.asn \
$(ASN1_V2_SPEC).asn
@@ -180,25 +89,6 @@ $(PER_ASN1_V2_SPEC).erl: \
$(EBIN)/$(PER_ASN1_V2_SPEC).$(EMULATOR): \
$(PER_ASN1_V2_SPEC).erl
-$(PER_BIN_ASN1_V2_SPEC).erl: \
- $(PER_BIN_ASN1_V2_SPEC).set.asn \
- $(ASN1_V2_SPEC).asn
- @echo "$(PER_BIN_ASN1_V2_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_V2_FLAGS) $(PER_BIN_ASN1_V2_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_ASN1_V2_SPEC).$(EMULATOR): \
- $(PER_BIN_ASN1_V2_SPEC).erl
-
-$(PER_BIN_DRV_ASN1_V2_SPEC).erl: \
- $(PER_BIN_DRV_ASN1_V2_SPEC).set.asn \
- $(ASN1_V2_SPEC).asn
- @echo "$(PER_BIN_DRV_ASN1_V2_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_DRV_V2_FLAGS) $(PER_BIN_DRV_ASN1_V2_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_DRV_ASN1_V2_SPEC).$(EMULATOR): \
- $(PER_BIN_DRV_ASN1_V2_SPEC).erl
-
-
# --- Version 3 ---
# -- (prev3a) --
@@ -212,26 +102,6 @@ $(BER_ASN1_PREV3A_SPEC).erl: \
$(EBIN)/$(BER_ASN1_PREV3A_SPEC).$(EMULATOR): \
$(BER_ASN1_PREV3A_SPEC).erl
-$(BER_BIN_ASN1_PREV3A_SPEC).erl: \
- $(BER_BIN_ASN1_PREV3A_SPEC).set.asn \
- $(BER_BIN_ASN1_PREV3A_SPEC).asn1config \
- $(ASN1_PREV3A_SPEC).asn
- @echo "$(BER_BIN_ASN1_PREV3A_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_PREV3A_FLAGS) $(BER_BIN_ASN1_PREV3A_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_ASN1_PREV3A_SPEC).$(EMULATOR): \
- $(BER_BIN_ASN1_PREV3A_SPEC).erl
-
-$(BER_BIN_DRV_ASN1_PREV3A_SPEC).erl: \
- $(BER_BIN_DRV_ASN1_PREV3A_SPEC).set.asn \
- $(BER_BIN_DRV_ASN1_PREV3A_SPEC).asn1config \
- $(ASN1_PREV3A_SPEC).asn
- @echo "$(BER_BIN_DRV_ASN1_PREV3A_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_DRV_PREV3A_FLAGS) $(BER_BIN_DRV_ASN1_PREV3A_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_DRV_ASN1_PREV3A_SPEC).$(EMULATOR): \
- $(BER_BIN_DRV_ASN1_PREV3A_SPEC).erl
-
$(PER_ASN1_PREV3A_SPEC).erl: \
$(PER_ASN1_PREV3A_SPEC).set.asn \
$(ASN1_PREV3A_SPEC).asn
@@ -241,23 +111,6 @@ $(PER_ASN1_PREV3A_SPEC).erl: \
$(EBIN)/$(PER_ASN1_PREV3A_SPEC).$(EMULATOR): \
$(PER_ASN1_PREV3A_SPEC).erl
-$(PER_BIN_ASN1_PREV3A_SPEC).erl: \
- $(PER_BIN_ASN1_PREV3A_SPEC).set.asn \
- $(ASN1_PREV3A_SPEC).asn
- @echo "$(PER_BIN_ASN1_PREV3A_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_PREV3A_FLAGS) $(PER_BIN_ASN1_PREV3A_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_ASN1_PREV3A_SPEC).$(EMULATOR): \
- $(PER_BIN_ASN1_PREV3A_SPEC).erl
-
-$(PER_BIN_DRV_ASN1_PREV3A_SPEC).erl: \
- $(PER_BIN_DRV_ASN1_PREV3A_SPEC).set.asn \
- $(ASN1_PREV3A_SPEC).asn
- @echo "$(PER_BIN_DRV_ASN1_PREV3A_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_DRV_PREV3A_FLAGS) $(PER_BIN_DRV_ASN1_PREV3A_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_DRV_ASN1_PREV3A_SPEC).$(EMULATOR): \
- $(PER_BIN_DRV_ASN1_PREV3A_SPEC).erl
# -- (prev3b) --
@@ -270,26 +123,6 @@ $(BER_ASN1_PREV3B_SPEC).erl: \
$(EBIN)/$(BER_ASN1_PREV3B_SPEC).$(EMULATOR): \
$(BER_ASN1_PREV3B_SPEC).erl
-$(BER_BIN_ASN1_PREV3B_SPEC).erl: \
- $(BER_BIN_ASN1_PREV3B_SPEC).set.asn \
- $(BER_BIN_ASN1_PREV3B_SPEC).asn1config \
- $(ASN1_PREV3B_SPEC).asn
- @echo "$(BER_BIN_ASN1_PREV3B_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_PREV3B_FLAGS) $(BER_BIN_ASN1_PREV3B_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_ASN1_PREV3B_SPEC).$(EMULATOR): \
- $(BER_BIN_ASN1_PREV3B_SPEC).erl
-
-$(BER_BIN_DRV_ASN1_PREV3B_SPEC).erl: \
- $(BER_BIN_DRV_ASN1_PREV3B_SPEC).set.asn \
- $(BER_BIN_DRV_ASN1_PREV3B_SPEC).asn1config \
- $(ASN1_PREV3B_SPEC).asn
- @echo "$(BER_BIN_DRV_ASN1_PREV3B_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_DRV_PREV3B_FLAGS) $(BER_BIN_DRV_ASN1_PREV3B_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_DRV_ASN1_PREV3B_SPEC).$(EMULATOR): \
- $(BER_BIN_DRV_ASN1_PREV3B_SPEC).erl
-
$(PER_ASN1_PREV3B_SPEC).erl: \
$(PER_ASN1_PREV3B_SPEC).set.asn \
$(ASN1_PREV3B_SPEC).asn
@@ -299,24 +132,6 @@ $(PER_ASN1_PREV3B_SPEC).erl: \
$(EBIN)/$(PER_ASN1_PREV3B_SPEC).$(EMULATOR): \
$(PER_ASN1_PREV3B_SPEC).erl
-$(PER_BIN_ASN1_PREV3B_SPEC).erl: \
- $(PER_BIN_ASN1_PREV3B_SPEC).set.asn \
- $(ASN1_PREV3B_SPEC).asn
- @echo "$(PER_BIN_ASN1_PREV3B_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_PREV3B_FLAGS) $(PER_BIN_ASN1_PREV3B_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_ASN1_PREV3B_SPEC).$(EMULATOR): \
- $(PER_BIN_ASN1_PREV3B_SPEC).erl
-
-$(PER_BIN_DRV_ASN1_PREV3B_SPEC).erl: \
- $(PER_BIN_DRV_ASN1_PREV3B_SPEC).set.asn \
- $(ASN1_PREV3B_SPEC).asn
- @echo "$(PER_BIN_DRV_ASN1_PREV3B_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_DRV_PREV3B_FLAGS) $(PER_BIN_DRV_ASN1_PREV3B_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_DRV_ASN1_PREV3B_SPEC).$(EMULATOR): \
- $(PER_BIN_DRV_ASN1_PREV3B_SPEC).erl
-
# -- (prev3c) --
@@ -329,26 +144,6 @@ $(BER_ASN1_PREV3C_SPEC).erl: \
$(EBIN)/$(BER_ASN1_PREV3C_SPEC).$(EMULATOR): \
$(BER_ASN1_PREV3C_SPEC).erl
-$(BER_BIN_ASN1_PREV3C_SPEC).erl: \
- $(BER_BIN_ASN1_PREV3C_SPEC).set.asn \
- $(BER_BIN_ASN1_PREV3C_SPEC).asn1config \
- $(ASN1_PREV3C_SPEC).asn
- @echo "$(BER_BIN_ASN1_PREV3C_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_PREV3C_FLAGS) $(BER_BIN_ASN1_PREV3C_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_ASN1_PREV3C_SPEC).$(EMULATOR): \
- $(BER_BIN_ASN1_PREV3C_SPEC).erl
-
-$(BER_BIN_DRV_ASN1_PREV3C_SPEC).erl: \
- $(BER_BIN_DRV_ASN1_PREV3C_SPEC).set.asn \
- $(BER_BIN_DRV_ASN1_PREV3C_SPEC).asn1config \
- $(ASN1_PREV3C_SPEC).asn
- @echo "$(BER_BIN_DRV_ASN1_PREV3C_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_DRV_PREV3C_FLAGS) $(BER_BIN_DRV_ASN1_PREV3C_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_DRV_ASN1_PREV3C_SPEC).$(EMULATOR): \
- $(BER_BIN_DRV_ASN1_PREV3C_SPEC).erl
-
$(PER_ASN1_PREV3C_SPEC).erl: \
$(PER_ASN1_PREV3C_SPEC).set.asn \
$(ASN1_PREV3C_SPEC).asn
@@ -358,24 +153,6 @@ $(PER_ASN1_PREV3C_SPEC).erl: \
$(EBIN)/$(PER_ASN1_PREV3C_SPEC).$(EMULATOR): \
$(PER_ASN1_PREV3C_SPEC).erl
-$(PER_BIN_ASN1_PREV3C_SPEC).erl: \
- $(PER_BIN_ASN1_PREV3C_SPEC).set.asn \
- $(ASN1_PREV3C_SPEC).asn
- @echo "$(PER_BIN_ASN1_PREV3C_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_PREV3C_FLAGS) $(PER_BIN_ASN1_PREV3C_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_ASN1_PREV3C_SPEC).$(EMULATOR): \
- $(PER_BIN_ASN1_PREV3C_SPEC).erl
-
-$(PER_BIN_DRV_ASN1_PREV3C_SPEC).erl: \
- $(PER_BIN_DRV_ASN1_PREV3C_SPEC).set.asn \
- $(ASN1_PREV3C_SPEC).asn
- @echo "$(PER_BIN_DRV_ASN1_PREV3C_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_DRV_PREV3C_FLAGS) $(PER_BIN_DRV_ASN1_PREV3C_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_DRV_ASN1_PREV3C_SPEC).$(EMULATOR): \
- $(PER_BIN_DRV_ASN1_PREV3C_SPEC).erl
-
# -- (v3) --
@@ -388,26 +165,6 @@ $(BER_ASN1_V3_SPEC).erl: \
$(EBIN)/$(BER_ASN1_V3_SPEC).$(EMULATOR): \
$(BER_ASN1_V3_SPEC).erl
-$(BER_BIN_ASN1_V3_SPEC).erl: \
- $(BER_BIN_ASN1_V3_SPEC).set.asn \
- $(BER_BIN_ASN1_V3_SPEC).asn1config \
- $(ASN1_V3_SPEC).asn
- @echo "$(BER_BIN_ASN1_V3_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_V3_FLAGS) $(BER_BIN_ASN1_V3_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_ASN1_V3_SPEC).$(EMULATOR): \
- $(BER_BIN_ASN1_V3_SPEC).erl
-
-$(BER_BIN_DRV_ASN1_V3_SPEC).erl: \
- $(BER_BIN_DRV_ASN1_V3_SPEC).set.asn \
- $(BER_BIN_DRV_ASN1_V3_SPEC).asn1config \
- $(ASN1_V3_SPEC).asn
- @echo "$(BER_BIN_DRV_ASN1_V3_SPEC):"
- $(ERLC) -bber_bin $(BER_BIN_DRV_V3_FLAGS) $(BER_BIN_DRV_ASN1_V3_SPEC).set.asn
-
-$(EBIN)/$(BER_BIN_DRV_ASN1_V3_SPEC).$(EMULATOR): \
- $(BER_BIN_DRV_ASN1_V3_SPEC).erl
-
$(PER_ASN1_V3_SPEC).erl: \
$(PER_ASN1_V3_SPEC).set.asn \
$(ASN1_V3_SPEC).asn
@@ -417,39 +174,15 @@ $(PER_ASN1_V3_SPEC).erl: \
$(EBIN)/$(PER_ASN1_V3_SPEC).$(EMULATOR): \
$(PER_ASN1_V3_SPEC).erl
-$(PER_BIN_ASN1_V3_SPEC).erl: \
- $(PER_BIN_ASN1_V3_SPEC).set.asn \
- $(ASN1_V3_SPEC).asn
- @echo "$(PER_BIN_ASN1_V3_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_V3_FLAGS) $(PER_BIN_ASN1_V3_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_ASN1_V3_SPEC).$(EMULATOR): \
- $(PER_BIN_ASN1_V3_SPEC).erl
-
-$(PER_BIN_DRV_ASN1_V3_SPEC).erl: \
- $(PER_BIN_DRV_ASN1_V3_SPEC).set.asn \
- $(ASN1_V3_SPEC).asn
- @echo "$(PER_BIN_DRV_ASN1_V3_SPEC):"
- $(ERLC) -bper_bin $(PER_BIN_DRV_V3_FLAGS) $(PER_BIN_DRV_ASN1_V3_SPEC).set.asn
-
-$(EBIN)/$(PER_BIN_DRV_ASN1_V3_SPEC).$(EMULATOR): \
- $(PER_BIN_DRV_ASN1_V3_SPEC).erl
-
# -------------
$(EBIN)/megaco_ber_encoder.$(EMULATOR): megaco_ber_encoder.erl \
$(MEGACO_ENGINEDIR)/megaco_message_internal.hrl
-$(EBIN)/megaco_ber_bin_encoder.$(EMULATOR): megaco_ber_bin_encoder.erl \
- $(MEGACO_ENGINEDIR)/megaco_message_internal.hrl
-
$(EBIN)/megaco_per_encoder.$(EMULATOR): megaco_per_encoder.erl \
$(MEGACO_ENGINEDIR)/megaco_message_internal.hrl
-$(EBIN)/megaco_per_bin_encoder.$(EMULATOR): megaco_per_bin_encoder.erl \
- $(MEGACO_ENGINEDIR)/megaco_message_internal.hrl
-
$(EBIN)/megaco_binary_encoder_lib.$(EMULATOR): megaco_binary_encoder_lib.erl \
$(MEGACO_ENGINEDIR)/megaco_message_internal.hrl
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.asn1config b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.asn1config
deleted file mode 100644
index 179473717d..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.asn1config
+++ /dev/null
@@ -1,43 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_drv_media_gateway_control_prev3a',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.set.asn b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.set.asn
deleted file mode 100644
index b9ba7ffdb4..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3a.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3a.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.asn1config b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.asn1config
deleted file mode 100644
index ceda97fbd1..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.asn1config
+++ /dev/null
@@ -1,43 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_drv_media_gateway_control_prev3b',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.set.asn b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.set.asn
deleted file mode 100644
index 0437bde310..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3b.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3b.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.asn1config b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.asn1config
deleted file mode 100644
index d181ef44bd..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.asn1config
+++ /dev/null
@@ -1,43 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_drv_media_gateway_control_prev3c',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.set.asn b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.set.asn
deleted file mode 100644
index e78055fbad..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_prev3c.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3c.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.set.asn b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.set.asn
deleted file mode 100644
index 0f5a92dba1..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v1.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.asn1config b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.asn1config
deleted file mode 100644
index 3d0cb9a019..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.asn1config
+++ /dev/null
@@ -1,43 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_drv_media_gateway_control_v2',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.set.asn b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.set.asn
deleted file mode 100644
index 7fc82b127f..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v2.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v2.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.asn1config b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.asn1config
deleted file mode 100644
index cc662c0145..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.asn1config
+++ /dev/null
@@ -1,43 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_drv_media_gateway_control_v3',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.set.asn b/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.set.asn
deleted file mode 100644
index 1d7950a283..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v3.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v3.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_encoder.erl b/lib/megaco/src/binary/megaco_ber_bin_encoder.erl
deleted file mode 100644
index bf9926c7e5..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_encoder.erl
+++ /dev/null
@@ -1,716 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2000-2009. All Rights Reserved.
-%%
-%% The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-
-%%
-%%----------------------------------------------------------------------
-%% Purpose : Handle ASN.1 BER encoding of Megaco/H.248
-%%----------------------------------------------------------------------
-
--module(megaco_ber_bin_encoder).
-
--behaviour(megaco_encoder).
-
--export([encode_message/3, decode_message/3,
- decode_mini_message/3,
-
- encode_transaction/3,
- encode_action_requests/3,
- encode_action_request/3,
- encode_action_reply/3,
-
- version_of/2]).
-
-%% Backward compatible functions:
--export([encode_message/2, decode_message/2]).
-
--include_lib("megaco/src/engine/megaco_message_internal.hrl").
-
--define(V1_ASN1_MOD, megaco_ber_bin_media_gateway_control_v1).
--define(V2_ASN1_MOD, megaco_ber_bin_media_gateway_control_v2).
--define(V3_ASN1_MOD, megaco_ber_bin_media_gateway_control_v3).
--define(PREV3A_ASN1_MOD, megaco_ber_bin_media_gateway_control_prev3a).
--define(PREV3B_ASN1_MOD, megaco_ber_bin_media_gateway_control_prev3b).
--define(PREV3C_ASN1_MOD, megaco_ber_bin_media_gateway_control_prev3c).
--define(V1_ASN1_MOD_DRV, megaco_ber_bin_drv_media_gateway_control_v1).
--define(V2_ASN1_MOD_DRV, megaco_ber_bin_drv_media_gateway_control_v2).
--define(V3_ASN1_MOD_DRV, megaco_ber_bin_drv_media_gateway_control_v3).
--define(PREV3A_ASN1_MOD_DRV, megaco_ber_bin_drv_media_gateway_control_prev3a).
--define(PREV3B_ASN1_MOD_DRV, megaco_ber_bin_drv_media_gateway_control_prev3b).
--define(PREV3C_ASN1_MOD_DRV, megaco_ber_bin_drv_media_gateway_control_prev3c).
-
--define(V1_TRANS_MOD, megaco_binary_transformer_v1).
--define(V2_TRANS_MOD, megaco_binary_transformer_v2).
--define(V3_TRANS_MOD, megaco_binary_transformer_v3).
--define(PREV3A_TRANS_MOD, megaco_binary_transformer_prev3a).
--define(PREV3B_TRANS_MOD, megaco_binary_transformer_prev3b).
--define(PREV3C_TRANS_MOD, megaco_binary_transformer_prev3c).
-
--define(BIN_LIB, megaco_binary_encoder_lib).
-
-
-%%----------------------------------------------------------------------
-%% Detect (check/get) message version
-%% Return {ok, Version} | {error, Reason}
-%%----------------------------------------------------------------------
-
-version_of([{version3,v3},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?V3_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3c},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?PREV3C_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3b},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?PREV3B_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3a},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?PREV3A_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,v3}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?V3_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3c}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?PREV3C_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3b}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?PREV3B_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3a}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?PREV3A_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?V3_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-version_of(EC, Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?V3_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders).
-
-
-%%----------------------------------------------------------------------
-%% Convert a 'MegacoMessage' record into a binary
-%% Return {ok, Binary} | {error, Reason}
-%%----------------------------------------------------------------------
-
-
-encode_message(EC,
- #'MegacoMessage'{mess = #'Message'{version = V}} = MegaMsg) ->
- encode_message(EC, V, MegaMsg).
-
-
-%% -- Version 1 --
-
-encode_message([{version3, _},driver|EC], 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([driver|EC], 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,_}|EC], 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-encode_message(EC, 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-
-%% -- Version 2 --
-
-encode_message([{version3,_},driver|EC], 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([driver|EC], 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,_}|EC], 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-encode_message(EC, 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-
-%% -- Version 3 --
-
-encode_message([{version3,v3},driver|EC], 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3c},driver|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3C_ASN1_MOD_DRV,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3b},driver|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3B_ASN1_MOD_DRV,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3a},driver|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3A_ASN1_MOD_DRV,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,v3}|EC], 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3c}|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3C_ASN1_MOD,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3b}|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3B_ASN1_MOD,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3a}|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3A_ASN1_MOD,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([driver|EC], 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-encode_message(EC, 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list).
-
-
-%%----------------------------------------------------------------------
-%% Convert a transaction (or transactions in the case of ack) record(s)
-%% into a binary
-%% Return {ok, Binary} | {error, Reason}
-%%----------------------------------------------------------------------
-
-%% encode_transaction([] = EC, 1, Trans) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([native] = EC, 1, Trans) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([driver|EC], 1, Trans) ->
-%% AsnMod = ?V1_ASN1_MOD_DRV,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction(_EC, 1, _Trans) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([] = EC, 2, Trans) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([native] = EC, 2, Trans) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([driver|EC], 2, Trans) ->
-%% AsnMod = ?V2_ASN1_MOD_DRV,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%%encode_transaction(_EC, 2, _Trans) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list).
-%% encode_transaction([] = EC, 3, Trans) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([native] = EC, 3, Trans) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([driver|EC], 3, Trans) ->
-%% AsnMod = ?V3_ASN1_MOD_DRV,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%%encode_transaction(_EC, 3, _Trans) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list).
-encode_transaction(_EC, _V, _Trans) ->
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a list of ActionRequest record's into a binary
-%% Return {ok, DeepIoList} | {error, Reason}
-%%----------------------------------------------------------------------
-%% encode_action_requests([] = EC, 1, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([native] = EC, 1, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([driver|EC], 1, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V1_ASN1_MOD_DRV,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests(_EC, 1, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([] = EC, 2, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([native] = EC, 2, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([driver|EC], 2, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V2_ASN1_MOD_DRV,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests(_EC, 2, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([] = EC, 3, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([native] = EC, 3, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests([driver|EC], 3, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V3_ASN1_MOD_DRV,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%%encode_action_requests(_EC, 3, ActReqs) when is_list(ActReqs) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_requests(EC, ActReqs,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_requests(_EC, V, _ActReqs) ->
-%% {error, {bad_version, V}}.
-encode_action_requests(_EC, _V, _ActReqs) ->
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a ActionRequest record into a binary
-%% Return {ok, DeepIoList} | {error, Reason}
-%%----------------------------------------------------------------------
-%% encode_action_request([] = EC, 1, ActReq) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([native] = EC, 1, ActReq) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([driver|EC], 1, ActReq) ->
-%% AsnMod = ?V1_ASN1_MOD_DRV,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request(_EC, 1, ActReq) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([] = EC, 2, ActReq) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([native] = EC, 2, ActReq) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([driver|EC], 2, ActReq) ->
-%% AsnMod = ?V2_ASN1_MOD_DRV,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request(_EC, 2, ActReq) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([] = EC, 3, ActReq) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([native] = EC, 3, ActReq) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request([driver|EC], 3, ActReq) ->
-%% AsnMod = ?V3_ASN1_MOD_DRV,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-%% encode_action_request(_EC, 3, ActReq) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_action_request(EC, ActReq,
-%% AsnMod, TransMod,
-%% io_list);
-encode_action_request(_EC, _V, _ActReq) ->
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a action reply into a deep io list
-%% Not yest supported by this binary codec!
-%% Return {ok, DeepIoList} | {error, Reason}
-%%----------------------------------------------------------------------
-
-encode_action_reply(_EC, _V, _AcionReply) ->
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a binary into a 'MegacoMessage' record
-%% Return {ok, MegacoMessageRecord} | {error, Reason}
-%%----------------------------------------------------------------------
-
-%% Old decode function
-decode_message(EC, Binary) ->
- decode_message(EC, 1, Binary).
-
-%% -- Dynamic version detection --
-
-%% Select from message
-decode_message([{version3,v3},driver|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD_DRV, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD_DRV, ?V2_TRANS_MOD},
- {?V3_ASN1_MOD_DRV, ?V3_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,prev3c},driver|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD_DRV, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD_DRV, ?V2_TRANS_MOD},
- {?PREV3C_ASN1_MOD_DRV, ?PREV3C_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,prev3b},driver|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD_DRV, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD_DRV, ?V2_TRANS_MOD},
- {?PREV3B_ASN1_MOD_DRV, ?PREV3B_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,prev3a},driver|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD_DRV, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD_DRV, ?V2_TRANS_MOD},
- {?PREV3A_ASN1_MOD_DRV, ?PREV3A_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,v3}|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD, ?V2_TRANS_MOD},
- {?V3_ASN1_MOD, ?V3_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,prev3c}|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD, ?V2_TRANS_MOD},
- {?PREV3C_ASN1_MOD, ?PREV3C_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,prev3b}|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD, ?V2_TRANS_MOD},
- {?PREV3B_ASN1_MOD, ?PREV3B_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([{version3,prev3a}|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD, ?V2_TRANS_MOD},
- {?PREV3A_ASN1_MOD, ?PREV3A_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-decode_message([driver|EC], dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD_DRV, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD_DRV, ?V2_TRANS_MOD},
- {?V3_ASN1_MOD_DRV, ?V3_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, dynamic, Binary) ->
- Mods = [{?V1_ASN1_MOD, ?V1_TRANS_MOD},
- {?V2_ASN1_MOD, ?V2_TRANS_MOD},
- {?V3_ASN1_MOD, ?V3_TRANS_MOD}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Mods, binary);
-
-
-%% -- Version 1 --
-
-decode_message([{version3,_},driver|EC], 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([driver|EC], 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,_}|EC], 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-
-%% -- Version 2 --
-
-decode_message([{version3,_},driver|EC], 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([driver|EC], 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,_}|EC], 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-
-%% -- Version 3 --
-
-decode_message([{version3,v3},driver|EC], 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3c},driver|EC], 3, Binary) ->
- AsnMod = ?PREV3C_ASN1_MOD_DRV,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3b},driver|EC], 3, Binary) ->
- AsnMod = ?PREV3B_ASN1_MOD_DRV,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3a},driver|EC], 3, Binary) ->
- AsnMod = ?PREV3A_ASN1_MOD_DRV,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,v3}|EC], 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3c}|EC], 3, Binary) ->
- AsnMod = ?PREV3C_ASN1_MOD,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3b}|EC], 3, Binary) ->
- AsnMod = ?PREV3B_ASN1_MOD,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3a}|EC], 3, Binary) ->
- AsnMod = ?PREV3A_ASN1_MOD,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([driver|EC], 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary).
-
-
-decode_mini_message([{version3,v3},driver|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD_DRV,
- ?V2_ASN1_MOD_DRV,
- ?V3_ASN1_MOD_DRV],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3c},driver|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD_DRV,
- ?V2_ASN1_MOD_DRV,
- ?PREV3C_ASN1_MOD_DRV],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3b},driver|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD_DRV,
- ?V2_ASN1_MOD_DRV,
- ?PREV3B_ASN1_MOD_DRV],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3a},driver|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD_DRV,
- ?V2_ASN1_MOD_DRV,
- ?PREV3A_ASN1_MOD_DRV],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,v3}|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD,
- ?V2_ASN1_MOD,
- ?V3_ASN1_MOD],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3c}|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD,
- ?V2_ASN1_MOD,
- ?PREV3C_ASN1_MOD],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3b}|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD,
- ?V2_ASN1_MOD,
- ?PREV3B_ASN1_MOD],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3a}|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD,
- ?V2_ASN1_MOD,
- ?PREV3A_ASN1_MOD],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([driver|EC], dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD_DRV,
- ?V2_ASN1_MOD_DRV,
- ?V3_ASN1_MOD_DRV],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message(EC, dynamic, Bin) ->
- Mods = [?V1_ASN1_MOD,
- ?V2_ASN1_MOD,
- ?V3_ASN1_MOD],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,_},driver|EC], 1, Bin) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,_}|EC], 1, Bin) ->
- AsnMod = ?V1_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([driver|EC], 1, Bin) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message(EC, 1, Bin) ->
- AsnMod = ?V1_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,_},driver|EC], 2, Bin) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,_}|EC], 2, Bin) ->
- AsnMod = ?V2_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([driver|EC], 2, Bin) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message(EC, 2, Bin) ->
- AsnMod = ?V2_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,v3},driver|EC], 3, Bin) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3c},driver|EC], 3, Bin) ->
- AsnMod = ?PREV3C_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3b},driver|EC], 3, Bin) ->
- AsnMod = ?PREV3B_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3a},driver|EC], 3, Bin) ->
- AsnMod = ?PREV3A_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,v3}|EC], 3, Bin) ->
- AsnMod = ?V3_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3c}|EC], 3, Bin) ->
- AsnMod = ?PREV3C_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3b}|EC], 3, Bin) ->
- AsnMod = ?PREV3B_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3a}|EC], 3, Bin) ->
- AsnMod = ?PREV3A_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([driver|EC], 3, Bin) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message(EC, 3, Bin) ->
- AsnMod = ?V3_ASN1_MOD,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary).
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.set.asn b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.set.asn
deleted file mode 100644
index b9ba7ffdb4..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3a.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.set.asn b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.set.asn
deleted file mode 100644
index 0437bde310..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3b.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.asn1config b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.asn1config
deleted file mode 100644
index c74422b9a2..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.asn1config
+++ /dev/null
@@ -1,43 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_media_gateway_control_prev3c',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.set.asn b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.set.asn
deleted file mode 100644
index e78055fbad..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3c.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3c.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.asn1config b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.asn1config
deleted file mode 100644
index e815e90948..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.asn1config
+++ /dev/null
@@ -1,44 +0,0 @@
-{exclusive_decode,
- {'megaco_ber_bin_media_gateway_control_v1',
- [
- {decode_message_trans_partial,
- [
- 'MegacoMessage',[{mess,[{messageBody,[{transactions,parts}]}]}]
- ]
- },
- {decode_message_acts_partial,
- ['Transaction',
- [
- {transactionRequest,
- [
- {actions,parts}
- ]
- },
- {transactionReply,
- [
- {transactionResult, [{actionReplies,parts}]}
- ]
- }
- ]
- ]
- },
- {decode_message_version,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{mId,undecoded},{messageBody,undecoded}]}
- ]
- ]
- },
- {decode_message_mId,
- ['MegacoMessage',
- [
- {authHeader,undecoded},
- {mess,[{messageBody,undecoded}]}
- ]
- ]
- }
-
- ]
- }
-}.
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.set.asn b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.set.asn
deleted file mode 100644
index 0f5a92dba1..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v1.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v1.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.set.asn b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.set.asn
deleted file mode 100644
index 7fc82b127f..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v2.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.set.asn b/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.set.asn
deleted file mode 100644
index 1d7950a283..0000000000
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v3.asn
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.asn1config b/lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3a.asn1config
index cc072b30ee..da67561f1b 100644
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v2.asn1config
+++ b/lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3a.asn1config
@@ -1,5 +1,5 @@
{exclusive_decode,
- {'megaco_ber_bin_media_gateway_control_v2',
+ {'megaco_ber_media_gateway_control_prev3a',
[
{decode_message_trans_partial,
[
@@ -14,7 +14,7 @@
{actions,parts}
]
},
- {transactionReply,
+ {transactionReply,
[
{transactionResult, [{actionReplies,parts}]}
]
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.asn1config b/lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3b.asn1config
index deeb2b2da9..2f25f03d97 100644
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_v3.asn1config
+++ b/lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3b.asn1config
@@ -1,5 +1,5 @@
{exclusive_decode,
- {'megaco_ber_bin_media_gateway_control_v3',
+ {'megaco_ber_media_gateway_control_prev3b',
[
{decode_message_trans_partial,
[
@@ -14,7 +14,7 @@
{actions,parts}
]
},
- {transactionReply,
+ {transactionReply,
[
{transactionResult, [{actionReplies,parts}]}
]
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.asn1config b/lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3c.asn1config
index 456ce750ad..23c343eed0 100644
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3a.asn1config
+++ b/lib/megaco/src/binary/megaco_ber_media_gateway_control_prev3c.asn1config
@@ -1,5 +1,5 @@
{exclusive_decode,
- {'megaco_ber_bin_media_gateway_control_prev3a',
+ {'megaco_ber_media_gateway_control_prev3c',
[
{decode_message_trans_partial,
[
@@ -14,7 +14,7 @@
{actions,parts}
]
},
- {transactionReply,
+ {transactionReply,
[
{transactionResult, [{actionReplies,parts}]}
]
diff --git a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.asn1config b/lib/megaco/src/binary/megaco_ber_media_gateway_control_v1.asn1config
index ea10a7d527..951825c0aa 100644
--- a/lib/megaco/src/binary/megaco_ber_bin_drv_media_gateway_control_v1.asn1config
+++ b/lib/megaco/src/binary/megaco_ber_media_gateway_control_v1.asn1config
@@ -1,5 +1,5 @@
{exclusive_decode,
- {'megaco_ber_bin_drv_media_gateway_control_v1',
+ {'megaco_ber_media_gateway_control_v1',
[
{decode_message_trans_partial,
[
@@ -14,7 +14,7 @@
{actions,parts}
]
},
- {transactionReply,
+ {transactionReply,
[
{transactionResult, [{actionReplies,parts}]}
]
@@ -38,7 +38,7 @@
]
]
}
+
]
}
}.
-
diff --git a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.asn1config b/lib/megaco/src/binary/megaco_ber_media_gateway_control_v3.asn1config
index fa5cd80baf..e4b1f9ece9 100644
--- a/lib/megaco/src/binary/megaco_ber_bin_media_gateway_control_prev3b.asn1config
+++ b/lib/megaco/src/binary/megaco_ber_media_gateway_control_v3.asn1config
@@ -1,5 +1,5 @@
{exclusive_decode,
- {'megaco_ber_bin_media_gateway_control_prev3b',
+ {'megaco_ber_media_gateway_control_v3',
[
{decode_message_trans_partial,
[
@@ -14,7 +14,7 @@
{actions,parts}
]
},
- {transactionReply,
+ {transactionReply,
[
{transactionResult, [{actionReplies,parts}]}
]
diff --git a/lib/megaco/src/binary/megaco_binary_encoder.erl b/lib/megaco/src/binary/megaco_binary_encoder.erl
index f825f91a45..51e167590d 100644
--- a/lib/megaco/src/binary/megaco_binary_encoder.erl
+++ b/lib/megaco/src/binary/megaco_binary_encoder.erl
@@ -241,55 +241,30 @@ encode_action_reply(_EC, _V, _AcionReply) ->
%% Return {ok, Version} | {error, Reason}
%%----------------------------------------------------------------------
-version_of([{version3,v3},driver|EC], Binary) ->
- Decoders = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_v3],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3c},driver|EC], Binary) ->
- Decoders = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3c],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3b},driver|EC], Binary) ->
- Decoders = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3b],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([{version3,prev3a},driver|EC], Binary) ->
- Decoders = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3a],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
-version_of([driver|EC], Binary) ->
- Decoders = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_v3],
- ?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
version_of([{version3,v3}|EC], Binary) ->
- Decoders = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_v3],
+ Decoders = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_v3],
?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
version_of([{version3,prev3c}|EC], Binary) ->
- Decoders = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3c],
+ Decoders = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_prev3c],
?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
version_of([{version3,prev3b}|EC], Binary) ->
- Decoders = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3b],
+ Decoders = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_prev3b],
?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
version_of([{version3,prev3a}|EC], Binary) ->
- Decoders = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3a],
+ Decoders = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_prev3a],
?BIN_LIB:version_of(EC, Binary, dynamic, Decoders);
version_of(EC, Binary) ->
- Decoders = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_v3],
+ Decoders = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_v3],
?BIN_LIB:version_of(EC, Binary, dynamic, Decoders).
@@ -301,287 +276,153 @@ version_of(EC, Binary) ->
decode_message(EC, Binary) ->
decode_message(EC, 1, Binary).
-decode_message([{version3,v3},driver|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_binary_transformer_v1},
- {megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_binary_transformer_v2},
- {megaco_ber_bin_drv_media_gateway_control_v3,
- megaco_binary_transformer_v3}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
-decode_message([{version3,prev3c},driver|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_binary_transformer_v1},
- {megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_binary_transformer_v2},
- {megaco_ber_bin_drv_media_gateway_control_prev3c,
- megaco_binary_transformer_prev3c}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
-decode_message([{version3,prev3b},driver|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_binary_transformer_v1},
- {megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_binary_transformer_v2},
- {megaco_ber_bin_drv_media_gateway_control_prev3b,
- megaco_binary_transformer_prev3b}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
-decode_message([{version3,prev3a},driver|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_binary_transformer_v1},
- {megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_binary_transformer_v2},
- {megaco_ber_bin_drv_media_gateway_control_prev3a,
- megaco_binary_transformer_prev3a}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
-decode_message([driver|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_binary_transformer_v1},
- {megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_binary_transformer_v2},
- {megaco_ber_bin_drv_media_gateway_control_v3,
- megaco_binary_transformer_v3}],
- ?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
decode_message([{version3,v3}|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_media_gateway_control_v1,
+ Decoders = [{megaco_ber_media_gateway_control_v1,
megaco_binary_transformer_v1},
- {megaco_ber_bin_media_gateway_control_v2,
+ {megaco_ber_media_gateway_control_v2,
megaco_binary_transformer_v2},
- {megaco_ber_bin_media_gateway_control_v3,
+ {megaco_ber_media_gateway_control_v3,
megaco_binary_transformer_v3}],
?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
decode_message([{version3,prev3c}|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_media_gateway_control_v1,
+ Decoders = [{megaco_ber_media_gateway_control_v1,
megaco_binary_transformer_v1},
- {megaco_ber_bin_media_gateway_control_v2,
+ {megaco_ber_media_gateway_control_v2,
megaco_binary_transformer_v2},
- {megaco_ber_bin_media_gateway_control_prev3c,
+ {megaco_ber_media_gateway_control_prev3c,
megaco_binary_transformer_prev3c}],
?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
decode_message([{version3,prev3b}|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_media_gateway_control_v1,
+ Decoders = [{megaco_ber_media_gateway_control_v1,
megaco_binary_transformer_v1},
- {megaco_ber_bin_media_gateway_control_v2,
+ {megaco_ber_media_gateway_control_v2,
megaco_binary_transformer_v2},
- {megaco_ber_bin_media_gateway_control_prev3b,
+ {megaco_ber_media_gateway_control_prev3b,
megaco_binary_transformer_prev3b}],
?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
decode_message([{version3,prev3a}|EC], dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_media_gateway_control_v1,
+ Decoders = [{megaco_ber_media_gateway_control_v1,
megaco_binary_transformer_v1},
- {megaco_ber_bin_media_gateway_control_v2,
+ {megaco_ber_media_gateway_control_v2,
megaco_binary_transformer_v2},
- {megaco_ber_bin_media_gateway_control_prev3a,
+ {megaco_ber_media_gateway_control_prev3a,
megaco_binary_transformer_prev3a}],
?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
decode_message(EC, dynamic, Binary) ->
- Decoders = [{megaco_ber_bin_media_gateway_control_v1,
+ Decoders = [{megaco_ber_media_gateway_control_v1,
megaco_binary_transformer_v1},
- {megaco_ber_bin_media_gateway_control_v2,
+ {megaco_ber_media_gateway_control_v2,
megaco_binary_transformer_v2},
- {megaco_ber_bin_media_gateway_control_v3,
+ {megaco_ber_media_gateway_control_v3,
megaco_binary_transformer_v3}],
?BIN_LIB:decode_message_dynamic(EC, Binary, Decoders, binary);
%% -- Version 1 --
-decode_message([{version3,_},driver|EC], 1, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v1,
- TransMod = megaco_binary_transformer_v1,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-decode_message([driver|EC], 1, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v1,
- TransMod = megaco_binary_transformer_v1,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
decode_message([{version3,_}|EC], 1, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v1,
+ AsnMod = megaco_ber_media_gateway_control_v1,
TransMod = megaco_binary_transformer_v1,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
decode_message(EC, 1, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v1,
+ AsnMod = megaco_ber_media_gateway_control_v1,
TransMod = megaco_binary_transformer_v1,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
%% -- Version 2 --
-decode_message([{version3,_},driver|EC], 2, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v2,
- TransMod = megaco_binary_transformer_v2,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-decode_message([driver|EC], 2, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v2,
- TransMod = megaco_binary_transformer_v2,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
decode_message([{version3,_}|EC], 2, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v2,
+ AsnMod = megaco_ber_media_gateway_control_v2,
TransMod = megaco_binary_transformer_v2,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
decode_message(EC, 2, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v2,
+ AsnMod = megaco_ber_media_gateway_control_v2,
TransMod = megaco_binary_transformer_v2,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
%% -- Version 3 --
-decode_message([{version3,v3},driver|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v3,
- TransMod = megaco_binary_transformer_v3,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3c},driver|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_prev3c,
- TransMod = megaco_binary_transformer_prev3c,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3b},driver|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_prev3b,
- TransMod = megaco_binary_transformer_prev3b,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3a},driver|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_prev3a,
- TransMod = megaco_binary_transformer_prev3a,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-decode_message([driver|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v3,
- TransMod = megaco_binary_transformer_v3,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
decode_message([{version3,v3}|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v3,
+ AsnMod = megaco_ber_media_gateway_control_v3,
TransMod = megaco_binary_transformer_v3,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
decode_message([{version3,prev3c}|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_prev3c,
+ AsnMod = megaco_ber_media_gateway_control_prev3c,
TransMod = megaco_binary_transformer_prev3c,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
decode_message([{version3,prev3b}|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_prev3b,
+ AsnMod = megaco_ber_media_gateway_control_prev3b,
TransMod = megaco_binary_transformer_prev3b,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
decode_message([{version3,prev3a}|EC], 3, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_prev3a,
+ AsnMod = megaco_ber_media_gateway_control_prev3a,
TransMod = megaco_binary_transformer_prev3a,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
decode_message(EC, 3, Binary) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v3,
+ AsnMod = megaco_ber_media_gateway_control_v3,
TransMod = megaco_binary_transformer_v3,
?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary).
-decode_mini_message([{version3,v3},driver|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_v3],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3c},driver|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3c],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3b},driver|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3b],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,prev3a},driver|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_prev3a],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([driver|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_drv_media_gateway_control_v1,
- megaco_ber_bin_drv_media_gateway_control_v2,
- megaco_ber_bin_drv_media_gateway_control_v3],
- ?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
decode_mini_message([{version3,v3}|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_v3],
+ Mods = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_v3],
?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
decode_mini_message([{version3,prev3c}|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3c],
+ Mods = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_prev3c],
?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
decode_mini_message([{version3,prev3b}|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3b],
+ Mods = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_prev3b],
?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
decode_mini_message([{version3,prev3a}|EC], dynamic, Bin) ->
- Mods = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_prev3a],
+ Mods = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_prev3a],
?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
decode_mini_message(EC, dynamic, Bin) ->
- Mods = [megaco_ber_bin_media_gateway_control_v1,
- megaco_ber_bin_media_gateway_control_v2,
- megaco_ber_bin_media_gateway_control_v3],
+ Mods = [megaco_ber_media_gateway_control_v1,
+ megaco_ber_media_gateway_control_v2,
+ megaco_ber_media_gateway_control_v3],
?BIN_LIB:decode_mini_message_dynamic(EC, Bin, Mods, binary);
-decode_mini_message([{version3,_},driver|EC], 1, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v1,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([driver|EC], 1, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v1,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message([{version3,_}|EC], 1, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v1,
+ AsnMod = megaco_ber_media_gateway_control_v1,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message(EC, 1, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v1,
+ AsnMod = megaco_ber_media_gateway_control_v1,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,_},driver|EC], 2, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v2,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([driver|EC], 2, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v2,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message([{version3,_}|EC], 2, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v2,
+ AsnMod = megaco_ber_media_gateway_control_v2,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message(EC, 2, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v2,
+ AsnMod = megaco_ber_media_gateway_control_v2,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,v3},driver|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v3,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3c},driver|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_prev3c,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3b},driver|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_prev3b,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([{version3,prev3a},driver|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_prev3a,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
-decode_mini_message([driver|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_drv_media_gateway_control_v3,
- ?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message([{version3,v3}|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v3,
+ AsnMod = megaco_ber_media_gateway_control_v3,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message([{version3,prev3c}|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_prev3c,
+ AsnMod = megaco_ber_media_gateway_control_prev3c,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message([{version3,prev3b}|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_prev3b,
+ AsnMod = megaco_ber_media_gateway_control_prev3b,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message([{version3,prev3a}|EC], 3, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_prev3a,
+ AsnMod = megaco_ber_media_gateway_control_prev3a,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary);
decode_mini_message(EC, 3, Bin) ->
- AsnMod = megaco_ber_bin_media_gateway_control_v3,
+ AsnMod = megaco_ber_media_gateway_control_v3,
?BIN_LIB:decode_mini_message(EC, Bin, AsnMod, binary).
diff --git a/lib/megaco/src/binary/megaco_binary_encoder_lib.erl b/lib/megaco/src/binary/megaco_binary_encoder_lib.erl
index 967ee93935..262889db39 100644
--- a/lib/megaco/src/binary/megaco_binary_encoder_lib.erl
+++ b/lib/megaco/src/binary/megaco_binary_encoder_lib.erl
@@ -275,7 +275,7 @@ decode_message_dynamic(_EC, _BadBin, _Mods, _Type) ->
{error, no_binary}.
-decode_message(EC, Bin, AsnMod, TransMod, binary) ->
+decode_message(EC, Bin, AsnMod, TransMod, _) ->
case asn1rt:decode(AsnMod, 'MegacoMessage', Bin) of
{ok, MegaMsg} ->
case EC of
@@ -286,19 +286,6 @@ decode_message(EC, Bin, AsnMod, TransMod, binary) ->
end;
{error, Reason} ->
{error, Reason}
- end;
-decode_message(EC, Bin, AsnMod, TransMod, io_list) ->
- ShallowIoList = erlang:binary_to_list(Bin),
- case asn1rt:decode(AsnMod, 'MegacoMessage', ShallowIoList) of
- {ok, MegaMsg} ->
- case EC of
- [native] ->
- {ok, MegaMsg};
- _ ->
- {ok, TransMod:tr_message(MegaMsg, decode, EC)}
- end;
- {error, Reason} ->
- {error, Reason}
end.
diff --git a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3a.set.asn b/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3a.set.asn
deleted file mode 100644
index b9ba7ffdb4..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3a.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3a.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3b.set.asn b/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3b.set.asn
deleted file mode 100644
index 0437bde310..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3b.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3b.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3c.set.asn b/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3c.set.asn
deleted file mode 100644
index e78055fbad..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_prev3c.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3c.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v1.set.asn b/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v1.set.asn
deleted file mode 100644
index 0f5a92dba1..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v1.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v1.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v2.set.asn b/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v2.set.asn
deleted file mode 100644
index 7fc82b127f..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v2.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v2.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v3.set.asn b/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v3.set.asn
deleted file mode 100644
index 1d7950a283..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_drv_media_gateway_control_v3.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v3.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_encoder.erl b/lib/megaco/src/binary/megaco_per_bin_encoder.erl
deleted file mode 100644
index f7280f4e04..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_encoder.erl
+++ /dev/null
@@ -1,447 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
-%%
-%% The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-
-%%
-%%----------------------------------------------------------------------
-%% Purpose : Handle ASN.1 PER encoding of Megaco/H.248
-%%----------------------------------------------------------------------
-
--module(megaco_per_bin_encoder).
-
--behaviour(megaco_encoder).
-
--export([encode_message/3, decode_message/3,
- decode_mini_message/3,
-
- encode_transaction/3,
- encode_action_requests/3,
- encode_action_request/3,
- encode_action_reply/3,
-
- version_of/2]).
-
-%% Backward compatible functions:
--export([encode_message/2, decode_message/2]).
-
--include_lib("megaco/src/engine/megaco_message_internal.hrl").
-
--define(V1_ASN1_MOD, megaco_per_bin_media_gateway_control_v1).
--define(V2_ASN1_MOD, megaco_per_bin_media_gateway_control_v2).
--define(V3_ASN1_MOD, megaco_per_bin_media_gateway_control_v3).
--define(PREV3A_ASN1_MOD, megaco_per_bin_media_gateway_control_prev3a).
--define(PREV3B_ASN1_MOD, megaco_per_bin_media_gateway_control_prev3b).
--define(PREV3C_ASN1_MOD, megaco_per_bin_media_gateway_control_prev3c).
--define(V1_ASN1_MOD_DRV, megaco_per_bin_drv_media_gateway_control_v1).
--define(V2_ASN1_MOD_DRV, megaco_per_bin_drv_media_gateway_control_v2).
--define(V3_ASN1_MOD_DRV, megaco_per_bin_drv_media_gateway_control_v3).
--define(PREV3A_ASN1_MOD_DRV, megaco_per_bin_drv_media_gateway_control_prev3a).
--define(PREV3B_ASN1_MOD_DRV, megaco_per_bin_drv_media_gateway_control_prev3b).
--define(PREV3C_ASN1_MOD_DRV, megaco_per_bin_drv_media_gateway_control_prev3c).
-
--define(V1_TRANS_MOD, megaco_binary_transformer_v1).
--define(V2_TRANS_MOD, megaco_binary_transformer_v2).
--define(V3_TRANS_MOD, megaco_binary_transformer_v3).
--define(PREV3A_TRANS_MOD, megaco_binary_transformer_prev3a).
--define(PREV3B_TRANS_MOD, megaco_binary_transformer_prev3b).
--define(PREV3C_TRANS_MOD, megaco_binary_transformer_prev3c).
-
--define(BIN_LIB, megaco_binary_encoder_lib).
-
-
-%%----------------------------------------------------------------------
-%% Detect (check/get) message version
-%% Return {ok, Version} | {error, Reason}
-%%----------------------------------------------------------------------
-
-version_of([{version3,v3},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?V3_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,prev3c},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?PREV3C_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,prev3b},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?PREV3B_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,prev3a},driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?PREV3A_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([driver|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD_DRV, ?V2_ASN1_MOD_DRV, ?V3_ASN1_MOD_DRV],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,v3}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?V3_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,prev3c}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?PREV3C_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,prev3b}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?PREV3B_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-version_of([{version3,prev3a}|EC], Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?PREV3A_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-version_of(EC, Binary) ->
- Decoders = [?V1_ASN1_MOD, ?V2_ASN1_MOD, ?V3_ASN1_MOD],
- ?BIN_LIB:version_of(EC, Binary, 1, Decoders).
-
-
-%%----------------------------------------------------------------------
-%% Convert a 'MegacoMessage' record into a binary
-%% Return {ok, Binary} | {error, Reason}
-%%----------------------------------------------------------------------
-
-encode_message(EC,
- #'MegacoMessage'{mess = #'Message'{version = V}} = MegaMsg) ->
- encode_message(EC, V, MegaMsg).
-
-
-%% -- Version 1 --
-
-encode_message([{version3, _},driver|EC], 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([driver|EC], 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,_}|EC], 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-encode_message(EC, 1, MegaMsg) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-
-%% -- Version 2 --
-
-encode_message([{version3,_},driver|EC], 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([driver|EC], 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,_}|EC], 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-encode_message(EC, 2, MegaMsg) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-
-%% -- Version 3 --
-
-encode_message([{version3,v3},driver|EC], 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3c},driver|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3C_ASN1_MOD_DRV,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3b},driver|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3B_ASN1_MOD_DRV,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3a},driver|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3A_ASN1_MOD_DRV,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([driver|EC], 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,v3}|EC], 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3c}|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3C_ASN1_MOD,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3b}|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3B_ASN1_MOD,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-encode_message([{version3,prev3a}|EC], 3, MegaMsg) ->
- AsnMod = ?PREV3A_ASN1_MOD,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-encode_message(EC, 3, MegaMsg) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:encode_message(EC, MegaMsg, AsnMod, TransMod, io_list).
-
-
-%%----------------------------------------------------------------------
-%% Convert a transaction (or transactions in the case of ack) record(s)
-%% into a binary
-%% Return {ok, Binary} | {error, Reason}
-%%----------------------------------------------------------------------
-
-%% encode_transaction([] = EC, 1, Trans) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([native] = EC, 1, Trans) ->
-%% AsnMod = ?V1_ASN1_MOD,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([driver|EC], 1, Trans) ->
-%% AsnMod = ?V1_ASN1_MOD_DRV,
-%% TransMod = ?V1_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-encode_transaction(_EC, 1, _Trans) ->
- %% AsnMod = ?V1_ASN1_MOD,
- %% TransMod = ?V1_TRANS_MOD,
- %% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
- %% io_list);
- {error, not_implemented};
-
-%% encode_transaction([] = EC, 2, Trans) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([native] = EC, 2, Trans) ->
-%% AsnMod = ?V2_ASN1_MOD,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([driver|EC], 2, Trans) ->
-%% AsnMod = ?V2_ASN1_MOD_DRV,
-%% TransMod = ?V2_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-encode_transaction(_EC, 2, _Trans) ->
- %% AsnMod = ?V2_ASN1_MOD,
- %% TransMod = ?V2_TRANS_MOD,
- %% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
- %% io_list).
- {error, not_implemented};
-
-%% encode_transaction([] = EC, 3, Trans) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([native] = EC, 3, Trans) ->
-%% AsnMod = ?V3_ASN1_MOD,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-%% encode_transaction([driver|EC], 3, Trans) ->
-%% AsnMod = ?V3_ASN1_MOD_DRV,
-%% TransMod = ?V3_TRANS_MOD,
-%% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod,
-%% io_list);
-encode_transaction(_EC, 3, _Trans) ->
- %% AsnMod = ?V3_ASN1_MOD,
- %% TransMod = ?V3_TRANS_MOD,
- %% ?BIN_LIB:encode_transaction(EC, Trans, AsnMod, TransMod, %% io_list).
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a list of ActionRequest record's into a binary
-%% Return {ok, DeepIoList} | {error, Reason}
-%%----------------------------------------------------------------------
-encode_action_requests(_EC, 1, ActReqs) when is_list(ActReqs) ->
- %% ?BIN_LIB:encode_action_requests(EC, ActReqs,
- %% ?V1_ASN1_MOD,
- %% ?V1_TRANS_MOD,
- %% io_list);
- {error, not_implemented};
-encode_action_requests(_EC, 2, ActReqs) when is_list(ActReqs) ->
- %% ?BIN_LIB:encode_action_requests(EC, ActReqs,
- %% ?V1_ASN1_MOD,
- %% ?V1_TRANS_MOD,
- %% io_list).
- {error, not_implemented};
-encode_action_requests(_EC, 3, ActReqs) when is_list(ActReqs) ->
- %% ?BIN_LIB:encode_action_requests(EC, ActReqs,
- %% ?V1_ASN1_MOD,
- %% ?V1_TRANS_MOD,
- %% io_list).
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a ActionRequest record into a binary
-%% Return {ok, DeepIoList} | {error, Reason}
-%%----------------------------------------------------------------------
-encode_action_request(_EC, 1, _ActReq) ->
- %% ?BIN_LIB:encode_action_request(EC, ActReq,
- %% ?V1_ASN1_MOD,
- %% ?V1_TRANS_MOD,
- %% io_list);
- {error, not_implemented};
-encode_action_request(_EC, 2, _ActReq) ->
- %% ?BIN_LIB:encode_action_request(EC, ActReq,
- %% ?V1_ASN1_MOD,
- %% ?V1_TRANS_MOD,
- %% io_list).
- {error, not_implemented};
-encode_action_request(_EC, 3, _ActReq) ->
- %% ?BIN_LIB:encode_action_request(EC, ActReq,
- %% ?V1_ASN1_MOD,
- %% ?V1_TRANS_MOD,
- %% io_list).
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a action reply into a deep io list
-%% Not yest supported by this binary codec!
-%% Return {ok, DeepIoList} | {error, Reason}
-%%----------------------------------------------------------------------
-
-encode_action_reply(_EC, _V, _AcionReply) ->
- {error, not_implemented}.
-
-
-%%----------------------------------------------------------------------
-%% Convert a binary into a 'MegacoMessage' record
-%% Return {ok, MegacoMessageRecord} | {error, Reason}
-%%----------------------------------------------------------------------
-
-decode_message(EC, Binary) ->
- decode_message(EC, 1, Binary).
-
-%% PER does not support partial decode, so this means V1
-decode_message(EC, dynamic, Binary) ->
- decode_message(EC, 1, Binary);
-
-
-%% -- Version 1 --
-
-decode_message([{version3,_},driver|EC], 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([driver|EC], 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD_DRV,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,_}|EC], 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, 1, Binary) ->
- AsnMod = ?V1_ASN1_MOD,
- TransMod = ?V1_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-
-%% -- Version 2 --
-
-decode_message([{version3,_},driver|EC], 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([driver|EC], 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD_DRV,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,_}|EC], 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, 2, Binary) ->
- AsnMod = ?V2_ASN1_MOD,
- TransMod = ?V2_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-
-%% -- Version 3 --
-
-decode_message([{version3,v3},driver|EC], 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3c},driver|EC], 3, Binary) ->
- AsnMod = ?PREV3C_ASN1_MOD_DRV,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3b},driver|EC], 3, Binary) ->
- AsnMod = ?PREV3B_ASN1_MOD_DRV,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3a},driver|EC], 3, Binary) ->
- AsnMod = ?PREV3A_ASN1_MOD_DRV,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([driver|EC], 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD_DRV,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,v3}|EC], 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3c}|EC], 3, Binary) ->
- AsnMod = ?PREV3C_ASN1_MOD,
- TransMod = ?PREV3C_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3b}|EC], 3, Binary) ->
- AsnMod = ?PREV3B_ASN1_MOD,
- TransMod = ?PREV3B_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-decode_message([{version3,prev3a}|EC], 3, Binary) ->
- AsnMod = ?PREV3A_ASN1_MOD,
- TransMod = ?PREV3A_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary);
-
-%% All values we need to take (special) care of has been delt with,
-%% so just pass the rest on
-decode_message(EC, 3, Binary) ->
- AsnMod = ?V3_ASN1_MOD,
- TransMod = ?V3_TRANS_MOD,
- ?BIN_LIB:decode_message(EC, Binary, AsnMod, TransMod, binary).
-
-
-decode_mini_message(_EC, _Vsn, _Bin) ->
- {error, not_implemented}.
diff --git a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3a.set.asn b/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3a.set.asn
deleted file mode 100644
index b9ba7ffdb4..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3a.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3a.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3b.set.asn b/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3b.set.asn
deleted file mode 100644
index 0437bde310..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3b.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3b.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3c.set.asn b/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3c.set.asn
deleted file mode 100644
index e78055fbad..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_prev3c.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-prev3c.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v1.set.asn b/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v1.set.asn
deleted file mode 100644
index 0f5a92dba1..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v1.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v1.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v2.set.asn b/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v2.set.asn
deleted file mode 100644
index 7fc82b127f..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v2.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v2.asn
diff --git a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v3.set.asn b/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v3.set.asn
deleted file mode 100644
index 1d7950a283..0000000000
--- a/lib/megaco/src/binary/megaco_per_bin_media_gateway_control_v3.set.asn
+++ /dev/null
@@ -1 +0,0 @@
-MEDIA-GATEWAY-CONTROL-v3.asn
diff --git a/lib/megaco/src/binary/modules.mk b/lib/megaco/src/binary/modules.mk
index a86ce2aecc..bbaf087ceb 100644
--- a/lib/megaco/src/binary/modules.mk
+++ b/lib/megaco/src/binary/modules.mk
@@ -27,19 +27,6 @@ MODULES = \
megaco_ber_media_gateway_control_prev3b \
megaco_ber_media_gateway_control_prev3c \
megaco_ber_media_gateway_control_v3 \
- megaco_ber_bin_encoder \
- megaco_ber_bin_media_gateway_control_v1 \
- megaco_ber_bin_media_gateway_control_v2 \
- megaco_ber_bin_media_gateway_control_prev3a \
- megaco_ber_bin_media_gateway_control_prev3b \
- megaco_ber_bin_media_gateway_control_prev3c \
- megaco_ber_bin_media_gateway_control_v3 \
- megaco_ber_bin_drv_media_gateway_control_v1 \
- megaco_ber_bin_drv_media_gateway_control_v2 \
- megaco_ber_bin_drv_media_gateway_control_prev3a \
- megaco_ber_bin_drv_media_gateway_control_prev3b \
- megaco_ber_bin_drv_media_gateway_control_prev3c \
- megaco_ber_bin_drv_media_gateway_control_v3 \
megaco_per_encoder \
megaco_per_media_gateway_control_v1 \
megaco_per_media_gateway_control_v2 \
@@ -47,19 +34,6 @@ MODULES = \
megaco_per_media_gateway_control_prev3b \
megaco_per_media_gateway_control_prev3c \
megaco_per_media_gateway_control_v3 \
- megaco_per_bin_encoder \
- megaco_per_bin_media_gateway_control_v1 \
- megaco_per_bin_media_gateway_control_v2 \
- megaco_per_bin_media_gateway_control_prev3a \
- megaco_per_bin_media_gateway_control_prev3b \
- megaco_per_bin_media_gateway_control_prev3c \
- megaco_per_bin_media_gateway_control_v3 \
- megaco_per_bin_drv_media_gateway_control_v1 \
- megaco_per_bin_drv_media_gateway_control_v2 \
- megaco_per_bin_drv_media_gateway_control_prev3a \
- megaco_per_bin_drv_media_gateway_control_prev3b \
- megaco_per_bin_drv_media_gateway_control_prev3c \
- megaco_per_bin_drv_media_gateway_control_v3 \
megaco_binary_name_resolver_v1 \
megaco_binary_name_resolver_v2 \
megaco_binary_name_resolver_prev3a \
@@ -85,44 +59,20 @@ ASN1_PREV3C_SPEC = MEDIA-GATEWAY-CONTROL-prev3c
ASN1_V3_SPEC = MEDIA-GATEWAY-CONTROL-v3
BER_ASN1_V1_SPEC = megaco_ber_media_gateway_control_v1
-BER_BIN_ASN1_V1_SPEC = megaco_ber_bin_media_gateway_control_v1
-BER_BIN_DRV_ASN1_V1_SPEC = megaco_ber_bin_drv_media_gateway_control_v1
PER_ASN1_V1_SPEC = megaco_per_media_gateway_control_v1
-PER_BIN_ASN1_V1_SPEC = megaco_per_bin_media_gateway_control_v1
-PER_BIN_DRV_ASN1_V1_SPEC = megaco_per_bin_drv_media_gateway_control_v1
BER_ASN1_V2_SPEC = megaco_ber_media_gateway_control_v2
-BER_BIN_ASN1_V2_SPEC = megaco_ber_bin_media_gateway_control_v2
-BER_BIN_DRV_ASN1_V2_SPEC = megaco_ber_bin_drv_media_gateway_control_v2
PER_ASN1_V2_SPEC = megaco_per_media_gateway_control_v2
-PER_BIN_ASN1_V2_SPEC = megaco_per_bin_media_gateway_control_v2
-PER_BIN_DRV_ASN1_V2_SPEC = megaco_per_bin_drv_media_gateway_control_v2
BER_ASN1_PREV3A_SPEC = megaco_ber_media_gateway_control_prev3a
-BER_BIN_ASN1_PREV3A_SPEC = megaco_ber_bin_media_gateway_control_prev3a
-BER_BIN_DRV_ASN1_PREV3A_SPEC = megaco_ber_bin_drv_media_gateway_control_prev3a
PER_ASN1_PREV3A_SPEC = megaco_per_media_gateway_control_prev3a
-PER_BIN_ASN1_PREV3A_SPEC = megaco_per_bin_media_gateway_control_prev3a
-PER_BIN_DRV_ASN1_PREV3A_SPEC = megaco_per_bin_drv_media_gateway_control_prev3a
BER_ASN1_PREV3B_SPEC = megaco_ber_media_gateway_control_prev3b
-BER_BIN_ASN1_PREV3B_SPEC = megaco_ber_bin_media_gateway_control_prev3b
-BER_BIN_DRV_ASN1_PREV3B_SPEC = megaco_ber_bin_drv_media_gateway_control_prev3b
PER_ASN1_PREV3B_SPEC = megaco_per_media_gateway_control_prev3b
-PER_BIN_ASN1_PREV3B_SPEC = megaco_per_bin_media_gateway_control_prev3b
-PER_BIN_DRV_ASN1_PREV3B_SPEC = megaco_per_bin_drv_media_gateway_control_prev3b
BER_ASN1_PREV3C_SPEC = megaco_ber_media_gateway_control_prev3c
-BER_BIN_ASN1_PREV3C_SPEC = megaco_ber_bin_media_gateway_control_prev3c
-BER_BIN_DRV_ASN1_PREV3C_SPEC = megaco_ber_bin_drv_media_gateway_control_prev3c
PER_ASN1_PREV3C_SPEC = megaco_per_media_gateway_control_prev3c
-PER_BIN_ASN1_PREV3C_SPEC = megaco_per_bin_media_gateway_control_prev3c
-PER_BIN_DRV_ASN1_PREV3C_SPEC = megaco_per_bin_drv_media_gateway_control_prev3c
BER_ASN1_V3_SPEC = megaco_ber_media_gateway_control_v3
-BER_BIN_ASN1_V3_SPEC = megaco_ber_bin_media_gateway_control_v3
-BER_BIN_DRV_ASN1_V3_SPEC = megaco_ber_bin_drv_media_gateway_control_v3
PER_ASN1_V3_SPEC = megaco_per_media_gateway_control_v3
-PER_BIN_ASN1_V3_SPEC = megaco_per_bin_media_gateway_control_v3
-PER_BIN_DRV_ASN1_V3_SPEC = megaco_per_bin_drv_media_gateway_control_v3
diff --git a/lib/megaco/test/megaco_actions_test.erl b/lib/megaco/test/megaco_actions_test.erl
index 2efb6e834a..6d0e80281d 100644
--- a/lib/megaco/test/megaco_actions_test.erl
+++ b/lib/megaco/test/megaco_actions_test.erl
@@ -80,8 +80,7 @@ end_per_testcase(Case, Config) ->
all() ->
[pretty_text, flex_pretty_text, compact_text,
- flex_compact_text, erl_dist, erl_dist_mc, ber_bin,
- ber_bin_drv, ber_bin_native, ber_bin_drv_native].
+ flex_compact_text, erl_dist, erl_dist_mc].
groups() ->
[].
@@ -170,39 +169,6 @@ erl_dist_mc(Config) when is_list(Config) ->
req_and_rep(Config, Codec, Version, EncodingConfig).
-ber_bin(suite) ->
- [];
-ber_bin(doc) ->
- [];
-ber_bin(Config) when is_list(Config) ->
- ?SKIP(currently_not_supported_by_asn1).
-
-
-ber_bin_drv(suite) ->
- [];
-ber_bin_drv(doc) ->
- [];
-ber_bin_drv(Config) when is_list(Config) ->
- ?SKIP(currently_not_supported_by_asn1).
-
-
-ber_bin_native(suite) ->
- [];
-ber_bin_native(doc) ->
- [];
-ber_bin_native(Config) when is_list(Config) ->
- ?SKIP(currently_not_supported_by_asn1).
-
-
-ber_bin_drv_native(suite) ->
- [];
-ber_bin_drv_native(doc) ->
- [];
-ber_bin_drv_native(Config) when is_list(Config) ->
- ?SKIP(currently_not_supported_by_asn1).
-
-
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
req_and_rep(Config, Codec, _Version, EC) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_call_flow_test.erl b/lib/megaco/test/megaco_call_flow_test.erl
index b9d64ca8b2..d5888018cd 100644
--- a/lib/megaco/test/megaco_call_flow_test.erl
+++ b/lib/megaco/test/megaco_call_flow_test.erl
@@ -25,7 +25,6 @@
%% megaco_call_flow_test:compact_text().
%% megaco_call_flow_test:bin().
%% megaco_call_flow_test:asn1_ber().
-%% megaco_call_flow_test:asn1_ber_bin().
%% megaco_call_flow_test:asn1_per().
%% megaco_call_flow_test:erl_dist().
%% megaco_call_flow_test:compressed_erl_dist().
@@ -62,7 +61,7 @@ all() ->
groups() ->
[{text, [], [pretty, compact]},
{flex, [], [pretty_flex, compact_flex]},
- {binary, [], [bin, ber, ber_bin, per]}].
+ {binary, [], [bin, ber, per]}].
init_per_group(_GroupName, Config) ->
Config.
@@ -106,12 +105,6 @@ ber(Config) when is_list(Config) ->
?ACQUIRE_NODES(1, Config),
asn1_ber().
-ber_bin(suite) ->
- [];
-ber_bin(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- asn1_ber_bin().
-
per(suite) ->
[];
per(Config) when is_list(Config) ->
@@ -1198,8 +1191,7 @@ encoders() ->
{megaco_pretty_text_encoder, [], []},
{megaco_compact_text_encoder, [], []},
{megaco_binary_encoder, [], [native]},
- %% {megaco_ber_encoder, [], [native]},
- %% {megaco_ber_bin_encoder, [], [native]},
+ {megaco_ber_encoder, [], [native]},
{megaco_per_encoder, [], [native]},
{megaco_erl_dist_encoder, [], []},
{megaco_erl_dist_encoder, [compressed], [compressed]}
@@ -1214,7 +1206,6 @@ pretty_mod({Mod, Opt, _Opt2}) ->
megaco_compact_text_encoder -> compact_text;
megaco_binary_encoder -> asn1_ber;
megaco_ber_encoder -> asn1_ber_old;
- megaco_ber_bin_encoder -> asn1_ber_bin;
megaco_per_encoder -> asn1_per;
megaco_erl_dist_encoder when Opt == [] -> standard_erl;
megaco_erl_dist_encoder when Opt == [compressed] -> compressed_erl;
@@ -1263,13 +1254,6 @@ asn1_ber() ->
All = [encode(Slogan, Msg, Encoder) || {Slogan, Msg} <- messages()],
compute_res(All).
-asn1_ber_bin() ->
- Default = [],
- Native = [native],
- Encoder = {megaco_ber_bin_encoder, Default, Native},
- All = [encode(Slogan, Msg, Encoder) || {Slogan, Msg} <- messages()],
- compute_res(All).
-
asn1_per() ->
Default = [],
Native = [native],
@@ -1634,7 +1618,7 @@ gen_ber_header() ->
%% Generate headerfile for asn.1 BER test in C
%%----------------------------------------------------------------------
gen_ber_bin_header() ->
- Encoder = {megaco_ber_bin_encoder, [], []},
+ Encoder = {megaco_ber_encoder, [], []},
L = [{S, gen_byte_msg(Msg, Encoder)} || {S, Msg} <- messages()],
gen_header_file_binary(L).
diff --git a/lib/megaco/test/megaco_codec_prev3a_test.erl b/lib/megaco/test/megaco_codec_prev3a_test.erl
index d50e72aef1..4f1160b93f 100644
--- a/lib/megaco/test/megaco_codec_prev3a_test.erl
+++ b/lib/megaco/test/megaco_codec_prev3a_test.erl
@@ -63,12 +63,8 @@
ber_test_msgs/1,
- ber_bin_test_msgs/1,
-
per_test_msgs/1,
- per_bin_test_msgs/1,
-
erl_dist_m_test_msgs/1,
tickets/0,
@@ -280,17 +276,14 @@ groups() ->
[{group, pretty}, {group, flex_pretty},
{group, compact}, {group, flex_compact}]},
{binary, [],
- [{group, bin}, {group, ber}, {group, ber_bin},
- {group, per}, {group, per_bin}]},
+ [{group, bin}, {group, ber}, {group, per}]},
{erl_dist, [], [{group, erl_dist_m}]},
{pretty, [], [pretty_test_msgs]},
{compact, [], [compact_test_msgs]},
{flex_pretty, [], flex_pretty_cases()},
{flex_compact, [], flex_compact_cases()},
{bin, [], [bin_test_msgs]}, {ber, [], [ber_test_msgs]},
- {ber_bin, [], [ber_bin_test_msgs]},
{per, [], [per_test_msgs]},
- {per_bin, [], [per_bin_test_msgs]},
{erl_dist_m, [], [erl_dist_m_test_msgs]},
{tickets, [],
[{group, compact_tickets},
@@ -1106,17 +1099,6 @@ ber_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ber_bin_test_msgs(suite) ->
- [];
-ber_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1(binary) ++ msgs4(binary) ++ msgs5(binary) ++ msgs6(binary),
- DynamicDecode = true,
- test_msgs(megaco_ber_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
per_test_msgs(suite) ->
[];
per_test_msgs(Config) when is_list(Config) ->
@@ -1128,17 +1110,6 @@ per_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-per_bin_test_msgs(suite) ->
- [];
-per_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1(binary) ++ msgs4(binary) ++ msgs5(binary) ++ msgs6(binary),
- DynamicDecode = false,
- test_msgs(megaco_per_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
erl_dist_m_test_msgs(suite) ->
[];
erl_dist_m_test_msgs(Config) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_codec_prev3b_test.erl b/lib/megaco/test/megaco_codec_prev3b_test.erl
index eaab8f37c1..4bd49365e7 100644
--- a/lib/megaco/test/megaco_codec_prev3b_test.erl
+++ b/lib/megaco/test/megaco_codec_prev3b_test.erl
@@ -63,12 +63,8 @@
ber_test_msgs/1,
- ber_bin_test_msgs/1,
-
per_test_msgs/1,
- per_bin_test_msgs/1,
-
erl_dist_m_test_msgs/1,
tickets/0,
@@ -296,17 +292,14 @@ groups() ->
[{group, pretty}, {group, flex_pretty},
{group, compact}, {group, flex_compact}]},
{binary, [],
- [{group, bin}, {group, ber}, {group, ber_bin},
- {group, per}, {group, per_bin}]},
+ [{group, bin}, {group, ber}, {group, per}]},
{erl_dist, [], [{group, erl_dist_m}]},
{pretty, [], [pretty_test_msgs]},
{compact, [], [compact_test_msgs]},
{flex_pretty, [], flex_pretty_cases()},
{flex_compact, [], flex_compact_cases()},
{bin, [], [bin_test_msgs]}, {ber, [], [ber_test_msgs]},
- {ber_bin, [], [ber_bin_test_msgs]},
{per, [], [per_test_msgs]},
- {per_bin, [], [per_bin_test_msgs]},
{erl_dist_m, [], [erl_dist_m_test_msgs]},
{tickets, [],
[{group, compact_tickets},
@@ -1171,16 +1164,6 @@ ber_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ber_bin_test_msgs(suite) ->
- [];
-ber_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1(binary) ++ msgs4(binary) ++ msgs5(binary) ++ msgs6(binary),
- DynamicDecode = true,
- test_msgs(megaco_ber_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
per_test_msgs(suite) ->
[];
@@ -1193,17 +1176,6 @@ per_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-per_bin_test_msgs(suite) ->
- [];
-per_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1(binary) ++ msgs4(binary) ++ msgs5(binary) ++ msgs6(binary),
- DynamicDecode = false,
- test_msgs(megaco_per_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
erl_dist_m_test_msgs(suite) ->
[];
erl_dist_m_test_msgs(Config) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_codec_prev3c_test.erl b/lib/megaco/test/megaco_codec_prev3c_test.erl
index 7f9c0fe4e7..baa1c7f547 100644
--- a/lib/megaco/test/megaco_codec_prev3c_test.erl
+++ b/lib/megaco/test/megaco_codec_prev3c_test.erl
@@ -65,12 +65,8 @@
ber_test_msgs/1,
- ber_bin_test_msgs/1,
-
per_test_msgs/1,
- per_bin_test_msgs/1,
-
erl_dist_m_test_msgs/1,
tickets/0,
@@ -301,17 +297,14 @@ groups() ->
[{group, pretty}, {group, flex_pretty},
{group, compact}, {group, flex_compact}]},
{binary, [],
- [{group, bin}, {group, ber}, {group, ber_bin},
- {group, per}, {group, per_bin}]},
+ [{group, bin}, {group, ber}, {group, per}]},
{erl_dist, [], [{group, erl_dist_m}]},
{pretty, [], [pretty_test_msgs]},
{compact, [], [compact_test_msgs]},
{flex_pretty, [], flex_pretty_cases()},
{flex_compact, [], flex_compact_cases()},
{bin, [], [bin_test_msgs]}, {ber, [], [ber_test_msgs]},
- {ber_bin, [], [ber_bin_test_msgs]},
{per, [], [per_test_msgs]},
- {per_bin, [], [per_bin_test_msgs]},
{erl_dist_m, [], [erl_dist_m_test_msgs]},
{tickets, [],
[{group, compact_tickets},
@@ -823,21 +816,6 @@ ber_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ber_bin_test_msgs(suite) ->
- [];
-ber_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs =
- msgs1a(binary) ++
- msgs5(binary) ++
- msgs6(binary) ++
- msgs7(binary),
- DynamicDecode = true,
- test_msgs(megaco_ber_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
per_test_msgs(suite) ->
[];
per_test_msgs(Config) when is_list(Config) ->
@@ -853,21 +831,6 @@ per_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-per_bin_test_msgs(suite) ->
- [];
-per_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs =
- msgs1a(binary) ++
- msgs5(binary) ++
- msgs6(binary) ++
- msgs7(binary),
- DynamicDecode = false,
- test_msgs(megaco_per_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
erl_dist_m_test_msgs(suite) ->
[];
erl_dist_m_test_msgs(Config) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_codec_v1_test.erl b/lib/megaco/test/megaco_codec_v1_test.erl
index e9c19605dd..86f332fde0 100644
--- a/lib/megaco/test/megaco_codec_v1_test.erl
+++ b/lib/megaco/test/megaco_codec_v1_test.erl
@@ -66,12 +66,8 @@
ber_test_msgs/1,
- ber_bin_test_msgs/1,
-
per_test_msgs/1,
- per_bin_test_msgs/1,
-
erl_dist_m_test_msgs/1,
tickets/0,
@@ -476,9 +472,7 @@ groups() ->
{group, flex_compact}]},
{binary, [], [{group, bin},
{group, ber},
- {group, ber_bin},
- {group, per},
- {group, per_bin}]},
+ {group, per}]},
{erl_dist, [], [{group, erl_dist_m}]},
{pretty, [], [pretty_test_msgs]},
{compact, [], [compact_test_msgs]},
@@ -486,9 +480,7 @@ groups() ->
{flex_compact, [], flex_compact_cases()},
{bin, [], [bin_test_msgs]},
{ber, [], [ber_test_msgs]},
- {ber_bin, [], [ber_bin_test_msgs]},
{per, [], [per_test_msgs]},
- {per_bin, [], [per_bin_test_msgs]},
{erl_dist_m, [], [erl_dist_m_test_msgs]},
{tickets, [], [{group, compact_tickets},
{group, pretty_tickets},
@@ -1266,17 +1258,6 @@ ber_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ber_bin_test_msgs(suite) ->
- [];
-ber_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1(),
- DynamicDecode = true,
- test_msgs(megaco_ber_bin_encoder, DynamicDecode, [], Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
per_test_msgs(suite) ->
[];
per_test_msgs(Config) when is_list(Config) ->
@@ -1288,17 +1269,6 @@ per_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-per_bin_test_msgs(suite) ->
- [];
-per_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1(),
- DynamicDecode = false,
- test_msgs(megaco_per_bin_encoder, DynamicDecode, [], Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
erl_dist_m_test_msgs(suite) ->
[];
erl_dist_m_test_msgs(Config) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_codec_v2_test.erl b/lib/megaco/test/megaco_codec_v2_test.erl
index a44f74166c..e8db9e1cb1 100644
--- a/lib/megaco/test/megaco_codec_v2_test.erl
+++ b/lib/megaco/test/megaco_codec_v2_test.erl
@@ -64,12 +64,8 @@
ber_test_msgs/1,
- ber_bin_test_msgs/1,
-
per_test_msgs/1,
- per_bin_test_msgs/1,
-
erl_dist_m_test_msgs/1,
tickets/0,
@@ -447,17 +443,14 @@ groups() ->
[{group, pretty}, {group, flex_pretty},
{group, compact}, {group, flex_compact}]},
{binary, [],
- [{group, bin}, {group, ber}, {group, ber_bin},
- {group, per}, {group, per_bin}]},
+ [{group, bin}, {group, ber}, {group, per}]},
{erl_dist, [], [{group, erl_dist_m}]},
{pretty, [], [pretty_test_msgs]},
{compact, [], [compact_test_msgs]},
{flex_pretty, [], flex_pretty_cases()},
{flex_compact, [], flex_compact_cases()},
{bin, [], [bin_test_msgs]}, {ber, [], [ber_test_msgs]},
- {ber_bin, [], [ber_bin_test_msgs]},
{per, [], [per_test_msgs]},
- {per_bin, [], [per_bin_test_msgs]},
{erl_dist_m, [], [erl_dist_m_test_msgs]},
{tickets, [],
[{group, compact_tickets}, {group, pretty_tickets},
@@ -1285,17 +1278,6 @@ ber_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ber_bin_test_msgs(suite) ->
- [];
-ber_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1() ++ msgs4(),
- DynamicDecode = true,
- test_msgs(megaco_ber_bin_encoder, DynamicDecode, [], Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
per_test_msgs(suite) ->
[];
per_test_msgs(Config) when is_list(Config) ->
@@ -1307,17 +1289,6 @@ per_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-per_bin_test_msgs(suite) ->
- [];
-per_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs = msgs1() ++ msgs4(),
- DynamicDecode = false,
- test_msgs(megaco_per_bin_encoder, DynamicDecode, [], Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
erl_dist_m_test_msgs(suite) ->
[];
erl_dist_m_test_msgs(Config) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_codec_v3_test.erl b/lib/megaco/test/megaco_codec_v3_test.erl
index 2c35ce13b3..67805479f9 100644
--- a/lib/megaco/test/megaco_codec_v3_test.erl
+++ b/lib/megaco/test/megaco_codec_v3_test.erl
@@ -56,9 +56,7 @@
flex_compact_dm_timers8/1,
bin_test_msgs/1,
ber_test_msgs/1,
- ber_bin_test_msgs/1,
per_test_msgs/1,
- per_bin_test_msgs/1,
erl_dist_m_test_msgs/1,
tickets/0,
@@ -288,17 +286,14 @@ groups() ->
[{group, pretty}, {group, flex_pretty},
{group, compact}, {group, flex_compact}]},
{binary, [],
- [{group, bin}, {group, ber}, {group, ber_bin},
- {group, per}, {group, per_bin}]},
+ [{group, bin}, {group, ber}, {group, per}]},
{erl_dist, [], [{group, erl_dist_m}]},
{pretty, [], [pretty_test_msgs]},
{compact, [], [compact_test_msgs]},
{flex_pretty, [], flex_pretty_cases()},
{flex_compact, [], flex_compact_cases()},
{bin, [], [bin_test_msgs]}, {ber, [], [ber_test_msgs]},
- {ber_bin, [], [ber_bin_test_msgs]},
{per, [], [per_test_msgs]},
- {per_bin, [], [per_bin_test_msgs]},
{erl_dist_m, [], [erl_dist_m_test_msgs]},
{tickets, [],
[{group, compact_tickets},
@@ -823,22 +818,6 @@ ber_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-ber_bin_test_msgs(suite) ->
- [];
-ber_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs =
- msgs1a(binary) ++
- msgs5(binary) ++
- msgs6(binary) ++
- msgs7(binary) ++
- msgs8(binary),
- DynamicDecode = true,
- test_msgs(megaco_ber_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
per_test_msgs(suite) ->
[];
per_test_msgs(Config) when is_list(Config) ->
@@ -855,22 +834,6 @@ per_test_msgs(Config) when is_list(Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-per_bin_test_msgs(suite) ->
- [];
-per_bin_test_msgs(Config) when is_list(Config) ->
- ?ACQUIRE_NODES(1, Config),
- Msgs =
- msgs1a(binary) ++
- msgs5(binary) ++
- msgs6(binary) ++
- msgs7(binary) ++
- msgs8(binary),
- DynamicDecode = false,
- test_msgs(megaco_per_bin_encoder, DynamicDecode, ?EC, Msgs).
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
erl_dist_m_test_msgs(suite) ->
[];
erl_dist_m_test_msgs(Config) when is_list(Config) ->
diff --git a/lib/megaco/test/megaco_mess_test.erl b/lib/megaco/test/megaco_mess_test.erl
index 663ac8c329..f8be96c254 100644
--- a/lib/megaco/test/megaco_mess_test.erl
+++ b/lib/megaco/test/megaco_mess_test.erl
@@ -1393,7 +1393,7 @@ rarpaop_mgc_event_sequence(text, tcp) ->
rarpaop_mgc_event_sequence(binary, tcp) ->
Port = 2945,
TranspMod = megaco_tcp,
- EncMod = megaco_ber_bin_encoder,
+ EncMod = megaco_ber_encoder,
EncConf = [],
rarpaop_mgc_event_sequence(Port, TranspMod, EncMod, EncConf).
@@ -1680,7 +1680,7 @@ rarpaop_mg_event_sequence(text, tcp) ->
rarpaop_mg_event_sequence(Port, EncMod, EncConf);
rarpaop_mg_event_sequence(binary, tcp) ->
Port = 2945,
- EncMod = megaco_ber_bin_encoder,
+ EncMod = megaco_ber_encoder,
EncConf = [],
rarpaop_mg_event_sequence(Port, EncMod, EncConf).
diff --git a/lib/megaco/test/megaco_mib_test.erl b/lib/megaco/test/megaco_mib_test.erl
index 52d99d1442..ddc74ab741 100644
--- a/lib/megaco/test/megaco_mib_test.erl
+++ b/lib/megaco/test/megaco_mib_test.erl
@@ -647,13 +647,13 @@ mk_recv_info([{text,udp}|ET], Acc) ->
{port, 2944}],
mk_recv_info(ET, [RI|Acc]);
mk_recv_info([{binary,tcp}|ET], Acc) ->
- RI = [{encoding_module, megaco_ber_bin_encoder},
+ RI = [{encoding_module, megaco_ber_encoder},
{encoding_config, []},
{transport_module, megaco_tcp},
{port, 2945}],
mk_recv_info(ET, [RI|Acc]);
mk_recv_info([{binary,udp}|ET], Acc) ->
- RI = [{encoding_module, megaco_ber_bin_encoder},
+ RI = [{encoding_module, megaco_ber_encoder},
{encoding_config, []},
{transport_module, megaco_udp},
{port, 2945}],
@@ -1013,7 +1013,7 @@ start_mg(Node, Mid, Encoding, Transport, Verbosity) ->
{encoding_config, []},
{port,2944}];
binary ->
- [{encoding_module, megaco_ber_bin_encoder},
+ [{encoding_module, megaco_ber_encoder},
{encoding_config, []},
{port,2945}]
end,
diff --git a/lib/megaco/test/megaco_test_mg.erl b/lib/megaco/test/megaco_test_mg.erl
index ecb3cedc83..947f0eebbb 100644
--- a/lib/megaco/test/megaco_test_mg.erl
+++ b/lib/megaco/test/megaco_test_mg.erl
@@ -158,7 +158,7 @@ select_encoding(pretty_text) ->
select_encoding(compact_text) ->
{megaco_compact_text_encoder, 2944};
select_encoding(binary) ->
- {megaco_ber_bin_encoder, 2945};
+ {megaco_ber_encoder, 2945};
select_encoding(erl_dist) ->
{megaco_erl_dist_encoder, 2946};
select_encoding(Encoding) ->
diff --git a/lib/megaco/test/megaco_test_mgc.erl b/lib/megaco/test/megaco_test_mgc.erl
index 13c1cebe56..a964983861 100644
--- a/lib/megaco/test/megaco_test_mgc.erl
+++ b/lib/megaco/test/megaco_test_mgc.erl
@@ -135,7 +135,7 @@ select_encoding(pretty_text) ->
select_encoding(compact_text) ->
{megaco_compact_text_encoder, 2944};
select_encoding(binary) ->
- {megaco_ber_bin_encoder, 2945};
+ {megaco_ber_encoder, 2945};
select_encoding(erl_dist) ->
{megaco_erl_dist_encoder, 2946};
select_encoding(Encoding) ->
diff --git a/lib/observer/doc/src/notes.xml b/lib/observer/doc/src/notes.xml
index ea665eee88..4ec03782a7 100644
--- a/lib/observer/doc/src/notes.xml
+++ b/lib/observer/doc/src/notes.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>2004</year><year>2011</year>
+ <year>2004</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/odbc/doc/src/notes.xml b/lib/odbc/doc/src/notes.xml
index 5f6cf91961..7ba0307a45 100644
--- a/lib/odbc/doc/src/notes.xml
+++ b/lib/odbc/doc/src/notes.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>2004</year><year>2011</year>
+ <year>2004</year><year>2012</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/orber/src/Makefile b/lib/orber/src/Makefile
index 72610def2b..6eb659407d 100644
--- a/lib/orber/src/Makefile
+++ b/lib/orber/src/Makefile
@@ -200,8 +200,7 @@ ERL_COMPILE_FLAGS += $(ERL_IDL_FLAGS) \
+'{attribute,insert,app_vsn,"orber_$(ORBER_VSN)"}' \
-D'ORBVSN="$(ORBER_VSN)"'
-ASN_FLAGS = -bber_bin +der +compact_bit_string +optimize \
- +nowarn_unused_record
+ASN_FLAGS = -bber +der +compact_bit_string +nowarn_unused_record
# ----------------------------------------------------
# Targets
diff --git a/lib/percept/doc/src/notes.xml b/lib/percept/doc/src/notes.xml
index 1ac1a5ab62..dd70cfe994 100644
--- a/lib/percept/doc/src/notes.xml
+++ b/lib/percept/doc/src/notes.xml
@@ -32,6 +32,21 @@
</header>
<p>This document describes the changes made to the Percept application.</p>
+<section><title>Percept 0.8.7</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ Add missing modules in app-file</p>
+ <p>
+ Own Id: OTP-10439</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Percept 0.8.6.1</title>
<section><title>Improvements and New Features</title>
diff --git a/lib/percept/src/percept.app.src b/lib/percept/src/percept.app.src
index 7b20093ece..cf4a9fc438 100644
--- a/lib/percept/src/percept.app.src
+++ b/lib/percept/src/percept.app.src
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2009. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/percept/vsn.mk b/lib/percept/vsn.mk
index 9267a41055..f868246f7b 100644
--- a/lib/percept/vsn.mk
+++ b/lib/percept/vsn.mk
@@ -1 +1 @@
-PERCEPT_VSN = 0.8.6.1
+PERCEPT_VSN = 0.8.7
diff --git a/lib/public_key/asn1/Makefile b/lib/public_key/asn1/Makefile
index 957c332cad..763b788e53 100644
--- a/lib/public_key/asn1/Makefile
+++ b/lib/public_key/asn1/Makefile
@@ -66,7 +66,7 @@ EBIN = ../ebin
EXTRA_ERLC_FLAGS =
ERL_COMPILE_FLAGS += $(EXTRA_ERLC_FLAGS)
-ASN_FLAGS = -bber_bin +der +compact_bit_string +optimize +noobj +asn1config +inline +nif
+ASN_FLAGS = -bber +der +compact_bit_string +noobj +asn1config +inline
# ----------------------------------------------------
# Targets
diff --git a/lib/public_key/doc/src/notes.xml b/lib/public_key/doc/src/notes.xml
index d895042570..a5e8beedf0 100644
--- a/lib/public_key/doc/src/notes.xml
+++ b/lib/public_key/doc/src/notes.xml
@@ -34,6 +34,41 @@
<file>notes.xml</file>
</header>
+<section><title>Public_Key 0.17</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ ssh_decode now handles comments, at the end of the line,
+ containing withe spaces correctly</p>
+ <p>
+ Own Id: OTP-9361</p>
+ </item>
+ <item>
+ <p>
+ Add missing references to sha224 and sha384</p>
+ <p>
+ Own Id: OTP-9362 Aux Id: seq12116 </p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ public_key now supports PKCS-10 and includes exprimental
+ support for PKCS-7</p>
+ <p>
+ Own Id: OTP-10509 Aux Id: kunagi-291 [202] </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Public_Key 0.16</title>
<section><title>Improvements and New Features</title>
diff --git a/lib/public_key/include/public_key.hrl b/lib/public_key/include/public_key.hrl
index 2dfdbbb8f3..90ca7256ea 100644
--- a/lib/public_key/include/public_key.hrl
+++ b/lib/public_key/include/public_key.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/public_key/src/pubkey_cert_records.erl b/lib/public_key/src/pubkey_cert_records.erl
index 33fe940ea2..98004c71a3 100644
--- a/lib/public_key/src/pubkey_cert_records.erl
+++ b/lib/public_key/src/pubkey_cert_records.erl
@@ -119,7 +119,7 @@ encode_supportedPublicKey(#'OTPSubjectPublicKeyInfo'{algorithm= PA =
subjectPublicKey = SPK0}) ->
Type = supportedPublicKeyAlgorithms(Algo),
{ok, SPK} = 'OTP-PUB-KEY':encode(Type, SPK0),
- #'OTPSubjectPublicKeyInfo'{subjectPublicKey = {0,list_to_binary(SPK)}, algorithm=PA}.
+ #'OTPSubjectPublicKeyInfo'{subjectPublicKey = {0,SPK}, algorithm=PA}.
%%% Extensions
@@ -161,7 +161,7 @@ decode_extensions(Exts) ->
case extension_id(Id) of
undefined -> Ext;
Type ->
- {ok, Value} = 'OTP-PUB-KEY':decode(Type, list_to_binary(Value0)),
+ {ok, Value} = 'OTP-PUB-KEY':decode(Type, iolist_to_binary(Value0)),
Ext#'Extension'{extnValue=transform(Value,decode)}
end
end, Exts).
@@ -176,7 +176,7 @@ encode_extensions(Exts) ->
Type ->
Value1 = transform(Value0,encode),
{ok, Value} = 'OTP-PUB-KEY':encode(Type, Value1),
- Ext#'Extension'{extnValue=list_to_binary(Value)}
+ Ext#'Extension'{extnValue=Value}
end
end, Exts).
diff --git a/lib/public_key/test/erl_make_certs.erl b/lib/public_key/test/erl_make_certs.erl
index 254aa6d2f9..d6bdd05d01 100644
--- a/lib/public_key/test/erl_make_certs.erl
+++ b/lib/public_key/test/erl_make_certs.erl
@@ -137,10 +137,10 @@ decode_key(PemBin, Pw) ->
encode_key(Key = #'RSAPrivateKey'{}) ->
{ok, Der} = 'OTP-PUB-KEY':encode('RSAPrivateKey', Key),
- {'RSAPrivateKey', list_to_binary(Der), not_encrypted};
+ {'RSAPrivateKey', Der, not_encrypted};
encode_key(Key = #'DSAPrivateKey'{}) ->
{ok, Der} = 'OTP-PUB-KEY':encode('DSAPrivateKey', Key),
- {'DSAPrivateKey', list_to_binary(Der), not_encrypted}.
+ {'DSAPrivateKey', Der, not_encrypted}.
make_tbs(SubjectKey, Opts) ->
Version = list_to_atom("v"++integer_to_list(proplists:get_value(version, Opts, 3))),
diff --git a/lib/ssh/doc/src/notes.xml b/lib/ssh/doc/src/notes.xml
index 36010da07a..d4acb2ef1a 100644
--- a/lib/ssh/doc/src/notes.xml
+++ b/lib/ssh/doc/src/notes.xml
@@ -29,6 +29,50 @@
<file>notes.xml</file>
</header>
+<section><title>Ssh 2.1.2</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ SSH quiet mode</p>
+ <p>
+ A new option to ssh:connect/3,4, quiet_mode. If true, the
+ client will not print out anything on authorization.</p>
+ <p>
+ Own Id: OTP-10429 Aux Id: kunagi-273 [184] </p>
+ </item>
+ <item>
+ <p>
+ Restrict which key algorithms to use</p>
+ <p>
+ A new option to ssh:connect/3,4 is introduced,
+ public_key_algs, where you can restrict which key
+ algorithms to use and in which order to try them.</p>
+ <p>
+ Own Id: OTP-10498 Aux Id: kunagi-289 [200] </p>
+ </item>
+ <item>
+ <p>
+ Confidentiality of client password</p>
+ <p>
+ Unsets clients password after authentication.</p>
+ <p>
+ Own Id: OTP-10511 Aux Id: kunagi-292 [203] </p>
+ </item>
+ <item>
+ <p>
+ Fixed user interaction for SSH</p>
+ <p>
+ It's now available to accept hosts and input password</p>
+ <p>
+ Own Id: OTP-10513 Aux Id: kunagi-293 [204] </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Ssh 2.1.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/ssh/src/ssh_io.erl b/lib/ssh/src/ssh_io.erl
index 17a7cebb4a..01fc713569 100644
--- a/lib/ssh/src/ssh_io.erl
+++ b/lib/ssh/src/ssh_io.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl
index e1949daba2..efcb11f88f 100644
--- a/lib/ssh/test/ssh_basic_SUITE.erl
+++ b/lib/ssh/test/ssh_basic_SUITE.erl
@@ -42,7 +42,6 @@ all() ->
{group, dsa_pass_key},
{group, rsa_pass_key},
{group, internal_error},
- {group, idle_time},
daemon_already_started,
server_password_option,
server_userpassword_option,
@@ -247,7 +246,8 @@ idle_time(Config) ->
ConnectionRef =
ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
{user_dir, UserDir},
- {user_interaction, false}]),
+ {user_interaction, false},
+ {idle_time, 2000}]),
{ok, Id} = ssh_connection:session_channel(ConnectionRef, 1000),
ssh_connection:close(ConnectionRef, Id),
receive
diff --git a/lib/ssl/doc/src/notes.xml b/lib/ssl/doc/src/notes.xml
index 6c01954010..7e751a215d 100644
--- a/lib/ssl/doc/src/notes.xml
+++ b/lib/ssl/doc/src/notes.xml
@@ -30,7 +30,39 @@
</header>
<p>This document describes the changes made to the SSL application.</p>
- <section><title>SSL 5.1</title>
+ <section><title>SSL 5.1.1</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ ssl:recv/3 could "loose" data when the timeout occurs. If
+ the timout in ssl:connect or ssl:ssl_accept expired the
+ ssl connection process was not terminated as it should,
+ this due to gen_fsm:send_all_state_event timout is a
+ client side time out. These timouts are now handled by
+ the gen_fsm-procss instead.</p>
+ <p>
+ Own Id: OTP-10569</p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ Better termination handling that avoids hanging.</p>
+ <p>
+ Own Id: OTP-10574</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
+<section><title>SSL 5.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
diff --git a/lib/ssl/src/Makefile b/lib/ssl/src/Makefile
index c5c5bf593a..6be8a1456e 100644
--- a/lib/ssl/src/Makefile
+++ b/lib/ssl/src/Makefile
@@ -130,3 +130,23 @@ release_spec: opt
release_docs_spec:
+# ----------------------------------------------------
+# Dependencies
+# ----------------------------------------------------
+$(EBIN)/inet_tls_dist.$(EMULATOR): ../../kernel/include/net_address.hrl ../../kernel/include/dist.hrl ../../kernel/include/dist_util.hrl
+$(EBIN)/ssl.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ../../public_key/include/public_key.hrl
+$(EBIN)/ssl_alert.$(EMULATOR): ssl_alert.hrl ssl_record.hrl
+$(EBIN)/ssl_certificate.$(EMULATOR): ssl_internal.hrl ssl_alert.hrl ssl_handshake.hrl ../../public_key/include/public_key.hrl
+$(EBIN)/ssl_certificate_db.$(EMULATOR): ssl_internal.hrl ../../public_key/include/public_key.hrl ../../kernel/include/file.hrl
+$(EBIN)/ssl_cipher.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
+$(EBIN)/ssl_connection.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
+$(EBIN)/ssl_handshake.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl ../../public_key/include/public_key.hrl
+$(EBIN)/ssl_manager.$(EMULATOR): ssl_internal.hrl ssl_handshake.hrl ../../kernel/include/file.hrl
+$(EBIN)/ssl_record.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl ssl_handshake.hrl ssl_alert.hrl
+$(EBIN)/ssl_session.$(EMULATOR): ssl_internal.hrl ssl_handshake.hrl
+$(EBIN)/ssl_session_cache.$(EMULATOR): ssl_internal.hrl ssl_handshake.hrl
+$(EBIN)/ssl_session_cache_api.$(EMULATOR): ssl_internal.hrl ssl_handshake.hrl
+$(EBIN)/ssl_ssl3.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl
+$(EBIN)/ssl_tls1.$(EMULATOR): ssl_internal.hrl ssl_record.hrl ssl_cipher.hrl
+
+
diff --git a/lib/ssl/src/ssl_manager.erl b/lib/ssl/src/ssl_manager.erl
index 0cf4f2ce33..13689ce7d8 100644
--- a/lib/ssl/src/ssl_manager.erl
+++ b/lib/ssl/src/ssl_manager.erl
@@ -24,8 +24,6 @@
-module(ssl_manager).
-behaviour(gen_server).
--include("ssl_internal.hrl").
-
%% Internal application API
-export([start_link/1, start_link_dist/1,
connection_init/2, cache_pem_file/2,
diff --git a/lib/ssl/src/ssl_session.erl b/lib/ssl/src/ssl_session.erl
index 2ad422fc03..a24b2d9444 100644
--- a/lib/ssl/src/ssl_session.erl
+++ b/lib/ssl/src/ssl_session.erl
@@ -72,15 +72,12 @@ valid_session(#session{time_stamp = TimeStamp}, LifeTime) ->
server_id(Port, <<>>, _SslOpts, _Cert, _, _) ->
{ssl_manager:new_session_id(Port), undefined};
-server_id(Port, SuggestedId,
- #ssl_options{reuse_sessions = ReuseEnabled,
- reuse_session = ReuseFun},
- Cert, Cache, CacheCb) ->
+server_id(Port, SuggestedId, Options, Cert, Cache, CacheCb) ->
LifeTime = case application:get_env(ssl, session_lifetime) of
{ok, Time} when is_integer(Time) -> Time;
_ -> ?'24H_in_sec'
end,
- case is_resumable(SuggestedId, Port, ReuseEnabled,ReuseFun,
+ case is_resumable(SuggestedId, Port, Options,
Cache, CacheCb, LifeTime, Cert)
of
{true, Resumed} ->
@@ -112,9 +109,9 @@ select_session(Sessions, #ssl_options{ciphers = Ciphers}, OwnCert) ->
[[Id, _]|_] -> Id
end.
-is_resumable(_, _, false, _, _, _, _, _) ->
+is_resumable(_, _, #ssl_options{reuse_sessions = false}, _, _, _, _) ->
{false, undefined};
-is_resumable(SuggestedSessionId, Port, true, ReuseFun, Cache,
+is_resumable(SuggestedSessionId, Port, #ssl_options{reuse_session = ReuseFun} = Options, Cache,
CacheCb, SecondLifeTime, OwnCert) ->
case CacheCb:lookup(Cache, {Port, SuggestedSessionId}) of
#session{cipher_suite = CipherSuite,
@@ -125,6 +122,7 @@ is_resumable(SuggestedSessionId, Port, true, ReuseFun, Cache,
case resumable(IsResumable)
andalso (OwnCert == SessionOwnCert)
andalso valid_session(Session, SecondLifeTime)
+ andalso reusable_options(Options, Session)
andalso ReuseFun(SuggestedSessionId, PeerCert,
Compression, CipherSuite)
of
@@ -139,3 +137,9 @@ resumable(new) ->
false;
resumable(IsResumable) ->
IsResumable.
+
+reusable_options(#ssl_options{fail_if_no_peer_cert = true,
+ verify = verify_peer}, Session) ->
+ (Session#session.peer_certificate =/= undefined);
+reusable_options(_,_) ->
+ true.
diff --git a/lib/ssl/test/erl_make_certs.erl b/lib/ssl/test/erl_make_certs.erl
index 254aa6d2f9..d6bdd05d01 100644
--- a/lib/ssl/test/erl_make_certs.erl
+++ b/lib/ssl/test/erl_make_certs.erl
@@ -137,10 +137,10 @@ decode_key(PemBin, Pw) ->
encode_key(Key = #'RSAPrivateKey'{}) ->
{ok, Der} = 'OTP-PUB-KEY':encode('RSAPrivateKey', Key),
- {'RSAPrivateKey', list_to_binary(Der), not_encrypted};
+ {'RSAPrivateKey', Der, not_encrypted};
encode_key(Key = #'DSAPrivateKey'{}) ->
{ok, Der} = 'OTP-PUB-KEY':encode('DSAPrivateKey', Key),
- {'DSAPrivateKey', list_to_binary(Der), not_encrypted}.
+ {'DSAPrivateKey', Der, not_encrypted}.
make_tbs(SubjectKey, Opts) ->
Version = list_to_atom("v"++integer_to_list(proplists:get_value(version, Opts, 3))),
diff --git a/lib/ssl/test/ssl_basic_SUITE.erl b/lib/ssl/test/ssl_basic_SUITE.erl
index a202aca943..4c3548a703 100644
--- a/lib/ssl/test/ssl_basic_SUITE.erl
+++ b/lib/ssl/test/ssl_basic_SUITE.erl
@@ -248,6 +248,7 @@ api_tests() ->
[connection_info,
peername,
peercert,
+ peercert_with_client_cert,
sockname,
versions,
controlling_process,
@@ -274,6 +275,7 @@ certificate_verify_tests() ->
server_verify_client_once_passive,
server_verify_client_once_active,
server_verify_client_once_active_once,
+ new_server_wants_peer_cert,
client_verify_none_passive,
client_verify_none_active,
client_verify_none_active_once,
@@ -788,6 +790,43 @@ peercert(Config) when is_list(Config) ->
peercert_result(Socket) ->
ssl:peercert(Socket).
+%%--------------------------------------------------------------------
+
+peercert_with_client_cert(doc) ->
+ [""];
+peercert_with_client_cert(suite) ->
+ [];
+peercert_with_client_cert(Config) when is_list(Config) ->
+ ClientOpts = ?config(client_dsa_opts, Config),
+ ServerOpts = ?config(server_dsa_verify_opts, Config),
+ {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
+
+ Server = ssl_test_lib:start_server([{node, ClientNode}, {port, 0},
+ {from, self()},
+ {mfa, {?MODULE, peercert_result, []}},
+ {options, ServerOpts}]),
+ Port = ssl_test_lib:inet_port(Server),
+ Client = ssl_test_lib:start_client([{node, ServerNode}, {port, Port},
+ {host, Hostname},
+ {from, self()},
+ {mfa, {?MODULE, peercert_result, []}},
+ {options, ClientOpts}]),
+
+ ServerCertFile = proplists:get_value(certfile, ServerOpts),
+ [{'Certificate', ServerBinCert, _}]= ssl_test_lib:pem_to_der(ServerCertFile),
+ ClientCertFile = proplists:get_value(certfile, ClientOpts),
+ [{'Certificate', ClientBinCert, _}]= ssl_test_lib:pem_to_der(ClientCertFile),
+
+ ServerMsg = {ok, ClientBinCert},
+ ClientMsg = {ok, ServerBinCert},
+
+ test_server:format("Testcase ~p, Client ~p Server ~p ~n",
+ [self(), Client, Server]),
+
+ ssl_test_lib:check_result(Server, ServerMsg, Client, ClientMsg),
+
+ ssl_test_lib:close(Server),
+ ssl_test_lib:close(Client).
%%--------------------------------------------------------------------
sockname(doc) ->
@@ -3610,9 +3649,14 @@ no_reuses_session_server_restart_new_cert(Config) when is_list(Config) ->
%% Make sure session is registered
test_server:sleep(?SLEEP),
+ Monitor = erlang:monitor(process, Server),
ssl_test_lib:close(Server),
ssl_test_lib:close(Client0),
-
+ receive
+ {'DOWN', Monitor, _, _, _} ->
+ ok
+ end,
+
Server1 =
ssl_test_lib:start_server([{node, ServerNode}, {port, Port},
{from, self()},
@@ -3719,10 +3763,14 @@ reuseaddr(Config) when is_list(Config) ->
{from, self()},
{mfa, {ssl_test_lib, no_result, []}},
{options, [{active, false} | ClientOpts]}]),
- test_server:sleep(?SLEEP),
+ Monitor = erlang:monitor(process, Server),
ssl_test_lib:close(Server),
ssl_test_lib:close(Client),
-
+ receive
+ {'DOWN', Monitor, _, _, _} ->
+ ok
+ end,
+
Server1 =
ssl_test_lib:start_server([{node, ServerNode}, {port, Port},
{from, self()},
@@ -4041,6 +4089,67 @@ client_server_opts({KeyAlgo,_,_}, Config) when KeyAlgo == dss orelse KeyAlgo ==
{?config(client_dsa_opts, Config),
?config(server_dsa_opts, Config)}.
+
+%%--------------------------------------------------------------------
+
+new_server_wants_peer_cert(doc) ->
+ ["Test that server configured to do client certification does"
+ " not reuse session without a client certificate."];
+new_server_wants_peer_cert(suite) ->
+ [];
+new_server_wants_peer_cert(Config) when is_list(Config) ->
+ ServerOpts = ?config(server_opts, Config),
+ VServerOpts = [{verify, verify_peer}, {fail_if_no_peer_cert, true}
+ | ?config(server_verification_opts, Config)],
+ ClientOpts = ?config(client_verification_opts, Config),
+
+ {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
+
+ Server =
+ ssl_test_lib:start_server([{node, ServerNode}, {port, 0},
+ {from, self()},
+ {mfa, {?MODULE, peercert_result, []}},
+ {options, [ServerOpts]}]),
+ Port = ssl_test_lib:inet_port(Server),
+ Client =
+ ssl_test_lib:start_client([{node, ClientNode}, {port, Port},
+ {host, Hostname},
+ {from, self()},
+ {mfa, {ssl_test_lib, no_result, []}},
+ {options, ClientOpts}]),
+
+ Monitor = erlang:monitor(process, Server),
+ ssl_test_lib:close(Server),
+ ssl_test_lib:close(Client),
+ receive
+ {'DOWN', Monitor, _, _, _} ->
+ ok
+ end,
+
+ Server1 = ssl_test_lib:start_server([{node, ServerNode}, {port, Port},
+ {from, self()},
+ {mfa, {?MODULE, peercert_result, []}},
+ {options, VServerOpts}]),
+ Client1 =
+ ssl_test_lib:start_client([{node, ClientNode}, {port, Port},
+ {host, Hostname},
+ {from, self()},
+ {mfa, {ssl_test_lib, no_result, []}},
+ {options, [ClientOpts]}]),
+
+ CertFile = proplists:get_value(certfile, ClientOpts),
+ [{'Certificate', BinCert, _}]= ssl_test_lib:pem_to_der(CertFile),
+
+ ServerMsg = {error, no_peercert},
+ Sever1Msg = {ok, BinCert},
+
+ ssl_test_lib:check_result(Server, ServerMsg, Server1, Sever1Msg),
+
+ ssl_test_lib:close(Server1),
+ ssl_test_lib:close(Client),
+ ssl_test_lib:close(Client1).
+
+
%%--------------------------------------------------------------------
%%% Internal functions
%%--------------------------------------------------------------------
diff --git a/lib/ssl/test/ssl_to_openssl_SUITE.erl b/lib/ssl/test/ssl_to_openssl_SUITE.erl
index 98ef050b14..f4e19b3f87 100644
--- a/lib/ssl/test/ssl_to_openssl_SUITE.erl
+++ b/lib/ssl/test/ssl_to_openssl_SUITE.erl
@@ -1080,14 +1080,13 @@ ssl2_erlang_server_openssl_client(Config) when is_list(Config) ->
OpenSslPort = open_port({spawn, Cmd}, [stderr_to_stdout]),
port_command(OpenSslPort, Data),
-
+ receive
+ {'EXIT', OpenSslPort, _} ->
+ ok
+
+ end,
ssl_test_lib:check_result(Server, {error,"protocol version"}),
-
- %% Clean close down! Server needs to be closed first !!
- ssl_test_lib:close(Server),
- close_port(OpenSslPort),
- process_flag(trap_exit, false),
- ok.
+ process_flag(trap_exit, false).
%%--------------------------------------------------------------------
erlang_client_openssl_server_npn(doc) ->
diff --git a/lib/stdlib/doc/src/notes.xml b/lib/stdlib/doc/src/notes.xml
index b4d9f9a444..2a308cbe09 100644
--- a/lib/stdlib/doc/src/notes.xml
+++ b/lib/stdlib/doc/src/notes.xml
@@ -30,6 +30,21 @@
</header>
<p>This document describes the changes made to the STDLIB application.</p>
+<section><title>STDLIB 1.18.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ Minor test updates</p>
+ <p>
+ Own Id: OTP-10591</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>STDLIB 1.18.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/test_server/doc/src/notes.xml b/lib/test_server/doc/src/notes.xml
index 3b109193a0..6a9add044a 100644
--- a/lib/test_server/doc/src/notes.xml
+++ b/lib/test_server/doc/src/notes.xml
@@ -32,6 +32,47 @@
<file>notes.xml</file>
</header>
+<section><title>Test_Server 3.5.3</title>
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ test_server_h will now recognize info_reports written by
+ ct connection handlers (according to the description in
+ cth_conn_log) and ignore them as they will be completely
+ handled by by ct_conn_log_h.</p>
+ <p>
+ Earlier test_server_h would print a tag (testcase name)
+ before forwarding the report to error_logger_tty_h. This
+ would cause lots of tags in the log with no info report
+ following (since error_logger_tty_h did not handle them).</p>
+ <p>
+ Own Id: OTP-10571</p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Known Bugs and Problems</title>
+ <list>
+ <item>
+ <p>
+ Restore Config data if lost when test case fails.</p>
+ <p>
+ Own Id: OTP-10070 Aux Id: kunagi-175 [86] </p>
+ </item>
+ <item>
+ <p>
+ IO server error in test_server.</p>
+ <p>
+ Own Id: OTP-10125 Aux Id: OTP-10101, kunagi-177 [88] </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Test_Server 3.5.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/test_server/src/test_server_io.erl b/lib/test_server/src/test_server_io.erl
index e960b3087a..777b377201 100644
--- a/lib/test_server/src/test_server_io.erl
+++ b/lib/test_server/src/test_server_io.erl
@@ -307,8 +307,10 @@ do_print_buffered(Q0, St) ->
gc(#st{gls=Gls0}) ->
InUse0 = [begin
- {group_leader,GL} = process_info(P, group_leader),
- GL
+ case process_info(P, group_leader) of
+ {group_leader,GL} -> GL;
+ undefined -> undefined
+ end
end || P <- processes()],
InUse = ordsets:from_list(InUse0),
Gls = gb_sets:to_list(Gls0),
diff --git a/lib/test_server/src/ts.erl b/lib/test_server/src/ts.erl
index 3ddc58fdbc..115e783070 100644
--- a/lib/test_server/src/ts.erl
+++ b/lib/test_server/src/ts.erl
@@ -259,21 +259,43 @@ run(List, Opts) when is_list(List), is_list(Opts) ->
run(Testspec, Config) when is_atom(Testspec), is_list(Config) ->
Options=check_test_get_opts(Testspec, Config),
File=atom_to_list(Testspec),
- Spec = case code:lib_dir(Testspec) of
- _ when Testspec == emulator;
- Testspec == system;
- Testspec == epmd ->
- File++".spec";
- {error, bad_name} ->
- create_skip_spec(Testspec, tests(Testspec));
- Path ->
- case file:read_file_info(filename:join(Path,"ebin")) of
- {ok,_} ->
- File++".spec";
- _ ->
- create_skip_spec(Testspec, tests(Testspec))
- end
- end,
+ WhatToDo =
+ case Testspec of
+ %% Known to exist but fails generic tests below
+ emulator -> test;
+ system -> test;
+ erl_interface -> test;
+ epmd -> test;
+ _ ->
+ case code:lib_dir(Testspec) of
+ {error,bad_name} ->
+ %% Application does not exist
+ skip;
+ Path ->
+ case file:read_file_info(filename:join(Path,"ebin")) of
+ {ok,#file_info{type=directory}} ->
+ %% Erlang application is built
+ test;
+ _ ->
+ case filelib:wildcard(
+ filename:join([Path,"priv","*.jar"])) of
+ [] ->
+ %% The application is not built
+ skip;
+ [_|_] ->
+ %% Java application is built
+ test
+ end
+ end
+ end
+ end,
+ Spec =
+ case WhatToDo of
+ skip ->
+ create_skip_spec(Testspec, tests(Testspec));
+ test ->
+ File++".spec"
+ end,
run_test(File, [{spec,[Spec]}], Options);
%% Runs one module in a spec (interactive)
run(Testspec, Mod) when is_atom(Testspec), is_atom(Mod) ->
diff --git a/lib/test_server/vsn.mk b/lib/test_server/vsn.mk
index aecf595f3f..b956ebb2b3 100644
--- a/lib/test_server/vsn.mk
+++ b/lib/test_server/vsn.mk
@@ -1 +1 @@
-TEST_SERVER_VSN = 3.5.2
+TEST_SERVER_VSN = 3.5.3
diff --git a/lib/tools/src/tools.app.src b/lib/tools/src/tools.app.src
index 94998fb763..553c5eb96b 100644
--- a/lib/tools/src/tools.app.src
+++ b/lib/tools/src/tools.app.src
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in