24 #ifndef GOBY_ACOMMS_IP_CODECS_H
25 #define GOBY_ACOMMS_IP_CODECS_H
30 #include <boost/any.hpp>
31 #include <boost/cstdint.hpp>
32 #include <dccl/bitset.h>
33 #include <dccl/exception.h>
34 #include <dccl/field_codec_fixed.h>
46 std::uint32_t pre_encode(
const std::string& field_value)
override;
47 std::string post_decode(
const std::uint32_t& wire_value)
override;
50 dccl::Bitset encode(
const std::uint32_t& wire_value)
override
54 std::uint32_t decode(
dccl::Bitset* bits)
override {
return bits->to<std::uint32_t>(); }
55 unsigned size()
override {
return 32; }
64 dccl::Bitset encode(
const std::uint32_t& wire_value)
override
66 unsigned short val = wire_value & 0xFFFF;
67 unsigned short val_le = ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
72 unsigned short val = bits->to<std::uint32_t>();
73 return ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
75 unsigned size()
override {
return 16; }
80 :
public dccl::TypedFixedFieldCodec<goby::acomms::protobuf::IPv4Header::FlagsFragOffset>
93 unsigned short val_le = ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
98 unsigned short val_le = bits->to<std::uint32_t>();
99 unsigned short val = ((val_le & 0xFF) << 8) | ((val_le >> 8) & 0xFF);
106 unsigned size()
override {
return 16; }
110 template <
unsigned Id>
116 std::uint32_t decode(
dccl::Bitset* )
override {
return Id; }
117 unsigned size()
override {
return 0; }