From a754ad322c5c5257314fe0dde34998f2e75c3c84 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 28 Apr 2026 11:46:39 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B34G=E5=BC=80=E4=B8=8D=E8=B5=B7?= =?utf8?q?=E6=9D=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../third_party/lwip/CMakeLists.txt | 41 +++++++ .../freertos/src/test/lwip_test.c | 63 ++++++++++ .../freertos/src/test/socket_test.c | 113 ++++++++++++++++++ .../lwip/lwip_adapter/liteos/src/arch/sio.c | 6 +- .../src/include/lwip/lwipopts_default.h | 12 +- .../lwip_adapter/liteos/src/test/lwip_test.c | 63 ++++++++++ .../lwip_adapter/liteos/src/test/slip_test.c | 18 +-- .../liteos/src/test/socket_test.c | 113 ++++++++++++++++++ .../lwip/lwip_v2.1.3/src/api/tcpip.c | 10 ++ .../lwip/lwip_v2.1.3/src/core/dns.c | 4 + .../lwip/lwip_v2.1.3/src/core/init.c | 11 +- .../4g/cat1Service/Service/cat1_utils.c | 4 - 12 files changed, 424 insertions(+), 34 deletions(-) create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c diff --git a/code/sdk/open_source/openharmony/third_party/lwip/CMakeLists.txt b/code/sdk/open_source/openharmony/third_party/lwip/CMakeLists.txt index 3a0e8b4fd..d00ce71bd 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/CMakeLists.txt +++ b/code/sdk/open_source/openharmony/third_party/lwip/CMakeLists.txt @@ -23,6 +23,40 @@ elseif("freertos" IN_LIST TARGET_COMPONENT) ${CMAKE_CURRENT_SOURCE_DIR}/lwip_adapter/freertos) endif() +# PPP +set(lwipppp_SRCS + ${LWIP_DIR}/src/netif/ppp/auth.c + ${LWIP_DIR}/src/netif/ppp/ccp.c + ${LWIP_DIR}/src/netif/ppp/chap-md5.c + ${LWIP_DIR}/src/netif/ppp/chap_ms.c + ${LWIP_DIR}/src/netif/ppp/chap-new.c + ${LWIP_DIR}/src/netif/ppp/demand.c + ${LWIP_DIR}/src/netif/ppp/eap.c + ${LWIP_DIR}/src/netif/ppp/ecp.c + ${LWIP_DIR}/src/netif/ppp/eui64.c + ${LWIP_DIR}/src/netif/ppp/fsm.c + ${LWIP_DIR}/src/netif/ppp/ipcp.c + ${LWIP_DIR}/src/netif/ppp/ipv6cp.c + ${LWIP_DIR}/src/netif/ppp/lcp.c + ${LWIP_DIR}/src/netif/ppp/magic.c + ${LWIP_DIR}/src/netif/ppp/mppe.c + ${LWIP_DIR}/src/netif/ppp/multilink.c + ${LWIP_DIR}/src/netif/ppp/ppp.c + ${LWIP_DIR}/src/netif/ppp/pppapi.c + ${LWIP_DIR}/src/netif/ppp/pppcrypt.c + ${LWIP_DIR}/src/netif/ppp/pppoe.c + ${LWIP_DIR}/src/netif/ppp/pppol2tp.c + ${LWIP_DIR}/src/netif/ppp/pppos.c + ${LWIP_DIR}/src/netif/ppp/upap.c + ${LWIP_DIR}/src/netif/ppp/utils.c + ${LWIP_DIR}/src/netif/ppp/vj.c + ${LWIP_DIR}/src/netif/ppp/polarssl/arc4.c + ${LWIP_DIR}/src/netif/ppp/polarssl/des.c + ${LWIP_DIR}/src/netif/ppp/polarssl/md4.c + ${LWIP_DIR}/src/netif/ppp/polarssl/md5.c + ${LWIP_DIR}/src/netif/ppp/polarssl/sha1.c +) + set(SOURCES ${CMAKE_LWIP_SOURCE_DIR}/src/core/tcp_out.c ${CMAKE_LWIP_SOURCE_DIR}/src/core/inet_chksum.c @@ -76,6 +110,13 @@ set(SOURCES ${CMAKE_LWIP_SOURCE_DIR}/src/api/api_lib.c ${CMAKE_LWIP_ADAPTER_DIR}/src/arch/sys_arch.c ${CMAKE_LWIP_ADAPTER_DIR}/src/arch/ethernetif.c + ${CMAKE_LWIP_ADAPTER_DIR}/src/arch/sio.c + ${CMAKE_LWIP_SOURCE_DIR}/src/netif/slipif.c + ${CMAKE_LWIP_ADAPTER_DIR}/src/test/lwip_test.c + ${CMAKE_LWIP_ADAPTER_DIR}/src/test/socket_test.c + ${CMAKE_LWIP_ADAPTER_DIR}/src/test/slip_test.c + ${CMAKE_CURRENT_SOURCE_DIR}/lwip_adapter/lwip_driver_adapter/lwip_driver_adapter.c + ${lwipppp_SRCS} ) if("__LITEOS__" IN_LIST DEFINES) diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c new file mode 100644 index 000000000..99e96bdba --- /dev/null +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c @@ -0,0 +1,63 @@ +#include "lwip_test.h" +#include "lwip/netif.h" +#include "lwip/netifapi.h" +#include "lwip/ethernetif.h" +#define IP_ADDR0 192 +#define IP_ADDR1 168 +#define IP_ADDR2 1 +#define IP_ADDR3 122 + +#define NETMASK_ADDR0 255 +#define NETMASK_ADDR1 255 +#define NETMASK_ADDR2 255 +#define NETMASK_ADDR3 0 + +#define GW_ADDR0 192 +#define GW_ADDR1 168 +#define GW_ADDR2 1 +#define GW_ADDR3 1 + +#define WIFI_DRIVER_IF 801 +#define HWADDR_LEN 6 + +struct netif g_netif; + +err_t my_hw_input(struct pbuf *p, struct netif *netif); + +err_t my_hw_input(struct pbuf *p, struct netif *netif) +{ + (void)p; + (void)netif; + printf("enter my_hw_input\n"); + return 0; +} + +void lwip_test_init(void) +{ + int ret = 0; + ip4_addr_t ip, gw, netmask; + + IP4_ADDR(&ip, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); + IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); + IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); + + g_netif.hwaddr_len = HWADDR_LEN; + g_netif.hwaddr[0] = 0x00; + g_netif.hwaddr[1] = 0x11; + g_netif.hwaddr[2] = 0x22; + g_netif.hwaddr[3] = 0x33; + g_netif.hwaddr[4] = 0x44; + g_netif.hwaddr[5] = 0x55; + + g_netif.flags = 4; + g_netif.input = my_hw_input; + /* Initilialize the LwIP stack */ + /* add the network interface */ + netif_add(&g_netif, &ip, &netmask, &gw, NULL, ðernetif_init, tcpip_input); + /* Registers the default network interface */ + netif_set_default(&g_netif); + + netif_is_link_up(&g_netif); + /* When the netif is fully configured this function must be called */ + netif_set_up(&g_netif); +} diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c new file mode 100644 index 000000000..d6f62e2e0 --- /dev/null +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c @@ -0,0 +1,113 @@ +#include "socket_test.h" +#include "lwip/opt.h" +#include "lwip/sys.h" +#include "lwip/api.h" +#include +#include + +#define SERVER_IP "192.168.1.121" +#define SEND_PORT 5002 +#define BUFFER_SIZE 1024 + +void udp_client(void) { + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = lwip_htons(SEND_PORT); + if (inet_aton(SERVER_IP, &server_addr.sin_addr) == 0) { + perror("Invalid server IP address"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + // 发送数据 + const char *message = "Hello, UDP Server!"; + int len = strlen(message); + printf("send message: \n"); + for (int i = 0; i < len; i++) { + printf(" %x ", message[i]); + } + printf("\n"); + if (sendto(sockfd, message, strlen(message), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error sending data"); + close(sockfd); + exit(EXIT_FAILURE); + } + sleep(1); + } +} + +#define REV_PORT 5001 +#define BUFFER_SIZE 1024 + +void udp_server(void) +{ + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = INADDR_ANY; + server_addr.sin_port = lwip_htons(REV_PORT); + + // 绑定套接字 + if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error binding socket"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + socklen_t client_len = sizeof(struct sockaddr_in); + struct sockaddr_in client_addr; + + // 接收数据 + ssize_t bytes_received = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client_addr, &client_len); + if (bytes_received == -1) { + perror("Error receiving data"); + continue; + } + + // 打印接收到的数据 + printf("Received message from %s:%d\n", inet_ntoa(client_addr.sin_addr), lwip_ntohs(client_addr.sin_port)); + printf("Received message: %d %s\n", (int)bytes_received, buffer); + printf("message: "); + for (int i = 0; i < bytes_received; i++) { + printf(" %02x ", buffer[i]); + } + printf("\n"); + + // 清空缓冲区 + memset(buffer, 0, BUFFER_SIZE); + // break; + } + + close(sockfd); +} + +void client_init(void) { + printf("___enter client_init function___\n"); + sys_thread_new("server", udp_server, NULL, 4096, 4); + sys_thread_new("client", udp_client, NULL, 4096, 4); +} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c index 3fb708d62..dc030fdb5 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c @@ -641,9 +641,9 @@ errcode_t sio_interrupt_enable(void (*data_callback)(const uint8_t *data, uint32 - printf("[SIO] Allocated %d x %d bytes = %.2f KB total\n", - SIO_PING_PONG_BUFFER_COUNT, SIO_PING_PONG_BUFFER_SIZE, - (SIO_PING_PONG_BUFFER_COUNT * SIO_PING_PONG_BUFFER_SIZE) / 1024.0); + // uint32_t total_bytes = SIO_PING_PONG_BUFFER_COUNT * SIO_PING_PONG_BUFFER_SIZE; + // printf("[SIO] Allocated %d x %d bytes = %u KB total\n", + // SIO_PING_PONG_BUFFER_COUNT, SIO_PING_PONG_BUFFER_SIZE, total_bytes / 1024); // 2. 创建消息队列 int ret = osal_msg_queue_create( diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h index 516f985b9..940098628 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h @@ -785,11 +785,7 @@ extern "C" { #endif #ifndef TCP_WND -#define TCP_WND (TCP_SND_BUF * 2 / 6) //改善810的下载速度 -#endif - -#ifndef LWIP_IGMP -#define LWIP_IGMP 1 +#define TCP_WND (TCP_SND_BUF * 2 / 3) #endif #ifndef LWIP_DNS_REVERSE @@ -804,10 +800,6 @@ extern "C" { #define LWIP_SO_RCVBUF 0 #endif -#ifndef LWIP_IPV6_MLD -#define LWIP_IPV6_MLD 0 -#endif - #ifndef LWIP_IPV6_MLD_QUERIER #define LWIP_IPV6_MLD_QUERIER 0 #endif @@ -1970,8 +1962,6 @@ TCP sender buffer space (pbufs). This must be at least = 2 * #define LWIP_NETIF_LOOPBACK 0 #endif - - #if LWIP_SNTP #define LWIP_DHCP_MAX_NTP_SERVERS 1 diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c new file mode 100644 index 000000000..99e96bdba --- /dev/null +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c @@ -0,0 +1,63 @@ +#include "lwip_test.h" +#include "lwip/netif.h" +#include "lwip/netifapi.h" +#include "lwip/ethernetif.h" +#define IP_ADDR0 192 +#define IP_ADDR1 168 +#define IP_ADDR2 1 +#define IP_ADDR3 122 + +#define NETMASK_ADDR0 255 +#define NETMASK_ADDR1 255 +#define NETMASK_ADDR2 255 +#define NETMASK_ADDR3 0 + +#define GW_ADDR0 192 +#define GW_ADDR1 168 +#define GW_ADDR2 1 +#define GW_ADDR3 1 + +#define WIFI_DRIVER_IF 801 +#define HWADDR_LEN 6 + +struct netif g_netif; + +err_t my_hw_input(struct pbuf *p, struct netif *netif); + +err_t my_hw_input(struct pbuf *p, struct netif *netif) +{ + (void)p; + (void)netif; + printf("enter my_hw_input\n"); + return 0; +} + +void lwip_test_init(void) +{ + int ret = 0; + ip4_addr_t ip, gw, netmask; + + IP4_ADDR(&ip, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); + IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); + IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); + + g_netif.hwaddr_len = HWADDR_LEN; + g_netif.hwaddr[0] = 0x00; + g_netif.hwaddr[1] = 0x11; + g_netif.hwaddr[2] = 0x22; + g_netif.hwaddr[3] = 0x33; + g_netif.hwaddr[4] = 0x44; + g_netif.hwaddr[5] = 0x55; + + g_netif.flags = 4; + g_netif.input = my_hw_input; + /* Initilialize the LwIP stack */ + /* add the network interface */ + netif_add(&g_netif, &ip, &netmask, &gw, NULL, ðernetif_init, tcpip_input); + /* Registers the default network interface */ + netif_set_default(&g_netif); + + netif_is_link_up(&g_netif); + /* When the netif is fully configured this function must be called */ + netif_set_up(&g_netif); +} diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/slip_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/slip_test.c index ba19351ed..f5c2993d4 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/slip_test.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/slip_test.c @@ -32,15 +32,14 @@ static bool slipif_initialled = false; void slip_test_init(void) { ip4_addr_t ipaddr, netmask, gw; - + printf("SLIP test initialization...\n"); - - /* Initialize SLIP netif */ - if (slipif_init(&slip_netif) != ERR_OK) { - printf("SLIP netif initialization failed!\n"); + + if (slipif_initialled) { + printf("SLIP netif already initialized, skip re-init\n"); return; } - + /* Set IP address */ // IP4_ADDR(&ipaddr, 192, 168, 1, 100); // IP4_ADDR(&netmask, 255, 255, 255, 0); @@ -48,8 +47,11 @@ void slip_test_init(void) IP_ADDR4(&ipaddr, 172, 16, 1, 5); IP_ADDR4(&netmask, 255, 255, 255, 0); IP_ADDR4(&gw, 172, 16, 1, 2); - /* Add netif to lwIP */ - netif_add(&slip_netif, &ipaddr, &netmask, &gw, NULL, slipif_init, tcpip_input); + /* Add netif to lwIP(slipif_init 由 netif_add 内部调用,勿再单独 slipif_init) */ + if (netif_add(&slip_netif, &ipaddr, &netmask, &gw, NULL, slipif_init, tcpip_input) == NULL) { + printf("SLIP netif add failed!\n"); + return; + } netif_set_up(&slip_netif); netif_set_link_up(&slip_netif); diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c new file mode 100644 index 000000000..2e8f48b01 --- /dev/null +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c @@ -0,0 +1,113 @@ +#include "socket_test.h" +#include "lwip/opt.h" +#include "lwip/sys.h" +#include "lwip/api.h" +#include +#include + +#define SERVER_IP "192.168.1.121" +#define SEND_PORT 5002 +#define BUFFER_SIZE 1024 + +void udp_client(void) { + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = lwip_htons(SEND_PORT); + if (inet_aton(SERVER_IP, &server_addr.sin_addr) == 0) { + perror("Invalid server IP address"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + // 发送数据 + const char *message = "Hello, UDP Server!"; + int len = strlen(message); + printf("send message: \n"); + for (int i = 0; i < len; i++) { + printf(" %x ", message[i]); + } + printf("\n"); + if (sendto(sockfd, message, strlen(message), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error sending data"); + close(sockfd); + exit(EXIT_FAILURE); + } + sleep(1); + } +} + +#define REV_PORT 5001 +#define BUFFER_SIZE 1024 + +void udp_server(void) +{ + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = INADDR_ANY; + server_addr.sin_port = lwip_htons(REV_PORT); + + // 绑定套接字 + if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error binding socket"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + socklen_t client_len = sizeof(struct sockaddr_in); + struct sockaddr_in client_addr; + + // 接收数据 + ssize_t bytes_received = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client_addr, &client_len); + if (bytes_received == -1) { + perror("Error receiving data"); + continue; + } + + // 打印接收到的数据 + printf("Received message from %s:%d\n", inet_ntoa(client_addr.sin_addr), lwip_ntohs(client_addr.sin_port)); + printf("Received message: %d %s\n", (int)bytes_received, buffer); + printf("message: "); + for (int i = 0; i < bytes_received; i++) { + printf(" %02x ", buffer[i]); + } + printf("\n"); + + // 清空缓冲区 + memset(buffer, 0, BUFFER_SIZE); + // break; + } + + close(sockfd); +} + +void client_init(void) { + printf("___enter client_init function___\n"); + sys_thread_new("server", udp_server, NULL, 512, 4); + sys_thread_new("client", udp_client, NULL, 512, 4); +} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c index 18d74a7ae..332de16f2 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/api/tcpip.c @@ -59,6 +59,10 @@ static app_task_definition_t taskcfg={0}; +#if LWIP_SLIP +extern void slip_test_init(void); +#endif + #define TCPIP_MSG_VAR_REF(name) API_VAR_REF(name) #define TCPIP_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct tcpip_msg, name) @@ -155,6 +159,12 @@ tcpip_thread(void *arg) LWIP_MARK_TCPIP_THREAD(); LOCK_TCPIP_CORE(); +#if LWIP_SLIP + /* 必须在 tcpip_init() 里 sys_mbox_new(&tcpip_mbox) 成功之后执行:此前 slip_test_init + * 会分配 SIO 缓冲/线程等,易耗尽系统堆,导致 osal_wait_init LOS_MemAlloc 失败。 + * 且 netif_add 要求 LWIP_ASSERT_CORE_LOCKED,此处已持锁。 */ + slip_test_init(); +#endif if (tcpip_init_done != NULL) { tcpip_init_done(tcpip_init_done_arg); } diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c index 5c6023898..ff4485842 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c @@ -333,6 +333,10 @@ dns_init(void) for (n = 0; (n < LWIP_DHCP_MAX_DNS_SERVERS); n++) { dns_setserver(n, &dnsserver); } +#ifdef DNS_SERVER_ADDRESS_SECONDARY + DNS_SERVER_ADDRESS_SECONDARY(&dnsserver); + dns_setserver(1, &dnsserver); +#endif #endif /* DNS_SERVER_ADDRESS */ LWIP_ASSERT("sanity check SIZEOF_DNS_QUERY", diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c index 067d51a05..4ca04a938 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c @@ -67,9 +67,8 @@ #include "arch/bpstruct.h" #endif -#if LWIP_SLIP -extern void slip_test_init(void); -#endif +/* SLIP 网卡在 tcpip_init 中于 tcpip_mbox 创建之后、tcpip_thread 内调用 slip_test_init, + * 避免 slip_test_init 先占满堆导致 sys_mbox_new(osal_wait_init) LOS_MemAlloc 失败。 */ PACK_STRUCT_BEGIN struct packed_struct_test { PACK_STRUCT_FLD_8(u8_t dummy1); @@ -376,11 +375,7 @@ lwip_init(void) dns_init(); #endif /* LWIP_DNS */ -#if LWIP_SLIP -#if 0 // 1201patch 为编译过屏蔽 - slip_test_init(); -#endif -#endif /* LWIP_SLIP */ +/* slip_test_init 已移至 tcpip.c 的 tcpip_thread(tcpip mbox 就绪且 core locked 后) */ #if PPP_SUPPORT ppp_init(); #endif diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c index 0bc6dea87..f61a99fd4 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c @@ -384,12 +384,10 @@ errcode_t cat1_register_time_ctl_functions(time_ctl_funcs_t *funcs) void cat1_api_suspend_protocol(void) { - #if 0 // 1201patch 为编译过屏蔽 #ifdef SUPPORT_LWIP tcpip_thread_suspend(); slipif_loop_thread_suspend(); #endif - #endif } /** @@ -405,12 +403,10 @@ void cat1_api_suspend_protocol(void) */ void cat1_api_resume_protocol(void) { - #if 0 // 1201patch 为编译过屏蔽 #ifdef SUPPORT_LWIP tcpip_thread_resume(); slipif_loop_thread_resume(); #endif - #endif } /** -- 2.17.1