diff -Nur lwip-2.2.0old/src/api/sockets.c lwip-2.2.0/src/api/sockets.c
--- lwip-2.2.0old/src/api/sockets.c	2024-04-29 10:39:04.721200645 +0800
+++ lwip-2.2.0/src/api/sockets.c	2024-04-29 11:21:09.036645032 +0800
@@ -3859,6 +3859,29 @@
             return ENOPROTOOPT;
            }
 	break;
+	case MCAST_JOIN_SOURCE_GROUP:
+        case MCAST_LEAVE_SOURCE_GROUP:
+        LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, struct group_source_req);
+            if ((((const struct group_source_req *)optval)->gsr_group.ss_family != AF_INET) ||
+               (((const struct group_source_req *)optval)->gsr_source.ss_family != AF_INET)) {
+             done_socket(sock);
+             return EINVAL;
+           }
+#if LWIP_UDP
+            if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_UDP) {
+              err = mcast_sock_join_leave_source_group(s,&sock->conn->pcb.udp->ipmc, optname, (const struct group_source_req *)optval);
+            } else
+#endif /* LWIP_UDP */
+#if LWIP_RAW
+            if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_RAW) {
+              err = mcast_sock_join_leave_source_group(s,&sock->conn->pcb.raw->ipmc, optname, (const struct group_source_req *)optval);
+            } else
+#endif /* LWIP_RAW */
+            {
+              done_socket(sock);
+              return ENOPROTOOPT;
+            }
+            break;
 #endif /* LWIP_IGMP */
         default:
           LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n",
