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.


*** empty log message ***
[palacios.git] / palacios / src / geekos / socket.c
1 #include <geekos/socket.h>
2
3 #define MAX_SOCKS 1024
4
5 struct socket sockets[1024];
6
7
8 void init_network() {
9   int i = 0;
10
11   for (i = 0; i < MAX_SOCKS; i++) {
12     sockets[i].in_use = 0;
13     init_queue(&(sockets[i].send_queue));
14     init_queue(&(sockets[i].recv_queue));
15   }
16
17   // set up interrupt handler
18   // set up device driver
19
20
21 }
22
23 static int allocate_socket_fd() {
24   int i = 0;
25   
26   for (i = 0; i < MAX_SOCKS; i++) {
27     if (sockets[i].in_use == 0) {
28       sockets[i].in_use = 1;
29       return i;
30     }
31   }
32
33   return -1;
34 }
35
36
37 struct socket * get_socket_from_fd(int fd) {
38   return &(sockets[fd]);
39 }
40
41
42
43
44 int connect(const uint_t ip_addr) {
45   int sockfd = -1;
46   sockfd = allocate_socket_fd();
47
48   if (sockfd == -1) {
49     return -1;
50   }
51
52
53
54   return sockfd;
55
56 }