[Bug 3595] pollskewlist documentation uses | when it shouldn't.
[Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when disconnected
[Bug 3774] mode 6 packets corrupted in rawstats file
[Bug 3793] Wrong variable type passed to record_raw_stats().
Remove inappropriate copyright notice in Windows messages.mc and messages.h
bk: 63f73826bn3P4-gBfVNIZJhrfdFOJQ
-
---
+* [Bug 3595] pollskewlist documentation uses | when it shouldn't.
+ - ntp.conf manual page and miscopt.html corrections. <hart@ntp.org>
+* [Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when
+ disconnected, breaking ntpq and ntpdc. <hart@ntp.org>
+* [Bug 3774] mode 6 packets corrupted in rawstats file <hart@ntp.org>
+ - Reported by Edward McGuire, fix identified by <wei6410@sina.com>.
+* [Bug 3793] Wrong variable type passed to record_raw_stats(). <hart@ntp.org>
+ - Report and patch by Yuezhen LUAN <wei6410@sina.com>.
* [Bug 3640] document "discard monitor" and fix the code. <hart@ntp.org>
- fixed bug identified by Edward McGuire <perlinger@ntp.org>
* [Bug 3660] Revert 4.2.8p15 change to manycast. <hart@ntp.org>
<h3>Copyright Notice</h3>
<img src="pic/sheepb.jpg" alt="jpg" align="left"> "Clone me," says Dolly sheepishly.
<p>Last update:
- <!-- #BeginDate format:En2m -->4-Feb-2020 23:47<!-- #EndDate -->
+ <!-- #BeginDate format:En2m -->22-Feb-2023 22:35<!-- #EndDate -->
UTC</p>
<br clear="left">
</p>
<pre>
***********************************************************************
* *
-* Copyright (c) Network Time Foundation 2011-2020 *
+* Copyright (c) Network Time Foundation 2011-2023 *
* *
* All Rights Reserved *
* *
For the JJY driver (type 40 mode 100 - 180), the argument is one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number, which can contain other modem control codes as well.</dd>
<dt id="pollskewlist"
- ><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>value</i><tt>
- | </tt><i>value</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>value</i><tt>
- | </tt><i>value</i><tt>]</tt></dt>
+ ><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>early late</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>early late</i><tt>]</tt></dt>
<dd>Enable skewing of our poll requests to our servers.
<i>poll</i>
is a number between 3 and 17 inclusive, identifying a specific poll interval.
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
-The first number specifies how early the poll may start,
-while
-the second number specifies how late the poll may be delayed.
+<i>early</i> specifies how early the poll may start, while
+<i>late</i> specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.</dd>
<dt id="reset"><tt>reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]</tt></dt>
<dd>Reset one or more groups of counters maintained by ntpd and exposed by <tt>ntpq</tt> and <tt>ntpdc</tt>.</dd>
extern vint64 subv64u32(const vint64 * lhs, uint32_t rhs);
/* parsing. works like strtoul() or strtoull() */
-extern vint64 strtouv64(const char * begp, char ** endp, int base);
+extern vint64 strtouv64(const char * begp, const char ** endp, int base);
#endif /*!defined(VINT64OPS_H)*/
/*
* We can't just hash the whole thing because there are hidden
* fields in sockaddr_in6 that might be filled in by recvfrom(),
- * so just use the family, port and address.
+ * so just use the family and address.
*/
pch = (const void *)&AF(addr);
hashVal = 37 * hashVal + *pch;
#include "ntp_fp.h"
#include "vint64ops.h"
-/* ---------------------------------------------------------------------
- * GCC is rather sticky with its 'const' attribute. We have to do it more
- * explicit than with a cast if we want to get rid of a CONST qualifier.
- * Greetings from the PASCAL world, where casting was only possible via
- * untagged unions...
- */
-static inline void*
-noconst(
- const void* ptr
- )
-{
- union {
- const void * cp;
- void * vp;
- } tmp;
- tmp.cp = ptr;
- return tmp.vp;
-}
-
/* -------------------------------------------------------------------------*/
vint64
strtouv64(
- const char * begp,
- char ** endp,
- int base
+ const char *begp,
+ const char **endp,
+ int base
)
{
vint64 res;
if (!num)
errno = EINVAL;
if (endp)
- *endp = (char*)noconst(src);
+ *endp = (const char *)src;
if (sig)
M_NEG(res.D_s.hi, res.D_s.lo);
return res;
.It Xo Cm pollskewlist
.Oo
.Ar poll
-.Ar value | value
+.Ar early late
.Oc
.Ar ...
.Oo
.Cm default
-.Ar value | value
+.Ar early late
.Oc
.Xc
Enable skewing of our poll requests to our servers.
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
-The first number specifies how early the poll may start,
+Ar early
+specifies how early the poll may start,
while
-the second number specifies how late the poll may be delayed.
+Ar late
+specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
PKT_MODE(pkt->li_vn_mode),
pkt->stratum,
pkt->ppoll, pkt->precision,
- pkt->rootdelay, pkt->rootdisp, pkt->refid,
+ FPTOD(NTOHS_FP(pkt->rootdelay)),
+ FPTOD(NTOHS_FP(pkt->rootdisp)), pkt->refid,
len - MIN_V4_PKT_LEN, (u_char *)&pkt->exten);
return;
nts.l_uf = (unsigned long)(ticks * (unsigned long)(sys_tick * FRAC));
}
DPRINTF(4, ("fetch_timestamp: system bintime network time stamp: %ld.%09lu\n",
- pbt.sec, (unsigned long)((nts.l_uf / FRAC) * 1e9)));
+ (long)pbt.sec, (u_long)((nts.l_uf / FRAC) * 1e9)));
}
break;
#endif /* HAVE_BINTIME */
if (!stats_control)
return;
+ /*
+ * Mode 6 and mode 7 packets do not have the format of normal
+ * NTP packets and will log garbage. So don't. [Bug 3774]
+ */
+ if (MODE_CONTROL == mode || MODE_PRIVATE == mode)
+ return;
+
get_systime(&now);
filegen_setup(&rawstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
#endif
a_info = getaddrinfo(hname, service, &hints, &ai);
}
- /* Some older implementations don't like AI_ADDRCONFIG. */
- if (a_info == EAI_BADFLAGS) {
+ /*
+ * Some older implementations don't like AI_ADDRCONFIG.
+ * Some versions of Windows return WSANO_DATA when there is no
+ * global address and AI_ADDRCONFIG is used. AI_ADDRCONFIG
+ * is useful to short-circuit DNS lookups for IP protocols
+ * for which the host has no local addresses. Windows
+ * unfortunately instead interprets AI_ADDRCONFIG to relate
+ * to off-host connectivity and so fails lookup when
+ * localhost works.
+ * To further muddy matters, some versions of WS2tcpip.h
+ * comment out #define EAI_NODATA WSANODATA claiming it
+ * was removed from RFC 2553bis and mentioning a need to
+ * contact the authors to find out why, but "helpfully"
+ * #defines EAI_NODATA EAI_NONAME (== WSAHOST_NOT_FOUND)
+ * So we get more ugly platform-specific workarounds.
+ */
+ if (
+#if defined(WIN32)
+ WSANO_DATA == a_info || EAI_NONAME == a_info ||
+#endif
+ EAI_BADFLAGS == a_info) {
hints.ai_flags = AI_CANONNAME;
a_info = getaddrinfo(hname, service, &hints, &ai);
}
if (!dogetassoc(fp))
return;
- for (u = 0; u < numhosts; u++) {
- if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
- name_or_num = nntohost(&netnum);
- sl = strlen(name_or_num);
- maxhostlen = max(maxhostlen, sl);
+ if (numhosts > 1) {
+ for (u = 0; u < numhosts; u++) {
+ if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
+ name_or_num = nntohost(&netnum);
+ sl = strlen(name_or_num);
+ maxhostlen = max(maxhostlen, sl);
+ }
}
- }
- if (numhosts > 1)
xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
"server (local)");
+ }
xprintf(fp,
" remote refid st t when poll reach delay offset jitter\n");
if (numhosts > 1)
if (!dogetassoc(fp))
return;
- for (u = 0; u < numhosts; u++) {
- if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
- name_or_num = nntohost(&netnum);
- sl = strlen(name_or_num);
- maxhostlen = max(maxhostlen, sl);
+ if (numhosts > 1) {
+ for (u = 0; u < numhosts; u++) {
+ if (getnetnum(chosts[u].name, &netnum, fullname, af)) {
+ name_or_num = nntohost(&netnum);
+ sl = strlen(name_or_num);
+ maxhostlen = max(maxhostlen, sl);
+ }
}
- }
- if (numhosts > 1)
xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
"server (local)");
+ }
xprintf(fp,
" remote refid assid st t when poll reach delay offset jitter\n");
if (numhosts > 1)
if (!dogetassoc(fp))
return;
- for (i = 0; i < numhosts; ++i) {
- if (getnetnum(chosts[i].name, &netnum, fullname, af))
- if (strlen(fullname) > maxhostlen)
- maxhostlen = strlen(fullname);
+ if (numhosts > 1) {
+ for (i = 0; i < numhosts; ++i) {
+ if (getnetnum(chosts[i].name, &netnum, fullname, af)) {
+ maxhostlen = max(maxhostlen, strlen(fullname));
+ }
+ xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
+ "server");
+ }
}
- if (numhosts > 1)
- xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
- "server");
xprintf(fp,
" remote local st t when poll reach delay offset disp\n");
if (numhosts > 1)
a_info = getaddrinfo(hname, svc, &hints, &ai);
}
#ifdef AI_ADDRCONFIG
- /* Some older implementations don't like AI_ADDRCONFIG. */
- if (a_info == EAI_BADFLAGS) {
+ /*
+ * Some older implementations don't like AI_ADDRCONFIG.
+ * Some versions of Windows return WSANO_DATA when there is no
+ * global address and AI_ADDRCONFIG is used. AI_ADDRCONFIG
+ * is useful to short-circuit DNS lookups for IP protocols
+ * for which the host has no local addresses. Windows
+ * unfortunately instead interprets AI_ADDRCONFIG to relate
+ * to off-host connectivity and so fails lookup when
+ * localhost works.
+ * To further muddy matters, some versions of WS2tcpip.h
+ * comment out #define EAI_NODATA WSANODATA claiming it
+ * was removed from RFC 2553bis and mentioning a need to
+ * contact the authors to find out why, but "helpfully"
+ * #defines EAI_NODATA EAI_NONAME (== WSAHOST_NOT_FOUND)
+ * So we get more ugly platform-specific workarounds.
+ */
+ if (
+#if defined(WIN32)
+ WSANO_DATA == a_info || EAI_NONAME == a_info ||
+#endif
+ EAI_BADFLAGS == a_info) {
hints.ai_flags &= ~AI_ADDRCONFIG;
a_info = getaddrinfo(hname, svc, &hints, &ai);
}
struct hstate {
char *list;
- const char **seen;
+ char const **seen;
int idx;
};
return;
n = (seen - hstate->seen) + 2;
- hstate->seen = erealloc(hstate->seen, n * sizeof(*seen));
+ hstate->seen = erealloc((void *)hstate->seen, n * sizeof(*seen));
hstate->seen[n-2] = name;
hstate->seen[n-1] = NULL;
struct hstate hstate = { NULL, NULL, K_PER_LINE+1 };
/* replace calloc(1, sizeof(const char *)) */
- hstate.seen = (const char **)emalloc_zero(sizeof(const char *));
+ hstate.seen = emalloc_zero(sizeof(const char*));
INIT_SSL();
EVP_MD_do_all_sorted(list_md_fn, &hstate);
list = hstate.list;
- free(hstate.seen);
+ free((void *)hstate.seen);
list = insert_cmac(list); /* Insert CMAC into SSL digests list */
/*
- Microsoft Developer Support
- Copyright (c) 1992 Microsoft Corporation
-
- This file contains the message definitions for the Win32
- syslog support messages for the nntp firewall
--------------------------------------------------------------------------
- HEADER SECTION
-
- The header section defines names and language identifiers for use
- by the message definitions later in this file. The MessageIdTypedef,
- SeverityNames, FacilityNames, and LanguageNames keywords are
- optional and not required.
-
-
-
- The MessageIdTypedef keyword gives a typedef name that is used in a
- type cast for each message code in the generated include file. Each
- message code appears in the include file with the format: #define
- name ((type) 0xnnnnnnnn) The default value for type is empty, and no
- type cast is generated. It is the programmer's responsibility to
- specify a typedef statement in the application source code to define
- the type. The type used in the typedef must be large enough to
- accomodate the entire 32-bit message code.
-
-
-
- The SeverityNames keyword defines the set of names that are allowed
- as the value of the Severity keyword in the message definition. The
- set is delimited by left and right parentheses. Associated with each
- severity name is a number that, when shifted left by 30, gives the
- bit pattern to logical-OR with the Facility value and MessageId
- value to form the full 32-bit message code. The default value of
- this keyword is:
-
- SeverityNames=(
- Success=0x0
- Informational=0x1
- Warning=0x2
- Error=0x3
- )
-
- Severity values occupy the high two bits of a 32-bit message code.
- Any severity value that does not fit in two bits is an error. The
- severity codes can be given symbolic names by following each value
- with :name
-
-
-FacilityNames=(System=0x0:FACILITY_SYSTEM
- Runtime=0x2:FACILITY_RUNTIME
- Stubs=0x3:FACILITY_STUBS
- Io=0x4:FACILITY_IO_ERROR_CODE
- )
-
- The FacilityNames keyword defines the set of names that are allowed
- as the value of the Facility keyword in the message definition. The
- set is delimited by left and right parentheses. Associated with each
- facility name is a number that, when shift it left by 16 bits, gives
- the bit pattern to logical-OR with the Severity value and MessageId
- value to form the full 32-bit message code. The default value of
- this keyword is:
-
- FacilityNames=(
- System=0x0FF
- Application=0xFFF
- )
-
- Facility codes occupy the low order 12 bits of the high order
- 16-bits of a 32-bit message code. Any facility code that does not
- fit in 12 bits is an error. This allows for 4,096 facility codes.
- The first 256 codes are reserved for use by the system software. The
- facility codes can be given symbolic names by following each value
- with :name
-
-
- The LanguageNames keyword defines the set of names that are allowed
- as the value of the Language keyword in the message definition. The
- set is delimited by left and right parentheses. Associated with each
- language name is a number and a file name that are used to name the
- generated resource file that contains the messages for that
- language. The number corresponds to the language identifier to use
- in the resource table. The number is separated from the file name
- with a colon. The initial value of LanguageNames is:
-
- LanguageNames=(English=1:MSG00001)
-
- Any new names in the source file which don't override the built-in
- names are added to the list of valid languages. This allows an
- application to support private languages with descriptive names.
-
-
--------------------------------------------------------------------------
- MESSAGE DEFINITION SECTION
-
- Following the header section is the body of the Message Compiler
- source file. The body consists of zero or more message definitions.
- Each message definition begins with one or more of the following
- statements:
-
- MessageId = [number|+number]
- Severity = severity_name
- Facility = facility_name
- SymbolicName = name
-
- The MessageId statement marks the beginning of the message
- definition. A MessageID statement is required for each message,
- although the value is optional. If no value is specified, the value
- used is the previous value for the facility plus one. If the value
- is specified as +number then the value used is the previous value
- for the facility, plus the number after the plus sign. Otherwise, if
- a numeric value is given, that value is used. Any MessageId value
- that does not fit in 16 bits is an error.
-
- The Severity and Facility statements are optional. These statements
- specify additional bits to OR into the final 32-bit message code. If
- not specified they default to the value last specified for a message
- definition. The initial values prior to processing the first message
- definition are:
-
- Severity=Success
- Facility=Application
-
- The value associated with Severity and Facility must match one of
- the names given in the FacilityNames and SeverityNames statements in
- the header section. The SymbolicName statement allows you to
- associate a C/C++ symbolic constant with the final 32-bit message
- code.
+ Boilerplate Microsoft copyright statement previously here removed because
+ the code does not posess "at least some minimal degree of creativity".
+
+ https://www.copyright.gov/comp3/chap300/ch300-copyrightable-authorship.pdf
+ Section 308 The Originality Requirement
*/
//
// Values are 32 bit values laid out as follows:
//
// Define the severity codes
//
-#define STATUS_SEVERITY_SUCCESS 0x0
-#define STATUS_SEVERITY_INFORMATIONAL 0x1
-#define STATUS_SEVERITY_WARNING 0x2
-#define STATUS_SEVERITY_ERROR 0x3
//
//
// %1
//
-#define NTP_ERROR ((DWORD)0xC0000001L)
+#define NTP_ERROR 0xC0000001L
//
// MessageId: NTP_WARNING
// %1
//
//
-#define NTP_WARNING ((DWORD)0x80000002L)
+#define NTP_WARNING 0x80000002L
//
// MessageId: NTP_INFO
//
//
//
-#define NTP_INFO ((DWORD)0x40000003L)
+#define NTP_INFO 0x40000003L
; /*
-; Microsoft Developer Support
-; Copyright (c) 1992 Microsoft Corporation
-;
-; This file contains the message definitions for the Win32
-; syslog support messages for the nntp firewall
-
-;-------------------------------------------------------------------------
-; HEADER SECTION
-;
-; The header section defines names and language identifiers for use
-; by the message definitions later in this file. The MessageIdTypedef,
-; SeverityNames, FacilityNames, and LanguageNames keywords are
-; optional and not required.
-;
-;
-MessageIdTypedef=DWORD
-;
-; The MessageIdTypedef keyword gives a typedef name that is used in a
-; type cast for each message code in the generated include file. Each
-; message code appears in the include file with the format: #define
-; name ((type) 0xnnnnnnnn) The default value for type is empty, and no
-; type cast is generated. It is the programmer's responsibility to
-; specify a typedef statement in the application source code to define
-; the type. The type used in the typedef must be large enough to
-; accomodate the entire 32-bit message code.
-;
-;
-SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
- Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
- Warning=0x2:STATUS_SEVERITY_WARNING
- Error=0x3:STATUS_SEVERITY_ERROR
- )
-;
-; The SeverityNames keyword defines the set of names that are allowed
-; as the value of the Severity keyword in the message definition. The
-; set is delimited by left and right parentheses. Associated with each
-; severity name is a number that, when shifted left by 30, gives the
-; bit pattern to logical-OR with the Facility value and MessageId
-; value to form the full 32-bit message code. The default value of
-; this keyword is:
-;
-; SeverityNames=(
-; Success=0x0
-; Informational=0x1
-; Warning=0x2
-; Error=0x3
-; )
-;
-; Severity values occupy the high two bits of a 32-bit message code.
-; Any severity value that does not fit in two bits is an error. The
-; severity codes can be given symbolic names by following each value
-; with :name
-;
-;
-;FacilityNames=(System=0x0:FACILITY_SYSTEM
-; Runtime=0x2:FACILITY_RUNTIME
-; Stubs=0x3:FACILITY_STUBS
-; Io=0x4:FACILITY_IO_ERROR_CODE
-; )
-;
-; The FacilityNames keyword defines the set of names that are allowed
-; as the value of the Facility keyword in the message definition. The
-; set is delimited by left and right parentheses. Associated with each
-; facility name is a number that, when shift it left by 16 bits, gives
-; the bit pattern to logical-OR with the Severity value and MessageId
-; value to form the full 32-bit message code. The default value of
-; this keyword is:
-;
-; FacilityNames=(
-; System=0x0FF
-; Application=0xFFF
-; )
-;
-; Facility codes occupy the low order 12 bits of the high order
-; 16-bits of a 32-bit message code. Any facility code that does not
-; fit in 12 bits is an error. This allows for 4,096 facility codes.
-; The first 256 codes are reserved for use by the system software. The
-; facility codes can be given symbolic names by following each value
-; with :name
-;
-;
-; The LanguageNames keyword defines the set of names that are allowed
-; as the value of the Language keyword in the message definition. The
-; set is delimited by left and right parentheses. Associated with each
-; language name is a number and a file name that are used to name the
-; generated resource file that contains the messages for that
-; language. The number corresponds to the language identifier to use
-; in the resource table. The number is separated from the file name
-; with a colon. The initial value of LanguageNames is:
-;
-; LanguageNames=(English=1:MSG00001)
-;
-; Any new names in the source file which don't override the built-in
-; names are added to the list of valid languages. This allows an
-; application to support private languages with descriptive names.
-;
-;
-;-------------------------------------------------------------------------
-; MESSAGE DEFINITION SECTION
-;
-; Following the header section is the body of the Message Compiler
-; source file. The body consists of zero or more message definitions.
-; Each message definition begins with one or more of the following
-; statements:
-;
-; MessageId = [number|+number]
-; Severity = severity_name
-; Facility = facility_name
-; SymbolicName = name
-;
-; The MessageId statement marks the beginning of the message
-; definition. A MessageID statement is required for each message,
-; although the value is optional. If no value is specified, the value
-; used is the previous value for the facility plus one. If the value
-; is specified as +number then the value used is the previous value
-; for the facility, plus the number after the plus sign. Otherwise, if
-; a numeric value is given, that value is used. Any MessageId value
-; that does not fit in 16 bits is an error.
-;
-; The Severity and Facility statements are optional. These statements
-; specify additional bits to OR into the final 32-bit message code. If
-; not specified they default to the value last specified for a message
-; definition. The initial values prior to processing the first message
-; definition are:
-;
-; Severity=Success
-; Facility=Application
-;
-; The value associated with Severity and Facility must match one of
-; the names given in the FacilityNames and SeverityNames statements in
-; the header section. The SymbolicName statement allows you to
-; associate a C/C++ symbolic constant with the final 32-bit message
-; code.
+; Boilerplate Microsoft copyright statement previously here removed because
+; the code does not posess "at least some minimal degree of creativity".
+;
+; https://www.copyright.gov/comp3/chap300/ch300-copyrightable-authorship.pdf
+; Section 308 The Originality Requirement
; */
MessageId=0x1
/* -*- Mode: Text -*- */
copyright = {
- date = "1992-2020";
+ date = "1992-2023";
owner = "The University of Delaware and Network Time Foundation";
eaddr = "http://bugs.ntp.org, bugs@ntp.org";
type = ntp;
{
const char *str = "192.0.2.1";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa4.sin_family = AF_INET;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET;
expected.sa4.sin_addr.s_addr = inet_addr("192.0.2.1");
SET_PORT(&expected, NTP_PORT);
{
const char *str = "192.0.2.2:2000";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa4.sin_family = AF_INET;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET;
expected.sa4.sin_addr.s_addr = inet_addr("192.0.2.2");
SET_PORT(&expected, 2000);
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
- const char *str1 = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";
- const char *str2 = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334]";
+ const char *str1 = "2001:db8:85a3:08d3:1319:8a2e:0370:7334";
+ const char *str2 = "[2001:0db8:85a3:8d3:1319:8a2e:370:7334]";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
SET_PORT(&expected, NTP_PORT);
TEST_ASSERT_TRUE(decodenetnum(str1, &actual));
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
const char *str = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334]:3000";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
SET_PORT(&expected, 3000);
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
- const char *str1 = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334%42";
+ const char *str1 = "2001:db8:85a3:8d3:1319:8a2e:370:7334%42";
const char *str2 = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334%42]";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
- expected.sa6.sin6_scope_id = 42;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
+ SET_SCOPE(&expected, 42);
SET_PORT(&expected, NTP_PORT);
TEST_ASSERT_TRUE(decodenetnum(str1, &actual));
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
- const char *str = "[2001:0db8:85a3:08d3:1319:8a2e:0370:7334%42]:3000";
+ const char *str = "[2001:db8:85a3:08d3:1319:8a2e:370:7334%42]:3000";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa6.sin6_family = AF_INET6;
- expected.sa6.sin6_addr = address;
- expected.sa6.sin6_scope_id = 42;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET6;
+ SET_ADDR6N(&expected, address);
+ SET_SCOPE(&expected, 42);
SET_PORT(&expected, 3000);
TEST_ASSERT_TRUE(decodenetnum(str, &actual));
*/
const char *str = "192.0.2.1:a700";
sockaddr_u actual;
-
sockaddr_u expected;
- memset(&expected, 0, sizeof(expected));
- expected.sa4.sin_family = AF_INET;
+
+ ZERO(expected);
+ AF(&expected) = AF_INET;
expected.sa4.sin_addr.s_addr = inet_addr("192.0.2.1");
SET_PORT(&expected, NTP_PORT);
const char *str =
"loremipsumloremipsumloremipsumloremipsumloremipsum"
"loremipsumloremipsumloremipsumloremipsum";
-
sockaddr_u actual;
+
TEST_ASSERT_FALSE(decodenetnum(str, &actual));
}
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
+ const struct in6_addr address = { { {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
+ 0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
- };
+ } } };
const char* expected =
"2001:db8:85a3:8d3:1319:8a2e:370:7334";
const char* expected_port =
"[2001:db8:85a3:8d3:1319:8a2e:370:7334]:123";
-
sockaddr_u input;
- memset(&input, 0, sizeof(input));
+
+ ZERO(input);
AF(&input) = AF_INET6;
SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
test_ScopedIPv6AddressWithPort(void)
{
#if defined(ISC_PLATFORM_HAVESCOPEID) && defined(WANT_IPV6)
-
+
const struct in6_addr address = { { {
0xfe, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
"fe80::212:3fff:fe29:fffa%5";
const char* expected_port =
"[fe80::212:3fff:fe29:fffa%5]:123";
-
sockaddr_u input;
- memset(&input, 0, sizeof(input));
+
+ ZERO(input);
AF(&input) = AF_INET6;
SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
{
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(WANT_IPV6)
- const struct in6_addr address = {
- 0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
- 0x13, 0x19, 0x8a, 0x2e,
- 0x03, 0x70, 0x73, 0x34
- };
+ const struct in6_addr address = { { {
+ 0xfe, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x12, 0x3f, 0xff,
+ 0xfe, 0x29, 0xff, 0xfa
+ } } };
sockaddr_u input1, input2;