Hello!
I'm writing a network application using libc, lwip, libc_lwip, and libc_lwip_nic_dhcp. But when I call socket(SOCK_STREAM), it hangs somewhere in lwip_socket(). Maybe it has something to do with the lwip tcp thread, but I'm not sure.
What else should I check for?
Thanks.
Hi,
On Thu, Mar 10, 2011 at 10:39:00AM +0300, Александр Домо wrote:
I'm writing a network application using libc, lwip, libc_lwip, and libc_lwip_nic_dhcp. But when I call socket(SOCK_STREAM), it hangs somewhere in lwip_socket(). Maybe it has something to do with the lwip tcp thread, but I'm not sure.
Maybe, maybe not, your provided rather little information about your application scenario. Please send information about the Genode platform you use, init configuration, the log messages, and at best your source code (snippets). Did you implement a client or server application?
What else should I check for?
First, try to find out, if any packet leaves or enters your Genode network node with Wireshark or a similar tool. Lwip should do DHCP to discover the network configuration. You could also try to ICMP ping the Genode node from another node in the network.
Regards
10.03.11 в 11:21 Christian Helmuth в письме писал(а):
Hi,
I'm writing a network application using libc, lwip, libc_lwip, and libc_lwip_nic_dhcp. But when I call socket(SOCK_STREAM), it hangs somewhere in lwip_socket().
Maybe, maybe not, your provided rather little information about your application scenario. Please send information about the Genode platform you use, init configuration, the log messages, and at best your source code (snippets). Did you implement a client or server application?
Yes, it seems I get dumb when I'm frustrated... Actually, I hoped it was something obvious, that's why I didn't get to the details. I'm using the latest downloaded package (not svn) I'm launching nic_drv + myapp (BTW, nic_drv + lwip_httpsrv works fine!) DHCP & ARP is working, therefore packets are sent fine. It's a client app, and here are the logs (I managed to turn on debug output in lwip):
int main(): --- create local services --- int main(): --- start init --- int main(): transferred 79 MB to init int main(): --- init created, waiting for exit condition --- [init] unsupported program segment type 0x4 [init] unsupported program segment type 0x4 [init -> myapp] Starting ldso ... [init -> myapp] Starting application ... environ: b78c6058 [init -> myapp] void init_nic_dhcp(): init_nic_dhcp() [init -> myapp] Libc::Lwip_plugin::Lwip_plugin(): using the lwIP libc plugin [init -> myapp] netif_set_ipaddr: netif address being changed [init -> myapp] netif: IP address of interface [init -> myapp] netif: netmask of interface [init -> myapp] netif: GW address of interface [init -> myapp] netif: added interface lo IP addr 127.0.0.1 netmask 255.255.255.0 gw 127.0.0.1 [init -> myapp] netif: IP address of interface [init -> myapp] netif: netmask of interface [init -> myapp] netif: GW address of interface [init -> myapp] netif: added interface en IP addr 0.0.0.0 netmask 0.0.0.0 gw 0.0.0.0 [init -> myapp] netif: setting default interface en [init -> fb_sdl] creating virtual framebuffer for mode 640x480@...64... [init -> fb_sdl] int main(int, char**): fb_ds_cap has port 49236 [init -> nitpicker] framebuffer is 640x480@...23... [init -> myapp] netif_set_ipaddr: netif address being changed [init -> myapp] netif: IP address of interface en set to 192.168.28.133 [init -> myapp] netif: netmask of interface en set to 255.255.255.0 [init -> myapp] netif: GW address of interface en set to 192.168.28.2 [init -> myapp] void init_libc_lwip(): init_libc_lwip() [init -> myapp] connection() [init -> myapp] virtual Libc::File_descriptor* Libc::Lwip_plugin::socket(int, int, int): socket() [init -> myapp] lwip_socket()... ^C
What's interesting, the nic_drv + lwip_httpsrv config pings ok, my config doesn't.
Thanks.
Hello,
On Thu, Mar 10, 2011 at 11:55:50PM +0300, Александр Домо wrote:
What's interesting, the nic_drv + lwip_httpsrv config pings ok, my config doesn't.
I built current SVN head with the patch attached to this email. After
make run/lwip_httpsrv_lx
I got a running http_srv with the libc plugin. Could you please check if this works for you too. BTW, your using Genode/Linux, right?
Greets
11.03.11 в 11:28 Christian Helmuth в письме писал(а):
Hello,
On Thu, Mar 10, 2011 at 11:55:50PM +0300, Александр Домо wrote:
What's interesting, the nic_drv + lwip_httpsrv config pings ok, my config doesn't.
I built current SVN head with the patch attached to this email. After
make run/lwip_httpsrv_lx
I got a running http_srv with the libc plugin. Could you please check
Yes, it's working!
if this works for you too. BTW, your using Genode/Linux, right?
Yes.
What's interesting, the logs are absolutely identical (except for the pointer values), but my app gets to lwip_socket() and just stops there...
I think I'll try studying this on my own from this point. I'll let know if I get anywhere!
Thanks!
P.S. When calling socket(), the execution stops in the function tcpip_apimsg()
P.P.S. In the file base/src/base/elf/elf_binary.cc consider replacing printf's with PWRN(), cause otherwise the whole output after that becomes blue ;)
Hello again!
11.03.11 в 16:02 Александр Домо в письме писал(а):
What's interesting, the nic_drv + lwip_httpsrv config pings ok, my config doesn't.
I built current SVN head with the patch attached to this email. After
make run/lwip_httpsrv_lx
I got a running http_srv with the libc plugin. Could you please check
Yes, it's working!
if this works for you too. BTW, your using Genode/Linux, right?
Yes.
What's interesting, the logs are absolutely identical (except for the pointer values), but my app gets to lwip_socket() and just stops there...
I think I'll try studying this on my own from this point. I'll let know if I get anywhere!
I finally got to the root of the problem! In my project source code I found a number of functions named "tcp_xxx", and particularly, tcp_init(), that came into conflict with the ones in the lwip library. When I renamed them, the problem was gone. Now if you could tell me who is right and who is wrong in this case? What is the right way of doing this?
Thanks!
Hi Александр,
On Mon, Mar 14, 2011 at 08:31:35PM +0300, Александр Домо wrote:
I finally got to the root of the problem! In my project source code I found a number of functions named "tcp_xxx", and particularly, tcp_init(), that came into conflict with the ones in the lwip library. When I renamed them, the problem was gone. Now if you could tell me who is right and who is wrong in this case? What is the right way of doing this?
Using the lwIP library you kind of sign a contract to not name your own API functions like exported functions. We did some mix of incremental link and making function private with objcopy in past projects, but I explicitly do not recommend such hacks if avoidable in any way. A clean interface is the best track.
If I am in doubt which symbol names can be used, I investigate the libraries with 'nm', prefix my C symbols or (at the best) use a C++ namespace for my own API.
Regards
On Mon, Mar 14, 2011 at 08:31:35PM +0300, Александр Домо wrote:
I finally got to the root of the problem! In my project source code I found a number of functions named "tcp_xxx", and particularly, tcp_init(), that came into conflict with the ones in the lwip library. When I renamed them, the problem was gone. Now if you could tell me who is right and who is wrong in this case? What is the right way of doing this?
Using the lwIP library you kind of sign a contract to not name your own API functions like exported functions. We did some mix of incremental link and making function private with objcopy in past projects, but I explicitly do not recommend such hacks if avoidable in any way. A clean interface is the best track.
If I am in doubt which symbol names can be used, I investigate the libraries with 'nm', prefix my C symbols or (at the best) use a C++ namespace for my own API.
Yes, I now understand it's part of the lwIP API. It's just the first time that I got stuck this way. Using namespaces is probably the best approach.
Thanks for helping!!!