1 #ifndef NETSNMP_SYSORTABLE_H
2 #define NETSNMP_SYSORTABLE_H
3 
4 struct sysORTable {
5     char            *OR_descr;
6     oid             *OR_oid;
7     size_t           OR_oidlen;
8     netsnmp_session *OR_sess;
9     u_long           OR_uptime;
10 };
11 
12 struct register_sysOR_parameters {
13     char            *descr;
14     oid             *name;
15     size_t           namelen;
16 };
17 
18 #define SYS_ORTABLE_REGISTERED_OK              0
19 #define SYS_ORTABLE_REGISTRATION_FAILED       -1
20 #define SYS_ORTABLE_UNREGISTERED_OK            0
21 #define SYS_ORTABLE_NO_SUCH_REGISTRATION      -1
22 
23 #include <net-snmp/agent/agent_callbacks.h>
24 
25 #define REGISTER_SYSOR_TABLE(theoid, len, descr)           \
26   do {                                                     \
27     struct sysORTable t;                                   \
28     t.OR_descr = NETSNMP_REMOVE_CONST(char *, descr);      \
29     t.OR_oid = theoid;                                     \
30     t.OR_oidlen = len;                                     \
31     t.OR_sess = NULL;                                      \
32     t.OR_uptime = 0;                                       \
33     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,         \
34                         SNMPD_CALLBACK_REQ_REG_SYSOR, &t); \
35   } while(0);
36 
37 #define REGISTER_SYSOR_ENTRY(theoid, descr)                     \
38   REGISTER_SYSOR_TABLE(theoid, sizeof(theoid) / sizeof(oid),    \
39                        descr)
40 
41 #define UNREGISTER_SYSOR_TABLE(theoid, len)                     \
42   do {                                                          \
43     struct sysORTable t;                                        \
44     t.OR_descr = NULL;                                          \
45     t.OR_oid = theoid;                                          \
46     t.OR_oidlen = len;                                          \
47     t.OR_sess = NULL;                                           \
48     t.OR_uptime = 0;                                            \
49     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,              \
50                         SNMPD_CALLBACK_REQ_UNREG_SYSOR, &t);    \
51   } while(0);
52 
53 #define UNREGISTER_SYSOR_ENTRY(theoid)                          \
54   UNREGISTER_SYSOR_TABLE(theoid, sizeof(theoid) / sizeof(oid))
55 
56 #define UNREGISTER_SYSOR_SESS(sess)                             \
57   snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,                \
58                       SNMPD_CALLBACK_REQ_UNREG_SYSOR_SESS,      \
59                       sess);
60 
61 
62 #endif /* NETSNMP_SYSORTABLE_H */
63