Support for poll server
This commit is contained in:
parent
0e459dd6b7
commit
a25a43b7af
Binary file not shown.
BIN
bin/ntimed.m68k
BIN
bin/ntimed.m68k
Binary file not shown.
|
@ -24,22 +24,9 @@
|
|||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# Handwritten configure script.
|
||||
# =============================
|
||||
#
|
||||
# Before you suggest I use tools for this, please read:
|
||||
#
|
||||
# https://www.varnish-cache.org/docs/trunk/phk/autocrap.html
|
||||
# and
|
||||
# http://queue.acm.org/detail.cfm?id=2349257
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# List of .h files
|
||||
# NB: These SHALL always be included with #include "..."
|
||||
|
||||
HDRS='
|
||||
compiler.h
|
||||
ntimed.h
|
||||
|
@ -58,10 +45,55 @@ HDRS='
|
|||
mem.h
|
||||
'
|
||||
|
||||
# List of .c files
|
||||
|
||||
SRCS='
|
||||
main_amiga.c
|
||||
main_amiga_client.c
|
||||
main_amiga_poll.c
|
||||
combine_delta.c
|
||||
ntp_filter.c
|
||||
ntp_packet.c
|
||||
ntp_peer.c
|
||||
ntp_peerset.c
|
||||
ntp_tools.c
|
||||
ocx_stdio.c
|
||||
param.c
|
||||
pll_std.c
|
||||
suckaddr.c
|
||||
time_amiga.c
|
||||
time_sim.c
|
||||
time_stuff.c
|
||||
todo.c
|
||||
tz.c
|
||||
udp.c
|
||||
agetaddrinfo.c
|
||||
apoll.c
|
||||
mem.c
|
||||
'
|
||||
|
||||
SRCS1='
|
||||
main_amiga_client.c
|
||||
combine_delta.c
|
||||
ntp_filter.c
|
||||
ntp_packet.c
|
||||
ntp_peer.c
|
||||
ntp_peerset.c
|
||||
ntp_tools.c
|
||||
ocx_stdio.c
|
||||
param.c
|
||||
pll_std.c
|
||||
suckaddr.c
|
||||
time_amiga.c
|
||||
time_sim.c
|
||||
time_stuff.c
|
||||
todo.c
|
||||
tz.c
|
||||
udp.c
|
||||
agetaddrinfo.c
|
||||
apoll.c
|
||||
mem.c
|
||||
'
|
||||
|
||||
SRCS2='
|
||||
main_amiga_poll.c
|
||||
combine_delta.c
|
||||
ntp_filter.c
|
||||
ntp_packet.c
|
||||
|
@ -85,36 +117,17 @@ SRCS='
|
|||
|
||||
if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then
|
||||
echo "make(1) is GNU make."
|
||||
BSD=false
|
||||
#elif [ -f /usr/share/mk/bsd.prog.mk ] ; then
|
||||
# echo "Found bsd.prog.mk, will use it."
|
||||
# BSD=true
|
||||
VALID=true
|
||||
else
|
||||
echo "Defaulting to plain makefile"
|
||||
BSD=false
|
||||
echo "Wrong version of make."
|
||||
VALID=false
|
||||
fi
|
||||
|
||||
if $BSD ; then
|
||||
(
|
||||
echo '# BSD-style Makefile generated by configure'
|
||||
echo 'PROG = ntimed-client'
|
||||
for f in ${SRCS}
|
||||
do
|
||||
echo "SRCS += ${f}"
|
||||
done
|
||||
|
||||
echo 'NO_MAN = not_yet'
|
||||
echo 'LDADD += -lm'
|
||||
echo 'WARNS ?= 6'
|
||||
echo '.include <bsd.prog.mk>'
|
||||
) > Makefile
|
||||
|
||||
msg=", remember to run 'make depend'"
|
||||
else
|
||||
if $VALID ; then
|
||||
(
|
||||
echo '# Portable Makefile generated by configure'
|
||||
echo ''
|
||||
echo 'all: ntimed'
|
||||
echo 'all: ntimed ntimed-poll'
|
||||
echo ''
|
||||
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
|
||||
echo 'CC = gcc'
|
||||
|
@ -155,13 +168,29 @@ else
|
|||
echo
|
||||
l="${l} ${b}.o"
|
||||
done
|
||||
|
||||
|
||||
BIN1=""
|
||||
for f in ${SRCS1}
|
||||
do
|
||||
BIN1="${BIN1} `basename $f .c`.o"
|
||||
done
|
||||
|
||||
BIN2=""
|
||||
for f in ${SRCS2}
|
||||
do
|
||||
BIN2="${BIN2} `basename $f .c`.o"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "ntimed: ${l}"
|
||||
echo " \${CC} \${CFLAGS} -o ntimed ${l} -lm"
|
||||
echo "ntimed: ${BIN1}"
|
||||
echo " \${CC} \${CFLAGS} -o ntimed ${BIN1} -lm"
|
||||
echo
|
||||
echo
|
||||
echo "ntimed-poll: ${BIN2}"
|
||||
echo " \${CC} \${CFLAGS} -o ntimed-poll ${BIN2} -lm"
|
||||
echo
|
||||
echo "clean:"
|
||||
echo " rm -f ${l} ntimed"
|
||||
echo " rm -f ${l} ntimed ntimed-poll"
|
||||
echo
|
||||
echo "depend:"
|
||||
echo " @echo Dependencies already done"
|
||||
|
|
83
main.c
83
main.c
|
@ -1,83 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Main main() functions
|
||||
* =====================
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ntimed.h"
|
||||
#include "ntp.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static void
|
||||
dummy(void)
|
||||
{
|
||||
// Reference otherwise unused "library" functions
|
||||
|
||||
NTP_Peer_Destroy(NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
main_run_tests(int argc, char * const * argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
Time_Amiga_Passive();
|
||||
|
||||
TS_RunTest(NULL);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char * const *argv)
|
||||
{
|
||||
int r;
|
||||
|
||||
if(OpenLibraries() != 0)
|
||||
return -1;
|
||||
|
||||
if (getpid() == 0)
|
||||
dummy();
|
||||
|
||||
if (argc > 1 && !strcmp(argv[1], "--poll-server")) {
|
||||
r = (main_poll_server(argc - 1, argv + 1));
|
||||
} else if (argc > 1 && !strcmp(argv[1], "--sim-client")) {
|
||||
r = (main_sim_client(argc - 1, argv + 1));
|
||||
} else if (argc > 1 && !strcmp(argv[1], "--run-tests")) {
|
||||
r = (main_run_tests(argc - 1, argv + 1));
|
||||
} else {
|
||||
r = main_client(argc, argv);
|
||||
}
|
||||
|
||||
CloseLibraries();
|
||||
|
||||
return r;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Carsten Larsen
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -80,8 +81,13 @@
|
|||
#undef PARAM_TABLE_NAME
|
||||
#undef PARAM_CLIENT
|
||||
|
||||
#define ARGSFORMAT "P=PARAM/K,T=TRACEFILE/K,Z=TIMEZONE/K,SERVERS/M,SYNC/S,SAVE/S,QUIET/S"
|
||||
const char *vers = "\0$VER: ntimed 1.0a";
|
||||
|
||||
void Time_Amiga(struct todolist *);
|
||||
void Time_Amiga_Passive(void);
|
||||
extern int validtime;
|
||||
|
||||
BOOL savetime;
|
||||
BOOL started_from_wb;
|
||||
struct Library *BattClockBase;
|
||||
|
@ -92,8 +98,6 @@ struct ntp_peerset *nps = NULL;
|
|||
struct todolist *tdl = NULL;
|
||||
struct udp_socket *usc = NULL;
|
||||
|
||||
extern int validtime;
|
||||
|
||||
struct ntimedargs {
|
||||
char *params;
|
||||
char *tracefile;
|
||||
|
@ -288,4 +292,3 @@ static void clean_exit()
|
|||
|
||||
freeall();
|
||||
}
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Carsten Larsen
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <proto/exec.h>
|
||||
#include <proto/dos.h>
|
||||
#include <proto/intuition.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef Debug
|
||||
#undef Debug
|
||||
#endif
|
||||
|
||||
#ifdef AROS
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <proto/socket.h>
|
||||
#include <sys/socket.h>
|
||||
#include <bsdsocket/socketbasetags.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifdef Debug
|
||||
#undef Debug
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "tz.h"
|
||||
#include "ntimed.h"
|
||||
#include "ntimed_platform.h"
|
||||
#include "mem.h"
|
||||
#include "ntp.h"
|
||||
#include "udp.h"
|
||||
|
||||
#define ARGSFORMAT "D=DURATION/N,M=MONITOR/K,T=TRACEFILE/K,Z=TIMEZONE/K,SERVERS/M,QUIET/S"
|
||||
const char *vers = "\0$VER: ntimed-poll 1.0a";
|
||||
|
||||
void Time_Amiga(struct todolist *);
|
||||
void Time_Amiga_Passive(void);
|
||||
|
||||
BOOL started_from_wb;
|
||||
struct Library *BattClockBase;
|
||||
struct Library *SocketBase = NULL;
|
||||
struct RDArgs *rdargs = NULL;
|
||||
struct udp_socket *usc = NULL;
|
||||
struct ntp_peerset *npl = NULL;
|
||||
struct todolist *tdl = NULL;
|
||||
|
||||
struct ntimedargs {
|
||||
long *duration;
|
||||
char *monitor;
|
||||
char *tracefile;
|
||||
char *timezone;
|
||||
char **servers;
|
||||
long quiet;
|
||||
};
|
||||
|
||||
static void init_libs(struct ntimedargs *args);
|
||||
static void init_logic(struct ntimedargs *args);
|
||||
static void clean_exit();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct ntimedargs args = { NULL, NULL, "-", NULL, NULL, FALSE };
|
||||
|
||||
started_from_wb = (BOOL)argc;
|
||||
|
||||
atexit(clean_exit);
|
||||
|
||||
rdargs = ReadArgs(ARGS_FORMAT, (APTR)&args, NULL);
|
||||
if (!rdargs)
|
||||
{
|
||||
PrintFault(IoErr(), (ARGPTR)argv[0]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (!args.quiet) {
|
||||
EnableDebug();
|
||||
}
|
||||
|
||||
init_libs(&args);
|
||||
|
||||
if (args.timezone) {
|
||||
ArgTimezone(args.timezone);
|
||||
}
|
||||
|
||||
ArgTracefile(args.tracefile);
|
||||
|
||||
init_logic(&args);
|
||||
|
||||
NTP_PeerSet_Poll(NULL, npl, usc, tdl);
|
||||
(void)TODO_Run(NULL, tdl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_libs(struct ntimedargs *args)
|
||||
{
|
||||
#ifdef AROS
|
||||
if(!(SocketBase = OpenLibrary(BSDLIB_NAME, BSDLIB_REV))) {
|
||||
Put(NULL, OCX_DIAG, "No TCP/IP Stack running.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR)&errno,
|
||||
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR)&h_errno, TAG_DONE)) {
|
||||
Put(NULL, OCX_DIAG, "Error initializing bsdsocket.\n");
|
||||
exit(2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
mps_filter(struct ocx *ocx, const struct ntp_peer *np)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
NTP_Tool_Format(buf, sizeof buf, np->rx_pkt);
|
||||
Put(ocx, OCX_TRACE, "Poll %s %s %s\n", np->hostname, np->ip, buf);
|
||||
}
|
||||
|
||||
static enum todo_e __match_proto__(todo_f)
|
||||
mps_mon(struct ocx *ocx, struct todolist *tdl, void *priv)
|
||||
{
|
||||
char buf[256];
|
||||
struct ntp_peer *np;
|
||||
int i;
|
||||
|
||||
(void)ocx;
|
||||
(void)tdl;
|
||||
CAST_OBJ_NOTNULL(np, priv, NTP_PEER_MAGIC);
|
||||
i = NTP_Peer_Poll(ocx, usc, np, 0.2);
|
||||
if (i == 1) {
|
||||
NTP_Tool_Format(buf, sizeof buf, np->rx_pkt);
|
||||
Put(ocx, OCX_TRACE, "Monitor %s %s %s\n", np->hostname, np->ip, buf);
|
||||
} else {
|
||||
Put(ocx, OCX_TRACE, "Monitor_err %s %s %d\n", np->hostname, np->ip, i);
|
||||
}
|
||||
|
||||
return(TODO_OK);
|
||||
}
|
||||
|
||||
static enum todo_e __match_proto__(todo_f)
|
||||
mps_end(struct ocx *ocx, struct todolist *tdl, void *priv)
|
||||
{
|
||||
(void)tdl;
|
||||
(void)priv;
|
||||
Put(ocx, OCX_TRACE, "# Run completed\n");
|
||||
return(TODO_FAIL);
|
||||
}
|
||||
|
||||
static void init_logic(struct ntimedargs *args)
|
||||
{
|
||||
struct ntp_peer *mon;
|
||||
struct ntp_peer *np;
|
||||
int npeer;
|
||||
int i;
|
||||
long duration;
|
||||
mon = NULL;
|
||||
npeer = 0;
|
||||
duration = 1800;
|
||||
|
||||
if (args->duration) {
|
||||
duration = *(args->duration);
|
||||
if(duration < 1) {
|
||||
Put(NULL, OCX_DEBUG, "Invalid DURATION value.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(args->monitor) {
|
||||
mon = NTP_Peer_NewLookup(NULL, args->monitor);
|
||||
if (mon == NULL) {
|
||||
Put(NULL, OCX_DEBUG, "MONITOR did not resolve.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
tdl = TODO_NewList();
|
||||
Time_Amiga_Passive();
|
||||
|
||||
npl = NTP_PeerSet_New(NULL);
|
||||
AN(npl);
|
||||
|
||||
for (i = 0; args->servers[i]; i++)
|
||||
npeer += NTP_PeerSet_Add(NULL, npl, args->servers[i]);
|
||||
|
||||
Put(NULL, OCX_TRACE, "# NTIMED Format poll-server 1.0\n");
|
||||
Put(NULL, OCX_TRACE, "# Timezone set to %s (UTC%s%.2f)\n",
|
||||
tza[tzid].abbr,
|
||||
tza[tzid].offset < 0.0 ? "-" : "+",
|
||||
fabs(tza[tzid].offset));
|
||||
|
||||
Put(NULL, OCX_TRACE, "# Found %d peers\n", npeer);
|
||||
|
||||
if (npeer == 0) {
|
||||
Put(NULL, OCX_DEBUG, "No NTP peers found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NTP_PeerSet_Foreach(np, npl) {
|
||||
Put(NULL, OCX_TRACE, "# Peer %s %s\n", np->hostname, np->ip);
|
||||
np->filter_func = mps_filter;
|
||||
}
|
||||
|
||||
if (mon != NULL)
|
||||
Put(NULL, OCX_TRACE, "# Monitor %s %s\n", mon->hostname, mon->ip);
|
||||
|
||||
usc = UdpTimedSocket(NULL);
|
||||
if (usc == NULL) {
|
||||
Put(NULL, OCX_DEBUG, "Could not open UDP socket\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Put(NULL, OCX_TRACE, "# Duration of run set to %d seconds\n", duration);
|
||||
|
||||
TODO_ScheduleRel(tdl, mps_end, NULL, duration, 0, "End task");
|
||||
|
||||
if (mon != NULL)
|
||||
TODO_ScheduleRel(tdl, mps_mon, mon, 0, 32, "Monitor");
|
||||
}
|
||||
|
||||
static void clean_exit()
|
||||
{
|
||||
ArgTracefile(NULL);
|
||||
|
||||
if(usc) {
|
||||
UDP_Socket_Destroy(usc);
|
||||
usc = NULL;
|
||||
}
|
||||
|
||||
#ifdef AROS
|
||||
if (SocketBase != NULL) {
|
||||
CloseLibrary(SocketBase);
|
||||
SocketBase = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rdargs) {
|
||||
FreeArgs(rdargs);
|
||||
rdargs = NULL;
|
||||
}
|
||||
|
||||
freeall();
|
||||
}
|
149
main_client.c
149
main_client.c
|
@ -1,149 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Client main function
|
||||
* ====================
|
||||
*
|
||||
* Steer system time based on NTP servers
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "tz.h"
|
||||
#include "ntimed.h"
|
||||
#include "ntp.h"
|
||||
#include "udp.h"
|
||||
|
||||
#define PARAM_CLIENT PARAM_INSTANCE
|
||||
#define PARAM_TABLE_NAME client_param_table
|
||||
#include "param_instance.h"
|
||||
#undef PARAM_TABLE_NAME
|
||||
#undef PARAM_CLIENT
|
||||
|
||||
static volatile sig_atomic_t restart = 1;
|
||||
|
||||
static void
|
||||
sig_hup(int siginfo)
|
||||
{
|
||||
(void)signal(SIGHUP, sig_hup);
|
||||
(void)siginfo;
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
int
|
||||
main_client(int argc, char *const *argv)
|
||||
{
|
||||
int ch;
|
||||
struct ntp_peer *np;
|
||||
struct ntp_peerset *nps;
|
||||
struct todolist *tdl;
|
||||
struct combine_delta *cd;
|
||||
struct udp_socket *usc;
|
||||
int npeer = 0;
|
||||
int help = 0;
|
||||
|
||||
//setbuf(stdout, NULL);
|
||||
//setbuf(stderr, NULL);
|
||||
|
||||
tdl = TODO_NewList();
|
||||
Time_Amiga(tdl);
|
||||
|
||||
PLL_Init();
|
||||
|
||||
nps = NTP_PeerSet_New(NULL);
|
||||
|
||||
Param_Register(client_param_table);
|
||||
NF_Init();
|
||||
|
||||
while ((ch = getopt(argc, argv, "p:t:z:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'p':
|
||||
Param_Tweak(NULL, optarg);
|
||||
break;
|
||||
case 't':
|
||||
ArgTracefile(optarg);
|
||||
break;
|
||||
case 'z':
|
||||
help = ArgTimezone(optarg);
|
||||
break;
|
||||
default:
|
||||
Fail(NULL, 0,
|
||||
"Usage %s [-p param] [-t tracefile] [-z timezone] servers...",
|
||||
argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (help)
|
||||
exit(1);
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
for (ch = 0; ch < argc; ch++)
|
||||
npeer += NTP_PeerSet_Add(NULL, nps, argv[ch]);
|
||||
if (npeer == 0)
|
||||
Fail(NULL, 0, "No NTP peers found");
|
||||
|
||||
Put(NULL, OCX_TRACE, "# NTIMED Format client 1.0\n");
|
||||
Put(NULL, OCX_TRACE, "# Found %d peers\n", npeer);
|
||||
Put(NULL, OCX_TRACE, "# Timezone set to %s (UTC%s%.2f) %s\n",
|
||||
tza[tzid].abbr,
|
||||
tza[tzid].offset < 0.0 ? "-" : "+",
|
||||
fabs(tza[tzid].offset),
|
||||
tza[tzid].name);
|
||||
|
||||
Param_Report(NULL, OCX_TRACE);
|
||||
|
||||
usc = UdpTimedSocket(NULL);
|
||||
if (usc == NULL)
|
||||
Fail(NULL, errno, "Could not open UDP socket");
|
||||
|
||||
cd = CD_New();
|
||||
|
||||
NTP_PeerSet_Foreach(np, nps) {
|
||||
NF_New(np);
|
||||
np->combiner = CD_AddSource(cd, np->hostname, np->ip);
|
||||
}
|
||||
|
||||
do {
|
||||
if (restart) {
|
||||
Debug(NULL, "RESTART\n");
|
||||
TB_generation++;
|
||||
NTP_PeerSet_Poll(NULL, nps, usc, tdl);
|
||||
restart = 0;
|
||||
}
|
||||
(void)signal(SIGHUP, sig_hup);
|
||||
(void)TODO_Run(NULL, tdl);
|
||||
} while (restart);
|
||||
|
||||
return (0);
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* poll-server
|
||||
* [-d duration] When to stop
|
||||
* [-m monitor] Poll this monitor every 32 seconds
|
||||
* [-t tracefile] Where to save the output (if not stdout)
|
||||
* server ... What servers to poll
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "ntimed.h"
|
||||
#include "ntp.h"
|
||||
#include "udp.h"
|
||||
|
||||
static struct udp_socket *usc;
|
||||
|
||||
static void
|
||||
mps_filter(struct ocx *ocx, const struct ntp_peer *np)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
NTP_Tool_Format(buf, sizeof buf, np->rx_pkt);
|
||||
Put(ocx, OCX_TRACE, "Poll %s %s %s\n", np->hostname, np->ip, buf);
|
||||
}
|
||||
|
||||
static enum todo_e __match_proto__(todo_f)
|
||||
mps_mon(struct ocx *ocx, struct todolist *tdl, void *priv)
|
||||
{
|
||||
char buf[256];
|
||||
struct ntp_peer *np;
|
||||
int i;
|
||||
|
||||
(void)ocx;
|
||||
(void)tdl;
|
||||
CAST_OBJ_NOTNULL(np, priv, NTP_PEER_MAGIC);
|
||||
i = NTP_Peer_Poll(ocx, usc, np, 0.2);
|
||||
if (i == 1) {
|
||||
NTP_Tool_Format(buf, sizeof buf, np->rx_pkt);
|
||||
Put(ocx, OCX_TRACE,
|
||||
"Monitor %s %s %s\n", np->hostname, np->ip, buf);
|
||||
} else {
|
||||
Put(ocx, OCX_TRACE,
|
||||
"Monitor_err %s %s %d\n", np->hostname, np->ip, i);
|
||||
}
|
||||
return(TODO_OK);
|
||||
}
|
||||
|
||||
static enum todo_e __match_proto__(todo_f)
|
||||
mps_end(struct ocx *ocx, struct todolist *tdl, void *priv)
|
||||
{
|
||||
(void)tdl;
|
||||
(void)priv;
|
||||
Put(ocx, OCX_TRACE, "# Run completed\n");
|
||||
return(TODO_FAIL);
|
||||
}
|
||||
|
||||
int
|
||||
main_poll_server(int argc, char *const *argv)
|
||||
{
|
||||
int ch;
|
||||
int npeer = 0;
|
||||
char *p;
|
||||
struct ntp_peerset *npl;
|
||||
struct ntp_peer *mon = NULL;
|
||||
struct ntp_peer *np;
|
||||
struct todolist *tdl;
|
||||
double duration = 1800;
|
||||
|
||||
//setbuf(stdout, NULL);
|
||||
//setbuf(stderr, NULL);
|
||||
|
||||
ArgTracefile("-");
|
||||
|
||||
tdl = TODO_NewList();
|
||||
Time_Amiga_Passive();
|
||||
|
||||
npl = NTP_PeerSet_New(NULL);
|
||||
AN(npl);
|
||||
|
||||
while ((ch = getopt(argc, argv, "d:m:t:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'd':
|
||||
duration = strtod(optarg, &p);
|
||||
if (*p != '\0' || duration < 1.0)
|
||||
Fail(NULL, 0, "Invalid -d argument");
|
||||
break;
|
||||
case 'm':
|
||||
mon = NTP_Peer_NewLookup(NULL, optarg);
|
||||
if (mon == NULL)
|
||||
Fail(NULL, 0, "Monitor (-m) didn't resolve.");
|
||||
break;
|
||||
case 't':
|
||||
ArgTracefile(optarg);
|
||||
break;
|
||||
default:
|
||||
Fail(NULL, 0,
|
||||
"Usage %s [-d duration] [-m monitor] "
|
||||
"[-t tracefile] server...", argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
for (ch = 0; ch < argc; ch++)
|
||||
npeer += NTP_PeerSet_Add(NULL, npl, argv[ch]);
|
||||
Put(NULL, OCX_TRACE, "# NTIMED Format poll-server 1.0\n");
|
||||
Put(NULL, OCX_TRACE, "# Found %d peers\n", npeer);
|
||||
if (npeer == 0)
|
||||
Fail(NULL, 0, "No peers found");
|
||||
|
||||
NTP_PeerSet_Foreach(np, npl) {
|
||||
Put(NULL, OCX_TRACE, "# Peer %s %s\n", np->hostname, np->ip);
|
||||
np->filter_func = mps_filter;
|
||||
}
|
||||
|
||||
if (mon != NULL)
|
||||
Put(NULL, OCX_TRACE,
|
||||
"# Monitor %s %s\n", mon->hostname, mon->ip);
|
||||
|
||||
usc = UdpTimedSocket(NULL);
|
||||
assert(usc != NULL);
|
||||
|
||||
TODO_ScheduleRel(tdl, mps_end, NULL, duration, 0, "End task");
|
||||
|
||||
if (mon != NULL)
|
||||
TODO_ScheduleRel(tdl, mps_mon, mon, 0, 32, "Monitor");
|
||||
|
||||
NTP_PeerSet_Poll(NULL, npl, usc, tdl);
|
||||
(void)TODO_Run(NULL, tdl);
|
||||
return (0);
|
||||
}
|
|
@ -1,292 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* sim_client
|
||||
* -s simfile Output file from poll-server
|
||||
* server_numbers ...
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ntimed.h"
|
||||
#include "ntp.h"
|
||||
|
||||
#define PARAM_CLIENT PARAM_INSTANCE
|
||||
#define PARAM_TABLE_NAME client_param_table
|
||||
#include "param_instance.h"
|
||||
#undef PARAM_TABLE_NAME
|
||||
#undef PARAM_CLIENT
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
struct sim_file {
|
||||
unsigned magic;
|
||||
#define SIM_FILE_MAGIC 0x7f847bd0
|
||||
char *filename;
|
||||
FILE *input;
|
||||
unsigned n_peer;
|
||||
struct ntp_peerset *npl;
|
||||
struct timestamp when;
|
||||
unsigned t0;
|
||||
};
|
||||
|
||||
static void
|
||||
simfile_poll(struct ocx *ocx, const struct sim_file *sf, char *buf)
|
||||
{
|
||||
char *hostname;
|
||||
char *ip;
|
||||
char *pkt;
|
||||
struct ntp_peer *np;
|
||||
struct ntp_packet *rxp;
|
||||
struct ntp_packet *txp;
|
||||
|
||||
CHECK_OBJ_NOTNULL(sf, SIM_FILE_MAGIC);
|
||||
AN(buf);
|
||||
|
||||
if (memcmp(buf, "Poll ", 5))
|
||||
Fail(ocx, 0, "Bad 'Poll' line (%s)\n", buf);
|
||||
hostname = buf + 5;
|
||||
ip = strchr(hostname, ' ');
|
||||
if (ip == NULL)
|
||||
Fail(ocx, 0, "Bad 'Poll' line (%s)\n", buf);
|
||||
pkt = strchr(ip + 1, ' ');
|
||||
if (pkt == NULL)
|
||||
Fail(ocx, 0, "Bad 'Poll' line (%s)\n", buf);
|
||||
|
||||
*ip++ = '\0';
|
||||
*pkt++ = '\0';
|
||||
|
||||
NTP_PeerSet_Foreach(np, sf->npl)
|
||||
if (!strcmp(np->hostname, hostname) && !strcmp(np->ip, ip))
|
||||
break;
|
||||
if (np == NULL)
|
||||
Fail(ocx, 0, "Peer not found (%s, %s)\n", hostname, ip);
|
||||
|
||||
CHECK_OBJ_NOTNULL(np, NTP_PEER_MAGIC);
|
||||
|
||||
txp = np->tx_pkt;
|
||||
INIT_OBJ(txp, NTP_PACKET_MAGIC);
|
||||
|
||||
rxp = np->rx_pkt;
|
||||
if (NTP_Tool_Scan(rxp, pkt))
|
||||
Fail(ocx, 0, "Cannot parse packet (%s, %s, %s)\n",
|
||||
hostname, ip, pkt);
|
||||
|
||||
TS_Add(&rxp->ntp_origin, Time_Sim_delta);
|
||||
TS_Add(&rxp->ts_rx, Time_Sim_delta);
|
||||
|
||||
txp->ntp_transmit = rxp->ntp_origin;
|
||||
|
||||
if (np->filter_func != NULL)
|
||||
np->filter_func(ocx, np);
|
||||
}
|
||||
|
||||
static enum todo_e
|
||||
simfile_readline(struct ocx *ocx, struct todolist *tdl, void *priv)
|
||||
{
|
||||
struct sim_file *sf;
|
||||
char buf[BUFSIZ], *p;
|
||||
struct timestamp t0;
|
||||
unsigned u1, u2;
|
||||
double dt;
|
||||
|
||||
AN(tdl);
|
||||
CAST_OBJ_NOTNULL(sf, priv, SIM_FILE_MAGIC);
|
||||
|
||||
TB_Now(&t0);
|
||||
|
||||
while (1) {
|
||||
if (fgets(buf, sizeof buf, sf->input) == NULL) {
|
||||
Debug(ocx, "EOF on -s file (%s)\n", sf->filename);
|
||||
exit(0);
|
||||
}
|
||||
p = strchr(buf, '\r');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
p = strchr(buf, '\n');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
|
||||
if (!strncmp(buf, "Now ", 4)) {
|
||||
if (sscanf(buf, "Now %u.%u", &u1, &u2) != 2)
|
||||
Fail(ocx, 0, "Bad 'Now' line (%s)", buf);
|
||||
if (sf->t0 == 0)
|
||||
sf->t0 = u1 - t0.sec;
|
||||
u1 -= sf->t0;
|
||||
TS_Nanosec(&sf->when, u1, u2);
|
||||
dt = TS_Diff(&sf->when, &t0);
|
||||
if (dt >= 1e-3) {
|
||||
TODO_ScheduleAbs(tdl, simfile_readline, priv,
|
||||
&sf->when, 0.0, "Readline");
|
||||
return (TODO_OK);
|
||||
}
|
||||
} else if (!strncmp(buf, "Poll ", 5)) {
|
||||
simfile_poll(ocx, sf, buf);
|
||||
}
|
||||
/* We ignore things we don't understand */
|
||||
}
|
||||
}
|
||||
|
||||
static struct sim_file *
|
||||
SimFile_Open(struct ocx *ocx, const char *fn, struct todolist *tdl,
|
||||
struct ntp_peerset *npl)
|
||||
{
|
||||
struct sim_file *sf;
|
||||
char buf[BUFSIZ];
|
||||
char buf2[BUFSIZ];
|
||||
char buf3[BUFSIZ];
|
||||
char *e;
|
||||
int s;
|
||||
unsigned fpeer = 0;
|
||||
|
||||
AN(fn);
|
||||
AN(tdl);
|
||||
AN(npl);
|
||||
|
||||
ALLOC_OBJ(sf, SIM_FILE_MAGIC);
|
||||
AN(sf);
|
||||
|
||||
sf->input = fopen(fn, "r");
|
||||
if (sf->input == NULL)
|
||||
Fail(ocx, 1, "Could not open -s file (%s)", fn);
|
||||
sf->filename = strdup(fn);
|
||||
AN(sf->filename);
|
||||
sf->npl = npl;
|
||||
|
||||
for (s = 0; s < 3; ) {
|
||||
if (fgets(buf, sizeof buf, sf->input) == NULL)
|
||||
Fail(ocx, 1, "Premature EOF on -s file (%s)", fn);
|
||||
e = strchr(buf, '\0');
|
||||
AN(e);
|
||||
if (e == buf)
|
||||
continue;
|
||||
if (e[-1] == '\n')
|
||||
*--e = '\0';
|
||||
Debug(ocx, ">>> %s\n", buf);
|
||||
switch(s) {
|
||||
case 0:
|
||||
if (strcmp(buf, "# NTIMED Format poll-server 1.0"))
|
||||
Fail(ocx, 0,
|
||||
"Wrong fileformat in -s file (%s)", fn);
|
||||
s++;
|
||||
break;
|
||||
case 1:
|
||||
if (sscanf(buf, "# Found %u peers", &sf->n_peer) != 1)
|
||||
Fail(ocx, 0,
|
||||
"Expected '# Found ... peers' line");
|
||||
s++;
|
||||
break;
|
||||
case 2:
|
||||
if (sscanf(buf, "# Peer %s %s", buf2, buf3) != 2)
|
||||
Fail(ocx, 0, "Expected '# Peer' line");
|
||||
|
||||
NTP_PeerSet_AddSim(ocx, npl, buf2, buf3);
|
||||
if (++fpeer == sf->n_peer)
|
||||
s++;
|
||||
break;
|
||||
default:
|
||||
Debug(ocx, "<%s>\n", buf);
|
||||
Fail(ocx, 0,
|
||||
"XXX: Wrong state (%d) in open_sim_file", s);
|
||||
}
|
||||
}
|
||||
(void)simfile_readline(NULL, tdl, sf);
|
||||
return (sf);
|
||||
}
|
||||
|
||||
int
|
||||
main_sim_client(int argc, char *const *argv)
|
||||
{
|
||||
int ch;
|
||||
const char *s_filename = NULL;
|
||||
struct sim_file *sf;
|
||||
struct ntp_peerset *npl;
|
||||
struct ntp_peer *np;
|
||||
struct todolist *tdl;
|
||||
struct combine_delta *cd;
|
||||
double a, b, c;
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
tdl = TODO_NewList();
|
||||
Time_Sim(tdl);
|
||||
|
||||
PLL_Init();
|
||||
|
||||
npl = NTP_PeerSet_New(NULL);
|
||||
|
||||
Param_Register(client_param_table);
|
||||
NF_Init();
|
||||
|
||||
while ((ch = getopt(argc, argv, "B:s:p:t:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'B':
|
||||
ch = sscanf(optarg, "%lg,%lg,%lg", &a, &b, &c);
|
||||
if (ch != 3)
|
||||
Fail(NULL, 0,
|
||||
"bad -B argument \"when,freq,phase\"");
|
||||
Time_Sim_Bump(tdl, a, b, c);
|
||||
break;
|
||||
case 's':
|
||||
s_filename = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
Param_Tweak(NULL, optarg);
|
||||
break;
|
||||
case 't':
|
||||
ArgTracefile(optarg);
|
||||
break;
|
||||
default:
|
||||
Fail(NULL, 0,
|
||||
"Usage %s [-s simfile] [-p params] [-t tracefile]"
|
||||
" [-B when,freq,phase]", argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// argc -= optind;
|
||||
// argv += optind;
|
||||
|
||||
Param_Report(NULL, OCX_TRACE);
|
||||
|
||||
if (s_filename == NULL)
|
||||
Fail(NULL, 1, "You must specify -s file.");
|
||||
|
||||
sf = SimFile_Open(NULL, s_filename, tdl, npl);
|
||||
AN(sf);
|
||||
|
||||
cd = CD_New();
|
||||
|
||||
NTP_PeerSet_Foreach(np, npl) {
|
||||
NF_New(np);
|
||||
np->combiner = CD_AddSource(cd, np->hostname, np->ip);
|
||||
}
|
||||
|
||||
(void)TODO_Run(NULL, tdl);
|
||||
|
||||
return (0);
|
||||
}
|
11
ntimed.h
11
ntimed.h
|
@ -103,15 +103,8 @@ void Time_Sim_Bump(struct todolist *, double when, double freq, double phase);
|
|||
|
||||
/* time_unix.c -- UNIX timebase ***************************************/
|
||||
|
||||
//void Time_Unix(struct todolist *);
|
||||
//void Time_Unix_Passive(void);
|
||||
|
||||
/* time_amiga.c -- Amiga timebase *************************************/
|
||||
|
||||
void Time_Amiga(struct todolist *);
|
||||
void Time_Amiga_Passive(void);
|
||||
|
||||
/**********************************************************************/
|
||||
void Time_Unix(struct todolist *);
|
||||
void Time_Unix_Passive(void);
|
||||
|
||||
/* time_stuff.c -- Timebase infrastructure ****************************/
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define ARGSFORMAT "P=PARAM/K,T=TRACEFILE/K,Z=TIMEZONE/K,SERVERS/M,SYNC/S,SAVE/S,QUIET/S"
|
||||
|
||||
#ifdef AOS3
|
||||
#define ARGPTR STRPTR
|
||||
#define ARGS_FORMAT ARGSFORMAT
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2015 Carsten Larsen
|
||||
* Copyright (c) 2014 Poul-Henning Kamp
|
||||
* All rights reserved.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue