net: context: Bind did not check IPv4 multicast address
If the user tried to bind to IPv4 multicast address, then the operation failed and returned error. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
6edb0e3d18
commit
2c6e473c93
|
@ -831,8 +831,8 @@ int net_context_bind(struct net_context *context, const struct sockaddr *addr,
|
|||
#if defined(CONFIG_NET_IPV4)
|
||||
if (addr->sa_family == AF_INET) {
|
||||
struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
|
||||
struct net_if *iface = NULL;
|
||||
struct net_if_addr *ifaddr;
|
||||
struct net_if *iface;
|
||||
struct in_addr *ptr;
|
||||
int ret;
|
||||
|
||||
|
@ -840,7 +840,18 @@ int net_context_bind(struct net_context *context, const struct sockaddr *addr,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (addr4->sin_addr.s_addr == INADDR_ANY) {
|
||||
if (net_is_ipv4_addr_mcast(&addr4->sin_addr)) {
|
||||
struct net_if_mcast_addr *maddr;
|
||||
|
||||
maddr = net_if_ipv4_maddr_lookup(&addr4->sin_addr,
|
||||
&iface);
|
||||
if (!maddr) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ptr = &maddr->address.in_addr;
|
||||
|
||||
} else if (addr4->sin_addr.s_addr == INADDR_ANY) {
|
||||
iface = net_if_get_default();
|
||||
|
||||
ptr = (struct in_addr *)net_ipv4_unspecified_address();
|
||||
|
|
Loading…
Reference in a new issue