[SNMP4J] SNMP4J-Agent API [was: SNMP doubts]

Frank Fock fock at agentpp.com
Thu Mar 31 18:46:59 CEST 2005


Hi Kevin,

Kevin J. Schmidt wrote:

>Frank: Are you working on an SNMP4J agent? If so, will it be a tool
>kit or a full-blown implementation, or?
>
>  
>
The SNMP4J-Agent API will be toolkit although it will provide 
implementations
of the SNMP-TARGET-MIB, SNMP-NOTIFICATION-MIB,
SNMP-FRAMEWORK-MIB, SNMPv2-MIB, SNMP-USER-BASED-SM-MIB,
SNMP-COMMUNITY-MIB, SNMP-VIEW-BASED-ACM-MIB, and
SNMP-MPD-MIB.
As this is the MIB set the 1.0 version will support, additional MIB 
modules will
be added later on (for example NOTIFICTION-LOG-MIB).

It will be a toolkit where you can put together an agent with a few 
lines of code as
the following code snippet from my test-agent shows:

  public TestAgent() throws IOException {
    transportMapping =
        new DefaultUdpTransportMapping(new UdpAddress("0.0.0.0/4700"));
    dispatcher = new MessageDispatcherImpl();
    session = new Snmp(dispatcher, transportMapping);
    MPv3 mpv3 = new MPv3();
    USM usm = new USM(SecurityProtocols.getInstance(),
                      new OctetString(mpv3.getLocalEngineID()),
                      getEngineBoots());
    SecurityModels.getInstance().addSecurityModel(usm);
    SecurityProtocols.getInstance().addDefaultProtocols();
    dispatcher.addMessageProcessingModel(new MPv1());
    dispatcher.addMessageProcessingModel(new MPv2c());
    dispatcher.addMessageProcessingModel(mpv3);
    agent = new CommandProcessor(new OctetString(mpv3.getLocalEngineID()));
    server = new DefaultMOServer();
    server.addContext(new OctetString());
    sysGroup = new SystemGroup(new OctetString("SNMP4J Test-Agent"),
                               new OID("1.3.6.1.4.1.4976"),
                               new Integer32(10));
    snmpFrameworkMIB =
        new SnmpFrameworkMIB((USM)
                             
mpv3.getSecurityModel(SecurityModel.SECURITY_MODEL_USM),
                             dispatcher.getTransportMappings());
    UsmMIB usmMIB = new UsmMIB(usm, SecurityProtocols.getInstance());
    usm.addUsmUserListener(usmMIB);

    VacmMIB vacmMIB = new VacmMIB(server);

    // add USM users
    addUsmUser(usm);

    try {
      vacmMIB.registerMOs(server, null);
      usmMIB.registerMOs(server, null);
      sysGroup.registerMOs(server, null);
      snmpFrameworkMIB.registerMOs(server, null);
      server.register(createStaticIfTable(), null);
    }
    catch (DuplicateRegistrationException ex) {
      ex.printStackTrace();
    }
    agent.addMOServer(server);
    addViews(vacmMIB);
    agent.setVacm(vacmMIB);
    dispatcher.addCommandResponder(agent);
  }


Best regards,
Frank




More information about the SNMP4J mailing list