From feaa11fb77f6134639885c378d87903fc2301331 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Tue, 6 Feb 2024 09:55:23 +0800
Subject: [PATCH] adapt lwip-2.2.0

---
 src/lstack/api/lstack_rtw_api.c         |  2 +-
 src/lstack/core/lstack_lwip.c           | 16 ++++++++--------
 src/lstack/core/lstack_protocol_stack.c |  8 ++++----
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/lstack/api/lstack_rtw_api.c b/src/lstack/api/lstack_rtw_api.c
index 839d320..10bc613 100644
--- a/src/lstack/api/lstack_rtw_api.c
+++ b/src/lstack/api/lstack_rtw_api.c
@@ -168,7 +168,7 @@ static ssize_t rtw_udp_recvfrom(int sockfd, void *buf, size_t len, int flags,
         }
         sock = sock->listen_next;
         if (sock != NULL && sock->conn != NULL) {
-            sockfd = sock->conn->socket;
+            sockfd = sock->conn->callback_arg.socket;
         } else {
             if (sock == NULL) {
                 errno = EAGAIN;
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 22605dd..2ba18e2 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -973,9 +973,9 @@ void do_lwip_read_recvlist(struct protocol_stack *stack, uint32_t max_num)
 
         ssize_t len = 0;
         if (NETCONN_IS_UDP(sock)) {
-            len = lwip_recv(sock->conn->socket, NULL, SSIZE_MAX, 0);
+            len = lwip_recv(sock->conn->callback_arg.socket, NULL, SSIZE_MAX, 0);
         } else {
-            len = lwip_recv(sock->conn->socket, NULL, 0, 0);
+            len = lwip_recv(sock->conn->callback_arg.socket, NULL, 0, 0);
         }
         if (len < 0 && errno != EAGAIN) {
             sock->errevent = 1;
@@ -993,7 +993,7 @@ void do_lwip_connected_callback(struct netconn *conn)
         return;
     }
 
-    int32_t fd = conn->socket;
+    int32_t fd = conn->callback_arg.socket;
     struct lwip_sock *sock = get_socket_by_fd(fd);
     if (sock == NULL || sock->conn == NULL) {
         return;
@@ -1033,9 +1033,9 @@ static void copy_pcb_to_conn(struct gazelle_stat_lstack_conn_info *conn, const s
     conn->keep_cnt = pcb->keep_cnt;
 
     if (netconn != NULL) {
-        conn->fd = netconn->socket;
+        conn->fd = netconn->callback_arg.socket;
         conn->recv_cnt = (netconn->recvmbox == NULL) ? 0 : rte_ring_count(netconn->recvmbox->ring);
-        struct lwip_sock *sock = get_socket(netconn->socket);
+        struct lwip_sock *sock = get_socket(netconn->callback_arg.socket);
         if (sock != NULL) {
             conn->recv_ring_cnt = (sock->recv_ring == NULL) ? 0 : gazelle_ring_readable_count(sock->recv_ring);
             conn->recv_ring_cnt += (sock->recv_lastdata) ? 1 : 0;
@@ -1121,7 +1121,7 @@ uint32_t do_lwip_get_conntable(struct gazelle_stat_lstack_conn_info *conn,
         conn[conn_num].l_port = pcbl->local_port;
         conn[conn_num].tcp_sub_state = pcbl->state;
         struct netconn *netconn = (struct netconn *)pcbl->callback_arg;
-        conn[conn_num].fd = netconn != NULL ? netconn->socket : -1;
+        conn[conn_num].fd = netconn != NULL ? netconn->callback_arg.socket : -1;
         if (netconn != NULL && netconn->acceptmbox != NULL) {
             conn[conn_num].recv_cnt = rte_ring_count(netconn->acceptmbox->ring);
         }
@@ -1319,7 +1319,7 @@ err_t same_node_ring_create(struct rte_ring **ring, int size, int port, char *na
 static void init_same_node_ring(struct tcp_pcb *pcb)
 {
     struct netconn *netconn = (struct netconn *)pcb->callback_arg;
-    struct lwip_sock *sock = get_socket(netconn->socket);
+    struct lwip_sock *sock = get_socket(netconn->callback_arg.socket);
 
     pcb->client_rx_ring = NULL;
     pcb->client_tx_ring = NULL;
@@ -1334,7 +1334,7 @@ static void init_same_node_ring(struct tcp_pcb *pcb)
 err_t create_same_node_ring(struct tcp_pcb *pcb)
 {
     struct netconn *netconn = (struct netconn *)pcb->callback_arg;
-    struct lwip_sock *sock = get_socket(netconn->socket);
+    struct lwip_sock *sock = get_socket(netconn->callback_arg.socket);
 
     if (same_node_ring_create(&pcb->client_rx_ring, CLIENT_RING_SIZE, pcb->local_port, "client", "rx") != 0) {
         goto END;
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 9e2197c..8b99e82 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -903,7 +903,7 @@ void stack_send(struct rpc_msg *msg)
         return;
     }
 
-    replenish_again = do_lwip_send(stack, sock->conn->socket, sock, len, 0);
+    replenish_again = do_lwip_send(stack, sock->conn->callback_arg.socket, sock, len, 0);
     if (replenish_again < 0) {
         __sync_fetch_and_sub(&sock->call_num, 1);
         return;
@@ -1102,7 +1102,7 @@ int32_t stack_broadcast_close(int32_t fd)
         if (sock == NULL || sock->conn == NULL) {
             break;
         }
-        fd = sock->conn->socket;
+        fd = sock->conn->callback_arg.socket;
     } while (sock);
 
     return ret;
@@ -1125,7 +1125,7 @@ int stack_broadcast_shutdown(int fd, int how)
         if (sock == NULL || sock->conn == NULL) {
             break;
         }
-        fd = sock->conn->socket;
+        fd = sock->conn->callback_arg.socket;
     } while (sock);
 
     return ret;
@@ -1290,7 +1290,7 @@ int32_t stack_broadcast_accept4(int32_t fd, struct sockaddr *addr, socklen_t *ad
     }
 
     if (min_sock && min_sock->conn) {
-        ret = rpc_call_accept(min_sock->conn->socket, addr, addrlen, flags);
+        ret = rpc_call_accept(min_sock->conn->callback_arg.socket, addr, addrlen, flags);
     }
 
     if (min_sock && min_sock->wakeup && min_sock->wakeup->type == WAKEUP_EPOLL) {
-- 
2.33.0

