update ping debug commands

This commit is contained in:
wlyu 2021-12-22 13:46:19 +08:00
commit ebb1321b7c
310 changed files with 132313 additions and 132584 deletions

View File

@ -32,9 +32,8 @@
* Includes
******************************************************************************/
#if LWIP_IPV4 && LWIP_RAW
//#if LWIP_IPV4 && LWIP_RAW
#if 1
#include "ping.h"
#include "lwip/opt.h"
@ -81,7 +80,6 @@
/* System clock name. */
#define TEST_CLOCK_NAME kCLOCK_CoreSysClk
/*******************************************************************************
* Prototypes
******************************************************************************/

View File

@ -23,13 +23,18 @@
#include "udp_echo.h"
#include <connect_ethernet.h>
static void NetStackTaskCreate(void* param);
#define UDP_TASK_STACK_SIZE 2048
extern void TcpIpInit(void);
extern char* send_msg;
int UdpEchoSocketDemo(int argc, char *argv[])
static void NetStackTaskCreate(void* param)
{
TcpIpInit();
UdpEchoInit();
}
int LwipUdpDemo(int argc, char *argv[])
{
if (argc == 2)
{
@ -42,7 +47,7 @@ int UdpEchoSocketDemo(int argc, char *argv[])
(const char* )"NetStackTaskCreate",
NetStackTaskCreate,
(void* )NULL,
(uint16_t )512,
(uint16_t )UDP_TASK_STACK_SIZE,
15);
if(thr_id >= 0)
@ -51,19 +56,11 @@ int UdpEchoSocketDemo(int argc, char *argv[])
KPrintf("NetStackTaskCreate create failed !\n");
return -1;
}
return 0;
}
#ifndef SEPARATE_COMPILE
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
UdpEchoSocketDemo, UdpEchoSocketDemo, tcp_echo_socket function );
UdpTest, LwipUdpDemo, UDP socket demo function);
#endif
static void NetStackTaskCreate(void* param)
{
TcpIpInit();
UdpEchoInit();
}

View File

@ -39,8 +39,7 @@
*/
#include "lwip/opt.h"
//tst by wly
#include "ip.h"
#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
#include "ping.h"
@ -184,8 +183,6 @@ ping_recv(int s)
struct sockaddr_storage from;
int fromlen = sizeof(from);
// lw_print("lw: [%s] recv %d\n",__func__, fromlen);
while((len = lwip_recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0) {
if (len >= (int)(sizeof(struct ip_hdr)+sizeof(struct icmp_echo_hdr))) {
ip_addr_t fromaddr;
@ -344,7 +341,6 @@ ping_send(struct raw_pcb *raw, const ip_addr_t *addr)
p = pbuf_alloc(PBUF_IP, (u16_t)ping_size, PBUF_RAM);
if (!p) {
lw_trace();
return;
}
if ((p->len == p->tot_len) && (p->next == NULL)) {
@ -380,9 +376,6 @@ ping_raw_init(void)
ping_pcb = raw_new(IP_PROTO_ICMP);
LWIP_ASSERT("ping_pcb != NULL", ping_pcb != NULL);
//tst by wly
lw_print("lw: [%s] pcb %p\n", __func__, ping_pcb);
raw_recv(ping_pcb, ping_recv, NULL);
raw_bind(ping_pcb, IP_ADDR_ANY);
sys_timeout(PING_DELAY, ping_timeout, ping_pcb);

View File

@ -61,6 +61,12 @@
#include "lwip/api.h"
#include <xs_ktask.h>
#ifdef BOARD_CORTEX_M7_EVB
#define LWIP_UDP_TASK_STACK 4096
#else
#define LWIP_UDP_TASK_STACK 2048
#endif
#define RECV_DATA (1024)
char* send_msg = "\n\nThis one is UDP pkg. Congratulations on you.\n\n";
@ -156,8 +162,6 @@ static void UdpEchoThreadClient(void *arg)
KPrintf("UDP connect sucess, start to send.\n");
KPrintf("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
while (1)
{
KPrintf("Lwip client is running.\n");
@ -182,9 +186,9 @@ void
UdpEchoInit(void)
{
#ifdef SET_AS_SERVER
sys_thread_new("UdpEchoThreadServer", UdpEchoThreadServer, NULL, 2048, 4);
sys_thread_new("UdpEchoThreadServer", UdpEchoThreadServer, NULL, LWIP_UDP_TASK_STACK, 4);
#else
sys_thread_new("UdpEchoThreadClient", UdpEchoThreadClient, NULL, 2048, 4);
sys_thread_new("UdpEchoThreadClient", UdpEchoThreadClient, NULL, LWIP_UDP_TASK_STACK, 4);
#endif
}

View File

@ -287,7 +287,7 @@ err_t ethernetif_init(struct netif *netif, struct ethernetif *ethernetif,
/* Init ethernetif parameters.*/
*ethernetif_enet_ptr(ethernetif) = ethernetif_get_enet_base(enetIdx);
LWIP_ASSERT("*ethernetif_enet_ptr(ethernetif) != NULL", (*ethernetif_enet_ptr(ethernetif) != NULL));
// LWIP_ASSERT("*ethernetif_enet_ptr(ethernetif) != NULL", (*ethernetif_enet_ptr(ethernetif) != NULL));
/* set MAC hardware address length */
netif->hwaddr_len = ETH_HWADDR_LEN;

View File

@ -146,8 +146,7 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
- To use this feature let the following define uncommented.
- To disable it and process by CPU comment the the checksum.
*/
#define CHECKSUM_BY_HARDWARE
//#define CHECKSUM_BY_HARDWARE
#ifdef CHECKSUM_BY_HARDWARE
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
@ -208,7 +207,6 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
---------------------------------
*/
#define DEFAULT_UDP_RECVMBOX_SIZE 10
#define DEFAULT_TCP_RECVMBOX_SIZE 10
#define DEFAULT_ACCEPTMBOX_SIZE 10
@ -232,268 +230,15 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
---------- Lwip Debug options ----------
----------------------------------------
*/
//#define LWIP_DEBUG 1
#define LWIP_DEBUG 1
#define LWIP_IPV4 1
#define LWIP_RAW 1
#define FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE
#define lw_print KPrintf
#endif /* __LWIPOPTS_H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
//#ifndef __LWIPOPTS_H__
//#define __LWIPOPTS_H__
//#define TCPIP_MBOX_SIZE 6
//#define TCPIP_THREAD_NAME "tcp/ip"
//#define TCPIP_THREAD_STACKSIZE 1500
//#define TCPIP_THREAD_PRIO 3
//#define DEFAULT_THREAD_STACKSIZE 1500
//#define DEFAULT_THREAD_PRIO 3
//#define ETH_PAD_SIZE 2
//#define LWIP_TCPIP_CORE_LOCKING 0 ///TODO Initialize mutex
////#define LWIP_DEBUG
////#define DBG_TYPES_ON 0xff
//#define ETHARP_DEBUG LWIP_DBG_OFF
//#define NETIF_DEBUG LWIP_DBG_ON
//#define PBUF_DEBUG LWIP_DBG_OFF
//#define API_LIB_DEBUG LWIP_DBG_OFF
//#define API_MSG_DEBUG LWIP_DBG_OFF
//#define SOCKETS_DEBUG LWIP_DBG_OFF
//#define ICMP_DEBUG LWIP_DBG_OFF
//#define IGMP_DEBUG LWIP_DBG_OFF
//#define INET_DEBUG LWIP_DBG_OFF
//#define IP_DEBUG LWIP_DBG_OFF
//#define IP_REASS_DEBUG LWIP_DBG_OFF
//#define RAW_DEBUG LWIP_DBG_OFF
//#define MEM_DEBUG LWIP_DBG_OFF
//#define MEMP_DEBUG LWIP_DBG_OFF
//#define SYS_DEBUG LWIP_DBG_OFF
//#define TCP_DEBUG LWIP_DBG_OFF
//#define TCP_INPUT_DEBUG LWIP_DBG_OFF
//#define TCP_FR_DEBUG LWIP_DBG_OFF
//#define TCP_RTO_DEBUG LWIP_DBG_OFF
//#define TCP_CWND_DEBUG LWIP_DBG_OFF
//#define TCP_WND_DEBUG LWIP_DBG_OFF
//#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
//#define TCP_RST_DEBUG LWIP_DBG_OFF
//#define TCP_QLEN_DEBUG LWIP_DBG_OFF
//#define UDP_DEBUG LWIP_DBG_OFF
//#define TCPIP_DEBUG LWIP_DBG_OFF
//#define PPP_DEBUG LWIP_DBG_OFF
//#define SLIP_DEBUG LWIP_DBG_OFF
//#define DHCP_DEBUG LWIP_DBG_OFF
//#define AUTOIP_DEBUG LWIP_DBG_OFF
//#define SNMP_MSG_DEBUG LWIP_DBG_OFF
//#define SNMP_MIB_DEBUG LWIP_DBG_OFF
//#define DNS_DEBUG LWIP_DBG_OFF
//#define LWIP_NOASSERT 0
///**
// * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
// * critical regions during buffer allocation, deallocation and memory
// * allocation and deallocation.
// */
//#define SYS_LIGHTWEIGHT_PROT 1
///*
// ------------------------------------
// ---------- Memory options ----------
// ------------------------------------
//*/
///**
// * MEM_ALIGNMENT: should be set to the alignment of the CPU
// * 4 byte alignment -> #define MEM_ALIGNMENT 4
// * 2 byte alignment -> #define MEM_ALIGNMENT 2
// */
//#define MEM_ALIGNMENT 4
///** STF (9*1024)
// * MEM_SIZE: the size of the heap memory. If the application will send
// * a lot of data that needs to be copied, this should be set high.
// */
//#define MEM_SIZE (8*1024)
///*
// ------------------------------------------------
// ---------- Internal Memory Pool Sizes ----------
// ------------------------------------------------
//*/
///** STF 40
// * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
// * If the application sends a lot of data out of ROM (or other static memory),
// * this should be set high.
// */
//#define MEMP_NUM_PBUF 20
///** STF 8
// * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
// * (requires the LWIP_TCP option)
// */
//#define MEMP_NUM_TCP_PCB 10
///**
// * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
// * (requires the LWIP_TCP option)
// */
//#define MEMP_NUM_TCP_SEG 8
///** STF 3
// * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
// * (requires NO_SYS==0)
// */
//#define MEMP_NUM_SYS_TIMEOUT 5
///**
// * MEMP_NUM_NETBUF: the number of struct netbufs.
// * (only needed if you use the sequential API, like api_lib.c)
// */
//#define MEMP_NUM_NETBUF 4
///** STF 8
// * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
// */
//#define PBUF_POOL_SIZE 4
///*
// ----------------------------------
// ---------- Pbuf options ----------
// ----------------------------------
//*/
///**
// * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
// * designed to accomodate single full size TCP frame in one pbuf, including
// * TCP_MSS, IP header, and link header.
// */
//#define PBUF_POOL_BUFSIZE 1500
///*
// ---------------------------------
// ---------- TCP options ----------
// ---------------------------------
//*/
///**
// * LWIP_TCP==1: Turn on TCP.
// */
//#define LWIP_TCP 1
///* TCP Maximum segment size. */
//#define TCP_MSS 1500
///* TCP sender buffer space (bytes). */
//#define TCP_SND_BUF 2*TCP_MSS
///**
// * TCP_WND: The size of a TCP window.
// */
//#define TCP_WND 2*TCP_MSS //1500
///**
// * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments.
// */
//#define TCP_SYNMAXRTX 4
///*
// ---------------------------------
// ---------- RAW options ----------
// ---------------------------------
//*/
///**
// * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
// */
//#define LWIP_RAW 0
///*
// ----------------------------------------------
// ---------- Sequential layer options ----------
// ----------------------------------------------
//*/
///**
// * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
// */
//#define LWIP_NETCONN 1
///*
// ------------------------------------
// ---------- Socket options ----------
// ------------------------------------
//*/
///**
// * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
// */
//#define LWIP_SOCKET 1
///*
// ----------------------------------------
// ---------- Statistics options ----------
// ----------------------------------------
//*/
///**
// * LWIP_STATS==1: Enable statistics collection in lwip_stats.
// */
//#define LWIP_STATS 0
///*
// ----------------------------------
// ---------- DHCP options ----------
// ----------------------------------
//*/
///**
// * LWIP_DHCP==1: Enable DHCP module.
// */
//#define LWIP_DHCP 0
///*
// ----------------------------------
// ---------- IGMP options ----------
// ----------------------------------
//*/
///**
// * LWIP_IGMP==1: Turn on IGMP module.
// */
//#define LWIP_IGMP 0
//#define LWIP_PROVIDE_ERRNO 1
////#define LWIP_SNMP 1
//#endif /* __LWIPOPTS_H__ */

View File

@ -439,12 +439,3 @@ void TcpIpInit(void)
((gnetif.ip_addr.addr)&0xff000000)>>24);
}

View File

@ -69,8 +69,8 @@
#define IP_ADDR0_ClIENT 192
#define IP_ADDR1_ClIENT 168
#define IP_ADDR2_ClIENT 0
#define IP_ADDR3_ClIENT 177
#define IP_ADDR2_ClIENT 250
#define IP_ADDR3_ClIENT 253
/*NETMASK*/
#define NETMASK_ADDR0 255
@ -81,8 +81,8 @@
/*Gateway Address*/
#define GW_ADDR0 192
#define GW_ADDR1 168
#define GW_ADDR2 0
#define GW_ADDR3 1
#define GW_ADDR2 250
#define GW_ADDR3 252
/* USER CODE END 0 */
#define SYS_MBOX_NULL 0

View File

@ -78,7 +78,8 @@
* systems, this should be defined to something less resource-consuming.
*/
#ifndef LWIP_PLATFORM_DIAG
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
#include "xs_base.h"
#define LWIP_PLATFORM_DIAG(x) do {KPrintf x;} while(0)
#include <stdio.h>
#include <stdlib.h>
#endif

View File

@ -888,7 +888,7 @@
* LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
*/
#if !defined LWIP_RAW || defined __DOXYGEN__
#define LWIP_RAW 0
#define LWIP_RAW 1
#endif
/**