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>master
parent
b2072076bf
commit
582a8858d7
17
ptp4l.c
17
ptp4l.c
|
@ -27,6 +27,7 @@
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "sk.h"
|
#include "sk.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
int assume_two_step;
|
int assume_two_step;
|
||||||
double configured_pi_kp, configured_pi_ki; /*see pi.c*/
|
double configured_pi_kp, configured_pi_ki; /*see pi.c*/
|
||||||
|
@ -38,22 +39,6 @@ static struct defaultDS ds;
|
||||||
static struct port_defaults pod;
|
static struct port_defaults pod;
|
||||||
static struct config cfg_settings;
|
static struct config cfg_settings;
|
||||||
|
|
||||||
static int generate_clock_identity(struct ClockIdentity *ci, char *name)
|
|
||||||
{
|
|
||||||
unsigned char mac[6];
|
|
||||||
if (sk_interface_macaddr(name, mac, sizeof(mac)))
|
|
||||||
return -1;
|
|
||||||
ci->id[0] = mac[0];
|
|
||||||
ci->id[1] = mac[1];
|
|
||||||
ci->id[2] = mac[2];
|
|
||||||
ci->id[3] = 0xFF;
|
|
||||||
ci->id[4] = 0xFE;
|
|
||||||
ci->id[5] = mac[3];
|
|
||||||
ci->id[6] = mac[4];
|
|
||||||
ci->id[7] = mac[5];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void usage(char *progname)
|
static void usage(char *progname)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|
17
util.c
17
util.c
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "sk.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
char *ps_str[] = {
|
char *ps_str[] = {
|
||||||
|
@ -73,3 +74,19 @@ char *pid2str(struct PortIdentity *id)
|
||||||
id->portNumber);
|
id->portNumber);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int generate_clock_identity(struct ClockIdentity *ci, char *name)
|
||||||
|
{
|
||||||
|
unsigned char mac[6];
|
||||||
|
if (sk_interface_macaddr(name, mac, sizeof(mac)))
|
||||||
|
return -1;
|
||||||
|
ci->id[0] = mac[0];
|
||||||
|
ci->id[1] = mac[1];
|
||||||
|
ci->id[2] = mac[2];
|
||||||
|
ci->id[3] = 0xFF;
|
||||||
|
ci->id[4] = 0xFE;
|
||||||
|
ci->id[5] = mac[3];
|
||||||
|
ci->id[6] = mac[4];
|
||||||
|
ci->id[7] = mac[5];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue