forked from richardcochran/linuxptp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmc_agent.h
89 lines (75 loc) · 3.16 KB
/
pmc_agent.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* @file pmc_agent.h
* @brief Client code for making PTP management requests.
* @note Copyright (C) 2013 Miroslav Lichvar <[email protected]>
* @note Copyright (C) 2020 Richard Cochran <[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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef HAVE_PMC_AGENT_H
#define HAVE_PMC_AGENT_H
#include <stdbool.h>
#include "pmc_common.h"
struct pmc_agent;
typedef int pmc_node_recv_subscribed_t(void *context, struct ptp_message *msg,
int excluded);
int init_pmc_node(struct config *cfg, struct pmc_agent *agent, const char *uds,
pmc_node_recv_subscribed_t *recv_subscribed, void *context);
int update_pmc_node(struct pmc_agent *agent, int subscribe);
int run_pmc_subscribe(struct pmc_agent *agent, int timeout);
int run_pmc_clock_identity(struct pmc_agent *agent, int timeout);
int run_pmc_wait_sync(struct pmc_agent *agent, int timeout);
int run_pmc_get_number_ports(struct pmc_agent *agent, int timeout);
void run_pmc_events(struct pmc_agent *agent);
int run_pmc_port_properties(struct pmc_agent *agent, int timeout,
unsigned int port, int *state,
int *tstamping, char *iface);
int run_pmc_get_utc_offset(struct pmc_agent *agent, int timeout);
void *get_mgt_data(struct ptp_message *msg);
/**
* Creates an instance of a PMC agent.
* @return Pointer to a PMC instance on success, NULL otherwise.
*/
struct pmc_agent *pmc_agent_create(void);
/**
* Destroys an instance of a PMC agent.
* @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
*/
void pmc_agent_destroy(struct pmc_agent *agent);
/**
* Gets the current leap adjustment.
* @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
* @return The leap adjustment in seconds, either 1, 0, or -1.
*/
int pmc_agent_get_leap(struct pmc_agent *agent);
/**
* Gets the TAI-UTC offset.
* @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
* @return Current offset in seconds.
*/
int pmc_agent_get_sync_offset(struct pmc_agent *agent);
/**
* Sets the TAI-UTC offset.
* @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
* @param offset Desired offset in seconds.
*/
void pmc_agent_set_sync_offset(struct pmc_agent *agent, int offset);
/**
* Tests whether the current UTC offset is traceable.
* @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
* @return True is the offset is traceable, false otherwise.
*/
bool pmc_agent_utc_offset_traceable(struct pmc_agent *agent);
#endif