From 86d29221f39c0b47b21fbfae9c800b7e661c4f88 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 4 Feb 2020 11:50:29 +0100 Subject: [PATCH] ntp: add function to change authentication-specific address When an NTS source will be replaced, the authentication-specific address of the NTS-KE server will need to be changed too. --- ntp_auth.c | 14 ++++++++++++++ ntp_auth.h | 3 +++ ntp_core.c | 3 +++ 3 files changed, 20 insertions(+) diff --git a/ntp_auth.c b/ntp_auth.c index 43f4483..4f99154 100644 --- a/ntp_auth.c +++ b/ntp_auth.c @@ -422,3 +422,17 @@ NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response, NTP_PacketInf return 1; } + +/* ================================================== */ + +void +NAU_ChangeAddress(NAU_Instance instance, IPAddr *address) +{ + switch (instance->mode) { + case NTP_AUTH_NONE: + case NTP_AUTH_SYMMETRIC: + break; + default: + assert(0); + } +} diff --git a/ntp_auth.h b/ntp_auth.h index a032614..8211c63 100644 --- a/ntp_auth.h +++ b/ntp_auth.h @@ -81,4 +81,7 @@ extern int NAU_GenerateResponseAuth(NTP_Packet *request, NTP_PacketInfo *request extern int NAU_CheckResponseAuth(NAU_Instance instance, NTP_Packet *response, NTP_PacketInfo *info); +/* Change an authentication-specific address (e.g. after replacing a source) */ +extern void NAU_ChangeAddress(NAU_Instance instance, IPAddr *address); + #endif diff --git a/ntp_core.c b/ntp_core.c index 9ce0426..ab7d503 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -710,6 +710,9 @@ NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr, int SRC_SetRefid(inst->source, UTI_IPToRefid(&remote_addr->ip_addr), &inst->remote_addr.ip_addr); SRC_ResetInstance(inst->source); + + if (!ntp_only) + NAU_ChangeAddress(inst->auth, &remote_addr->ip_addr); } /* ================================================== */