genode/repos/os/src/server/nic_bridge/nic.h
Stefan Kalkowski a145e6ad70 nic_bridge: transition to the new base API
* use Component::* instead of Server::*
* do not use old printf format anymore
* do not use old Genode::env()->heap() anymore
* avoid pointers where possible, and use references instead
* throw away the thread-safe variants of list and AVL tree,
  nic_bridge became single-threaded in the past
* introduce Ram_session_guard instead of Allocator_guard

Issue #1987
2016-06-28 11:09:23 +02:00

63 lines
1.5 KiB
C++

/*
* \brief Proxy-ARP NIC session handler
* \author Stefan Kalkowski
* \date 2010-08-18
*/
/*
* Copyright (C) 2010-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _SRC__SERVER__NIC_BRIDGE__NIC_H_
#define _SRC__SERVER__NIC_BRIDGE__NIC_H_
#include <nic_session/connection.h>
#include <nic/packet_allocator.h>
#include <packet_handler.h>
namespace Net { class Nic; }
class Net::Nic : public Net::Packet_handler
{
private:
enum {
PACKET_SIZE = ::Nic::Packet_allocator::DEFAULT_PACKET_SIZE,
BUF_SIZE = ::Nic::Session::QUEUE_SIZE * PACKET_SIZE,
};
::Nic::Packet_allocator _tx_block_alloc;
::Nic::Connection _nic;
Ethernet_frame::Mac_address _mac;
public:
Nic(Genode::Entrypoint&, Genode::Heap&, Vlan&);
::Nic::Connection *nic() { return &_nic; }
Ethernet_frame::Mac_address mac() { return _mac; }
bool link_state() { return _nic.link_state(); }
/******************************
** Packet_handler interface **
******************************/
Packet_stream_sink< ::Nic::Session::Policy> * sink() {
return _nic.rx(); }
Packet_stream_source< ::Nic::Session::Policy> * source() {
return _nic.tx(); }
bool handle_arp(Ethernet_frame *eth, Genode::size_t size);
bool handle_ip(Ethernet_frame *eth, Genode::size_t size);
void finalize_packet(Ethernet_frame *eth, Genode::size_t size) {}
};
#endif /* _SRC__SERVER__NIC_BRIDGE__NIC_H_ */