2013-03-28 10:03:23 +00:00
|
|
|
/*
|
|
|
|
* \brief Interface to create statistic about received and transmitted
|
|
|
|
* packets of NIC components
|
|
|
|
* \author Alexander Boettcher
|
|
|
|
* \date 2013-03-26
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2013-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 _INCLUDE__NIC__STAT_H_
|
|
|
|
#define _INCLUDE__NIC__STAT_H_
|
|
|
|
|
|
|
|
#include <base/stdint.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
|
|
|
#include <timer_session/connection.h>
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Nic { class Measurement; }
|
2013-03-28 10:03:23 +00:00
|
|
|
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
class Nic::Measurement
|
|
|
|
{
|
|
|
|
private:
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
Timer::Connection &_timer;
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
Net::Ethernet_frame::Mac_address _mac;
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
struct stat
|
|
|
|
{
|
|
|
|
Genode::uint64_t size;
|
|
|
|
unsigned long count;
|
|
|
|
} _stat, _drop;
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
Genode::addr_t _timestamp;
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
enum status {
|
|
|
|
FOR_US,
|
|
|
|
IS_MAGIC,
|
|
|
|
UNKNOWN
|
|
|
|
};
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
enum status _check(Net::Ethernet_frame *, Genode::size_t);
|
|
|
|
public:
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
Measurement(Timer::Connection &timer)
|
|
|
|
:
|
|
|
|
_timer(timer), _timestamp(0)
|
|
|
|
{
|
|
|
|
_stat.size = _stat.count = _drop.size = _drop.count = 0;
|
|
|
|
}
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
void set_mac(void * mac)
|
|
|
|
{
|
|
|
|
Genode::memcpy(_mac.addr, mac, 6);
|
|
|
|
}
|
2013-03-28 10:03:23 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
void data(Net::Ethernet_frame *, Genode::size_t);
|
|
|
|
};
|
2013-03-28 10:03:23 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__NIC__STAT_H_ */
|