[Top][All Lists]

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

Re: [lwip-users] dns_gethostbyname

From: Sandra Gilge
Subject: Re: [lwip-users] dns_gethostbyname
Date: Tue, 5 May 2015 11:27:48 +0200

Hallo Christoph,

I think the tcpip_callback_with_block is the right solution for me. Many
thanks for that hint.

But I wonder how I can pass several parameters to dns_gethostbyname then. Is
it done in a struct?
Dns_gethostbyname has four parameters:
dns_gethostbyname (const char *hostname, struct ip_addr *addr,
dns_found_callback  found,
                void *callback_arg)

As far as I understand a message is sent to tcpip_thread with
functionpointer and pointer to parameter as payload of that message. 

Best regards,

-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Im Auftrag von
Gesendet: Montag, 4. Mai 2015 18:00
An: address@hidden
Betreff: lwip-users Digest, Vol 141, Issue 4

Send lwip-users mailing list submissions to

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to

You can reach the person managing the list at

When replying, please edit your Subject line so it is more specific than
"Re: Contents of lwip-users digest..."

Today's Topics:

   1. Re: dns_gethostbyname (Krzysztof Weso?owski)
   2. Unix port does not work on Ubuntu 14.04 (Edgar Bonet)


Message: 1
Date: Sun, 3 May 2015 20:15:59 +0200
From: Krzysztof Weso?owski <address@hidden>
To: Mailing list for lwIP users <address@hidden>
Subject: Re: [lwip-users] dns_gethostbyname
Content-Type: text/plain; charset="utf-8"

Hi there,

What do you mean with "You can however post your callback to be executed on
> lwip thread"?

What callback do you talk about, the callback function that is given as
> parameter in the dns_gethostbyname?

both "netconn api" and "socket api use "raw api" under the hood, those APIs
handle inter thread communication for you.

You can do something similar if you need to execute code on tcpip_thread
from your code. Just use function:


This function simply takes function pointer, void * argument (to pass
additional context to your function if it is needed), and uses RTOS
mechanisms to execute in on tcpip thread (extra argument determines if
current thread will block until execution on tcpip thread completes).

You need to prepare your own functions:
- one responsible for starting request, which will call dns_gethostbyname
and will be passed to tcpip_callback_with_block,
- one responsible for handling result of request, passed to
dns_gethostbyname. This function will be called by dns code on tcpip thread
when requests completes.

Unfortunately I do not have sample at hand.

Krzysztof Weso?owski
-------------- next part --------------
An HTML attachment was scrubbed...


Message: 2
Date: Mon, 04 May 2015 10:01:51 +0200
From: Edgar Bonet <address@hidden>
To: address@hidden
Subject: [lwip-users] Unix port does not work on Ubuntu 14.04
Message-ID: <address@hidden>
Content-Type: text/plain; charset=utf-8; format=flowed

Hello every one!

I am new to lwIP and to this list. Right now I am just trying to get the
Unix port work on my box (Ubuntu 14.04 on x86_64) in order to get started
with lwIP. My understanding is that echop (minimal project) and unixsim (the
development platform, according to the README) are good starting points...
but I am struggling to get these work.

What I did is basically the following:

     # Get a development snapshot
     git clone --depth 1 git://git.sv.gnu.org/lwip.git
     git clone --depth 1 git://git.sv.gnu.org/lwip/lwip-contrib.git

     # First, try the minimal project
     cd lwip-contrib/ports/unix/proj/minimal
     make  # -> fail
     # fix the compile errors
     make  # -> success
     sudo ./echop  # test -> fail

     # Next, try simhost
     cd ../unixsim
     make  # -> fail
     # fix the compile errors
     make  # -> success
     sudo ./simhost  # test -> fail

As shown above, I had to edit a few files in order to get this compile.
Here is the list of the edits, as patches attached to this message:

   * patches to lwip:

     + define-fd-set-val.patch:
         In src/include/lwip/sockets.h, define FD_SET_VAL() if needed. Do
         not assume defined(FD_SET) implies defined(FD_SET_VAL).

     + const-mib_node.patch
         In src/core/snmp/mib2.c, add a const qualifier to a struct
         mib_node* array. This array is used to initialize a struct
         mib_array_node which requires the qualifier.

   * patches to lwip-contrib:

     + contrib-const-mib_node.patch
         Same as above, but for several arrays in

     + snmp_set_stuff-nbargs.patch
         In ports/unix/proj/minimal/main.c, call snmp_set_syscontact()
         and snmp_set_syslocation() with the proper number of arguments
         (3 instead of 2).

Now that it compiles, the results of my tests are the following:

   * Both echop and simhost create a tap0 interface bound to on the Linux side. Both display, upon startup, the

         Host at mask gateway

     Both respond to arp and ping requests to However, TCP
     connection requests (on port 7 for echop and port 80 for simhost)
     are not answered. According to Wireshark, the SYN packets are just
     silently dropped.

   * On echop, the -d (debug) option has no effect. On simhost, this
     same option triggers a very verbose output. When simhost receives a
     TCP SYN while in verbose mode, it outputs

         ip_route: No route to

     This makes little sense to me: is on the same local net
     ( than simhost itself, how come it cannot find the

   * Stracing echop shows that it reads all the incoming packets from
     /dev/net/tun and writes the replies (arp and ping) to the same
     special file. Nothing is written in response to TCP SYNs.

Now I come with a lot of questions: Is this the proper venue to get help on
debugging all this? Should I go to lwip-devel instead? What should I do with
my patches? Should I open a bug on the savannah bug tracker for each of
them? If so, should I attach the patch to the bug or put it on the patch
tracker instead? Anyone an idea on how to debug the "No route to" problem? Anyone managed to get this Unix port working on a
Debian-like system?

Oh, BTW, I also tried the 1.4.1 release: simhost works fine on that version
(after applying a different set of patches to make it compile):
I can see a nice web page on . echop does not work.


Edgar Bonet.

PS: This is the second time I am sending this message. First time was last
Thursday, and it did not get through. At this point I assume it has been
dropped, not just delayed. This time I am omitting the patches that where
originally attached, on the assumption that the list server may just be
filtering out any message with attachments.


lwip-users mailing list

End of lwip-users Digest, Vol 141, Issue 4

reply via email to

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