libptpmgmt  1.3
libptpmgmt library that provides the functionality of linuxptp pmc
Public Attributes | List of all members
ptpmgmt_sk_t Struct Reference

#include <sock.h>

Public Attributes

void(* free )(ptpmgmt_sk sk)
 
void(* close )(ptpmgmt_sk sk)
 
bool(* init )(ptpmgmt_sk sk)
 
bool(* send )(ptpmgmt_sk sk, const void *msg, size_t len)
 
ssize_t(* rcv )(ptpmgmt_sk sk, void *buf, size_t bufSize, bool block)
 
int(* getFd )(const_ptpmgmt_sk sk)
 
int(* fileno )(const_ptpmgmt_sk sk)
 
bool(* poll )(ptpmgmt_sk sk, uint64_t timeout_ms)
 
bool(* tpoll )(ptpmgmt_sk sk, uint64_t *timeout_ms)
 
const char *(* getPeerAddress )(const_ptpmgmt_sk sk)
 
bool(* isPeerAddressAbstract )(const_ptpmgmt_sk sk)
 
bool(* setPeerAddress )(ptpmgmt_sk sk, const char *string)
 
bool(* setPeerAddressAbstract )(ptpmgmt_sk sk, const char *string)
 
bool(* setPeerAddressCfg )(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
 
const char *(* getSelfAddress )(const_ptpmgmt_sk sk)
 
bool(* isSelfAddressAbstract )(const_ptpmgmt_sk sk)
 
bool(* setSelfAddress )(ptpmgmt_sk sk, const char *string)
 
bool(* setSelfAddressAbstract )(ptpmgmt_sk sk, const char *string)
 
bool(* setDefSelfAddress )(ptpmgmt_sk sk, const char *rootBase, const char *useDef)
 
const char *(* getHomeDir )(ptpmgmt_sk sk)
 
bool(* sendTo )(ptpmgmt_sk sk, const void *msg, size_t len, const char *addrStr)
 
bool(* sendToA )(ptpmgmt_sk sk, const void *msg, size_t len, const char *addrStr)
 
ssize_t(* rcvFrom )(ptpmgmt_sk sk, void *buf, size_t bufSize, char *from, size_t *fromSize, bool block)
 
ssize_t(* rcvFromA )(ptpmgmt_sk sk, void *buf, size_t bufSize, bool block)
 
const char *(* getLastFrom )(const_ptpmgmt_sk sk)
 
bool(* isLastFromAbstract )(const_ptpmgmt_sk sk)
 
bool(* setIfUsingName )(ptpmgmt_sk sk, const char *ifName)
 
bool(* setIfUsingIndex )(ptpmgmt_sk sk, int ifIndex)
 
bool(* setIf )(ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj)
 
bool(* setAll )(ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj, const_ptpmgmt_cfg cfg, const char *section)
 
bool(* setAllInit )(ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj, const_ptpmgmt_cfg cfg, const char *section)
 
bool(* setUdpTtl )(ptpmgmt_sk sk, uint8_t udp_ttl)
 
bool(* setUdpTtlCfg )(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
 
bool(* setScope )(ptpmgmt_sk sk, uint8_t udp6_scope)
 
bool(* setScopeCfg )(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
 
bool(* setPtpDstMacStr )(ptpmgmt_sk sk, const char *string)
 
bool(* setPtpDstMac )(ptpmgmt_sk sk, const void *ptp_dst_mac, size_t len)
 
bool(* setPtpDstMacCfg )(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
 
bool(* setSocketPriority )(ptpmgmt_sk sk, uint8_t socket_priority)
 
bool(* setSocketPriorityCfg )(ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)
 

Detailed Description

The ptpmgmt socket structure hold the socket object and call backs to call C++ methods

Member Data Documentation

◆ close

void(* ptpmgmt_sk_t::close) (ptpmgmt_sk sk)

close socket and release its resources

Parameters
[in,out]sksocket

◆ fileno

int(* ptpmgmt_sk_t::fileno) (const_ptpmgmt_sk sk)

Get socket file description

Parameters
[in]sksocket
Returns
socket file description
Note
Can be used to poll, send or receive from socket. The user is advice to use properly. Do NOT free the socket. If you want to close the socket use the close function ONLY.

◆ free

void(* ptpmgmt_sk_t::free) (ptpmgmt_sk sk)

< Free a socket object

Parameters
[in,out]sksocket

◆ getFd

int(* ptpmgmt_sk_t::getFd) (const_ptpmgmt_sk sk)

Get socket file description

Parameters
[in]sksocket
Returns
socket file description
Note
Can be used to poll, send or receive from socket. The user is advice to use properly. Do NOT free the socket. If you want to close the socket use the close function ONLY.

◆ getHomeDir

const char*(* ptpmgmt_sk_t::getHomeDir) (ptpmgmt_sk sk)

Get user home directory

Parameters
[in,out]sksocket
Returns
string object with home directory

◆ getLastFrom

const char*(* ptpmgmt_sk_t::getLastFrom) (const_ptpmgmt_sk sk)

Fetch origin address from last rcvFrom() call

Parameters
[in]sksocket
Returns
Unix socket address
Note
store address only on the rcvFrom() call without the from parameter
Attention
no protection or thread safe, fetch last rcvFrom() call with this object.

◆ getPeerAddress

const char*(* ptpmgmt_sk_t::getPeerAddress) (const_ptpmgmt_sk sk)

Get peer address

Parameters
[in]sksocket
Returns
string object with peer address

◆ getSelfAddress

const char*(* ptpmgmt_sk_t::getSelfAddress) (const_ptpmgmt_sk sk)

Get self address

Parameters
[in]sksocket
Returns
string object with self address

◆ init

bool(* ptpmgmt_sk_t::init) (ptpmgmt_sk sk)

Allocate the socket and initialize it with current parameters

Parameters
[in,out]sksocket
Returns
true if socket creation success

◆ isLastFromAbstract

bool(* ptpmgmt_sk_t::isLastFromAbstract) (const_ptpmgmt_sk sk)

Is last from address abstract?

Parameters
[in]sksocket
Returns
true if last from address is abstract address

◆ isPeerAddressAbstract

bool(* ptpmgmt_sk_t::isPeerAddressAbstract) (const_ptpmgmt_sk sk)

Is peer address abstract?

Parameters
[in]sksocket
Returns
true if peer address is abstract address

◆ isSelfAddressAbstract

bool(* ptpmgmt_sk_t::isSelfAddressAbstract) (const_ptpmgmt_sk sk)

Is self address abstract?

Parameters
[in]sksocket
Returns
true if self address is abstract address

◆ poll

bool(* ptpmgmt_sk_t::poll) (ptpmgmt_sk sk, uint64_t timeout_ms)

Single socket polling

Parameters
[in,out]sksocket
[in]timeout_mstimeout in milliseconds, until receive a packet. use 0 for blocking.
Returns
true if a packet is ready for receive
Note
If user need multiple socket, then fetch the file description with fileno() And implement it, or merge it into an existing polling

◆ rcv

ssize_t(* ptpmgmt_sk_t::rcv) (ptpmgmt_sk sk, void *buf, size_t bufSize, bool block)

Receive a message using the socket

Parameters
[in,out]sksocket
[in,out]bufpointer to a memory buffer
[in]bufSizememory buffer size
[in]blocktrue, wait till a packet arrives. false, do not wait, return error if no packet available
Returns
number of bytes received or negative on failure

◆ rcvFrom

ssize_t(* ptpmgmt_sk_t::rcvFrom) (ptpmgmt_sk sk, void *buf, size_t bufSize, char *from, size_t *fromSize, bool block)

Receive a message using the socket from any address

Parameters
[in,out]sksocket
[in,out]bufpointer to a memory buffer
[in]bufSizememory buffer size
[out]fromUnix socket address (socket file)
[in,out]fromSizefrom string buffer size Actual from string size on return
[in]blocktrue, wait till a packet arrives. false, do not wait, return error if no packet available
Returns
number of bytes received or negative on failure
Note
from store the origin address which send the packet

◆ rcvFromA

ssize_t(* ptpmgmt_sk_t::rcvFromA) (ptpmgmt_sk sk, void *buf, size_t bufSize, bool block)

Receive a message using the socket from any address

Parameters
[in,out]sksocket
[in,out]bufpointer to a memory buffer
[in]bufSizememory buffer size
[in]blocktrue, wait till a packet arrives. false, do not wait, return error if no packet available
Returns
number of bytes received or negative on failure
Note
use getLastFrom() to fetch origin address which send the packet

◆ send

bool(* ptpmgmt_sk_t::send) (ptpmgmt_sk sk, const void *msg, size_t len)

Send the message using the socket

Parameters
[in,out]sksocket
[in]msgpointer to message memory buffer
[in]lenmessage length
Returns
true if message is sent
Note
true does NOT guarantee the frame was successfully arrives its target. Only the network layer sends it.

◆ sendTo

bool(* ptpmgmt_sk_t::sendTo) (ptpmgmt_sk sk, const void *msg, size_t len, const char *addrStr)

Send the message using the socket to a specific address

Parameters
[in,out]sksocket
[in]msgpointer to message memory buffer
[in]lenmessage length
[in]addrStrUnix socket address (socket file)
Returns
true if message is sent
Note
true does NOT guarantee the frame was successfully arrives its target. Only the network layer sends it.

◆ sendToA

bool(* ptpmgmt_sk_t::sendToA) (ptpmgmt_sk sk, const void *msg, size_t len, const char *addrStr)

Send the message using the socket to a specific abstract soket address

Parameters
[in,out]sksocket
[in]msgpointer to message memory buffer
[in]lenmessage length
[in]addrStrUnix abstract socket address
Returns
true if message is sent
Note
true does NOT guarantee the frame was successfully arrives its target. Only the network layer sends it.
add '0' byte at the start of the address to mark it as abstract socket address

◆ setAll

bool(* ptpmgmt_sk_t::setAll) (ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj, const_ptpmgmt_cfg cfg, const char *section)

Set all socket parameters using a network interface object and a configuration file

Parameters
[in,out]sksocket
[in]ifObjinitialized network interface object
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if network interface exists and update all parameters.
Note
parameters can not be changed after initializing. User can close the socket, change any of the parameters value and initialize a new socket.
calling without section will fetch value from "global" section

◆ setAllInit

bool(* ptpmgmt_sk_t::setAllInit) (ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj, const_ptpmgmt_cfg cfg, const char *section)

Set all socket parameters using a network interface object and a configuration file and initialize

Parameters
[in,out]sksocket
[in]ifObjinitialized network interface object
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if network interface exists and update all parameters.
Note
parameters can not be changed after initializing. User can close the socket, change any of the parameters value and initialize a new socket.
calling without section will fetch value from "global" section

◆ setDefSelfAddress

bool(* ptpmgmt_sk_t::setDefSelfAddress) (ptpmgmt_sk sk, const char *rootBase, const char *useDef)

Set self address using predefined algorithm

Parameters
[in,out]sksocket
[in]rootBasebase used for root user
[in]useDefbase used for non root user
Returns
true if self address is updated
Note
address can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setIf

bool(* ptpmgmt_sk_t::setIf) (ptpmgmt_sk sk, const_ptpmgmt_ifInfo ifObj)

Set network interface using a network interface object

Parameters
[in,out]sksocket
[in]ifObjinitialized network interface object
Returns
true if network interface exists and updated.
Note
network interface can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setIfUsingIndex

bool(* ptpmgmt_sk_t::setIfUsingIndex) (ptpmgmt_sk sk, int ifIndex)

Set network interface using its index

Parameters
[in,out]sksocket
[in]ifIndexinterface index
Returns
true if network interface exists and updated.
Note
network interface can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setIfUsingName

bool(* ptpmgmt_sk_t::setIfUsingName) (ptpmgmt_sk sk, const char *ifName)

Set network interface using its name

Parameters
[in,out]sksocket
[in]ifNameinterface name
Returns
true if network interface exists and updated.
Note
network interface can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setPeerAddress

bool(* ptpmgmt_sk_t::setPeerAddress) (ptpmgmt_sk sk, const char *string)

Set peer address

Parameters
[in,out]sksocket
[in]stringobject with peer address
Returns
true if peer address is updated

◆ setPeerAddressAbstract

bool(* ptpmgmt_sk_t::setPeerAddressAbstract) (ptpmgmt_sk sk, const char *string)

Set peer address with Abstract address

Parameters
[in,out]sksocket
[in]stringobject with peer address
Returns
true if peer address is updated
Note
add '0' byte at the start of the address to mark it as abstract socket address

◆ setPeerAddressCfg

bool(* ptpmgmt_sk_t::setPeerAddressCfg) (ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)

Set peer address using configuration file

Parameters
[in,out]sksocket
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if peer address is updated
Note
calling without section will fetch value from "global" section

◆ setPtpDstMac

bool(* ptpmgmt_sk_t::setPtpDstMac) (ptpmgmt_sk sk, const void *ptp_dst_mac, size_t len)

Set PTP multicast address using binary from

Parameters
[in,out]sksocket
[in]ptp_dst_macaddress in binary string object
[in]lenMAC address length
Returns
true if PTP multicast address is updated
Note
PTP multicast address can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setPtpDstMacCfg

bool(* ptpmgmt_sk_t::setPtpDstMacCfg) (ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)

Set PTP multicast address using configuration file

Parameters
[in,out]sksocket
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if PTP multicast address is updated
Note
PTP multicast address can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
calling without section will fetch value from "global" section

◆ setPtpDstMacStr

bool(* ptpmgmt_sk_t::setPtpDstMacStr) (ptpmgmt_sk sk, const char *string)

Set PTP multicast address using string from

Parameters
[in,out]sksocket
[in]stringaddress in a string object
Returns
true if PTP multicast address is updated
Note
PTP multicast address can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
function convert address to binary form and return false if conversion fail (address is using wrong format).

◆ setScope

bool(* ptpmgmt_sk_t::setScope) (ptpmgmt_sk sk, uint8_t udp6_scope)

Set IP version 6 address scope

Parameters
[in,out]sksocket
[in]udp6_scopeIP version 6 address scope
Returns
true if IPv6 scope is updated
Note
IPv6 scope can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setScopeCfg

bool(* ptpmgmt_sk_t::setScopeCfg) (ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)

Set IP version 6 address scope using configuration file

Parameters
[in,out]sksocket
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if IPv6 scope is updated
Note
IPv6 scope can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
calling without section will fetch value from "global" section

◆ setSelfAddress

bool(* ptpmgmt_sk_t::setSelfAddress) (ptpmgmt_sk sk, const char *string)

Set self address

Parameters
[in,out]sksocket
[in]stringobject with self address
Returns
true if self address is updated
Note
address can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setSelfAddressAbstract

bool(* ptpmgmt_sk_t::setSelfAddressAbstract) (ptpmgmt_sk sk, const char *string)

Set self address with Abstract address

Parameters
[in,out]sksocket
[in]stringobject with self address
Returns
true if self address is updated
Note
address can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
add '0' byte at the start of the address to mark it as abstract socket address

◆ setSocketPriority

bool(* ptpmgmt_sk_t::setSocketPriority) (ptpmgmt_sk sk, uint8_t socket_priority)

Set socket priority

Parameters
[in,out]sksocket
[in]socket_prioritysocket priority value
Returns
true if socket priority is updated
Note
socket priority can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
the priority is used by network layer, it is not part of the packet

◆ setSocketPriorityCfg

bool(* ptpmgmt_sk_t::setSocketPriorityCfg) (ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)

Set socket priority using configuration file

Parameters
[in,out]sksocket
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if socket priority is updated
Note
socket priority can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
calling without section will fetch value from "global" section

◆ setUdpTtl

bool(* ptpmgmt_sk_t::setUdpTtl) (ptpmgmt_sk sk, uint8_t udp_ttl)

Set IP ttl value

Parameters
[in,out]sksocket
[in]udp_ttlIP time to live
Returns
true if IP ttl is updated
Note
in IP version 6 the value is used for multicast hops
IP ttl can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.

◆ setUdpTtlCfg

bool(* ptpmgmt_sk_t::setUdpTtlCfg) (ptpmgmt_sk sk, const_ptpmgmt_cfg cfg, const char *section)

Set IP ttl value using configuration file

Parameters
[in,out]sksocket
[in]cfgreference to configuration file object
[in]sectionin configuration file
Returns
true if IP ttl is updated
Note
in IP version 6 the value is used for multicast hops
IP ttl can not be changed after initializing. User can close the socket, change this value, and initialize a new socket.
calling without section will fetch value from "global" section

◆ tpoll

bool(* ptpmgmt_sk_t::tpoll) (ptpmgmt_sk sk, uint64_t *timeout_ms)

Single socket polling and update timeout

Parameters
[in,out]sksocket
[in,out]timeout_mstimeout in milliseconds until receive a packet. use 0 for blocking.
Returns
true if a packet is ready for receive
Note
The function will reduce the wait time from timeout when packet arrives. The user is advice to ensure the timeout is positive, as zero cause to block until receive a packet.

The documentation for this struct was generated from the following file: