}
+prefix_ void senf::MIHPacketType::finalize(packet p)
+{
+ p->source_length() << senf::bytes( p->source_mihf_id());
+ p->destination_length() << senf::bytes( p->destination_mihf_id());
+ p->payloadLength_() << p.size() - 8;
+}
+
#undef prefix_
source_type() = 1;
destination_type() = 2;
}
+
+ friend class MIHPacketType;
};
using mixin::initSize;
static void dump(packet p, std::ostream &os);
-// static void finalize(packet p);
+ static void finalize(packet p);
};
typedef ConcretePacket<MIHPacketType> MIHPacket;
}
-prefix_ void senf::BaseTLVPacketParser:: maxLengthValue(DynamicTLVLengthParser::value_type v)
- const
+prefix_ void senf::DynamicTLVLengthParser:: maxValue(DynamicTLVLengthParser::value_type v)
{
if (v <= 127)
return;
- size_type b = senf::bytes( length_());
+ size_type b = bytes();
if (v <= UInt8Parser::max_value) {
- if (b < 2) length_().resize(2);
+ if (b < 2) resize(2);
return;
}
if (v <= UInt16Parser::max_value) {
- if (b < 3) length_().resize(3);
+ if (b < 3) resize(3);
return;
}
if (v <= UInt24Parser::max_value) {
- if (b < 4) length_().resize(4);
+ if (b < 4) resize(4);
return;
}
- if (b < 5) length_().resize(5);
+ if (b < 5) resize(5);
}
SENF_PARSER_PRIVATE_BITFIELD ( extended_length_flag, 1, bool );
SENF_PARSER_PRIVATE_BITFIELD ( fixed_length_field, 7, unsigned );
- void resize(size_type size);
void shrink();
+ void maxValue(DynamicTLVLengthParser::value_type v);
+ private:
+ void resize(size_type size);
};
SENF_PARSER_FIELD_RO ( length, DynamicTLVLengthParser );
SENF_PARSER_FINALIZE ( BaseTLVPacketParser );
- void maxLengthValue(DynamicTLVLengthParser::value_type v) const;
- void shrinkLength() { length_().shrink(); };
+ void maxLengthValue(DynamicTLVLengthParser::value_type v) const {
+ length_().maxValue(v);
+ }
+ void shrinkLength() {
+ length_().shrink();
+ };
protected:
size_type length_bytes() const { return length_().bytes(); };
struct TestMacAddressTLVPacketParser : public BaseTLVPacketParser
{
# include SENF_PARSER()
- SENF_PARSER_INHERIT ( BaseTLVPacketParser )
- SENF_PARSER_VECTOR ( value, bytes(length), senf::MACAddressParser )
+ SENF_PARSER_INHERIT ( BaseTLVPacketParser );
+ SENF_PARSER_VECTOR ( value, bytes(length), senf::MACAddressParser );
SENF_PARSER_FINALIZE( TestMacAddressTLVPacketParser );
};