net/inet: Add check for protocol before handing out TCP and UDP sockets.

This commit is contained in:
Gregory Nutt 2017-10-23 09:58:11 -06:00
parent 261045e689
commit fb3655e9f0

View File

@ -1237,9 +1237,23 @@ FAR const struct sock_intf_s *
}
else
#endif
#ifdef NET_UDP_HAVE_STACK
if (type == SOCK_DGRAM && (protocol == 0 || protocol == IPPROTO_UDP))
{
return &g_inet_sockif;
}
else
#endif
#ifdef NET_TCP_HAVE_STACK
if (type == SOCK_STREAM && (protocol == 0 || protocol == IPPROTO_TCP))
{
return &g_inet_sockif;
}
else
#endif
{
return NULL;
}
}
#endif /* HAVE_INET_SOCKETS */