PageRenderTime 30ms CodeModel.GetById 12ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/include/ntpsim.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 93 lines | 68 code | 13 blank | 12 comment | 0 complexity | 62072af40c5a2c1e3cae6c5b62865533 MD5 | raw file
 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 */
27typedef enum {
28        BEEP, CLOCK, TIMER, PACKET
29} funcTkn;
30
31typedef 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
42typedef struct List {
43        Event event;
44        struct List *next;
45} *Queue;
46
47typedef 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 */
70int	ntpsim		P((int argc, char *argv[]));
71Event	event		P((double, funcTkn));
72Queue	queue		P((Event, Queue ));
73Node	node		P((void));
74void	push		P((Event, Queue *));
75Event	pop		P((Queue *));
76void	ndbeep		P((Node *, Event));
77void	ndeclk		P((Node *, Event));
78void	ntptmr		P((Node *, Event));
79void	netpkt		P((Node *, Event));
80int	srvr_rply	P((Node *, struct sockaddr_storage *,
81			    struct interface *, struct pkt *));
82double	gauss		P((double, double));
83double	poisson		P((double, double));
84int	node_clock	P((Node *, double));
85void	abortsim	P((char *));
86
87/*
88 * The global Node
89 */
90Node ntp_node;
91
92#endif
93