Created with colorer-take5 library. Type 'asn1'

--
-- @(#) IvmaiAsn-XDR-Encoding.edm - XDR encoding rules for xdr2asn1.
-- (c) 2004 Ivan Maidanski <ivmai@mail.ru>
-- Free specification (GNU GPL). No warranties. All rights reserved.
-- -
-- Project: IvmaiAsn ASN1/ECN/XDR Tools
-- Language: ECN:2002
-- Tested with: OSS ASN.1 and ECN Syntax Checker Version 8.2
-- --

--
-- Normative references:
-- - Srinivasan R. XDR: External Data Representation Standard. -
-- Request For Comments 1832, August 1995.
-- - ITU-T Recommendation X.680 (2002) | ISO/IEC 8824-1:2002,
-- Information technology - Abstract Syntax Notation One (ASN.1):
-- Specification of basic notation.
-- - ITU-T Draft Recommendation X.692 (2002) | ISO/IEC 8825-3:2002,
-- Information technology - ASN.1 encoding rules: Specification
-- of Encoding Control Notation (ECN).
-- --

IvmaiAsn-XDR-Encoding
ENCODING-DEFINITIONS ::= BEGIN

--
-- Note: ECN still lacks for the definition of the #REAL encoding
-- class so the definitions of FLOAT, DOUBLE and QUADRUPLE types (if
-- present) in an ASN.1 module implicitly generated by xdr2asn1
-- converter shall be manually changed from "REAL (WITH ....)"
-- clauses to "OCTET STRING (SIZE (4))", "OCTET STRING (SIZE (8))"
-- and "OCTET STRING (SIZE (16))" ones, correspondingly (so that,
-- after it, XDREncodingRules encoding set could be successfully
-- applied to that ASN.1 module).
-- --

-- /* Sample use of XDR encoding rules */
--
-- Sample-XDR2ASN1-ELM-Module
-- LINK-DEFINITIONS ::= BEGIN
--
-- IMPORTS
-- #SampleTopLevelMessage
-- FROM Sample-XDR2ASN1-ASN1-Module /* produced by xdr2asn1 */
-- XDREncodingRules
-- FROM IvmaiAsn-XDR-Encoding;
--
-- ENCODE #SampleTopLevelMessage
-- WITH XDREncodingRules
--
-- END
-- --

EXPORTS
        XDREncodingRules;

IMPORTS;

nullEncoding #NULL ::= {
        ENCODING-SPACE }

integerEncoding #INTEGER ::= {
        ENCODINGS {
                {
                        IF semi-bounded-without-negatives
                        ENCODING-SPACE
                        SIZE 1
                        MULTIPLE OF dword32
                        ENCODING positive-int },
                {
                        IF bounded-with-negatives
                        ENCODING-SPACE
                        SIZE fixed-to-max
                        MULTIPLE OF dword32 },
                {
                        IF bounded-without-negatives
                        ENCODING-SPACE
                        SIZE fixed-to-max
                        MULTIPLE OF dword32
                        ENCODING positive-int },
                {
                        ENCODING-SPACE
                        SIZE 1
                        MULTIPLE OF dword32 } } }

booleanEncoding #BOOLEAN ::= {
        USE #INTEGER
        MAPPING VALUES {
                FALSE TO 0,
                TRUE TO 1 }
        WITH integerEncoding }

#LengthAndElements {< #Element >} ::= #CONCATENATION {
        length #INTEGER (0 .. MAX),
        elements #Element }

charsWithLenEncoding {< REFERENCE: length >} #IA5String ::= {
        TRANSFORMS {
                {
                        CHAR-TO-BITS
                        AS iso10646
                        SIZE 1
                        MULTIPLE OF octet } }
        REPETITION-ENCODING {
                REPETITION-SPACE
                SIZE variable-with-determinant
                MULTIPLE OF repetitions
                USING length } }

concatPaddedEncoding #CONCATENATION ::= {
        ENCODING-SPACE
        MULTIPLE OF dword32
        VALUE-PADDING
        JUSTIFIED left: 0
        POST-PADDING zero
        UNUSED BITS
        DETERMINED BY not-needed
        }

lengthAndCharsEncoding {< #Element >}
 #LengthAndElements {< #Element >} ::= {
        ENCODE STRUCTURE {
                length integerEncoding,
                elements charsWithLenEncoding {< length >}
                STRUCTURED WITH concatPaddedEncoding } }

ia5stringEncoding #IA5String ::= {
        REPETITION-ENCODING {
                REPLACE
                STRUCTURE
                WITH #LengthAndElements
                ENCODED BY lengthAndCharsEncoding } }

#FixedElements {< #Element >} ::= #CONCATENATION {
        elements #Element }

octetsNoLenEncoding #OCTET-STRING ::= {
        REPETITION-ENCODING {
                REPETITION-SPACE
                MULTIPLE OF repetitions } }

fixedOctetsEncoding {< #Element >}
 #FixedElements {< #Element >} ::= {
        ENCODE STRUCTURE {
                elements octetsNoLenEncoding
                STRUCTURED WITH concatPaddedEncoding } }

octetsWithLenEncoding {< REFERENCE: length >} #OCTET-STRING ::= {
        REPETITION-ENCODING {
                REPETITION-SPACE
                SIZE variable-with-determinant
                MULTIPLE OF repetitions
                USING length } }

lengthAndOctetsEncoding {< #Element >}
 #LengthAndElements {< #Element >} ::= {
        ENCODE STRUCTURE {
                length integerEncoding,
                elements octetsWithLenEncoding {< length >}
                STRUCTURED WITH concatPaddedEncoding } }

octetStringEncoding #OCTET-STRING ::= {
        REPETITION-ENCODINGS {
                {
                        IF fixed-size
                        REPLACE
                        STRUCTURE
                        WITH #FixedElements
                        ENCODED BY fixedOctetsEncoding },
                {
                        REPLACE
                        STRUCTURE
                        WITH #LengthAndElements
                        ENCODED BY lengthAndOctetsEncoding } } }

sequenceofNoLenEncoding #SEQUENCE-OF ::= {
        REPETITION-ENCODING {
                REPETITION-SPACE
                MULTIPLE OF repetitions } }

concatenationEncoding #CONCATENATION ::= {
        ENCODING-SPACE }

fixedSequenceofEncoding {< #Element >}
 #FixedElements {< #Element >} ::= {
        ENCODE STRUCTURE {
                elements sequenceofNoLenEncoding
                STRUCTURED WITH concatenationEncoding } }

sequenceofWithLenEncoding {< REFERENCE: length >} #SEQUENCE-OF ::= {
        REPETITION-ENCODING {
                REPETITION-SPACE
                SIZE variable-with-determinant
                MULTIPLE OF repetitions
                USING length } }

lengthAndSequenceofEncoding {< #Element >}
 #LengthAndElements {< #Element >} ::= {
        ENCODE STRUCTURE {
                length integerEncoding,
                elements sequenceofWithLenEncoding {< length >}
                STRUCTURED WITH concatenationEncoding } }

sequenceOfEncoding #SEQUENCE-OF ::= {
        REPETITION-ENCODINGS {
                {
                        IF fixed-size
                        REPLACE
                        STRUCTURE
                        WITH #FixedElements
                        ENCODED BY fixedSequenceofEncoding },
                {
                        REPLACE
                        STRUCTURE
                        WITH #LengthAndElements
                        ENCODED BY lengthAndSequenceofEncoding } } }

sequenceEncoding #SEQUENCE ::= {
        ENCODING-SPACE }

tagEncoding #TAG ::= {
        ENCODING-SPACE
        SIZE 1
        MULTIPLE OF dword32
        EXHIBITS HANDLE "Tag"
        AT {
                0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
                8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
                16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
                24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 } }

choiceEncoding #CHOICE ::= {
        ALTERNATIVE
        DETERMINED BY handle
        HANDLE "Tag" }

XDREncodingRules #ENCODINGS ::= {
        nullEncoding |
        integerEncoding |
        booleanEncoding |
        -- realEncoding |
        ia5stringEncoding |
        octetStringEncoding |
        sequenceOfEncoding |
        sequenceEncoding |
        tagEncoding |
        choiceEncoding }

END