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 */
16size_t ntpsnmpd_parse_string(const char *string, char *field, size_t
17			     fieldsize, char *value, size_t valuesize);
18size_t ntpsnmpd_cut_string(const char *string, char *dest, char delim,
19			   int fieldnumber, size_t maxsize);
20size_t read_ntp_value(const char *variable, char *value,
21		      size_t valuesize);
22
23/* Initialization */
24void init_ntpSnmpSubagentObject(void);
25
26/* MIB Section 1 Callback Functions*/
27Netsnmp_Node_Handler get_ntpEntSoftwareName;
28Netsnmp_Node_Handler get_ntpEntSoftwareVersion;
29Netsnmp_Node_Handler get_ntpEntSoftwareVendor;
30Netsnmp_Node_Handler get_ntpEntSystemType;
31Netsnmp_Node_Handler get_ntpEntTimeResolution;
32Netsnmp_Node_Handler get_ntpEntTimePrecision;
33Netsnmp_Node_Handler get_ntpEntTimeDistance;
34
35/* MIB Section 2 Callback Functions (TODO) */
36Netsnmp_Node_Handler get_ntpEntStatusCurrentMode;
37Netsnmp_Node_Handler get_ntpEntStatusCurrentModeVal;
38Netsnmp_Node_Handler get_ntpEntStatusStratum;
39Netsnmp_Node_Handler get_ntpEntStatusActiveRefSourceId;
40Netsnmp_Node_Handler get_ntpEntStatusActiveRefSourceName;
41Netsnmp_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, ...)				\
53static 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, ...)				\
66static 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