9#include <l4/cxx/minmax>
10#include <l4/l4virtio/server/virtio>
14#include "virtio_net.h"
15#include "virtio_net_buffer.h"
24 return id > 0U &&
id < 0xfffU;
43 : _tci{tci}, _mac_remaining{12}, _tag_remaining{tag_remaining}
53 : _tci{0}, _mac_remaining{0}, _tag_remaining{0}
102 else if (_mac_remaining)
105 ret = src.
copy_to(&dst, _mac_remaining);
106 _mac_remaining -= ret;
108 else if (_tag_remaining > 0)
118 memcpy(dst.
pos, &tag[4 - _tag_remaining], ret);
120 _tag_remaining -= (int)ret;
122 else if (_tag_remaining < 0)
125 _tag_remaining +=
static_cast<int>(src.
skip(-_tag_remaining));
144 if (
L4_UNLIKELY(_tci != 0 && hdr->flags.need_csum()))
147 hdr->csum_start -= 4U;
149 hdr->csum_start += 4U;
Class for VLAN packet rewriting.
static constexpr Virtio_vlan_mangle remove()
Construct an object that removes the VLAN tag.
void rewrite_hdr(Virtio_net::Hdr *hdr)
Rewrite the virtio network header.
Virtio_vlan_mangle()
Default constructor.
static constexpr Virtio_vlan_mangle add(l4_uint16_t tci)
Construct an object that adds a VLAN tag.
l4_uint32_t copy_pkt(Buffer &dst, Buffer &src)
Copy packet from src to dst.
unsigned char l4_uint8_t
Unsigned 8bit value.
signed char l4_int8_t
Signed 8bit value.
unsigned int l4_uint32_t
Unsigned 32bit value.
unsigned short int l4_uint16_t
Unsigned 16bit value.
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
#define L4_LIKELY(x)
Expression is likely to execute.
Common L4 ABI Data Types.
Data buffer used to transfer packets.
l4_uint32_t copy_to(Data_buffer *dst, l4_uint32_t max=UINT_MAX)
Copy contents from this buffer to the destination buffer.
l4_uint32_t left
Bytes left in buffer.
char * pos
Current buffer position.
l4_uint32_t skip(l4_uint32_t bytes)
Skip given number of bytes in this buffer.