xref: /freebsd/contrib/ntp/include/ntpsim.h (revision c98323078dede7579020518ec84cdcb478e5c142)
1 /*
2  * ntpsim.h - Prototypes for ntpsim
3  */
4 
5 #ifndef __ntpsim_h
6 #define __ntpsim_h
7 
8 #include <stdio.h>
9 #include <math.h>
10 #include <sys/socket.h>
11 #include <arpa/inet.h>
12 #include "ntp_syslog.h"
13 #include "ntp_fp.h"
14 #include "ntp.h"
15 #include "ntp_select.h"
16 #include "ntp_malloc.h"
17 #include "ntp_refclock.h"
18 #include "recvbuff.h"
19 #include "ntp_io.h"
20 #include "ntp_stdlib.h"
21 
22 #define PI 3.1415926535
23 
24 /*
25  * ntpsim declarations
26  */
27 typedef enum {
28         BEEP, CLOCK, TIMER, PACKET
29 } funcTkn;
30 
31 typedef struct {
32         double time;
33         union {
34                 struct pkt evnt_pkt;
35 		struct recvbuf evnt_buf;
36         } buffer;
37 #define ntp_pkt buffer.evnt_pkt
38 #define rcv_buf buffer.evnt_buf
39         funcTkn function;
40 } Event;
41 
42 typedef struct List {
43         Event event;
44         struct List *next;
45 } *Queue;
46 
47 typedef struct nde {
48         double	time;			/* simulation time */
49 	double	sim_time;		/* end simulation time */
50 	double	ntp_time;		/* client disciplined time */
51 	double	adj;			/* remaining time correction */
52 	double	slew;			/* correction slew rate */
53 
54 	double	clk_time;		/* server time */
55 	double	ferr;			/* frequency errort */
56 	double	fnse;			/* random walk noise */
57 	double	ndly;			/* network delay */
58 	double	snse;			/* phase noise */
59 	double	pdly;			/* processing delay */
60 	double	bdly;			/* beep interval */
61 
62 	double	last_time;		/* last clock read time */
63         Queue	events;			/* Node Event Queue */
64 	struct recvbuf *rbuflist;	/* Node Receive Buffer */
65 } Node;
66 
67 /*
68  * Function prototypes
69  */
70 int	ntpsim		P((int argc, char *argv[]));
71 Event	event		P((double, funcTkn));
72 Queue	queue		P((Event, Queue ));
73 Node	node		P((void));
74 void	push		P((Event, Queue *));
75 Event	pop		P((Queue *));
76 void	ndbeep		P((Node *, Event));
77 void	ndeclk		P((Node *, Event));
78 void	ntptmr		P((Node *, Event));
79 void	netpkt		P((Node *, Event));
80 int	srvr_rply	P((Node *, struct sockaddr_storage *,
81 			    struct interface *, struct pkt *));
82 double	gauss		P((double, double));
83 double	poisson		P((double, double));
84 int	node_clock	P((Node *, double));
85 void	abortsim	P((char *));
86 
87 /*
88  * The global Node
89  */
90 Node ntp_node;
91 
92 #endif
93 
94