7 #include <netinet/in.h>
14 #include <sys/types.h>
15 #include <sys/socket.h>
17 #include <ntp_rfc2553.h>
18 #include <ntp_stdlib.h>
19 #include <ntp_machine.h>
20 #include <ntp_unixtime.h>
26 #include "sntp-opts.h"
27 #include "utilities.h"
29 /* FIXME To be replaced by the constants in ntp.h */
30 #define SERVER_UNUSEABLE -1 /* Skip server */
31 #define PACKET_UNUSEABLE -2 /* Discard packet and try to get a useable packet again if not tried too often */
32 #define SERVER_AUTH_FAIL -3 /* Authentication failed, act upon settings */
33 #define KOD_DEMOBILIZE -4 /* KOD packet with code DENY or RSTR, stop all communication and save KOD information */
34 #define KOD_RATE -5 /* KOD packet with code RATE, reduce poll intervall */
35 #define BROADCAST_FAILED -6
39 int is_reachable (struct addrinfo
*dst
);
41 int resolve_hosts (char **hosts
, int hostc
, struct addrinfo
***res
, int pref_family
);
43 void create_socket (SOCKET
*rsock
, sockaddr_u
*dest
);
45 void sendpkt (SOCKET rsock
, sockaddr_u
*dest
, struct pkt
*pkt
, int len
);
47 int recvdata (SOCKET rsock
, sockaddr_u
*sender
, char *rdata
, int rdata_len
);
49 int recvpkt (SOCKET rsock
, struct pkt
*rpkt
, struct pkt
*spkt
);
51 int recv_bcst_data (SOCKET rsock
, char *rdata
, int rdata_len
, sockaddr_u
*sas
, sockaddr_u
*ras
);
53 int recv_bcst_pkt (SOCKET rsock
, struct pkt
*rpkt
, sockaddr_u
*sas
);
55 /* Shortened peer structure. Not absolutely necessary yet */
71 u_char precision
; /* should be s_char */
77 #define clear_to_zero opcode
78 u_int32 opcode
; /* last request opcode */
79 associd_t assoc
; /* peer association ID */
80 u_int32 crypto
; /* peer status word */
81 EVP_PKEY
*pkey
; /* public key */
82 const EVP_MD
*digest
; /* message digest algorithm */
83 char *subject
; /* certificate subject name */
84 char *issuer
; /* certificate issuer name */
85 struct cert_info
*xinfo
; /* issuer certificate */
86 keyid_t pkeyid
; /* previous key ID */
87 keyid_t hcookie
; /* host cookie */
88 keyid_t pcookie
; /* peer cookie */
89 const struct pkey_info
*ident_pkey
; /* identity key */
90 BIGNUM
*iffval
; /* identity challenge (IFF, GQ, MV) */
91 const BIGNUM
*grpkey
; /* identity challenge key (GQ) */
92 struct value cookval
; /* receive cookie values */
93 struct value recval
; /* receive autokey values */
94 struct exten
*cmmd
; /* extension pointer */
95 u_long refresh
; /* next refresh epoch */
98 * Variables used by authenticated server
100 keyid_t
*keylist
; /* session key ID list */
101 int keynumber
; /* current key number */
102 struct value encrypt
; /* send encrypt values */
103 struct value sndval
; /* send autokey values */
105 #define clear_to_zero status
108 l_fp rec
; /* receive time stamp */
109 l_fp xmt
; /* transmit time stamp */
110 l_fp dst
; /* destination timestamp */
111 l_fp aorg
; /* origin timestamp */
112 l_fp borg
; /* alternate origin timestamp */
113 double offset
; /* peer clock offset */
114 double delay
; /* peer roundtrip delay */