udp*: multicast join work with specific addresses
Remove unused sockaddr size argument, and pass address using specific struct Signed-off-by: Rafaël Carré <funman@videolan.org>master
parent
ee2a9d4ac9
commit
5219b6417f
8
udp.c
8
udp.c
|
@ -62,12 +62,10 @@ static int mcast_bind(int fd, int index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mcast_join(int fd, int index, const struct sockaddr *grp,
|
||||
socklen_t grplen)
|
||||
static int mcast_join(int fd, int index, const struct sockaddr_in *sa)
|
||||
{
|
||||
int err, off = 0;
|
||||
struct ip_mreqn req;
|
||||
struct sockaddr_in *sa = (struct sockaddr_in *) grp;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
memcpy(&req.imr_multiaddr, &sa->sin_addr, sizeof(struct in_addr));
|
||||
|
@ -129,12 +127,12 @@ static int open_socket(const char *name, struct in_addr mc_addr[2], short port,
|
|||
goto no_option;
|
||||
}
|
||||
addr.sin_addr = mc_addr[0];
|
||||
if (mcast_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
|
||||
if (mcast_join(fd, index, &addr)) {
|
||||
pr_err("mcast_join failed");
|
||||
goto no_option;
|
||||
}
|
||||
addr.sin_addr = mc_addr[1];
|
||||
if (mcast_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
|
||||
if (mcast_join(fd, index, &addr)) {
|
||||
pr_err("mcast_join failed");
|
||||
goto no_option;
|
||||
}
|
||||
|
|
7
udp6.c
7
udp6.c
|
@ -68,11 +68,10 @@ static int mc_bind(int fd, int index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mc_join(int fd, int index, const struct sockaddr *grp, socklen_t grplen)
|
||||
static int mc_join(int fd, int index, const struct sockaddr_in6 *sa)
|
||||
{
|
||||
int err, off = 0;
|
||||
struct ipv6_mreq req;
|
||||
struct sockaddr_in6 *sa = (struct sockaddr_in6 *) grp;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
memcpy(&req.ipv6mr_multiaddr, &sa->sin6_addr, sizeof(struct in6_addr));
|
||||
|
@ -137,12 +136,12 @@ static int open_socket_ipv6(const char *name, struct in6_addr mc_addr[2], short
|
|||
goto no_option;
|
||||
}
|
||||
addr.sin6_addr = mc_addr[0];
|
||||
if (mc_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
|
||||
if (mc_join(fd, index, &addr)) {
|
||||
pr_err("mcast_join failed");
|
||||
goto no_option;
|
||||
}
|
||||
addr.sin6_addr = mc_addr[1];
|
||||
if (mc_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
|
||||
if (mc_join(fd, index, &addr)) {
|
||||
pr_err("mcast_join failed");
|
||||
goto no_option;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue