IBM
Contents Index Previous Next



Appendix A


Example 7 : The RFC1157-SNMP ASN.1 Module

RFC1157-SNMP DEFINITIONS ::= BEGIN
IMPORTS
    ObjectName, ObjectSyntax, NetworkAddress, IpAddress, TimeTicks
        FROM RFC1155-SMI;


-- top-level message


Message ::=
    SEQUENCE {
        version    INTEGER { version-1(0) }, -- version-1 for this RFC
        community  OCTET STRING,             -- community name, for example, 
"private" or "public"
        data       PDUs --ANY--              -- e.g., PDUs if trivial 
authentication is being used
    }

comPublic  OCTET STRING ::= '7075626C6963'H
comPrivate OCTET STRING ::= '70726976617465'H

-- protocol data units


PDUs ::=
    CHOICE {
        get-request       GetRequest-PDU,
        get-next-request  GetNextRequest-PDU,
        get-response      GetResponse-PDU,
        set-request       SetRequest-PDU,
        trap              Trap-PDU
    }


-- the individual PDUs and commonly used data types will be defined later


GetRequest-PDU ::=  -- Used to retrieve a piece of management information
    [0] IMPLICIT
        SEQUENCE {
            request-id         RequestID,
            error-status       ErrorStatus,     -- always 0
            error-index        ErrorIndex,      -- always 0
            variable-bindings  VarBindList
        }


GetNextRequest-PDU ::=  -- Used iteratively to retrieve sequences of management 
information
    [1] IMPLICIT
        SEQUENCE {
            request-id         RequestID,
            error-status       ErrorStatus,     -- always 0
            error-index        ErrorIndex,      -- always 0
            variable-bindings  VarBindList
        }


GetResponse-PDU ::=  -- Used by the agent to respond with data to requests from 
the manager
    [2] IMPLICIT
        SEQUENCE {
            request-id         RequestID,
            error-status       ErrorStatus,
            error-index        ErrorIndex,
            variable-bindings  VarBindList
        }


SetRequest-PDU ::=  -- Used to initialize and make a change to a value of the 
network element
    [3] IMPLICIT
        SEQUENCE {
            request-id         RequestID,
            error-status       ErrorStatus,     -- always 0
            error-index        ErrorIndex,      -- always 0
            variable-bindings  VarBindList
        }


Trap-PDU ::=  -- Trap == Asynchronous event report from the agent running on the 
managed system (sent without being asked)
              -- Used to report an alert or other asynchronous event about a 
managed system.
              -- Asynchronous event reports are called notifications in later 
versions of SNMP
    [4] IMPLICIT
    SEQUENCE {
        enterprise         OBJECT IDENTIFIER,         -- type of object 
generating trap, see sysObjectID in [5]
        agent-addr         NetworkAddress,            -- address of object 
generating trap
        generic-trap       INTEGER {                  -- generic trap type
                             coldStart(0),
                             warmStart(1),
                             linkDown(2),
                             linkUp(3),
                             authenticationFailure(4),
                             egpNeighborLoss(5),
                             enterpriseSpecific(6)
                           },
        specific-trap      INTEGER,                   -- specific code, present 
even if generic-trap is not enterpriseSpecific
        time-stamp         TimeTicks,                 -- time elapsed between 
the last (re)initialization of the network entity and the generation of the trap
        variable-bindings  VarBindList                -- "interesting" 
information
    }


-- request/response information


RequestID ::=
    INTEGER


ErrorStatus ::=
    INTEGER {
      noError(0),
      tooBig(1),
      noSuchName(2),
      badValue(3),
      readOnly(4),
      genErr(5)
    }


ErrorIndex ::=
    INTEGER


-- variable bindings


VarBind ::=
    SEQUENCE {
        name   ObjectName,
        value  ObjectSyntax
    }


VarBindList ::=
    SEQUENCE OF
        VarBind


END

Example 8 : The RFC1155-SMI ASN.1 Module

RFC1155-SMI DEFINITIONS ::= BEGIN
EXPORTS -- EVERYTHING
    internet, directory, mgmt, experimental, private, enterprises,
    ObjectName, ObjectSyntax, SimpleSyntax,
    ApplicationSyntax, NetworkAddress, IpAddress,
    Counter, Gauge, TimeTicks, Opaque;


-- the path to the root

internet      OBJECT IDENTIFIER ::= { iso(1) org(3) dod(6) 1 }
directory     OBJECT IDENTIFIER ::= { internet 1 }
mgmt          OBJECT IDENTIFIER ::= { internet 2 }
experimental  OBJECT IDENTIFIER ::= { internet 3 }
private       OBJECT IDENTIFIER ::= { internet 4 }
enterprises   OBJECT IDENTIFIER ::= { private 1 }

-- names of objects in the MIB

ObjectName ::= OBJECT IDENTIFIER

-- syntax of objects in the MIB

ObjectSyntax ::= CHOICE {
                   simple            SimpleSyntax,
                   application-wide  ApplicationSyntax
                   }

SimpleSyntax ::= CHOICE {
                   number  INTEGER,
                   string  OCTET STRING,
                   object  OBJECT IDENTIFIER,
                   empty   NULL
                 }

simple-value SimpleSyntax ::= empty : NULL

ApplicationSyntax ::= CHOICE {
                        address    NetworkAddress,
                        counter    Counter,
                        gauge      Gauge,
                        ticks      TimeTicks,
                        arbitrary  Opaque

                  -- other application-wide types, as they are
                  -- defined, will be added here
                      }


-- application-wide types

                  NetworkAddress ::=
                      CHOICE {
                          internet
                              IpAddress
                      }

                  IpAddress ::=
                      [APPLICATION 0]          -- in network-byte order
                          IMPLICIT OCTET STRING (SIZE (4))

                  Counter ::=
                      [APPLICATION 1]
                          IMPLICIT INTEGER (0..4294967295)

                  Gauge ::=
                      [APPLICATION 2]
                          IMPLICIT INTEGER (0..4294967295)

                  TimeTicks ::=
                      [APPLICATION 3]
                          IMPLICIT INTEGER (0..4294967295)

                  Opaque ::=
                      [APPLICATION 4]          -- arbitrary ASN.1 value,
                          IMPLICIT OCTET STRING   --   "double-wrapped"

                  END

Example 9 : The RFCxxxx-MIBs ASN.1 Module

RFCxxxx-MIBs DEFINITIONS ::= BEGIN
    IMPORTS
        mgmt, enterprises, NetworkAddress, IpAddress, Counter, Gauge, TimeTicks
            FROM RFC1155-SMI;


mib        OBJECT IDENTIFIER ::= { mgmt 1 } -- 1.3.6.1.2.1


system     OBJECT IDENTIFIER ::= { mib 1 }  -- 1.3.6.1.2.1.1
interfaces OBJECT IDENTIFIER ::= { mib 2 }
at         OBJECT IDENTIFIER ::= { mib 3 }
ip         OBJECT IDENTIFIER ::= { mib 4 }
icmp       OBJECT IDENTIFIER ::= { mib 5 }
tcp        OBJECT IDENTIFIER ::= { mib 6 }
udp        OBJECT IDENTIFIER ::= { mib 7 }
egp        OBJECT IDENTIFIER ::= { mib 8 }
printmib   OBJECT IDENTIFIER ::= { mib 43 } -- 1.3.6.1.2.1.43


-- 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."

sysDescr     OBJECT IDENTIFIER ::= { system 1 }
DisplayString ::= OCTET STRING

END


http://www.ibm.com/rational
Contents Index Previous Next