From: Dave Hart Date: Tue, 12 Oct 2010 01:16:13 +0000 (+0000) Subject: [Bug 1584]: ntpsnmpd OID must be mib-2.197. X-Git-Tag: NTP_4_2_6P3_RC3~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12971d31e5676e8cfb2d62a03d5cb9b21bffda19;p=thirdparty%2Fntp.git [Bug 1584]: ntpsnmpd OID must be mib-2.197. bk: 4cb3b6dd2q318444T72uaXjJMuwnMg --- diff --git a/ChangeLog b/ChangeLog index 2b0538378..6ae7151b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ --- +* [Bug 1584]: ntpsnmpd OID must be mib-2.197. * [Bug 1643]: Range-check the decoding of the RIPE-NCC status codes. * [Bug 1644]: cvo.sh should use lsb_release to identify linux distros. diff --git a/ntpq/libntpq.c b/ntpq/libntpq.c index 8b5ec8dcb..e33f304ac 100644 --- a/ntpq/libntpq.c +++ b/ntpq/libntpq.c @@ -9,7 +9,7 @@ * communcation is based on mode 6 packets. * ****************************************************************************/ -#define _LIBNTPQC +#define LIBNTPQ_C #define NO_MAIN_ALLOWED 1 /* #define BUILD_AS_LIB Already provided by the Makefile */ @@ -17,40 +17,21 @@ #include "libntpq.h" /* Function Prototypes */ -int ntpq_openhost(char *); -int ntpq_closehost(void); -int ntpq_queryhost(unsigned short VARSET, unsigned short association, char *resultbuf, int maxlen); -int ntpq_stripquotes ( char *resultbuf, char *srcbuf, int datalen, int maxlen ); -int ntpq_queryhost_peervars(unsigned short association, char *resultbuf, int maxlen); -int ntpq_getvar( char *resultbuf, int datalen, const char *varname, char *varvalue, int maxlen); -int ntpq_get_peervar( const char *varname, char *varvalue, int maxlen); -int ntpq_read_associations ( unsigned short resultbuf[], int max_entries ); -int ntpq_read_sysvars( char *resultbuf, int maxsize ); -int ntpq_get_assoc_allvars( int associd ); -int ntpq_get_sysvars( void ); -int ntpq_get_assocs ( void ); -int ntpq_read_assoc_peervars( int associd, char *resultbuf, int maxsize ); -int ntpq_read_assoc_clockvars( int associd, char *resultbuf, int maxsize ); -int ntpq_get_assoc_number ( int associd ); -int ntpq_get_assoc_peervars( int associd ); -int ntpq_get_assoc_clockvars( int associd ); -int ntpq_get_assoc_clocktype ( int assoc_number ); const char *Version = "libntpq 0.3beta"; /* global variables used for holding snapshots of data */ - char peervars[NTPQ_BUFLEN]; - int peervarlen = 0; - int peervar_assoc = 0; - char clockvars[NTPQ_BUFLEN]; - int clockvarlen = 0; - int clockvar_assoc = 0; - char sysvars[NTPQ_BUFLEN]; - int sysvarlen = 0; - char *ntpq_resultbuffer[NTPQ_BUFLEN]; - unsigned short ntpq_associations[MAXASSOC]; - +char peervars[NTPQ_BUFLEN]; +int peervarlen = 0; +int peervar_assoc = 0; +char clockvars[NTPQ_BUFLEN]; +int clockvarlen = 0; +int clockvar_assoc = 0; +char sysvars[NTPQ_BUFLEN]; +int sysvarlen = 0; +char *ntpq_resultbuffer[NTPQ_BUFLEN]; +unsigned short ntpq_associations[MAXASSOC]; struct ntpq_varlist ntpq_varlist[MAXLIST]; /***************************************************************************** @@ -129,32 +110,42 @@ int ntpq_stripquotes ( char *resultbuf, char *srcbuf, int datalen, int maxlen ) * Parameters: * resultbuf char* The resulting string without quoted * characters - * datalen int The number of bytes stored in + * datalen size_t The number of bytes stored in * resultbuf * varname char* Name of the required variable * varvalue char* Where the value of the variable should * be stored - * maxlen int Max. number of bytes for varvalue + * maxlen size_t Max. number of bytes for varvalue * * Returns: - * int number of chars that have been copied to + * size_t number of chars that have been copied to * varvalue ****************************************************************************/ -int ntpq_getvar( char *resultbuf, int datalen, const char *varname, char *varvalue, int maxlen) +size_t +ntpq_getvar( + char * resultbuf, + size_t datalen, + const char * varname, + char * varvalue, + size_t maxlen) { - char *name; - char *value = NULL; + char * name; + char * value; + int idatalen; - while (nextvar(&datalen, &resultbuf, &name, &value)) { + value = NULL; + idatalen = (int)datalen; + + while (nextvar(&idatalen, &resultbuf, &name, &value)) { + if (strcmp(varname, name) == 0) { + ntpq_stripquotes(varvalue, value, strlen(value), maxlen); - if ( strcmp(varname, name) == 0 ) { - ntpq_stripquotes(varvalue,value,strlen(value),maxlen); return strlen(varvalue); - } - } + } + } - return 0; + return 0; } @@ -487,35 +478,37 @@ int ntpq_get_assoc_number ( int associd ) * - OR - * 0 (zero) if an error occured ****************************************************************************/ -int ntpq_read_sysvars( char *resultbuf, int maxsize ) +size_t +ntpq_read_sysvars( + char * resultbuf, + size_t maxsize) { - char *datap; - int res; - int dsize; - u_short rstatus; + char * datap; + int res; + int i_dsize; + size_t dsize; + u_short rstatus; - res = doquery(CTL_OP_READVAR, 0, 0, 0, (char *)0, &rstatus, - &dsize, &datap); - - if (res != 0) - return 0; + res = doquery(CTL_OP_READVAR, 0, 0, 0, NULL, &rstatus, + &i_dsize, &datap); - if (dsize == 0) { - if (numhosts > 1) - (void) fprintf(stderr, "server=%s ", currenthost); - (void) fprintf(stderr, - "***No sysvar information returned \n"); - return 0; - } else { - if ( dsize > maxsize ) - dsize = maxsize; + if (res != 0) + return 0; - memcpy(resultbuf,datap,dsize); - } + if (dsize == 0) { + if (numhosts > 1) + fprintf(stderr, "server=%s ", currenthost); + fprintf(stderr, "***No sysvar information returned\n"); - return dsize; + return 0; + } else { + dsize = max(0, i_dsize); + dsize = min(dsize, maxsize); + memcpy(resultbuf, datap, dsize); + } + return dsize; } diff --git a/ntpq/libntpq.h b/ntpq/libntpq.h index bd41feb85..18f565a29 100644 --- a/ntpq/libntpq.h +++ b/ntpq/libntpq.h @@ -60,7 +60,7 @@ struct ntpq_varlist { }; /* global variables used for holding snapshots of data */ -#ifndef _LIBNTPQC +#ifndef LIBNTPQ_C extern char peervars[]; extern int peervarlen; extern int peervar_assoc; @@ -80,15 +80,16 @@ extern struct ntpq_varlist ntpq_varlist[MAXLIST]; */ /* from libntpq.c */ -#ifndef _LIBNTPQC extern int ntpq_openhost(char *); extern int ntpq_closehost(void); extern int ntpq_queryhost(unsigned short VARSET, unsigned short association, char *resultbuf, int maxlen); -extern int ntpq_getvar( char *resultbuf, int datalen, const char *varname, char *varvalue, int maxlen); +extern size_t ntpq_getvar(char *resultbuf, size_t datalen, + const char *varname, char *varvalue, + size_t maxlen); extern int ntpq_stripquotes ( char *resultbuf, char *srcbuf, int datalen, int maxlen ); extern int ntpq_queryhost_peervars(unsigned short association, char *resultbuf, int maxlen); extern int ntpq_get_peervar( const char *varname, char *varvalue, int maxlen); -extern int ntpq_read_sysvars( char *resultbuf, int maxsize ); +extern size_t ntpq_read_sysvars(char *resultbuf, size_t maxsize); extern int ntpq_get_sysvars( void ); extern int ntpq_read_associations ( unsigned short resultbuf[], int max_entries ); extern int ntpq_get_assocs ( void ); @@ -99,7 +100,6 @@ extern int ntpq_get_assoc_allvars( int associd ); extern int ntpq_get_assoc_clocktype ( int assoc_number ); extern int ntpq_read_assoc_peervars( int associd, char *resultbuf, int maxsize ); extern int ntpq_read_assoc_clockvars( int associd, char *resultbuf, int maxsize ); - #endif /* in libntpq_subs.c */ #ifndef _LIBNTPQSUBSC diff --git a/ntpsnmpd/Makefile.am b/ntpsnmpd/Makefile.am index c04b41532..80a54873f 100644 --- a/ntpsnmpd/Makefile.am +++ b/ntpsnmpd/Makefile.am @@ -9,8 +9,8 @@ endif EXTRA_PROGRAMS= ntpsnmpd ntpsnmpd_SOURCES= netsnmp_daemonize.c ntpsnmpd.c ntpSnmpSubagentObject.c \ - ntpsnmpd-opts.c ntpsnmpd-opts.h -noinst_HEADERS= ntpSnmpSubagentObject.h + ntpsnmpd-opts.c ntpsnmpd-opts.h ntpSnmpSubagentObject.h \ + ntp_snmp.h # HMS: we probably want a version.o file here, too. LDADD= ../ntpq/libntpq.a ../libntp/libntp.a @LCRYPTO@ @SNMP_LIBS@ \ $(LIBOPTS_LDADD) diff --git a/ntpsnmpd/ntpSnmpSubagentObject.c b/ntpsnmpd/ntpSnmpSubagentObject.c index 3a5815a45..bc54e5bc7 100644 --- a/ntpsnmpd/ntpSnmpSubagentObject.c +++ b/ntpsnmpd/ntpSnmpSubagentObject.c @@ -15,69 +15,17 @@ * ntpd process. * ****************************************************************************/ -#include -#include -#include -#include "ntpSnmpSubagentObject.h" +#include +#include +#include #include /* general purpose buffer length definition */ #define NTPQ_BUFLEN 2048 -static int ntpSnmpSubagentObject = 3; - char ntpvalue[NTPQ_BUFLEN]; - -/***************************************************************************** - * - * ntpsnmpd_strip_string - * - * This function removes white space characters and EOL chars - * from the beginning and end of a given NULL terminated string. - * Be aware that the parameter itself is altered. - * - **************************************************************************** - * Parameters: - * string char* The name of the string variable - * NOTE: must be NULL terminated! - * Returns: - * int length of resulting string (i.e. w/o white spaces) - ****************************************************************************/ - -int ntpsnmpd_strip_string(char *string) -{ - char newstring[2048] = { 0 }; - int i = 0; - int j = 0; - - if ( strlen(string) > 2047 ) - string[2048]=0; - - j = strlen(string); - - for (i=0;i=a) - l=1; - else - { - switch(string[i]) - { - case 0x09: // Tab - case 0x0A: // LF - case 0x0D: // CR - case ' ': // Space - break; - case '=': - l=1; - break; - - default: - if ( j < fieldsize ) - { - if ( ( string[i] >= 'a' ) && ( string[i] <='z' ) ) - field[j++]=( string[i] - 32 ); // convert to Uppercase - else - field[j++]=string[i]; - } + for (i = 0; l == 0; i++) { + if (i >= str_cnt) { + l=1; + } else { + switch (string[i]) { + case '\t': /* Tab */ + case '\n': /* LF */ + case '\r': /* CR */ + case ' ': /* Space */ + break; + + case '=': + l=1; + break; + default: + if (j >= fieldsize) + break; + if (isalpha(string[i])) + field[j++] = toupper(string[i]); + else + field[j++] = string[i]; } } } - field[j]=0; j=0; value[0]=0; + field[j] = '\0'; + j = 0; + value[0] = '\0'; /* Now parsing the value */ - for (l=0;i 0x0D ) && ( string[i] != ' ' ) ) - l = j+1; + for (l = 0; i < str_cnt; i++) { + if (string[i] > 0x0D && string[i] != ' ') + l = j + 1; - if ( ( value[0] != 0 ) || ( ( string[i] > 0x0D ) && ( string[i] != ' ' ) ) ) - { - if (j < valuesize ) - value[j++]=string[i]; + if (value[0] != 0 || + (string[i] > 0x0D && string[i] != ' ')) { + if (j < valuesize) + value[j++] = string[i]; } } - value[l]=0; - - if ( value[0]=='"' ) - strcpy(value, (char *) &value[1]); + value[l] = '\0'; - if ( value[strlen(value)-1] == '"' ) - value[strlen(value)-1]=0; + if (value[0] == '"') + strncpy(value, &value[1], valuesize); - return (strlen(value)); + val_cnt = strlen(value); + if (value[val_cnt - 1] == '"') { + val_cnt--; + value[val_cnt] = '\0'; + } + return (val_cnt); } @@ -209,41 +157,30 @@ int ntpsnmpd_parse_string(char *src, char *field, int fieldsize, char *value, in * int length of resulting dest string ****************************************************************************/ -int ntpsnmpd_cut_string(char *src, char *dest, const char delim, int fieldnumber, int maxsize) +size_t ntpsnmpd_cut_string(char *src, char *dest, const char delim, int fieldnumber, size_t maxsize) { char string[2048]; - int i = 0; - int j = 0; - int l = 0; - int a = 0; + size_t i; + size_t j; + int l; + size_t a; - strncpy (string, src, sizeof(string)); - + strncpy(string, src, sizeof(string)); a = strlen(string); - - memset (dest, 0, maxsize); + j = 0; + memset(dest, 0, maxsize); /* Parsing the field name */ - for (i=0;l<=fieldnumber;i++) - { - if (i>=a) - l=fieldnumber+1; /* terminate loop */ - else - { - if ( string[i] == delim ) - { - l++; /* next field */ - } - else if ( ( l == fieldnumber) && ( j < maxsize ) ) - { - dest[j++]=string[i]; - } - - } + for (i = 0, l = 0; l <= fieldnumber; i++) { + if (i >= a) + break; /* terminate loop */ + if (string[i] == delim) + l++; /* next field */ + else if (l == fieldnumber && j < maxsize) + dest[j++] = string[i]; } - return (strlen(dest)); - + return j; } @@ -266,22 +203,23 @@ int ntpsnmpd_cut_string(char *src, char *dest, const char delim, int fieldnumber * rbuffer ****************************************************************************/ -unsigned int read_ntp_value(char *variable, char *rbuffer, unsigned int maxlength) +size_t +read_ntp_value( + char * variable, + char * rbuffer, + size_t maxlength) { - unsigned int i, sv_len = 0; - char sv_data[NTPQ_BUFLEN]; + size_t sv_len; + char sv_data[NTPQ_BUFLEN]; - memset (sv_data,0, NTPQ_BUFLEN); - sv_len= ntpq_read_sysvars ( sv_data, NTPQ_BUFLEN ); - - if ( sv_len ) - { - i=ntpq_getvar( sv_data, sv_len , variable, rbuffer, maxlength); - return i; - } else { - return 0; - } + memset(sv_data, 0, sizeof(sv_data)); + sv_len = ntpq_read_sysvars(sv_data, sizeof(sv_data)); + if (0 == sv_len) + return 0; + else + return ntpq_getvar(sv_data, sv_len, variable, rbuffer, + maxlength); } @@ -378,45 +316,6 @@ int get_ntpEntSoftwareVersion (netsnmp_mib_handler *handler, } -int get_ntpEntSoftwareVersionVal (netsnmp_mib_handler *handler, - netsnmp_handler_registration *reginfo, - netsnmp_agent_request_info *reqinfo, - netsnmp_request_info *requests) -{ - unsigned int i = 0; - switch (reqinfo->mode) { - case MODE_GET: - { - - if ( read_ntp_value("versionval", ntpvalue, NTPQ_BUFLEN) ) - { - i=atoi(ntpvalue); - snmp_set_var_typed_value(requests->requestvb, ASN_UNSIGNED, - (u_char *) &i, - sizeof (i) - ); - } else { - i = 0; - snmp_set_var_typed_value(requests->requestvb, ASN_UNSIGNED, - (u_char *) &i, - sizeof(i) - ); - } - break; - - } - - - default: - /* If we cannot get the information we need, we will return a generic error to the SNMP client */ - return SNMP_ERR_GENERR; - } - - return SNMP_ERR_NOERROR; -} - - - int get_ntpEntSoftwareVendor (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, @@ -527,47 +426,6 @@ int get_ntpEntTimeResolution (netsnmp_mib_handler *handler, return SNMP_ERR_NOERROR; } - - -int get_ntpEntTimeResolutionVal (netsnmp_mib_handler *handler, - netsnmp_handler_registration *reginfo, - netsnmp_agent_request_info *reqinfo, - netsnmp_request_info *requests) -{ - - unsigned int i = 0; - switch (reqinfo->mode) { - case MODE_GET: - { - - if ( read_ntp_value("resolutionval", ntpvalue, NTPQ_BUFLEN) ) - { - i=atoi(ntpvalue); - snmp_set_var_typed_value(requests->requestvb, ASN_UNSIGNED, - (u_char *) &i, - sizeof (i) - ); - } else { - i = 0; - snmp_set_var_typed_value(requests->requestvb, ASN_UNSIGNED, - (u_char *) &i, - sizeof(i) - ); - } - break; - - } - - - default: - /* If we cannot get the information we need, we will return a generic error to the SNMP client */ - return SNMP_ERR_GENERR; - } - - return SNMP_ERR_NOERROR; -} - - int get_ntpEntTimePrecision (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, @@ -602,45 +460,6 @@ int get_ntpEntTimePrecision (netsnmp_mib_handler *handler, return SNMP_ERR_NOERROR; } -int get_ntpEntTimePrecisionVal (netsnmp_mib_handler *handler, - netsnmp_handler_registration *reginfo, - netsnmp_agent_request_info *reqinfo, - netsnmp_request_info *requests) -{ - - int i = 0; - switch (reqinfo->mode) { - case MODE_GET: - { - - if ( read_ntp_value("precision", ntpvalue, NTPQ_BUFLEN) ) - { - i=atoi(ntpvalue); - snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, - (u_char *) &i, - sizeof (i) - ); - } else { - i = 0; - snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER, - (u_char *) &i, - sizeof(i) - ); - } - break; - - } - - - default: - /* If we cannot get the information we need, we will return a generic error to the SNMP client */ - return SNMP_ERR_GENERR; - } - - return SNMP_ERR_NOERROR; -} - - int get_ntpEntTimeDistance (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, @@ -680,26 +499,18 @@ int get_ntpEntTimeDistance (netsnmp_mib_handler *handler, /* * * Initialize sub agent - * TODO: Define NTP MIB OID (has to be assigned by IANA) - * At the moment we use a private MIB branch (enterprises.5597.99) */ void init_ntpSnmpSubagentObject(void) { - - /* Register all MIB objects with the agentx master */ - - _SETUP_OID_RO( ntpEntSoftwareName , NTPV4_OID , 1, 1, 1, 0 ); - _SETUP_OID_RO( ntpEntSoftwareVersion , NTPV4_OID , 1, 1, 2, 0 ); - _SETUP_OID_RO( ntpEntSoftwareVersionVal , NTPV4_OID , 1, 1, 3, 0 ); - _SETUP_OID_RO( ntpEntSoftwareVendor , NTPV4_OID , 1, 1, 4, 0 ); - _SETUP_OID_RO( ntpEntSystemType , NTPV4_OID , 1, 1, 5, 0 ); - _SETUP_OID_RO( ntpEntTimeResolution , NTPV4_OID , 1, 1, 6, 0 ); - _SETUP_OID_RO( ntpEntTimeResolutionVal , NTPV4_OID , 1, 1, 7, 0 ); - _SETUP_OID_RO( ntpEntTimePrecision , NTPV4_OID , 1, 1, 8, 0 ); - _SETUP_OID_RO( ntpEntTimePrecisionVal , NTPV4_OID , 1, 1, 9, 0 ); - _SETUP_OID_RO( ntpEntTimeDistance , NTPV4_OID , 1, 1,10, 0 ); - + /* Register all MIB objects with the agentx master */ + NTP_OID_RO( ntpEntSoftwareName, 1, 1, 1, 0); + NTP_OID_RO( ntpEntSoftwareVersion, 1, 1, 2, 0); + NTP_OID_RO( ntpEntSoftwareVendor, 1, 1, 3, 0); + NTP_OID_RO( ntpEntSystemType, 1, 1, 4, 0); + NTP_OID_RO( ntpEntTimeResolution, 1, 1, 5, 0); + NTP_OID_RO( ntpEntTimePrecision, 1, 1, 6, 0); + NTP_OID_RO( ntpEntTimeDistance, 1, 1, 7, 0); } diff --git a/ntpsnmpd/ntpSnmpSubagentObject.h b/ntpsnmpd/ntpSnmpSubagentObject.h index f568c73ec..d48ccd7ae 100644 --- a/ntpsnmpd/ntpSnmpSubagentObject.h +++ b/ntpsnmpd/ntpSnmpSubagentObject.h @@ -11,24 +11,23 @@ #define NTPSNMPSUBAGENTOBJECT_H /* Function Prototypes */ +#if 0 /* appears unused */ int ntpsnmpd_strip_string(char *string); -int ntpsnmpd_parse_string(char *src, char *field, int fieldsize, char *value, int valuesize); -int ntpsnmpd_cut_string(char *src, char *dest, const char delim, int fieldnumber, int maxsize); -unsigned int read_ntp_value(char *variable, char *rbuffer, unsigned int maxlength); +#endif /* #if 0 -- appears unused */ +size_t ntpsnmpd_parse_string(char *src, char *field, size_t fieldsize, char *value, size_t valuesize); +size_t ntpsnmpd_cut_string(char *src, char *dest, const char delim, int fieldnumber, size_t maxsize); +size_t read_ntp_value(char *variable, char *rbuffer, size_t maxlength); /* Initialization */ -void init_ntpSnmpSubagentObject(void); +void init_ntpSnmpSubagentObject(void); /* MIB Section 1 Callback Functions*/ Netsnmp_Node_Handler get_ntpEntSoftwareName; Netsnmp_Node_Handler get_ntpEntSoftwareVersion; -Netsnmp_Node_Handler get_ntpEntSoftwareVersionVal; Netsnmp_Node_Handler get_ntpEntSoftwareVendor; Netsnmp_Node_Handler get_ntpEntSystemType; Netsnmp_Node_Handler get_ntpEntTimeResolution; -Netsnmp_Node_Handler get_ntpEntTimeResolutionVal; Netsnmp_Node_Handler get_ntpEntTimePrecision; -Netsnmp_Node_Handler get_ntpEntTimePrecisionVal; Netsnmp_Node_Handler get_ntpEntTimeDistance; /* MIB Section 2 Callback Functions (TODO) */ @@ -39,37 +38,44 @@ Netsnmp_Node_Handler get_ntpEntStatusActiveRefSourceId; Netsnmp_Node_Handler get_ntpEntStatusActiveRefSourceName; Netsnmp_Node_Handler get_ntpEntStatusActiveOffset; -/* TODO: This needs to be changed as soon as the official OID has been registered with IANA */ -#define NTPV4_OID 1,3,6,1,4,1,5597,99 +#define NTPV4_OID 1,3,6,1,2,1,197 /* mib-2 197 */ -/* The following two macros simplify the registration of the callback functions - * and allow to easily specify the name and OID of either read-only (RO) or read-write (RW) functions +/* + * The following macros simplify the registration of the callback + * functions and register the name and OID of either read-only (RO) or + * read-write (RW) functions. */ -#define _SETUP_OID_RO( _oidname, ... ) \ - static oid _oidname##_oid [] = { __VA_ARGS__ }; \ - { \ - netsnmp_register_read_only_instance(netsnmp_create_handler_registration \ - ("#_oidname", \ - get_##_oidname, \ - _oidname##_oid, \ - OID_LENGTH \ - ( _oidname##_oid ), \ - HANDLER_CAN_RONLY)); \ - } +#define SETUP_OID_RO(oidname, ...) \ +static oid oidname##_oid [] = { __VA_ARGS__ }; \ +{ \ + netsnmp_register_read_only_instance( \ + netsnmp_create_handler_registration( \ + "#oidname", \ + get_##oidname, \ + oidname##_oid, \ + OID_LENGTH \ + ( oidname##_oid ), \ + HANDLER_CAN_RONLY)); \ +} -#define _SETUP_OID_RW( _oidname, ... ) \ - static oid _oidname##_oid [] = { __VA_ARGS__ }; \ - { \ - netsnmp_register_instance(netsnmp_create_handler_registration \ - ("#_oidname", \ - do_##_oidname, \ - _oidname##_oid, \ - OID_LENGTH \ - ( _oidname##_oid ), \ - HANDLER_CAN_RWRITE)); \ - } +#define SETUP_OID_RW(oidname, ...) \ +static oid oidname##_oid [] = { __VA_ARGS__ }; \ +{ \ + netsnmp_register_instance( \ + netsnmp_create_handler_registration( \ + "#oidname", \ + do_##oidname, \ + oidname##_oid, \ + OID_LENGTH \ + ( oidname##_oid ), \ + HANDLER_CAN_RWRITE)); \ +} +#define NTP_OID_RO(oidname, w, x, y, z) \ + SETUP_OID_RO(oidname, NTPV4_OID, w, x, y, z) +#define NTP_OID_RW(oidname, w, x, y, z) \ + SETUP_OID_RW(oidname, NTPV4_OID, w, x, y, z) #endif diff --git a/ntpsnmpd/ntp_snmp.h b/ntpsnmpd/ntp_snmp.h new file mode 100644 index 000000000..1e0499d05 --- /dev/null +++ b/ntpsnmpd/ntp_snmp.h @@ -0,0 +1,34 @@ +/* + * ntp_snmp.h -- common net-snmp header includes and workaround + * for Autoconf-related PACKAGE_* redefinitions between + * net-snmp and NTP. + * + * Currently ntpsnmpd *.c files are exceptions to the rule that every .c + * file should include before any other headers. It would be + * ideal to rearrange its includes so that our config.h is first, but + * that is complicated by the redefinitions between our config.h and + * net-snmp/net-snmp-config.h. + */ + +#include +#include +#include + +#ifdef PACKAGE_BUGREPORT +# undef PACKAGE_BUGREPORT +#endif +#ifdef PACKAGE_NAME +# undef PACKAGE_NAME +#endif +#ifdef PACKAGE_STRING +# undef PACKAGE_STRING +#endif +#ifdef PACKAGE_TARNAME +# undef PACKAGE_TARNAME +#endif +#ifdef PACKAGE_VERSION +# undef PACKAGE_VERSION +#endif + +#include +#include diff --git a/ntpsnmpd/ntpsnmpd.c b/ntpsnmpd/ntpsnmpd.c index 194080783..0a98a3b2b 100644 --- a/ntpsnmpd/ntpsnmpd.c +++ b/ntpsnmpd/ntpsnmpd.c @@ -20,6 +20,7 @@ * ****************************************************************************/ +#include #include #include @@ -27,17 +28,6 @@ #include #endif -#include -#include -#include -#include - -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION - #include #include diff --git a/ntpsnmpd/ntpv4-mib.mib b/ntpsnmpd/ntpv4-mib.mib index 68e877a5a..e8cb01658 100644 --- a/ntpsnmpd/ntpv4-mib.mib +++ b/ntpsnmpd/ntpv4-mib.mib @@ -1,124 +1,38 @@ -- ********************************************************************* -- ---$Id: draft-ietf-ntp-ntpv4-mib-05.xml 1.12 2007/11/28 00:00:00Z chelliot $ ---$Name: SUBMIT_1 $ --- -- The Network Time Protocol Version 4 -- Management Information Base (MIB) -- -- Authors: Heiko Gerstung (heiko.gerstung@meinberg.de) --- Chris Elliott (chelliot@cisco.com) +-- Chris Elliott (chelliot@pobox.com) -- -- for the Internet Engineering Task Force (IETF) -- NTP Working Group (ntpwg) -- -- -- ********************************************************************* --- --- $Log: draft-ietf-ntp-ntpv4-mib-05.xml $ --- Revision 1.14 2008/08/29 00:00:00Z heiko --- Re-submitted after expiration: --- - The working group agreed to forward this draft in its current form (04), --- but it expired before that could be done --- Revision 1.13 2008/02/25 00:00:00Z chelliot --- MIB: --- - Added statistics table on a per-packet mode basis --- (ntpEntStatPktModeTable) --- Revision 1.12 2007/11/28 00:00:00Z chelliot --- MIB: --- - Added protocol statistics at the entity and association level --- XML/RFC: --- - Changed a couple of instances of "instance" to "entity" and "srv" --- to "ent". --- - Changed Meinberg address and Heiko's phone number. --- Revision 1.11 2007/07/23 00:00:00Z chelliot --- MIB: --- - Modified Contact Info --- - Added Stratum and NTP time TCs --- - Changed ntpEntNotifNotInSync to ntpEntNotifCurrentMode and --- deleted ntpEntNotifEntityStarted and ntpEntNotifEntityStopped --- - Added compliance for SNTP entities --- - Changed ntpTime to ntpDateTime --- Revision 1.10 2007/07/09 00:00:00Z chelliot --- XML/RFC: --- - Changed RFC to Internet --- - Changed service and service instance* to entity/entities --- - Revised the Security Considerations to include read-write object --- security considerations --- - Added Chris Elliott as an author --- - Fixed several lines to be 72 characters long or less --- MIB: --- - Changed "service" and "service instance" to "entity", --- and Srv to Ent --- - Changed status to mode --- - Added association status object --- - Added leap second objects --- Revision 1.9 2007/03/04 06:59:44Z chelliot --- MIB: --- - Added time objects, comments, changed notifications --- - Changed server to service --- Revision 1.8 2006/10/23 03:37:44Z chelliot --- MIB: --- - Changed various object types, added notification control object --- Revision 1.7 2006/06/16 07:13:50Z heiko --- XML/RFC: --- - Added/changed comments about the to-be-done IANA SMI assignment --- Revision 1.6 2006/06/16 07:04:43Z heiko --- RFC/XML: --- - phone number corrected --- - removed unused references --- MIB: --- - added ntpSrvTimePrecision --- - changed INTEGER objects to Integer32 --- - changed default value for ntpSrvStatusStratum from 99 to 16 --- - changed default value for ntpSrvStatusActiveRefclockId from 99-0 --- - changed object names to ntpSrvStatusActiveRefSourceName --- (from ntpSrvStatusActiveRefclockName) and to --- ntpSrvStatusNumberOfRefSources (from --- ntpSrvStatusNumberOfRefclocks) --- - removed ntpSrvStatusAuthKeyId object --- - added ntpSrvStatusDispersion to provide the current root --- dispersion --- - major rework of section 3 (Status of associations) to compile --- cleanly,including: --- - added dispersion to the association dataset --- - renaming of objects --- - added an index to the association table --- - formal changes --- - traps are now reverse mappable --- - traps are now define with payload where applicable --- - added compliance statements --- Revision 1.5 2006/02/27 08:28:16Z heiko --- - changed to RFC format and added header as well as --- introduction and technical description --- - added other necessary RFC components (copyright statement etc.) --- Revision 1.4 2006/02/27 07:06:49Z heiko --- - removed all objects with data type REAL --- - everything that needs to be floating point is now defined as --- DisplayString --- Revision 1.2 2006/01/23 08:58:11Z heiko --- - changed the datatype of offset, jitter and delay objects from --- Integer32 to REAL +-- Rev 1.00 +-- Published as RFC 5907 -- -- ********************************************************************* NTPv4-MIB DEFINITIONS ::= BEGIN - IMPORTS - MODULE-IDENTITY, OBJECT-TYPE , enterprises, mib-2, Integer32, NOTIFICATION-TYPE, - Unsigned32, Counter32 - FROM SNMPv2-SMI + MODULE-IDENTITY, OBJECT-TYPE , mib-2, Integer32, NOTIFICATION-TYPE, + Unsigned32, Counter32, TimeTicks + FROM SNMPv2-SMI -- RFC 2578 MODULE-COMPLIANCE, OBJECT-GROUP, NOTIFICATION-GROUP - FROM SNMPv2-CONF + FROM SNMPv2-CONF -- RFC 2580 DisplayString, TEXTUAL-CONVENTION - FROM SNMPv2-TC + FROM SNMPv2-TC -- RFC 2579 InetAddressType, InetAddress - FROM INET-ADDRESS-MIB; + FROM INET-ADDRESS-MIB -- RFC 4001 + Utf8String + FROM SYSAPPL-MIB; -- RFC 2287 ntpSnmpMIB MODULE-IDENTITY - LAST-UPDATED "200802250000Z" -- February 25, 2008 - + LAST-UPDATED "201005170000Z" -- May 17, 2010 ORGANIZATION "The IETF NTP Working Group (ntpwg)" CONTACT-INFO " WG Email: ntpwg@lists.ntp.isc.org @@ -135,44 +49,38 @@ ntpSnmpMIB MODULE-IDENTITY Email: heiko.gerstung@meinberg.de Chris Elliott - Cisco Systems, Inc. - 7025 Kit Creek Rd., P.O. Box 14987 - Research Triangle Park 27709 + 1516 Kent St. + Durham, NC 27707 + USA + + Phone: +1-919-308-1216 + Email: chelliot@pobox.com + + Brian Haberman + 11100 Johns Hopkins Road + Laurel, MD 20723 USA - Phone: +1 919-392-2146 - Email: chelliot@cisco.com" + Phone: +1-443-778-1319 + Email: brian@innovationslab.net" DESCRIPTION - "The Management Information Base for NTP time entities." - REVISION "200802250000Z" - DESCRIPTION - "Added ntpEntStatPktModeTable" - REVISION "200711280000Z" - DESCRIPTION - "Multiple proposed changes for IETF 70" - REVISION "200707230000Z" - DESCRIPTION - "Multiple proposed changes for IETF 69" - REVISION "200707090000Z" - DESCRIPTION - "Multiple changes from IETF 68" - REVISION "200703040000Z" - DESCRIPTION - "More MIB review modifications." - REVISION "200610230000Z" - DESCRIPTION - "Modifications from MIB review." - REVISION "200606190000Z" - DESCRIPTION - "First Draft Version" - REVISION "200512190000Z" - DESCRIPTION - "revised edition (added traps and stuff)" - REVISION "200511160000Z" + "The Management Information Base for NTP time entities. + + Copyright (c) 2010 IETF Trust and the persons identified as + authors of the code. All rights reserved. + + Redistribution and use in source and binary forms, with or + without modification, is permitted pursuant to, and subject + to the license terms contained in, the Simplified BSD License + set forth in Section 4.c of the IETF Trust's Legal Provisions + Relating to IETF Documents + (http://trustee.ietf.org/license-info)." + + REVISION "201005170000Z" DESCRIPTION - "Initial draft" - ::= { enterprises 5597 99 } + "This revision of the MIB module is published as RFC 5907." + ::= { mib-2 197 } ntpSnmpMIBObjects OBJECT IDENTIFIER ::= { ntpSnmpMIB 1 } @@ -183,7 +91,6 @@ ntpEntStatus OBJECT IDENTIFIER ::= { ntpSnmpMIBObjects 2 } ntpAssociation OBJECT IDENTIFIER ::= { ntpSnmpMIBObjects 3 } ntpEntControl OBJECT IDENTIFIER ::= { ntpSnmpMIBObjects 4 } ntpEntNotifObjects OBJECT IDENTIFIER ::= { ntpSnmpMIBObjects 5 } -ntpEntNotifPrefix OBJECT IDENTIFIER ::= { ntpSnmpMIBObjects 6 } -- -- Textual Conventions @@ -201,21 +108,13 @@ NtpDateTime ::= TEXTUAL-CONVENTION STATUS current DESCRIPTION "NTP date/time on the device, in 128-bit - NTP date format. Ref: draft-ietf-ntp-ntpv4-proto-06, - section 6: - It includes a 64-bit signed seconds field - spanning 584 billion years and a 64-bit fraction - field resolving .05 attosecond (i.e. 0.5e-18). - For convenience in mapping between formats, the - seconds field is divided into a 32-bit era field - and a 32-bit timestamp field. - - If time is not syncronized this field shall be a - zero-length string. - - This TC is not to be used for objects that are used - to set the time of the node querying this object. - NTP should be used for this--or at least SNTP." + NTP date format. If time is not syncronized, this + field shall be a zero-length string. + + This trusted certificate (TC) is not to be used for objects + that are used to set the time of the node querying this + object. NTP should be used for this -- or at least SNTP." + REFERENCE "RFC 5905, section 6" SYNTAX OCTET STRING (SIZE (0 | 16)) -- @@ -224,99 +123,58 @@ NtpDateTime ::= TEXTUAL-CONVENTION -- ntpEntSoftwareName OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS read-only STATUS current DESCRIPTION - "The product name of the installed NTP version." - -- the product name of the running ntp implementation, e.g. "ntpd" + "The product name of the running NTP version, e.g., 'ntpd'." ::= { ntpEntInfo 1 } ntpEntSoftwareVersion OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS read-only STATUS current DESCRIPTION - "The software version of the installed NTP implementation." - -- full version string, e.g. "ntpd-4.2.0b@1.1433 ..." + "The software version of the installed NTP implementation + as a full version string, e.g., 'ntpd-4.2.0b@1.1433 ...'" ::= { ntpEntInfo 2 } -ntpEntSoftwareVersionVal OBJECT-TYPE - SYNTAX Unsigned32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Software version of installed NTP as an unsigned integer - value." - -- e.g. if version string is "4.2.0b" this could be translated into - -- 4202. This could be useful to find out if version of entity on a - -- is newer or older than version of the entity on b (without too - -- much string parsing trouble) - ::= { ntpEntInfo 3 } - ntpEntSoftwareVendor OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS read-only STATUS current DESCRIPTION "The vendor/author of the installed NTP version." - ::= { ntpEntInfo 4 } + ::= { ntpEntInfo 3 } ntpEntSystemType OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS read-only STATUS current DESCRIPTION - "General hardware/os platform information." - -- e.g. "Linux 2.6.12 / x86" + "General hardware/os platform information, + e.g., 'Linux 2.6.12 / x86'." -- freely configurable, default is OS Version / Hardware platform - ::= { ntpEntInfo 5 } + ::= { ntpEntInfo 4 } ntpEntTimeResolution OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "A string describing the time resolution of the running NTP - implementation." - -- e.g. "100 ns" - -- depends on the NTP implementation and the underlying OS. The - -- current resolution should be used, so if the OS only supports - -- 10ms and ntpd is capable of 1ns, the 10ms should be advertised - ::= { ntpEntInfo 6 } - -ntpEntTimeResolutionVal OBJECT-TYPE SYNTAX Unsigned32 MAX-ACCESS read-only STATUS current DESCRIPTION - "The time resolution in integer format." - -- ntpEntTimeResolution in Integer format - -- shows the resolution based on 1 second, e.g. "1ms" translates to - -- 1000 - ::= { ntpEntInfo 7 } + "The time resolution in integer format, where the resolution + is represented as divisions of a second, e.g., a value of 1000 + translates to 1.0 ms." + ::= { ntpEntInfo 5 } ntpEntTimePrecision OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "A string describing the precision with which the NTP entity - implementation/OS manages its time base." - -- e.g. "-18" means 2^-18 = 0.000003814697265625 seconds - -- "-5" means 2^-5 = 0.03125 seconds - -- depends on the NTP implementation and the underlying OS. - ::= { ntpEntInfo 8 } - -ntpEntTimePrecisionVal OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION - "The entity's precision in integer format." - -- ntpEntTimePrecision in signed Integer format - -- shows the precision. A value of -5 would mean 2^-5 = 31.25 ms - ::= { ntpEntInfo 9 } + "The entity's precision in integer format, shows the precision. + A value of -5 would mean 2^-5 = 31.25 ms." + ::= { ntpEntInfo 6 } ntpEntTimeDistance OBJECT-TYPE SYNTAX DisplayString @@ -324,38 +182,14 @@ ntpEntTimeDistance OBJECT-TYPE STATUS current DESCRIPTION "The distance from this NTP entity to the root time reference - (stratum 0) source." - -- including the unit - -- e.g. "13.243 ms" - ::= { ntpEntInfo 10 } + (stratum 0) source including the unit, e.g., '13.243 ms'." + ::= { ntpEntInfo 7 } -- -- Section 2: Current NTP status (dynamic information) -- ntpEntStatusCurrentMode OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The actual mode of NTP as a string" - --- possible strings: - --- "not running" : NTP is not running - --- "not synchronized" : NTP is not synchronized to any time source - --- (stratum = 16) - --- "none configured" : NTP is not synchronized and does not have a - --- server configured - --- (stratum = 16) - --- "sync to local" : NTP is synchronized to own local clock - --- (degraded reliability) - --- "sync to refclock" : NTP is synchronized to a local hardware - --- refclock (e.g. GPS) - --- "sync to remote server" : NTP is synchronized to a remote NTP - --- server ("upstream" server) - --- "unknown" : The state of NTP is unknown. - ::= { ntpEntStatus 1 } - -ntpEntStatusCurrentModeVal OBJECT-TYPE SYNTAX INTEGER { notRunning(1), notSynchronized(2), @@ -368,20 +202,32 @@ ntpEntStatusCurrentModeVal OBJECT-TYPE MAX-ACCESS read-only STATUS current DESCRIPTION - "The current mode of the NTP as integer value." - -- see ntpEntStatusCurrentMode - DEFVAL { 99 } - ::= { ntpEntStatus 2 } + "The current mode of the NTP. The definition of each possible + value is: + notRunning(1) - NTP is not running. + notSynchronized(2) - NTP is not synchronized to any time + source (stratum = 16). + noneConfigured(3) - NTP is not synchronized and does not + have a reference configured + (stratum = 16). + syncToLocal(4) - NTP is distributing time based on its + local clock (degraded accuracy and/or + reliability). + syncToRefclock(5) - NTP is synchronized to a local + hardware refclock (e.g., GPS). + syncToRemoteServer(6) - NTP is synchronized to a remote + NTP server ('upstream' server). + unknown(99) - The state of NTP is unknown." + ::= { ntpEntStatus 1 } ntpEntStatusStratum OBJECT-TYPE SYNTAX NtpStratum MAX-ACCESS read-only STATUS current DESCRIPTION - "The NTP entity's own stratum value." - -- should be stratum of syspeer + 1 (or 16 if no syspeer) - DEFVAL { 16 } - ::= { ntpEntStatus 3 } + "The NTP entity's own stratum value. Should be a stratum of + syspeer + 1 (or 16 if no syspeer)." + ::= { ntpEntStatus 2 } ntpEntStatusActiveRefSourceId OBJECT-TYPE SYNTAX Unsigned32 ( 0..99999 ) @@ -389,30 +235,26 @@ ntpEntStatusActiveRefSourceId OBJECT-TYPE STATUS current DESCRIPTION "The association ID of the current syspeer." - DEFVAL { 0 } - ::= { ntpEntStatus 4 } + ::= { ntpEntStatus 3 } ntpEntStatusActiveRefSourceName OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS read-only STATUS current DESCRIPTION "The hostname/descriptive name of the current reference source - selected as syspeer." - -- e.g. "ntp1.ptb.de" or "GPS" or "DCFi" ... - -- maybe something like "RefClk(8)"="hardware clock using driver 8" - -- would be nice - ::= { ntpEntStatus 5 } + selected as syspeer, e.g., 'ntp1.ptb.de' or 'GPS' or + 'DCFi', ..." + ::= { ntpEntStatus 4 } ntpEntStatusActiveOffset OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION - "The Time offset to the current selected reference time source - as a string." - -- including unit, e.g. "0.032 ms" or "1.232 s" - ::= { ntpEntStatus 6 } + "The time offset to the current selected reference time source + as a string including unit, e.g., '0.032 ms' or '1.232 s'." + ::= { ntpEntStatus 5 } ntpEntStatusNumberOfRefSources OBJECT-TYPE SYNTAX Unsigned32 (0..99) @@ -420,28 +262,25 @@ ntpEntStatusNumberOfRefSources OBJECT-TYPE STATUS current DESCRIPTION "The number of reference sources configured for NTP." - DEFVAL { 0 } - ::= { ntpEntStatus 7 } + ::= { ntpEntStatus 6 } ntpEntStatusDispersion OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION - "The root dispersion of the running NTP entity." - -- e.g. "6.927" - DEFVAL { "n/a" } - ::= { ntpEntStatus 8 } + "The root dispersion of the running NTP entity, e.g., '6.927'." + ::= { ntpEntStatus 7 } ntpEntStatusEntityUptime OBJECT-TYPE - SYNTAX Unsigned32 + SYNTAX TimeTicks MAX-ACCESS read-only STATUS current DESCRIPTION - "The uptime of the NTP entity in seconds." - -- time since ntpd was (re-)started (not sysUptime!) - DEFVAL { 0 } - ::= { ntpEntStatus 9 } + "The uptime of the NTP entity, (i.e., the time since ntpd was + (re-)initialized not sysUptime!). The time is represented in + hundreds of seconds since Jan 1, 1970 (00:00:00.000) UTC." + ::= { ntpEntStatus 8 } ntpEntStatusDateTime OBJECT-TYPE SYNTAX NtpDateTime @@ -449,111 +288,128 @@ ntpEntStatusDateTime OBJECT-TYPE STATUS current DESCRIPTION "The current NTP date/time on the device, in 128-bit - NTP date format. Ref: draft-ietf-ntp-ntpv4-proto-06, - section 6: - It includes a 64-bit signed seconds field - spanning 584 billion years and a 64-bit fraction - field resolving .05 attosecond (i.e. 0.5e-18). - For convenience in mapping between formats, the - seconds field is divided into a 32-bit era field - and a 32-bit timestamp field. - - If time is not syncronized this field shall be a - zero-length string. + NTP date format. If time is not syncronized, this + field shall be a zero-length string. This object can be used to timestamp events on this - node and allow a management station to coorelate - different time objects. For example, a management + node and allow a management station to correlate + different time objects. For example, a management station could query this object and sysUpTime in the same operation to be able to relate sysUpTime to NTP time. This object is not to be used to set the time of - the node querying this object. NTP should be used - for this--or at least SNTP." - ::= { ntpEntStatus 10 } + the node querying this object. NTP should be used + for this -- or at least SNTP." + REFERENCE "RFC 5905, section 6" + ::= { ntpEntStatus 9 } ntpEntStatusLeapSecond OBJECT-TYPE - SYNTAX Integer32 + SYNTAX NtpDateTime MAX-ACCESS read-only STATUS current DESCRIPTION - "Date the next known leap second will occur. If there is - no leap second announced then this object should be 0." - DEFVAL { 0 } - ::= { ntpEntStatus 11 } + "Date the next known leap second will occur. If there is + no leap second announced, then this object should be 0." + ::= { ntpEntStatus 10 } ntpEntStatusLeapSecDirection OBJECT-TYPE SYNTAX Integer32 (-1..1) MAX-ACCESS read-only STATUS current DESCRIPTION - "Direction of next known leap second. If there is no - leap second announced then this object should be 0." - DEFVAL { 0 } - ::= { ntpEntStatus 12 } + "Direction of next known leap second. If there is no + leap second announced, then this object should be 0." + ::= { ntpEntStatus 11 } ntpEntStatusInPkts OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION "The total number of NTP messages delivered to the - NTP entity from the transport service." - ::= { ntpEntStatus 13 } + NTP entity from the transport service. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." + ::= { ntpEntStatus 12 } ntpEntStatusOutPkts OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION "The total number of NTP messages delivered to the - transport service by this NTP entity." - ::= { ntpEntStatus 14 } + transport service by this NTP entity. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." + ::= { ntpEntStatus 13 } ntpEntStatusBadVersion OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION - "The total number of NTP messages which were delivered + "The total number of NTP messages that were delivered to this NTP entity and were for an unsupported NTP - version." - ::= { ntpEntStatus 15 } + version. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." + ::= { ntpEntStatus 14 } ntpEntStatusProtocolError OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION - "The total number of NTP messages which were delivered + "The total number of NTP messages that were delivered to this NTP entity and this entity was not able to - process due to an NTP protocol error." - ::= { ntpEntStatus 16 } + process due to an NTP protocol error. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." + ::= { ntpEntStatus 15 } ntpEntStatusNotifications OBJECT-TYPE SYNTAX Counter32 + UNITS "notifications" MAX-ACCESS read-only STATUS current DESCRIPTION - "The total number of SNMP notifications which this NTP - entity has generated." - ::= { ntpEntStatus 17 } + "The total number of SNMP notifications that this NTP + entity has generated. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." + ::= { ntpEntStatus 16 } ntpEntStatPktModeTable OBJECT-TYPE SYNTAX SEQUENCE OF NtpEntStatPktModeEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION - "The number of packets sent and received by packet mode." - ::= { ntpEntStatus 18 } + "The number of packets sent and received by packet mode. + One entry per packet mode." + ::= { ntpEntStatus 17 } ntpEntStatPktModeEntry OBJECT-TYPE SYNTAX NtpEntStatPktModeEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION - "The number of packets sent and received by packet mode." + "A statistical record of the number of packets sent and + received for each packet mode." INDEX { ntpEntStatPktMode } ::= { ntpEntStatPktModeTable 1 } @@ -580,18 +436,29 @@ ntpEntStatPktMode OBJECT-TYPE ntpEntStatPktSent OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION - "The number of NTP packets sent with this packet mode." + "The number of NTP packets sent with this packet mode. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." ::= { ntpEntStatPktModeEntry 2 } ntpEntStatPktReceived OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION - "The number of NTP packets received with this packet mode." + "The number of NTP packets received with this packet mode. + + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." ::= { ntpEntStatPktModeEntry 3 } -- @@ -617,7 +484,7 @@ ntpAssociationEntry OBJECT-TYPE NtpAssociationEntry ::= SEQUENCE { ntpAssocId Unsigned32, - ntpAssocName DisplayString, + ntpAssocName Utf8String, ntpAssocRefId DisplayString, ntpAssocAddressType InetAddressType, ntpAssocAddress InetAddress, @@ -633,11 +500,11 @@ ntpAssocId OBJECT-TYPE MAX-ACCESS not-accessible STATUS current DESCRIPTION - "The association ID. This is an internal, unique ID." + "The association ID. This is an internal, unique ID." ::= { ntpAssociationEntry 1 } ntpAssocName OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS read-only STATUS current DESCRIPTION @@ -655,21 +522,24 @@ ntpAssocRefId OBJECT-TYPE ::= { ntpAssociationEntry 3 } ntpAssocAddressType OBJECT-TYPE - SYNTAX InetAddressType + SYNTAX InetAddressType { ipv4(1), ipv6(2), ipv4z(3), ipv6z(4) } MAX-ACCESS read-only STATUS current DESCRIPTION - "The type of address of the association." - -- contains the type of address for uni/multi/broadcast associations + "The type of address of the association. Can be either IPv4 or + IPv6 (both with or without zone index) and contains the type of + address for unicast, multicast, and broadcast associations." ::= { ntpAssociationEntry 4 } ntpAssocAddress OBJECT-TYPE - SYNTAX InetAddress + SYNTAX InetAddress (SIZE (4|8|16|20)) MAX-ACCESS read-only STATUS current DESCRIPTION - "The IP address (IPv4 or IPv6) of the association." - -- contains IP address of uni/multi/broadcast associations + "The IP address (IPv4 or IPv6, with or without zone index) of + the association. The type and size depends on the + ntpAssocAddressType object. Represents the IP address of a + uni/multi/broadcast association." ::= { ntpAssociationEntry 5 } ntpAssocOffset OBJECT-TYPE @@ -678,7 +548,7 @@ ntpAssocOffset OBJECT-TYPE STATUS current DESCRIPTION "The time offset to the association as a string." - -- including unit, e.g. "0.032 ms" or "1.232 s" + -- including unit, e.g., "0.032 ms" or "1.232 s" ::= { ntpAssociationEntry 6 } ntpAssocStratum OBJECT-TYPE @@ -694,7 +564,7 @@ ntpAssocStatusJitter OBJECT-TYPE MAX-ACCESS read-only STATUS current DESCRIPTION - "The jitter in miliseconds as a string." + "The jitter in milliseconds as a string." ::= { ntpAssociationEntry 8 } ntpAssocStatusDelay OBJECT-TYPE @@ -702,7 +572,7 @@ ntpAssocStatusDelay OBJECT-TYPE MAX-ACCESS read-only STATUS current DESCRIPTION - "The network delay in miliseconds as a string." + "The network delay in milliseconds as a string." ::= { ntpAssociationEntry 9 } ntpAssocStatusDispersion OBJECT-TYPE @@ -711,7 +581,7 @@ ntpAssocStatusDispersion OBJECT-TYPE STATUS current DESCRIPTION "The root dispersion of the association." - -- e.g. "6.927" + -- e.g., "6.927" ::= { ntpAssociationEntry 10 } ntpAssociationStatisticsTable OBJECT-TYPE @@ -739,31 +609,46 @@ NtpAssociationStatisticsEntry ::= SEQUENCE { ntpAssocStatInPkts OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION "The total number of NTP messages delivered to the - NTP entity from this association." + NTP entity from this association. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." ::= { ntpAssociationStatisticsEntry 1 } ntpAssocStatOutPkts OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION "The total number of NTP messages delivered to the transport service by this NTP entity for this - association." + association. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." ::= { ntpAssociationStatisticsEntry 2 } ntpAssocStatProtocolError OBJECT-TYPE SYNTAX Counter32 + UNITS "packets" MAX-ACCESS read-only STATUS current DESCRIPTION - "The total number of NTP messages which were delivered + "The total number of NTP messages that were delivered to this NTP entity from this association and this entity - was not able to process due to an NTP protocol error." + was not able to process due to an NTP protocol error. + Discountinuities in the value of this counter can occur + upon cold start or reinitialization of the NTP entity, the + management system and at other times as indicated by + discontinuities in the value of sysUpTime." ::= { ntpAssociationStatisticsEntry 3 } -- @@ -772,13 +657,16 @@ ntpAssocStatProtocolError OBJECT-TYPE ntpEntHeartbeatInterval OBJECT-TYPE SYNTAX Unsigned32 + UNITS "seconds" MAX-ACCESS read-write STATUS current DESCRIPTION "The interval at which the ntpEntNotifHeartbeat notification - should be sent, in seconds. If set to 0 and the - entNotifHeartbeat bit in ntpEntNotifBits is 1 then - ntpEntNotifHeartbeat is sent once." + should be sent, in seconds. If set to 0 and the + entNotifHeartbeat bit in ntpEntNotifBits is 1, then + ntpEntNotifHeartbeat is sent once. + This value is stored persistently and will be restored to its + last set value upon cold start or restart." DEFVAL { 60 } ::= { ntpEntControl 1 } @@ -798,8 +686,10 @@ ntpEntNotifBits OBJECT-TYPE MAX-ACCESS read-write STATUS current DESCRIPTION - "A bit for each notification. A 1 for a particular bit enables - that particular notification, a 0 disables it." + "A bit for each notification. A 1 for a particular bit enables + that particular notification, a 0 disables it. + This value is stored persistently and will be restored to its + last set value upon cold start or restart." ::= { ntpEntControl 2 } -- @@ -807,12 +697,12 @@ ntpEntNotifBits OBJECT-TYPE -- ntpEntNotifMessage OBJECT-TYPE - SYNTAX DisplayString + SYNTAX Utf8String MAX-ACCESS accessible-for-notify STATUS current DESCRIPTION - "Used as a payload object for all notifications. Holds a clear - text event message." + "Used as a payload object for all notifications. Holds a + cleartext event message." DEFVAL { "no event" } ::= { ntpEntNotifObjects 1 } @@ -820,14 +710,14 @@ ntpEntNotifMessage OBJECT-TYPE -- SNMP notification definitions -- -ntpEntNotifications OBJECT IDENTIFIER ::= { ntpEntNotifPrefix 0 } +ntpEntNotifications OBJECT IDENTIFIER ::= { ntpSnmpMIB 0 } ntpEntNotifModeChange NOTIFICATION-TYPE - OBJECTS { ntpEntStatusCurrentModeVal } + OBJECTS { ntpEntStatusCurrentMode } STATUS current DESCRIPTION "The notification to be sent when the NTP entity changes mode, - including starting and stopping (if possible)" + including starting and stopping (if possible)." ::= { ntpEntNotifications 1 } ntpEntNotifStratumChange NOTIFICATION-TYPE @@ -848,7 +738,7 @@ ntpEntNotifSyspeerChanged NOTIFICATION-TYPE ::= { ntpEntNotifications 3 } ntpEntNotifAddAssociation NOTIFICATION-TYPE - OBJECTS { ntpEntStatusDateTime, ntpAssocName, ntpEntNotifMessage } + OBJECTS { ntpEntStatusDateTime, ntpAssocName, ntpEntNotifMessage } STATUS current DESCRIPTION "The notification to be sent when a new association is @@ -856,7 +746,7 @@ ntpEntNotifAddAssociation NOTIFICATION-TYPE ::= { ntpEntNotifications 4 } ntpEntNotifRemoveAssociation NOTIFICATION-TYPE - OBJECTS { ntpEntStatusDateTime, ntpAssocName, ntpEntNotifMessage } + OBJECTS { ntpEntStatusDateTime, ntpAssocName, ntpEntNotifMessage } STATUS current DESCRIPTION "The notification to be sent when an association is @@ -868,9 +758,8 @@ ntpEntNotifConfigChanged NOTIFICATION-TYPE STATUS current DESCRIPTION "The notification to be sent when the NTP configuration has - changed." - -- e.g. when the system connected to the internet and was assigned - -- a new IP address by the ISPs DHCP server + changed, e.g., when the system connected to the Internet and + was assigned a new IP address by the ISPs DHCP server." ::= { ntpEntNotifications 6 } ntpEntNotifLeapSecondAnnounced NOTIFICATION-TYPE @@ -882,7 +771,7 @@ ntpEntNotifLeapSecondAnnounced NOTIFICATION-TYPE ::= { ntpEntNotifications 7 } ntpEntNotifHeartbeat NOTIFICATION-TYPE - OBJECTS { ntpEntStatusDateTime, ntpEntStatusCurrentModeVal, + OBJECTS { ntpEntStatusDateTime, ntpEntStatusCurrentMode, ntpEntHeartbeatInterval, ntpEntNotifMessage } STATUS current DESCRIPTION @@ -895,7 +784,7 @@ ntpEntNotifHeartbeat NOTIFICATION-TYPE -- Conformance/Compliance statements -- -ntpEntConformance OBJECT IDENTIFIER ::= { ntpSnmpMIB 6 } +ntpEntConformance OBJECT IDENTIFIER ::= { ntpSnmpMIB 2 } ntpEntCompliances OBJECT IDENTIFIER ::= { ntpEntConformance 1 } ntpEntGroups OBJECT IDENTIFIER ::= { ntpEntConformance 2 } @@ -903,32 +792,35 @@ ntpEntGroups OBJECT IDENTIFIER ::= { ntpEntConformance 2 } ntpEntNTPCompliance MODULE-COMPLIANCE STATUS current DESCRIPTION - "The compliance statement for SNMP entities which use NTP and - implement the NTP MIB" + "The compliance statement for SNMP entities that use NTP and + implement the NTP MIB." MODULE -- this module MANDATORY-GROUPS { - ntpEntObjectsGroup1, - ntpEntObjectsGroup2, - ntpEntNotifPrefixGroup + ntpEntObjectsGroup1 } ::= { ntpEntCompliances 1 } ntpEntSNTPCompliance MODULE-COMPLIANCE STATUS current DESCRIPTION - "The compliance statement for SNMP entities which use SNTP and - implement the NTP MIB" + "The compliance statement for SNMP entities that use SNTP and + implement the NTP MIB." MODULE -- this module MANDATORY-GROUPS { ntpEntObjectsGroup1 } + GROUP ntpEntObjectsGroup2 + DESCRIPTION + "Optional object group." + GROUP ntpEntNotifGroup + DESCRIPTION + "Optional notifications for this MIB." ::= { ntpEntCompliances 2 } ntpEntObjectsGroup1 OBJECT-GROUP OBJECTS { ntpEntSoftwareName, ntpEntSoftwareVersion, - ntpEntSoftwareVersionVal, ntpEntSoftwareVendor, ntpEntSystemType, ntpEntStatusEntityUptime, @@ -940,19 +832,15 @@ ntpEntObjectsGroup1 OBJECT-GROUP } STATUS current DESCRIPTION - "A collection of objects for the NTP MIB that all NTP - or SNTP entities should implement." + "A collection of objects for the NTP MIB." ::= { ntpEntGroups 1 } ntpEntObjectsGroup2 OBJECT-GROUP OBJECTS { ntpEntTimeResolution, - ntpEntTimeResolutionVal, ntpEntTimePrecision, - ntpEntTimePrecisionVal, ntpEntTimeDistance, ntpEntStatusCurrentMode, - ntpEntStatusCurrentModeVal, ntpEntStatusStratum, ntpEntStatusActiveRefSourceId, ntpEntStatusActiveRefSourceName, @@ -982,11 +870,10 @@ ntpEntObjectsGroup2 OBJECT-GROUP } STATUS current DESCRIPTION - "A collection of objects for the NTP MIB that are optional - for NTP or SNTP entities to implement." + "A collection of objects for the NTP MIB." ::= { ntpEntGroups 2 } -ntpEntNotifPrefixGroup NOTIFICATION-GROUP +ntpEntNotifGroup NOTIFICATION-GROUP NOTIFICATIONS { ntpEntNotifModeChange, ntpEntNotifStratumChange,