aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
AgeCommit message (Collapse)Author
2019-03-22Merge pull request #2159 from dotsimon/asn1_pedefsIngela Andin
ASN.1: fix various problems with value definitions OTP-15697
2019-02-25Fix compiling value of SEQUENCE OF CHOICE with extensionsSimon Cornish
2019-02-25Fix compiling value of CHOICE with extensionsSimon Cornish
2019-02-25Fix for DEFAULT used with OCTET STRINGSimon Cornish
2018-07-27Change "can not" into "cannot"Raimo Niskanen
I did not find any legitimate use of "can not", however skipped changing e.g RFCs archived in the source tree.
2018-06-18Update copyright yearHenrik Nord
2018-04-16asn1: Eliminate use of erlang:get_stacktrace/0Björn Gustavsson
Also eliminate use of erlang:get_stacktrace/0 in code generated by the ASN.1 compiler.
2018-03-05Merge branch 'maint'Raimo Niskanen
2018-03-02Dialyzer suppress per_common:to_bitstring/2Raimo Niskanen
2017-11-23Merge branch 'maint'Hans Nilsson
* maint: asn1: asn1:test now handles no_ok_wrapper and undec_rest asn1: Further adjustments on generated code asn1: Protect more by try..catch
2017-11-23Merge branch 'hans/asn1/asn1ct_test_fix/ERL-518/OTP-14787' into maintHans Nilsson
* hans/asn1/asn1ct_test_fix/ERL-518/OTP-14787: asn1: asn1:test now handles no_ok_wrapper and undec_rest
2017-11-21asn1: asn1:test now handles no_ok_wrapper and undec_restHans Nilsson
2017-11-21asn1: Further adjustments on generated codeHans Nilsson
2017-11-21asn1: Protect more by try..catchHans Nilsson
2017-09-15Merge branch 'siri/string-new-api'Siri Hansen
* siri/string-new-api: (28 commits) hipe (test): Do not use deprecated functions in string(3) dialyzer (test): Do not use deprecated functions in string(3) eunit (test): Do not use deprecated functions in string(3) system (test): Do not use deprecated functions in string(3) system (test): Do not use deprecated functions in string(3) mnesia (test): Do not use deprecated functions in string(3) Deprecate old string functions observer: Do not use deprecated functions in string(3) common_test: Do not use deprecated functions in string(3) eldap: Do not use deprecated functions in string(3) et: Do not use deprecated functions in string(3) os_mon: Do not use deprecated functions in string(3) debugger: Do not use deprecated functions in string(3) runtime_tools: Do not use deprecated functions in string(3) asn1: Do not use deprecated functions in string(3) compiler: Do not use deprecated functions in string(3) sasl: Do not use deprecated functions in string(3) reltool: Do not use deprecated functions in string(3) kernel: Do not use deprecated functions in string(3) hipe: Do not use deprecated functions in string(3) ... Conflicts: lib/eunit/src/eunit_lib.erl lib/observer/src/crashdump_viewer.erl lib/reltool/src/reltool_target.erl
2017-09-15asn1: Do not use deprecated functions in string(3)Dan Gudmundsson
2017-08-24Merge branch 'maint-20' into maintRaimo Niskanen
* maint-20: Updated OTP version Prepare release Accept non-binary options as socket-options Bump version Fix broken handling of default values in extensions for PER compiler: Fix live regs update on allocate in validator Take fail labels into account when determining liveness in block ops Check for overflow when appending binaries, and error out with system_limit
2017-08-16Fix broken handling of default values in extensions for PERBjörn Gustavsson
Default values have never worked in extension for PER. Note that for default values in the root part of SEQUENCE, giving a value equal to the DEFAULT value, will result in the same encoding as if asn1_DEFAULT was given. However, that behavior is not promised by the documentation. The documentation says that asn1_DEFAULT should be used for default values. For DEFAULT in extensions, only implement what the documentation promises and nothing more. ERIERL-60
2017-07-27Merge branch 'maint-20' into maintJohn Högberg
* maint-20: Updated OTP version Update release notes Update version numbers Fix doc for the 'quiet' option; it defaults to false asn1: Fix missing quotes of external encoding call Add a dedicated close function for TCP ports to prevent issues like ERL-430/448 Close TCP ports properly on send timeout erts: Add missing release note
2017-07-20asn1: Fix missing quotes of external encoding callSverker Eriksson
introduced by 8e4a9864385242b962ce7446f7daa4f58cfecca5.
2017-07-04Corrected behavior of option {n2n, EnumTypeName} whenKenneth Lundin
EnumTypeName contains a hypen like fore example Cause-Misc. This caused syntax errors when compiling the generated Erlang code.
2017-05-04Update copyright yearRaimo Niskanen
2017-03-27Add a no_native option wherever there is an on_loadKostis Sagonas
This is a poor man's solution that allows to build and test the system with all files compiled to native code simply by setting the ERL_COMPILER_OPTS environment variable. Better solutions, like automatically setting the no_native option whenever the compiler sees an on_load attribute, obviously exist but require more time to implement.
2017-03-15Remove default clauses that cause exceptions for internal errorsBjörn Gustavsson
Just crash if there is an internal error.
2017-03-14Clean up commentsBjörn Gustavsson
* Remove out-commented code * Fix obvious typos and bad grammar * Adhere to the conventions for when to use "%" and "%%".
2017-03-14Clean up asn1ct_gen:emit/1Björn Gustavsson
Remove blank lines between clauses; use matching instead of is_list/1 guards.
2017-03-14Remove unused clauses in asn1ct_gen:emit/1Björn Gustavsson
2017-03-14Clean up use of asn1ct_gen:emit/1Björn Gustavsson
Stop up using asn1ct_gen:emit/1 with a tuple instead of a list. Also remove the remaining uses of asn1ct_gen:demit/1.
2017-03-14Remove the 'debug' optionBjörn Gustavsson
The debug option no longer serves any useful purpose.
2017-03-14Only generate needed single quotes around function namesBjörn Gustavsson
That will make code slightly easier to read.
2017-03-14asn1ct_gen_ber_bin_v2: Remove unused codeBjörn Gustavsson
The code is not covered. The code is also not present in the PER backend. Here is a somewhat more formal proof that the code cannot be reached: asn1ct_gen_ber_bin_v2:gen_encode_user/3 calls asn1ct_gen:gen_encode_constructed/4 where Typename is a list of one element. asn1ct_gen:gen_encode_constructed/4 will call asn1ct_gen_ber_bin_v2:gen_encode/3 via asn1ct_gen:gen_types/4. Note that if InnerType in asn1ct_gen:gen_encode_constructed/4 is 'SEQUENCE OF' or 'SET OF', Typename will be extended to a list with two elements. If InnerType in asn1ct_gen:gen_encode_constructed/4 is 'SET', 'SEQUENCE', or 'CHOICE', then asn1ct_gen_ber_bin_v2:gen_encode/3 will be called with the last argument being a #'ComponentType'{}. asn1ct_gen_ber_bin_v2:gen_encode/3 will in that cause extend Typename before calling itself recursively. Therefore, Typename is always a list with at least two elements when the removed code is called.
2017-03-14asn1ct_gen_per: Fix broken dialyzer suppression functionBjörn Gustavsson
ce431409d0daba broke generation of dialyzer suppressions for per and uper. While we are it, add type tests to asn1ct_func:is_used/1 to avoid similar problems in the future.
2017-03-01Fix typos: lenght -> lengthMyron Marston
2017-02-21encode/decode: Include the stack trace in error returnsBjörn Gustavsson
The generated encode/2 and decode/2 functions can return cryptic error messages. Consider this ASN.1 spec: T DEFINITIONS AUTOMATIC TAGS ::= BEGIN S ::= SEQUENCE { b BOOLEAN, i INTEGER (1..100), j INTEGER (0..7), s OCTET STRING } END In OTP 19, the error terms will look like this: Eshell V8.2 (abort with ^G) 1> asn1ct:compile('T', [ber]). ok 2> rr('T'). ['S'] 3> 'T':encode('S', #'S'{}). {error,{asn1,{encode_boolean,undefined}}} 4> 'T':encode('S', #'S'{b=false}). {error,{asn1,{encode_integer,undefined}}} 5> 'T':encode('S', #'S'{b=false,i=7,j=0}). {error,{asn1,function_clause}} Some error terms are clearer than other. In the first error term, it is clear that the error refers to the 'b' field, since there is only one BOOLEAN in 'S'. The second error term could refer to either 'i' or 'j'. The last error term... well... in this case we can infer that it must refer to 's'. The easiest way to provide more information is to include the stack trace with line numbers in the error term: 3> 'T':encode('S', #'S'{b=false}). {error,{asn1,{{encode_integer,undefined}, [{'T',encode_integer,2,[{file,"T.erl"},{line,240}]}, {'T',enc_S,2,[{file,"T.erl"},{line,102}]}, {'T',encode,2,[{file,"T.erl"},{line,36}]}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]}, {shell,exprs,7,[{file,"shell.erl"},{line,686}]}, {shell,eval_exprs,7,[{file,"shell.erl"},{line,641}]}, {shell,eval_loop,3,[{file,"shell.erl"},{line,626}]}]}}} By looking at the generated Erlang code, we can see that encoding failed for 'i'. This is an compatible change. All that the documentation says is that the format of the error tuple is: {error,{asn1,Description}} With this change, Description is always a tuple: {ErrorDescription,StackTrace} Alternatives considered: Providing more information in the error term itself and make sure there can be no 'function_clause', 'badarg', or 'badmatch' exceptions. That would be possible, but it would require a lot of work and it would increase the size of the generated code and make it slower. Therefore, this solution was rejected.
2017-02-21PER decoding: Be less verbose for invalid ENUMERATEDBjörn Gustavsson
When an invalid value is encountered when trying to decode an ENUMERATED, the exception can be quite verbose. Here is an actual example from NBAP-PDU-Contents: _ -> exit({error,{asn1,{decode_enumerated,{V4@V3,[chCode1div1,chCode2div1,chCode2div2,chCode4div1,chCode4div2,chCode4div3,chCode4div4,chCode8div1,chCode8div2,chCode8div3,chCode8div4,chCode8div5,chCode8div6,chCode8div7,chCode8div8,chCode16div1,chCode16div2,chCode16div3,chCode16div4,chCode16div5,chCode16div6,chCode16div7,chCode16div8,chCode16div9,chCode16div10,chCode16div11,chCode16div12,chCode16div13,chCode16div14,chCode16div15,chCode16div16]}}}}) Listing the possible values for an ENUMERATED when decoding fails is not helpful and increases the code size (it would have made somewhat more sense to list the possible values if *encoding* failed).
2017-02-17PER encoding: Emit comments about each attributeBjörn Gustavsson
To make it easier to find your way in the generated code, add a comment about each attribute in the generated code for SEQUENCE and SET.
2017-02-17PER: Slightly improve error reporting for encodingBjörn Gustavsson
Generate slightly better error reasons when encoding of INTEGER, ENUMERATED, or BOOLEAN fails.
2017-02-16asn1ct_gen: Clean up handling of dispatch generationBjörn Gustavsson
2017-02-16Package abstract code in a record for code generationBjörn Gustavsson
For now, do the packaging before call asn1ct_gen:pgen().
2017-02-16asn1ct_gen: Polish the file headerBjörn Gustavsson
2017-02-15asn1ct_gen: Clean up generation of .hrl file headerBjörn Gustavsson
Note that put(currmod, Mod) is not needed because it has already been done by the caller.
2017-02-15asn1ct_gen: Clean up generation records in .hrl fileBjörn Gustavsson
2017-02-15asn1ct_gen: Clean up generation of -export directivesBjörn Gustavsson
2017-02-15asn1ct_gen: Clean up generation of valuesBjörn Gustavsson
2017-02-06Teach the ASN.1 compiler the 'maps' optionBjörn Gustavsson
When the 'maps' option is given, the SEQUENCE and SET types are represented as maps instead of as records. Optional and default values must be not be given as asn1_NOVALUE or asn1_DEFAULT in a map passed to the M:encode/2 function; they must be omitted from the map. Similarly, when decoding missing values will be omitted from the map. No .hrl files will be generated when the 'maps' options is used. That means values in an ASN.1 module must be retrieved by calling the appropriate function in generated module. Since we one day hope to get rid of the options 'compact_bit_string', 'legacy_bit_string', and 'legacy_erlang_types', we will not allow them to be combined with the 'maps' option.
2017-02-03Refactor decoding as a preparation for handling mapsBjörn Gustavsson
2017-02-03Refactor encoding of optional valuesBjörn Gustavsson
As a preparation for supporting maps in a future commit, refactor the functions for encoding optional values.
2017-02-03Clean up filtering of optionsBjörn Gustavsson
2017-02-03Refactor code generation optionsBjörn Gustavsson
Most options to the code generation pass are passed through the process dictionary. At the same time, an Erule or Erules argument is passed to most code generation functions. The Erule argument is only an atom indicating the encoding rules ('ber', 'per', or 'uper'). Introduce a new record #gen{} to contain code generation options and parameters. Pass it as the Erule argument (renaming it to Gen in functions that we will have to touch anyway). In this commit, eliminate the use of the variable 'encoding_options' in the process dictionary.
2017-02-03Simplify gen_enc_components_call() and friendsBjörn Gustavsson