ntpSnmpSubagentObject.h revision 290001
1/*****************************************************************************
2 *
3 *  ntpSnmpSubAgentObject.h
4 *
5 *	Definitions and macros for ntpSnmpSubAgentObject.c
6 *
7 ****************************************************************************/
8
9
10#ifndef NTPSNMPSUBAGENTOBJECT_H
11#define NTPSNMPSUBAGENTOBJECT_H
12
13/* Function Prototypes */
14size_t ntpsnmpd_parse_string(const char *string, char *field, size_t
15			     fieldsize, char *value, size_t valuesize);
16size_t ntpsnmpd_cut_string(const char *string, char *dest, char delim,
17			   int fieldnumber, size_t maxsize);
18size_t read_ntp_value(const char *variable, char *value,
19		      size_t valuesize);
20
21/* Initialization */
22void init_ntpSnmpSubagentObject(void);
23
24/* MIB Section 1 Callback Functions*/
25Netsnmp_Node_Handler get_ntpEntSoftwareName;
26Netsnmp_Node_Handler get_ntpEntSoftwareVersion;
27Netsnmp_Node_Handler get_ntpEntSoftwareVendor;
28Netsnmp_Node_Handler get_ntpEntSystemType;
29Netsnmp_Node_Handler get_ntpEntTimeResolution;
30Netsnmp_Node_Handler get_ntpEntTimePrecision;
31Netsnmp_Node_Handler get_ntpEntTimeDistance;
32
33/* MIB Section 2 Callback Functions (TODO) */
34Netsnmp_Node_Handler get_ntpEntStatusCurrentMode;
35Netsnmp_Node_Handler get_ntpEntStatusCurrentModeVal;
36Netsnmp_Node_Handler get_ntpEntStatusStratum;
37Netsnmp_Node_Handler get_ntpEntStatusActiveRefSourceId;
38Netsnmp_Node_Handler get_ntpEntStatusActiveRefSourceName;
39Netsnmp_Node_Handler get_ntpEntStatusActiveOffset;
40
41#define NTPV4_OID 1,3,6,1,2,1,197	/* mib-2 197 */
42
43
44/*
45 * The following macros simplify the registration of the callback
46 * functions and register the name and OID of either read-only (RO) or
47 * read-write (RW) functions.
48 */
49
50#define SETUP_OID_RO(oidname, ...)				\
51static oid oidname##_oid [] = { __VA_ARGS__ };			\
52{								\
53	netsnmp_register_read_only_instance(			\
54		netsnmp_create_handler_registration(		\
55			"#oidname",				\
56			get_##oidname,				\
57			oidname##_oid,				\
58			OID_LENGTH				\
59			( oidname##_oid ),			\
60			HANDLER_CAN_RONLY));			\
61}
62
63#define SETUP_OID_RW(oidname, ...)				\
64static oid oidname##_oid [] = { __VA_ARGS__ };			\
65{								\
66	netsnmp_register_instance(				\
67		netsnmp_create_handler_registration(		\
68			"#oidname",				\
69			do_##oidname,				\
70			oidname##_oid,				\
71			OID_LENGTH				\
72			( oidname##_oid ),			\
73			HANDLER_CAN_RWRITE));			\
74}
75
76#define NTP_OID_RO(oidname, w, x, y, z)				\
77	SETUP_OID_RO(oidname, NTPV4_OID, w, x, y, z)
78#define NTP_OID_RW(oidname, w, x, y, z)				\
79	SETUP_OID_RW(oidname, NTPV4_OID, w, x, y, z)
80
81#endif
82