Hi,
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??
Peter
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,
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@...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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/genode-main
Hello Peter,
On Tue, Mar 02, 2010 at 12:20:15AM +1030, Peter Nguyen wrote:
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)
You're digging deep into lwIP here, that we just adopted for Genode, but I'll share my limited knowledge...
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?
'pcb.ip' is the lwIP-internal protocol control block for IP packets [1]. Therefore, I assume that the fields (e.g., local_ip or tos) correspond to the connection configuration and will end as in the final network packet on the wire. Note, IP addresses are stored in network byte order [2].
[1] lwip-1.3.2/src/include/lwip/api.h:114 [2] lwip-1.3.2/src/include/ipv4/lwip/ip.h:76
Regards
On Monday, 1. March 2010 16:17:05 Christian Helmuth wrote:
Hello Peter,
On Tue, Mar 02, 2010 at 12:20:15AM +1030, Peter Nguyen wrote:
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)
You're digging deep into lwIP here, that we just adopted for Genode, but I'll share my limited knowledge...
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?
'pcb.ip' is the lwIP-internal protocol control block for IP packets [1]. Therefore, I assume that the fields (e.g., local_ip or tos) correspond to the connection configuration and will end as in the final network packet on the wire. Note, IP addresses are stored in network byte order [2].
[1] lwip-1.3.2/src/include/lwip/api.h:114 [2] lwip-1.3.2/src/include/ipv4/lwip/ip.h:76
Regards
Hi Peter,
as Christian already mentioned, this code is related to the LwIP library and is not specific to Genode. If you have questions regarding the internals of LwIP, the lwip-users mailing list might be of value for you: http://lists.nongnu.org/mailman/listinfo/lwip-users
Nevertheless, within Genode I recommend to not use the netconn interface directly, but use LwIP's BSD-like socket interface (lwip/socket.h) or our LwIP plugin for the libc, as its more convenient to use. Regardless of what kind of interface you choose, I strongly recommend you to update to Genode's last release 10.02, as it contains a far-reaching rework of Genode's LwIP backend, including several bug-fixes.
regards