32 return ((
static_cast<uint16_t
>(
hdr_ext_len) + 1u) * 8u);
40 return static_cast<uint8_t
>(
static_cast<uint8_t
>(
last_entry) + 1u);
54 return reinterpret_cast<const uint8_t*
>(
this) + 8u;
58 -> std::span<const uint8_t, 16> {
59 return std::span<const uint8_t, 16>{
91 if (hdr_len < 8u || (hdr_len % 8u) != 0u) {
94 if (packet_remaining_len < hdr_len) {
121 return reinterpret_cast<const uint8_t*
>(
this) +
tlv_offset();
132 -> std::optional<std::span<const uint8_t>> {
148 uint16_t packet_remaining_len)
const noexcept
149 -> std::optional<std::span<const uint8_t, 16>> {
172 : ptr_{ptr}, len_{len}, pos_{0} {}
179 const uint8_t t = ptr_[pos_];
181 out =
SRv6Tlv{t, 0,
nullptr, 1u};
187 if (pos_ + 2u > len_) {
191 const uint8_t len = ptr_[pos_ + 1u];
192 if (
static_cast<uint16_t
>(pos_ + 2u + len) > len_) {
196 out =
SRv6Tlv{t, len, ptr_ + pos_ + 2u,
static_cast<uint16_t
>(2u + len)};
218 constexpr bool d_bit() const noexcept {
223 return ((
autoswap(b) >> 15) & 0x1u) != 0u;
226 constexpr auto key_id() const noexcept -> uint32_t {
234 constexpr auto hmac() const noexcept -> std::span<const uint8_t> {
237 const uint8_t* p =
value + 6u;
238 return std::span<const uint8_t>{p,
static_cast<uint16_t
>(
length - 6u)};
242static_assert(
sizeof(SRv6Header) == 8,
"Wrong SRH header size");
243static_assert(
alignof(SRv6Header) == 1,
"Wrong SRH header alignment");
constexpr SRv6TlvIterator(const uint8_t *ptr, uint16_t len) noexcept
Definition srv6_header.hxx:171
constexpr bool next(SRv6Tlv &out) noexcept
Definition srv6_header.hxx:174
SRv6TlvType
SRv6 Segment Routing Header (SRH) TLV types.
Definition srv6_header.hxx:12
@ Hmac
Definition srv6_header.hxx:12
@ PadN
Definition srv6_header.hxx:12
@ Pad1
Definition srv6_header.hxx:12
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:212
uint8_t length
Definition srv6_header.hxx:214
constexpr bool valid() const noexcept
Definition srv6_header.hxx:216
const uint8_t * value
Definition srv6_header.hxx:213
constexpr bool d_bit() const noexcept
Definition srv6_header.hxx:218
constexpr auto key_id() const noexcept -> uint32_t
Definition srv6_header.hxx:226
constexpr auto hmac() const noexcept -> std::span< const uint8_t >
Definition srv6_header.hxx:234
TLV view returned by the iterator.
Definition srv6_header.hxx:161
uint16_t total_len
Definition srv6_header.hxx:165
uint8_t type
Definition srv6_header.hxx:162
const uint8_t * value
Definition srv6_header.hxx:164
uint8_t length
Definition srv6_header.hxx:163