File: CTrafStatsEntry.h

package info (click to toggle)
trafstats 0.4.20-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 296 kB
  • ctags: 110
  • sloc: cpp: 1,036; sh: 475; perl: 173; makefile: 98
file content (47 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download
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
#ifndef CTRAFSTATS_H
  #define CTRAFSTATS_H

#include <netinet/in.h>
#include <list.h>
#include <string>
class CTrafStatsList;
class CTrafStatsEntry {
friend class CTrafStatsList;
public:
	CTrafStatsEntry(	const struct in_addr source,
				int sport,
				const struct in_addr destination,
				int dport,
				char *timestamp,
				unsigned long amount);
	CTrafStatsEntry(const CTrafStatsEntry& copy);
	~CTrafStatsEntry();

	void print();
	struct in_addr source() const { return iSource; };
	struct in_addr destination() const { return iDestination; };
	int sport() const { return iSport; };
	int dport() const { return iDport; };
	char *timestamp() const { return iTimestamp; };
	unsigned long amount() const { return iAmount; };
	bool matches(const CTrafStatsEntry& match);
	CTrafStatsEntry& operator+=(const CTrafStatsEntry& addee);
	bool operator<(const CTrafStatsEntry& match);
	
	std::string asString() const;
	std::string asQuery() const;

private:

	struct in_addr iSource,iDestination;
	int iSport,iDport;
	unsigned long iAmount;
	char *iTimestamp;

};

inline CTrafStatsEntry& operator+(	const CTrafStatsEntry& lhs,
				const CTrafStatsEntry& rhs) 
		{return CTrafStatsEntry(lhs) += rhs;};

#endif