10 #include <unordered_map>
12 #include <tins/tins.h>
15 #include "object_set.hpp"
22 Host(
const Tins::ARP::hwaddress_type hw,
const Tins::IPv4Address ip)
26 bool operator == (
const Host& other)
const {
31 const Tins::ARP::hwaddress_type hw;
32 const Tins::IPv4Address ip;
39 size_t operator()(
const Host& host)
const {
41 boost::hash_combine<std::string>(seed, host.hw.to_string());
42 boost::hash_combine<uint32_t>(seed, host.ip);
51 HostFlows(
const Host& host) : _host(host), _bytes_in(0), _bytes_out(0) {}
54 _flows.push_back(summary);
57 void remove_flow(
const Flow& flow) {
58 for (
auto flow_summary = _flows.begin(); flow_summary != _flows.end(); flow_summary++) {
59 if ((*flow_summary)->flow() == flow) {
60 _flows.erase(flow_summary);
66 void update_host_stats(
const Flow& flow,
size_t bytes) {
67 if (flow.src_ip == _host.ip && flow.src_hw == _host.hw)
73 const Host& host()
const {
return _host; }
74 const std::vector<const FlowCounter*>& flows()
const {
return _flows; }
75 size_t bytes_in()
const {
return _bytes_in; }
76 size_t bytes_out()
const {
return _bytes_out; }
80 std::vector<const FlowCounter*> _flows;
representation of a packet flow
Definition: flow.hpp:22
counts bytes associated with a Flow
Definition: flow.hpp:74
IP and hardware address for a network host.
Definition: host.hpp:21