Commit 0572fe61 authored by Adam Wujek's avatar Adam Wujek

include/ppsi: use MECH_* instead of PP_*_MECH

Replace PP_E2E_MECH with MECH_E2E
and PP_P2P_MECH with MECH_P2P
Signed-off-by: 's avatarAdam Wujek <adam.wujek@creotech.pl>
parent 12615dab
......@@ -170,9 +170,6 @@
#define PP_MCAST_MACADDRESS "\x01\x1B\x19\x00\x00\x00"
#define PP_PDELAY_MACADDRESS "\x01\x80\xC2\x00\x00\x0E"
#define PP_E2E_MECH 0
#define PP_P2P_MECH 1
#include <arch/constants.h> /* architectures may override the defaults */
#endif /* __PPSI_CONSTANTS_H__ */
......@@ -426,6 +426,7 @@ enum ENTimeSource {
enum ENDelayMechanism {
MECH_E2E = 1,
MECH_P2P = 2,
MECH_MAX_SUPPORTED = 2,
MECH_COMMON_P2P = 3,
MECH_SPECIAL = 4,
MECH_NO_MECHANISM = 0xFE
......
......@@ -243,7 +243,7 @@ struct pp_instance {
/* The net_path used to be allocated separately, but there's no need */
struct pp_channel ch[__NR_PP_NP]; /* general and event ch */
Integer32 mcast_addr[2]; /* only ipv4/udp */
Integer32 mcast_addr[MECH_MAX_SUPPORTED + 1]; /* only ipv4/udp */
int tx_offset, rx_offset; /* ptp payload vs send/recv */
unsigned char peer[6]; /* Our peer's MAC address from last received msg*/
unsigned char activePeer[6]; /* Our peer's MAC address we talk with */
......
......@@ -2,43 +2,43 @@
/*
* PP_NP_GEN/EVT is the event or general message. It selects the socket etc
* PP_P2P_MECH is used to select a destination address for pdelay frames.
* P2P is used to select a destination address for pdelay frames.
* the numeric 0..5 is the "controlField" (magic ptpV1 numbers in byte 32).
* PP_LOG is the kind of logInterval to put in byte 33.
*/
struct pp_msgtype_info pp_msgtype_info[] = {
[PPM_SYNC_FMT] = {
PPM_SYNC, PP_SYNC_LENGTH,
PP_NP_EVT, PP_E2E_MECH, 0, PP_LOG_SYNC },
PP_NP_EVT, MECH_E2E, 0, PP_LOG_SYNC },
[PPM_DELAY_REQ_FMT] = {
PPM_DELAY_REQ, PP_DELAY_REQ_LENGTH,
PP_NP_EVT, PP_E2E_MECH, 1, 0x7f },
PP_NP_EVT, MECH_E2E, 1, 0x7f },
[PPM_PDELAY_REQ_FMT] = {
PPM_PDELAY_REQ,PP_PDELAY_REQ_LENGTH,
PP_NP_EVT, PP_P2P_MECH, 5, 0x7f },
PP_NP_EVT, MECH_P2P, 5, 0x7f },
[PPM_PDELAY_RESP_FMT] = {
PPM_PDELAY_RESP, PP_PDELAY_RESP_LENGTH,
PP_NP_EVT, PP_P2P_MECH, 5, 0x7f },
PP_NP_EVT, MECH_P2P, 5, 0x7f },
[PPM_FOLLOW_UP_FMT] = {
PPM_FOLLOW_UP, PP_FOLLOW_UP_LENGTH,
PP_NP_GEN, PP_E2E_MECH, 2, PP_LOG_SYNC },
PP_NP_GEN, MECH_E2E, 2, PP_LOG_SYNC },
[PPM_DELAY_RESP_FMT] = {
PPM_DELAY_RESP, PP_DELAY_RESP_LENGTH,
PP_NP_GEN, PP_E2E_MECH, 3, PP_LOG_REQUEST },
PP_NP_GEN, MECH_E2E, 3, PP_LOG_REQUEST },
[PPM_PDELAY_R_FUP_FMT] = {
PPM_PDELAY_R_FUP, PP_PDELAY_RESP_FOLLOW_UP_LENGTH,
PP_NP_GEN, PP_P2P_MECH, 5, 0x7f },
PP_NP_GEN, MECH_P2P, 5, 0x7f },
[PPM_ANNOUNCE_FMT] = {
PPM_ANNOUNCE, PP_ANNOUNCE_LENGTH,
PP_NP_GEN, PP_E2E_MECH, 5, PP_LOG_ANNOUNCE},
PP_NP_GEN, MECH_E2E, 5, PP_LOG_ANNOUNCE},
[PPM_SIGNALING_FMT] = {
PPM_SIGNALING, -1,
PP_NP_GEN, PP_E2E_MECH, 5, 0x7f},
PP_NP_GEN, MECH_E2E, 5, 0x7f},
[PPM_SIGNALING_NO_FWD_FMT] = {
PPM_SIGNALING, -1,
PP_NP_GEN, PP_P2P_MECH, 5, 0x7f},
PP_NP_GEN, MECH_P2P, 5, 0x7f},
/* We don't use management, or not in the table-driven code */
[PPM_MANAGEMENT_FMT] = { PPM_MANAGEMENT, -1, PP_NP_GEN, PP_E2E_MECH, 4, 0x7f},
[PPM_MANAGEMENT_FMT] = { PPM_MANAGEMENT, -1, PP_NP_GEN, MECH_E2E, 4, 0x7f},
};
char *pp_msgtype_name[] = {
......
......@@ -29,9 +29,9 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg
struct pp_msgtype_info *mf = pp_msgtype_info + msg_fmt;
struct bare_ethhdr *hdr = pkt;
struct pp_time *t = &ppi->last_snt_time;
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
static const uint8_t macaddr[MECH_MAX_SUPPORTED + 1][ETH_ALEN] = {
[MECH_E2E] = PP_MCAST_MACADDRESS,
[MECH_P2P] = PP_PDELAY_MACADDRESS,
};
int is_pdelay = mf->is_pdelay;
int ret;
......
......@@ -190,9 +190,9 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg
[PP_NP_GEN] = PP_GEN_PORT,
[PP_NP_EVT] = PP_EVT_PORT,
};
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
static const uint8_t macaddr[MECH_MAX_SUPPORTED + 1][ETH_ALEN] = {
[MECH_E2E] = PP_MCAST_MACADDRESS,
[MECH_P2P] = PP_PDELAY_MACADDRESS,
};
int ret;
......@@ -422,7 +422,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
context = addr_str; errno = EINVAL;
if (!inet_aton(addr_str, &net_addr))
goto err_out;
ppi->mcast_addr[PP_E2E_MECH] = net_addr.s_addr;
ppi->mcast_addr[MECH_E2E] = net_addr.s_addr;
/* multicast sends only on specified interface */
imr.imr_multiaddr.s_addr = net_addr.s_addr;
......@@ -446,7 +446,7 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
errno = EINVAL;
if (!inet_aton(addr_str, &net_addr))
goto err_out;
ppi->mcast_addr[PP_P2P_MECH] = net_addr.s_addr;
ppi->mcast_addr[MECH_P2P] = net_addr.s_addr;
imr.imr_multiaddr.s_addr = net_addr.s_addr;
/* join multicast group (for receiving) on specified interface */
......@@ -564,17 +564,17 @@ static int unix_net_exit(struct pp_instance *ppi)
/* Close General Multicast */
imr.imr_interface.s_addr = htonl(INADDR_ANY);
imr.imr_multiaddr.s_addr = ppi->mcast_addr[0];
imr.imr_multiaddr.s_addr = ppi->mcast_addr[MECH_E2E];
setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
imr.imr_multiaddr.s_addr = ppi->mcast_addr[1];
imr.imr_multiaddr.s_addr = ppi->mcast_addr[MECH_P2P];
setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
close(fd);
ppi->ch[i].fd = -1;
}
ppi->mcast_addr[0] = ppi->mcast_addr[1] = 0;
ppi->mcast_addr[MECH_E2E] = ppi->mcast_addr[MECH_P2P] = 0;
return 0;
default:
......
......@@ -125,9 +125,9 @@ static int wrpc_net_send(struct pp_instance *ppi, void *pkt, int len, enum pp_ms
struct wr_sockaddr addr;
struct pp_time *t = &ppi->last_snt_time;
int is_pdelay = mf->is_pdelay;
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
static const uint8_t macaddr[MECH_MAX_SUPPORTED + 1][ETH_ALEN] = {
[MECH_E2E] = PP_MCAST_MACADDRESS,
[MECH_P2P] = PP_PDELAY_MACADDRESS,
};
/*
......
......@@ -497,9 +497,9 @@ static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,enum pp_msg_
[PP_NP_GEN] = PP_GEN_PORT,
[PP_NP_EVT] = PP_EVT_PORT,
};
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
static const uint8_t macaddr[MECH_MAX_SUPPORTED + 1][ETH_ALEN] = {
[MECH_E2E] = PP_MCAST_MACADDRESS,
[MECH_P2P] = PP_PDELAY_MACADDRESS,
};
struct wrs_socket *s;
int ret, fd, drop;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment