${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
${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)
+++ /dev/null
-#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);
-}
+++ /dev/null
-#include "socket_test.h"
-#include "lwip/opt.h"
-#include "lwip/sys.h"
-#include "lwip/api.h"
-#include <lwip/sockets.h>
-#include <errno.h>
-
-#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
- // 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);
+ 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);
// 2. 创建消息队列
int ret = osal_msg_queue_create(
#endif
#ifndef TCP_WND
-#define TCP_WND (TCP_SND_BUF * 2 / 3)
+#define TCP_WND (TCP_SND_BUF * 2 / 6) //改善810的下载速度
+#endif
+
+#ifndef LWIP_IGMP
+#define LWIP_IGMP 1
#endif
#ifndef LWIP_DNS_REVERSE
#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
#define LWIP_NETIF_LOOPBACK 0
#endif
+
+
#if LWIP_SNTP
#define LWIP_DHCP_MAX_NTP_SERVERS 1
+++ /dev/null
-#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);
-}
void slip_test_init(void)
{
ip4_addr_t ipaddr, netmask, gw;
-
+
printf("SLIP test initialization...\n");
-
- if (slipif_initialled) {
- printf("SLIP netif already initialized, skip re-init\n");
+
+ /* Initialize SLIP netif */
+ if (slipif_init(&slip_netif) != ERR_OK) {
+ printf("SLIP netif initialization failed!\n");
return;
}
-
+
/* Set IP address */
// IP4_ADDR(&ipaddr, 192, 168, 1, 100);
// IP4_ADDR(&netmask, 255, 255, 255, 0);
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(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;
- }
+ /* Add netif to lwIP */
+ netif_add(&slip_netif, &ipaddr, &netmask, &gw, NULL, slipif_init, tcpip_input);
netif_set_up(&slip_netif);
netif_set_link_up(&slip_netif);
+++ /dev/null
-#include "socket_test.h"
-#include "lwip/opt.h"
-#include "lwip/sys.h"
-#include "lwip/api.h"
-#include <lwip/sockets.h>
-#include <errno.h>
-
-#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
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)
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);
}
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",
#include "arch/bpstruct.h"
#endif
-/* SLIP 网卡在 tcpip_init 中于 tcpip_mbox 创建之后、tcpip_thread 内调用 slip_test_init,
- * 避免 slip_test_init 先占满堆导致 sys_mbox_new(osal_wait_init) LOS_MemAlloc 失败。 */
+#if LWIP_SLIP
+extern void slip_test_init(void);
+#endif
PACK_STRUCT_BEGIN
struct packed_struct_test {
PACK_STRUCT_FLD_8(u8_t dummy1);
dns_init();
#endif /* LWIP_DNS */
-/* slip_test_init 已移至 tcpip.c 的 tcpip_thread(tcpip mbox 就绪且 core locked 后) */
+#if LWIP_SLIP
+#if 0 // 1201patch 为编译过屏蔽
+ slip_test_init();
+#endif
+#endif /* LWIP_SLIP */
#if PPP_SUPPORT
ppp_init();
#endif
void cat1_api_suspend_protocol(void)
{
+ #if 0 // 1201patch 为编译过屏蔽
#ifdef SUPPORT_LWIP
tcpip_thread_suspend();
slipif_loop_thread_suspend();
#endif
+ #endif
}
/**
*/
void cat1_api_resume_protocol(void)
{
+ #if 0 // 1201patch 为编译过屏蔽
#ifdef SUPPORT_LWIP
tcpip_thread_resume();
slipif_loop_thread_resume();
#endif
+ #endif
}
/**