Tuesday, 9 September 2014

Object Type should extends from Object Identifier

In MIB, there are 2 ways to define Identifier Objects; as Object-Identifier and Object-Type.

RFC1213-MIB.mib
          -- Object Identifier
          mib-2      OBJECT IDENTIFIER ::= { mgmt 1 }

          -- Object Type
          sysDescr OBJECT-TYPE
              SYNTAX  DisplayString (SIZE (0..255))
              ACCESS  read-only
              STATUS  mandatory
               DESCRIPTION
                      "A textual description of the entity.  This value
                      should include the full name and version
                      identification of the system's hardware type,
                      software operating-system, and networking
                      software.  It is mandatory that this only contain
                      printable ASCII characters."
              ::= { system 1 }


Object-Identifier basically contains OID name and OID value where else Object-Type contains these as well few more additional attributes.

In another word, Object-Type EClass should extend from Object-Identifier EClass. This can be done via Xtext declarative way:

Mib.xtext
Definition:
 name=ID 'DEFINITIONS' '::=' 'BEGIN'
 Export?
 imports=Import?
 (identifiers+=Identifier | DataType)+
 'END';

Object:
 name=ID;

Identifier:
 ObjectType | (name=Object mibType value=OidValue);

ObjectType:
 name=Object imp=[Object] 'SYNTAX' mibType 'ACCESS' ID 'STATUS' ID
 ('DESCRIPTION' STRING)?
 ('REFERENCE' STRING)?
 ('INDEX' '{' mibType (',' mibType)* '}')?
 ('DEFVAL' '{' INT | STRING '}')?
 value=OidValue;



This generates following ecore model:



No comments:

Post a Comment