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