-
Notifications
You must be signed in to change notification settings - Fork 9
/
sender.h
62 lines (54 loc) · 1.48 KB
/
sender.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
/*
* Copyright (C) 2018 Miroslav Lichvar <[email protected]>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef SENDER_H
#define SENDER_H
#include <limits.h>
#include <time.h>
#include <stdbool.h>
#include <stdint.h>
#define MAX_SENDER_REQUESTS (PIPE_BUF / sizeof (struct sender_request))
enum request_mode {
INVALID_MODE,
NTP_BASIC,
NTP_INTERLEAVED,
PTP_DELAY,
PTP_NSM,
};
struct sender_config {
int sock_fd;
enum request_mode mode;
char src_mac[6];
char dst_mac[6];
uint32_t dst_address;
int ptp_domain;
int ptp_mcast;
struct {
const char *c2s;
const char *cookie;
} nts;
};
struct sender_request {
struct timespec when;
uint32_t src_address;
uint32_t _pad;
uint64_t remote_id;
uint64_t local_id;
};
int sender_start(struct sender_config *config);
bool sender_send_requests(int sender_fd, struct sender_request *requests, int num);
void sender_stop(int sender_fd);
#endif