lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] UDP on 1.3


From: Ed Sutter
Subject: Re: [lwip-users] UDP on 1.3
Date: Fri, 01 Aug 2008 20:32:03 -0400
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

Ok, well I found the problem (I think)...
The problem AFAIK was in the original udp echo server code that I
used...

>> void monsrvr_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p,
>> struct ip_addr *addr, u16_t port)
>> {
>>     int i;
>>     struct pbuf *q;
>>
>>     if (p != NULL) {
>>         /* send received packet back to sender */
>>         udp_sendto(pcb, p, addr, port);
>>         /* free the pbuf */
>>         pbuf_free(p);
>>     }
>> }

In my app it has a different purpose, but the fundamental code was
just reused.  The problem was that the 'addr' parameter passed to
monsrvr_recv() above is in the packet.  On the round trip, this ends
up pointing to the "source" IP instead of the "destination" ip (since
on the echo, source and dest are reversed).  ANyway, I copied *addr to
myaddr and the passed a pointer to myaddr (&myaddr) to udp_sendto()
and that solved it (or at least the echo now works.

>> void monsrvr_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p,
>> struct ip_addr *addr, u16_t port)
>> {
>>     int i;
>>     struct pbuf *q;
>>     struct ip_addr myaddr;
>>     myaddr = *addr;
>>
>>     if (p != NULL) {
>>         /* send received packet back to sender */
>>         udp_sendto(pcb, p, &myaddr, port);
>>         /* free the pbuf */
>>         pbuf_free(p);
>>     }
>> }

So, if anyone who knows this stack really well could verify that my thinking
is correct, that sure would be helpful!

Thanks!
Ed



Ed Sutter wrote:
One more bit of data I just noticed...
If I turn off ARP_QUEUEING, then etharp_query() hits the error message
at the bottom of the function...

Ethernet destination address unknown, queueing disabled, packet ...dropped.

Ed

Ed Sutter wrote:
Hey folks,
I'm trying to complete a port of LWIP 1.3.0 raw api. I've used sockets on several earlier versions of LWIP in the past, and usually I've hacked away at my current installation to upgrade to the latest. Haven't had any problems. This time I decided to start from scratch, just to clean up. If useful, I'll
write up my experience and give it to whoever may want it for the Wiki;
however, I have a few hurdles to get over first. Note that this is my first
use of the RAW API, plus this is an implementation that doesn't even use
interrupts.

So, I'm running the httpd example code with no problem.  This obviously
means that my packet interface is in place, and I'm successfully running
TCP/IP. Now I'm trying to do what should be the simpler step (a UDP server) and I'm having problems. I've hunted the mail archives and I see hints of
the problem, but haven't found anything that clearly fixes me up.

I'm doing something very similar to the udp_echo_server() (found it on the mail archive, see below). I have a known working udp client and I'm seeing the incoming packets, but never see the outgoing packets on the interface.
I see it call ip_output_if(), then etharp_output_query(). It sends out a
gratuitous ARP (for some reason), then nothing else. Has anyone seen this?
Am I missing something in initialization?

Thanks for any suggestions
Ed

void monsrvr_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
    int i;
    struct pbuf *q;

    if (p != NULL) {
        /* send received packet back to sender */
        udp_sendto(pcb, p, addr, port);
        /* free the pbuf */
        pbuf_free(p);
    }
}


void monsrvr_init(void)
{
    struct udp_pcb * pcb;

    /* get new pcb */
    pcb = udp_new();
    if (pcb == NULL) {
        return;
    }

    /* bind to any IP address on port 777 */
    if (udp_bind(pcb, IP_ADDR_ANY, 777) != ERR_OK) {
        return;
    }

    /* set monsrvr_recv() as callback function
       for received packets */
    udp_recv(pcb, monsrvr_recv, NULL);
}


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users



_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]