本文整理汇总了C++中OctetStr::set_data方法的典型用法代码示例。如果您正苦于以下问题:C++ OctetStr::set_data方法的具体用法?C++ OctetStr::set_data怎么用?C++ OctetStr::set_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OctetStr
的用法示例。
在下文中一共展示了OctetStr::set_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debugprintf
//.........这里部分代码省略.........
break;
}
case SNMPv3_USM_NOT_IN_TIME_WINDOW:
case SNMPv3_MP_NOT_IN_TIME_WINDOW: {
counterVb.set_oid(oidUsmStatsNotInTimeWindows);
counterVb.set_value(Counter32(usm->get_stats_not_in_time_windows()));
break;
}
case SNMPv3_USM_DECRYPTION_ERROR: {
counterVb.set_oid(oidUsmStatsDecryptionErrors);
counterVb.set_value(Counter32(usm->get_stats_decryption_errors()));
//sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
break;
}
case SNMPv3_USM_AUTHENTICATION_ERROR:
case SNMPv3_USM_AUTHENTICATION_FAILURE: {
counterVb.set_oid(oidUsmStatsWrongDigests);
counterVb.set_value(Counter32(usm->get_stats_wrong_digests()));
//sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
break;
}
case SNMPv3_USM_UNKNOWN_ENGINEID:
case SNMPv3_MP_INVALID_ENGINEID: {
//sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
counterVb.set_oid(oidUsmStatsUnknownEngineIDs);
counterVb.set_value(Counter32(usm->get_stats_unknown_engine_ids()));
break;
}
case SNMPv3_MP_UNSUPPORTED_SECURITY_MODEL: {
counterVb.set_oid(oidSnmpUnknownSecurityModels);
counterVb.set_value(Counter32(get_stats_unknown_security_models()));
sModel = SNMP_SECURITY_MODEL_USM;
sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
break;
}
case SNMPv3_USM_UNKNOWN_SECURITY_NAME: {
counterVb.set_oid(oidUsmStatsUnknownUserNames);
counterVb.set_value(Counter32(usm->get_stats_unknown_user_names()));
sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
debugprintf(2, "Report: SecurityName: %s",sName.get_printable());
break;
}
case SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL: {
counterVb.set_oid(oidUsmStatsUnsupportedSecLevels);
counterVb.set_value(Counter32(usm->get_stats_unsupported_sec_levels()));
sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
break;
}
default: {
counterVb.set_oid(oidSnmpInvalidMsgs);
counterVb.set_value(Counter32(get_stats_invalid_msgs()));
sModel = SNMP_SECURITY_MODEL_USM;
sLevel = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
sName.set_data(0, 0);
debugprintf(2, "ErrorCode was %i in snmp_parse", errorCode);
}
} // end switch
counterVb.get_oid(counterOid);
smioid = counterOid.oidval();
int status = convertVbToSmival(counterVb, &smival);
if (status != SNMP_CLASS_SUCCESS) {
return SNMPv3_MP_ERROR;
}
snmp_add_var(pdu, smioid->ptr,
(int) smioid->len, &smival);
freeSmivalDescriptor(&smival);
Buffer<unsigned char> sendbuffer(MAX_SNMP_PACKET);
int sendbufferlen= MAX_SNMP_PACKET;
status = snmp_build( pdu, sendbuffer.get_ptr(), &sendbufferlen,
own_engine_id_oct, sName, sModel, sLevel,
OctetStr(cEngineID, cEngineIDLength),
OctetStr(cName, cNameLength));
if (status != SNMPv3_MP_OK) {
debugprintf(2, "v3MP::send_report: error serializing message (mpSnmpBuild returns: %i).", status);
return SNMPv3_MP_ERROR;
}
SnmpSocket send_fd = INVALID_SOCKET;
if (pdu_type == sNMP_PDU_INFORM)
{
debugprintf(4, "Received a snmpInform pdu.");
if (snmp_session->get_eventListHolder()->notifyEventList())
send_fd = snmp_session->get_eventListHolder()->notifyEventList()->get_notify_fd();
}
status = snmp_session->send_raw_data(sendbuffer.get_ptr(),
(size_t)sendbufferlen,// pdu to send
destination, // target address
send_fd); // the fd to use
if ( status != 0)
{
debugprintf(1, "v3MP::send_report: error sending message (%i)", status);
return SNMPv3_MP_ERROR;
}
debugprintf(3, "v3MP::send_report: Report sent.");
return SNMPv3_MP_OK;
}
示例2: unload
// unload the data into SNMP++ objects
int SnmpMessage::unload(Pdu &pdu, // Pdu object
OctetStr &community, // community object
snmp_version &version, // SNMP version #
OctetStr *engine_id, // optional v3
OctetStr *security_name, // optional v3
long int *security_model,
UdpAddress *from_addr,
Snmp *snmp_session)
{
pdu.clear();
if (!valid_flag)
return SNMP_CLASS_INVALID;
snmp_pdu *raw_pdu;
raw_pdu = snmp_pdu_create(0); // do a "snmp_free_pdu( raw_pdu)" before return
int status;
#ifdef _SNMPv3
OctetStr context_engine_id;
OctetStr context_name;
long int security_level = SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV;
if ((security_model) && (security_name) && (engine_id) && (snmp_session)) {
status = v3MP::I->snmp_parse(snmp_session, raw_pdu,
databuff, (int)bufflen, *engine_id,
*security_name, context_engine_id, context_name,
security_level, *security_model, version, *from_addr);
if (status != SNMPv3_MP_OK) {
pdu.set_request_id( raw_pdu->reqid);
pdu.set_type( raw_pdu->command);
snmp_free_pdu( raw_pdu);
return status;
}
pdu.set_context_engine_id(context_engine_id);
pdu.set_context_name(context_name);
pdu.set_security_level(security_level);
pdu.set_message_id(raw_pdu->msgid);
pdu.set_maxsize_scopedpdu(raw_pdu->maxsize_scopedpdu);
}
else {
#endif
unsigned char community_name[MAX_LEN_COMMUNITY + 1];
int community_len = MAX_LEN_COMMUNITY + 1;
status = snmp_parse(raw_pdu, databuff, (int) bufflen,
community_name, community_len, version);
if (status != SNMP_CLASS_SUCCESS) {
snmp_free_pdu(raw_pdu);
return status;
}
community.set_data( community_name, community_len);
#ifdef _SNMPv3
}
#endif
// load up the SNMP++ variables
pdu.set_request_id(raw_pdu->reqid);
pdu.set_error_status((int) raw_pdu->errstat);
pdu.set_error_index((int) raw_pdu->errindex);
pdu.set_type( raw_pdu->command);
// deal with traps a little different
if ( raw_pdu->command == sNMP_PDU_V1TRAP) {
// timestamp
TimeTicks timestamp;
timestamp = raw_pdu->time;
pdu.set_notify_timestamp( timestamp);
// set the agent address
IpAddress agent_addr(inet_ntoa(raw_pdu->agent_addr.sin_addr));
if (agent_addr != "0.0.0.0")
{
pdu.set_v1_trap_address(agent_addr);
LOG_BEGIN(DEBUG_LOG | 4);
LOG("SNMPMessage: Trap address of received v1 trap");
LOG(agent_addr.get_printable());
LOG_END;
}
// set enterprise, notifyid
Oid enterprise;
if (raw_pdu->enterprise_length >0) {
for (int i=0; i< raw_pdu->enterprise_length; i++) {
enterprise += (int) (raw_pdu->enterprise[i]);
}
pdu.set_notify_enterprise(enterprise);
}
switch (raw_pdu->trap_type) {
case 0:
pdu.set_notify_id(coldStart);
break;
case 1:
pdu.set_notify_id(warmStart);
break;
//.........这里部分代码省略.........