X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2F80221Bundle%2FTLVParser.hh;h=c8b49ada7f6ac702edf9509a65bc9a762a4c421e;hb=4a99bad0289a65567e85cb51bd357a34562b2c04;hp=1ee9bfa0f7f46cae64b6f35507dfb8d80af3fea8;hpb=f723d7852a8195072eee387ea9ca77156b58438b;p=senf.git diff --git a/senf/Packets/80221Bundle/TLVParser.hh b/senf/Packets/80221Bundle/TLVParser.hh index 1ee9bfa..c8b49ad 100644 --- a/senf/Packets/80221Bundle/TLVParser.hh +++ b/senf/Packets/80221Bundle/TLVParser.hh @@ -127,8 +127,10 @@ namespace senf { the current length value. */ void finalizeLength() { - protect(), length_().finalize(); + protect(), length_().finalize(); }; + + typedef GenericTLVParserRegistry Registry; protected: /// resize the packet after the length field to given size @@ -161,12 +163,12 @@ namespace senf { \note you must call mihfIdPacket.maxLengthValue( 253) *before* setting longer MIHF_IDs values. */ - class MIHFId_TLVParser : public MIHBaseTLVParser + class MIHFIdTLVParser : public MIHBaseTLVParser { # include SENF_PARSER() SENF_PARSER_INHERIT ( MIHBaseTLVParser ); SENF_PARSER_SKIP ( length(), 0 ); - SENF_PARSER_FINALIZE ( MIHFId_TLVParser ); + SENF_PARSER_FINALIZE ( MIHFIdTLVParser ); public: std::string asString() const; @@ -186,6 +188,8 @@ namespace senf { MIHFId valueAs(MIHFId::Type type) const; + void dump(std::ostream & os) const; + private: template struct binaryNAIEncoder { @@ -215,6 +219,85 @@ namespace senf { } }; + struct MIHFSrcIdTLVParser : public MIHFIdTLVParser + { + MIHFSrcIdTLVParser(data_iterator i, state_type s) : MIHFIdTLVParser(i,s) {} + + void init() const { + defaultInit(); + type() << typeId+0; + } + static type_t::value_type const typeId = 1; + + void dump(std::ostream & os) const; + }; + + struct MIHFDstIdTLVParser : public MIHFIdTLVParser + { + MIHFDstIdTLVParser(data_iterator i, state_type s) : MIHFIdTLVParser(i,s) {} + + void init() const { + defaultInit(); + type() << typeId+0; + } + static type_t::value_type const typeId = 2; + + void dump(std::ostream & os) const; + }; + + /** \brief Parser for 802.21 Status TLV + */ + struct MIHStatusTLVParser : public MIHBaseTLVParser + { + # include SENF_PARSER() + SENF_PARSER_INHERIT ( MIHBaseTLVParser ); + SENF_PARSER_FIELD ( value, UInt8Parser ); + SENF_PARSER_FINALIZE( MIHStatusTLVParser ); + SENF_PARSER_INIT() { + defaultInit(); + type() << typeId+0; + length_() = 1; + } + static type_t::value_type const typeId = 3; + void dump(std::ostream & os) const; ///< dump string representation to given stream + + enum StatusCode { + Success, UnspecifiedFailure, Rejected, AuthorizationFailure, NetworkError }; + }; + + struct MIHRegisterReqCodeTLVParser : public MIHBaseTLVParser + { + # include SENF_PARSER() + SENF_PARSER_INHERIT ( MIHBaseTLVParser ); + SENF_PARSER_FIELD ( value, UInt8Parser ); + SENF_PARSER_FINALIZE ( MIHRegisterReqCodeTLVParser ); + + SENF_PARSER_INIT() { + defaultInit(); + type() = typeId+0; + length_() = 1; + } + static type_t::value_type const typeId = 11; + void dump(std::ostream & os) const; ///< dump string representation to given stream + + enum RequestCode { Registration, ReRegistration }; + }; + + struct MIHValidTimeIntervalTLVParser : public MIHBaseTLVParser + { + # include SENF_PARSER() + SENF_PARSER_INHERIT ( MIHBaseTLVParser ); + SENF_PARSER_FIELD ( value, UInt32Parser ); + SENF_PARSER_FINALIZE ( MIHValidTimeIntervalTLVParser ); + + SENF_PARSER_INIT() { + defaultInit(); + type() = typeId+0; + length_() = 4; + } + static type_t::value_type const typeId = 12; + void dump(std::ostream & os) const; ///< dump string representation to given stream + }; }