Add a configuration option to specify the L2 MAC addresses.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
928abf32f2
commit
7460d2756a
16
config.c
16
config.c
|
@ -19,14 +19,16 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "ether.h"
|
||||
|
||||
static void scan_line(char *s, struct config *cfg)
|
||||
{
|
||||
double df;
|
||||
int val;
|
||||
int i, val;
|
||||
Integer8 i8;
|
||||
UInteger16 u16;
|
||||
UInteger8 u8;
|
||||
unsigned char mac[MAC_LEN];
|
||||
|
||||
struct defaultDS *dds = cfg->dds;
|
||||
struct port_defaults *pod = cfg->pod;
|
||||
|
@ -99,6 +101,18 @@ static void scan_line(char *s, struct config *cfg)
|
|||
|
||||
if (df > 0.0 && df < 1.0)
|
||||
*cfg->pi_integral_const = df;
|
||||
|
||||
} else if (MAC_LEN == sscanf(s, " ptp_dst_mac %hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
|
||||
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])) {
|
||||
|
||||
for (i = 0; i < MAC_LEN; i++)
|
||||
cfg->ptp_dst_mac[i] = mac[i];
|
||||
|
||||
} else if (MAC_LEN == sscanf(s, " p2p_dst_mac %hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
|
||||
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])) {
|
||||
|
||||
for (i = 0; i < MAC_LEN; i++)
|
||||
cfg->p2p_dst_mac[i] = mac[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
config.h
2
config.h
|
@ -28,6 +28,8 @@ struct config {
|
|||
int *tx_timestamp_retries;
|
||||
double *pi_proportional_const;
|
||||
double *pi_integral_const;
|
||||
unsigned char *ptp_dst_mac;
|
||||
unsigned char *p2p_dst_mac;
|
||||
};
|
||||
|
||||
int config_read(char *name, struct config *cfg);
|
||||
|
|
|
@ -19,7 +19,12 @@ announceReceiptTimeout 3
|
|||
#
|
||||
# Run time options
|
||||
#
|
||||
transportSpecific 0x0
|
||||
tx_timestamp_retries 2
|
||||
pi_proportional_const 0.0
|
||||
pi_integral_const 0.0
|
||||
#
|
||||
# Transport options
|
||||
#
|
||||
transportSpecific 0x0
|
||||
ptp_dst_mac 01:1B:19:00:00:00
|
||||
p2p_dst_mac 01:80:C2:00:00:0E
|
||||
|
|
4
ptp4l.c
4
ptp4l.c
|
@ -32,6 +32,8 @@
|
|||
|
||||
int sk_tx_retries = 2; /*see sk.c*/
|
||||
double configured_pi_kp, configured_pi_ki; /*see pi.c*/
|
||||
extern unsigned char ptp_dst_mac[]; /*see raw.c*/
|
||||
extern unsigned char p2p_dst_mac[]; /*see raw.c*/
|
||||
|
||||
static int running = 1;
|
||||
static struct defaultDS ds;
|
||||
|
@ -219,6 +221,8 @@ int main(int argc, char *argv[])
|
|||
cfg_settings.tx_timestamp_retries = &sk_tx_retries;
|
||||
cfg_settings.pi_proportional_const = &configured_pi_kp;
|
||||
cfg_settings.pi_integral_const = &configured_pi_ki;
|
||||
cfg_settings.ptp_dst_mac = ptp_dst_mac;
|
||||
cfg_settings.p2p_dst_mac = p2p_dst_mac;
|
||||
|
||||
if (config && config_read(config, &cfg_settings)) {
|
||||
fprintf(stderr, "failed to read configuration file\n");
|
||||
|
|
4
raw.c
4
raw.c
|
@ -138,8 +138,8 @@ static int raw_close(struct transport *t, struct fdarray *fda)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char ptp_dst_mac[MAC_LEN] = { PTP_DST_MAC };
|
||||
static unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC };
|
||||
unsigned char ptp_dst_mac[MAC_LEN] = { PTP_DST_MAC };
|
||||
unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC };
|
||||
|
||||
static int open_socket(char *name, int event)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue