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-30 10:27:19.406967694 +0800
+++ lwip-2.2.0/src/api/sockets.c	2024-04-30 10:37:41.203874969 +0800
@@ -3859,6 +3859,29 @@
             return ENOPROTOOPT;
            }
 	break;
+	case MCAST_JOIN_GROUP:
+        case MCAST_LEAVE_GROUP: {
+          LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, struct group_req);
+          if (((const struct group_req *)optval)->gr_group.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_group(s,&sock->conn->pcb.udp->ipmc, optname, (const struct group_req *)optval);
+          } else
+#endif /* LWIP_UDP */
+#if LWIP_RAW
+          if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_RAW) {
+            err = mcast_sock_join_leave_group(s,&sock->conn->pcb.raw->ipmc, optname, (const struct group_req *)optval);
+          } else
+#endif /* LWIP_RAW */
+          {
+            done_socket(sock);
+            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);
