Commit eb89f037 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek

net: fix IP addresses for pdelay (unix, wrs)

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent a9373c90
......@@ -143,7 +143,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; /* only ipv4/udp */
Integer32 mcast_addr[2]; /* only ipv4/udp */
int tx_offset, rx_offset; /* ptp payload vs send/recv */
unsigned char peer[6]; /* Our peer's MAC address */
uint16_t peer_vid; /* Our peer's VID (for PROTO_VLAN) */
......
......@@ -12,7 +12,8 @@
#include <ppsi/lib.h>
#include "wr-constants.h"
#define WRS_PPSI_SHMEM_VERSION 16 /* Many changes since the last incease */
#define WRS_PPSI_SHMEM_VERSION 17 /* Changed definition of field mcast_addr of
* struct pp_instance */
/*
* This structure is used as extension-specific data in the DSPort
......
......@@ -183,7 +183,7 @@ static int sim_net_send(struct pp_instance *ppi, void *pkt, int len,
PP_SLAVE_GEN_PORT :
PP_SLAVE_EVT_PORT);
addr.sin_addr.s_addr = ppi->mcast_addr;
addr.sin_addr.s_addr = ppi->mcast_addr[0];
if (t)
ppi->t_ops->get(ppi, t);
......
......@@ -190,7 +190,6 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
[PP_NP_GEN] = PP_GEN_PORT,
[PP_NP_EVT] = PP_EVT_PORT,
};
/* FIXME: udp address for sendto */
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
......@@ -252,9 +251,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
case PPSI_PROTO_UDP:
addr.sin_family = AF_INET;
addr.sin_port = htons(udpport[chtype]);
addr.sin_addr.s_addr = ppi->mcast_addr;
/* FIXME: differentiate pldeay mac address */
addr.sin_addr.s_addr = ppi->mcast_addr[is_pdelay];
if (t)
ppi->t_ops->get(ppi, t);
......@@ -418,7 +415,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 = net_addr.s_addr;
ppi->mcast_addr[PP_E2E_MECH] = net_addr.s_addr;
/* multicast sends only on specified interface */
imr.imr_multiaddr.s_addr = net_addr.s_addr;
......@@ -435,8 +432,6 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
&imr, sizeof(struct ip_mreq)) < 0)
goto err_out;
#if 0 /* FIXME: UDP pdelay is not working due to address inflation */
/* Init Peer multicast IP address */
memcpy(addr_str, PP_PDELAY_DOMAIN_ADDRESS, INET_ADDRSTRLEN);
......@@ -444,7 +439,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 = net_addr.s_addr;
ppi->mcast_addr[PP_P2P_MECH] = net_addr.s_addr;
imr.imr_multiaddr.s_addr = net_addr.s_addr;
/* join multicast group (for receiving) on specified interface */
......@@ -452,7 +447,6 @@ static int unix_open_ch_udp(struct pp_instance *ppi, char *ifname, int chtype)
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&imr, sizeof(struct ip_mreq)) < 0)
goto err_out;
#endif
/* End of General multicast Ip address init */
......@@ -566,16 +560,18 @@ static int unix_net_exit(struct pp_instance *ppi)
continue;
/* Close General Multicast */
imr.imr_multiaddr.s_addr = ppi->mcast_addr;
imr.imr_interface.s_addr = htonl(INADDR_ANY);
imr.imr_multiaddr.s_addr = ppi->mcast_addr[0];
setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
imr.imr_multiaddr.s_addr = ppi->mcast_addr[1];
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[0] = ppi->mcast_addr[1] = 0;
return 0;
default:
......
......@@ -461,7 +461,6 @@ static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
[PP_NP_GEN] = PP_GEN_PORT,
[PP_NP_EVT] = PP_EVT_PORT,
};
/* FIXME: udp address for sendto */
static const uint8_t macaddr[2][ETH_ALEN] = {
[PP_E2E_MECH] = PP_MCAST_MACADDRESS,
[PP_P2P_MECH] = PP_PDELAY_MACADDRESS,
......@@ -549,7 +548,7 @@ static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
fd = ppi->ch[chtype].fd;
addr.sin_family = AF_INET;
addr.sin_port = htons(udpport[chtype]);
addr.sin_addr.s_addr = ppi->mcast_addr;
addr.sin_addr.s_addr = ppi->mcast_addr[is_pdelay];
if (drop)
addr.sin_port = 3200;
ret = sendto(fd, pkt, len, 0, (struct sockaddr *)&addr,
......
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