complie and debug test_net
This commit is contained in:
@@ -56,6 +56,7 @@ libsem = $(KERNEL_ROOT)/services/app/libsemaphore.o
|
||||
lwip: COMPILER lwip_server.o | bin
|
||||
@${ld} ${user_ldflags} -e main -o $@ ${sys} ${api} ${core} ${ipv4} ${netif} lwip_server.o ${libserial} ${printf} ${libmem} ${usyscall} ${arch_usyscall} ${session} ${libipc} ${libsem} ${board_specs}
|
||||
@${objdump} -S $@ > $@.asm
|
||||
@$(ar) -r liblwip.a ${sys} ${api} ${core} ${ipv4} ${netif}
|
||||
@mv *.o bin
|
||||
@mv $@ $(KERNEL_ROOT)/services/app
|
||||
@mv $@.asm $(KERNEL_ROOT)/services/app
|
||||
|
||||
@@ -51,7 +51,7 @@ static void low_level_init(struct netif *netif)
|
||||
netif->mtu = 1500;
|
||||
|
||||
#if LWIP_ARP
|
||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP ;
|
||||
#else
|
||||
netif->flags |= NETIF_FLAG_BROADCAST;
|
||||
#endif /* LWIP_ARP */
|
||||
@@ -60,6 +60,26 @@ static void low_level_init(struct netif *netif)
|
||||
|
||||
}
|
||||
|
||||
void print_packet_data(const char *packet_data, int length) {
|
||||
printf("Packet Data:\n");
|
||||
for (int i = 0; i < length; ++i) {
|
||||
printf("%02X ", packet_data[i]); // 打印十六进制值,每个字节两位
|
||||
if ((i + 1) % 16 == 0 || i == length - 1) { // 每16个字节一行
|
||||
for (int j = 0; j < 15 - (i % 16); ++j) {
|
||||
printf(" "); // 打印空格对齐
|
||||
}
|
||||
printf("| ");
|
||||
for (int j = i - (i % 16); j <= i; ++j) {
|
||||
if (packet_data[j] >= 32 && packet_data[j] <= 126) {
|
||||
printf("%c", packet_data[j]); // 如果是可打印的ASCII字符,打印对应字符
|
||||
} else {
|
||||
printf("."); // 否则打印点表示不可打印字符
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This function should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
@@ -85,7 +105,7 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
||||
|
||||
pbuf_copy_partial(p, buf, p->tot_len, 0);
|
||||
|
||||
printf("output %s\n", buf);
|
||||
print_packet_data(buf, p->tot_len);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@@ -114,12 +134,8 @@ static struct pbuf* low_level_input(struct netif *netif)
|
||||
*/
|
||||
void ethernetif_input(struct netif *netif)
|
||||
{
|
||||
struct ethernetif *ethernetif;
|
||||
struct eth_hdr *ethhdr;
|
||||
struct pbuf *p;
|
||||
|
||||
ethernetif = netif->state;
|
||||
|
||||
/* move received packet into a new pbuf */
|
||||
p = low_level_input(netif);
|
||||
/* if no packet could be read, silently ignore this */
|
||||
|
||||
@@ -223,5 +223,188 @@
|
||||
---------- Lwip Debug options ----------
|
||||
----------------------------------------
|
||||
*/
|
||||
#ifndef LWIP_DEBUG
|
||||
#define LWIP_DEBUG 1
|
||||
#define LWIP_SOCKET_DEBUG
|
||||
#define LWIP_SOCKETS_DEBUG
|
||||
#define LWIP_TCPIP_DEBUG
|
||||
#define LWIP_MEMP_DEBUG
|
||||
#define LWIP_PBUF_DEBUG
|
||||
#define LWIP_TCP_INPUT_DEBUG
|
||||
#define LWIP_TCP_OUTPUT_DEBUG
|
||||
#define LWIP_NETIF_DEBUG
|
||||
#define LWIP_ETHARP_DEBUG
|
||||
#define LWIP_API_MSG_DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
#ifdef LWIP_SYS_DEBUG
|
||||
#define SYS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define SYS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_ETHARP_DEBUG
|
||||
#define ETHARP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PPP_DEBUG
|
||||
#define PPP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define PPP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_MEM_DEBUG
|
||||
#define MEM_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define MEM_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_MEMP_DEBUG
|
||||
#define MEMP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PBUF_DEBUG
|
||||
#define PBUF_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_API_LIB_DEBUG
|
||||
#define API_LIB_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define API_LIB_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_API_MSG_DEBUG
|
||||
#define API_MSG_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define API_MSG_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCPIP_DEBUG
|
||||
#define TCPIP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_NETIF_DEBUG
|
||||
#define NETIF_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_SOCKETS_DEBUG
|
||||
#define SOCKETS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DNS_DEBUG
|
||||
#define DNS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define DNS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_AUTOIP_DEBUG
|
||||
#define AUTOIP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define AUTOIP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DHCP_DEBUG
|
||||
#define DHCP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_IP_DEBUG
|
||||
#define IP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define IP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_IP_REASS_DEBUG
|
||||
#define IP_REASS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define IP_REASS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_ICMP_DEBUG
|
||||
#define ICMP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_IGMP_DEBUG
|
||||
#define IGMP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define IGMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_UDP_DEBUG
|
||||
#define UDP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define UDP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_DEBUG
|
||||
#define TCP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_INPUT_DEBUG
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_OUTPUT_DEBUG
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_RTO_DEBUG
|
||||
#define TCP_RTO_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_RTO_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_CWND_DEBUG
|
||||
#define TCP_CWND_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_CWND_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_WND_DEBUG
|
||||
#define TCP_WND_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_WND_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_FR_DEBUG
|
||||
#define TCP_FR_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_FR_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_QLEN_DEBUG
|
||||
#define TCP_QLEN_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_RST_DEBUG
|
||||
#define TCP_RST_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_RST_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_DEBUG */
|
||||
#endif /* LWIP_LWIPOPTS_H */
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#endif
|
||||
|
||||
#include "arch/cc.h"
|
||||
#include "libserial.h"
|
||||
|
||||
/**
|
||||
* @defgroup compiler_abstraction Compiler/platform abstraction
|
||||
@@ -78,7 +79,7 @@
|
||||
* systems, this should be defined to something less resource-consuming.
|
||||
*/
|
||||
#ifndef LWIP_PLATFORM_DIAG
|
||||
#define LWIP_PLATFORM_DIAG(x) do {printf(x);} while(0)
|
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||
// #include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,7 @@ endif
|
||||
cc = ${toolchain}gcc
|
||||
ld = ${toolchain}g++
|
||||
objdump = ${toolchain}objdump
|
||||
ar = ${toolchain}ar
|
||||
|
||||
c_useropts = -O2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user