Commit Graph

19 Commits (7c6a9862fd7c6e49350aaf527194603930b10ca2)

Author SHA1 Message Date
Stephen Walker 159eb5ff11 util: Fix unknown time_t types with musl-libc builds
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>
2017-05-15 23:05:57 +02:00
Miroslav Lichvar 01d523fb48 util: add function for simple rate limiting.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2015-09-11 21:24:34 +02:00
Miroslav Lichvar 16bb89d5bf util: exit in string_* and parray_* functions when allocation fails. 2015-08-29 10:33:35 +02:00
Miroslav Lichvar e4325ee3fb util: add wrappers for memory allocation functions.
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.
2015-08-29 10:33:35 +02:00
Richard Cochran efa91dda77 util: provide the 'count_char' helper function.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:21:43 +02:00
Richard Cochran 5fe77584b4 util: add a helper function to scan a MAC address.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:46 +02:00
Miroslav Lichvar 2098d7c162 Add string and pointer array utility functions.
Add some functions to work with strings and arrays of pointers that will
be useful later.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-10-03 14:25:19 +02:00
Miroslav Lichvar 48046e593e Don't include config.h in util.h
The config module is used by ptp4l only, but util is shared with other
programs.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-10-03 14:25:19 +02:00
Miroslav Lichvar ca637b2067 Move signal handling to util.c.
This will be useful in phc2sys and pmc.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-09-21 12:34:05 +02:00
Stephan Gatzka 110849d422 Make functions and structs dealing with string literals const correct.
This allows the compiler to check if someone writes into string
literals.

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:41:47 +01:00
Richard Cochran a3762c506e pmc: add a command to select the target port.
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>
2013-07-22 21:47:28 +02:00
Richard Cochran e67276a56e trivial: break the very long lines of the get_ functions.
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>
2013-06-14 12:58:56 +02:00
Ken ICHIKAWA 42cb449eaa util: Add common procedures to get argument values for ptp4l and phc2sys
Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com>
2013-06-04 20:16:21 +02:00
Ken ICHIKAWA 306f83e7b1 Add support for more strict config value validation
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>
2013-06-04 20:16:21 +02:00
Miroslav Lichvar eb93926bc9 phc2sys: Handle leap seconds.
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>
2013-03-20 19:37:39 +01:00
Geoff Salmon e919971905 adds CLOCK_DESCRIPTION struct
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>
2013-02-25 18:11:03 +01:00
Geoff Salmon 68b4678f7b adds static_ptp_text and functions for setting PTPText and static_ptp_text
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>
2013-02-04 12:22:11 +01:00
Richard Cochran 582a8858d7 Make the function to generate a clock identity a global function.
This will allow code reuse in the management client.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-05 21:46:03 +02:00
Richard Cochran e930bc4e11 Add utility functions for obtaining human readable strings.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-06 07:37:06 +01:00