您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ snmp_free_pdu函数代码示例

51自学网 2021-06-03 08:04:01
  C++
这篇教程C++ snmp_free_pdu函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中snmp_free_pdu函数的典型用法代码示例。如果您正苦于以下问题:C++ snmp_free_pdu函数的具体用法?C++ snmp_free_pdu怎么用?C++ snmp_free_pdu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了snmp_free_pdu函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _clone_pdu_header

/* * Creates and allocates a clone of the input PDU, * but does NOT copy the variables. * This function should be used with another function, * such as _copy_pdu_vars. * * Returns a pointer to the cloned PDU if successful. * Returns 0 if failure. */staticnetsnmp_pdu    *_clone_pdu_header(netsnmp_pdu *pdu){    netsnmp_pdu    *newpdu;    struct snmp_secmod_def *sptr;    newpdu = (netsnmp_pdu *) malloc(sizeof(netsnmp_pdu));    if (!newpdu)        return 0;    memmove(newpdu, pdu, sizeof(netsnmp_pdu));    /*     * reset copied pointers if copy fails      */    newpdu->variables = 0;    newpdu->enterprise = 0;    newpdu->community = 0;    newpdu->securityEngineID = 0;    newpdu->securityName = 0;    newpdu->contextEngineID = 0;    newpdu->contextName = 0;    newpdu->transport_data = 0;    /*     * copy buffers individually. If any copy fails, all are freed.      */    if (snmp_clone_mem((void **) &newpdu->enterprise, pdu->enterprise,                       sizeof(oid) * pdu->enterprise_length) ||        snmp_clone_mem((void **) &newpdu->community, pdu->community,                       pdu->community_len) ||        snmp_clone_mem((void **) &newpdu->contextEngineID,                       pdu->contextEngineID, pdu->contextEngineIDLen)        || snmp_clone_mem((void **) &newpdu->securityEngineID,                          pdu->securityEngineID, pdu->securityEngineIDLen)        || snmp_clone_mem((void **) &newpdu->contextName, pdu->contextName,                          pdu->contextNameLen)        || snmp_clone_mem((void **) &newpdu->securityName,                          pdu->securityName, pdu->securityNameLen)        || snmp_clone_mem((void **) &newpdu->transport_data,                          pdu->transport_data,                          pdu->transport_data_length)) {        snmp_free_pdu(newpdu);        return 0;    }    if ((sptr = find_sec_mod(newpdu->securityModel)) != NULL &&        sptr->pdu_clone != NULL) {        /*         * call security model if it needs to know about this          */        (*sptr->pdu_clone) (pdu, newpdu);    }    return newpdu;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:64,


示例2: send_trap_to_sess

/* * send_trap_to_sess: sends a trap to a session but assumes that the * pdu is constructed correctly for the session type.  */voidsend_trap_to_sess(netsnmp_session * sess, netsnmp_pdu *template_pdu){    netsnmp_pdu    *pdu;    int            result;    char           tmp[SPRINT_MAX_LEN];    int            len;    if (!sess || !template_pdu)        return;    DEBUGMSGTL(("trap", "sending trap type=%d, version=%d/n",                template_pdu->command, sess->version));#ifndef NETSNMP_DISABLE_SNMPV1    if (sess->version == SNMP_VERSION_1 &&        (template_pdu->command != SNMP_MSG_TRAP))        return;                 /* Skip v1 sinks for v2 only traps */    if (sess->version != SNMP_VERSION_1 &&        (template_pdu->command == SNMP_MSG_TRAP))        return;                 /* Skip v2+ sinks for v1 only traps */#endif    template_pdu->version = sess->version;    pdu = snmp_clone_pdu(template_pdu);    pdu->sessid = sess->sessid; /* AgentX only ? */    if ( template_pdu->command == SNMP_MSG_INFORM#ifdef USING_AGENTX_PROTOCOL_MODULE         || template_pdu->command == AGENTX_MSG_NOTIFY#endif       ) {        result =            snmp_async_send(sess, pdu, &handle_inform_response, NULL);            } else {        if ((sess->version == SNMP_VERSION_3) &&                (pdu->command == SNMP_MSG_TRAP2) &&                (pdu->securityEngineIDLen == 0)) {            len = snmpv3_get_engineID(tmp, sizeof(tmp));            memdup(&pdu->securityEngineID, tmp, len);            pdu->securityEngineIDLen = len;        }        result = snmp_send(sess, pdu);    }    if (result == 0) {        snmp_sess_perror("snmpd: send_trap", sess);        snmp_free_pdu(pdu);    } else {        snmp_increment_statistic(STAT_SNMPOUTTRAPS);        snmp_increment_statistic(STAT_SNMPOUTPKTS);    }}
开发者ID:grantc,项目名称:ingres-snmp-agent,代码行数:59,


示例3: getCurrentMeasurement

/** Get current from power supply*/double getCurrentMeasurement(HSNMP m_sessp, int channel) {  double value;  struct snmp_pdu* pdu = snmp_pdu_create(SNMP_MSG_GET);    // prepare get-request pdu  // for(each GET request to one crate) {    snmp_add_null_var(pdu,oidOutputMeasurementCurrent[channel],lengthOutputMeasurementCurrent[channel]);   // generate request data  // } // endfor  struct snmp_pdu* response;	int status = snmp_sess_synch_response(m_sessp,pdu,&response);  /*  * Process the response.  */  if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) {    /*    * SUCCESS: Print the result variables    */    struct variable_list *vars;        // debug print    //for(vars = response->variables; vars; vars = vars->next_variable)    //  print_variable(vars->name, vars->name_length, vars);    /* manipuate the information ourselves */    for(vars = response->variables; vars; vars = vars->next_variable) {			if (vars->type == ASN_OPAQUE_FLOAT) {				    // 0x78        value = *vars->val.floatVal;      }			else if (vars->type == ASN_OPAQUE_DOUBLE) {			// 0x79        value = *vars->val.doubleVal;      }			else if(vars->type == ASN_INTEGER) {				      // 0x02				value = (double)*vars->val.integer;      }    }  } else {    /*    * FAILURE: print what went wrong!    */    if (status == STAT_SUCCESS)      fprintf(stderr, "Error in packet/nReason: %s/n",      snmp_errstring(response->errstat));    else      snmp_sess_perror("snmpget",snmp_sess_session(m_sessp));    return 0;  }  snmp_free_pdu(response);  return value;}
开发者ID:BillMills,项目名称:GRIFFIN-SOH,代码行数:57,


示例4: handle_subagent_set_response

inthandle_subagent_set_response(int op, netsnmp_session * session, int reqid,                             netsnmp_pdu *pdu, void *magic){    netsnmp_session *retsess;    struct agent_netsnmp_set_info *asi;    if (op != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE || magic == NULL) {        return 1;    }    DEBUGMSGTL(("agentx/subagent",                "handling agentx subagent set response (mode=%d,req=0x%x,"                "trans=0x%x,sess=0x%x)/n",                pdu->command, pdu->reqid,pdu->transid, pdu->sessid));    pdu = snmp_clone_pdu(pdu);    asi = (struct agent_netsnmp_set_info *) magic;    retsess = asi->sess;    asi->errstat = pdu->errstat;    if (asi->mode == SNMP_MSG_INTERNAL_SET_RESERVE1) {        /*         * reloop for RESERVE2 mode, an internal only agent mode          */        /*         * XXX: check exception statuses of reserve1 first          */        if (!pdu->errstat) {            asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_RESERVE2;            snmp_async_send(agentx_callback_sess, pdu,                            handle_subagent_set_response, asi);            DEBUGMSGTL(("agentx/subagent",                        "  going from RESERVE1 -> RESERVE2/n"));            return 1;        }    } else {        if (asi->mode == SNMP_MSG_INTERNAL_SET_FREE ||            asi->mode == SNMP_MSG_INTERNAL_SET_UNDO ||            asi->mode == SNMP_MSG_INTERNAL_SET_COMMIT) {            free_set_vars(retsess, pdu);        }        pdu->variables = NULL;  /* the variables were added by us */    }    netsnmp_assert(retsess != NULL);    pdu->command = AGENTX_MSG_RESPONSE;    pdu->version = retsess->version;    if (!snmp_send(retsess, pdu)) {        snmp_free_pdu(pdu);    }    DEBUGMSGTL(("agentx/subagent", "  FINISHED/n"));    return 1;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:55,


示例5: setOutputRampUp

/** Write RampUp to power supply*/double  setOutputRampUp(HSNMP m_sessp,int channel,double value) {  struct snmp_pdu* pdu = snmp_pdu_create(SNMP_MSG_SET);    // prepare set-request pdu  pdu->community = (u_char*)strdup(writeCommunity);  pdu->community_len = strlen(writeCommunity);  // for(each SET request to one crate) {  float v = (float) value;  snmp_pdu_add_variable(pdu,oidOutputRampUp[channel],lengthOutputRampUp[channel],ASN_OPAQUE_FLOAT,(u_char*)&v,sizeof(v));  // } // endfor  struct snmp_pdu* response;	int status = snmp_sess_synch_response(m_sessp,pdu,&response);  /*  * Process the response.  */  if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) {    /*    * SUCCESS: Print the result variables    */    struct variable_list *vars;        // debug print    //for(vars = response->variables; vars; vars = vars->next_variable)    //  print_variable(vars->name, vars->name_length, vars);    /* manipuate the information ourselves */    for(vars = response->variables; vars; vars = vars->next_variable) {			if (vars->type == ASN_OPAQUE_FLOAT) {				    // 0x78        value = *vars->val.floatVal;      }			else if (vars->type == ASN_OPAQUE_DOUBLE) {			// 0x79        value = *vars->val.doubleVal;      }			else if(vars->type == ASN_INTEGER) {				      // 0x02				value = (double)*vars->val.integer;      }    }  } else {    /*    * FAILURE: print what went wrong!    */    if (status == STAT_SUCCESS)      fprintf(stderr, "Error in packet/nReason: %s/n",      snmp_errstring(response->errstat));    else      snmp_sess_perror("snmpget",snmp_sess_session(m_sessp));    return 0;  }  snmp_free_pdu(response);  return value;}
开发者ID:BillMills,项目名称:GRIFFIN-SOH,代码行数:57,


示例6: NotifyingEntry

static voidNotifyingEntry(UNUSED tState self){    netsnmp_pdu* act = snmp_clone_pdu(pdu);    if(act) {        act->sessid = session;        act->transid = 0;        act->reqid = ++packetid;        if(snmp_sess_send(sessp, act) == 0)            snmp_free_pdu(act);    }}
开发者ID:nnathan,项目名称:net-snmp,代码行数:12,


示例7: powernet_snmp_kill_ups_power

int powernet_snmp_kill_ups_power(UPSINFO *ups){   /* Was 1} change submitted by Kastus Shchuka ([email
C++ snmp_get_sysuptime函数代码示例
C++ snmp_fold_field函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。