11 Star 75 Fork 103

OpenHarmony/third_party_lwip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0082-add-vlanid-in-netif.patch 3.35 KB
一键复制 编辑 原始数据 按行查看 历史
Aurora 提交于 2023-12-07 03:26 . update lwip to 2.1.3-39.oe2203sp1
diff -Nur lwip-org/src/core/netif.c lwip-vlan/src/core/netif.c
--- lwip-org/src/core/netif.c 2023-11-24 17:38:29.428481010 +0800
+++ lwip-vlan/src/core/netif.c 2023-11-27 18:35:00.172481010 +0800
@@ -355,6 +355,11 @@
netif->input = input;
NETIF_RESET_HINTS(netif);
+
+#if GAZELLE_ENABLE
+ netif->vlan_enable=false;
+#endif
+
#if ENABLE_LOOPBACK
netif->loop_first = NULL;
netif->loop_last = NULL;
@@ -441,6 +446,15 @@
return netif;
}
+#if GAZELLE_ENABLE
+void
+netif_set_vlan_tci(struct netif *netif, u16_t vlan_tci)
+{
+ netif->vlan_enable = true;
+ netif->vlan_tci = vlan_tci;
+}
+#endif
+
static void
netif_do_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
{
diff -Nur lwip-org/src/core/tcp.c lwip-vlan/src/core/tcp.c
--- lwip-org/src/core/tcp.c 2023-11-24 17:38:29.448481010 +0800
+++ lwip-vlan/src/core/tcp.c 2023-11-27 10:42:33.228481010 +0800
@@ -987,7 +987,9 @@
lpcb->tos = pcb->tos;
#if LWIP_VLAN_PCP
+#if !GAZELLE_ENABLE
lpcb->netif_hints.tci = pcb->netif_hints.tci;
+#endif
#endif /* LWIP_VLAN_PCP */
#if GAZELLE_TCP_REUSE_IPPORT
lpcb->connect_num = 0;
diff -Nur lwip-org/src/core/tcp_in.c lwip-vlan/src/core/tcp_in.c
--- lwip-org/src/core/tcp_in.c 2023-11-24 17:38:29.448481010 +0800
+++ lwip-vlan/src/core/tcp_in.c 2023-11-27 10:42:33.228481010 +0800
@@ -808,7 +808,9 @@
npcb->listener = pcb;
#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */
#if LWIP_VLAN_PCP
+#if !GAZELLE_ENABLE
npcb->netif_hints.tci = pcb->netif_hints.tci;
+#endif
#endif /* LWIP_VLAN_PCP */
/* inherit socket options */
npcb->so_options = pcb->so_options & SOF_INHERITED;
diff -Nur lwip-org/src/include/lwip/netif.h lwip-vlan/src/include/lwip/netif.h
--- lwip-org/src/include/lwip/netif.h 2023-11-24 17:38:29.440481010 +0800
+++ lwip-vlan/src/include/lwip/netif.h 2023-11-27 18:33:07.936481010 +0800
@@ -45,6 +45,10 @@
#include "lwip/ip_addr.h"
+#if GAZELLE_ENABLE
+#include <stdbool.h>
+#endif
+
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
@@ -357,6 +361,10 @@
#if GAZELLE_ENABLE
u64_t rxol_flags;
u64_t txol_flags;
+ bool vlan_enable;
+ /** vlan id is an attribute of NIC. The variable 'netif_hints' is not used because it is assigned by pcb,
+ * while non transport layers without pcb cannot be enabled */
+ u16_t vlan_tci;
#endif
/** descriptive abbreviation */
char name[2];
@@ -484,6 +492,7 @@
#define netif_get_rxol_flags(netif) ((netif)->rxol_flags)
#define netif_get_txol_flags(netif) ((netif)->txol_flags)
+void netif_set_vlan_tci(struct netif *netif, u16_t vlan_tci);
void netif_set_rtc_mode(struct netif *netif);
void netif_set_rxol_flags(struct netif *netif, u64_t flags);
void netif_set_txol_flags(struct netif *netif, u64_t flags);
diff -Nur lwip-org/src/netif/ethernet.c lwip-vlan/src/netif/ethernet.c
--- lwip-org/src/netif/ethernet.c 2023-11-24 17:38:29.444481010 +0800
+++ lwip-vlan/src/netif/ethernet.c 2023-11-27 11:07:48.464481010 +0800
@@ -283,9 +283,15 @@
vlan_prio_vid = LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type);
#elif LWIP_VLAN_PCP
vlan_prio_vid = -1;
+#if !GAZELLE_ENABLE
if (netif->hints && (netif->hints->tci >= 0)) {
vlan_prio_vid = (u16_t)netif->hints->tci;
}
+#else
+ if (netif->vlan_enable) {
+ vlan_prio_vid = netif->vlan_tci;
+ }
+#endif /* GAZELLE_ENABLE */
#endif
if (vlan_prio_vid >= 0) {
struct eth_vlan_hdr *vlanhdr;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_lwip.git
git@gitee.com:openharmony/third_party_lwip.git
openharmony
third_party_lwip
third_party_lwip
master

搜索帮助