This is a small test page."; /* HTML page */
+enum { HTTP_INDEX_HTML_SZ = 1024 };
+
+static char http_index_html[HTTP_INDEX_HTML_SZ]; /* HTML page */
+
+using namespace Genode;
/**
@@ -52,7 +57,7 @@ void http_server_serve(int conn)
/* Read the data from the port, blocking if nothing yet there.
We assume the request (the part we care about) is in one packet */
buflen = lwip_recv(conn, buf, 1024, 0);
- Genode::log("Packet received!");
+ log("Packet received!");
/* Ignore all receive errors */
if (buflen > 0) {
@@ -66,7 +71,7 @@ void http_server_serve(int conn)
buf[3] == ' ' &&
buf[4] == '/' ) {
- Genode::log("Will send response");
+ log("Will send response");
/* Send http header */
lwip_send(conn, http_html_hdr, Genode::strlen(http_html_hdr), 0);
@@ -78,50 +83,104 @@ void http_server_serve(int conn)
}
+template This is a small test page.",
+ ip_addr_str.string(), port);
+
+ log("Now, I will bind ...");
struct sockaddr_in in_addr;
in_addr.sin_family = AF_INET;
- in_addr.sin_port = htons(80);
+ in_addr.sin_port = htons(port);
in_addr.sin_addr.s_addr = INADDR_ANY;
if(lwip_bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
- Genode::error("bind failed!");
+ error("bind failed!");
return -1;
}
- Genode::log("Now, I will listen ...");
+ log("Now, I will listen ...");
if(lwip_listen(s, 5)) {
- Genode::error("listen failed!");
+ error("listen failed!");
return -1;
}
- Genode::log("Start the server loop ...");
+ log("Start the server loop ...");
while(true) {
struct sockaddr addr;
socklen_t len = sizeof(addr);
int client = lwip_accept(s, &addr, &len);
if(client < 0) {
- Genode::warning("invalid socket from accept!");
+ warning("invalid socket from accept!");
continue;
}
http_server_serve(client);
diff --git a/repos/libports/src/test/lwip/http_srv_static/target.mk b/repos/libports/src/test/lwip/http_srv_static/target.mk
index b688ef91d..38dc61a22 100644
--- a/repos/libports/src/test/lwip/http_srv_static/target.mk
+++ b/repos/libports/src/test/lwip/http_srv_static/target.mk
@@ -1,5 +1,5 @@
TARGET = test-lwip_httpsrv_static
-LIBS = lwip libc
+LIBS = lwip libc config
SRC_CC = main.cc
INC_DIR += $(REP_DIR)/src/lib/lwip/include
HTTP server at %s:%u
"
+ "