etharp_query() has error return type now. Matched dhcp.c with this change.

Added debug messages in other places.
This commit is contained in:
likewise 2003-04-01 14:02:50 +00:00
parent 132b09ce09
commit 1a72feb128
9 changed files with 40 additions and 29 deletions

2
FILES
View File

@ -1,4 +1,4 @@
src/ - The source code for the lwIP TCP/IP stack.
doc/ - Documentation on the lwIP APIs.
doc/ - The documentation for lwIP.
See also the FILES file in each subdirectory.

View File

@ -154,19 +154,13 @@ static void dhcp_handle_nak(struct netif *netif) {
static void dhcp_check(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
struct pbuf *p;
err_t result;
u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_check()\n"));
/* create an ARP query for the offered IP address, expecting that no host
responds, as the IP address should not be in use. */
p = etharp_query(netif, &dhcp->offered_ip_addr, NULL);
if (p != NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_check(): sending ARP request len %u\n", p->tot_len));
result = netif->linkoutput(netif, p);
pbuf_free(p);
p = NULL;
} else {
result = etharp_query(netif, &dhcp->offered_ip_addr, NULL);
if (result != ERR_OK) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n"));
}
dhcp->tries++;

View File

@ -494,7 +494,7 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
#ifdef IP_STATS
lwip_stats.ip.xmit++;
#endif /* IP_STATS */
DEBUGF(IP_DEBUG, ("ip_output_if: %c%c ", netif->name[0], netif->name[1]));
DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num));
#if IP_DEBUG
ip_debug_print(p);
#endif /* IP_DEBUG */

View File

@ -176,8 +176,8 @@ void
netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
{
ip_addr_set(&(netif->ip_addr), ipaddr);
DEBUGF(NETIF_DEBUG, ("netif: setting IP address of interface %c%c to %d.%d.%d.%d\n",
netif->name[0], netif->name[1],
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting IP address of interface %c%c%u to %u.%u.%u.%u\n",
netif->name[0], netif->name[1], netif->num,
(u8_t)(ntohl(ipaddr->addr) >> 24 & 0xff),
(u8_t)(ntohl(ipaddr->addr) >> 16 & 0xff),
(u8_t)(ntohl(ipaddr->addr) >> 8 & 0xff),
@ -188,12 +188,24 @@ void
netif_set_gw(struct netif *netif, struct ip_addr *gw)
{
ip_addr_set(&(netif->gw), gw);
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting GW address of interface %c%c%u to %u.%u.%u.%u\n",
netif->name[0], netif->name[1], netif->num,
(u8_t)(ntohl(gw->addr) >> 24 & 0xff),
(u8_t)(ntohl(gw->addr) >> 16 & 0xff),
(u8_t)(ntohl(gw->addr) >> 8 & 0xff),
(u8_t)(ntohl(gw->addr) & 0xff)));
}
/*-----------------------------------------------------------------------------------*/
void
netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
{
ip_addr_set(&(netif->netmask), netmask);
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE, ("netif: setting netmask of interface %c%c%u to %u.%u.%u.%u\n",
netif->name[0], netif->name[1], netif->num,
(u8_t)(ntohl(netmask->addr) >> 24 & 0xff),
(u8_t)(ntohl(netmask->addr) >> 16 & 0xff),
(u8_t)(ntohl(netmask->addr) >> 8 & 0xff),
(u8_t)(ntohl(netmask->addr) & 0xff)));
}
/*-----------------------------------------------------------------------------------*/
void

View File

@ -184,7 +184,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
prev = pcb;
}
if(pcb == NULL) {
if (pcb == NULL) {
/* If it did not go to an active connection, we check the connections
in the TIME-WAIT state. */

View File

@ -410,14 +410,14 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
/* chksum zero must become 0xffff, as zero means 'no checksum' */
if(udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
}
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum %x\n", udphdr->chksum));
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum));
snmp_inc_udpoutdatagrams();
DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if(,,,,IP_PROTO_UDP,)\n"));
/* output to IP */
err = ip_output_if(q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);
}
/* did we chain a header? */
/* did we chain a header earlier? */
if (q != p) {
/* free the header */
pbuf_free(q);
@ -504,7 +504,11 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
pcb->next = udp_pcbs;
udp_pcbs = pcb;
}
DEBUGF(UDP_DEBUG, ("udp_bind: bound to port %u\n", port));
DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %u.%u.%u.%u, port %u\n",
(u8_t)(ntohl(ipaddr->addr) >> 24 & 0xff),
(u8_t)(ntohl(ipaddr->addr) >> 16 & 0xff),
(u8_t)(ntohl(ipaddr->addr) >> 8 & 0xff),
(u8_t)(ntohl(ipaddr->addr) & 0xff), port));
return ERR_OK;
}
/**

View File

@ -59,7 +59,7 @@ typedef enum {
#define PBUF_FLAG_ROM 0x01 /* Flags that pbuf data is stored in ROM. */
#define PBUF_FLAG_POOL 0x02 /* Flags that the pbuf comes from the
pbuf pool. */
#define PBUF_FLAG_REF 0x03
#define PBUF_FLAG_REF 0x04
struct pbuf {
struct pbuf *next;

View File

@ -91,7 +91,7 @@ struct pbuf *etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
struct pbuf *p);
struct pbuf *etharp_output(struct netif *netif, struct ip_addr *ipaddr,
struct pbuf *q);
struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);

View File

@ -638,11 +638,12 @@ etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
* TODO: use the ctime field to see how long ago an ARP request was sent,
* possibly retry.
*/
struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
{
struct eth_addr *srcaddr;
struct etharp_hdr *hdr;
struct pbuf *p;
err_t result;
u8_t i;
srcaddr = (struct eth_addr *)netif->hwaddr;
@ -651,24 +652,23 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
if(ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
if (arp_table[i].state == ETHARP_STATE_PENDING) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already pending as entry %u\n", i));
/* break out of for-loop */
/* break out of for-loop, user may wish to queue a packet on a stable entry */
break;
}
else if (arp_table[i].state == ETHARP_STATE_STABLE) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already stable as entry %u\n", i));
/* TODO: user may wish to queue a packet on a stable entry. */
return NULL;
}
}
}
/* queried address not yet pending in ARP table? */
if (i == ARP_TABLE_SIZE)
{
/* queried address not yet in ARP table? */
if (i == ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: IP address not found in ARP table\n"));
/* find an available entry */
i = find_arp_entry();
/* bail out if no ARP entries are available */
if(i == ARP_TABLE_SIZE)
{
if (i == ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available.\n"));
return NULL;
}
@ -686,10 +686,10 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
if ((q != NULL) && (arp_table[i].p == NULL)) {
/* copy PBUF_REF referenced payloads to PBUF_RAM */
q = pbuf_take(q);
/* pbufs are queued, increase the reference count */
pbuf_ref(q);
/* remember pbuf to queue, if any */
arp_table[i].p = q;
/* pbufs are queued, increase the reference count */
pbuf_ref(q);
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: queued packet %p on ARP entry %u.\n", (void *)q, i));
}
#endif
@ -721,12 +721,13 @@ struct pbuf *etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pb
}
hdr->ethhdr.type = htons(ETHTYPE_ARP);
/* send ARP query */
netif->linkoutput(netif, p);
result = netif->linkoutput(netif, p);
/* free ARP query packet */
pbuf_free(p);
p = NULL;
} else {
result = ERR_MEM;
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_query: could not allocate pbuf for ARP request.\n"));
}
return NULL;
return result;
}