Ejemplo n.º 1
0
  protected void updateIpRouteClassNames() {
    m_oidMask2IpRouteclassName.clear();
    try {
      getWriteLock().lock();
      final Iproutes iproutes = m_config.getIproutes();
      if (iproutes == null) {
        LOG.info("no iproutes found in config");
        return;
      }

      for (final Vendor vendor : iproutes.getVendorCollection()) {
        final SnmpObjectId curRootSysOid = new SnmpObjectId(vendor.getSysoidRootMask());
        final String curClassName = vendor.getClassName();

        for (final String specific : vendor.getSpecific()) {
          final SnmpObjectId oidMask = new SnmpObjectId(specific);
          oidMask.prepend(curRootSysOid);
          m_oidMask2IpRouteclassName.put(oidMask.toString(), curClassName);
          LOG.debug(
              "initializeIpRouteClassNames:  adding class {} for oid {}", curClassName, oidMask);
        }
      }
    } finally {
      getWriteLock().unlock();
    }
  }
 @Override
 protected TrapIdentity getTrapIdentity() {
   // Get the value for the snmpTrapOID
   SnmpObjectId snmpTrapOid =
       (SnmpObjectId) m_pdu.getVarBindAt(V2TrapInformation.SNMP_TRAP_OID_INDEX).getValue();
   SnmpObjectId lastVarBindOid = m_pdu.getVarBindAt(getPduLength() - 1).getName();
   SnmpSyntax lastVarBindValue = m_pdu.getVarBindAt(getPduLength() - 1).getValue();
   return new TrapIdentity(
       SnmpObjId.get(snmpTrapOid.getIdentifiers()),
       SnmpObjId.get(lastVarBindOid.getIdentifiers()),
       new JoeSnmpValue(lastVarBindValue));
 }
Ejemplo n.º 3
0
 private SnmpObjectId getRootOid(final SnmpObjectId snmpObj) {
   try {
     getReadLock().lock();
     final int[] identifiers = snmpObj.getIdentifiers();
     final int[] rootIdentifiers = new int[identifiers.length - 1];
     System.arraycopy(identifiers, 0, rootIdentifiers, 0, rootIdentifiers.length);
     return new SnmpObjectId(rootIdentifiers);
   } finally {
     getReadLock().unlock();
   }
 }
Ejemplo n.º 4
0
  protected void updateVlanClassNames() {
    m_oidMask2VlanclassName.clear();
    try {
      getWriteLock().lock();
      final Vlans vlans = m_config.getVlans();
      if (vlans == null) {
        LOG.info("initializeVlanClassNames: no vlans found in config");
      }

      final List<String> excludedOids = new ArrayList<String>();
      for (final Vendor vendor : vlans.getVendorCollection()) {
        final SnmpObjectId curRootSysOid = new SnmpObjectId(vendor.getSysoidRootMask());
        final String curClassName = vendor.getClassName();

        for (final String specific : vendor.getSpecific()) {
          final SnmpObjectId oidMask = new SnmpObjectId(specific);
          oidMask.prepend(curRootSysOid);
          m_oidMask2VlanclassName.put(oidMask.toString(), curClassName);
          LOG.debug("initializeVlanClassNames:  adding class {} for oid {}", curClassName, oidMask);
        }

        for (final ExcludeRange excludeRange : vendor.getExcludeRangeCollection()) {
          final SnmpObjectId snmpBeginOid = new SnmpObjectId(excludeRange.getBegin());
          final SnmpObjectId snmpEndOid = new SnmpObjectId(excludeRange.getEnd());
          final SnmpObjectId snmpRootOid = getRootOid(snmpBeginOid);
          if (snmpBeginOid.getLength() == snmpEndOid.getLength()
              && snmpRootOid.isRootOf(snmpEndOid)) {
            final SnmpObjectId snmpCurOid = new SnmpObjectId(snmpBeginOid);
            while (snmpCurOid.compare(snmpEndOid) <= 0) {
              excludedOids.add(snmpCurOid.toString());
              LOG.debug(
                  "initializeVlanClassNames:  signing excluded class {} for oid {}",
                  curClassName,
                  curRootSysOid.toString().concat(snmpCurOid.toString()));
              int lastCurCipher = snmpCurOid.getLastIdentifier();
              lastCurCipher++;
              int[] identifiers = snmpCurOid.getIdentifiers();
              identifiers[identifiers.length - 1] = lastCurCipher;
              snmpCurOid.setIdentifiers(identifiers);
            }
          }
        }

        for (final IncludeRange includeRange : vendor.getIncludeRangeCollection()) {
          final SnmpObjectId snmpBeginOid = new SnmpObjectId(includeRange.getBegin());
          final SnmpObjectId snmpEndOid = new SnmpObjectId(includeRange.getEnd());
          final SnmpObjectId rootOid = getRootOid(snmpBeginOid);
          if (snmpBeginOid.getLength() == snmpEndOid.getLength() && rootOid.isRootOf(snmpEndOid)) {
            final SnmpObjectId snmpCurOid = new SnmpObjectId(snmpBeginOid);
            while (snmpCurOid.compare(snmpEndOid) <= 0) {
              if (!excludedOids.contains(snmpBeginOid.toString())) {
                final SnmpObjectId oidMask = new SnmpObjectId(snmpBeginOid);
                oidMask.prepend(curRootSysOid);
                m_oidMask2VlanclassName.put(oidMask.toString(), curClassName);
                LOG.debug(
                    "initializeVlanClassNames:  adding class {} for oid {}", curClassName, oidMask);
              }
              int lastCipher = snmpBeginOid.getLastIdentifier();
              lastCipher++;
              int[] identifiers = snmpBeginOid.getIdentifiers();
              identifiers[identifiers.length - 1] = lastCipher;
              snmpCurOid.setIdentifiers(identifiers);
            }
          }
        }
      }
    } finally {
      getWriteLock().unlock();
    }
  }