Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios...
Lei Xia [Tue, 3 Feb 2009 22:09:59 +0000 (16:09 -0600)]
palacios/build/Makefile
palacios/include/palacios/vmm_socket.h
palacios/src/palacios/vmm_socket.c

index c50323e..1b2cf5d 100644 (file)
@@ -3,7 +3,7 @@
 #  Northwestern University 
 # (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
 # (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
-# (c) 2008, Lei Xia <xiaxlei@gmail.com>
+# (c) 2008, Lei Xia <lxia@northwestern.edu>
 # (c) 2008, The V3VEE Project <http://www.v3vee.org> 
 #
 # Based on GeekOS Makefile:
index bd88682..92a916d 100644 (file)
@@ -203,7 +203,7 @@ void v3_zero_sockset(struct v3_sock_set * sock_set);    // clears all is_set var
 
 struct v3_socket_hooks {
   // Socket creation routines
-  V3_SOCK (*tcp_socket)(const int bufsize, const int nodelay, const int nonblocking);
+xsxsxsxsxs  V3_SOCK (*tcp_socket)(const int bufsize, const int nodelay, const int nonblocking);
   V3_SOCK (*udp_socket)(const int bufsize, const int nonblocking);
 
   // Socket Destruction
@@ -211,8 +211,10 @@ struct v3_socket_hooks {
 
   // Network Server Calls
   int (*bind_socket)(const V3_SOCK sock, const int port);
+
+  int (*listen)(const V3_SOCK sock, int backlog);
   
-  int (*accept)(const V3_SOCK const sock, unsigned int * remote_ip);
+  V3_SOCK (*accept)(const V3_SOCK const sock, unsigned int * remote_ip, unsigned int * port);
   // This going to suck
   int (*select)(struct v3_sock_set * rset, \
                struct v3_sock_set * wset, \
@@ -240,7 +242,7 @@ struct v3_socket_hooks {
 };
 
 
-void V3_Init_Socket(struct v3_socket_hooks * hooks);
+extern void V3_Init_Sockets(struct v3_socket_hooks * hooks);
 
 
 #endif
index dbc19c0..2832db7 100644 (file)
 
 #include <palacios/vmm_socket.h>
 #include <palacios/vmm.h>
+#include <palacios/vmm_debug.h>
+#include <palacios/vmm_stddef.h>
 
 
 struct v3_socket_hooks * sock_hooks = 0;
 
 
+//static int v3_socket_api_test(void);
 
 
 void V3_Init_Sockets(struct v3_socket_hooks * hooks) {
   PrintInfo("Initializing Socket Interface\n");
   sock_hooks = hooks;
+
+  PrintDebug("V3 sockets inited\n");
+
+  //v3_socket_api_test();
+  
+  return;
 }
 
 
@@ -38,6 +47,7 @@ void v3_init_sock_set(struct v3_sock_set * sock_set) {
   sock_set->num_socks = 0;
   sock_set->socks = NULL;
 
+  return;
 }
 
 
@@ -107,3 +117,62 @@ void v3_zero_sockset(struct v3_sock_set * sock_set) {
     iter->is_set = 0;
   }
 }
+
+#if 0
+static int
+v3_socket_api_test(void)
+{
+       unsigned int port;
+       char buf[1024];
+       int rc = 0;
+       V3_SOCK sock; 
+       V3_SOCK client;
+       unsigned int remote_ip;
+       
+       PrintDebug("\nIn Palacios: TEST BEGIN: Sockets API\n");
+       sock = sock_hooks->tcp_socket(0, 0, 0);
+       if( sock == NULL ){
+               PrintDebug( "ERROR: tcp_socket() failed!\n");
+               return -1;
+       }
+
+       port = 80;
+
+       if( sock_hooks->bind_socket(sock, port) < 0){
+               PrintDebug("bind error\n");
+               return -1;
+       }
+
+       if( sock_hooks->listen(sock, 1) < 0) {
+               PrintDebug("listen error\n" );
+               return -1;
+       }
+
+       PrintDebug( "Going into mainloop: server listening on port %d\n", port);
+
+       client = sock_hooks->accept(sock, &remote_ip , &port);
+
+       PrintDebug(" New connection from %d port: %d\n", remote_ip, port);
+            
+       sock_hooks->send(client, "Welcome!\n", 9);
+
+       while(1)
+       {               
+            sock_hooks->send(client, buf, rc);
+            rc = sock_hooks->recv(client, buf, sizeof(buf)-1);
+            if( rc <= 0 ){
+                               PrintDebug( "Closed connection\n");
+                               sock_hooks->close(client);
+                               break;
+            }
+
+            buf[rc] = '\0';
+
+            PrintDebug( "Read %d bytes: '%s'\n", rc, buf);
+        }
+
+       PrintDebug("TEST END: Sockets API\n");
+       return 0;
+}
+
+#endif