Correct unit tests for sntp offset_calculation() arg change.
bk: 4d048824jcvkNGaNeqf0qvlEPvBKDw
* send packet and bump counters
*/
if (res_authenticate && sys_authenticate) {
- int maclen;
-
maclen = authencrypt(res_keyid, (u_int32 *)&rpkt,
CTL_HEADER_LEN);
sendpkt(rmt_addr, lcl_inter, -2, (void *)&rpkt,
/* Define a function to create the server associations */
void create_server_associations(void)
{
- int i;
- for (i = 0;i < simulation.num_of_servers;++i) {
- printf("%s\n", stoa(simulation.servers[i].addr));
- if (peer_config(simulation.servers[i].addr,
- NULL,
- ANY_INTERFACE_CHOOSE(simulation.servers[i].addr),
- MODE_CLIENT,
- NTP_VERSION,
- NTP_MINDPOLL,
- NTP_MAXDPOLL,
- 0, /* peerflags */
- 0, /* ttl */
- 0, /* peerkey */
- (u_char *)"*" /* peerkeystr */) == 0) {
- fprintf(stderr, "ERROR!! Could not create association for: %s",
- stoa(simulation.servers[i].addr));
+ int i;
+
+ for (i = 0; i < simulation.num_of_servers; ++i) {
+ printf("%s\n", stoa(simulation.servers[i].addr));
+ if (peer_config(simulation.servers[i].addr,
+ NULL,
+ ANY_INTERFACE_CHOOSE(simulation.servers[i].addr),
+ MODE_CLIENT,
+ NTP_VERSION,
+ NTP_MINDPOLL,
+ NTP_MAXDPOLL,
+ 0, /* peerflags */
+ 0, /* ttl */
+ 0, /* peerkey */
+ NULL /* group ident */) == 0) {
+ fprintf(stderr,
+ "ERROR!! Could not create association for: %s",
+ stoa(simulation.servers[i].addr));
+ }
}
- }
}
tmp.l_uf = 0UL;
HTONL_FP(&tmp, &rpkt.xmt);
- // T4 - Destination timestamp
+ // T4 - Destination timestamp as standard timeval
tmp.l_ui = 1000000001UL;
tmp.l_uf = 0UL;
timeval dst;
TSTOTV(&tmp, &dst);
+ dst.tv_sec -= JAN_1970;
double offset, precision, root_disp;
offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &root_disp);
tmp.l_uf = 2147483648UL;
HTONL_FP(&tmp, &rpkt.xmt);
- // T4 - Destination timestamp
+ // T4 - Destination timestamp as standard timeval
tmp.l_ui = 1000000003UL;
tmp.l_uf = 0UL;
timeval dst;
TSTOTV(&tmp, &dst);
+ dst.tv_sec -= JAN_1970;
double offset, precision, root_disp;
offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &root_disp);
sockaddr_u input;
addrinfo inputA;
+ memset(&input, 0, sizeof(input));
input.sa6.sin6_family = AF_INET6;
input.sa6.sin6_addr = address;
EXPECT_STREQ(expected, ss_to_str(&input));
TEST_F(utilitiesTest, SetLiVnMode1) {
pkt expected;
expected.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
- NTP_VERSION,
- MODE_SERVER);
+ NTP_VERSION,
+ MODE_SERVER);
pkt actual;
set_li_vn_mode(&actual, LEAP_NOWARNING, NTP_VERSION,
TEST_F(socktoaTest, IPv6AddressWithPort) {
const struct in6_addr address = {
0x20, 0x01, 0x0d, 0xb8,
- 0x85, 0xa3, 0x08, 0xd3,
- 0x13, 0x19, 0x8a, 0x2e,
- 0x03, 0x70, 0x73, 0x34
+ 0x85, 0xa3, 0x08, 0xd3,
+ 0x13, 0x19, 0x8a, 0x2e,
+ 0x03, 0x70, 0x73, 0x34
};
const char* expected =
"[2001:db8:85a3:8d3:1319:8a2e:370:7334]:123";
sockaddr_u input;
- input.sa6.sin6_family = AF_INET6;
- input.sa6.sin6_addr = address;
+ memset(&input, 0, sizeof(input));
+ AF(&input) = AF_INET6;
+ SET_ADDR6N(&input, address);
+ SET_PORT(&input, 123);
+
+ EXPECT_STREQ(expected, socktoa(&input));
+ EXPECT_STREQ(expected_port, sockporttoa(&input));
+}
+
+#ifdef ISC_PLATFORM_HAVESCOPEID
+TEST_F(socktoaTest, ScopedIPv6AddressWithPort) {
+ const struct in6_addr address = {
+ 0xfe, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x12, 0x3f, 0xff,
+ 0xfe, 0x29, 0xff, 0xfa
+ };
+
+ const char* expected =
+ "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));
+ AF(&input) = AF_INET6;
+ SET_ADDR6N(&input, address);
SET_PORT(&input, 123);
+ SCOPE_VAR(&input) = 5;
EXPECT_STREQ(expected, socktoa(&input));
EXPECT_STREQ(expected_port, sockporttoa(&input));
}
+#endif /* ISC_PLATFORM_HAVESCOPEID */
TEST_F(socktoaTest, HashEqual) {
sockaddr_u input1 = CreateSockaddr4("192.00.2.2", 123);