Quoting Dave Shield <[EMAIL PROTECTED]>: > > > I am in the middle of writing an agentx subagent. I have the handler all > > set up and registered using netsnmp_register_handler, it get my > > requests. The problem is I don't know what to do from there. > > OK - first question: what sort of objects is this handler dealing with? > One scalar? A group of scalars? A table? A whole subtree?
My handler is dealing with a whole subtree. My subagent reads a mib created by me. That mib contains many scalar points representing devices and parameters (can't use a table here because of customer limitations). When a request comes in I need to take the oid and find the device and param that oid represents. Once I have that I can get the value and return it in the response. Is there a helper to register for a complete subtree? > > The 'netsnmp_register_handler' API is a fairly general-purpose call. > You may find it easier to use one of the more specialised helpers, > that will handle much of the work for you. > > > If I try to > > set the value of the requests->requestvp > > How are you doing this? > What's the code? I find the type it shoud be from the mib and malloc the correct member in the val union. I see now that I need to user snmp_set_var_typed_value. > > > > Does anyone know of an example subagent that is a little more in depth > > than the tutorial? > > Bear in mind that the MIB module API is independent of whether it is > part of an AgentX subagent, or a master SNMP agent. So any of the > techniques used in the v5-style MIB modules in the main source > distribution should be applicable to your subagent. > > > I am using netsnmp_create_handler_registration and > > netsnmp_register_handler. My handler function returns 0. Is that > > correct? > > Ideally, I'd suggest you return SNMP_ERR_NOERROR (i.e. 0) for a > successful request, and the appropriate SNMP_ERR_xxx for a failure. > But it doesn't actually matter - this return value is ignored anyway! > > It's more important to set the error using netsnmp_set_request_error() > > > > Also what is the expected way to return the values, just malloc > > the correct val and set it or what? > > snmp_set_var_typed_value( requests->requestvb, ASN_TYPE, > (u_char *)&value, sizeof( value )); > > > But remember that 'requests' is actually a *list* of varbinds for > this handler, so you really need to wrap the processing in a loop > to pick up each one. > > Again, see the main source code for examples. > > Dave > > > Glenn MacGregor HighStreet Networks ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ ------------------------------------------------------- This SF.Net email is sponsored by: GNOME Foundation Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. GNOME Users and Developers European Conference, 28-30th June in Norway http://2004/guadec.org _______________________________________________ Net-snmp-coders mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
