2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/vmm_socket.h>
22 #include <palacios/vmm.h>
25 struct v3_socket_hooks * sock_hooks = 0;
30 void V3_Init_Sockets(struct v3_socket_hooks * hooks) {
31 PrintInfo("Initializing Socket Interface\n");
37 void v3_init_sock_set(struct v3_sock_set * sock_set) {
38 sock_set->num_socks = 0;
39 sock_set->socks = NULL;
47 /* This should probably check if the socket is already added */
48 // adds socket to the sockset
49 void v3_set_sock(struct v3_sock_set * sock_set, V3_SOCK sock) {
50 struct v3_sock_entry * new_entry = V3_Malloc(sizeof(struct v3_sock_entry));
52 new_entry->sock = sock;
53 new_entry->is_set = 0;
55 if (sock_set->socks) {
56 new_entry->next = sock_set->socks;
59 sock_set->socks = new_entry;
61 sock_set->num_socks++;
65 // deletes socket from sockset
66 void v3_clr_sock(struct v3_sock_set * sock_set, V3_SOCK sock) {
67 struct v3_sock_entry * iter, * back_ptr;
69 iter = sock_set->socks;
72 v3_foreach_sock(sock_set, iter) {
73 if (iter->sock == sock) {
74 if (back_ptr == NULL) {
75 sock_set->socks = iter->next;
77 back_ptr->next = iter->next;
82 sock_set->num_socks--;
90 // checks is_set vairable
91 int v3_isset_sock(struct v3_sock_set * sock_set, V3_SOCK sock) {
92 struct v3_sock_entry * iter;
94 v3_foreach_sock(sock_set, iter) {
95 if (iter->sock == sock) {
103 // clears all is_set variables.
104 void v3_zero_sockset(struct v3_sock_set * sock_set) {
105 struct v3_sock_entry * iter;
106 v3_foreach_sock(sock_set, iter) {