Move include files in debian packge into 'senf' subdirectory
[senf.git] / Packets / DefaultBundle / IpV6Packet.test.cc
1 // Copyright (C) 2007
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief IpV6Packet unit tests */
23
24 //#include "IpV6Packet.test.hh"
25 //#include "IpV6Packet.test.ih"
26
27 // Custom includes
28 #include "IpV6Packet.hh"
29 #include "../../Socket/Protocols/INet/INetAddressing.hh"
30 #include "../../Packets/DataPacket.hh"
31
32 #include <boost/test/auto_unit_test.hpp>
33 #include <boost/test/test_tools.hpp>
34
35 #define prefix_
36 ///////////////////////////////cc.p////////////////////////////////////////
37
38 BOOST_AUTO_UNIT_TEST(ipV6Packet_packet)
39 {
40     unsigned char data[] = { 0x60, 0x12, 0x20, 0x30,
41                              0x01, 0x02, 0x03, 0x04,
42                              0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
43                              0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
44                              0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
45                              0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
46                              0xff };
47
48     senf::IpV6Packet p (senf::IpV6Packet::create(data));
49
50
51     BOOST_CHECK_EQUAL( p->version(),       0x06u      );
52     BOOST_CHECK_EQUAL( p->trafficClass(),  0x01u      );
53     BOOST_CHECK_EQUAL( p->flowLabel(),     0x22030u   );
54     BOOST_CHECK_EQUAL( p->length(),        0x0102u    );
55     BOOST_CHECK_EQUAL( p->nextHeader(),    0x03u      );
56     BOOST_CHECK_EQUAL( p->hopLimit(),      0x04u      );
57     BOOST_CHECK_EQUAL( p->source().value(),
58                        senf::INet6Address::from_string("1011:1213:1415:1617:1819:1a1b:1c1d:1e1f") );
59     BOOST_CHECK_EQUAL( p->destination().value(),
60                        senf::INet6Address::from_string("2021:2223:2425:2627:2829:2a2b:2c2d:2e2f") );
61
62     BOOST_CHECK( p.next() );
63     BOOST_CHECK( p.next().is<senf::DataPacket>() );
64     BOOST_CHECK_EQUAL( p.next().size(), 1u );
65 }
66
67 ///////////////////////////////cc.e////////////////////////////////////////
68 #undef prefix_
69
70 \f
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // c-file-style: "senf"
75 // indent-tabs-mode: nil
76 // ispell-local-dictionary: "american"
77 // compile-command: "scons -u test"
78 // comment-column: 40
79 // End: