From b6e9527f073d81ee9a3aa186c86a6a4fc8ff6a0b Mon Sep 17 00:00:00 2001
From: wanfeng <wanfeng@kylinos.cn>
Date: Wed, 3 Jul 2024 17:01:53 +0800
Subject: [PATCH] add MCAST_MSFILTER in setsockopt for MLDv2 of IPv6

---
 src/api/sockets.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/api/sockets.c b/src/api/sockets.c
index 7a67650..9e6ba90 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -4124,6 +4124,27 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
           if (NETCONNTYPE_GROUPV6(netconn_type(sock->conn)) == NETCONN_RAW_IPV6) {
             err = mcast_sock_block_unblock_source_group(&sock->conn->pcb.raw->ipmc, optname, (const struct group_source_req *)optval);
           } else
+#endif /* LWIP_RAW */
+          {
+            done_socket(sock);
+            return ENOPROTOOPT;
+          }
+          break;
+        case MCAST_MSFILTER:
+          LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, struct group_filter);
+          if (((const struct group_filter *)optval)->gf_group.ss_family != AF_INET6) {
+            done_socket(sock);
+            return EINVAL;
+          }
+#if LWIP_UDP
+          if (NETCONNTYPE_GROUPV6(netconn_type(sock->conn)) == NETCONN_UDP_IPV6) {
+            err = mcast_sock_set_groupfilter(&sock->conn->pcb.udp->ipmc, optname, (const struct group_filter *)optval);
+          } else
+#endif /* LWIP_UDP */
+#if LWIP_RAW
+          if (NETCONNTYPE_GROUPV6(netconn_type(sock->conn)) == NETCONN_RAW_IPV6) {
+            err = mcast_sock_set_groupfilter(&sock->conn->pcb.raw->ipmc, optname, (const struct group_filter *)optval);
+          } else
 #endif /* LWIP_RAW */
           {
             done_socket(sock);
-- 
2.25.1

