-/* $OpenBSD: client.c,v 1.117 2022/03/24 07:37:19 otto Exp $ */
+/* $OpenBSD: client.c,v 1.118 2023/12/20 15:36:36 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
interval = error_interval();
set_next(p, interval);
log_info("reply from %s: not synced (%s), next query %llds",
- log_sockaddr((struct sockaddr *)&p->addr->ss), s,
- (long long)interval);
+ log_ntp_addr(p->addr), s, (long long)interval);
return (0);
}
if (!p->trusted && conf->constraint_median != 0 &&
(constraint_check(T2) != 0 || constraint_check(T3) != 0)) {
log_info("reply from %s: constraint check failed",
- log_sockaddr((struct sockaddr *)&p->addr->ss));
+ log_ntp_addr(p->addr));
set_next(p, error_interval());
return (0);
}
set_next(p, interval);
log_info("reply from %s: negative delay %fs, "
"next query %llds",
- log_sockaddr((struct sockaddr *)&p->addr->ss),
+ log_ntp_addr(p->addr),
p->reply[p->shift].delay, (long long)interval);
return (0);
}
if (p->trustlevel < TRUSTLEVEL_BADPEER &&
p->trustlevel + 1 >= TRUSTLEVEL_BADPEER)
log_info("peer %s now valid",
- log_sockaddr((struct sockaddr *)&p->addr->ss));
+ log_ntp_addr(p->addr));
p->trustlevel++;
}
interval = scale_interval(INTERVAL_QUERY_NORMAL);
log_debug("reply from %s: offset %f delay %f, "
- "next query %llds",
- log_sockaddr((struct sockaddr *)&p->addr->ss),
- offset, delay,
- (long long)interval);
+ "next query %llds", log_ntp_addr(p->addr),
+ offset, delay, (long long)interval);
set_next(p, interval);
{
const char *address;
- address = log_sockaddr((struct sockaddr *)&peer->addr->ss);
+ address = log_ntp_addr(peer->addr);
if (peer->lasterror == error) {
log_debug("%s %s: %s", operation, address, strerror(error));
return;
-/* $OpenBSD: constraint.c,v 1.55 2023/12/06 15:51:53 otto Exp $ */
+/* $OpenBSD: constraint.c,v 1.56 2023/12/20 15:36:36 otto Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
strsignal(sig) : "unknown";
log_warnx("constraint %s; "
"terminated with signal %d (%s)",
- log_sockaddr((struct sockaddr *)
- &cstr->addr->ss), sig, signame);
+ log_ntp_addr(cstr->addr), sig, signame);
}
fail = 1;
}
gettime_from_timeval(&tv[1]);
log_info("constraint reply from %s: offset %f",
- log_sockaddr((struct sockaddr *)&cstr->addr->ss),
+ log_ntp_addr(cstr->addr),
offset);
cstr->state = STATE_REPLY_RECEIVED;
if (fail) {
log_debug("no constraint reply from %s"
" received in time, next query %ds",
- log_sockaddr((struct sockaddr *)
- &cstr->addr->ss), CONSTRAINT_SCAN_INTERVAL);
+ log_ntp_addr(cstr->addr),
+ CONSTRAINT_SCAN_INTERVAL);
cnt = 0;
TAILQ_FOREACH(tmp, &conf->constraints, entry)
-/* $OpenBSD: control.c,v 1.19 2021/04/21 09:38:11 bluhm Exp $ */
+/* $OpenBSD: control.c,v 1.20 2023/12/20 15:36:36 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
now = getmonotime();
if (p->addr) {
- a = log_sockaddr((struct sockaddr *)&p->addr->ss);
+ a = log_ntp_addr(p->addr);
if (p->addr->notauth)
auth = " (non-dnssec lookup)";
}
-/* $OpenBSD: ntp.c,v 1.171 2023/12/06 15:51:53 otto Exp $ */
+/* $OpenBSD: ntp.c,v 1.172 2023/12/20 15:36:36 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
if (p->deadline > 0 && p->deadline <= getmonotime()) {
timeout = 300;
log_debug("no reply from %s received in time, "
- "next query %ds", log_sockaddr(
- (struct sockaddr *)&p->addr->ss), timeout);
+ "next query %ds", log_ntp_addr( p->addr),
+ timeout);
if (p->trustlevel >= TRUSTLEVEL_BADPEER &&
(p->trustlevel /= 2) < TRUSTLEVEL_BADPEER)
log_info("peer %s now invalid",
- log_sockaddr(
- (struct sockaddr *)&p->addr->ss));
+ log_ntp_addr(p->addr));
if (client_nextaddr(p) == 1) {
peer_addr_head_clear(p);
client_nextaddr(p);
}
if (p->senderrors > MAX_SEND_ERRORS) {
log_debug("failed to send query to %s, "
- "next query %ds", log_sockaddr(
- (struct sockaddr *)&p->addr->ss),
+ "next query %ds", log_ntp_addr(p->addr),
INTERVAL_QUERY_PATHETIC);
p->senderrors = 0;
if (client_nextaddr(p) == 1) {
conf->automatic)) {
case -1:
log_debug("no reply from %s "
- "received", log_sockaddr(
- (struct sockaddr *) &pp->addr->ss));
+ "received", log_ntp_addr(pp->addr));
if (pp->trustlevel >=
TRUSTLEVEL_BADPEER &&
(pp->trustlevel /= 2) <
TRUSTLEVEL_BADPEER)
log_info("peer %s now invalid",
- log_sockaddr(
- (struct sockaddr *)
- &pp->addr->ss));
+ log_ntp_addr(pp->addr));
break;
case 0: /* invalid replies are ignored */
break;
continue;
}
log_debug("Adding address %s to %s",
- log_sockaddr((struct sockaddr *)
- &h->ss), peer->addr_head.name);
+ log_ntp_addr(h), peer->addr_head.name);
npeer = new_peer();
npeer->weight = peer->weight;
npeer->query_addr4 = peer->query_addr4;
-/* $OpenBSD: ntpd.h,v 1.152 2022/11/27 13:19:00 otto Exp $ */
+/* $OpenBSD: ntpd.h,v 1.153 2023/12/20 15:36:36 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
struct s_fixedpt d_to_sfp(double);
char *print_rtable(int);
const char *log_sockaddr(struct sockaddr *);
+const char *log_ntp_addr(struct ntp_addr *);
pid_t start_child(char *, int, int, char **);
int sanitize_argv(int *, char ***);
-/* $OpenBSD: util.c,v 1.27 2023/11/19 10:41:25 claudio Exp $ */
+/* $OpenBSD: util.c,v 1.28 2023/12/20 15:36:36 otto Exp $ */
/*
* Copyright (c) 2004 Alexander Guy <alexander.guy@andern.org>
return (buf);
}
+const char *
+log_ntp_addr(struct ntp_addr *addr)
+{
+ if (addr == NULL)
+ return ("(unknown)");
+ return log_sockaddr((struct sockaddr *)&addr->ss);
+}
+
pid_t
start_child(char *pname, int cfd, int argc, char **argv)
{