address= address + "/" + port;
Address targetAddress = GenericAddress.parse(address);
logger.info("sendig trap to: " + address + ", message: " + message);
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(community));
target.setAddress(targetAddress);
PDUv1 pdu = new PDUv1();
pdu.setType(PDU.V1TRAP);
VariableBinding vb = new VariableBinding();
OID oidMessage = new OID (alarmMessageOid);
vb.setOid(oidMessage);
if(message.length() < MAX_ALARM_MESSAGE_SIZE) {
vb.setVariable(new OctetString(message));
} else {
String tmpMessage = message.substring(0,MAX_ALARM_MESSAGE_SIZE);
logger.info(" message too long " + message +
". send " + tmpMessage);
vb.setVariable(new OctetString(tmpMessage));
}
pdu.add(vb);
OID oid = new OID(trapId);
if(trapType == CRITICAL_TRAP) {
pdu.setSpecificTrap(CRITICAL_TRAP);