ia64/xen-unstable

view extras/mini-os/daytime.c @ 18811:390ef36eb596

Remove Xen-private definitions from kexec public header.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Nov 19 13:13:39 2008 +0000 (2008-11-19)
parents 7fc9767f966a
children
line source
1 /*
2 * daytime.c: a simple network service based on lwIP and mini-os
3 *
4 * Tim Deegan <Tim.Deegan@eu.citrix.net>, July 2007
5 */
7 #include <os.h>
8 #include <xmalloc.h>
9 #include <console.h>
10 #include <netfront.h>
11 #include <lwip/api.h>
13 static char message[29];
15 void run_server(void *p)
16 {
17 struct ip_addr listenaddr = { 0 };
18 struct netconn *listener;
19 struct netconn *session;
20 struct timeval tv;
21 err_t rc;
23 start_networking();
25 if (0) {
26 struct ip_addr ipaddr = { htonl(0x0a000001) };
27 struct ip_addr netmask = { htonl(0xff000000) };
28 struct ip_addr gw = { 0 };
29 networking_set_addr(&ipaddr, &netmask, &gw);
30 }
32 tprintk("Opening connection\n");
34 listener = netconn_new(NETCONN_TCP);
35 tprintk("Connection at %p\n", listener);
37 rc = netconn_bind(listener, &listenaddr, 13);
38 if (rc != ERR_OK) {
39 tprintk("Failed to bind connection: %i\n", rc);
40 return;
41 }
43 rc = netconn_listen(listener);
44 if (rc != ERR_OK) {
45 tprintk("Failed to listen on connection: %i\n", rc);
46 return;
47 }
49 while (1) {
50 session = netconn_accept(listener);
51 if (session == NULL)
52 continue;
54 gettimeofday(&tv, NULL);
55 sprintf(message, "%20lu.%6.6lu\n", tv.tv_sec, tv.tv_usec);
56 (void) netconn_write(session, message, strlen(message), NETCONN_COPY);
57 (void) netconn_disconnect(session);
58 (void) netconn_delete(session);
59 }
60 }
63 int app_main(start_info_t *si)
64 {
65 create_thread("server", run_server, NULL);
66 return 0;
67 }