const PegInfo norm_names[] =
{
- { "ip4.trim", "eth packets trimmed to datagram size" },
- { "ip4.tos", "type of service normalizations" },
- { "ip4.df", "don't frag bit normalizations" },
- { "ip4.rf", "reserved flag bit clears" },
- { "ip4.ttl", "time-to-live normalizations" },
- { "ip4.opts", "ip4 options cleared" },
- { "icmp4.echo", "icmp4 ping normalizations" },
- { "ip6.ttl", "ip6 hop limit normalizations" },
- { "ip6.opts", "ip6 options cleared" },
- { "icmp6.echo", "icmp6 echo normalizations" },
- { "tcp.syn_opt", "SYN only options cleared from non-SYN packets" },
- { "tcp.ts_ecr", "timestamp cleared on non-ACKs" },
- { "tcp.opt", "packetw with options cleared" },
- { "tcp.pad", "packetw with padding cleared" },
- { "tcp.rsv", "packets with reserved bits cleared" },
- { "tcp.ecn_pkt", "packets with ECN bits cleared" },
- { "tcp.ns", "packets with nonce bit cleared" },
- { "tcp.urg", "packets with urgent flag with urgent pointer cleared" },
- { "tcp.urp", "packets without data with urgent poniter cleared" },
+ { "ip4 trim", "eth packets trimmed to datagram size" },
+ { "ip4 tos", "type of service normalizations" },
+ { "ip4 df", "don't frag bit normalizations" },
+ { "ip4 rf", "reserved flag bit clears" },
+ { "ip4 ttl", "time-to-live normalizations" },
+ { "ip4 opts", "ip4 options cleared" },
+ { "icmp4 echo", "icmp4 ping normalizations" },
+ { "ip6 hops", "ip6 hop limit normalizations" },
+ { "ip6 options", "ip6 options cleared" },
+ { "icmp6 echo", "icmp6 echo normalizations" },
+ { "tcp syn options", "SYN only options cleared from non-SYN packets" },
+ { "tcp ts ecr", "timestamp cleared on non-ACKs" },
+ { "tcp options", "packets with options cleared" },
+ { "tcp paddding", "packets with padding cleared" },
+ { "tcp reserved", "packets with reserved bits cleared" },
+ { "tcp ecn pkt", "packets with ECN bits cleared" },
+ { "tcp nonce", "packets with nonce bit cleared" },
+ { "tcp urgent flag", "packets without urgent flag with urgent pointer cleared" },
+ { "tcp urgent ptr", "packets without data with urgent poniter cleared" },
{ nullptr, nullptr }
};
static THREAD_LOCAL PegCount normStats[PC_MAX];
-static PegCount gnormStats[PC_MAX];
//static int Norm_Eth(Packet*, uint8_t layer, int changes);
static int Norm_IP4(NormalizerConfig*, Packet*, uint8_t layer, int changes);
//-----------------------------------------------------------------------
-void Norm_SumStats (void)
-{
- sum_stats((PegCount*)&gnormStats, (PegCount*)&normStats, array_size(norm_names));
- Stream_SumNormalizationStats();
-}
-
-// need to output the label heading only if not already done
-// the label is emitted only if any counts are non-zero
-// FIXIT-L would prefer to hide this logic in the stats methods somehow
-static bool labeled()
-{
- unsigned i = 0, max = array_size(norm_names);
-
- while ( i < max && !gnormStats[i] )
- ++i;
-
- return ( i < max );
-}
-
-void Norm_PrintStats (const char* name)
-{
- show_stats((PegCount*)&gnormStats, norm_names, array_size(norm_names), name);
-
- if ( labeled() )
- name = nullptr;
-
- Stream_PrintNormalizationStats(name);
-}
+const PegInfo* Norm_GetPegs()
+{ return norm_names; }
-void Norm_ResetStats (void)
+PegCount* Norm_GetCounts(unsigned& c)
{
- memset(gnormStats, 0, sizeof(gnormStats));
- Stream_ResetNormalizationStats();
+ c = PC_MAX;
+ return normStats;
}
//-----------------------------------------------------------------------
/*
-** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ ** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
** Copyright (C) 2010-2013 Sourcefire, Inc.
**
** This program is free software; you can redistribute it and/or modify
#include <string.h>
#include <string>
#include <sstream>
+#include <vector>
+
+#include "stream/stream.h"
using namespace std;
return true;
}
-void NormalizeModule::sum_stats()
-{ Norm_SumStats(); }
+const PegInfo* NormalizeModule::get_pegs() const
+{
+ static vector<PegInfo> pegs;
+ pegs.clear();
+
+ const PegInfo* p = Norm_GetPegs();
+
+ while ( p && p->name )
+ pegs.push_back(*p++);
+
+ p = Stream_GetNormPegs();
+
+ while ( p && p->name )
+ pegs.push_back(*p++);
+
+ return &pegs[0];
+}
+
+PegCount* NormalizeModule::get_counts() const
+{
+ static vector<PegCount> counts;
+ counts.clear();
+ unsigned c = 0;
+
+ PegCount* p = Norm_GetCounts(c);
-void NormalizeModule::show_stats()
-{ Norm_PrintStats(get_name()); }
+ for ( unsigned i = 0; i < c; ++i )
+ counts.push_back(p[i]);
-void NormalizeModule::reset_stats()
-{ Norm_ResetStats(); }
+ p = Stream_GetNormCounts(c);
+
+ for ( unsigned i = 0; i < c; ++i )
+ counts.push_back(p[i]);
+
+ return &counts[0];
+}
PC_MAX
} PegCounts;
-static PegCount gnormStats[PC_MAX];
static THREAD_LOCAL PegCount normStats[PC_MAX];
static const PegInfo pegName[] =
{
- { "tcp.trim", "tcp segments trimmed to correct size" },
- { "tcp.ecn_ssn", "ECN bits cleared" },
- { "tcp.ts_nop", "timestamp options cleared" },
- { "tcp.ips_data", "normalized segments" },
- { "tcp.block", "blocked segments" },
+ { "tcp trim", "tcp segments trimmed to correct size" },
+ { "tcp ecn session", "ECN bits cleared" },
+ { "tcp ts nop", "timestamp options cleared" },
+ { "tcp ips data", "normalized segments" },
+ { "tcp block", "blocked segments" },
{ nullptr, nullptr }
};
-void Stream_SumNormalizationStats()
-{
- sum_stats((PegCount*)&gnormStats, (PegCount*)&normStats, array_size(pegName));
-}
-
-void Stream_PrintNormalizationStats (const char* name)
-{
- show_stats((PegCount*)&gnormStats, pegName, PC_MAX, name);
-}
+const PegInfo* Stream_GetNormPegs()
+{ return pegName; }
-void Stream_ResetNormalizationStats (void)
-{
- memset(gnormStats, 0, sizeof(gnormStats));
+PegCount* Stream_GetNormCounts(unsigned& c)
+{
+ c = PC_MAX;
+ return normStats;
}
//-----------------------------------------------------------------------