aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-07-26 11:15:36 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-07-26 11:21:41 +0100
commit5131663c4ab29939ef6d23066d9832a23bb445a3 (patch)
tree1afb83eb082a6860549e8df97e7e5038097b5656
parente4fd80fb096858c399b17c308986aaed563b8ca9 (diff)
parent6438fbcb6cb7e0cd40e4bb3681ada047fe77ffdd (diff)
downloadsyslinux-5131663c4ab29939ef6d23066d9832a23bb445a3.tar.gz
Merge branch 'elflink-undi-debug-for-mfleming' of git://github.com/geneC/syslinux into firmwaresyslinux-6.02-pre13
Pull UNDIIF packet header debug patch series from Gene Cumm, * 'elflink-undi-debug-for-mfleming' of git://github.com/geneC/syslinux: Allow for UNDIIF_ID_DEBUG in 1 mk line core/lwip/undiif: dprint MAC/ARP/IP/ICMP/TCP/UDP headers; poll debug lwip/undiif: split arphdr._hwlen_protolen lwip: Allow LWIP_PLATFORM_* output to use dprintf lwip: undiif: Fix debug options to unique *_DEBUG macros Conflicts: core/kaboom.c
-rw-r--r--core/kaboom.c2
-rw-r--r--core/lwip/src/include/arch/cc.h14
-rw-r--r--core/lwip/src/include/lwip/opt.h28
-rw-r--r--core/lwip/src/netif/undiif.c296
-rw-r--r--mk/devel.mk4
5 files changed, 300 insertions, 44 deletions
diff --git a/core/kaboom.c b/core/kaboom.c
index 474b8abf..4c150e76 100644
--- a/core/kaboom.c
+++ b/core/kaboom.c
@@ -4,7 +4,7 @@
#include "core.h"
-#ifdef CORE_DEBUG
+#if defined(CORE_DEBUG) || defined(DEBUG_PORT)
#include <dprintf.h>
diff --git a/core/lwip/src/include/arch/cc.h b/core/lwip/src/include/arch/cc.h
index 677ef4f5..5ab13dec 100644
--- a/core/lwip/src/include/arch/cc.h
+++ b/core/lwip/src/include/arch/cc.h
@@ -21,9 +21,19 @@ typedef uintptr_t mem_ptr_t;
#define PACK_STRUCT_STRUCT __packed
+#define LWIP_PLATFORM_USE_DPRINTF
+
+#ifdef LWIP_PLATFORM_USE_DPRINTF
+# include <dprintf.h>
+# define LWIP_PLATFORM_PRINTF dprintf
+#else
+# define LWIP_PLATFORM_PRINTF printf
+#endif
+
+
#if 1
-#define LWIP_PLATFORM_DIAG(x) do { printf x; } while(0)
-#define LWIP_PLATFORM_ASSERT(x) do { printf("LWIP(%s,%d,%p): %s", __FILE__, __LINE__, __builtin_return_address(0), (x)); kaboom(); } while(0)
+#define LWIP_PLATFORM_DIAG(x) do { LWIP_PLATFORM_PRINTF x; } while(0)
+#define LWIP_PLATFORM_ASSERT(x) do { LWIP_PLATFORM_PRINTF("LWIP(%s,%d,%p): %s", __FILE__, __LINE__, __builtin_return_address(0), (x)); kaboom(); } while(0)
#else
#define LWIP_PLATFORM_DIAG(x) ((void)0) /* For now... */
#define LWIP_PLATFORM_ASSERT(x) kaboom()
diff --git a/core/lwip/src/include/lwip/opt.h b/core/lwip/src/include/lwip/opt.h
index a1b87658..490aab43 100644
--- a/core/lwip/src/include/lwip/opt.h
+++ b/core/lwip/src/include/lwip/opt.h
@@ -1816,6 +1816,34 @@
#endif
/**
+ * UNDIIF_DEBUG: Enable debugging in undiif.c.
+ */
+#ifndef UNDIIF_DEBUG
+#define UNDIIF_DEBUG LWIP_DBG_OFF
+#endif
+
+/**
+ * UNDIIF_ARP_DEBUG: Enable ETHARP debugging in undiif.c.
+ */
+#ifndef UNDIIF_ARP_DEBUG
+#define UNDIIF_ARP_DEBUG LWIP_DBG_OFF
+#endif
+
+/**
+ * UNDIIF_NET_DEBUG: Enable NETIF debugging in undiif.c.
+ */
+#ifndef UNDIIF_NET_DEBUG
+#define UNDIIF_NET_DEBUG LWIP_DBG_OFF
+#endif
+
+/**
+ * UNDIIF_ID_DEBUG: Enable debugging to identify packets in undiif.c.
+ */
+#ifndef UNDIIF_ID_DEBUG
+#define UNDIIF_ID_DEBUG LWIP_DBG_OFF
+#endif
+
+/**
* PBUF_DEBUG: Enable debugging in pbuf.c.
*/
#ifndef PBUF_DEBUG
diff --git a/core/lwip/src/netif/undiif.c b/core/lwip/src/netif/undiif.c
index 2c7e4ac4..0dee67a2 100644
--- a/core/lwip/src/netif/undiif.c
+++ b/core/lwip/src/netif/undiif.c
@@ -45,10 +45,27 @@
* something that better describes your network interface.
*/
+/* other headers include deprintf.h too early */
+#define UNDIIF_ID_FULL_DEBUG (UNDIIF_ID_DEBUG | UNDIIF_DEBUG)
+
+#if UNDIIF_ID_FULL_DEBUG
+# ifndef DEBUG
+# define DEBUG 1
+# endif
+# ifndef DEBUG_PORT
+# define DEBUG_PORT 0x3f8
+# endif
+#endif /* UNDIIF_ID_FULL_DEBUG */
+
#include <core.h>
#include "lwip/opt.h"
+#define LWIP_UNDIIF_DBG(debug) \
+ ( ((debug) & LWIP_DBG_ON) && \
+ ((debug) & LWIP_DBG_TYPES_ON) && \
+ (((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL) )
+
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
@@ -66,6 +83,11 @@
#include <syslinux/pxe_api.h>
#include <dprintf.h>
+/* debug extras */
+#include "ipv4/lwip/icmp.h"
+#include "lwip/tcp_impl.h"
+#include "lwip/udp.h"
+
#if LWIP_AUTOIP
#error "AUTOIP not supported"
#endif
@@ -100,7 +122,8 @@ PACK_STRUCT_BEGIN
struct arp_hdr {
PACK_STRUCT_FIELD(u16_t hwtype);
PACK_STRUCT_FIELD(u16_t proto);
- PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
+ PACK_STRUCT_FIELD(u8_t hwlen);
+ PACK_STRUCT_FIELD(u8_t protolen);
PACK_STRUCT_FIELD(u16_t opcode);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
@@ -151,6 +174,8 @@ static u8_t undiarp_cached_entry;
#define UNDIARP_TRY_HARD 1
#define UNDIARP_FIND_ONLY 2
+#define UNIDIF_ID_STRLEN 244
+
static inline bool undi_is_ethernet(struct netif *netif)
{
@@ -213,6 +238,153 @@ static void print_arp_pbuf(struct netif *netif, struct pbuf *p)
}
#endif
+#if LWIP_UNDIIF_DBG(UNDIIF_ID_FULL_DEBUG)
+int snprintf_eth_hdr(char *str, size_t size, char head[],
+ struct eth_hdr *ethhdr, char dir, char status,
+ char tail[])
+{
+ u8_t *d = ethhdr->dest.addr;
+ u8_t *s = ethhdr->src.addr;
+ return snprintf(str, size,
+ "%s: d:%02x:%02x:%02x:%02x:%02x:%02x"
+ " s:%02x:%02x:%02x:%02x:%02x:%02x"
+ " t:%4hx %c%c %s\n", head,
+ d[0], d[1], d[2], d[3], d[4], d[5],
+ s[0], s[1], s[2], s[3], s[4], s[5],
+ (unsigned)htons(ethhdr->type),
+ dir, status, tail);
+}
+
+int snprintf_arp_hdr(char *str, size_t size, char head[],
+ struct eth_hdr *ethhdr, char dir,
+ char status, char tail[])
+{
+ struct etharp_hdr *arphdr;
+ u8_t *d, *s;
+ struct ip_addr *sip, *dip;
+ if (ntohs(ethhdr->type) == ETHTYPE_ARP) {
+ arphdr = (struct etharp_hdr *)((void *)ethhdr + 14);
+ d = arphdr->dhwaddr.addr;
+ s = arphdr->shwaddr.addr;
+ sip = (struct ip_addr *) &(arphdr->sipaddr);
+ dip = (struct ip_addr *) &(arphdr->dipaddr);
+ return snprintf(str, size,
+ "%s: s:%02x:%02x:%02x:%02x:%02x:%02x"
+ " %3d.%3d.%3d.%3d"
+ " %02x:%02x:%02x:%02x:%02x:%02x"
+ " %3d.%3d.%3d.%3d"
+ " %c%c %s\n", head,
+ s[0], s[1], s[2], s[3], s[4], s[5],
+ ip4_addr1(sip), ip4_addr2(sip),
+ ip4_addr3(sip), ip4_addr4(sip),
+ d[0], d[1], d[2], d[3], d[4], d[5],
+ ip4_addr1(dip), ip4_addr2(dip),
+ ip4_addr3(dip), ip4_addr4(dip),
+ dir, status, tail);
+ } else {
+ return 0;
+ }
+}
+
+int snprintf_ip_hdr(char *str, size_t size, char head[],
+ struct eth_hdr *ethhdr, char dir,
+ char status, char tail[])
+{
+ struct ip_hdr *iphdr;
+ if (ntohs(ethhdr->type) == ETHTYPE_IP) {
+ iphdr = (struct ip_hdr *)((void *)ethhdr + 14);
+ return snprintf(str, size,
+ "%s: s:%3d.%3d.%3d.%3d %3d.%3d.%3d.%3d l:%5d"
+ " i:%04x p:%04x c:%04x hl:%3d"
+ " %c%c %s\n", head,
+ ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src),
+ ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src),
+ ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest),
+ ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest),
+ ntohs(IPH_LEN(iphdr)), ntohs(IPH_ID(iphdr)),
+ IPH_PROTO(iphdr), ntohs(IPH_CHKSUM(iphdr)),
+ (IPH_HL(iphdr) << 2),
+ dir, status, tail);
+ } else {
+ return 0;
+ }
+}
+
+int snprintf_icmp_hdr(char *str, size_t size, char head[],
+ struct eth_hdr *ethhdr, char dir,
+ char status, char tail[])
+{
+ struct ip_hdr *iphdr;
+ struct icmp_echo_hdr *icmphdr;
+ if (ntohs(ethhdr->type) == ETHTYPE_IP) {
+ iphdr = (struct ip_hdr *)((void *)ethhdr + 14);
+ if (IPH_PROTO(iphdr) == IP_PROTO_ICMP) {
+ icmphdr = (struct icmp_echo_hdr *)((void *)iphdr + (IPH_HL(iphdr) << 2));
+ return snprintf(str, size,
+ "%s: t:%02x c:%02x k:%04x"
+ " i:%04x s:%04x "
+ " %c%c %s\n", head,
+ icmphdr->type, icmphdr->code, ntohs(icmphdr->chksum),
+ ntohs(icmphdr->id), ntohs(icmphdr->seqno),
+ dir, status, tail);
+ } else {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+}
+
+int snprintf_tcp_hdr(char *str, size_t size, char head[],
+ struct eth_hdr *ethhdr, char dir,
+ char status, char tail[])
+{
+ struct ip_hdr *iphdr;
+ struct tcp_hdr *tcphdr;
+ if (ntohs(ethhdr->type) == ETHTYPE_IP) {
+ iphdr = (struct ip_hdr *)((void *)ethhdr + 14);
+ if (IPH_PROTO(iphdr) == IP_PROTO_TCP) {
+ tcphdr = (struct tcp_hdr *)((void *)iphdr + (IPH_HL(iphdr) << 2));
+ return snprintf(str, size,
+ "%s: s:%5d %5d q:%08x a:%08x k:%04x"
+ " %c%c %s\n", head,
+ ntohs(tcphdr->src), ntohs(tcphdr->dest),
+ ntohl(tcphdr->seqno), ntohl(tcphdr->ackno),
+ ntohs(tcphdr->chksum),
+ dir, status, tail);
+ } else {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+}
+
+int snprintf_udp_hdr(char *str, size_t size, char head[],
+ struct eth_hdr *ethhdr, char dir,
+ char status, char tail[])
+{
+ struct ip_hdr *iphdr;
+ struct udp_hdr *udphdr;
+ if (ntohs(ethhdr->type) == ETHTYPE_IP) {
+ iphdr = (struct ip_hdr *)((void *)ethhdr + 14);
+ if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
+ udphdr = (struct udp_hdr *)((void *)iphdr + (IPH_HL(iphdr) << 2));
+ return snprintf(str, size,
+ "%s: s:%5d %5d l:%d c:%04x"
+ " %c%c %s\n", head,
+ ntohs(udphdr->src), ntohs(udphdr->dest),
+ ntohs(udphdr->len), ntohs(udphdr->chksum),
+ dir, status, tail);
+ } else {
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+}
+#endif /* UNDIIF_ID_FULL_DEBUG */
+
/**
* In this function, the hardware should be initialized.
* Called from undiif_init().
@@ -302,6 +474,27 @@ undi_transmit(struct netif *netif, struct pbuf *pbuf,
static __lowmem char pkt_buf[PKTBUF_SIZE];
uint32_t now;
static uint32_t first_xmit;
+#if LWIP_UNDIIF_DBG(UNDIIF_ID_FULL_DEBUG)
+ char *str = malloc(UNIDIF_ID_STRLEN);
+ int strpos = 0;
+ struct eth_hdr *ethhdr = pbuf->payload;
+
+
+ strpos = snprintf_eth_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ "undi", ethhdr, 'x', '0', "");
+ strpos += snprintf_arp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " arp", ethhdr, 'x', '0', "");
+ strpos += snprintf_ip_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " ip", ethhdr, 'x', '0', "");
+ strpos += snprintf_icmp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " icmp", ethhdr, 'x', '0', "");
+ strpos += snprintf_tcp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " tcp", ethhdr, 'x', '0', "");
+ strpos += snprintf_udp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " udp", ethhdr, 'x', '0', "");
+ LWIP_DEBUGF(UNDIIF_ID_FULL_DEBUG, ("%s", str));
+ free(str);
+#endif /* UNDIIF_ID_FULL_DEBUG */
/* Drop jumbo frames */
if ((pbuf->tot_len > sizeof(pkt_buf)) || (pbuf->tot_len > netif->mtu))
@@ -313,6 +506,7 @@ undi_transmit(struct netif *netif, struct pbuf *pbuf,
first_xmit = now;
} else if (now - first_xmit > 3000) {
/* 3 seconds after first transmit, and no interrupts */
+ LWIP_PLATFORM_DIAG(("undiif: forcing polling\n"));
asm volatile("orb $1,%0" : "+m" (pxe_need_poll));
asm volatile("incl %0" : "+m" (pxe_irq_count));
}
@@ -375,14 +569,14 @@ undiarp_request(struct netif *netif, struct ip_addr *ipaddr)
struct arp_hdr *hdr;
u8_t *hdr_ptr;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_request: sending ARP request.\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_request: sending ARP request.\n"));
/* allocate a pbuf for the outgoing ARP request packet */
p = pbuf_alloc(PBUF_RAW, arp_hdr_len(netif), PBUF_RAM);
/* could allocate a pbuf for an ARP request? */
if (p == NULL) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,
- ("etharp_raw: could not allocate pbuf for ARP request.\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,
+ ("undiarp_raw: could not allocate pbuf for ARP request.\n"));
ETHARP_STATS_INC(etharp.memerr);
return ERR_MEM;
}
@@ -390,12 +584,12 @@ undiarp_request(struct netif *netif, struct ip_addr *ipaddr)
(p->len >= arp_hdr_len(netif)));
hdr = p->payload;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_request: sending raw ARP packet.\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_request: sending raw ARP packet.\n"));
hdr->opcode = htons(ARP_REQUEST);
hdr->hwtype = htons(MAC_type);
hdr->proto = htons(ETHTYPE_IP);
- /* set hwlen and protolen together */
- hdr->_hwlen_protolen = htons((netif->hwaddr_len << 8) | sizeof(struct ip_addr));
+ hdr->hwlen = netif->hwaddr_len;
+ hdr->protolen = sizeof(struct ip_addr);
hdr_ptr = (unsigned char *)(hdr + 1);
memcpy(hdr_ptr, netif->hwaddr, netif->hwaddr_len);
@@ -450,7 +644,7 @@ undiarp_tmr(void)
{
u8_t i;
- LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG, ("undiarp_timer\n"));
/* remove expired entries from the ARP table */
for (i = 0; i < ARP_TABLE_SIZE; ++i) {
arp_table[i].ctime++;
@@ -459,7 +653,7 @@ undiarp_tmr(void)
((arp_table[i].state == UNDIARP_STATE_PENDING) &&
(arp_table[i].ctime >= UNDIARP_MAXPENDING))) {
/* pending or stable entry has become old! */
- LWIP_DEBUGF(UNDIARP_DEBUG, ("etharp_timer: expired %s entry %"U16_F".\n",
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG , ("undiarp_timer: expired %s entry %"U16_F".\n",
arp_table[i].state == UNDIARP_STATE_STABLE ? "stable" : "pending", (u16_t)i));
/* clean up entries that have just been expired */
/* remove from SNMP ARP index tree */
@@ -468,7 +662,7 @@ undiarp_tmr(void)
/* and empty packet queue */
if (arp_table[i].q != NULL) {
/* remove all queued packets */
- LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].q)));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG , ("undiarp_timer: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].q)));
free_undiarp_q(arp_table[i].q);
arp_table[i].q = NULL;
}
@@ -571,7 +765,7 @@ find_entry(struct ip_addr *ipaddr, u8_t flags)
for (i = 0; i < ARP_TABLE_SIZE; ++i) {
/* no empty entry found yet and now we do find one? */
if ((empty == ARP_TABLE_SIZE) && (arp_table[i].state == UNDIARP_STATE_EMPTY)) {
- LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %"U16_F"\n", (u16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG , ("find_entry: found empty entry %"U16_F"\n", (u16_t)i));
/* remember first empty entry */
empty = i;
}
@@ -579,7 +773,7 @@ find_entry(struct ip_addr *ipaddr, u8_t flags)
else if (arp_table[i].state == UNDIARP_STATE_PENDING) {
/* if given, does IP address match IP address in ARP entry? */
if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i));
/* found exact IP address match, simply bail out */
#if LWIP_NETIF_HWADDRHINT
NETIF_SET_HINT(netif, i);
@@ -607,7 +801,7 @@ find_entry(struct ip_addr *ipaddr, u8_t flags)
else if (arp_table[i].state == UNDIARP_STATE_STABLE) {
/* if given, does IP address match IP address in ARP entry? */
if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i));
/* found exact IP address match, simply bail out */
#if LWIP_NETIF_HWADDRHINT
NETIF_SET_HINT(netif, i);
@@ -628,7 +822,7 @@ find_entry(struct ip_addr *ipaddr, u8_t flags)
if (((empty == ARP_TABLE_SIZE) && ((flags & UNDIARP_TRY_HARD) == 0))
/* or don't create new entry, only search? */
|| ((flags & UNDIARP_FIND_ONLY) != 0)) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: no empty entry found and not allowed to recycle\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: no empty entry found and not allowed to recycle\n"));
return (s8_t)ERR_MEM;
}
@@ -644,13 +838,13 @@ find_entry(struct ip_addr *ipaddr, u8_t flags)
/* 1) empty entry available? */
if (empty < ARP_TABLE_SIZE) {
i = empty;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i));
}
/* 2) found recyclable stable entry? */
else if (old_stable < ARP_TABLE_SIZE) {
/* recycle oldest stable*/
i = old_stable;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i));
#if ARP_QUEUEING
/* no queued packets should exist on stable entries */
LWIP_ASSERT("arp_table[i].q == NULL", arp_table[i].q == NULL);
@@ -659,13 +853,13 @@ find_entry(struct ip_addr *ipaddr, u8_t flags)
} else if (old_pending < ARP_TABLE_SIZE) {
/* recycle oldest pending */
i = old_pending;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i));
#if ARP_QUEUEING
/* 4) found recyclable pending entry with queued packets? */
} else if (old_queue < ARP_TABLE_SIZE) {
/* recycle oldest pending */
i = old_queue;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q)));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q)));
free_undiarp_q(arp_table[i].q);
arp_table[i].q = NULL;
#endif
@@ -742,7 +936,7 @@ undiarp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
if (ip_addr_isbroadcast(ipaddr, netif) ||
ip_addr_ismulticast(ipaddr) ||
ip_addr_isany(ipaddr)) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: will not add non-unicast IP address to ARP cache\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: will not add non-unicast IP address to ARP cache\n"));
return ERR_ARG;
}
@@ -755,9 +949,9 @@ undiarp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
/* could not find or create entry? */
if (i < 0) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: could not create ARP entry\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: could not create ARP entry\n"));
if (q) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: packet dropped\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: packet dropped\n"));
ETHARP_STATS_INC(etharp.memerr);
}
return (err_t)i;
@@ -844,23 +1038,23 @@ undiarp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
/* queue did not exist, first item in queue */
arp_table[i].q = new_entry;
}
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: queued packet %p on ARP entry %"S16_F"\n", (void *)q, (s16_t)i));
result = ERR_OK;
} else {
/* the pool MEMP_ARP_QUEUE is empty */
pbuf_free(p);
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));
/* { result == ERR_MEM } through initialization */
}
} else {
ETHARP_STATS_INC(etharp.memerr);
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));
/* { result == ERR_MEM } through initialization */
}
#else /* ARP_QUEUEING == 0 */
/* q && state == PENDING && ARP_QUEUEING == 0 => result = ERR_MEM */
/* { result == ERR_MEM } through initialization */
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: Ethernet destination address unknown, queueing disabled, packet %p dropped\n", (void *)q));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_query: Ethernet destination address unknown, queueing disabled, packet %p dropped\n", (void *)q));
#endif
}
}
@@ -1038,8 +1232,8 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr,
hwaddr_t *lladdr, u8_t flags)
{
s8_t i;
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry()\n"));
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiif:update_arp_entry()\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiif:update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
(*lladdr)[0], (*lladdr)[1], (*lladdr)[2],
(*lladdr)[3], (*lladdr)[4], (*lladdr)[5]));
@@ -1047,7 +1241,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr,
if (ip_addr_isany(ipaddr) ||
ip_addr_isbroadcast(ipaddr, netif) ||
ip_addr_ismulticast(ipaddr)) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: will not add non-unicast IP address to ARP cache\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiif:update_arp_entry: will not add non-unicast IP address to ARP cache\n"));
return ERR_ARG;
}
/* find or create ARP entry */
@@ -1068,7 +1262,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr,
/* insert in SNMP ARP index tree */
snmp_insert_arpidx_tree(netif, &arp_table[i].ipaddr);
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiif:update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));
/* update address */
memcpy(arp_table[i].hwaddr, lladdr, netif->hwaddr_len);
@@ -1125,7 +1319,7 @@ undiarp_input(struct netif *netif, struct pbuf *p)
/* drop short ARP packets: we have to check for p->len instead of p->tot_len here
since a struct arp_hdr is pointed to p->payload, so it musn't be chained! */
if (p->len < arp_hdr_len(netif)) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("undiarp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len,
(s16_t)SIZEOF_ETHARP_PACKET));
printf("short arp packet\n");
@@ -1138,11 +1332,12 @@ undiarp_input(struct netif *netif, struct pbuf *p)
hdr = p->payload;
/* RFC 826 "Packet Reception": */
if ((hdr->hwtype != htons(MAC_type)) ||
- (hdr->_hwlen_protolen != htons((netif->hwaddr_len << 8) | sizeof(struct ip_addr))) ||
+ (hdr->hwlen != netif->hwaddr_len) ||
+ (hdr->protolen != sizeof(struct ip_addr)) ||
(hdr->proto != htons(ETHTYPE_IP))) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("undiarp_input: packet dropped, wrong hw type, hwlen, proto, or protolen (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n",
- hdr->hwtype, ARPH_HWLEN(hdr), hdr->proto, ARPH_PROTOLEN(hdr)));
+ hdr->hwtype, hdr->hwlen, hdr->proto, hdr->protolen));
ETHARP_STATS_INC(etharp.proterr);
ETHARP_STATS_INC(etharp.drop);
printf("malformed arp packet\n");
@@ -1188,11 +1383,11 @@ undiarp_input(struct netif *netif, struct pbuf *p)
* reply. In any case, we time-stamp any existing ARP entry,
* and possiby send out an IP packet that was queued on it. */
- LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: incoming ARP request\n"));
+ LWIP_DEBUGF (UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: incoming ARP request\n"));
/* ARP request for our address? */
if (for_us) {
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: replying to ARP request for our IP address\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: replying to ARP request for our IP address\n"));
/* Re-use pbuf to send ARP reply.
Since we are re-using an existing pbuf, we can't call etharp_raw since
that would allocate a new pbuf. */
@@ -1211,16 +1406,16 @@ undiarp_input(struct netif *netif, struct pbuf *p)
/* we are not configured? */
} else if (netif->ip_addr.addr == 0) {
/* { for_us == 0 and netif->ip_addr.addr == 0 } */
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: we are unconfigured, ARP request ignored.\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: we are unconfigured, ARP request ignored.\n"));
/* request was not directed to us */
} else {
/* { for_us == 0 and netif->ip_addr.addr != 0 } */
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: ARP request was not for us.\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: ARP request was not for us.\n"));
}
break;
case ARP_REPLY:
/* ARP reply. We already updated the ARP cache earlier. */
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: incoming ARP reply\n"));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: incoming ARP reply\n"));
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
/* DHCP wants to know about ARP replies from any host with an
* IP address also offered to us by the DHCP server. We do not
@@ -1230,7 +1425,7 @@ undiarp_input(struct netif *netif, struct pbuf *p)
#endif
break;
default:
- LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode)));
+ LWIP_DEBUGF(UNDIIF_ARP_DEBUG | UNDIIF_DEBUG | LWIP_DBG_TRACE, ("undiarp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode)));
ETHARP_STATS_INC(etharp.err);
break;
}
@@ -1265,7 +1460,26 @@ void undiif_input(t_PXENV_UNDI_ISR *isr)
if (undi_is_ethernet(&undi_netif)) {
/* points to packet payload, which starts with an Ethernet header */
struct eth_hdr *ethhdr = p->payload;
-
+#if LWIP_UNDIIF_DBG(UNDIIF_ID_FULL_DEBUG)
+ char *str = malloc(UNIDIF_ID_STRLEN);
+ int strpos = 0;
+
+ strpos = snprintf_eth_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ "undi", ethhdr, 'r', '0', "");
+ strpos += snprintf_arp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " arp", ethhdr, 'r', '0', "");
+ strpos += snprintf_ip_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " ip", ethhdr, 'r', '0', "");
+ strpos += snprintf_icmp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " icmp", ethhdr, 'r', '0', "");
+ strpos += snprintf_tcp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " tcp", ethhdr, 'r', '0', "");
+ strpos += snprintf_udp_hdr(str + strpos, UNIDIF_ID_STRLEN - strpos,
+ " udp", ethhdr, 'r', '0', "");
+ LWIP_DEBUGF(UNDIIF_ID_FULL_DEBUG, ("%s", str));
+ free(str);
+#endif /* UNDIIF_ID_FULL_DEBUG */
+
switch (htons(ethhdr->type)) {
/* IP or ARP packet? */
case ETHTYPE_IP:
@@ -1277,7 +1491,7 @@ void undiif_input(t_PXENV_UNDI_ISR *isr)
#endif /* PPPOE_SUPPORT */
/* full packet send to tcpip_thread to process */
if (tcpip_input(p, &undi_netif)!=ERR_OK)
- { LWIP_DEBUGF(NETIF_DEBUG, ("undiif_input: IP input error\n"));
+ { LWIP_DEBUGF(UNDIIF_NET_DEBUG | UNDIIF_DEBUG, ("undiif_input: IP input error\n"));
pbuf_free(p);
p = NULL;
}
diff --git a/mk/devel.mk b/mk/devel.mk
index 7c029771..b1fca87e 100644
--- a/mk/devel.mk
+++ b/mk/devel.mk
@@ -3,3 +3,7 @@ GCCWARN += -Wno-clobbered
#GCCWARN += -DDEBUG_MALLOC
# GCCWARN += -DDEBUG_PORT=0x3f8 -DCORE_DEBUG=1
GCCWARN += -DDYNAMIC_DEBUG
+
+## The following will enable printing ethernet/arp/ip/icmp/tcp/udp headers
+## in undiif.c
+# GCCWARN += -DUNDIIF_ID_DEBUG=0x80U -DLWIP_DEBUG -DDEBUG_PORT=0x3f8