#ifndef NTP_SYSLOG_H
#define NTP_SYSLOG_H
+#include <ntp_types.h> /* u_int32 type */
+
# ifdef VMS
extern void msyslog();
# else
#define NLOG_STATIST 0x00000008
#define NLOG_OSYS 0 /* offset for system flags */
-#define NLOG_SYSMASK 0x0000000F /* system log events */
+#define NLOG_SYSMASK 0x0000000F /* system log events */
#define NLOG_SYSINFO 0x00000001 /* system info log events */
#define NLOG_SYSEVENT 0x00000002 /* system events */
#define NLOG_SYSSTATUS 0x00000004 /* system status (sync/unsync) */
#define NLOG_SYSSTATIST 0x00000008 /* system statistics output */
#define NLOG_OPEER 4 /* offset for peer flags */
-#define NLOG_PEERMASK 0x000000F0 /* peer log events */
+#define NLOG_PEERMASK 0x000000F0 /* peer log events */
#define NLOG_PEERINFO 0x00000010 /* peer info log events */
#define NLOG_PEEREVENT 0x00000020 /* peer events */
#define NLOG_PEERSTATUS 0x00000040 /* peer status (sync/unsync) */
#define NLOG_PEERSTATIST 0x00000080 /* peer statistics output */
#define NLOG_OCLOCK 8 /* offset for clock flags */
-#define NLOG_CLOCKMASK 0x00000F00 /* clock log events */
+#define NLOG_CLOCKMASK 0x00000F00 /* clock log events */
#define NLOG_CLOCKINFO 0x00000100 /* clock info log events */
#define NLOG_CLOCKEVENT 0x00000200 /* clock events */
#define NLOG_CLOCKSTATUS 0x00000400 /* clock status (sync/unsync) */
#define NLOG_CLOCKSTATIST 0x00000800 /* clock statistics output */
#define NLOG_OSYNC 12 /* offset for sync flags */
-#define NLOG_SYNCMASK 0x0000F000 /* sync log events */
+#define NLOG_SYNCMASK 0x0000F000 /* sync log events */
#define NLOG_SYNCINFO 0x00001000 /* sync info log events */
#define NLOG_SYNCEVENT 0x00002000 /* sync events */
#define NLOG_SYNCSTATUS 0x00004000 /* sync status (sync/unsync) */
#define NLOG_SYNCSTATIST 0x00008000 /* sync statistics output */
-extern unsigned long ntp_syslogmask;
+extern u_int32 ntp_syslogmask;
#define NLOG(_X_) if (ntp_syslogmask & (_X_))
#endif /* NTP_SYSLOG_H */
* "logconfig" building blocks
*/
struct masks {
- const char *name;
- unsigned long mask;
+ const char * const name;
+ const u_int32 mask;
};
static struct masks logcfg_class[] = {
- { "clock", NLOG_OCLOCK },
- { "peer", NLOG_OPEER },
- { "sync", NLOG_OSYNC },
- { "sys", NLOG_OSYS },
- { (char *)0, 0 }
+ { "clock", NLOG_OCLOCK },
+ { "peer", NLOG_OPEER },
+ { "sync", NLOG_OSYNC },
+ { "sys", NLOG_OSYS },
+ { NULL, 0 }
};
-static struct masks logcfg_item[] = {
+/* logcfg_noclass_items[] masks are complete and must not be shifted */
+static struct masks logcfg_noclass_items[] = {
+ { "allall", NLOG_SYSMASK | NLOG_PEERMASK | NLOG_CLOCKMASK | NLOG_SYNCMASK },
+ { "allinfo", NLOG_SYSINFO | NLOG_PEERINFO | NLOG_CLOCKINFO | NLOG_SYNCINFO },
+ { "allevents", NLOG_SYSEVENT | NLOG_PEEREVENT | NLOG_CLOCKEVENT | NLOG_SYNCEVENT },
+ { "allstatus", NLOG_SYSSTATUS | NLOG_PEERSTATUS | NLOG_CLOCKSTATUS | NLOG_SYNCSTATUS },
+ { "allstatistics", NLOG_SYSSTATIST | NLOG_PEERSTATIST | NLOG_CLOCKSTATIST | NLOG_SYNCSTATIST },
+ /* the remainder are misspellings of clockall, peerall, sysall, and syncall. */
+ { "allclock", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OCLOCK },
+ { "allpeer", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OPEER },
+ { "allsys", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OSYS },
+ { "allsync", (NLOG_INFO | NLOG_STATIST | NLOG_EVENT | NLOG_STATUS) << NLOG_OSYNC },
+ { NULL, 0 }
+};
+
+/* logcfg_class_items[] masks are shiftable by NLOG_O* counts */
+static struct masks logcfg_class_items[] = {
+ { "all", NLOG_INFO | NLOG_EVENT | NLOG_STATUS | NLOG_STATIST },
{ "info", NLOG_INFO },
- { "allinfo", NLOG_SYSINFO|NLOG_PEERINFO|NLOG_CLOCKINFO|NLOG_SYNCINFO },
{ "events", NLOG_EVENT },
- { "allevents", NLOG_SYSEVENT|NLOG_PEEREVENT|NLOG_CLOCKEVENT|NLOG_SYNCEVENT },
{ "status", NLOG_STATUS },
- { "allstatus", NLOG_SYSSTATUS|NLOG_PEERSTATUS|NLOG_CLOCKSTATUS|NLOG_SYNCSTATUS },
{ "statistics", NLOG_STATIST },
- { "allstatistics", NLOG_SYSSTATIST|NLOG_PEERSTATIST|NLOG_CLOCKSTATIST|NLOG_SYNCSTATIST },
- { "allclock", (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OCLOCK },
- { "allpeer", (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OPEER },
- { "allsys", (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OSYS },
- { "allsync", (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OSYNC },
- { "all", NLOG_SYSMASK|NLOG_PEERMASK|NLOG_CLOCKMASK|NLOG_SYNCMASK },
- { (char *)0, 0 }
+ { NULL, 0 }
};
/* Limits */
} while (0)
void ntpd_set_tod_using(const char *);
-static unsigned long get_pfxmatch(char **s,struct masks *m);
-static unsigned long get_match(char *s,struct masks *m);
-static unsigned long get_logmask(char *s);
+static u_int32 get_pfxmatch(const char **, struct masks *);
+static u_int32 get_match(const char *, struct masks *);
+static u_int32 get_logmask(const char *);
static int getnetnum(const char *num,sockaddr_u *addr, int complain,
enum gnn_type a_type);
static int get_multiple_netnums(const char *num, sockaddr_u *addr,
* get_pfxmatch - find value for prefixmatch
* and update char * accordingly
*/
-static unsigned long
+static u_int32
get_pfxmatch(
- char ** s,
- struct masks *m
+ const char ** pstr,
+ struct masks * m
)
{
- while (m->name) {
- if (strncmp(*s, m->name, strlen(m->name)) == 0) {
- *s += strlen(m->name);
+ while (m->name != NULL) {
+ if (strncmp(*pstr, m->name, strlen(m->name)) == 0) {
+ *pstr += strlen(m->name);
return m->mask;
} else {
m++;
/*
* get_match - find logmask value
*/
-static unsigned long
+static u_int32
get_match(
- char *s,
- struct masks *m
+ const char * str,
+ struct masks * m
)
{
- while (m->name) {
- if (strcmp(s, m->name) == 0)
+ while (m->name != NULL) {
+ if (strcmp(str, m->name) == 0)
return m->mask;
else
m++;
/*
* get_logmask - build bitmask for ntp_syslogmask
*/
-static unsigned long
+static u_int32
get_logmask(
- char *s
+ const char * str
)
{
- char *t;
- unsigned long offset;
- unsigned long mask;
+ const char * t;
+ u_int32 offset;
+ u_int32 mask;
+
+ mask = get_match(str, logcfg_noclass_items);
+ if (mask != 0)
+ return mask;
- t = s;
+ t = str;
offset = get_pfxmatch(&t, logcfg_class);
- mask = get_match(t, logcfg_item);
+ mask = get_match(t, logcfg_class_items);
if (mask)
return mask << offset;
else
- msyslog(LOG_ERR, "logconfig: illegal argument %s - ignored", s);
+ msyslog(LOG_ERR, "logconfig: '%s' not recognized - ignored",
+ str);
return 0;
}