From 992e79a0f8975657bf741d95d1faf4ab5c6f3ee3 Mon Sep 17 00:00:00 2001 From: zhao maosheng Date: Tue, 10 Sep 2024 16:21:19 +0800 Subject: [PATCH] optimize sal_bind --- components/net/sal/src/sal_socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/net/sal/src/sal_socket.c b/components/net/sal/src/sal_socket.c index a268c2dceb..6cd2caeea3 100644 --- a/components/net/sal/src/sal_socket.c +++ b/components/net/sal/src/sal_socket.c @@ -679,7 +679,8 @@ int sal_bind(int socket, const struct sockaddr *name, socklen_t namelen) addr_un = (struct sockaddr_un *)name; - if ((addr_un->sa_family != AF_UNIX) && (addr_un->sa_family != AF_NETLINK)) +#define IS_INET_ADDR_FAMILY(_af) ((_af) == AF_INET) || ((_af) == AF_INET6) + if (IS_INET_ADDR_FAMILY(name->sa_family)) { /* bind network interface by ip address */ sal_sockaddr_to_ipaddr(name, &input_ipaddr);