raw: Add list function for finding an element.
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 21 May 2011 08:48:55 +0000 (11:48 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 21 May 2011 08:48:55 +0000 (11:48 +0300)
src/raw/swift_raw.c

index 7a5da0d..441181a 100644 (file)
@@ -36,6 +36,10 @@ static struct sock_list sock_list_head = {
        .prev = &sock_list_head
 };
 
+/*
+ * Add new socket to list. Called by sw_socket "syscall".
+ */
+
 static struct sock_list *list_add_socket(int s)
 {
        struct sock_list *ptr = malloc(sizeof(*ptr));
@@ -50,6 +54,10 @@ static struct sock_list *list_add_socket(int s)
        return ptr;
 }
 
+/*
+ * Bind socket to given address. Called by sw_bind "syscall".
+ */
+
 static struct sock_list *list_update_socket_address(int s, struct sockaddr_sw *addr)
 {
        struct sock_list *ptr;
@@ -63,6 +71,26 @@ static struct sock_list *list_update_socket_address(int s, struct sockaddr_sw *a
        return NULL;
 }
 
+/*
+ * Get list element containing socket s. Called by sw_send* "syscalls".
+ */
+
+static struct sock_list *list_elem_from_socket(int s)
+{
+       struct sock_list *ptr;
+
+       for (ptr = sock_list_head.next; ptr != &sock_list_head; ptr = ptr->next)
+               if (ptr->s == s) {
+                       return ptr;
+               }
+
+       return NULL;
+}
+
+/*
+ * Remove socket from list. Called by sw_close "syscall".
+ */
+
 static struct sock_list *list_unlink_socket(int s)
 {
        struct sock_list *ptr;