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.


added a configuration structure for the binary inputs to the vmm (ramdisk, bios)
[palacios.git] / geekos / src / geekos / net.c
1 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
2 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
3
4
5 #include <geekos/net.h>
6 #include <geekos/socket.h>
7 #include <geekos/ne2k.h>
8
9 #include <geekos/debug.h>
10
11 #ifdef LWIP
12 #include <lwip/apps/ping.h>
13 #include <lwip/lwip/sockets.h>
14 #include <lwip/ipv4/lwip/ip_addr.h>
15 #include <lwip/netif/ne2kif.h>
16 #include <lwip/sys.h>
17 #include <lwip/netifapi.h>
18 #include <lwip/tcpip.h>
19
20 #include <netif/etharp.h>
21
22
23 static void
24 tcpip_init_done(void *arg)
25 {
26   sys_sem_t *sem;
27   sem = arg;
28   sys_sem_signal(*sem);
29 }
30
31 void Init_Network() {
32
33   //temporay now we are using lwip sockets
34   // init_socket_layer();
35   
36   struct ip_addr ipaddr, netmask, gateway;
37   sys_sem_t sem;
38   err_t err;
39
40   sem = sys_sem_new(0);
41
42 #ifdef LWIP_DEBUG
43   PrintBoth("lwIP: before tcpip_init\n");
44 #endif
45
46   tcpip_init(tcpip_init_done, &sem);  //initial the whole lwip module
47
48 #ifdef LWIP_DEBUG
49   PrintBoth("lwIP: After tcpip_init\n");
50 #endif
51
52   sys_sem_wait(sem);
53   sys_sem_free(sem);
54  
55   IP4_ADDR(&gateway, 192,168,1,1);
56   IP4_ADDR(&ipaddr, 192,168,1,2);
57   IP4_ADDR(&netmask, 255,255,255,0);
58
59
60   err = netifapi_netif_add(&ne2kif, &ipaddr, &netmask, &gateway, 
61                                                 NULL, ne2kif_init, ethernet_input); 
62   
63   if (err != ERR_OK){
64                 PrintBoth("lwip: initial network failed! add netif error %d/n", err);
65                 return;
66   }
67   
68   netifapi_netif_set_default(&ne2kif);
69
70   //initial a network application
71   ping_init();
72 }
73
74 #endif
75
76
77 #if 0
78 void test_network() {
79
80     uchar_t local_addr[4];
81     uchar_t remote_addr[4];
82
83     local_addr[0] = 10;
84     local_addr[1] = 0;
85     local_addr[2] = 2;
86     local_addr[3] = 21;
87
88 //    set_ip_addr(local_addr);
89
90     remote_addr[0] = 10;
91     remote_addr[1] = 0;
92     remote_addr[2] = 2;
93     remote_addr[3] = 20;
94
95
96    // connect(remote_addr, 4301);
97
98 }
99
100 #endif