31 return ((
static_cast<uint16_t
>(
hdr_ext_len) + 1u) * 8u);
39 return static_cast<uint8_t
>(
static_cast<uint8_t
>(
last_entry) + 1u);
53 return reinterpret_cast<const uint8_t*
>(
this) + 8u;
57 -> std::span<const uint8_t, 16> {
58 return std::span<const uint8_t, 16>{
79 return reinterpret_cast<const uint8_t*
>(
this) +
tlv_offset();
95 : ptr_{ptr}, len_{len}, pos_{0} {}
102 const uint8_t t = ptr_[pos_];
104 out =
SRv6Tlv{t, 0,
nullptr, 1u};
110 if (pos_ + 2u > len_) {
114 const uint8_t len = ptr_[pos_ + 1u];
115 if (
static_cast<uint16_t
>(pos_ + 2u + len) > len_) {
119 out =
SRv6Tlv{t, len, ptr_ + pos_ + 2u,
static_cast<uint16_t
>(2u + len)};
141 constexpr bool d_bit() const noexcept {
146 return ((
autoswap(b) >> 15) & 0x1u) != 0u;
149 constexpr auto key_id() const noexcept -> uint32_t {
157 constexpr auto hmac() const noexcept -> std::span<const uint8_t> {
160 const uint8_t* p =
value + 6u;
161 return std::span<const uint8_t>{p,
static_cast<uint16_t
>(
length - 6u)};
165static_assert(
sizeof(SRv6Header) == 8,
"Wrong SRH header size");
166static_assert(
alignof(SRv6Header) == 1,
"Wrong SRH header alignment");
constexpr SRv6TlvIterator(const uint8_t *ptr, uint16_t len) noexcept
Definition srv6_header.hxx:94
constexpr bool next(SRv6Tlv &out) noexcept
Definition srv6_header.hxx:97
SRv6TlvType
SRv6 Segment Routing Header (SRH) TLV types.
Definition srv6_header.hxx:11
@ Hmac
Definition srv6_header.hxx:11
@ PadN
Definition srv6_header.hxx:11
@ Pad1
Definition srv6_header.hxx:11
constexpr _Tp read_from_bytes(const uint8_t *src)
Read a trivially copyable type from a byte array.
Definition utils.hxx:24
constexpr _Tp autoswap(_Tp tp)
Byte-swap a value if the host is little-endian.
Definition utils.hxx:13
HMAC TLV view for type==5 (HMAC). The 'value' pointer is the TLV variable data where the first two by...
Definition srv6_header.hxx:135
uint8_t length
Definition srv6_header.hxx:137
constexpr bool valid() const noexcept
Definition srv6_header.hxx:139
const uint8_t * value
Definition srv6_header.hxx:136
constexpr bool d_bit() const noexcept
Definition srv6_header.hxx:141
constexpr auto key_id() const noexcept -> uint32_t
Definition srv6_header.hxx:149
constexpr auto hmac() const noexcept -> std::span< const uint8_t >
Definition srv6_header.hxx:157
TLV view returned by the iterator.
Definition srv6_header.hxx:84
uint16_t total_len
Definition srv6_header.hxx:88
uint8_t type
Definition srv6_header.hxx:85
const uint8_t * value
Definition srv6_header.hxx:87
uint8_t length
Definition srv6_header.hxx:86