I have got 2 questions about Agentx subagent method via net-snmp

1,how do I put the value of the variable requested by SNMP GET request into
the PDU or get the the

value of the variable requeste by SNMP SET request from the PDU and commit
it in my own variable for

management object?for example in the function handle_subagent_response where
should I put the value

of the variable requested by SNMP GET request in?(I indicate the place I
think in the following code

commented by this sentence "/********added by me***********/")

int
handle_subagent_response(int op, netsnmp_session * session, int reqid,
                        netsnmp_pdu *pdu, void *magic)
{
   ns_subagent_magic *smagic = (ns_subagent_magic *) magic;
   netsnmp_variable_list *u = NULL, *v = NULL;
   int             rc = 0;

   if (op != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE || magic == NULL) {
       return 1;
   }

   pdu = snmp_clone_pdu(pdu);
   DEBUGMSGTL(("agentx/subagent",
               "handling AgentX response (cmd 0x%02x orig_cmd 0x%02x)\n",
               pdu->command, smagic->original_command));

   if (pdu->command == SNMP_MSG_INTERNAL_SET_FREE ||
       pdu->command == SNMP_MSG_INTERNAL_SET_UNDO ||
       pdu->command == SNMP_MSG_INTERNAL_SET_COMMIT) {
       free_set_vars(smagic->session, pdu);
   }

   if (smagic->original_command == AGENTX_MSG_GETNEXT) {
       DEBUGMSGTL(("agentx/subgaent",
                   "do getNext scope processing %p %p\n", smagic->ovars,
                   pdu->variables));
       for (u = smagic->ovars, v = pdu->variables; u != NULL && v != NULL;
            u = u->next_variable, v = v->next_variable) {
           if (snmp_oid_compare
               (u->val.objid, u->val_len / sizeof(oid), nullOid,
                nullOidLen) != 0) {
               /*
                * The master agent requested scoping for this variable.
                */
               rc = snmp_oid_compare(v->name, v->name_length,
                                     u->val.objid,
                                     u->val_len / sizeof(oid));
               DEBUGMSGTL(("agentx/subagent", "result "));
               DEBUGMSGOID(("agentx/subagent", v->name, v->name_length));
               DEBUGMSG(("agentx/subagent", " scope to "));
               DEBUGMSGOID(("agentx/subagent",
                            u->val.objid, u->val_len / sizeof(oid)));
               DEBUGMSG(("agentx/subagent", " result %d\n", rc));

               if (rc >= 0) {
                   /*
                    * The varbind is out of scope.  From RFC2741, p. 66:
"If
                    * the subagent cannot locate an appropriate variable,
                    * v.name is set to the starting OID, and the VarBind is
                    * set to `endOfMibView'".
                    */
                   snmp_set_var_objid(v, u->name, u->name_length);
                   snmp_set_var_typed_value(v, SNMP_ENDOFMIBVIEW, 0, 0);
                   DEBUGMSGTL(("agentx/subagent",
                               "scope violation -- return
endOfMibView\n"));
               }
           } else {
               DEBUGMSGTL(("agentx/subagent", "unscoped var\n"));
           }
       }
   }

   /*
    * XXXJBPN: similar for GETBULK but the varbinds can get re-ordered I
    * think which makes it er more difficult.
    */

   if (smagic->ovars != NULL) {
       snmp_free_varbind(smagic->ovars);
   }

   pdu->command = AGENTX_MSG_RESPONSE;
   pdu->version = smagic->session->version;
/********added by me***********/
//(should I add code here with  this function snmp_set_var_typed_value???)
/********added by me***********/
   if (!snmp_send(smagic->session, pdu)) {
       snmp_free_pdu(pdu);
   }
   DEBUGMSGTL(("agentx/subagent", "  FINISHED\n"));
   free(smagic);
   return 1;
}
2. ns_subagent_magic *magic;
I want to know what this variable is used for.

thanks in advance!


--
----------------------------------------------------------
Hellen
---------------------------------------------------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to