refactored MPESection (deleted DSMCCSection & DatagramSection); crc calculation doesn...
[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 "../../Utils/auto_unit_test.hh"
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     BOOST_CHECK_EQUAL( p->version(),       0x06u      );
51     BOOST_CHECK_EQUAL( p->trafficClass(),  0x01u      );
52     BOOST_CHECK_EQUAL( p->flowLabel(),     0x22030u   );
53     BOOST_CHECK_EQUAL( p->length(),        0x0102u    );
54     BOOST_CHECK_EQUAL( p->nextHeader(),    0x03u      );
55     BOOST_CHECK_EQUAL( p->hopLimit(),      0x04u      );
56     BOOST_CHECK_EQUAL( p->source().value(),
57                        senf::INet6Address::from_string("1011:1213:1415:1617:1819:1a1b:1c1d:1e1f") );
58     BOOST_CHECK_EQUAL( p->destination().value(),
59                        senf::INet6Address::from_string("2021:2223:2425:2627:2829:2a2b:2c2d:2e2f") );
60
61     BOOST_CHECK( p.next() );
62     BOOST_CHECK( p.next().is<senf::DataPacket>() );
63     BOOST_CHECK_EQUAL( p.next().size(), 1u );
64 }
65
66 ///////////////////////////////cc.e////////////////////////////////////////
67 #undef prefix_
68
69 \f
70 // Local Variables:
71 // mode: c++
72 // fill-column: 100
73 // c-file-style: "senf"
74 // indent-tabs-mode: nil
75 // ispell-local-dictionary: "american"
76 // compile-command: "scons -u test"
77 // comment-column: 40
78 // End: