author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 4571 | 2c9c600270e0 |
permissions | -rw-r--r-- |
4571
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
*/ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
/** |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
* This is the test code for ipv4-l3-protocol.cc |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
*/ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
#ifdef RUN_SELF_TESTS |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
#include "ns3/simulator.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
#include "ns3/test.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#include "ns3/log.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
#include "ns3/inet-socket-address.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
#include "ns3/node.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
#include "ipv4-l3-protocol.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
#include "arp-l3-protocol.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
#include "ipv4-interface.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
#include "loopback-net-device.h" |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
namespace ns3 { |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
class Ipv4L3ProtocolTest: public Test |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
{ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
public: |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
virtual bool RunTests (void); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
Ipv4L3ProtocolTest (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
}; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
Ipv4L3ProtocolTest::Ipv4L3ProtocolTest () |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
: Test ("Ipv4L3Protocol") |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
{ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
} |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
bool |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
Ipv4L3ProtocolTest::RunTests (void) |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
{ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
bool result = true; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
Ptr<Node> node = CreateObject<Node> (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
Ptr<Ipv4Interface> interface = CreateObject<Ipv4Interface> (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
Ptr<LoopbackNetDevice> device = CreateObject<LoopbackNetDevice> (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
node->AddDevice (device); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
interface->SetDevice (device); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
interface->SetNode (node); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
uint32_t index = ipv4->AddIpv4Interface (interface); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
NS_TEST_ASSERT_EQUAL (index, 0); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
interface->SetUp (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
Ipv4InterfaceAddress ifaceAddr1 = Ipv4InterfaceAddress ("192.168.0.1", "255.255.255.0"); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
interface->AddAddress (ifaceAddr1); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
Ipv4InterfaceAddress ifaceAddr2 = Ipv4InterfaceAddress ("192.168.0.2", "255.255.255.0"); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
interface->AddAddress (ifaceAddr2); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
Ipv4InterfaceAddress ifaceAddr3 = Ipv4InterfaceAddress ("10.30.0.1", "255.255.255.0"); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
interface->AddAddress (ifaceAddr3); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
Ipv4InterfaceAddress ifaceAddr4 = Ipv4InterfaceAddress ("250.0.0.1", "255.255.255.0"); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
interface->AddAddress (ifaceAddr4); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
uint32_t num = interface->GetNAddresses (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
NS_TEST_ASSERT_EQUAL (num, 4); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
74 |
interface->RemoveAddress (2); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
75 |
num = interface->GetNAddresses (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
76 |
NS_TEST_ASSERT_EQUAL (num, 3); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
Ipv4InterfaceAddress output = interface->GetAddress (2); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
NS_TEST_ASSERT_EQUAL (ifaceAddr4, output); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
79 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
80 |
return result; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
81 |
} |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
83 |
static Ipv4L3ProtocolTest gIpv4L3ProtocolTest; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
84 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
85 |
}; // namespace ns3 |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
86 |
|
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
#endif /* RUN_SELF_TESTS */ |