The utility function to compare port IDs takes pointers, but it only needs
to read the referenced data. This patch marks the parameters as const,
allowing passing constants in the future.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The one user of the function, posix_clock_open(), simply open codes
the closing call to phc_close(). This patch provides a method to
balance closing and opening of a posix clock. In addition, the
phc_ctl program never explicitly closed the opened clock, and so this
patch adds the missing call.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The function to open a posix clock never modifies the passed in
string. This patch adds the const keyword to ensure this function
stays that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
TLV_PORT_PROPERTIES_NP carries, among other attributes, a timestamp type
used for that port. In order to make it possible to format the value for
user consumption, introduce a new function ts_str().
Signed-off-by: Petr Machata <petrm@mellanox.com>
The two programs, phc2sys and phc_ctl, use nearly identical subroutines to
open an instance of a dynamic posix clock. In anticipation of yet a third
program with similar needs, this patch refactors the common code into the
utilities.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Currently the clockIdentity is generated from the mac address of the first
interface/port in config file. This patch add the possibility to set it in
config file.
The reason is if the stack is restarted with a different set of ports, it
may be circumstances when clockIdentity needs to be equal as before
restart even if the port setup is different.
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
Consistenly use the pid_eq() and cid_eq() helper functions. Move the
functions into utils.h (making them inline functions) because they are
used in multiple source files.
Signed-off-by: Michael Walle <michael@walle.cc>
The file, pmc.c, contains utility functions for printing out a port address
structure. We will want to call these functions from pmc_common.c, and so
this patch moves the utility functions where they belong.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Fixes the following build errors seen with musl-libc:
In file included from print.h:25:0,
from linreg.c:24:
util.h:364:32: error: unknown type name 'time_t'
int rate_limited(int interval, time_t *last);
Signed-off-by: Stephen Walker <stephendwalker+github@gmail.com>
[florian: extract patch from OpenWrt, add commit message]
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Add wrappers for malloc(), calloc(), realloc() and strdup() that check
if the allocation failed, print an error message and call exit(1). This
allows the caller to use the returned value without checking for errors.
This patch adds a new pmc command called "target" that lets the user
address a particular clock and port. Previously all management requests
were sent to the wild card address.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The get_ranged_ and get_arg_ declarations and definitions are just a wee
bit much too long. This patch breaks the overly long lines into two.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds functions to get int, uint, double value from string
with error checking and range specification.
These functions don't allow overflow and outside of the range values.
In addition, it adds parser_result cases "MALFORMED" and "OUT_OF_RANGE" to make
reason of parse error more clear.
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
Update the currentUtcOffset and leap61/59 values at one minute
interval. When a leap second is detected, set the STA_INS/STA_DEL
bit for the system clock.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Modifies existing structs changing Octet *foo -> Octet foo[0] and
marks them PACKED so the message buffer can be cast to the structs.
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
static_ptp_text is like a PTPText that includes space for the text
which makes it more convenient for ptp texts stored in the clock.
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>