pike.git / lib / modules / Protocols.pmod / SNMP.pmod / agent.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/SNMP.pmod/agent.pike:53:    if(r[0]==0) // we had an error    {    return_error(rv, @r[1..]);    return;    }    else varlist[oid]=r[1..];    }    else if(oid_get_callbacks["*"])    {    mixed r=oid_get_callbacks["*"](oid, rv[n[0]]); +  // We got a different OID than the requested +  // one. Typically happens with REQUEST_GETNEXT requests. +  string ret_oid = (sizeof (r) >= 4 && r[3]) || oid;    if(r[0]==0) // we had an error    { -  return_error(rv, @r[1..]); +  return_error(rv, @r[1..2]);    return;    } -  else varlist[oid]=r[1..]; +  else varlist[ret_oid]=r[1..2];    }    }    }    if(varlist && sizeof(varlist)>0)    get_response(varlist, rv);    }    else if(rv[n[0]]->op==Protocols.SNMP.REQUEST_SET) // are we a Set?    {    if(!has_value(set_community_list, rv[n[0]]->community))    // let us ignore bad communities
pike.git/lib/modules/Protocols.pmod/SNMP.pmod/agent.pike:296:   //! set the Get request callback function for an Object Identifier   //!   //! @param oid   //! the string object identifier, such as 1.3.6.1.4.1.132.2   //! or an asterisk (*) to serve as the handler for all requests   //! for which a handler is specified.   //! @param cb   //! the function to call when oid is requested by a manager   //! the function should take 2 arguments: a string containing the   //! requested oid and the body of the request as a mapping. - //! The function should return an array containing 3 elements: + //! The function should return an array containing 3 or 4 elements:   //! The first is a boolean indicating success or failure.   //! If success, the next 2 elements should be the SNMP data type of   //! the result followed by the result itself.   //! If failure, the next 2 elements should be the error-status   //! such as @[Protocols.SNMP.ERROR_TOOBIG] and the second   //! is the error-index, if any. -  + //! If a fourth array element is returned, it should contain the OID + //! that the callback actually fetched (typically different from the + //! requested OID for REQUEST_GETNEXT requests). This is needed for + //! e.g. snmpwalk to work properly. + //!   //! @note   //! there can be only one callback per object identifier.   //! calling this function more than once with the same oid will   //! result in the new callback replacing the existing one.   void set_get_oid_callback(string oid, function cb)   {    if(oid=="*"); // we can let * pass.    else if(!oid || !is_valid_oid(oid))    error("set_get_oid_callback(): invalid or no oid specified.\n");