SNMPTrapListener.java revision d81978a0815d5b8a75633c35e3e1f8708d36f017
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
*/
// OpenDMK Imports
//
/**
* This class perform a SNMP trap listener.
*/
public class SNMPTrapListener implements SnmpTrapListener {
/**
* Callback for SNMP v1 traps.
*
* @param trap trap information
*/
} else {
}
}
/**
* Callback for SNMP v2c traps.
*
* @param trap trap information
*/
} else {
}
}
/**
* Callback for SNMP v3 traps.
*
* @param trap trap information
*/
} else {
}
}
/**
* Gets the calling arguments.
*
* @param args SNMP agent version + SNMP agent host + SNMP agent port
* @return 0 if the init succeeded or 1 if the init failed
*/
int rc = 0;
// Missing arguments
"usage: " +
" -h <remoteHost>" +
" -p <port>" +
" -t <number>" +
" -c <community>");
rc = 1;
} else {
case 'h':
remoteHost = val;
break;
case 'p':
break;
case 't':
break;
case 'c':
break;
default:
rc = 1;
}
if (rc == 1) {
break;
}
i = i + 1;
}
}
if (rc == 0) {
} else {
}
return rc;
}
/**
* Run the trap listener.
*
* @return 0 if the run succeeded or 1 if the run failed
*/
public int run() {
int rc = 0;
try {
trapAgent.addTrapListener(this);
t.start();
"run() of SNMPTrapListener: Listen traps on port " + port);
// Register with STAF
// Post event to notice that the trap listener is ready
"run() of SNMPTrapListener: Send \"SNMPTrapListener/Ready\"" +
// Wait event which notices that all the traps have been sent
// Delte event
// Display status of the traps
"run() of SNMPTrapListener has catched " +
currentTrapNumber + " traps.");
// Status of the trap listener
nbTrapV1_community + "," +
nbTrapV1_otherCommunity + "," +
nbTrapV2_community + "," +
nbTrapV2_otherCommunity + "," +
nbTrapV3_community + "," +
rc = 1;
}
} catch (Exception e) {
rc = 1;
}
if (rc == 0) {
} else {
}
return rc;
}
/**
* Main.
*
* @param args arguments
*/
int rc = 0;
// Retrieve parameters
// If init() succeeded then run the trap listener
if (rc == 0) {
}
}
// Arguments
int port = 0;
int currentTrapNumber = 0;
int nbTrapV1_community = 0;
int nbTrapV1_otherCommunity = 0;
int nbTrapV2_community = 0;
int nbTrapV2_otherCommunity = 0;
int nbTrapV3_community = 0;
int nbTrapV3_otherCommunity = 0;
}