udp6: add an option to set the multicast scope.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-11-25 20:30:14 +01:00
parent f92f09f563
commit d83cd7283c
6 changed files with 19 additions and 0 deletions

View File

@ -255,6 +255,11 @@ static enum parser_result parse_global_setting(const char *option,
for (i = 0; i < MAC_LEN; i++)
cfg->p2p_dst_mac[i] = mac[i];
} else if (!strcmp(option, "udp6_scope")) {
if (1 != sscanf(value, "%hhx", &u8) || (u8 & 0xF0))
return BAD_VALUE;
*cfg->udp6_scope = u8;
} else if (!strcmp(option, "logging_level")) {
if (1 != sscanf(value, "%d", &val) ||
!(val >= PRINT_LEVEL_MIN && val <= PRINT_LEVEL_MAX))

View File

@ -71,6 +71,7 @@ struct config {
unsigned char *ptp_dst_mac;
unsigned char *p2p_dst_mac;
unsigned char *udp6_scope;
int print_level;
int use_syslog;

View File

@ -43,6 +43,7 @@ clock_servo pi
transportSpecific 0x0
ptp_dst_mac 01:1B:19:00:00:00
p2p_dst_mac 01:80:C2:00:00:0E
udp6_scope 0x0E
#
# Default interface options
#

View File

@ -31,6 +31,7 @@
#include "raw.h"
#include "sk.h"
#include "transport.h"
#include "udp6.h"
#include "util.h"
int assume_two_step = 0;
@ -78,6 +79,7 @@ static struct config cfg_settings = {
.ptp_dst_mac = ptp_dst_mac,
.p2p_dst_mac = p2p_dst_mac,
.udp6_scope = &udp6_scope,
.print_level = LOG_INFO,
.use_syslog = 1,

4
udp6.c
View File

@ -40,6 +40,8 @@
#define PTP_PRIMARY_MCAST_IP6ADDR "FF0E:0:0:0:0:0:0:181"
#define PTP_PDELAY_MCAST_IP6ADDR "FF02:0:0:0:0:0:0:6B"
unsigned char udp6_scope = 0x0E;
struct udp6 {
struct transport t;
int index;
@ -160,6 +162,8 @@ static int udp6_open(struct transport *t, char *name, struct fdarray *fda,
if (1 != inet_pton(AF_INET6, PTP_PRIMARY_MCAST_IP6ADDR, &mc6_addr[MC_PRIMARY]))
return -1;
mc6_addr[MC_PRIMARY].s6_addr[1] = udp6_scope;
if (1 != inet_pton(AF_INET6, PTP_PDELAY_MCAST_IP6ADDR, &mc6_addr[MC_PDELAY]))
return -1;

6
udp6.h
View File

@ -23,6 +23,12 @@
#include "fd.h"
#include "transport.h"
/**
* The desired scope for the multicast messages. This will be used as
* the second byte of the primary IPv6 address. See RFC 4291.
*/
extern unsigned char udp6_scope;
/**
* Allocate an instance of a UDP/IPv6 transport.
* @return Pointer to a new transport instance on success, NULL otherwise.