forked from xuos/xiuos
fixed socket bug and optimize with lwip flag and other codes
This commit is contained in:
parent
c0de7ca44c
commit
169c3c3c5d
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
char tcp_socket_ip[] = {192, 168, 250, 252};
|
char tcp_socket_ip[] = {192, 168, 250, 252};
|
||||||
|
|
||||||
#define TCP_BUF_SIZE 1024
|
#define TCP_DEMO_BUF_SIZE 65535
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Code
|
* Code
|
||||||
|
@ -46,17 +46,15 @@ char tcp_socket_ip[] = {192, 168, 250, 252};
|
||||||
|
|
||||||
static void tcp_recv_demo(void *arg)
|
static void tcp_recv_demo(void *arg)
|
||||||
{
|
{
|
||||||
lw_print("tcp_recv_demo start.\n");
|
int fd = -1, clientfd;
|
||||||
|
|
||||||
int fd = -1;
|
|
||||||
char *recv_buf;
|
|
||||||
struct sockaddr_in tcp_addr, server_addr;
|
|
||||||
int recv_len;
|
int recv_len;
|
||||||
|
char *recv_buf;
|
||||||
|
struct sockaddr_in tcp_addr;
|
||||||
socklen_t addr_len;
|
socklen_t addr_len;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
recv_buf = (char *)malloc(TCP_BUF_SIZE);
|
recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE);
|
||||||
if (recv_buf == NULL)
|
if (recv_buf == NULL)
|
||||||
{
|
{
|
||||||
lw_print("No memory\n");
|
lw_print("No memory\n");
|
||||||
|
@ -81,16 +79,30 @@ static void tcp_recv_demo(void *arg)
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_print("tcp bind sucess, start to receive.\n");
|
lw_print("tcp bind success, start to receive.\n");
|
||||||
lw_print("\n\nLocal Port:%d\n\n", LWIP_LOCAL_PORT);
|
lw_print("\n\nLocal Port:%d\n\n", LWIP_LOCAL_PORT);
|
||||||
|
|
||||||
|
// setup socket fd as listening mode
|
||||||
|
if (listen(fd, 5) != 0 )
|
||||||
|
{
|
||||||
|
lw_print("Unable to listen\n");
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// accept client connection
|
||||||
|
clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len);
|
||||||
|
lw_print("client %s connected\n", inet_ntoa(tcp_addr.sin_addr));
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
memset(recv_buf, 0, TCP_BUF_SIZE);
|
memset(recv_buf, 0, TCP_DEMO_BUF_SIZE);
|
||||||
recv_len = recvfrom(fd, recv_buf, TCP_BUF_SIZE, 0, (struct sockaddr *)&server_addr, &addr_len);
|
recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0, (struct sockaddr *)&tcp_addr, &addr_len);
|
||||||
lw_pr_info("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
|
if(recv_len > 0)
|
||||||
lw_pr_info("Receive data : %s\n\n", recv_buf);
|
{
|
||||||
sendto(fd, recv_buf, recv_len, 0, (struct sockaddr*)&server_addr, addr_len);
|
lw_pr_info("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr));
|
||||||
|
lw_pr_info("Receive data : %d - %s\n\n", recv_len, recv_buf);
|
||||||
|
}
|
||||||
|
sendto(clientfd, recv_buf, recv_len, 0, (struct sockaddr*)&tcp_addr, addr_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
__exit:
|
__exit:
|
||||||
|
@ -116,7 +128,7 @@ void tcp_socket_recv_run(int argc, char *argv[])
|
||||||
|
|
||||||
ETH_BSP_Config();
|
ETH_BSP_Config();
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||||
sys_thread_new("tcp_recv_demo", tcp_recv_demo, NULL, 4096, 15);
|
sys_thread_new("tcp_recv_demo", tcp_recv_demo, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||||
|
@ -125,10 +137,11 @@ SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) |
|
||||||
static void tcp_send_demo(void *arg)
|
static void tcp_send_demo(void *arg)
|
||||||
{
|
{
|
||||||
int cnt = LWIP_DEMO_TIMES;
|
int cnt = LWIP_DEMO_TIMES;
|
||||||
lw_print("tcp_send_demo start.\n");
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
char send_msg[128];
|
char send_msg[128];
|
||||||
|
|
||||||
|
lw_print("%s start\n", __func__);
|
||||||
|
|
||||||
memset(send_msg, 0, sizeof(send_msg));
|
memset(send_msg, 0, sizeof(send_msg));
|
||||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -150,14 +163,14 @@ static void tcp_send_demo(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_print("tcp connect success, start to send.\n");
|
lw_print("tcp connect success, start to send.\n");
|
||||||
lw_print("\n\nTarget Port:%d\n\n", tcp_sock.sin_port);
|
lw_pr_info("\n\nTarget Port:%d\n\n", tcp_sock.sin_port);
|
||||||
|
|
||||||
while (cnt --)
|
while (cnt --)
|
||||||
{
|
{
|
||||||
lw_print("Lwip client is running.\n");
|
lw_print("Lwip client is running.\n");
|
||||||
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
|
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
|
||||||
sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr));
|
sendto(fd, send_msg, strlen(send_msg), 0, (struct sockaddr*)&tcp_sock, sizeof(struct sockaddr));
|
||||||
lw_print("Send tcp msg: %s ", send_msg);
|
lw_pr_info("Send tcp msg: %s ", send_msg);
|
||||||
MdelayKTask(1000);
|
MdelayKTask(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +191,8 @@ void tcp_socket_send_run(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ETH_BSP_Config();
|
ETH_BSP_Config();
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
|
||||||
sys_thread_new("tcp socket", tcp_send_demo, NULL, 4096, 25);
|
sys_thread_new("tcp socket", tcp_send_demo, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
* @date 2021.11.11
|
* @date 2021.11.11
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "sys_arch.h"
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/def.h"
|
#include "lwip/def.h"
|
||||||
#include "lwip/mem.h"
|
#include "lwip/mem.h"
|
||||||
|
@ -70,9 +71,10 @@
|
||||||
#include "lwip/igmp.h"
|
#include "lwip/igmp.h"
|
||||||
#include "lwip/mld6.h"
|
#include "lwip/mld6.h"
|
||||||
|
|
||||||
//#define USE_RTOS 1
|
#ifdef FSL_RTOS_XIUOS
|
||||||
//#define FSL_RTOS_FREE_RTOS
|
#define USE_RTOS 1
|
||||||
//#define FSL_RTOS_XIUOS
|
#define FSL_RTOS_FREE_RTOS
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS)
|
#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS)
|
||||||
|
|
||||||
|
@ -118,8 +120,6 @@ typedef struct EventGroupDef_t
|
||||||
|
|
||||||
struct EventGroupDef_t;
|
struct EventGroupDef_t;
|
||||||
typedef struct EventGroupDef_t * EventGroupHandle_t;
|
typedef struct EventGroupDef_t * EventGroupHandle_t;
|
||||||
#else
|
|
||||||
int lwip_sempahore;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -189,9 +189,7 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event
|
||||||
ethernetif_input(netif);
|
ethernetif_input(netif);
|
||||||
break;
|
break;
|
||||||
case kENET_TxEvent:
|
case kENET_TxEvent:
|
||||||
#ifdef FSL_RTOS_XIUOS
|
#ifndef FSL_RTOS_XIUOS
|
||||||
|
|
||||||
#else
|
|
||||||
{
|
{
|
||||||
portBASE_TYPE taskToWake = pdFALSE;
|
portBASE_TYPE taskToWake = pdFALSE;
|
||||||
|
|
||||||
|
@ -218,8 +216,7 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// KSemaphoreAbandon(ethernetif->enetSemaphore);
|
KSemaphoreAbandon(ethernetif->enetSemaphore);
|
||||||
KSemaphoreAbandon(lwip_sempahore);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -303,56 +300,6 @@ err_t ethernetif_mld_mac_filter(struct netif *netif, const ip6_addr_t *group,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define netifINTERFACE_TASK_STACK_SIZE ( 4096 )
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function is the ethernetif_input task, it is processed when a packet
|
|
||||||
* is ready to be read from the interface. It uses the function low_level_input()
|
|
||||||
* that should handle the actual reception of bytes from the network
|
|
||||||
* interface. Then the type of the received packet is determined and
|
|
||||||
* the appropriate input function is called.
|
|
||||||
*
|
|
||||||
* @param netif the lwip network interface structure for this ethernetif
|
|
||||||
*/
|
|
||||||
//void eth_input( void * pvParameters )
|
|
||||||
//{
|
|
||||||
// struct pbuf *p;
|
|
||||||
//
|
|
||||||
// for( ;; )
|
|
||||||
// {
|
|
||||||
// if (KSemaphoreObtain( lwip_sempahore, WAITING_FOREVER)==EOK)
|
|
||||||
// {
|
|
||||||
// p = low_level_input( s_pxNetIf );
|
|
||||||
//
|
|
||||||
// if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))
|
|
||||||
// {
|
|
||||||
// KPrintf("netif input return not OK ! \n");
|
|
||||||
// pbuf_free(p);
|
|
||||||
// p=NULL;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void low_level_init()
|
|
||||||
//{
|
|
||||||
// /* create the task that handles the ETH_MAC */
|
|
||||||
// uint32 thr_id = KTaskCreate((signed char*) "eth_input",
|
|
||||||
// eth_input,
|
|
||||||
// NULL,
|
|
||||||
// netifINTERFACE_TASK_STACK_SIZE,
|
|
||||||
// 15);
|
|
||||||
// if (thr_id >= 0)
|
|
||||||
// {
|
|
||||||
// StartupKTask(thr_id);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// KPrintf("Eth create failed !");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes ENET driver.
|
* Initializes ENET driver.
|
||||||
*/
|
*/
|
||||||
|
@ -397,7 +344,6 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif,
|
||||||
{
|
{
|
||||||
ethernetif->enetSemaphore = KSemaphoreCreate(0);
|
ethernetif->enetSemaphore = KSemaphoreCreate(0);
|
||||||
}
|
}
|
||||||
// lwip_sempahore = KSemaphoreCreate(0);
|
|
||||||
#else
|
#else
|
||||||
ethernetif->enetTransmitAccessEvent = xEventGroupCreate();
|
ethernetif->enetTransmitAccessEvent = xEventGroupCreate();
|
||||||
#endif
|
#endif
|
||||||
|
@ -474,7 +420,6 @@ static err_t enet_send_frame(struct ethernetif *ethernetif, unsigned char *data,
|
||||||
{
|
{
|
||||||
#ifdef FSL_RTOS_XIUOS
|
#ifdef FSL_RTOS_XIUOS
|
||||||
KSemaphoreObtain(ethernetif->enetSemaphore, portMAX_DELAY);
|
KSemaphoreObtain(ethernetif->enetSemaphore, portMAX_DELAY);
|
||||||
// KSemaphoreObtain(lwip_sempahore, portMAX_DELAY);
|
|
||||||
#else
|
#else
|
||||||
xEventGroupWaitBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, pdTRUE, (BaseType_t) false,
|
xEventGroupWaitBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, pdTRUE, (BaseType_t) false,
|
||||||
portMAX_DELAY);
|
portMAX_DELAY);
|
||||||
|
|
|
@ -84,11 +84,9 @@
|
||||||
char lwip_ipaddr[] = {192, 168, 250, 253};
|
char lwip_ipaddr[] = {192, 168, 250, 253};
|
||||||
char lwip_netmask[] = {255, 255, 255, 0};
|
char lwip_netmask[] = {255, 255, 255, 0};
|
||||||
char lwip_gwaddr[] = {192, 168, 250, 252};
|
char lwip_gwaddr[] = {192, 168, 250, 252};
|
||||||
|
char lwip_flag = 0;
|
||||||
int is_lwip_test = 0; //for lwip input thread
|
|
||||||
|
|
||||||
x_ticks_t lwip_sys_now;
|
x_ticks_t lwip_sys_now;
|
||||||
static int lwip_init_flag = 0;
|
|
||||||
|
|
||||||
struct sys_timeouts {
|
struct sys_timeouts {
|
||||||
struct sys_timeo *next;
|
struct sys_timeo *next;
|
||||||
|
@ -491,7 +489,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||||
};
|
};
|
||||||
|
|
||||||
if(lwip_init_flag)
|
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||||
{
|
{
|
||||||
lw_print("lw: [%s] already ...\n", __func__);
|
lw_print("lw: [%s] already ...\n", __func__);
|
||||||
|
|
||||||
|
@ -507,7 +505,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||||
netif_set_up(&gnetif);
|
netif_set_up(&gnetif);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lwip_init_flag = 1;
|
set_lwip_bit(LWIP_INIT_FLAG);
|
||||||
|
|
||||||
lw_print("lw: [%s] start ...\n", __func__);
|
lw_print("lw: [%s] start ...\n", __func__);
|
||||||
|
|
||||||
|
@ -522,7 +520,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||||
netif_set_default(&gnetif);
|
netif_set_default(&gnetif);
|
||||||
netif_set_up(&gnetif);
|
netif_set_up(&gnetif);
|
||||||
|
|
||||||
if(is_lwip_test)
|
if(chk_lwip_bit(LWIP_PRINT_FLAG))
|
||||||
{
|
{
|
||||||
lw_pr_info("\r\n************************************************\r\n");
|
lw_pr_info("\r\n************************************************\r\n");
|
||||||
lw_pr_info(" Network Configuration\r\n");
|
lw_pr_info(" Network Configuration\r\n");
|
||||||
|
@ -553,12 +551,13 @@ void lwip_config_tcp(char *ip, char *mask, char *gw)
|
||||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||||
};
|
};
|
||||||
|
|
||||||
if(lwip_init_flag)
|
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||||
{
|
{
|
||||||
lw_print("lw: [%s] already ...\n", __func__);
|
lw_print("lw: [%s] already ...\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lwip_init_flag = 1;
|
|
||||||
|
set_lwip_bit(LWIP_INIT_FLAG);
|
||||||
|
|
||||||
tcpip_init(NULL, NULL);
|
tcpip_init(NULL, NULL);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
#define LWIP_DEMO_TIMES 3
|
#define LWIP_DEMO_TIMES 3
|
||||||
#define LWIP_TASK_STACK_SIZE 4096
|
#define LWIP_TASK_STACK_SIZE 4096
|
||||||
#define LWIP_TASK_PRIO 15
|
#define LWIP_DEMO_TASK_PRIO 20
|
||||||
|
|
||||||
/* MAC address configuration. */
|
/* MAC address configuration. */
|
||||||
#define configMAC_ADDR {0x02, 0x12, 0x13, 0x10, 0x15, 0x11}
|
#define configMAC_ADDR {0x02, 0x12, 0x13, 0x10, 0x15, 0x11}
|
||||||
|
@ -82,16 +82,23 @@ typedef int32 sys_mbox_t;
|
||||||
typedef int32 sys_thread_t;
|
typedef int32 sys_thread_t;
|
||||||
typedef x_base sys_prot_t;
|
typedef x_base sys_prot_t;
|
||||||
|
|
||||||
#define MS_PER_SYSTICK_F407 1000/TICK_PER_SECOND
|
#define MS_PER_SYSTICK_F407 (1000 / TICK_PER_SECOND)
|
||||||
|
|
||||||
//debug rtos with IRQ
|
//debug rtos with IRQ
|
||||||
//#define FSL_RTOS_XIUOS
|
//#define FSL_RTOS_XIUOS
|
||||||
|
|
||||||
|
extern char lwip_flag;
|
||||||
|
|
||||||
|
#define LWIP_INIT_FLAG (1 << 0)
|
||||||
|
#define LWIP_PRINT_FLAG (1 << 1)
|
||||||
|
|
||||||
|
#define set_lwip_bit(__bit) lwip_flag |= (__bit)
|
||||||
|
#define clr_lwip_bit(__bit) lwip_flag &= ~(__bit)
|
||||||
|
#define chk_lwip_bit(__bit) ((lwip_flag & (__bit)) == (__bit))
|
||||||
|
|
||||||
extern char lwip_ipaddr[];
|
extern char lwip_ipaddr[];
|
||||||
extern char lwip_netmask[];
|
extern char lwip_netmask[];
|
||||||
extern char lwip_gwaddr[];
|
extern char lwip_gwaddr[];
|
||||||
extern int is_lwip_test;
|
|
||||||
extern int lwip_sempahore;
|
|
||||||
extern struct netif gnetif;
|
extern struct netif gnetif;
|
||||||
|
|
||||||
void lwip_tcp_init(void);
|
void lwip_tcp_init(void);
|
||||||
|
|
|
@ -133,7 +133,7 @@ void lwip_dhcp_test(void)
|
||||||
ETH_BSP_Config();
|
ETH_BSP_Config();
|
||||||
|
|
||||||
lwip_config_net(ip_addr, ip_addr, ip_addr);
|
lwip_config_net(ip_addr, ip_addr, ip_addr);
|
||||||
is_lwip_test = 1;
|
set_lwip_bit(LWIP_PRINT_FLAG);
|
||||||
|
|
||||||
dhcp_start(&gnetif);
|
dhcp_start(&gnetif);
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void lwip_dhcp_test(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is_lwip_test = 0;
|
clr_lwip_bit(LWIP_PRINT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,11 +101,13 @@ void lwip_ping_thread(int argc, char *argv[])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if (LWIP_DHCP) && (PING_USE_SOCKETS)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
get_url_ip(argv[1]);
|
get_url_ip(argv[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
lw_print("lw: [%s] argc %d\n", __func__, argc);
|
lw_print("lw: [%s] argc %d\n", __func__, argc);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void lwip_tcp_send_run(int argc, char *argv[])
|
||||||
|
|
||||||
ETH_BSP_Config();
|
ETH_BSP_Config();
|
||||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||||
sys_thread_new("tcp send", lwip_tcp_send_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_TASK_PRIO);
|
sys_thread_new("tcp send", lwip_tcp_send_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||||
|
|
|
@ -105,10 +105,6 @@ static u32_t ping_time;
|
||||||
static struct raw_pcb *ping_pcb;
|
static struct raw_pcb *ping_pcb;
|
||||||
#endif /* PING_USE_SOCKETS */
|
#endif /* PING_USE_SOCKETS */
|
||||||
|
|
||||||
#define PING_THREAD_STACKSIZE 4096
|
|
||||||
#define PING_THREAD_PRIO 15
|
|
||||||
|
|
||||||
|
|
||||||
/** Prepare a echo ICMP request */
|
/** Prepare a echo ICMP request */
|
||||||
static void
|
static void
|
||||||
ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
|
ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
|
||||||
|
@ -412,7 +408,7 @@ ping_init(const ip_addr_t* ping_addr)
|
||||||
ping_target = ping_addr;
|
ping_target = ping_addr;
|
||||||
|
|
||||||
#if PING_USE_SOCKETS
|
#if PING_USE_SOCKETS
|
||||||
th = sys_thread_new("ping_thread", ping_thread, NULL, PING_THREAD_STACKSIZE, PING_THREAD_PRIO);
|
th = sys_thread_new("ping_thread", ping_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||||
lw_print("lw: [%s] new thread %d addr %#x\n", __func__, th, (*ping_addr).addr);
|
lw_print("lw: [%s] new thread %d addr %#x\n", __func__, th, (*ping_addr).addr);
|
||||||
#else /* PING_USE_SOCKETS */
|
#else /* PING_USE_SOCKETS */
|
||||||
ping_raw_init();
|
ping_raw_init();
|
||||||
|
@ -476,6 +472,7 @@ int lwip_ping_recv(int s, int *ttl)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LWIP_DHCP) && (PING_USE_SOCKETS)
|
||||||
int get_url_ip(char* url)
|
int get_url_ip(char* url)
|
||||||
{
|
{
|
||||||
#if LWIP_VERSION_MAJOR >= 2U
|
#if LWIP_VERSION_MAJOR >= 2U
|
||||||
|
@ -539,6 +536,6 @@ int get_url_ip(char* url)
|
||||||
lwip_close(s);
|
lwip_close(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_RAW */
|
#endif /* LWIP_RAW */
|
||||||
|
|
Loading…
Reference in New Issue