1 Star 0 Fork 48

flying-eagle/lwip

forked from src-openEuler/lwip 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0118-support-querying-udp-multicast-addresses.patch 3.72 KB
一键复制 编辑 原始数据 按行查看 历史
sky 提交于 2024-03-24 05:30 . support querying udp multicast addresses
From 0ba2b637ae7ae725bdd7de24de58b517a0cce93f Mon Sep 17 00:00:00 2001
From: wuchangye <wuchangye@huawei.com>
Date: Sun, 24 Mar 2024 05:29:30 +0800
Subject: [PATCH] support querying udp multicast addresses
---
src/api/sockets.c | 43 ++++++++++++++++++++++++++++++++++++--
src/include/lwip/sockets.h | 1 +
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/src/api/sockets.c b/src/api/sockets.c
index 66f6e2c..c544c22 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -4342,6 +4342,27 @@ lwip_inet_pton(int af, const char *src, void *dst)
}
#if LWIP_IGMP
+#if GAZELLE_ENABLE
+int lwip_socket_get_multi_memberships(int s, ip4_addr_t *if_addr, ip4_addr_t *multi_addr)
+{
+ struct lwip_sock *sock = get_socket(s);
+
+ if (!sock) {
+ return 0;
+ }
+
+ if (socket_ipv4_multicast_memberships[s].sock == sock) {
+ ip4_addr_copy(*if_addr, socket_ipv4_multicast_memberships[s].if_addr);
+ ip4_addr_copy(*multi_addr, socket_ipv4_multicast_memberships[s].multi_addr);
+ done_socket(sock);
+ return 1;
+ }
+
+ done_socket(sock);
+ return 0;
+}
+#endif
+
/** Register a new IGMP membership. On socket close, the membership is dropped automatically.
*
* ATTENTION: this function is called from tcpip_thread (or under CORE_LOCK).
@@ -4357,8 +4378,11 @@ lwip_socket_register_membership(int s, const ip4_addr_t *if_addr, const ip4_addr
if (!sock) {
return 0;
}
-
+#if GAZELLE_ENABLE
+ i = s;
+#else
for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) {
+#endif
if (socket_ipv4_multicast_memberships[i].sock == NULL) {
socket_ipv4_multicast_memberships[i].sock = sock;
ip4_addr_copy(socket_ipv4_multicast_memberships[i].if_addr, *if_addr);
@@ -4366,7 +4390,9 @@ lwip_socket_register_membership(int s, const ip4_addr_t *if_addr, const ip4_addr
done_socket(sock);
return 1;
}
+#if !GAZELLE_ENABLE
}
+#endif
done_socket(sock);
return 0;
}
@@ -4386,16 +4412,24 @@ lwip_socket_unregister_membership(int s, const ip4_addr_t *if_addr, const ip4_ad
return;
}
+#if GAZELLE_ENABLE
+ i = s;
+#else
for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) {
+#endif
if ((socket_ipv4_multicast_memberships[i].sock == sock) &&
ip4_addr_eq(&socket_ipv4_multicast_memberships[i].if_addr, if_addr) &&
ip4_addr_eq(&socket_ipv4_multicast_memberships[i].multi_addr, multi_addr)) {
socket_ipv4_multicast_memberships[i].sock = NULL;
ip4_addr_set_zero(&socket_ipv4_multicast_memberships[i].if_addr);
ip4_addr_set_zero(&socket_ipv4_multicast_memberships[i].multi_addr);
+#if !GAZELLE_ENABLE
break;
+#endif
}
+#if !GAZELLE_ENABLE
}
+#endif
done_socket(sock);
}
@@ -4412,8 +4446,11 @@ lwip_socket_drop_registered_memberships(int s)
if (!sock) {
return;
}
-
+#if GAZELLE_ENABLE
+ i = s;
+#else
for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) {
+#endif
if (socket_ipv4_multicast_memberships[i].sock == sock) {
ip_addr_t multi_addr, if_addr;
ip_addr_copy_from_ip4(multi_addr, socket_ipv4_multicast_memberships[i].multi_addr);
@@ -4424,7 +4461,9 @@ lwip_socket_drop_registered_memberships(int s)
netconn_join_leave_group(sock->conn, &multi_addr, &if_addr, NETCONN_LEAVE);
}
+#if !GAZELLE_ENABLE
}
+#endif
done_socket(sock);
}
#endif /* LWIP_IGMP */
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
index 4466f11..296d4eb 100644
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -361,6 +361,7 @@ struct linger {
#if GAZELLE_UDP_ENABLE
#define IP_ADD_MEMBERSHIP 35
#define IP_DROP_MEMBERSHIP 36
+int lwip_socket_get_multi_memberships(int s, ip4_addr_t *if_addr, ip4_addr_t *multi_addr);
#else
/*
* Options and types related to multicast membership
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flying-eagle12138/lwip.git
git@gitee.com:flying-eagle12138/lwip.git
flying-eagle12138
lwip
lwip
master

搜索帮助