Further questions about LWIP/HTTP server

Peter Nguyen peter.nguyen at ...29...
Mon Mar 1 14:50:15 CET 2010


Stefan,

Sorry, I should have mentioned more specifically what i was after. So, i was
referring to the http_server_serve function in the http server code, whereby
upon receiving a HTTP request, the struct netconn variable (conn) seems to store
IP addresses which I think refer to the IP address that the HTTP request will be
sent back to. In following the struct netconn variable, I noticed two IP
addresses are stored: a local IP, and a remote IP. I discovered this via the
following code that I added:

addr = conn->pcb.ip->remote_ip.addr (remote_ip can be replaced by local_ip)

I was wondering what the purpose of the remote_ip and local_ip variables were?
Am i right in saying that remote_ip refers to the machine that performed the
HTTP request?

Thanks
Peter

Quoting Stefan Kalkowski <stefan.kalkowski at ...1...>:

> On Monday, 1. March 2010 05:30:27 Peter Nguyen wrote:
> > Hi,
>
> Hi Peter,
>
> >
> > In digging to the HTTP server functionality, I noticed that with IP
> > address, data is stored for local and remote IP addresses. I gather
> > remote IPs refer to the machines making the requests. Does the local IP
> > refer to the HTTP server itself??
>
> Well, I'm not sure what code you refer to: the actual HTTP server example
> code, or something in the LwIP libary? Moreover, I'm not sure, whether I got
> you right.
>
> If you talk about the HTTP server example code, there are 2 locations where
> a 'sockaddr' is used, the one representing the address of the http server, so
> to say the local IP (refering to the HTTP server):
>
> libports/src/test/lwip/http_srv/main.cc:89
>  struct sockaddr_in in_addr;
>  in_addr.sin_family = AF_INET;
>  in_addr.sin_port = htons(80);
>  in_addr.sin_addr.s_addr = INADDR_ANY;
>  if(lwip_bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
>  ...
>
> and one which is used to accept client connections, that will contain the
> address of the client, after a successful accept:
>
> libports/src/test/lwip/http_srv/main.cc:106
>  struct sockaddr addr;
>  socklen_t len = sizeof(addr);
>  int client = lwip_accept(s, &addr, &len);
>  ...
>
> Does this clarify your question?
>
> regards Stefan
>
> PS: I refer to the example code of our last release 10.02
>
> --
> Stefan Kalkowski
> Genode Labs Developer
> http://genode-labs.com
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Genode-main mailing list
> Genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
>






More information about the users mailing list