/
sflow_generator.h
51 lines (40 loc) · 1.4 KB
/
sflow_generator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
*/
#ifndef __SFLOW_GENERATOR_H__
#define __SFLOW_GENERATOR_H__
#include "base/queue_task.h"
#include "db_handler.h"
class SFlowCollector;
struct SFlowQueueEntry {
SFlowQueueEntry(boost::asio::const_buffer buf, size_t len,
uint64_t timestamp, SFlowCollector* collector);
~SFlowQueueEntry();
boost::asio::const_buffer buffer;
size_t length;
uint64_t timestamp;
SFlowCollector* const sflow_collector;
};
class SFlowGenerator {
public:
explicit SFlowGenerator(const std::string& ip_address,
SFlowCollector* sflow_collector,
DbHandlerPtr db_handler);
~SFlowGenerator();
bool EnqueueSFlowPacket(const boost::asio::const_buffer& buffer,
size_t length, uint64_t timestamp);
private:
bool ProcessSFlowPacket(boost::shared_ptr<SFlowQueueEntry>);
typedef WorkQueue<boost::shared_ptr<SFlowQueueEntry> > SFlowPktQueue;
std::string ip_address_;
SFlowCollector* const sflow_collector_;
DbHandlerPtr db_handler_;
SFlowPktQueue sflow_pkt_queue_;
SandeshTraceBufferPtr trace_buf_;
uint64_t num_packets_;
uint64_t num_invalid_packets_;
uint64_t time_first_pkt_seen_;
uint64_t time_last_pkt_seen_;
DISALLOW_COPY_AND_ASSIGN(SFlowGenerator);
};
#endif // __SFLOW_GENERATOR_H__