#ifndef NETWORKING_H
#define NETWORKING_H
#include <arpa/inet.h>
#include <netinet/in.h>
#include <strings.h>
#include <errno.h>
#include <config.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ntp_rfc2553.h>
#include <ntp_stdlib.h>
#include <ntp_machine.h>
#include <ntp_unixtime.h>
#include <ntp_fp.h>
#include <ntp.h>
#include "crypto.h"
#include "log.h"
#include "sntp-opts.h"
#include "utilities.h"
#define SERVER_UNUSEABLE -1
#define PACKET_UNUSEABLE -2
#define SERVER_AUTH_FAIL -3
#define KOD_DEMOBILIZE -4
#define KOD_RATE -5
#define BROADCAST_FAILED -6
int sendpkt(SOCKET rsock, sockaddr_u *dest, struct pkt *pkt, int len);
int recvdata(SOCKET rsock, struct timeval timeout, sockaddr_u *sender, void *rdata,
int rdata_len);
int recvpkt(SOCKET rsock, struct timeval timeout, struct pkt *rpkt, unsigned int rsize,
struct pkt *spkt);
int process_pkt(struct pkt *rpkt, sockaddr_u *sas, int pkt_len,
int mode, struct pkt *spkt, const char *func_name);
struct speer {
struct speer *next;
sockaddr_u srcadr;
u_char version;
u_char hmode;
u_char hpoll;
u_char minpoll;
u_char maxpoll;
u_int flags;
u_char num_events;
u_char ttl;
u_char leap;
u_char pmode;
u_char stratum;
u_char ppoll;
u_char precision;
u_int32 refid;
l_fp reftime;
keyid_t keyid;
#ifdef AUTOKEY
#define clear_to_zero opcode
u_int32 opcode;
associd_t assoc;
u_int32 crypto;
EVP_PKEY *pkey;
const EVP_MD *digest;
char *subject;
char *issuer;
struct cert_info *xinfo;
keyid_t pkeyid;
keyid_t hcookie;
keyid_t pcookie;
const struct pkey_info *ident_pkey;
BIGNUM *iffval;
const BIGNUM *grpkey;
struct value cookval;
struct value recval;
struct exten *cmmd;
u_long refresh;
keyid_t *keylist;
int keynumber;
struct value encrypt;
struct value sndval;
#else
#define clear_to_zero status
#endif
l_fp rec;
l_fp xmt;
l_fp dst;
l_fp aorg;
l_fp borg;
double offset;
double delay;
};
#endif