public SmiMib process(Object input) throws PhaseException { ASNMib asnMib = (ASNMib) input; SmiMib result = new SmiMib(new SmiJavaCodeNamingStrategy("org.jsmiparser.mib")); // TODO for (ASNModule am : asnMib.getModules()) { SmiModule sm = result.createModule(am.getIdToken()); processModule(result, am, sm); } return result; }
/** * Gets the module. * * @param mibObject the MIB object * @param mibFile the MIB file * @return the module */ private SmiModule getModule(SmiMib mibObject, File mibFile) { for (SmiModule m : mibObject.getModules()) { if (m.getIdToken().getLocation().getSource().contains(mibFile.getAbsolutePath())) { return m; } } errorHandler.addError("Can't find the MIB module for " + mibFile); return null; }
protected void checkOidTree(SmiMib mib) { // mib.getRootNode().dumpTree(System.out, ""); int count = 0; for (SmiSymbol symbol : mib.getSymbols()) { if (symbol instanceof SmiOidValue) { SmiOidValue oidValue = (SmiOidValue) symbol; // oidValue.dumpAncestors(System.out); if (oidValue.getNode() != mib.getRootNode()) { String msg = oidValue.getIdToken().toString(); assertNotNull(msg, oidValue.getNode().getParent()); SmiOidNode foundOidNode = oidValue.getNode().getParent().findChild(oidValue.getNode().getValue()); assertNotNull(msg, foundOidNode); assertSame(msg, oidValue.getNode(), foundOidNode); assertTrue(msg, oidValue.getNode().getParent().contains(oidValue.getNode())); } // SmiOidValue foundSymbol = findOidSymbol(mib.getRootNode(), // symbol.getId()); // assertNotNull(symbol.getId(), foundSymbol); // assertSame(symbol.getId(), symbol, foundSymbol); count++; } } // mib.getRootNode().dumpTree(System.out, ""); int totalChildCount = mib.getRootNode().getTotalChildCount(); // assertTrue(count + " < " + totalChildCount, count < totalChildCount); // System.out.println("totalChildCount: " + totalChildCount); // I don't think you can draw any conclusions based on the count: // - due to anonymous oid node, you can have more oid nodes than oid symbols // - due to duplicated symbols you can have more symbols than nodes: // assertEquals(count + mib.getDummyOidNodesCount(), totalChildCount); }
protected void checkObjectTypeAccessAll(SmiMib mib) { for (SmiObjectType objectType : mib.getObjectTypes()) { assertNotNull(objectType.getId(), objectType.getAccessAll()); } }