Pricing      Download   
MENU 
 Home Products About Support Contact

InfoObjectAsn1Example.asn1

( ASN.1 Examples | Home )
InfoObject-ASN1Module { 1 3 6 1 4 1 3817 99 1 2 3 }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN

    OpCode ::= INTEGER
   
    --
    -- Define OPERATION class and Operations
    --
    OPERATION ::= CLASS
    {
       &ArgumentType  OPTIONAL,
       &ResultType    OPTIONAL,
       &operationCode OpCode UNIQUE 
    }
    WITH SYNTAX
    {
       [ ARGUMENT &ArgumentType]
       [ RESULT   &ResultType ]
       CODE &operationCode
    }

    getOp  OPERATION ::=  
    { 
       ARGUMENT GetArgument
       RESULT   GetResult
       CODE     1
    }

    setOp OPERATION ::=  
    { 
       ARGUMENT SetArgument
       RESULT   SetResult
       CODE     2
    }

    OperationSet OPERATION ::= { getOp | setOp }

    --
    -- Define ATTRIBUTE class and attributes
    --

    AttributeId ::= INTEGER

    ATTRIBUTE ::= CLASS
    {
       &id AttributeId UNIQUE,
       &Type
    }
    WITH SYNTAX
    {
       ID &id 
       TYPE &Type
    }

    nameAttribute  ATTRIBUTE ::= { ID 1 TYPE GraphicString }
    ageAttribute   ATTRIBUTE ::= { ID 2 TYPE INTEGER }
    idAttribute    ATTRIBUTE ::= { ID 3 TYPE NumericString }

    -- Defined a set of ATTRIBUTEs
    AttributeSet   ATTRIBUTE ::= { nameAttribute | ageAttribute | idAttribute }


    Attribute   ::= SEQUENCE
    {
       id     ATTRIBUTE.&id({AttributeSet}),
       value  ATTRIBUTE.&Type({AttributeSet}{@.id})
    }

    AttributeList   ::= SET OF Attribute
    AttributeIdList ::= SET OF AttributeId

    -- 
    -- OPERATION &ArgumentType and &ResultType ASN.1 types
    -- 
    SetArgument ::= AttributeList
    SetResult   ::= AttributeList

    GetArgument ::= AttributeIdList
    GetResult   ::= AttributeList

    -- 
    -- Message structure containing result and responses
    -- 
    Message ::= CHOICE
    {
       request  [0] SEQUENCE
       {
	  opCode   OPERATION.&operationCode({OperationSet}),
	  argument OPERATION.&ArgumentType({OperationSet}{@.opCode})
       },
       response [1] SEQUENCE
       {
	  opCode   OPERATION.&operationCode({OperationSet}),
	  result OPERATION.&ResultType({OperationSet}{@.opCode})
       }
    }

    getRequestMessage Message ::= request: 
       { 
          opCode getOp.&operationCode, 
	  argument 
	  { 
	      nameAttribute.&id, 
	      ageAttribute.&id, 
	      idAttribute.&id
	  } 
       }

    getResponseMessage Message ::= response:
       { 
          opCode getOp.&operationCode, 
	  result 
	  { 
	      { id nameAttribute.&id, value "David Webb" },
	      { id ageAttribute.&id,  value 30 },
	      { id idAttribute.&id,   value "123456" } 
	  } 
       }

    setRequestMessage Message ::= request:
       { 
          opCode setOp.&operationCode, 
	  argument 
	  { 
	      { id nameAttribute.&id, value "Tony Stark" },
	      { id ageAttribute.&id,  value 40 },
	      { id idAttribute.&id,   value "654321" } 
	  } 
       }

END