80221Bundle: added static const etherType member to MIHPacketType
[senf.git] / senf / Packets / 80221Bundle / TLVParser.hh
index 5faf9eb..0fd0a71 100644 (file)
 #define HH_SENF_Packets_80221Bundle_TLVParser_ 1
 
 // Custom includes
-#include <algorithm>
 #include <senf/Packets/Packets.hh>
 #include "MIHTypes.hh"
 
 //#include "TLVParser.mpp"
-///////////////////////////////hh.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 
 namespace senf {
 
@@ -42,6 +41,12 @@ namespace senf {
           : senf::Exception("MIHTLVLengthException") {}
     };
 
+    struct InvalidMIHPacketException : public senf::Exception
+    {
+        InvalidMIHPacketException(std::string const & description)
+            : senf::Exception("Invalid MIH message: ") { append(description); }
+    };
+
 
     class MIHTLVLengthParser
         : public detail::packet::IntParserOps<MIHTLVLengthParser, boost::uint32_t>,
@@ -128,6 +133,9 @@ namespace senf {
             \param v maximum value of length field
          */
         void maxLength(MIHTLVLengthParser::value_type maxl) const;
+
+        void validateType(boost::uint8_t type) const;
+        void validateTypeLength(boost::uint8_t type, MIHTLVLengthParser::value_type length) const;
     };
 
 
@@ -192,7 +200,7 @@ namespace senf {
 
     public:
         ///\name Value setters
-        ///@{
+        //\{
         void value( MIHFId const & id);
 
         void value( std::string        const & id  );
@@ -200,10 +208,10 @@ namespace senf {
         void value( senf::INet4Address const & addr);
         void value( senf::INet6Address const & addr);
         void value( senf::EUI64        const & addr);
-        ///@}
+        //\}
 
         ///\name Value getters
-        ///@{
+        //\{
         MIHFId valueAs( MIHFId::Type type) const;
 
         std::string        valueAsString()       const;
@@ -211,10 +219,10 @@ namespace senf {
         senf::INet4Address valueAsINet4Address() const;
         senf::INet6Address valueAsINet6Address() const;
         senf::EUI64        valueAsEUI64()        const;
-        ///@}
+        //\}
 
         ///\name Value comparisons
-        ///@{
+        //\{
         bool valueEquals( MIHFId const & id) const;
 
         bool valueEquals( std::string        const & id  ) const;
@@ -222,7 +230,7 @@ namespace senf {
         bool valueEquals( senf::INet4Address const & addr) const;
         bool valueEquals( senf::INet6Address const & addr) const;
         bool valueEquals( senf::EUI64        const & addr) const;
-        ///@}
+        //\}
 
         void dump(std::ostream & os) const;
         void maxIdLength(boost::uint8_t maxl) const;
@@ -293,6 +301,7 @@ namespace senf {
         }
         static type_t::value_type const typeId = 1;
         void dump(std::ostream & os) const;
+        void validate() const;
     };
 
     /** \brief Parser for 802.21 destination MIHF_ID TLV
@@ -307,6 +316,7 @@ namespace senf {
         }
         static type_t::value_type const typeId = 2;
         void dump(std::ostream & os) const;
+        void validate() const;
     };
 
     /** \brief Parser for 802.21 Status TLV
@@ -325,6 +335,7 @@ namespace senf {
         }
         static type_t::value_type const typeId = 3;
         void dump(std::ostream & os) const; ///< dump string representation to given stream
+        void validate() const;
 
         enum StatusCode {
             Success, UnspecifiedFailure, Rejected, AuthorizationFailure, NetworkError };
@@ -344,6 +355,7 @@ namespace senf {
         }
         static type_t::value_type const typeId = 11;
         void dump(std::ostream & os) const; ///< dump string representation to given stream
+        void validate() const;
 
         enum RequestCode { Registration, ReRegistration };
     };
@@ -362,12 +374,13 @@ namespace senf {
         }
         static type_t::value_type const typeId = 12;
         void dump(std::ostream & os) const; ///< dump string representation to given stream
+        void validate() const;
     };
 
 }
 
 
-///////////////////////////////hh.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 #include "TLVParser.cci"
 #include "TLVParser.ct"
 #include "TLVParser.cti"