I am working on an AgentX subagent that will use my own explicit OID handlers. I am using net-snmp version 5.7.2 under x86_64 Linux. I need to support read/write variables of standard types like integer, unsigned integer, strings, etc. as well as non-standard types such as float, double, int64, uint64, etc. I wrote a test subagent to try handlers for variables of these various types. Everything seems to be working fine except for int64 and uint64.
An example subagent int64 handler is shown below. The OID for the int64 is "1.3.6.1.4.1.99999.6". I currently have snmpd configured with "rwcommunity public" for test purposes. I am testing with net-snmp command line utilities snmpget, snmpset, snmpwalk, etc. Here are some specific questions: (1) If I return type ASN_OPAQUE_I64 or U64 from subagent handler for a GET, snmpget displays the returned value as an OPAQUE hex string of 16 bytes (see below). Is there any way to get snmpget to display it as a 64 bit number? ASN_COUNTER64 works but I need read/write access and both signed and unsigned. # snmpget -v2c -c public -- localhost 1.3.6.1.4.1.99999.6 SNMPv2-SMI::enterprises.99999.6 = OPAQUE: 04 03 02 01 00 00 00 00 08 07 06 05 00 00 00 00 (2) snmpset calls with type I or U show up in the handler as type ASN_OPAQUE instead of ASN_OPAQUE_I64 or ASN_OPAQUE_U64, is there any way to get them to show up with the proper type like float and double do? (3) If I call snmpset with type I and set value to a negative number, snmpset hangs with 100% CPU and the subagent never receives anything. In previous testing with net-snmp 5.7.1, the subagent appeared to receive the right negative value but then snmpd would hang with 100% CPU. Is this a bug or am I doing something wrong? # snmpset -v2c -c public -- localhost 1.3.6.1.4.1.99999.6 I -10 Positive I values work OK and snmpset even displays things properly: # snmpset -v2c -c public -- localhost 1.3.6.1.4.1.99999.6 I 10 SNMPv2-SMI::enterprises.99999.6 = Opaque: Int64: 10 (4) If I call snmpset with type U the value received by the subagent is corrupted and the display is an OPAQUE hex string. Should this work? # snmpset -v2c -c public -- localhost 1.3.6.1.4.1.99999.6 U 10 SNMPv2-SMI::enterprises.99999.6 = OPAQUE: D0 C5 47 35 5A 7F 00 00 00 00 00 00 00 00 00 00 From subagent handler for call of snmpset with U 10: test1Object: int64Handler: set val.high=0x7f5a3547c5d0, val.low=0x0, val=3839254704500506624 ---------------------------------------------------------------------------- ---------------- Example int64 handler: static int64_t varInt64 = 0x0102030405060708; int int64Handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reg, netsnmp_agent_request_info *agentInfo, netsnmp_request_info *requests) { int ret; U64 val; DEBUGMSGTL((MODNAME, "int64Handler: received request, mode = %d\n", agentInfo->mode)); switch (agentInfo->mode) { case MODE_GET: case MODE_GETNEXT: val.high = (u_long)((varInt64 >> 32) & 0xffffffff); val.low = (u_long)(varInt64 & 0xffffffff); snmp_set_var_typed_value(requests->requestvb, ASN_OPAQUE_I64, &val, sizeof(val)); break; case MODE_SET_RESERVE1: ret = netsnmp_check_vb_type_and_size(requests->requestvb, ASN_OPAQUE, sizeof(val)); if ( ret != SNMP_ERR_NOERROR ) { DEBUGMSGTL((MODNAME, "int64Handler: Error, type=%d (%d), size=%d (%d), val.high=0x%lx. val.low=0x%lx\n", (int)requests->requestvb->type, (int)ASN_OPAQUE_I64, (int)requests->requestvb->val_len, (int)sizeof(val), requests->requestvb->val.counter64->high, requests->requestvb->val.counter64->low)); netsnmp_set_request_error(agentInfo, requests, ret); } break; case MODE_SET_RESERVE2: break; case MODE_SET_ACTION: val = *requests->requestvb->val.counter64; varInt64 = (int64_t)(((uint64_t)val.high << 32) | val.low); DEBUGMSGTL((MODNAME, "int64Handler: set val.high=0x%lx, val.low=0x%lx, val=%lld\n", val.high, val.low, (long long)varInt64)); case MODE_SET_UNDO: case MODE_SET_COMMIT: case MODE_SET_FREE: break; default: requests->delegated = -1; break; } return SNMP_ERR_NOERROR; } ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users