Commit 43d6378f authored by Cesar Prados's avatar Cesar Prados Committed by Alessandro Rubini

pdelay/socket: add pdelay support to sockets in wrs and unix arch

uninx sockets admit to join more than one multicast
group, using this feature the sockets in wrs and unix
arch, the same socket is able to get E2E and P2P msg.
Signed-off-by: Cesar Prados's avatarC.Prados <c.prados@gsi.de>
parent 42b1fafe
......@@ -203,7 +203,10 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
ch = ppi->ch + PP_NP_GEN;
hdr->h_proto = htons(ETH_P_1588);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
if (use_pdelay_addr)
memcpy(hdr->h_dest, PP_PDELAY_MACADDRESS, ETH_ALEN);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
memcpy(hdr->h_source, ch->addr, ETH_ALEN);
if (t)
......@@ -226,7 +229,10 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
vhdr->h_tci = htons(ppi->peer_vid); /* prio is 0 */
vhdr->h_tpid = htons(0x8100);
memcpy(vhdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
if (use_pdelay_addr)
memcpy(hdr->h_dest, PP_PDELAY_MACADDRESS, ETH_ALEN);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
memcpy(vhdr->h_source, ch->addr, ETH_ALEN);
if (t)
......@@ -316,6 +322,11 @@ static int unix_open_ch_raw(struct pp_instance *ppi, char *ifname, int chtype)
memcpy(pmr.mr_address, PP_MCAST_MACADDRESS, ETH_ALEN);
setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
/* add peer delay multicast address */
memcpy(pmr.mr_address, PP_PDELAY_MACADDRESS, ETH_ALEN);
setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
/* make timestamps available through recvmsg() -- FIXME: hw? */
temp = 1;
......@@ -419,6 +430,23 @@ 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;
/* Init Peer multicast IP address */
memcpy(addr_str, PP_PDELAY_DOMAIN_ADDRESS, INET_ADDRSTRLEN);
context = addr_str;
errno = EINVAL;
if (!inet_aton(addr_str, &net_addr))
goto err_out;
ppi->mcast_addr = net_addr.s_addr;
imr.imr_multiaddr.s_addr = net_addr.s_addr;
/* join multicast group (for receiving) on specified interface */
context = "setsockopt(IP_ADD_MEMBERSHIP)";
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&imr, sizeof(struct ip_mreq)) < 0)
goto err_out;
/* End of General multicast Ip address init */
/* set socket time-to-live */
......
......@@ -479,7 +479,10 @@ static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
if (drop)
hdr->h_proto++;
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
if (use_pdelay_addr)
memcpy(hdr->h_dest, PP_PDELAY_MACADDRESS, ETH_ALEN);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
memcpy(hdr->h_source, ch->addr, ETH_ALEN);
if (t)
......@@ -512,7 +515,11 @@ static int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
if (drop)
hdr->h_proto++;
memcpy(vhdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
if (use_pdelay_addr)
memcpy(vhdr->h_dest, PP_PDELAY_MACADDRESS, ETH_ALEN);
else
memcpy(vhdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
memcpy(vhdr->h_source, ch->addr, ETH_ALEN);
if (t)
......
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