70 lines
2.2 KiB
Diff
70 lines
2.2 KiB
Diff
diff -Nur lwip-gz-addr/src/include/lwip/priv/tcp_priv.h lwip-qtuple/src/include/lwip/priv/tcp_priv.h
|
|
--- lwip-gz-addr/src/include/lwip/priv/tcp_priv.h 2023-12-04 14:08:00.672481010 +0800
|
|
+++ lwip-qtuple/src/include/lwip/priv/tcp_priv.h 2023-12-11 11:19:34.552481010 +0800
|
|
@@ -347,24 +347,12 @@
|
|
LWIP_ASSERT("Invalid parameter", pcb != NULL);
|
|
|
|
struct gazelle_quintuple qtuple;
|
|
- if (IP_IS_V4_VAL(pcb->local_ip)) {
|
|
- qtuple.protocol = 0;
|
|
- qtuple.src_ip = ip_2_ip4(&pcb->local_ip)->addr;
|
|
- qtuple.src_port = lwip_htons(pcb->local_port);
|
|
- qtuple.dst_ip = ip_2_ip4(&pcb->remote_ip)->addr;
|
|
- qtuple.dst_port = lwip_htons(pcb->remote_port);
|
|
- } else {
|
|
-#if LWIP_IPV6
|
|
- qtuple.protocol = 1;
|
|
- qtuple.src_port = lwip_htons(pcb->local_port);
|
|
- qtuple.dst_port = lwip_htons(pcb->remote_port);
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
- qtuple.src_ip6[i] = pcb->local_ip.u_addr.ip6.addr[i];
|
|
- qtuple.dst_ip6[i] = pcb->remote_ip.u_addr.ip6.addr[i];
|
|
- }
|
|
-#endif
|
|
- }
|
|
+ qtuple.protocol = IP_IS_V4_VAL(pcb->local_ip) ? GZ_ADDR_TYPE_V4 : GZ_ADDR_TYPE_V6;
|
|
+ qtuple.src_ip = *((gz_addr_t *)&pcb->local_ip);
|
|
+ qtuple.src_port = lwip_htons(pcb->local_port);
|
|
+ qtuple.dst_ip = *((gz_addr_t *)&pcb->remote_ip);
|
|
+ qtuple.dst_port = lwip_htons(pcb->remote_port);
|
|
|
|
#if GAZELLE_TCP_REUSE_IPPORT
|
|
if (reg_type == REG_RING_TCP_CONNECT_CLOSE) {
|
|
diff -Nur lwip-gz-addr/src/include/reg_sock.h lwip-qtuple/src/include/reg_sock.h
|
|
--- lwip-gz-addr/src/include/reg_sock.h 2023-12-06 19:41:19.792481010 +0800
|
|
+++ lwip-qtuple/src/include/reg_sock.h 2023-12-11 16:17:59.860481010 +0800
|
|
@@ -37,6 +37,16 @@
|
|
|
|
#include "lwipopts.h"
|
|
|
|
+/* compatible with lwip_ip_addr_type */
|
|
+enum gz_ip_addr_type {
|
|
+ /** IPv4 */
|
|
+ GZ_ADDR_TYPE_V4 = 0U,
|
|
+ /** IPv6 */
|
|
+ GZ_ADDR_TYPE_V6 = 6U,
|
|
+ /** IPv4+IPv6 ("dual-stack") */
|
|
+ GZ_ADDR_TYPE_ANY = 46U
|
|
+};
|
|
+
|
|
/* compatible with ip4_addr_t */
|
|
struct gz_ip4 {
|
|
uint32_t addr;
|
|
@@ -78,13 +88,8 @@
|
|
uint16_t src_port;
|
|
uint16_t dst_port;
|
|
|
|
- /* TODO: replace with gz_addr_t */
|
|
- uint32_t src_ip;
|
|
- uint32_t dst_ip;
|
|
-#if LWIP_IPV6
|
|
- uint32_t src_ip6[4];
|
|
- uint32_t dst_ip6[4];
|
|
-#endif
|
|
+ gz_addr_t src_ip;
|
|
+ gz_addr_t dst_ip;
|
|
};
|
|
|
|
struct reg_ring_msg {
|