net: add ipv4 test

This commit is contained in:
Avi Kivity
2014-08-31 20:38:59 +03:00
parent ad312f9889
commit 99ed043a41
2 changed files with 27 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ CXXFLAGS += -pthread
# Ubuntu fails without this, see https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201
CXXFLAGS += -Wl,--no-as-needed
tests = test-reactor fileiotest virtiotest l3_test
tests = test-reactor fileiotest virtiotest l3_test ip_test
link = $(CXX) $(CXXFLAGS) -o $@ $^
@@ -44,4 +44,6 @@ virtiotest: virtiotest.o virtio.o reactor.o net.o ip.o ethernet.o arp.o
l3_test: l3_test.o virtio.o reactor.o net.o ip.o ethernet.o arp.o
ip_test: ip_test.o virtio.o reactor.o net.o ip.o arp.o ethernet.o
-include *.d

24
ip_test.cc Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2014 Cloudius Systems, Ltd.
*/
#include "arp.hh"
#include "ip.hh"
#include "net.hh"
#include "reactor.hh"
#include "virtio.hh"
using namespace net;
int main(int ac, char** av) {
auto vnet = create_virtio_net_device("tap0");
interface netif(std::move(vnet));
netif.run();
ipv4 inet(&netif);
inet.set_host_address(ipv4_address(0xc0a87a02));
the_reactor.run();
return 0;
}