net-snmp 5.7
sysORTable.h
00001 #ifndef NETSNMP_SYSORTABLE_H
00002 #define NETSNMP_SYSORTABLE_H
00003 
00004 struct sysORTable {
00005     char            *OR_descr;
00006     oid             *OR_oid;
00007     size_t           OR_oidlen;
00008     netsnmp_session *OR_sess;
00009     u_long           OR_uptime;
00010 };
00011 
00012 struct register_sysOR_parameters {
00013     char            *descr;
00014     oid             *name;
00015     size_t           namelen;
00016 };
00017 
00018 #define SYS_ORTABLE_REGISTERED_OK              0
00019 #define SYS_ORTABLE_REGISTRATION_FAILED       -1
00020 #define SYS_ORTABLE_UNREGISTERED_OK            0
00021 #define SYS_ORTABLE_NO_SUCH_REGISTRATION      -1
00022 
00023 #include <net-snmp/agent/agent_callbacks.h>
00024 
00025 #define REGISTER_SYSOR_TABLE(theoid, len, descr)           \
00026   do {                                                     \
00027     struct sysORTable t;                                   \
00028     t.OR_descr = NETSNMP_REMOVE_CONST(char *, descr);      \
00029     t.OR_oid = theoid;                                     \
00030     t.OR_oidlen = len;                                     \
00031     t.OR_sess = NULL;                                      \
00032     t.OR_uptime = 0;                                       \
00033     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,         \
00034                         SNMPD_CALLBACK_REQ_REG_SYSOR, &t); \
00035   } while(0);
00036 
00037 #define REGISTER_SYSOR_ENTRY(theoid, descr)                     \
00038   REGISTER_SYSOR_TABLE(theoid, sizeof(theoid) / sizeof(oid),    \
00039                        descr)
00040 
00041 #define UNREGISTER_SYSOR_TABLE(theoid, len)                     \
00042   do {                                                          \
00043     struct sysORTable t;                                        \
00044     t.OR_descr = NULL;                                          \
00045     t.OR_oid = theoid;                                          \
00046     t.OR_oidlen = len;                                          \
00047     t.OR_sess = NULL;                                           \
00048     t.OR_uptime = 0;                                            \
00049     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,              \
00050                         SNMPD_CALLBACK_REQ_UNREG_SYSOR, &t);    \
00051   } while(0);
00052 
00053 #define UNREGISTER_SYSOR_ENTRY(theoid)                          \
00054   UNREGISTER_SYSOR_TABLE(theoid, sizeof(theoid) / sizeof(oid))
00055 
00056 #define UNREGISTER_SYSOR_SESS(sess)                             \
00057   snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,                \
00058                       SNMPD_CALLBACK_REQ_UNREG_SYSOR_SESS,      \
00059                       sess);
00060 
00061 
00062 #endif /* NETSNMP_SYSORTABLE_H */