From bdecbc7f62e5be4c356621c15fd3eca01b849047 Mon Sep 17 00:00:00 2001
From: tho <tho@wiback.org>
Date: Mon, 12 Jan 2009 12:08:40 +0000
Subject: [PATCH] minor fixes

---
 Packets/80221Bundle/MIHPacket.cc      |  2 +-
 Packets/80221Bundle/MIHPacket.hh      | 17 +++++++++++++----
 Packets/80221Bundle/MIHPacket.test.cc | 21 ++++++++++++++++++++-
 Packets/80221Bundle/TLVPacket.cc      |  7 +++----
 Packets/AuxParser.hh                  |  2 +-
 Packets/Mainpage.dox                  |  1 +
 6 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/Packets/80221Bundle/MIHPacket.cc b/Packets/80221Bundle/MIHPacket.cc
index ce0e08606..97407c2c6 100644
--- a/Packets/80221Bundle/MIHPacket.cc
+++ b/Packets/80221Bundle/MIHPacket.cc
@@ -37,7 +37,7 @@ prefix_ void senf::MIHPacketType::dump(packet p, std::ostream &os)
 {
     boost::io::ios_all_saver ias(os);
     os << "MIH Packet:\n"
-       << "  protocol header:\n" << "\n"
+       << "  protocol header:\n"
        << "    Version:         " << unsigned( p->version()) << "\n"
        << "    Ack-Request:     " << p->ackRequest() << "\n"
        << "    Ack-Response:    " << p->ackResponse() << "\n"
diff --git a/Packets/80221Bundle/MIHPacket.hh b/Packets/80221Bundle/MIHPacket.hh
index 2c1da37ae..a67f0a6b4 100644
--- a/Packets/80221Bundle/MIHPacket.hh
+++ b/Packets/80221Bundle/MIHPacket.hh
@@ -35,14 +35,14 @@
 
 namespace senf {
 
-    struct MIHF_IdParser : public senf::PacketParserBase
+    struct MIHF_IdParser : public PacketParserBase
     {
-    #   include SENF_FIXED_PARSER()        
+    #   include SENF_PARSER()        
                 
         SENF_PARSER_FINALIZE ( MIHF_IdParser );
     };
 
-    struct MIHPacketParser : public senf::PacketParserBase
+    struct MIHPacketParser : public PacketParserBase
     {
     #   include SENF_PARSER()
         
@@ -84,7 +84,16 @@ namespace senf {
         friend class MIHPacketType;
     };
     
-    
+    /** \brief MIH packet
+
+        \par Packet type (typedef):
+            \ref MIHPacket
+
+        \par Fields:
+            \ref MIHPacketParser
+        
+        \ingroup protocolbundle_80221
+     */
     struct MIHPacketType
         : public PacketTypeBase,
           public PacketTypeMixin<MIHPacketType>
diff --git a/Packets/80221Bundle/MIHPacket.test.cc b/Packets/80221Bundle/MIHPacket.test.cc
index 9edeabe82..e0c9583d3 100644
--- a/Packets/80221Bundle/MIHPacket.test.cc
+++ b/Packets/80221Bundle/MIHPacket.test.cc
@@ -30,12 +30,31 @@
 #include <boost/test/test_tools.hpp>
 
 #include "MIHPacket.hh"
+#include "senf/Utils/hexdump.hh"
 
+using namespace senf;
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
-
+BOOST_AUTO_UNIT_TEST(MIHPacket_create)
+{
+    MIHPacket mihPacket (MIHPacket::create());
+    // set some fields
+    mihPacket->fragmentNr() = 42;
+    mihPacket->transactionId() = 21;
+    mihPacket.finalizeThis();
+    
+//    mihPacket.dump(std::cout);
+//    senf::hexdump(mihPacket.data().begin(), mihPacket.data().end(), std::cout);
+    
+    unsigned char data[] = { 
+            0x10, 0x54, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04,
+            0x01, 0x00,
+            0x02, 0x00
+    };
+    BOOST_CHECK( equal( mihPacket.data().begin(), mihPacket.data().end(), data ));
+}
 
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
diff --git a/Packets/80221Bundle/TLVPacket.cc b/Packets/80221Bundle/TLVPacket.cc
index f79d84b58..3bf20396d 100644
--- a/Packets/80221Bundle/TLVPacket.cc
+++ b/Packets/80221Bundle/TLVPacket.cc
@@ -163,11 +163,10 @@ prefix_ void senf::DynamicTLVLengthParser::resize(size_type size)
     size_type current_size (bytes());
     SafePacketParserWrapper<DynamicTLVLengthParser> safeThis (*this);
     
-    safe_data_iterator si (data(), i());
     if (current_size > size)
-        data().erase( si, boost::next(si, current_size-size));
+        data().erase( i(), boost::next(i(), current_size-size));
     else
-        data().insert( si, size-current_size, 0);
+        data().insert( i(), size-current_size, 0);
     
     if (size > 1) {
         safeThis->extended_length_flag() = true;
@@ -175,7 +174,7 @@ prefix_ void senf::DynamicTLVLengthParser::resize(size_type size)
     } else {
         safeThis->extended_length_flag() = false;
     }
-    value(v);
+    safeThis->value(v);
 }
 
 
diff --git a/Packets/AuxParser.hh b/Packets/AuxParser.hh
index c76926c4b..412bb2d76 100644
--- a/Packets/AuxParser.hh
+++ b/Packets/AuxParser.hh
@@ -122,7 +122,7 @@ namespace detail {
 
     /** \brief Internal: Apply transformation to arbitrary aux-parser policy
 
-        Transform must statisfy the interface
+        Transform must satisfy the interface
         \code
         struct Transform
         {
diff --git a/Packets/Mainpage.dox b/Packets/Mainpage.dox
index 7482b9f1d..8847a5c14 100644
--- a/Packets/Mainpage.dox
+++ b/Packets/Mainpage.dox
@@ -67,6 +67,7 @@
     \li \ref protocolbundle_default : Some basic default protocols: Ethernet, Ip, TCP, UDP
     \li \ref protocolbundle_mpegdvb : MPEG and DVB protocols
     \li \ref protocolbundle_80211 : 802.11 protocols
+    \li \ref protocolbundle_80221 : 802.21 protocols
 
     There are two ways to link with a bundle
     
-- 
GitLab