-- iVN Switch MIB (Draft)

IVN-SWITCH-MIB DEFINITIONS ::= BEGIN

IMPORTS
    MODULE-IDENTITY, OBJECT-TYPE, Unsigned32, TimeTicks
        FROM SNMPv2-SMI                 -- [RFC2578]
    DateAndTime, DisplayString, TruthValue
        FROM SNMPv2-TC                  -- [RFC2579]
    SnmpAdminString
        FROM SNMP-FRAMEWORK-MIB         -- [RFC3411]
    MODULE-COMPLIANCE, OBJECT-GROUP
        FROM SNMPv2-CONF                -- [RFC2580]
    iPhoiVNManagement
        FROM IPHOTONIX-SMI-MIB;

switchMIB MODULE-IDENTITY
    LAST-UPDATED "201709250000Z"  -- September 25, 2017
    ORGANIZATION "iPhotonix"
    CONTACT-INFO
          "support@iphotonix.com"
    DESCRIPTION
        "The Switch module provides SNMP access to passively
         monitor any existing iVN switches."
    REVISION    "201709250000Z"  -- September 25, 2017
    DESCRIPTION
        "Initial version."
    ::= { iPhoiVNManagement 3 }

switchObjects OBJECT IDENTIFIER ::= { switchMIB 1 }

switches  OBJECT IDENTIFIER ::= { switchObjects 1 }

switchPorts  OBJECT IDENTIFIER ::= { switchObjects 2 }


-- Switches Table --

switchTableLastChanged  OBJECT-TYPE
   SYNTAX      TimeTicks
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "The value of sysUpTime at the time the table was last updated."
   ::= { switches 1 }

switchTable OBJECT-TYPE
   SYNTAX      SEQUENCE OF SwitchEntry
   MAX-ACCESS  not-accessible
   STATUS      current
   DESCRIPTION
       "A table of Switch entries"
   ::= { switches 2 }

switchEntry OBJECT-TYPE
   SYNTAX      SwitchEntry
   MAX-ACCESS  not-accessible
   STATUS      current
   DESCRIPTION
       "Entries appear in this table when switches appear.  They
        are removed when the switch is removed."
   INDEX       { switchIndex }
   ::= { switchTable 1 }

SwitchEntry ::= SEQUENCE {
   switchIndex                 Unsigned32,
   switchDateAndTime           DateAndTime,
   switchName                  SnmpAdminString,
   switchEnabled               TruthValue,
   switchLostContact           DateAndTime,
   switchDeviceSerialNumber    DisplayString
   }

switchIndex OBJECT-TYPE
   SYNTAX     Unsigned32 (1..4294967295)
   MAX-ACCESS not-accessible
   STATUS     current
   DESCRIPTION
       "A strictly monotonically increasing integer which
       acts as the index of entries within the switch
       list.  It wraps back to 1 after it reaches its
       maximum value."
   ::= { switchEntry 1 }

switchDateAndTime OBJECT-TYPE
   SYNTAX      DateAndTime
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
       "The local date and time when the switch first appeared.

       Implementations MUST include the offset from UTC,
       if available.  Implementation in environments in which
       the UTC offset is not available is NOT RECOMMENDED."
   ::= { switchEntry 2 }

switchName    OBJECT-TYPE
   SYNTAX      SnmpAdminString
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "Switch name."
  ::= { switchEntry 3 }

switchEnabled    OBJECT-TYPE
   SYNTAX      TruthValue
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "Switch is enabled"
  ::= { switchEntry 4 }

switchLostContact    OBJECT-TYPE
   SYNTAX      DateAndTime
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "Time when contact was lost with the switch (or null).

       Implementations MUST include the offset from UTC,
       if available.  Implementation in environments in which
       the UTC offset is not available is NOT RECOMMENDED."
  ::= { switchEntry 5 }

switchDeviceSerialNumber    OBJECT-TYPE
   SYNTAX      DisplayString
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "Device serial number"
  ::= { switchEntry 6 }

-- The Switch Ports table is subordinate to Switch table
--
-- SNMP does not support tables within tables so a subordinate table
-- is emulated via index.
--
-- https://stackoverflow.com/questions/2510211/snmp-asn-1-mib-definitions-referencing-a-table-within-a-table

switchPortTable OBJECT-TYPE
    SYNTAX       SEQUENCE OF SwitchPortEntry
    MAX-ACCESS   not-accessible
    STATUS       current
    DESCRIPTION  "A table of Switch Port entries"
    ::= { switchPorts 1 }

switchPortEntry OBJECT-TYPE
    SYNTAX       SwitchPortEntry
    MAX-ACCESS   not-accessible
    STATUS       current
    DESCRIPTION  "Entry in Switch Port table"
    INDEX        { switchIndex,
                   switchPortIndex }
    ::= { switchPortTable 1 }

SwitchPortEntry ::= SEQUENCE {
    switchPortIndex       Unsigned32,
    switchPortStatus      INTEGER,
    switchLinkLastChange  DateAndTime
    }

switchPortIndex OBJECT-TYPE
   SYNTAX     Unsigned32 (1..4294967295)
   MAX-ACCESS not-accessible
   STATUS     current
   DESCRIPTION
       "A strictly monotonically increasing integer which
       acts as the index of entries within the switch
       port list.  It wraps back to 1 after it reaches its
       maximum value."
   ::= { switchPortEntry 1 }

switchPortStatus    OBJECT-TYPE
   SYNTAX      INTEGER { unknown(1), up(2), down(3) }
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "Port status (up/down)"
  ::= { switchPortEntry 2 }

switchLinkLastChange    OBJECT-TYPE
   SYNTAX      DateAndTime
   MAX-ACCESS  read-only
   STATUS      current
   DESCRIPTION
      "Time that switch link last changed state.

       Implementations MUST include the offset from UTC,
       if available.  Implementation in environments in which
       the UTC offset is not available is NOT RECOMMENDED."
  ::= { switchPortEntry 3 }


-- Conformance

switchConformance OBJECT IDENTIFIER ::= { switchMIB 2 }

switchCompliances OBJECT IDENTIFIER ::= { switchConformance 1 }

switchCompliance MODULE-COMPLIANCE
      STATUS  current
      DESCRIPTION
          "The compliance statement for systems supporting
          the Switch MIB."
      MODULE -- this module
          MANDATORY-GROUPS {
          switchObjectGroup,
          switchPortObjectGroup
          }
   ::= { switchCompliances 1 }

switchGroups OBJECT IDENTIFIER ::= { switchConformance 2 }

switchObjectGroup OBJECT-GROUP
    OBJECTS {
        switchTableLastChanged,
        switchDateAndTime,
        switchName,
        switchEnabled,
        switchLostContact,
        switchDeviceSerialNumber
        }
        STATUS   current
        DESCRIPTION
            "Switch list object group."
        ::= { switchGroups 1}

switchPortObjectGroup OBJECT-GROUP
    OBJECTS {
        switchPortStatus,
        switchLinkLastChange
        }
        STATUS   current
        DESCRIPTION
            "Switch port list object group."
        ::= { switchGroups 2}

END
