5 #include <netinet/in.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
15 #include <ntp_rfc2553.h>
16 #include <ntp_stdlib.h>
17 #include <ntp_machine.h>
18 #include <ntp_unixtime.h>
24 #include "sntp-opts.h"
25 #include "utilities.h"
27 /* FIXME To be replaced by the constants in ntp.h */
28 #define SERVER_UNUSEABLE -1 /* Skip server */
29 #define PACKET_UNUSEABLE -2 /* Discard packet and try to get a useable packet again if not tried too often */
30 #define SERVER_AUTH_FAIL -3 /* Authentication failed, act upon settings */
31 #define KOD_DEMOBILIZE -4 /* KOD packet with code DENY or RSTR, stop all communication and save KOD information */
32 #define KOD_RATE -5 /* KOD packet with code RATE, reduce poll intervall */
33 #define BROADCAST_FAILED -6
36 int sendpkt(SOCKET rsock, sockaddr_u *dest, struct pkt *pkt, int len);
37 int recvdata(SOCKET rsock, sockaddr_u *sender, void *rdata,
39 int recvpkt(SOCKET rsock, struct pkt *rpkt, unsigned int rsize,
41 int process_pkt(struct pkt *rpkt, sockaddr_u *sas, int pkt_len,
42 int mode, struct pkt *spkt, const char *func_name);
44 /* Shortened peer structure. Not absolutely necessary yet */
60 u_char precision; /* should be s_char */
66 #define clear_to_zero opcode
67 u_int32 opcode; /* last request opcode */
68 associd_t assoc; /* peer association ID */
69 u_int32 crypto; /* peer status word */
70 EVP_PKEY *pkey; /* public key */
71 const EVP_MD *digest; /* message digest algorithm */
72 char *subject; /* certificate subject name */
73 char *issuer; /* certificate issuer name */
74 struct cert_info *xinfo; /* issuer certificate */
75 keyid_t pkeyid; /* previous key ID */
76 keyid_t hcookie; /* host cookie */
77 keyid_t pcookie; /* peer cookie */
78 const struct pkey_info *ident_pkey; /* identity key */
79 BIGNUM *iffval; /* identity challenge (IFF, GQ, MV) */
80 const BIGNUM *grpkey; /* identity challenge key (GQ) */
81 struct value cookval; /* receive cookie values */
82 struct value recval; /* receive autokey values */
83 struct exten *cmmd; /* extension pointer */
84 u_long refresh; /* next refresh epoch */
87 * Variables used by authenticated server
89 keyid_t *keylist; /* session key ID list */
90 int keynumber; /* current key number */
91 struct value encrypt; /* send encrypt values */
92 struct value sndval; /* send autokey values */
93 #else /* !AUTOKEY follows */
94 #define clear_to_zero status
97 l_fp rec; /* receive time stamp */
98 l_fp xmt; /* transmit time stamp */
99 l_fp dst; /* destination timestamp */
100 l_fp aorg; /* origin timestamp */
101 l_fp borg; /* alternate origin timestamp */
102 double offset; /* peer clock offset */
103 double delay; /* peer roundtrip delay */