diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/Makefile.in | 2 | ||||
-rw-r--r-- | include/c99_snprintf.h | 28 | ||||
-rw-r--r-- | include/isc/Makefile.in | 1 | ||||
-rw-r--r-- | include/lib_strbuf.h | 30 | ||||
-rw-r--r-- | include/ntp.h | 73 | ||||
-rw-r--r-- | include/ntp_config.h | 13 | ||||
-rw-r--r-- | include/ntp_control.h | 2 | ||||
-rw-r--r-- | include/ntp_lists.h | 4 | ||||
-rw-r--r-- | include/ntp_md5.h | 25 | ||||
-rw-r--r-- | include/ntp_net.h | 13 | ||||
-rw-r--r-- | include/ntp_psl.h | 11 | ||||
-rw-r--r-- | include/ntp_stdlib.h | 20 | ||||
-rw-r--r-- | include/ntp_tty.h | 5 | ||||
-rw-r--r-- | include/ntp_types.h | 10 | ||||
-rw-r--r-- | include/ntpd.h | 80 | ||||
-rw-r--r-- | include/vint64ops.h | 2 |
17 files changed, 220 insertions, 100 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index dd739ebbcdbd..b661ca639f29 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -8,6 +8,7 @@ noinst_HEADERS = \ ascii.h \ audio.h \ binio.h \ + c99_snprintf.h \ declcond.h \ gps.h \ hopf6039.h \ diff --git a/include/Makefile.in b/include/Makefile.in index 5bf244e81bd8..317111a094b1 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -386,6 +386,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@ +PATH_OPENSSL = @PATH_OPENSSL@ PATH_PERL = @PATH_PERL@ PATH_RUBY = @PATH_RUBY@ PATH_SEPARATOR = @PATH_SEPARATOR@ @@ -492,6 +493,7 @@ noinst_HEADERS = \ ascii.h \ audio.h \ binio.h \ + c99_snprintf.h \ declcond.h \ gps.h \ hopf6039.h \ diff --git a/include/c99_snprintf.h b/include/c99_snprintf.h new file mode 100644 index 000000000000..f5c1bf0e117c --- /dev/null +++ b/include/c99_snprintf.h @@ -0,0 +1,28 @@ +/* + * ntp_c99_snprintf.h + * + * Included from config.h to deal with replacing [v]snprintf() on older + * systems. The #undef lines below cannot be directly in config.h as + * config.status modifies each #undef in config.h.in to either be a + * commented-out #undef or a functional #define. Here they are used + * to avoid redefinition warnings on systems such as macos ca. 2024 + * where system headers define [v]snprintf as preprocessor macros. + * + * Do not include this file directly, leave it to config.h. + */ + +#if !defined(_KERNEL) && !defined(PARSESTREAM) +/* + * stdio.h must be included in config.h after _GNU_SOURCE is defined + * but before #define snprintf rpl_snprintf + */ +# include <stdio.h> +#endif + +#ifdef HW_WANT_RPL_SNPRINTF +# undef snprintf +#endif +#ifdef HW_WANT_RPL_VSNPRINTF +# undef vsnprintf +#endif + diff --git a/include/isc/Makefile.in b/include/isc/Makefile.in index 037cfbe354bf..fadd48e1c8ee 100644 --- a/include/isc/Makefile.in +++ b/include/isc/Makefile.in @@ -344,6 +344,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@ +PATH_OPENSSL = @PATH_OPENSSL@ PATH_PERL = @PATH_PERL@ PATH_RUBY = @PATH_RUBY@ PATH_SEPARATOR = @PATH_SEPARATOR@ diff --git a/include/lib_strbuf.h b/include/lib_strbuf.h index 5ee92d6f8341..89da450a5547 100644 --- a/include/lib_strbuf.h +++ b/include/lib_strbuf.h @@ -5,28 +5,28 @@ #define LIB_STRBUF_H #include <ntp_types.h> -#include <ntp_malloc.h> /* for ZERO() */ +#include <ntp_malloc.h> /* for zero_mem() */ -/* - * Sizes of things - */ -#define LIB_NUMBUF 16 #define LIB_BUFLENGTH 128 -typedef char libbufstr[LIB_BUFLENGTH]; -extern libbufstr lib_stringbuf[LIB_NUMBUF]; -extern int lib_nextbuf; -extern int lib_inited; +extern int lib_inited; +extern int ipv4_works; +extern int ipv6_works; +extern void init_lib(void); /* - * Macro to get a pointer to the next buffer + * Get a pointer to the next string buffer of LIB_BUFLENGTH octets. + * New and modified code should use buf = lib_getbuf() directly to + * provide clarity for folks familiar with common C style, but there's + * no need to churn the history with a mechanical switch away from + * LIB_GETBUF(buf). */ -#define LIB_GETBUF(bufp) \ - do { \ - ZERO(lib_stringbuf[lib_nextbuf]); \ - (bufp) = &lib_stringbuf[lib_nextbuf++][0]; \ - lib_nextbuf %= COUNTOF(lib_stringbuf); \ +extern char* lib_getbuf(void); + +#define LIB_GETBUF(bufp) \ + do { \ + (bufp) = lib_getbuf(); \ } while (FALSE) #endif /* LIB_STRBUF_H */ diff --git a/include/ntp.h b/include/ntp.h index 258ddd6138f7..7406a79ea8a4 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -171,8 +171,8 @@ typedef char s_char; * Eventually the struct tag will change from interface to endpt_tag. * endpt is unrelated to the select algorithm's struct endpoint. */ -typedef struct interface endpt; -struct interface { +typedef struct endpt_tag endpt; +struct endpt_tag { endpt * elink; /* endpt list link */ endpt * mclink; /* per-AF_* multicast list */ void * ioreg_ctx; /* IO registration context */ @@ -185,9 +185,12 @@ struct interface { char name[32]; /* name of interface */ u_short family; /* AF_INET/AF_INET6 */ u_short phase; /* phase in update cycle */ - u_int32 flags; /* interface flags */ + u_int32 flags; /* INT_ flags */ int last_ttl; /* last TTL specified */ u_int32 addr_refid; /* IPv4 addr or IPv6 hash */ +# ifdef WORDS_BIGENDIAN + u_int32 old_refid; /* byte-swapped IPv6 refid */ +# endif int num_mcast; /* mcast addrs enabled */ u_long starttime; /* current_time at creation */ volatile long received; /* number of incoming packets */ @@ -200,11 +203,11 @@ struct interface { }; /* - * Flags for interfaces + * Flags for network endpoints (interfaces or really addresses) */ #define INT_UP 0x001 /* Interface is up */ #define INT_PPP 0x002 /* Point-to-point interface */ -#define INT_LOOPBACK 0x004 /* the loopback interface */ +#define INT_LOOPBACK 0x004 /* ::1 or 127.0.0.1 */ #define INT_BROADCAST 0x008 /* can broadcast out this interface */ #define INT_MULTICAST 0x010 /* can multicast out this interface */ #define INT_BCASTOPEN 0x020 /* broadcast receive socket is open */ @@ -212,7 +215,8 @@ struct interface { #define INT_WILDCARD 0x080 /* wildcard interface - usually skipped */ #define INT_MCASTIF 0x100 /* bound directly to MCAST address */ #define INT_PRIVACY 0x200 /* RFC 4941 IPv6 privacy address */ -#define INT_BCASTXMIT 0x400 /* socket setup to allow broadcasts */ +#define INT_BCASTXMIT 0x400 /* socket setup to allow broadcasts */ +#define INT_LL_OF_GLOB 0x800 /* IPv6 link-local duplicate of global */ /* * Define flasher bits (tests 1 through 11 in packet procedure) @@ -342,12 +346,12 @@ struct peer { u_char status; /* peer status */ u_char new_status; /* under-construction status */ u_char reach; /* reachability register */ + u_char filter_nextpt; /* index into filter shift register */ int flash; /* protocol error test tally bits */ u_long epoch; /* reference epoch */ int burst; /* packets remaining in burst */ int retry; /* retry counter */ int flip; /* interleave mode control */ - int filter_nextpt; /* index into filter shift register */ double filter_delay[NTP_SHIFT]; /* delay shift register */ double filter_offset[NTP_SHIFT]; /* offset shift register */ double filter_disp[NTP_SHIFT]; /* dispersion shift register */ @@ -463,11 +467,12 @@ struct peer { #define FLAG_XLEAVE 0x1000 /* interleaved protocol */ #define FLAG_XB 0x2000 /* interleaved broadcast */ #define FLAG_XBOGUS 0x4000 /* interleaved bogus packet */ -#ifdef OPENSSL +#ifdef AUTOKEY # define FLAG_ASSOC 0x8000 /* autokey request */ -#endif /* OPENSSL */ +#endif #define FLAG_TSTAMP_PPS 0x10000 /* PPS source provides absolute timestamp */ #define FLAG_LOOPNONCE 0x20000 /* Use a nonce for the loopback test */ +#define FLAG_DISABLED 0x40000 /* peer is being torn down */ /* * Definitions for the clear() routine. We use memset() to clear @@ -558,9 +563,15 @@ struct pkt { #define MIN_V4_PKT_LEN (12 * sizeof(u_int32)) /* min header length */ #define LEN_PKT_NOMAC (12 * sizeof(u_int32)) /* min header length */ #define MIN_MAC_LEN (1 * sizeof(u_int32)) /* crypto_NAK */ -#define MAX_MD5_LEN (5 * sizeof(u_int32)) /* MD5 */ -#define MAX_MAC_LEN (6 * sizeof(u_int32)) /* SHA */ +#define MD5_LENGTH 16 +#define SHAKE128_LENGTH 16 +#define CMAC_LENGTH 16 +#define SHA1_LENGTH 20 #define KEY_MAC_LEN sizeof(u_int32) /* key ID in MAC */ +#define MAX_MD5_LEN (KEY_MAC_LEN + MD5_LENGTH) +#define MAX_SHAKE128_LEN (KEY_MAC_LEN + SHAKE128_LENGTH) +#define MAX_SHA1_LEN (KEY_MAC_LEN + SHA1_LENGTH) +#define MAX_MAC_LEN (6 * sizeof(u_int32)) /* any MAC */ #define MAX_MDG_LEN (MAX_MAC_LEN-KEY_MAC_LEN) /* max. digest len */ /* @@ -703,6 +714,10 @@ struct pkt { #define max(a,b) (((a) > (b)) ? (a) : (b)) #define min3(a,b,c) min(min((a),(b)), (c)) +/* clamp a value within a range */ +#define CLAMP(val, minval, maxval) \ + max((minval), min((val), (maxval))) + /* * Configuration items. These are for the protocol module (proto_config()) @@ -783,7 +798,7 @@ typedef struct mon_data mon_entry; struct mon_data { mon_entry * hash_next; /* next structure in hash list */ DECL_DLIST_LINK(mon_entry, mru);/* MRU list link pointers */ - struct interface * lcladr; /* address on which this arrived */ + endpt * lcladr; /* address on which this arrived */ l_fp first; /* first time seen */ l_fp last; /* last time seen */ int leak; /* leaky bucket accumulator */ @@ -804,7 +819,7 @@ struct mon_data { #define MDF_POOL 0x08 /* pool client solicitor */ #define MDF_ACAST 0x10 /* manycast client solicitor */ #define MDF_BCLNT 0x20 /* eph. broadcast/multicast client */ -#define MDF_UCLNT 0x40 /* preemptible manycast or pool client */ +#define MDF_PCLNT 0x40 /* preemptible pool client */ /* * In the context of struct peer in ntpd, three of the cast_flags bits * represent configured associations which never receive packets, and @@ -841,11 +856,10 @@ typedef struct restrict_u_tag restrict_u; struct restrict_u_tag { restrict_u * link; /* link to next entry */ u_int32 count; /* number of packets matched */ + u_int32 expire; /* valid until current_time */ u_short rflags; /* restrict (accesslist) flags */ - u_short mflags; /* match flags */ - short ippeerlimit; /* IP peer limit */ - int srvfuzrftpoll; /* server response: fuzz reftime */ - u_long expire; /* valid until time */ + u_int32 mflags; /* match flags */ + short ippeerlimit; /* limit of associations matching */ union { /* variant starting here */ res_addr4 v4; res_addr6 v6; @@ -856,16 +870,13 @@ struct restrict_u_tag { #define V6_SIZEOF_RESTRICT_U (offsetof(restrict_u, u) \ + sizeof(res_addr6)) +/* restrictions for (4) a given address */ typedef struct r4addr_tag r4addr; struct r4addr_tag { u_short rflags; /* match flags */ short ippeerlimit; /* IP peer limit */ }; -char *build_iflags(u_int32 flags); -char *build_mflags(u_short mflags); -char *build_rflags(u_short rflags); - /* * Restrict (Access) flags (rflags) */ @@ -876,10 +887,6 @@ char *build_rflags(u_short rflags); #define RES_NOPEER 0x0010 /* new association denied */ #define RES_NOEPEER 0x0020 /* new ephemeral association denied */ #define RES_LIMITED 0x0040 /* packet rate exceeded */ -#define RES_FLAGS (RES_IGNORE | RES_DONTSERVE |\ - RES_DONTTRUST | RES_VERSION |\ - RES_NOPEER | RES_NOEPEER | RES_LIMITED) - #define RES_NOQUERY 0x0080 /* mode 6/7 packet denied */ #define RES_NOMODIFY 0x0100 /* mode 6/7 modify denied */ #define RES_NOTRAP 0x0200 /* mode 6/7 set trap denied */ @@ -894,7 +901,10 @@ char *build_rflags(u_short rflags); #define RES_UNUSED 0x0000 /* Unused flag bits (none left) */ -#define RES_ALLFLAGS (RES_FLAGS | RES_NOQUERY | \ +#define RES_ALLFLAGS (RES_IGNORE | RES_DONTSERVE | \ + RES_DONTTRUST | RES_VERSION | \ + RES_NOPEER | RES_NOEPEER | \ + RES_LIMITED | RES_NOQUERY | \ RES_NOMODIFY | RES_NOTRAP | \ RES_LPTRAP | RES_KOD | \ RES_MSSNTP | RES_FLAKE | \ @@ -948,4 +958,15 @@ struct endpoint { #define MRU_ROW_LIMIT 256 /* similar datagrams per response limit for ntpd */ #define MRU_FRAGS_LIMIT 128 + +/* found on POSIX systems in sysexit.h */ +#ifndef EX_SOFTWARE +# define EX_SOFTWARE 70 /* internal software error */ +#endif + +#define BYTESWAP32(u32) \ + (((u_int32)(u32) & 0xff000000) >> 24 | \ + ((u_int32)(u32) & 0xff0000) >> 8 | \ + ((u_int32)(u32) & 0xff00) << 8 | \ + ((u_int32)(u32) & 0xff) << 24) #endif /* NTP_H */ diff --git a/include/ntp_config.h b/include/ntp_config.h index dbb64e3a2eee..2fce70945035 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -113,7 +113,9 @@ struct restrict_node_tag { address_node * addr; address_node * mask; attr_val_fifo * flag_tok_fifo; + int/*BOOL*/ remove; int line_no; + int column; short ippeerlimit; short srvfuzrft; }; @@ -317,10 +319,13 @@ void destroy_attr_val(attr_val *node); filegen_node *create_filegen_node(int filegen_token, attr_val_fifo *options); string_node *create_string_node(char *str); -restrict_node *create_restrict_node(address_node *addr, - address_node *mask, - short ippeerlimit, - attr_val_fifo *flags, int line_no); +restrict_node *create_restrict_node(address_node * addr, + address_node * mask, + short ippeerlimit, + attr_val_fifo * flag_tok_fifo, + int/*BOOL*/ remove, + int nline, + int ncol); int_node *create_int_node(int val); addr_opts_node *create_addr_opts_node(address_node *addr, attr_val_fifo *options); diff --git a/include/ntp_control.h b/include/ntp_control.h index 2fe0f30bbd78..91b85aa52df4 100644 --- a/include/ntp_control.h +++ b/include/ntp_control.h @@ -159,7 +159,7 @@ struct ntp_control { */ struct ctl_trap { sockaddr_u tr_addr; /* address of trap recipient */ - struct interface *tr_localaddr; /* interface to send this through */ + endpt *tr_localaddr; /* interface to send this through */ u_long tr_settime; /* time trap was set */ u_long tr_count; /* async messages sent to this guy */ u_long tr_origtime; /* time trap was originally set */ diff --git a/include/ntp_lists.h b/include/ntp_lists.h index d741974943ef..bed692ff294e 100644 --- a/include/ntp_lists.h +++ b/include/ntp_lists.h @@ -181,7 +181,7 @@ do { \ #define UNLINK_EXPR_SLIST(punlinked, listhead, expr, nextlink, \ entrytype) \ -do { \ +if (NULL != (listhead)) { \ entrytype **ppentry; \ \ ppentry = &(listhead); \ @@ -202,6 +202,8 @@ do { \ } else { \ (punlinked) = NULL; \ } \ +} else do { \ + (punlinked) = NULL; \ } while (FALSE) #define UNLINK_SLIST(punlinked, listhead, ptounlink, nextlink, \ diff --git a/include/ntp_md5.h b/include/ntp_md5.h index 8b5a7d0cbb49..22caff350cd9 100644 --- a/include/ntp_md5.h +++ b/include/ntp_md5.h @@ -6,6 +6,18 @@ #ifndef NTP_MD5_H #define NTP_MD5_H +/* Use the system MD5 or fall back on libisc's */ +# if defined HAVE_MD5_H && defined HAVE_MD5INIT +# include <md5.h> +# else +# include "isc/md5.h" + typedef isc_md5_t MD5_CTX; +# define MD5_DIGEST_LENGTH ISC_MD5_DIGESTLENGTH +# define MD5Init(c) isc_md5_init(c) +# define MD5Update(c, p, s) isc_md5_update(c, (const void *)p, s) +# define MD5Final(d, c) isc_md5_final((c), (d)) /* swapped */ +# endif + # define KEY_TYPE_MD5 NID_md5 #ifdef OPENSSL @@ -20,20 +32,11 @@ /* * Provide OpenSSL-alike MD5 API if we're not using OpenSSL */ -# if defined HAVE_MD5_H && defined HAVE_MD5INIT -# include <md5.h> -# else -# include "isc/md5.h" - typedef isc_md5_t MD5_CTX; -# define MD5Init(c) isc_md5_init(c) -# define MD5Update(c, p, s) isc_md5_update(c, p, s) -# define MD5Final(d, c) isc_md5_final((c), (d)) /* swapped */ -# endif typedef MD5_CTX EVP_MD_CTX; # define NID_md5 4 /* from openssl/objects.h */ -# define EVP_MAX_MD_SIZE 64 /* from openssl/evp.h */ +# define EVP_MAX_MD_SIZE MD5_DIGEST_LENGTH # define EVP_MD_CTX_free(c) free(c) # define EVP_MD_CTX_new() calloc(1, sizeof(MD5_CTX)) # define EVP_get_digestbynid(t) NULL @@ -47,7 +50,7 @@ # define EVP_DigestFinal(c, d, pdl) \ do { \ MD5Final((d), (c)); \ - *(pdl) = 16; \ + *(pdl) = MD5_LENGTH; \ } while (0) # endif /* !OPENSSL */ #endif /* NTP_MD5_H */ diff --git a/include/ntp_net.h b/include/ntp_net.h index 0577402bfb2c..09cc7f65f97b 100644 --- a/include/ntp_net.h +++ b/include/ntp_net.h @@ -195,7 +195,7 @@ typedef union { #define SOCK_UNSPEC_S(psau) \ (SOCK_UNSPEC(psau) && !SCOPE(psau)) -/* choose a default net interface (struct interface) for v4 or v6 */ +/* choose a default net interface (endpt) for v4 or v6 */ #define ANY_INTERFACE_BYFAM(family) \ ((AF_INET == family) \ ? any_interface \ @@ -227,6 +227,12 @@ typedef union { */ #define LOOPBACKADR 0x7f000001 #define LOOPNETMASK 0xff000000 +#ifdef WORDS_BIGENDIAN +# define LOOPBACKADR_N LOOPBACKADR +#else +# define LOOPBACKADR_N 0x0100007f +#endif + #define ISBADADR(srcadr) \ (IS_IPV4(srcadr) \ @@ -234,5 +240,10 @@ typedef union { == (LOOPBACKADR & LOOPNETMASK)) \ && SRCADR(srcadr) != LOOPBACKADR) +#define IS_LOOPBACK_ADDR(psau) \ + (IS_IPV4(psau) \ + ? LOOPBACKADR == SRCADR(psau) \ + : IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(psau)) \ + ) #endif /* NTP_NET_H */ diff --git a/include/ntp_psl.h b/include/ntp_psl.h index a0c2662d44c7..c3a6846f90d0 100644 --- a/include/ntp_psl.h +++ b/include/ntp_psl.h @@ -4,12 +4,15 @@ /* * Poll Skew List Item + * u_in32 is large enough for sub and qty so long as NTP_MAXPOLL < 31 */ - +#if NTP_MAXPOLL >= 31 +#include "psl_item structure needs larger type" +#endif typedef struct psl_item_tag { - int sub; /* int or short? unsigned is OK, but why? */ - int qty; /* int or short? unsigned is OK, but why? */ - int msk; /* int or short? unsigned is OK */ + u_int32 sub; + u_int32 qty; + u_int32 msk; } psl_item; int get_pollskew(int, psl_item *); diff --git a/include/ntp_stdlib.h b/include/ntp_stdlib.h index 446837e3adcb..6f667fbabed7 100644 --- a/include/ntp_stdlib.h +++ b/include/ntp_stdlib.h @@ -11,10 +11,12 @@ #include "declcond.h" /* ntpd uses ntpd/declcond.h, others include/ */ #include "l_stdlib.h" +#include "lib_strbuf.h" #include "ntp_md5.h" #include "ntp_net.h" #include "ntp_debug.h" #include "ntp_malloc.h" +#include "lib_strbuf.h" #include "ntp_string.h" #include "ntp_syslog.h" #include "ntp_keyacc.h" @@ -113,7 +115,7 @@ extern size_t MD5authencrypt (int type, const u_char *key, size_t klen, extern int MD5authdecrypt (int type, const u_char *key, size_t klen, u_int32 *pkt, size_t length, size_t size, keyid_t keyno); -extern u_int32 addr2refid(sockaddr_u *); +extern u_int32 addr2refid (sockaddr_u *); /* authkeys.c */ extern void MD5auth_setkey (keyid_t, int, const u_char *, size_t, @@ -180,7 +182,6 @@ extern const char * k_st_flags (u_int32); extern char * statustoa (int, int); extern sockaddr_u * netof (sockaddr_u *); extern char * numtoa (u_int32); -extern char * numtohost (u_int32); extern const char * socktoa (const sockaddr_u *); extern const char * sockporttoa(const sockaddr_u *); extern u_short sock_hash (const sockaddr_u *); @@ -242,18 +243,21 @@ extern pset_tod_using set_tod_using; #ifdef OPENSSL extern void ssl_init (void); extern void ssl_check_version (void); -extern int ssl_init_done; +extern EVP_MD_CTX* digest_ctx; /* also ssl_init_done */ #define INIT_SSL() \ do { \ - if (!ssl_init_done) \ + if (NULL == digest_ctx) { \ ssl_init(); \ - } while (0) + } \ + } while (FALSE) #else /* !OPENSSL follows */ +#define ssl_check_version() do {} while (0) #define INIT_SSL() do {} while (0) #endif -extern int keytype_from_text (const char *, size_t *); -extern const char *keytype_name (int); -extern char * getpass_keytype (int); +extern int keytype_from_text (const char *text, + size_t *pdigest_len); +extern const char *keytype_name (int type); +extern char * getpass_keytype (int type); /* strl-obsd.c */ #ifndef HAVE_STRLCPY /* + */ diff --git a/include/ntp_tty.h b/include/ntp_tty.h index 6dc48b6c71f1..56f75c115907 100644 --- a/include/ntp_tty.h +++ b/include/ntp_tty.h @@ -100,4 +100,9 @@ extern int ntp_tty_ioctl(int, u_int); # endif #endif +extern int symBaud2numBaud(int symBaud); +# if 0 +extern int numBaud2symBaud(int numBaud); +#endif + #endif /* NTP_TTY_H */ diff --git a/include/ntp_types.h b/include/ntp_types.h index c3cf2c196521..6553f01b8a97 100644 --- a/include/ntp_types.h +++ b/include/ntp_types.h @@ -255,16 +255,6 @@ aligned_ptr( } /* - * Macro to use in otherwise-empty source files to comply with ANSI C - * requirement that each translation unit (source file) contain some - * declaration. This has commonly been done by declaring an unused - * global variable of type int or char. An extern reference to abs() - * serves the same purpose without bloat. We once used exit() but - * that can produce warnings on systems that declare exit() noreturn. - */ -#define NONEMPTY_TRANSLATION_UNIT extern int abs(int); - -/* * On Unix struct sock_timeval is equivalent to struct timeval. * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long * as required by Windows' socket() interface timeout argument, while diff --git a/include/ntpd.h b/include/ntpd.h index ad3e30fbb889..7de19d72de5a 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -47,6 +47,17 @@ # define DPRINTF(lvl, arg) do {} while (0) #endif +/* clear bitflag only on DEBUG builds */ +#ifdef DEBUG +# define CLEAR_BIT_IF_DEBUG(bit, flags) \ + do { \ + (flags) &= ~(bit); \ + } while (FALSE) +#else +# define CLEAR_BIT_IF_DEBUG(bit, flags) \ + do {} while (FALSE) +#endif + /* nt_clockstuff.c */ #ifdef SYS_WINNT @@ -60,15 +71,15 @@ extern char * saveconfigdir; /* ntpq saveconfig output directory */ extern void getconfig (int, char **); extern void ctl_clr_stats (void); -extern int ctlclrtrap (sockaddr_u *, struct interface *, int); +extern int ctlclrtrap (sockaddr_u *, endpt *, int); extern u_short ctlpeerstatus (struct peer *); -extern int ctlsettrap (sockaddr_u *, struct interface *, int, int); +extern int ctlsettrap (sockaddr_u *, endpt *, int, int); extern u_short ctlsysstatus (void); extern void init_control (void); extern void process_control (struct recvbuf *, int); extern void report_event (int, struct peer *, const char *); -extern int mprintf_event (int, struct peer *, const char *, ...) - NTP_PRINTF(3, 4); +extern int mprintf_event (int evcode, struct peer *p, + const char *fmt, ...) NTP_PRINTF(3, 4); /* ntp_control.c */ /* @@ -118,7 +129,9 @@ extern void enable_broadcast (endpt *, sockaddr_u *); extern void enable_multicast_if (endpt *, sockaddr_u *); extern void interface_update (interface_receiver_t, void *); #ifndef HAVE_IO_COMPLETION_PORT -extern void io_handler (void); +extern void io_handler (void); +#else +extern void WINAPI ip_interface_changed(ULONG_PTR ctx); #endif extern void init_io (void); extern void io_open_sockets (void); @@ -127,8 +140,10 @@ extern void io_setbclient (void); extern void io_unsetbclient (void); extern void io_multicast_add(sockaddr_u *); extern void io_multicast_del(sockaddr_u *); -extern void sendpkt (sockaddr_u *, struct interface *, int, struct pkt *, int); -#ifdef DEBUG +extern void sendpkt (sockaddr_u *dest, endpt * ep, int ttl, + struct pkt *pkt, int len); +extern isc_boolean_t is_linklocal(sockaddr_u *psau); +#ifdef DEBUG_TIMING extern void collect_timing (struct recvbuf *, const char *, int, l_fp *); #endif #ifdef HAVE_SIGNALED_IO @@ -141,8 +156,13 @@ extern void block_io_and_alarm (void); # define UNBLOCK_IO_AND_ALARM() do {} while (0) # define BLOCK_IO_AND_ALARM() do {} while (0) #endif -#define latoa(pif) localaddrtoa(pif) +#define eptoa(pif) localaddrtoa(pif) +#define latoa(pif) eptoa(pif) extern const char * localaddrtoa(endpt *); +#ifdef DEBUG +extern const char * iflags_str(u_int32 iflags); +#endif + /* ntp_loopfilter.c */ extern void init_loopfilter(void); @@ -198,7 +218,7 @@ extern int crypto_xmit (struct peer *, struct pkt *, struct exten *, keyid_t); extern keyid_t session_key (sockaddr_u *, sockaddr_u *, keyid_t, keyid_t, u_long); -extern int make_keylist (struct peer *, struct interface *); +extern int make_keylist (struct peer *, endpt *); extern void key_expire (struct peer *); extern void crypto_update (void); extern void crypto_update_taichange(void); @@ -226,7 +246,7 @@ extern void clock_select (void); extern void set_sys_leap (u_char); extern u_long leapsec; /* seconds to next leap (proximity class) */ -extern int leapdif; /* TAI difference step at next leap second*/ +extern int leapdif; /* TAI difference step at next leap second */ extern int sys_orphan; extern double sys_mindisp; extern double sys_maxdist; @@ -258,18 +278,27 @@ extern void reset_auth_stats(void); /* ntp_restrict.c */ extern void init_restrict (void); extern void restrictions (sockaddr_u *, r4addr *); -extern void hack_restrict (restrict_op, sockaddr_u *, sockaddr_u *, - short, u_short, u_short, u_long); -extern void restrict_source (sockaddr_u *, int, u_long); +extern int/*BOOL*/hack_restrict(restrict_op op, sockaddr_u *resaddr, + sockaddr_u *resmask, short ippeerlimit, + u_short mflags, u_short rflags, + u_int32 expire); +extern void restrict_source (sockaddr_u *addr, int/*BOOL*/ remove, + u_int32 lifetime); +#ifdef DEBUG extern void dump_restricts (void); +extern const char *resop_str (restrict_op op); +extern const char *rflags_str (u_short rflags); +extern const char *mflags_str (u_short mflags); +#endif + /* ntp_timer.c */ extern void init_timer (void); extern void reinit_timer (void); extern void timer (void); extern void timer_clr_stats (void); -extern void timer_interfacetimeout (u_long); -extern volatile int interface_interval; +extern int endpt_scan_period; /* -U option default 301s */ +extern u_long endpt_scan_timer; /* next scan current_time */ extern u_long orphwait; /* orphan wait time */ #ifdef AUTOKEY extern char *sys_hostname; /* host name */ @@ -288,17 +317,29 @@ extern void record_proto_stats (char *); extern void record_loop_stats (double, double, double, double, int); extern void record_clock_stats (sockaddr_u *, const char *); extern int mprintf_clock_stats(sockaddr_u *, const char *, ...) - NTP_PRINTF(2, 3); -extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid, int len, u_char *extra); + NTP_PRINTF(2, 3); +extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, + l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, + int leap, int version, int mode, + int stratum, int ppoll, int precision, + double root_delay, double root_dispersion, + u_int32 refid, int len, u_char *extra); extern void check_leap_file (int is_daily_check, u_int32 ntptime, const time_t * systime); extern void record_crypto_stats (sockaddr_u *, const char *); #ifdef DEBUG extern void record_timing_stats (const char *); +extern void append_flagstr(char *flagstr, size_t sz, const char *text); #endif extern char * fstostr(time_t); /* NTP timescale seconds */ /* ntpd.c */ extern void parse_cmdline_opts(int *, char ***); + +/* ntservice.c */ +#ifndef SYS_WINNT +# define ntservice_isup() do {} while (FALSE) +#endif + /* * Signals we catch for debugging. */ @@ -381,7 +422,10 @@ extern volatile u_long handler_pkts; /* number of pkts received by handler */ extern u_long io_timereset; /* time counters were reset */ /* ntp_io.c */ -extern int disable_dynamic_updates; +extern int no_periodic_scan; /* no periodic net addr scans */ +extern int scan_addrs_once; /* no net addr rescans */ +extern int nonlocal_v4_addr_up; /* should we try IPv4 pool? */ +extern int nonlocal_v6_addr_up; /* should we try IPv6 pool? */ extern u_int sys_ifnum; /* next .ifnum to assign */ extern endpt * any_interface; /* IPv4 wildcard */ extern endpt * any6_interface; /* IPv6 wildcard */ diff --git a/include/vint64ops.h b/include/vint64ops.h index 888d342781fb..50a8c4016264 100644 --- a/include/vint64ops.h +++ b/include/vint64ops.h @@ -23,6 +23,6 @@ extern vint64 subv64i32(const vint64 * lhs, int32_t rhs); extern vint64 subv64u32(const vint64 * lhs, uint32_t rhs); /* parsing. works like strtoul() or strtoull() */ -extern vint64 strtouv64(char const * begp, char const ** const endp, int base); +extern vint64 strtouv64(char * begp, char ** endp, int base); #endif /*!defined(VINT64OPS_H)*/ |