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.


fixed spurious characters...
[palacios.git] / palacios / include / palacios / vmm_socket.h
index df3bece..6025869 100644 (file)
@@ -42,7 +42,7 @@
       extern struct v3_socket_hooks * sock_hooks;      \
       V3_SOCK sock = 0;                                        \
       if ((sock_hooks) && (sock_hooks)->tcp_socket) {  \
-       sock = (sock_hooks)->tcp_socket(0,0);           \
+       sock = (sock_hooks)->tcp_socket(0,0,0);         \
       }                                                        \
       sock;                                            \
     })
     })
 
 
-#define V3_Accept_Socket() (-1)
-#define V3_Select_Socket() (-1)
+#define V3_Accept_Socket(sock, ip_ptr) ({                      \
+      extern struct v3_socket_hooks * sock_hooks;              \
+      int ret = -1;                                            \
+      if ((sock_hooks) && (sock_hooks)->accept) {              \
+       ret = (sock_hooks)->accept(sock, ip_ptr);               \
+      }                                                                \
+      ret;                                                     \
+    })
+
+
+#define V3_Select_Socket(rset,wset,eset,tv) ({                 \
+      extern struct v3_socket_hooks * sock_hooks;              \
+      int ret = -1;                                            \
+      if ((sock_hooks) && (sock_hooks)->select) {              \
+       ret = (sock_hooks)->select(rset, wset, eset, tv);       \
+      }                                                                \
+      ret;                                                     \
+    })
 
 
 
 #define V3_RecvFrom_Host(sock, hostname, port, buf, len) ({            \
       extern struct v3_socket_hooks * sock_hooks;                      \
       int ret = -1;                                                    \
-      if ((sock_hooks) && (sock_hooks)->recvfrom_host) {                       \
+      if ((sock_hooks) && (sock_hooks)->recvfrom_host) {               \
        ret = (sock_hooks)->recvfrom_host(sock, hostname, port, buf, len); \
       }                                                                        \
       ret;                                                             \
@@ -159,17 +175,30 @@ struct v3_timeval {
   long    tv_usec;        /* and microseconds */
 };
 
-struct v3_sock_set {
+struct v3_sock_entry {
   V3_SOCK sock;
   unsigned int is_set;
-  struct v3_sock_set * next;
+  struct v3_sock_entry * next;
+};
+
+struct v3_sock_set {
+  unsigned int num_socks;
+  struct v3_sock_entry * socks;
 };
 
 
-#define v3_set_sock(n, p)  ((p)->fd_bits[(n)/8] |=  (1 << ((n) & 7)))
-#define v3_clr_sock(n, p)  ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
-#define v3_isset_sock(n,p) ((p)->fd_bits[(n)/8] &   (1 << ((n) & 7)))
-#define v3_zero_sockset(p)    
+void v3_init_sock_set(struct v3_sock_set * sock_set);
+
+void v3_set_sock(struct v3_sock_set * sock_set, V3_SOCK sock); // adds socket to the sockset
+void v3_clr_sock(struct v3_sock_set * sock_set, V3_SOCK sock); // deletes socket from sockset
+int v3_isset_sock(struct v3_sock_set * sock_set, V3_SOCK sock);  // checks is_set vairable 
+void v3_zero_sockset(struct v3_sock_set * sock_set);    // clears all is_set variables.
+
+
+
+#define v3_foreach_sock(/* (struct v3_sock_set *) */ sock_set, /* (struct v3_sock_entry *) */ iter) \
+       for (iter = sock_set->socks; iter != NULL; iter = iter->next)
+
 
 
 struct v3_socket_hooks {
@@ -182,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);
+  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, \
@@ -211,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