libptpmgmt  1.4
libptpmgmt library that provides the functionality of linuxptp pmc
ptp.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-3.0-or-later
2  SPDX-FileCopyrightText: Copyright © 2023 Erez Geva <ErezGeva2@gmail.com> */
3 
12 #ifndef __PTPMGMT_C_IF_H
13 #define __PTPMGMT_C_IF_H
14 
15 #include "name.h"
16 #ifdef __PTPMGMT_HAVE_SYS_TYPES_H
17 #include <sys/types.h>
18 #else
20 typedef int clockid_t;
22 #endif /* __PTPMGMT_HAVE_SYS_TYPES_H */
23 #include <time.h>
24 #ifdef __linux__
25 #include <linux/ptp_clock.h>
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
34 
36 typedef const struct ptpmgmt_ifInfo_t *const_ptpmgmt_ifInfo;
37 
44  void *_this;
50  void (*free)(ptpmgmt_ifInfo i);
57  bool (*initUsingName)(ptpmgmt_ifInfo i, const char *ifName);
82  const char *(*ifName)(const_ptpmgmt_ifInfo i);
88  const uint8_t *(*mac)(const_ptpmgmt_ifInfo i);
104 };
105 
111 
114 
116 typedef const struct ptpmgmt_clock_t *const_ptpmgmt_clock;
117 
124  void *_this;
131  void (*free)(ptpmgmt_clock clk);
132 
138  struct timespec(*getTime)(const_ptpmgmt_clock clk);
145  bool (*setTime)(const_ptpmgmt_clock clk, const struct timespec *ts);
152  bool (*offsetClock)(const_ptpmgmt_clock clk, int64_t offset);
158  double (*getFreq)(const_ptpmgmt_clock clk);
165  bool (*setFreq)(const_ptpmgmt_clock clk, double freq);
172  bool (*setPhase)(const_ptpmgmt_clock clk, int64_t offset);
179  bool (*isCharFile)(const char *file);
187  bool (*initUsingDevice)(ptpmgmt_clock clk, const char *device, bool readonly);
195  bool (*initUsingIndex)(ptpmgmt_clock clk, int ptpIndex, bool readonly);
207  clockid_t (*clkId)(const_ptpmgmt_clock clk);
232  const char *(*device)(const_ptpmgmt_clock clk);
251  bool (*fetchCaps)(const_ptpmgmt_clock clk, struct ptp_clock_caps *caps);
260  bool (*readPin)(const_ptpmgmt_clock clk, unsigned int index,
261  struct ptp_pin_desc *pin);
270  bool (*writePin)(const_ptpmgmt_clock clk, struct ptp_pin_desc *pin);
280  bool (*ExternTSEbable)(const_ptpmgmt_clock clk, unsigned int index,
281  uint8_t flags);
289  bool (*ExternTSDisable)(const_ptpmgmt_clock clk, unsigned int index);
303  bool (*MaskEnable)(const_ptpmgmt_clock clk, unsigned int index);
310  bool (*readEvent)(const_ptpmgmt_clock clk, struct ptp_extts_event *event);
319  bool (*readEvents)(const_ptpmgmt_clock clk, struct ptp_extts_event *events,
320  size_t *size);
330  bool (*setPinPeriod)(const_ptpmgmt_clock clk, unsigned int index,
331  struct ptp_perout_request *times);
340  bool (*setPtpPpsEvent)(const_ptpmgmt_clock clk, bool enable);
349  bool (*samplePtpSys)(const_ptpmgmt_clock clk, size_t count,
350  struct ptp_sys_offset *samples);
360  bool (*extSamplePtpSys)(const_ptpmgmt_clock clk, size_t count,
361  struct ptp_sys_offset_extended *samples);
370  struct ptp_sys_offset_precise *sample);
371 };
372 
379 bool ptpmgmt_clock_isCharFile(const char *file);
380 
386 
392 
393 #ifdef __cplusplus
394 }
395 #endif
396 
397 #endif /* __PTPMGMT_C_IF_H */
ptpmgmt_clock ptpmgmt_clock_alloc_sys()
const struct ptpmgmt_ifInfo_t * const_ptpmgmt_ifInfo
Definition: ptp.h:36
struct ptpmgmt_ifInfo_t * ptpmgmt_ifInfo
Definition: ptp.h:33
bool ptpmgmt_clock_isCharFile(const char *file)
struct ptpmgmt_clock_t * ptpmgmt_clock
Definition: ptp.h:113
ptpmgmt_clock ptpmgmt_clock_alloc()
const struct ptpmgmt_clock_t * const_ptpmgmt_clock
Definition: ptp.h:116
ptpmgmt_ifInfo ptpmgmt_ifInfo_alloc()
Define name space.
Definition: ptp.h:122
bool(* ExternTSDisable)(const_ptpmgmt_clock clk, unsigned int index)
Definition: ptp.h:289
bool(* setTime)(const_ptpmgmt_clock clk, const struct timespec *ts)
Definition: ptp.h:145
bool(* initUsingIndex)(ptpmgmt_clock clk, int ptpIndex, bool readonly)
Definition: ptp.h:195
bool(* readPin)(const_ptpmgmt_clock clk, unsigned int index, struct ptp_pin_desc *pin)
Definition: ptp.h:260
bool(* initUsingDevice)(ptpmgmt_clock clk, const char *device, bool readonly)
Definition: ptp.h:187
bool(* readEvents)(const_ptpmgmt_clock clk, struct ptp_extts_event *events, size_t *size)
Definition: ptp.h:319
bool(* samplePtpSys)(const_ptpmgmt_clock clk, size_t count, struct ptp_sys_offset *samples)
Definition: ptp.h:349
bool(* readEvent)(const_ptpmgmt_clock clk, struct ptp_extts_event *event)
Definition: ptp.h:310
bool(* fetchCaps)(const_ptpmgmt_clock clk, struct ptp_clock_caps *caps)
Definition: ptp.h:251
bool(* setTimeFromSys)(const_ptpmgmt_clock clk)
Definition: ptp.h:238
bool(* extSamplePtpSys)(const_ptpmgmt_clock clk, size_t count, struct ptp_sys_offset_extended *samples)
Definition: ptp.h:360
void(* free)(ptpmgmt_clock clk)
Definition: ptp.h:131
const char *(* device)(const_ptpmgmt_clock clk)
Definition: ptp.h:232
bool(* setTimeToSys)(const_ptpmgmt_clock clk)
Definition: ptp.h:244
bool(* ExternTSEbable)(const_ptpmgmt_clock clk, unsigned int index, uint8_t flags)
Definition: ptp.h:280
bool(* writePin)(const_ptpmgmt_clock clk, struct ptp_pin_desc *pin)
Definition: ptp.h:270
int(* ptpIndex)(const_ptpmgmt_clock clk)
Definition: ptp.h:226
bool(* isInit)(const_ptpmgmt_clock clk)
Definition: ptp.h:201
bool(* setFreq)(const_ptpmgmt_clock clk, double freq)
Definition: ptp.h:165
int(* getFd)(const_ptpmgmt_clock clk)
Definition: ptp.h:213
int(* fileno)(const_ptpmgmt_clock clk)
Definition: ptp.h:219
double(* getFreq)(const_ptpmgmt_clock clk)
Definition: ptp.h:158
struct timespec(* getTime)(const_ptpmgmt_clock clk)
Definition: ptp.h:138
bool(* setPinPeriod)(const_ptpmgmt_clock clk, unsigned int index, struct ptp_perout_request *times)
Definition: ptp.h:330
bool(* MaskEnable)(const_ptpmgmt_clock clk, unsigned int index)
Definition: ptp.h:303
bool(* setPtpPpsEvent)(const_ptpmgmt_clock clk, bool enable)
Definition: ptp.h:340
bool(* setPhase)(const_ptpmgmt_clock clk, int64_t offset)
Definition: ptp.h:172
bool(* isCharFile)(const char *file)
Definition: ptp.h:179
bool(* offsetClock)(const_ptpmgmt_clock clk, int64_t offset)
Definition: ptp.h:152
clockid_t(* clkId)(const_ptpmgmt_clock clk)
Definition: ptp.h:207
bool(* MaskClearAll)(const_ptpmgmt_clock clk)
Definition: ptp.h:295
bool(* preciseSamplePtpSys)(const_ptpmgmt_clock clk, struct ptp_sys_offset_precise *sample)
Definition: ptp.h:369
Definition: ptp.h:42
bool(* initUsingIndex)(ptpmgmt_ifInfo i, int ifIndex)
Definition: ptp.h:64
const char *(* ifName)(const_ptpmgmt_ifInfo i)
Definition: ptp.h:82
bool(* isInit)(const_ptpmgmt_ifInfo i)
Definition: ptp.h:70
bool(* initUsingName)(ptpmgmt_ifInfo i, const char *ifName)
Definition: ptp.h:57
int(* ptpIndex)(const_ptpmgmt_ifInfo i)
Definition: ptp.h:103
size_t(* mac_size)(const_ptpmgmt_ifInfo i)
Definition: ptp.h:94
void(* free)(ptpmgmt_ifInfo i)
Definition: ptp.h:50
int(* ifIndex)(const_ptpmgmt_ifInfo i)
Definition: ptp.h:76