int handle_ifNumber(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { /* We are never called for a GETNEXT if it's registered as a "instance", as it's "magically" handled for us. */ /* a instance handler also only hands us one request at a time, so we don't need to loop over a list of requests; we'll only get one. */ int32_t v = 0; (void)handler; (void)reginfo; switch (reqinfo->mode) { case MODE_GET: count_ifNumber(&v); snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, (u_char *) &v, sizeof(v)); break; default: /* we should never get here, so this is a really bad error */ snmp_log(LOG_ERR, "unknown mode (%d) in handle_ifNumber\n", reqinfo->mode ); return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; }
void test_getIfNumber(void) { int32_t v = 0; count_ifNumber(&v); TEST_ASSERT_EQUAL_UINT32_MESSAGE(2, v, "testting test"); }