Skip to content
Snippets Groups Projects
Commit b1bb7919 authored by Matt Selsky's avatar Matt Selsky
Browse files

Eliminate unused netof6() function

parent df8223a5
No related branches found
No related tags found
Loading
Pipeline #83623913 passed
......@@ -98,7 +98,6 @@ extern const char * res_match_flags(unsigned short);
extern const char * res_access_flags(unsigned short);
extern const char * k_st_flags (uint32_t);
extern char * statustoa (int, int);
extern sockaddr_u * netof6 (sockaddr_u *);
extern const char * socktoa (const sockaddr_u *);
extern const char * socktoa_r (const sockaddr_u *sock, char *buf, size_t buflen);
extern const char * sockporttoa(const sockaddr_u *);
......
/*
* netof6 - return the net address part of an IPv6 address
* in a sockaddr_storage structure (zero out host part)
*
* except it does not really do that, it ASSumes /64
*
* returns points to a 8 position static array. Each
* position used in turn.
*
*/
#include "config.h"
#include <stdio.h>
#include <syslog.h>
#include "ntp_net.h"
#include "ntp_stdlib.h"
#include "ntp.h"
sockaddr_u *
netof6(
sockaddr_u *hostaddr
)
{
static sockaddr_u netofbuf[8];
static int next_netofbuf;
sockaddr_u * netaddr;
netaddr = &netofbuf[next_netofbuf];
next_netofbuf = (next_netofbuf + 1) % (int)COUNTOF(netofbuf);
memcpy(netaddr, hostaddr, sizeof(*netaddr));
if (IS_IPV6(netaddr))
/* assume the typical /64 subnet size */
memset(&NSRCADR6(netaddr)[8], '\0', 8);
#ifdef DEBUG
else {
msyslog(LOG_ERR, "ERR: Not IPv6, AF %d", AF(netaddr));
exit(1);
}
#endif
return netaddr;
}
......@@ -13,7 +13,6 @@ def build(ctx):
"isc_interfaceiter.c",
"isc_net.c",
"macencrypt.c",
"netof.c",
"ntp_endian.c",
"numtoa.c",
"refidsmear.c",
......
......@@ -49,7 +49,6 @@ static void RunAllTests(void)
RUN_TEST_GROUP(lfpfunc);
RUN_TEST_GROUP(lfptostr);
RUN_TEST_GROUP(macencrypt);
RUN_TEST_GROUP(netof6);
RUN_TEST_GROUP(numtoa);
RUN_TEST_GROUP(prettydate);
RUN_TEST_GROUP(random);
......
#include "config.h"
#include "ntp_stdlib.h"
#include "unity.h"
#include "unity_fixture.h"
TEST_GROUP(netof6);
TEST_SETUP(netof6) {}
TEST_TEAR_DOWN(netof6) {}
#include "sockaddrtest.h"
TEST(netof6, IPv6Address) {
/* IPv6 addresses are assumed to have 64-bit host
* and 64-bit network parts.
*/
const struct in6_addr input_address = {{{
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x13, 0x19, 0x8a, 0x2e,
0x03, 0x70, 0x73, 0x34
}}}; // 2001:0db8:85a3:08d3:1319:8a2e:0370:7334
const struct in6_addr expected_address = {{{
0x20, 0x01, 0x0d, 0xb8,
0x85, 0xa3, 0x08, 0xd3,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
}}}; // 2001:0db8:85a3:08d3:0000:0000:0000:0000
sockaddr_u input;
SET_AF(&input, AF_INET6);
SET_SOCK_ADDR6(&input, input_address);
SET_PORT(&input, 3000);
sockaddr_u expected;
SET_AF(&expected, AF_INET6);
SET_SOCK_ADDR6(&expected, expected_address);
SET_PORT(&expected, 3000);
sockaddr_u* actual = netof6(&input);
TEST_ASSERT_NOT_NULL(actual);
TEST_ASSERT_TRUE(IsEqualS(&expected, actual));
}
TEST_GROUP_RUNNER(netof6) {
RUN_TEST_CASE(netof6, IPv6Address);
}
......@@ -43,7 +43,6 @@ def build(ctx):
"libntp/lfpfunc.c",
"libntp/lfptostr.c",
"libntp/macencrypt.c",
"libntp/netof.c",
"libntp/numtoa.c",
"libntp/prettydate.c",
"libntp/refidsmear.c",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment