• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff -Nur lwip-org/src/core/tcp.c lwip-gz-addr/src/core/tcp.c
2--- lwip-org/src/core/tcp.c	2023-12-04 14:10:25.364481010 +0800
3+++ lwip-gz-addr/src/core/tcp.c	2023-12-04 14:33:31.712481010 +0800
4@@ -1161,7 +1161,7 @@
5
6       if (__atomic_load_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) {
7 #if GAZELLE_ENABLE
8-        if (port_in_stack_queue(pcb->remote_ip, pcb->local_ip, pcb->remote_port, tcp_port)) {
9+        if (port_in_stack_queue((gz_addr_t *)&pcb->remote_ip, (gz_addr_t *)&pcb->local_ip, pcb->remote_port, tcp_port)) {
10             tmp_port = tcp_port;
11             __atomic_store_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE);
12             break;
13diff -Nur lwip-org/src/core/udp.c lwip-gz-addr/src/core/udp.c
14--- lwip-org/src/core/udp.c	2023-12-04 14:10:25.364481010 +0800
15+++ lwip-gz-addr/src/core/udp.c	2023-12-04 14:19:58.832481010 +0800
16@@ -132,7 +132,7 @@
17     }
18
19     if (__atomic_load_n(&port_state[udp_port - UDP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) {
20-      if (port_in_stack_queue(dst_pcb->remote_ip, dst_pcb->local_ip, dst_pcb->remote_port, udp_port)) {
21+      if (port_in_stack_queue((gz_addr_t *)&dst_pcb->remote_ip, (gz_addr_t *)&dst_pcb->local_ip, dst_pcb->remote_port, udp_port)) {
22           tmp_port = udp_port;
23           __atomic_store_n(&port_state[udp_port - UDP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE);
24           break;
25diff -Nur lwip-org/src/include/lwipopts.h lwip-gz-addr/src/include/lwipopts.h
26--- lwip-org/src/include/lwipopts.h	2023-12-04 14:10:25.368481010 +0800
27+++ lwip-gz-addr/src/include/lwipopts.h	2023-12-06 19:29:24.520481010 +0800
28@@ -184,6 +184,7 @@
29 */
30 #define LWIP_IPV6                1
31 #define IP6_HLEN                 40
32+#define LWIP_IPV6_SCOPES         1
33
34 /*
35    ---------------------------------
36diff -Nur lwip-org/src/include/reg_sock.h lwip-gz-addr/src/include/reg_sock.h
37--- lwip-org/src/include/reg_sock.h	2023-12-04 14:10:25.368481010 +0800
38+++ lwip-gz-addr/src/include/reg_sock.h	2023-12-06 19:41:19.792481010 +0800
39@@ -34,7 +34,35 @@
40 #define __REG_SOCK_H__
41
42 #include <stdbool.h>
43-#include "lwip/ip_addr.h"
44+
45+#include "lwipopts.h"
46+
47+/*  compatible with ip4_addr_t */
48+struct gz_ip4 {
49+  uint32_t addr;
50+};
51+
52+/*  compatible with ip6_addr_t */
53+#if LWIP_IPV6
54+struct gz_ip6 {
55+  uint32_t addr[4];
56+#if LWIP_IPV6_SCOPES
57+  uint8_t zone;
58+#endif /* LWIP_IPV6_SCOPES */
59+};
60+#endif /* LWIP_IPV6 */
61+
62+/* gazelle ip address, compatible with ip_addr_t */
63+typedef struct gz_addr {
64+    union {
65+#if LWIP_IPV6
66+        struct gz_ip6 ip6;
67+#endif /* LWIP_IPV6 */
68+        struct gz_ip4 ip4;
69+    } u_addr;
70+    /** @ref lwip_ip_addr_type */
71+    uint8_t type;
72+} gz_addr_t;
73
74 enum reg_ring_type {
75     REG_RING_TCP_LISTEN = 0,
76@@ -45,10 +73,12 @@
77 };
78
79 struct gazelle_quintuple {
80-	uint32_t protocol;
81+    uint32_t protocol;
82     /* net byte order */
83     uint16_t src_port;
84     uint16_t dst_port;
85+
86+    /* TODO: replace with gz_addr_t */
87     uint32_t src_ip;
88     uint32_t dst_ip;
89 #if LWIP_IPV6
90@@ -65,6 +95,6 @@
91 };
92
93 extern int vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple);
94-extern bool port_in_stack_queue(ip_addr_t src_ip, ip_addr_t dst_ip, uint16_t src_port, uint16_t dst_port);
95+extern bool port_in_stack_queue(gz_addr_t *src_ip, gz_addr_t *dst_ip, uint16_t src_port, uint16_t dst_port);
96
97 #endif /* __REG_SOCK_H__ */
98