| 1 |
/* |
| 2 |
* HEADER Testing SNMP handler registration and unregistration. |
| 3 |
* See also https://github.com/net-snmp/net-snmp/issues/983. |
| 4 |
*/ |
| 5 |
|
| 6 |
static const oid Oid[] = { 1, 3, 6, 1, 4, 1, 8072, 2, 4, 1, 1, 2, 0 }; |
| 7 |
netsnmp_handler_registration *handler; |
| 8 |
netsnmp_watcher_info *watcher; |
| 9 |
int res; |
| 10 |
|
| 11 |
init_snmp("snmp"); |
| 12 |
handler = netsnmp_create_handler_registration("handler", NULL, Oid, |
| 13 |
OID_LENGTH(Oid), HANDLER_CAN_RWRITE); |
| 14 |
OK(handler != NULL, "Handler registration"); |
| 15 |
if (!handler) |
| 16 |
goto shutdown; |
| 17 |
|
| 18 |
handler->contextName = strdup("contextName"); |
| 19 |
watcher = netsnmp_create_watcher_info(NULL, 0, ASN_INTEGER, WATCHER_FIXED_SIZE); |
| 20 |
OK(watcher, "Watcher creation"); |
| 21 |
if (!watcher) |
| 22 |
goto unregister; |
| 23 |
res = netsnmp_register_watched_instance2(handler, watcher); |
| 24 |
OK(res == MIB_REGISTERED_OK, "Register watched instance"); |
| 25 |
|
| 26 |
unregister: |
| 27 |
netsnmp_unregister_handler(handler); |
| 28 |
|
| 29 |
shutdown: |
| 30 |
snmp_shutdown("snmp"); |