Hi all,
Attached patch applies appropriate changes to use AggregateIPFlows in
userlevel as well as Click kernel module. I'll be bringing most AggregateX
elements over so let me know if anyone is interested in those patches as
well.
Cheers
Beyers
diff -Naur a/click/elements/analysis/aggregateipflows.cc b/click/elements/analysis/aggregateipflows.cc
--- a/click/elements/analysis/aggregateipflows.cc 2007-09-10 07:37:22.000000000 +0200
+++ b/click/elements/analysis/aggregateipflows.cc 2007-10-01 23:42:54.000000000 +0200
@@ -67,7 +67,9 @@
// actual AggregateIPFlows operations
AggregateIPFlows::AggregateIPFlows()
- : _traceinfo_file(0), _packet_source(0), _filepos_h(0)
+#if CLICK_USERLEVEL
+ : _packet_source(0), _traceinfo_file(0), _filepos_h(0)
+#endif
{
}
@@ -105,9 +107,11 @@
"FRAGMENT_TIMEOUT", 0, cpSeconds, &_fragment_timeout,
"REAP", 0, cpSeconds, &_gc_interval,
"ICMP", 0, cpBool, &handle_icmp_errors,
- "TRACEINFO", 0, cpFilename, &_traceinfo_filename,
- "SOURCE", 0, cpElement, &_packet_source,
"FRAGMENTS", cpkC, &gave_fragments, cpBool, &fragments,
+#if CLICK_USERLEVEL
+ "TRACEINFO", 0, cpFilename, &_traceinfo_filename,
+ "SOURCE", 0, cpElement, &_packet_source,
+#endif
cpEnd) < 0)
return -1;
@@ -126,6 +130,7 @@
_active_sec = _gc_sec = 0;
_timestamp_warning = false;
+#if CLICK_USERLEVEL
if (_traceinfo_filename == "-")
_traceinfo_file = stdout;
else if (_traceinfo_filename && !(_traceinfo_file = fopen(_traceinfo_filename.c_str(), "w")))
@@ -140,7 +145,7 @@
}
fprintf(_traceinfo_file, ">\n");
}
-
+#endif
if (_fragments == 2)
_fragments = !input_is_pull(0);
else if (_fragments == 1 && input_is_pull(0))
@@ -154,16 +159,19 @@
{
clean_map(_tcp_map);
clean_map(_udp_map);
+#if CLICK_USERLEVEL
if (_traceinfo_file && _traceinfo_file != stdout) {
fprintf(_traceinfo_file, "</trace>\n");
fclose(_traceinfo_file);
}
delete _filepos_h;
+#endif
}
inline void
AggregateIPFlows::delete_flowinfo(const HostPair &hp, FlowInfo *finfo, bool really_delete)
{
+#if CLICK_USERLEVEL
if (_traceinfo_file) {
StatFlowInfo *sinfo = static_cast<StatFlowInfo *>(finfo);
IPAddress src(sinfo->reverse() ? hp.b : hp.a);
@@ -186,6 +194,7 @@
if (really_delete)
delete sinfo;
} else
+#endif
if (really_delete)
delete finfo;
}
@@ -207,6 +216,7 @@
}
}
+#if CLICK_USERLEVEL
void
AggregateIPFlows::stat_new_flow_hook(const Packet *p, FlowInfo *finfo)
{
@@ -216,6 +226,7 @@
if (_filepos_h)
(void) cp_integer(_filepos_h->call_read().trim_space(), &sinfo->_filepos);
}
+#endif
inline void
AggregateIPFlows::packet_emit_hook(const Packet *p, const click_ip *iph, FlowInfo *finfo)
@@ -235,11 +246,13 @@
finfo->_flow_over = 0;
}
+#if CLICK_USERLEVEL
// count packets
if (stats() && PAINT_ANNO(p) < 2) {
StatFlowInfo *sinfo = static_cast<StatFlowInfo *>(finfo);
sinfo->_packets[PAINT_ANNO(p)]++;
}
+#endif
}
void
@@ -410,8 +423,10 @@
_next++;
finfo->_reverse = flipped;
finfo->_flow_over = 0;
+#if CLICK_USERLEVEL
if (stats())
stat_new_flow_hook(p, finfo);
+#endif
notify(finfo->aggregate(), AggregateListener::NEW_AGG, p);
}
@@ -424,10 +439,12 @@
// make and install new FlowInfo pair
FlowInfo *finfo;
- if (stats()) {
+#if CLICK_USERLEVEL
+ if (stats()) {
finfo = new StatFlowInfo(ports, hpinfo->_flows, _next);
stat_new_flow_hook(p, finfo);
} else
+#endif
finfo = new FlowInfo(ports, hpinfo->_flows, _next);
finfo->_reverse = flipped;
@@ -591,7 +608,7 @@
add_write_handler("clear", write_handler, (void *)H_CLEAR);
}
-ELEMENT_REQUIRES(userlevel AggregateNotifier)
+ELEMENT_REQUIRES(AggregateNotifier)
EXPORT_ELEMENT(AggregateIPFlows)
#include <click/hashmap.cc>
CLICK_ENDDECLS
diff -Naur a/click/elements/analysis/aggregateipflows.hh b/click/elements/analysis/aggregateipflows.hh
--- a/click/elements/analysis/aggregateipflows.hh 2007-08-14 03:49:05.000000000 +0200
+++ b/click/elements/analysis/aggregateipflows.hh 2007-10-01 20:22:39.000000000 +0200
@@ -66,7 +66,7 @@
=item TRACEINFO
Filename. If provided, output information about each flow to that filename in
-an XML format.
+an XML format. Only available in userlevel.
=item SOURCE
@@ -74,7 +74,7 @@
'C<packet_filepos>' read handlers will be recorded in the TRACEINFO dump. (It
is not an error if the element doesn't have those handlers.) The
'C<packet_filepos>' results may be particularly useful, since a reader can use
-those results to skip ahead through a trace file.
+those results to skip ahead through a trace file. Only available in userlevel.
=item TCP_TIMEOUT
@@ -158,7 +158,9 @@
void add_handlers();
void cleanup(CleanupStage);
+#if CLICK_USERLEVEL
bool stats() const { return _traceinfo_file; }
+#endif
void push(int, Packet *);
Packet *pull(int);
@@ -189,12 +191,14 @@
bool reverse() const { return _reverse; }
};
+#if CLICK_USERLEVEL
struct StatFlowInfo : public FlowInfo {
Timestamp _first_timestamp;
uint32_t _filepos;
uint32_t _packets[2];
StatFlowInfo(uint32_t ports, FlowInfo *next, uint32_t agg) : FlowInfo(ports, next, agg) { _packets[0] = _packets[1] = 0; }
};
+#endif
struct HostPairInfo {
FlowInfo *_flows;
@@ -224,11 +228,13 @@
unsigned _fragments : 2;
bool _timestamp_warning : 1;
+#if CLICK_USERLEVEL
+ Element *_packet_source;
FILE *_traceinfo_file;
String _traceinfo_filename;
-
- Element *_packet_source;
+
HandlerCall *_filepos_h;
+#endif
static const click_ip *icmp_encapsulated_header(const Packet *);
@@ -237,7 +243,9 @@
void reap();
inline int relevant_timeout(const FlowInfo *, const Map &) const;
+#if CLICK_USERLEVEL
void stat_new_flow_hook(const Packet *, FlowInfo *);
+#endif
inline void packet_emit_hook(const Packet *, const click_ip *, FlowInfo *);
inline void delete_flowinfo(const HostPair &, FlowInfo *, bool really_delete = true);
void assign_aggregate(Map &, HostPairInfo *, int emit_before_sec);
diff -Naur a/click/elements/analysis/aggregatenotifier.cc b/click/elements/analysis/aggregatenotifier.cc
--- a/click/elements/analysis/aggregatenotifier.cc 2004-07-07 18:04:59.000000000 +0200
+++ b/click/elements/analysis/aggregatenotifier.cc 2007-10-01 20:23:30.000000000 +0200
@@ -29,5 +29,4 @@
}
CLICK_ENDDECLS
-ELEMENT_REQUIRES(userlevel)
ELEMENT_PROVIDES(AggregateNotifier)
_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click