X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=geekos%2Fsrc%2Fgeekos%2Fnet.c;h=7067a38db57d0a55886ee261ca7ab98f5674f5f2;hp=8fc76bc128486873c8611a8eae2cdb277cf88193;hb=a1073097716c800734e117267ce7aa92aa0d9a17;hpb=819c31aa7157ed1e3e17b9f05bf74de38179233d diff --git a/geekos/src/geekos/net.c b/geekos/src/geekos/net.c index 8fc76bc..7067a38 100644 --- a/geekos/src/geekos/net.c +++ b/geekos/src/geekos/net.c @@ -1,33 +1,74 @@ -/* - * This file is part of the Palacios Virtual Machine Monitor developed - * by the V3VEE Project with funding from the United States National - * Science Foundation and the Department of Energy. - * - * The V3VEE Project is a joint project between Northwestern University - * and the University of New Mexico. You can find out more at - * http://www.v3vee.org - * - * Copyright (c) 2008, Jack Lange - * Copyright (c) 2008, The V3VEE Project - * All rights reserved. - * - * Author: Jack Lange - * - * This is free software. You are permitted to use, - * redistribute, and modify it as specified in the file "V3VEE_LICENSE". - */ +/* (c) 2008, Jack Lange */ +/* (c) 2008, The V3VEE Project */ + #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include -void Init_Network() { - init_socket_layer(); + +static void +tcpip_init_done(void *arg) +{ + sys_sem_t *sem; + sem = arg; + sys_sem_signal(*sem); } +void Init_Network() { + + //temporay now we are using lwip sockets + // init_socket_layer(); + + struct ip_addr ipaddr, netmask, gateway; + sys_sem_t sem; + err_t err; + + sem = sys_sem_new(0); + +#ifdef LWIP_DEBUG + PrintBoth("lwIP: before tcpip_init\n"); +#endif + tcpip_init(tcpip_init_done, &sem); //initial the whole lwip module +#ifdef LWIP_DEBUG + PrintBoth("lwIP: After tcpip_init\n"); +#endif + sys_sem_wait(sem); + sys_sem_free(sem); + + IP4_ADDR(&gateway, 192,168,1,1); + IP4_ADDR(&ipaddr, 192,168,1,2); + IP4_ADDR(&netmask, 255,255,255,0); + + + err = netifapi_netif_add(&ne2kif, &ipaddr, &netmask, &gateway, + NULL, ne2kif_init, ethernet_input); + + if (err != ERR_OK){ + PrintBoth("lwip: initial network failed! add netif error %d/n", err); + return; + } + + netifapi_netif_set_default(&ne2kif); + + //initial a network application + ping_init(); +} + + +#if 0 void test_network() { uchar_t local_addr[4]; @@ -38,7 +79,7 @@ void test_network() { local_addr[2] = 2; local_addr[3] = 21; - set_ip_addr(local_addr); +// set_ip_addr(local_addr); remote_addr[0] = 10; remote_addr[1] = 0; @@ -46,6 +87,8 @@ void test_network() { remote_addr[3] = 20; - connect(remote_addr, 4301); + // connect(remote_addr, 4301); } + +#endif