Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / sntp / networking.h
blobd17239f9d5d4f1be26fdba27d7a2fbed41cca3f5
1 /* $NetBSD$ */
3 #ifndef NETWORKING_H
4 #define NETWORKING_H
6 #include <arpa/inet.h>
7 #include <netinet/in.h>
9 #include <strings.h>
10 #include <errno.h>
11 #include <config.h>
12 #include <netdb.h>
13 #include <unistd.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>
21 #include <ntp_fp.h>
22 #include <ntp.h>
24 #include "crypto.h"
25 #include "log.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
38 /* From ntpdate.c */
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 */
56 struct speer {
57 struct speer *next;
58 sockaddr_u srcadr;
59 u_char version;
60 u_char hmode;
61 u_char hpoll;
62 u_char minpoll;
63 u_char maxpoll;
64 u_int flags;
65 u_char num_events;
66 u_char ttl;
67 u_char leap;
68 u_char pmode;
69 u_char stratum;
70 u_char ppoll;
71 u_char precision; /* should be s_char */
72 u_int32 refid;
73 l_fp reftime;
74 keyid_t keyid;
76 #ifdef OPENSSL
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 */
104 #else /* OPENSSL */
105 #define clear_to_zero status
106 #endif /* OPENSSL */
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 */
121 #endif