ia64/xen-unstable

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