version 1.35, 2007/03/16 17:16:54
|
version 1.36, 2007/04/10 20:31:14
|
|
|
Array<String> propTYPEs; | Array<String> propTYPEs; |
Array<String> propVALUEs; | Array<String> propVALUEs; |
| |
CIMProperty prop; |
Array<String> mapStr; |
CIMQualifier trapQualifier; |
|
|
|
Uint32 qualifierPos; |
|
|
|
String propValue; |
|
|
|
String mapstr1; |
|
String mapstr2; |
|
| |
PEG_METHOD_ENTER(TRC_IND_HANDLER, | PEG_METHOD_ENTER(TRC_IND_HANDLER, |
"snmpIndicationHandler::handleIndication"); | "snmpIndicationHandler::handleIndication"); |
|
|
| |
for (Uint32 i=0; i < propertyCount; i++) | for (Uint32 i=0; i < propertyCount; i++) |
{ | { |
prop = indication.getProperty(i); |
CIMProperty prop = indication.getProperty(i); |
| |
if (!prop.isUninitialized()) |
Uint32 propDeclPos = indicationClass.findProperty(prop.getName()); |
{ |
if (propDeclPos != PEG_NOT_FOUND) |
CIMName propName = prop.getName(); |
|
Uint32 propPos = indicationClass.findProperty(propName); |
|
if (propPos != PEG_NOT_FOUND) |
|
{ | { |
CIMProperty trapProp = indicationClass.getProperty(propPos); |
CIMProperty propDecl = indicationClass.getProperty(propDeclPos); |
| |
qualifierPos = |
Uint32 qualifierPos = |
trapProp.findQualifier(CIMName("MappingStrings")); |
propDecl.findQualifier(CIMName("MappingStrings")); |
if (qualifierPos != PEG_NOT_FOUND) | if (qualifierPos != PEG_NOT_FOUND) |
{ | { |
trapQualifier = trapProp.getQualifier(qualifierPos); |
// |
|
// We are looking for following fields: |
|
// MappingStrings {"OID.IETF | SNMP." oidStr, |
|
// "DataType.IETF |" dataType} |
|
// oidStr is the object identifier (e.g. "1.3.6.1.2.1.5..." |
|
// dataType is either Integer, or OctetString, |
|
// or OID |
|
// Following is one example: |
|
// MappingStrings {"OID.IETF | SNMP.1.3.6.6.3.1.1.5.2", |
|
// "DataType.IETF | Integer"} |
|
// |
|
|
|
propDecl.getQualifier(qualifierPos).getValue().get( |
|
mapStr); |
| |
mapstr1.clear(); |
String oidStr, dataType; |
mapstr1 = trapQualifier.getValue().toString(); |
String mapStr1, mapStr2; |
|
Boolean isValidAuthority = false; |
|
Boolean isValidDataType = false; |
| |
if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) && |
for (Uint32 j=0; j < mapStr.size(); j++) |
(mapstr1.find("DataType.IETF") != PEG_NOT_FOUND)) |
|
{ | { |
if (mapstr1.subString(0, 8) == "OID.IETF") |
Uint32 barPos = mapStr[j].find("|"); |
{ |
|
mapstr1 = mapstr1.subString( |
if (barPos != PEG_NOT_FOUND) |
mapstr1.find("SNMP.") + 5); |
{ |
if (mapstr1.find("|") != PEG_NOT_FOUND) |
mapStr1 = mapStr[j].subString(0, barPos); |
{ |
mapStr2 = mapStr[j].subString(barPos + 1); |
mapstr2.clear(); |
|
mapstr2 = mapstr1.subString(0, |
_trimWhitespace(mapStr1); |
mapstr1.find("DataType.IETF")-1); |
_trimWhitespace(mapStr2); |
propOIDs.append(mapstr2); |
|
|
if ((mapStr1 == "OID.IETF") && |
propValue.clear(); |
(String::compare(mapStr2, |
propValue = prop.getValue().toString(); |
String("SNMP."), 5) == 0)) |
propVALUEs.append(propValue); |
{ |
|
isValidAuthority = true; |
mapstr2 = mapstr1.subString( |
oidStr = mapStr2.subString(5); |
mapstr1.find("|") + 2); |
|
mapstr2 = mapstr2.subString( |
|
0, mapstr2.size() - 1); |
|
propTYPEs.append(mapstr2); |
|
} | } |
|
else if (mapStr1 == "DataType.IETF") |
|
{ |
|
isValidDataType = true; |
|
dataType = mapStr2; |
|
} |
|
|
|
if (isValidAuthority && isValidDataType) |
|
{ |
|
propOIDs.append(oidStr); |
|
propTYPEs.append(dataType); |
|
propVALUEs.append(prop.getValue().toString()); |
|
|
|
break; |
} | } |
} | } |
} | } |
|
|
Uint32 portNumber; | Uint32 portNumber; |
| |
String trapOid; | String trapOid; |
|
Boolean trapOidAvailable = false; |
|
String exceptionStr; |
// | // |
// Get snmpTrapOid from context | // Get snmpTrapOid from context |
// | // |
|
|
context.get(SnmpTrapOidContainer::NAME); | context.get(SnmpTrapOidContainer::NAME); |
| |
trapOid = trapContainer.getSnmpTrapOid(); | trapOid = trapContainer.getSnmpTrapOid(); |
|
trapOidAvailable = true; |
} | } |
else | else |
{ | { |
|
|
indicationClass.findQualifier(CIMName("MappingStrings")); | indicationClass.findQualifier(CIMName("MappingStrings")); |
if (pos != PEG_NOT_FOUND) | if (pos != PEG_NOT_FOUND) |
{ | { |
trapOid = |
Array<String> classMapStr; |
indicationClass.getQualifier(pos).getValue().toString(); |
indicationClass.getQualifier(pos).getValue(). |
|
get(classMapStr); |
|
|
|
for (Uint32 i=0; i < classMapStr.size(); i++) |
|
{ |
|
Uint32 barPos = classMapStr[i].find("|"); |
| |
trapOid = trapOid.subString(11, PEG_NOT_FOUND); |
if (barPos != PEG_NOT_FOUND) |
|
{ |
|
String authorityName = |
|
classMapStr[i].subString(0, barPos); |
|
String oidStr = classMapStr[i].subString( |
|
barPos+1, PEG_NOT_FOUND); |
|
|
|
_trimWhitespace(authorityName); |
|
_trimWhitespace(oidStr); |
| |
if ((String::compare(trapOid, "SNMP.", 5)) == 0) |
if ((authorityName == "OID.IETF") && |
|
(String::compare(oidStr, |
|
String("SNMP."), 5) == 0)) |
{ | { |
trapOid = trapOid.subString(5, (trapOid.size()-6)); |
trapOid = oidStr.subString(5); |
|
trapOidAvailable = true; |
|
break; |
} | } |
else |
} |
|
} |
|
|
|
if (!trapOidAvailable) |
{ | { |
|
exceptionStr = "No MappingStrings for snmp trap" |
|
"is specified for class: "; |
|
|
|
exceptionStr.append( |
|
indication.getClassName().getString()); |
|
|
PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, | PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, |
"Invalid MappingStrings Value " + trapOid); |
exceptionStr); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, | throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, |
MessageLoaderParms( | MessageLoaderParms( |
"Handler.snmpIndicationHandler." | "Handler.snmpIndicationHandler." |
"snmpIndicationHandler.INVALID_MS_VALUE", |
"snmpIndicationHandler.NO_MS_FOR_SNMP_TRAP", |
"Invalid MappingStrings Value")); |
exceptionStr)); |
} | } |
} | } |
else | else |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
void snmpIndicationHandler::_trimWhitespace( |
|
String & nameStr) |
|
{ |
|
PEG_METHOD_ENTER(TRC_IND_HANDLER, |
|
"snmpIndicationHandler::_trimWhitespace"); |
|
|
|
Uint32 ps = 0; |
|
// skip begining whitespace |
|
for (ps = 0; ps < nameStr.size(); ps++) |
|
{ |
|
if (nameStr[ps] != ' ') |
|
{ |
|
break; |
|
} |
|
} |
|
|
|
if (ps != 0) |
|
{ |
|
nameStr.remove(0, ps); |
|
} |
|
|
|
// skip the appended whitespace |
|
for (ps = nameStr.size(); ps != 0; ps--) |
|
{ |
|
if (nameStr[ps-1] != ' ') |
|
{ |
|
break; |
|
} |
|
} |
|
|
|
if (ps != nameStr.size()) |
|
{ |
|
nameStr.remove(ps); |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
PEGASUS_USING_PEGASUS; | PEGASUS_USING_PEGASUS; |