[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [lwip-users] raw api recv callback - procedure to (temporarily)refus
From: |
Karl Kobel |
Subject: |
RE: [lwip-users] raw api recv callback - procedure to (temporarily)refuse data? |
Date: |
Mon, 9 May 2005 22:29:08 -0500 |
All,
I'm stuck. I'm nearly done with a single threaded version of slip. I
will add it to contrib when I complete it.
The problem stems most likely from my lack of understanding of pbufs.
The follow2ing is the code that executes when a complete packet is
received:
p = pbuf_alloc(PBUF_RAW, recved, PBUF_POOL);
if (p != NULL)
{
memcpy(p->payload, SlipBuff, recved);
p->len = recved;
LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
recved = 0;
return p;
}
SlipBuff has the data,
Recved has the length.
Small packets are handled correctly. However larger packets (around 300
bytes) the TCP checksum fails. The following is the portion of tcp_input
that fails.
/* Verify TCP checksum. */
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest),
IP_PROTO_TCP, p->tot_len) != 0) {
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to
failing checksum 0x%04x\n",
inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), (struct
ip_addr *)&(iphdr->dest),
IP_PROTO_TCP, p->tot_len)));
The pbuf that fails has the next pointer pointing to another pbuf (four
total in the one I trapped), but the payload and len are correct for the
entire packet in the first pbuf. Also if I jump past the code after the
first pbuf checksum is totaled, the packet checksum is correct and the
packet is received correctly.
This has to be a result of me doing something wrong. Do I need to do
something different when I allocate the pbuf in the slip driver? I tried
PBUF_LINK as the first argument with the same results. Do I have to set
the next pointer to NULL?
Thanks,
Karl