10#include "virtio_net.h" 
   11#include "virtio_net_buffer.h" 
   14#include <l4/l4virtio/server/virtio> 
   41  void const *
req_id()
 const { 
return _req_id; }
 
   46  virtual void copy_header(Virtio_net::Hdr *dst_header) 
const = 0;
 
 
   78    if (!_pkt.
pos || _pkt.
left < 14)
 
   81    uint8_t *p = 
reinterpret_cast<uint8_t *
>(_pkt.
pos);
 
   82    return p[12] == 0x81U && p[13] == 0x00U;
 
   85  uint16_t vlan_id()
 const 
   87    if (!has_vlan() || _pkt.left < 16)
 
   88      return VLAN_ID_NATIVE;
 
   90    uint8_t *p = 
reinterpret_cast<uint8_t *
>(_pkt.pos);
 
   91    return (uint16_t{p[14]} << 8 | p[15]) & 0xfffU;
 
  105  uint8_t 
const *buffer(
size_t *size)
 const 
  108    return reinterpret_cast<uint8_t 
const *
>(_pkt.pos);
 
  111  void dump_pkt()
 const 
  113    Dbg pkt_debug(Dbg::Packet, Dbg::Debug, 
"PKT");
 
  114    if (pkt_debug.is_active())
 
  122        Dbg pkt_trace(Dbg::Packet, Dbg::Trace, 
"PKT");
 
  123        if (pkt_trace.is_active() && _pkt.left >= 14)
 
  125            uint8_t 
const *packet = 
reinterpret_cast<uint8_t 
const *
>(_pkt.pos);
 
  126            pkt_trace.cprintf(
"\n\tEthertype: ");
 
  127            uint16_t ether_type = uint16_t{packet[12]} << 8 | packet[13];
 
  128            char const *protocol;
 
  131              case 0x0800: protocol = 
"IPv4"; 
break;
 
  132              case 0x0806: protocol = 
"ARP"; 
break;
 
  133              case 0x8100: protocol = 
"Vlan"; 
break;
 
  134              case 0x86dd: protocol = 
"IPv6"; 
break;
 
  135              case 0x8863: protocol = 
"PPPoE Discovery"; 
break;
 
  136              case 0x8864: protocol = 
"PPPoE Session"; 
break;
 
  137              default: protocol = 
nullptr;
 
  140              pkt_trace.cprintf(
"%s\n", protocol);
 
  142              pkt_trace.cprintf(
"%04x\n", ether_type);
 
A network request to only a single destination.
 
virtual void copy_header(Virtio_net::Hdr *dst_header) const =0
Populate the virtio-net header for the destination.
 
void const * req_id() const
Identifier for the underlying Net_request, used for logging purposes.
 
virtual bool done()=0
Check whether the transfer has been completed, i.e.
 
Buffer & cur_buf()
Buffer containing (a part of) the packet data.
 
Data buffer used to transfer packets.
 
l4_uint32_t left
Bytes left in buffer.
 
char * pos
Current buffer position.