config: convert 'ptp_dst_mac', letting it be a per-port option.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-21 22:44:29 +02:00
parent 5fe77584b4
commit a31f2d0ddf
7 changed files with 18 additions and 24 deletions

View File

@ -213,6 +213,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX), GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX),
GLOB_ITEM_INT("priority1", 128, 0, UINT8_MAX), GLOB_ITEM_INT("priority1", 128, 0, UINT8_MAX),
GLOB_ITEM_INT("priority2", 128, 0, UINT8_MAX), GLOB_ITEM_INT("priority2", 128, 0, UINT8_MAX),
PORT_ITEM_STR("ptp_dst_mac", "01:1B:19:00:00:00"),
GLOB_ITEM_INT("sanity_freq_limit", 200000000, 0, INT_MAX), GLOB_ITEM_INT("sanity_freq_limit", 200000000, 0, INT_MAX),
GLOB_ITEM_INT("slaveOnly", 0, 0, 1), GLOB_ITEM_INT("slaveOnly", 0, 0, 1),
GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX), GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
@ -467,14 +468,7 @@ static enum parser_result parse_global_setting(const char *option,
if (r != NOT_PARSED) if (r != NOT_PARSED)
return r; return r;
if (!strcmp(option, "ptp_dst_mac")) { if (!strcmp(option, "p2p_dst_mac")) {
if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]))
return BAD_VALUE;
for (i = 0; i < MAC_LEN; i++)
cfg->ptp_dst_mac[i] = mac[i];
} else if (!strcmp(option, "p2p_dst_mac")) {
if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])) &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]))
return BAD_VALUE; return BAD_VALUE;

View File

@ -47,7 +47,6 @@ struct config {
/* the rest are legacy fields */ /* the rest are legacy fields */
struct default_ds dds; struct default_ds dds;
unsigned char *ptp_dst_mac;
unsigned char *p2p_dst_mac; unsigned char *p2p_dst_mac;
char *uds_address; char *uds_address;
}; };

View File

@ -23,7 +23,6 @@
#include <stdint.h> #include <stdint.h>
#define MAC_LEN 6 #define MAC_LEN 6
#define PTP_DST_MAC 0x01, 0x1B, 0x19, 0x00, 0x00, 0x00
#define P2P_DST_MAC 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E #define P2P_DST_MAC 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E
typedef uint8_t eth_addr[MAC_LEN]; typedef uint8_t eth_addr[MAC_LEN];

View File

@ -185,6 +185,10 @@ The default is 16 seconds.
Select the delay mechanism. Possible values are E2E, P2P and Auto. Select the delay mechanism. Possible values are E2E, P2P and Auto.
The default is E2E. The default is E2E.
.TP .TP
.B ptp_dst_mac
The MAC address to which PTP messages should be sent.
Relevant only with L2 transport. The default is 01:1B:19:00:00:00.
.TP
.B network_transport .B network_transport
Select the network transport. Possible values are UDPv4, UDPv6 and L2. Select the network transport. Possible values are UDPv4, UDPv6 and L2.
The default is UDPv4. The default is UDPv4.
@ -412,10 +416,6 @@ disabled. The default is 200000000 (20%).
The number of the SHM segment used by ntpshm servo. The number of the SHM segment used by ntpshm servo.
The default is 0. The default is 0.
.TP .TP
.B ptp_dst_mac
The MAC address where should be PTP messages sent.
Relevant only with L2 transport. The default is 01:1B:19:00:00:00.
.TP
.B p2p_dst_mac .B p2p_dst_mac
The MAC address where should be peer delay messages the PTP peer. The MAC address where should be peer delay messages the PTP peer.
Relevant only with L2 transport. The default is 01:80:C2:00:00:0E. Relevant only with L2 transport. The default is 01:80:C2:00:00:0E.

View File

@ -59,7 +59,6 @@ static struct config cfg_settings = {
}, },
}, },
.ptp_dst_mac = ptp_dst_mac,
.p2p_dst_mac = p2p_dst_mac, .p2p_dst_mac = p2p_dst_mac,
.uds_address = uds_path, .uds_address = uds_path,
}; };

16
raw.c
View File

@ -37,12 +37,14 @@
#include <linux/sockios.h> #include <linux/sockios.h>
#include "address.h" #include "address.h"
#include "config.h"
#include "contain.h" #include "contain.h"
#include "ether.h" #include "ether.h"
#include "print.h" #include "print.h"
#include "raw.h" #include "raw.h"
#include "sk.h" #include "sk.h"
#include "transport_private.h" #include "transport_private.h"
#include "util.h"
struct raw { struct raw {
struct transport t; struct transport t;
@ -147,10 +149,9 @@ static int raw_close(struct transport *t, struct fdarray *fda)
return 0; return 0;
} }
unsigned char ptp_dst_mac[MAC_LEN] = { PTP_DST_MAC };
unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC }; unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC };
static int open_socket(const char *name, int event) static int open_socket(const char *name, int event, unsigned char *ptp_dst_mac)
{ {
struct sockaddr_ll addr; struct sockaddr_ll addr;
int fd, index; int fd, index;
@ -202,19 +203,26 @@ static int raw_open(struct transport *t, const char *name,
struct fdarray *fda, enum timestamp_type ts_type) struct fdarray *fda, enum timestamp_type ts_type)
{ {
struct raw *raw = container_of(t, struct raw, t); struct raw *raw = container_of(t, struct raw, t);
unsigned char ptp_dst_mac[MAC_LEN];
int efd, gfd; int efd, gfd;
char *str;
str = config_get_string(t->cfg, name, "ptp_dst_mac");
if (str2mac(str, ptp_dst_mac)) {
pr_err("invalid ptp_dst_mac %s", str);
return -1;
}
mac_to_addr(&raw->ptp_addr, ptp_dst_mac); mac_to_addr(&raw->ptp_addr, ptp_dst_mac);
mac_to_addr(&raw->p2p_addr, p2p_dst_mac); mac_to_addr(&raw->p2p_addr, p2p_dst_mac);
if (sk_interface_macaddr(name, &raw->src_addr)) if (sk_interface_macaddr(name, &raw->src_addr))
goto no_mac; goto no_mac;
efd = open_socket(name, 1); efd = open_socket(name, 1, ptp_dst_mac);
if (efd < 0) if (efd < 0)
goto no_event; goto no_event;
gfd = open_socket(name, 0); gfd = open_socket(name, 0, ptp_dst_mac);
if (gfd < 0) if (gfd < 0)
goto no_general; goto no_general;

5
raw.h
View File

@ -23,11 +23,6 @@
#include "fd.h" #include "fd.h"
#include "transport.h" #include "transport.h"
/**
* The MAC address to use for non-peer messages.
*/
extern unsigned char ptp_dst_mac[];
/** /**
* The MAC address to use for peer messages. * The MAC address to use for peer messages.
*/ */