Commits

stingh711 committed 0a27b2f

add mib and configure for topology

  • Participants
  • Parent commits 5407528

Comments (0)

Files changed (2)

config.properties

 topology.device.firmware.2=1.1
 topology.device.hardware.2=1.1
 
+topology.link.number=2
+topology.link.src.ip.1=172.25.21.69
+topology.link.src.port.1=3
+topology.link.dst.ip.1=172.25.21.70
+topology.link.dst.port.1=0
+topology.link.type.1=2
+topology.link.src.ip.2=172.25.21.69
+topology.link.src.port.2=3
+topology.link.dst.ip.2=172.25.21.70
+topology.link.dst.port.2=0
+topology.link.type.2=2
+
 app.statistics.10mins.number=7
 app.statistics.10mins.name.1=qq
 app.statistics.10mins.traffic.1=1000

src/com/zyxel/enc/netbar/agent/NRrouterMib.java

     private static final OID nsAppStatisticsAll = new OID("1.3.6.1.4.1.890.1.5.17.1.5.4.1.1");
     private static final OID nsIfTable = new OID("1.3.6.1.4.1.890.1.5.17.1.6.1.1");
     private static final OID nsWanIfTable = new OID("1.3.6.1.4.1.890.1.5.17.1.7.1.1");
+    private static final OID oidTopologyLinks = new OID("1.3.6.1.4.1.890.1.5.17.1.9.2.1.1");
+    private static final OID oidCurrentLinks = new OID("1.3.6.1.4.1.890.1.5.17.1.3.1.1");
     private static long startTime = 0;
-    //Topology devices table columns
+    //Topology devices table
     private DefaultMOTable deviceTable;
+    //Topology links table
+    private DefaultMOTable linkTable;
     //App Statistics 10 mins table
     private DefaultMOTable app10MinsTable;
     private DefaultMOTable app3hoursTable;
     private MOTableIndex wanInterfaceTableIndex = new MOTableIndex(wanInterfaceTableIndexs, false);
     private MOTableSubIndex[] interfaceTableIndexs = new MOTableSubIndex[]{new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)};
     private MOTableIndex interfaceTableIndex = new MOTableIndex(interfaceTableIndexs, false);
+    private MOTableSubIndex[] linkTableIndexs = new MOTableSubIndex[]{new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)};
+    private MOTableIndex linkTableIndex = new MOTableIndex(linkTableIndexs, false);
 
     private static String getCurrentTimeAsString() {
         return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
         server.register(new DateAndTimeScalar(nsSysDateTime, MOAccessImpl.ACCESS_READ_ONLY, new OctetString(getCurrentTimeAsString())), context);
         createTopologyTables();
         server.register(deviceTable, context);
+        
+        createLinkTables();
+        server.register(linkTable, context);
+        
         createAppStatisticsTables();
         server.register(app10MinsTable, context);
         server.register(app3hoursTable, context);
         deviceTable.setVolatile(true);
     }
 
+    private void createLinkTables() {
+        MOColumn[] columns = new MOColumn[5];
+        columns[0] = new MOColumn(1, SMIConstants.SYNTAX_IPADDRESS, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[1] = new MOColumn(2, SMIConstants.SYNTAX_INTEGER32, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[2] = new MOColumn(3, SMIConstants.SYNTAX_IPADDRESS, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[3] = new MOColumn(4, SMIConstants.SYNTAX_INTEGER32, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[4] = new MOColumn(5, SMIConstants.SYNTAX_INTEGER32, MOAccessImpl.ACCESS_READ_ONLY);
+        linkTable = new DefaultMOTable(oidTopologyLinks, linkTableIndex, columns);
+        MOMutableTableModel model = (MOMutableTableModel) linkTable.getModel();
+
+        int number = Integer.parseInt(Config.get("topology.link.number"));
+
+        for (int i = 1; i <= number; i++) {
+            Variable[] v = new Variable[]{
+                new IpAddress(Config.get("topology.link.src.ip." + i)),
+                new Integer32(Integer.valueOf(Config.get("topology.link.src.port." + i))),
+                new IpAddress(Config.get("topology.link.dst.ip." + i)),
+                new Integer32(Integer.valueOf(Config.get("topology.link.dst.port." + i))),
+                new Integer32(Integer.valueOf(Config.get("topology.link.type." + i))),
+            };
+            model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)), v));
+        }
+
+        linkTable.setVolatile(true);
+    }
+    
     private void createRouterWanInterfaceTable() {
         MOColumn[] columns = new MOColumn[8];
         columns[0] = new MOColumn(1, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);