-
Notifications
You must be signed in to change notification settings - Fork 0
/
hc_ntp.h
70 lines (61 loc) · 1.86 KB
/
hc_ntp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* houseclock - A simple GPS Time Server with Web console
*
* Copyright 2019, Pascal Martin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*
* hc_ntp.h - The NTP server implementation.
*/
#include <arpa/inet.h>
#include <netdb.h>
const char *hc_ntp_help (int level);
int hc_ntp_initialize (int argc, const char **argv);
void hc_ntp_process (const struct timeval *receive);
void hc_ntp_periodic (const struct timeval *now);
#define HC_NTP_DEPTH 128
#define HC_NTP_POOL 4
#define HC_NTP_STATUS "NtpStatus"
struct hc_ntp_traffic {
int received;
int client;
int broadcast;
time_t timestamp;
};
struct hc_ntp_client {
struct sockaddr_in address;
struct timeval origin;
struct timeval local;
int logged;
};
struct hc_ntp_server {
struct timeval origin;
struct timeval local;
short stratum;
struct sockaddr_in address;
char name[48];
int logged;
};
typedef struct {
char mode;
int8_t source;
short stratum;
struct hc_ntp_server pool[HC_NTP_POOL];
struct hc_ntp_traffic live;
struct hc_ntp_traffic latest;
struct hc_ntp_traffic history[HC_NTP_DEPTH];
struct hc_ntp_client clients[HC_NTP_DEPTH];
} hc_ntp_status;