package art.servers.signalsboardserver.controller.trapreceiver;
|
|
import art.library.net.snmp.SNMPTrapReceiver;
|
import art.library.net.snmp.SNMPListener;
|
import art.servers.signalsboardserver.Shared;
|
import art.servers.signalsboardserver.controller.ControllerUniversal;
|
import java.util.List;
|
import org.snmp4j.smi.VariableBinding;
|
|
|
public class TrapReceiver
|
{
|
private SNMPTrapReceiver receiver = null;
|
|
|
public TrapReceiver()
|
{
|
try
|
{
|
receiver = new SNMPTrapReceiver("127.0.0.1", 162, "public");
|
receiver.addListener(new MyListener());
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
|
|
private static class MyListener extends SNMPListener
|
{
|
public void trap(String sourceAddress, List<VariableBinding> variables)
|
{
|
try
|
{
|
Shared.println("TrapListener", "Received trap from " + sourceAddress);
|
|
// TODO: Get SNMP with this address
|
ControllerUniversal controller = Shared.controllersSnmp.get(sourceAddress);
|
controller.trapReceived(sourceAddress, variables);
|
// for (VariableBinding variable : variables)
|
// {
|
// try
|
// {
|
// Shared.println("TrapListener", "Variable: " + variable.toString());
|
// Shared.println("TrapListener", "Variable OID: " + variable.getOid().toString());
|
// controller.trapReceived(sourceAddress, variable);
|
// }
|
// catch (Exception e)
|
// {
|
// }
|
// }
|
}
|
catch (Exception exception)
|
{
|
|
}
|
}
|
}
|
|
}
|