23 #ifndef IPCodecs20160329H 24 #define IPCodecs20160329H 28 #include "goby/acomms/protobuf/network_header.pb.h" 29 #include "goby/util/primitive_types.h" 39 dccl::uint32 pre_encode(
const std::string& field_value);
40 std::string post_decode(
const dccl::uint32& wire_value);
42 dccl::Bitset encode() {
return dccl::Bitset(size(), 0); }
43 dccl::Bitset encode(
const goby::uint32& wire_value) {
return dccl::Bitset(size(), wire_value); }
44 goby::uint32 decode(dccl::Bitset* bits) {
return bits->to<dccl::uint32>(); }
45 unsigned size() {
return 32; }
52 dccl::Bitset encode() {
return dccl::Bitset(size(), 0); }
56 unsigned short val = wire_value & 0xFFFF;
57 unsigned short val_le = ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
58 return dccl::Bitset(size(), val_le);
63 return ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
65 unsigned size() {
return 16; }
70 :
public dccl::TypedFixedFieldCodec<goby::acomms::protobuf::IPv4Header::FlagsFragOffset>
73 dccl::Bitset encode() {
return dccl::Bitset(size(), 0); }
77 unsigned short val = wire_value.fragment_offset() & 0x1FFF;
78 if (wire_value.dont_fragment())
80 if (wire_value.more_fragments())
82 unsigned short val_le = ((val & 0xFF) << 8) | ((val >> 8) & 0xFF);
83 return dccl::Bitset(size(), val_le);
88 unsigned short val = ((val_le & 0xFF) << 8) | ((val_le >> 8) & 0xFF);
90 ret.set_fragment_offset(val & 0x1FFF);
91 ret.set_dont_fragment(val & 0x4000);
92 ret.set_more_fragments(val & 0x2000);
95 unsigned size() {
return 16; }
99 template <
unsigned Id>
103 dccl::Bitset encode() {
return dccl::Bitset(0, 0); }
104 dccl::Bitset encode(
const goby::uint32& wire_value) {
return dccl::Bitset(0, 0); }
106 unsigned size() {
return 0; }
109 uint16_t net_checksum(
const std::string& data);
google::protobuf::uint32 uint32
an unsigned 32 bit integer
The global namespace for the Goby project.