close_client_socket(inst);
else {
NIO_CloseServerSocket(inst->local_addr.sock_fd);
+ inst->local_addr.ip_addr.family = IPADDR_UNSPEC;
inst->local_addr.sock_fd = NIO_OpenServerSocket(remote_addr);
}
transmit_timeout(void *arg)
{
NCR_Instance inst = (NCR_Instance) arg;
+ NTP_Local_Address local_addr;
int sent;
inst->tx_timeout_id = 0;
inst->local_addr.sock_fd = NIO_OpenClientSocket(&inst->remote_addr);
}
+ /* Don't require the packet to be sent from the same address as before */
+ local_addr.ip_addr.family = IPADDR_UNSPEC;
+ local_addr.sock_fd = inst->local_addr.sock_fd;
+
/* Check whether we need to 'warm up' the link to the other end by
sending an NTP exchange to ensure both ends' ARP caches are
primed. On loaded systems this might also help ensure that bits
as the reply will be ignored */
transmit_packet(MODE_CLIENT, inst->local_poll, inst->version, 0, 0,
&inst->remote_orig, &inst->local_rx, NULL, NULL,
- &inst->remote_addr, &inst->local_addr);
+ &inst->remote_addr, &local_addr);
inst->presend_done = 1;
&inst->remote_orig,
&inst->local_rx, &inst->local_tx, &inst->local_ntp_tx,
&inst->remote_addr,
- &inst->local_addr);
+ &local_addr);
++inst->tx_count;
server and the socket can be closed */
close_client_socket(inst);
+ /* Update the local address */
+ inst->local_addr.ip_addr = local_addr->ip_addr;
+
requeue_transmit = 1;
}
/* ================================================== */
+uint32_t
+NCR_GetLocalRefid(NCR_Instance inst)
+{
+ return UTI_IPToRefid(&inst->local_addr.ip_addr);
+}
+
+/* ================================================== */
+
int NCR_IsSyncPeer(NCR_Instance inst)
{
return SRC_IsSyncPeer(inst->source);
rehash_records();
}
+/* ================================================== */
+
+uint32_t
+NSR_GetLocalRefid(IPAddr *address)
+{
+ NTP_Remote_Address remote_addr;
+ int slot, found;
+
+ remote_addr.ip_addr = *address;
+ remote_addr.port = 0;
+
+ find_slot(&remote_addr, &slot, &found);
+ if (!found)
+ return 0;
+
+ return NCR_GetLocalRefid(get_record(slot)->data);
+}
+
+/* ================================================== */
+
/* This routine is called by ntp_io when a new packet arrives off the network,
possibly with an authentication tail */
void
/* Procedure to resolve all names again */
extern void NSR_RefreshAddresses(void);
+/* Procedure to get local reference ID corresponding to a source */
+extern uint32_t NSR_GetLocalRefid(IPAddr *address);
+
/* This routine is called by ntp_io when a new packet arrives off the network */
extern void NSR_ProcessReceive(NTP_Packet *message, struct timeval *now, double now_err, NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr, int length);