libptpmgmt  1.4
libptpmgmt library that provides the functionality of linuxptp pmc
sock.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_SOCK_H
13 #define __PTPMGMT_C_SOCK_H
14 
15 #include "name.h"
16 #ifdef __PTPMGMT_HAVE_SYS_TYPES_H
17 #include <sys/types.h>
18 #else
20 typedef long ssize_t;
22 #endif /* __PTPMGMT_HAVE_SYS_TYPES_H */
23 #include "c/cfg.h"
24 #include "c/ptp.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
31 typedef struct ptpmgmt_sk_t *ptpmgmt_sk;
32 
34 typedef const struct ptpmgmt_sk_t *const_ptpmgmt_sk;
35 
40 struct ptpmgmt_sk_t {
42  void *_this;
49  void (*free)(ptpmgmt_sk sk);
50 
55  void (*close)(ptpmgmt_sk sk);
61  bool (*init)(ptpmgmt_sk sk);
71  bool (*send)(ptpmgmt_sk sk, const void *msg, size_t len);
82  ssize_t (*rcv)(ptpmgmt_sk sk, void *buf, size_t bufSize, bool block);
91  int (*getFd)(const_ptpmgmt_sk sk);
111  bool (*poll)(ptpmgmt_sk sk, uint64_t timeout_ms);
122  bool (*tpoll)(ptpmgmt_sk sk, uint64_t *timeout_ms);
128  const char *(*getPeerAddress)(const_ptpmgmt_sk sk);
141  bool (*setPeerAddress)(ptpmgmt_sk sk, const char *string);
150  bool (*setPeerAddressAbstract)(ptpmgmt_sk sk, const char *string);
160  const char *section);
166  const char *(*getSelfAddress)(const_ptpmgmt_sk sk);
182  bool (*setSelfAddress)(ptpmgmt_sk sk, const char *string);
194  bool (*setSelfAddressAbstract)(ptpmgmt_sk sk, const char *string);
205  bool (*setDefSelfAddress)(ptpmgmt_sk sk, const char *rootBase,
206  const char *useDef);
212  const char *(*getHomeDir)(ptpmgmt_sk sk);
223  bool (*sendTo)(ptpmgmt_sk sk, const void *msg, size_t len,
224  const char *addrStr);
237  bool (*sendToA)(ptpmgmt_sk sk, const void *msg, size_t len,
238  const char *addrStr);
253  ssize_t (*rcvFrom)(ptpmgmt_sk sk, void *buf, size_t bufSize, char *from,
254  size_t *fromSize, bool block);
266  ssize_t (*rcvFromA)(ptpmgmt_sk sk, void *buf, size_t bufSize, bool block);
275  const char *(*getLastFrom)(const_ptpmgmt_sk sk);
291  bool (*setIfUsingName)(ptpmgmt_sk sk, const char *ifName);
301  bool (*setIfUsingIndex)(ptpmgmt_sk sk, int ifIndex);
326  const_ptpmgmt_cfg cfg, const char *section);
341  const_ptpmgmt_cfg cfg, const char *section);
352  bool (*setUdpTtl)(ptpmgmt_sk sk, uint8_t udp_ttl);
366  const char *section);
376  bool (*setScope)(ptpmgmt_sk sk, uint8_t udp6_scope);
389  const char *section);
401  bool (*setPtpDstMacStr)(ptpmgmt_sk sk, const char *string);
412  bool (*setPtpDstMac)(ptpmgmt_sk sk, const void *ptp_dst_mac,
413  size_t len);
426  const char *section);
438  bool (*setSocketPriority)(ptpmgmt_sk sk, uint8_t socket_priority);
451  const char *section);
452 };
453 
458  ptpmgmt_SockUnix,
459  ptpmgmt_SockIp4,
460  ptpmgmt_SockIp6,
461  ptpmgmt_SockRaw,
462 };
463 
471 
472 #ifdef __cplusplus
473 }
474 #endif
475 
476 #endif /* __PTPMGMT_C_SOCK_H */
C interface to configuration class.
C interface to network and PHC classes.
ptpmgmt_sk ptpmgmt_sk_alloc(enum ptpmgmt_socket_class type)
struct ptpmgmt_sk_t * ptpmgmt_sk
Definition: sock.h:31
ptpmgmt_socket_class
Definition: sock.h:457
const struct ptpmgmt_sk_t * const_ptpmgmt_sk
Definition: sock.h:34
Define name space.
Definition: cfg.h:44
Definition: ptp.h:42
Definition: sock.h:40
bool(* setPeerAddress)(ptpmgmt_sk sk, const char *string)
Definition: sock.h:141
bool(* setPeerAddressAbstract)(ptpmgmt_sk sk, const char *string)
Definition: sock.h:150
bool(* setUdpTtlCfg)(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:365
int(* getFd)(const_ptpmgmt_sk sk)
Definition: sock.h:91
bool(* setPtpDstMac)(ptpmgmt_sk sk, const void *ptp_dst_mac, size_t len)
Definition: sock.h:412
bool(* isSelfAddressAbstract)(const_ptpmgmt_sk sk)
Definition: sock.h:172
bool(* setPtpDstMacCfg)(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:425
void(* close)(ptpmgmt_sk sk)
Definition: sock.h:55
bool(* sendToA)(ptpmgmt_sk sk, const void *msg, size_t len, const char *addrStr)
Definition: sock.h:237
bool(* setSocketPriorityCfg)(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:450
bool(* setSelfAddress)(ptpmgmt_sk sk, const char *string)
Definition: sock.h:182
bool(* init)(ptpmgmt_sk sk)
Definition: sock.h:61
bool(* setIfUsingName)(ptpmgmt_sk sk, const char *ifName)
Definition: sock.h:291
bool(* setAll)(ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:325
bool(* setPeerAddressCfg)(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:159
ssize_t(* rcvFrom)(ptpmgmt_sk sk, void *buf, size_t bufSize, char *from, size_t *fromSize, bool block)
Definition: sock.h:253
bool(* setAllInit)(ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:340
bool(* isLastFromAbstract)(const_ptpmgmt_sk sk)
Definition: sock.h:281
bool(* setDefSelfAddress)(ptpmgmt_sk sk, const char *rootBase, const char *useDef)
Definition: sock.h:205
bool(* tpoll)(ptpmgmt_sk sk, uint64_t *timeout_ms)
Definition: sock.h:122
bool(* sendTo)(ptpmgmt_sk sk, const void *msg, size_t len, const char *addrStr)
Definition: sock.h:223
bool(* isPeerAddressAbstract)(const_ptpmgmt_sk sk)
Definition: sock.h:134
ssize_t(* rcv)(ptpmgmt_sk sk, void *buf, size_t bufSize, bool block)
Definition: sock.h:82
bool(* setScope)(ptpmgmt_sk sk, uint8_t udp6_scope)
Definition: sock.h:376
bool(* setPtpDstMacStr)(ptpmgmt_sk sk, const char *string)
Definition: sock.h:401
bool(* setScopeCfg)(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
Definition: sock.h:388
bool(* setIf)(ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj)
Definition: sock.h:311
int(* fileno)(const_ptpmgmt_sk sk)
Definition: sock.h:100
bool(* setUdpTtl)(ptpmgmt_sk sk, uint8_t udp_ttl)
Definition: sock.h:352
bool(* send)(ptpmgmt_sk sk, const void *msg, size_t len)
Definition: sock.h:71
bool(* setSelfAddressAbstract)(ptpmgmt_sk sk, const char *string)
Definition: sock.h:194
bool(* setSocketPriority)(ptpmgmt_sk sk, uint8_t socket_priority)
Definition: sock.h:438
void(* free)(ptpmgmt_sk sk)
Definition: sock.h:49
bool(* poll)(ptpmgmt_sk sk, uint64_t timeout_ms)
Definition: sock.h:111
bool(* setIfUsingIndex)(ptpmgmt_sk sk, int ifIndex)
Definition: sock.h:301
ssize_t(* rcvFromA)(ptpmgmt_sk sk, void *buf, size_t bufSize, bool block)
Definition: sock.h:266