commit
e1145d70b2
|
@ -1588,7 +1588,7 @@ static int sctp_reconnect(ipfix_receiving_collector *collector){
|
|||
switch (snp.sn_header.sn_type) {
|
||||
case SCTP_ASSOC_CHANGE:
|
||||
sac = &snp.sn_assoc_change;
|
||||
if (!sac->sac_state==SCTP_COMM_UP) {
|
||||
if (sac->sac_state!=SCTP_COMM_UP) {
|
||||
msg(MSG_ERROR, "%sSCTP connection setup failed. "
|
||||
"Received unexpected SCTP_ASSOC_CHANGE notification with state %d",
|
||||
vrf_log, sac->sac_state);
|
||||
|
|
|
@ -65,7 +65,7 @@ int CfgBase::getInt(const std::string& name, int def, XMLElement* elem)
|
|||
std::string str;
|
||||
try {
|
||||
str = _get(name, elem);
|
||||
int res = strtol(str.c_str(), NULL, 10);
|
||||
long res = strtol(str.c_str(), NULL, 10);
|
||||
if (res==LONG_MIN || res==LONG_MAX) {
|
||||
THROWEXCEPTION("failed to read integer %s in element %s in configuration (is it too large? or invalid?)", str.c_str(), name.c_str());
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ Edge* Graph::addEdge(Node* n1, Node* n2)
|
|||
|
||||
void Graph::removeEdge(Node* n1, Node* n2)
|
||||
{
|
||||
if (matrix[n1->getID()][n2->getID()] < 0)
|
||||
if (matrix[n1->getID()][n2->getID()] == NULL)
|
||||
throw std::runtime_error("No edge between the nodes");
|
||||
|
||||
Edge *e = matrix[n1->getID()][n2->getID()];
|
||||
|
|
|
@ -89,7 +89,7 @@ XMLDocument* XMLDocument::parse_file(const std::string& fileName)
|
|||
|
||||
if(ctx->errNo) {
|
||||
exceptionMsg = "Can't parse the file; libxml inidicates error "
|
||||
+ ctx->errNo;
|
||||
+ std::to_string(ctx->errNo);
|
||||
goto free;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ private:
|
|||
XMLDocument(xmlDocPtr doc);
|
||||
|
||||
xmlDocPtr xmlDocument;
|
||||
xmlNodePtr xmlRootNode;
|
||||
|
||||
struct Initializer {
|
||||
Initializer();
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
InstanceManager<Host> HostStatistics::hostManager("Host");
|
||||
|
||||
HostStatistics::HostStatistics(std::string ipSubnet, std::string addrFilter, std::string logPath, uint16_t logInt)
|
||||
: ipSubnet(ipSubnet), addrFilter(addrFilter), logPath(logPath), logInt(logInt)
|
||||
HostStatistics::HostStatistics(std::string ipSubnet, std::string addrFilter, std::string logPath)
|
||||
: ipSubnet(ipSubnet), addrFilter(addrFilter), logPath(logPath)
|
||||
{
|
||||
// check if srcIP or dstIP in the subnet (1.1.1.1/16)
|
||||
// split string at the '/'
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
class HostStatistics : public IpfixRecordDestination, public Module, public Source<NullEmitable*>
|
||||
{
|
||||
public:
|
||||
HostStatistics(std::string ipSubnet, std::string addrFilter, std::string logPath, uint16_t logInt);
|
||||
HostStatistics(std::string ipSubnet, std::string addrFilter, std::string logPath);
|
||||
virtual ~HostStatistics();
|
||||
void onDataRecord(IpfixDataRecord* record);
|
||||
|
||||
|
@ -44,7 +44,6 @@ private:
|
|||
std::string ipSubnet;
|
||||
std::string addrFilter;
|
||||
std::string logPath;
|
||||
uint16_t logInt;
|
||||
uint32_t netAddr;
|
||||
uint8_t netSize;
|
||||
time_t logTimer;
|
||||
|
|
|
@ -27,7 +27,6 @@ HostStatisticsCfg::HostStatisticsCfg(XMLElement* elem) : CfgHelper<HostStatistic
|
|||
ipSubnet = get("subnet");
|
||||
addrFilter = get("addrFilter");
|
||||
logPath = get("logPath");
|
||||
logInt = (uint16_t)getInt("logInterval", 10);
|
||||
} catch(IllegalEntry ie) {
|
||||
THROWEXCEPTION("Illegal hostStatistics entry in config file");
|
||||
}
|
||||
|
@ -48,7 +47,7 @@ HostStatisticsCfg* HostStatisticsCfg::create(XMLElement* e)
|
|||
HostStatistics* HostStatisticsCfg::createInstance()
|
||||
{
|
||||
if (!instance) {
|
||||
instance = new HostStatistics(ipSubnet, addrFilter, logPath, logInt);
|
||||
instance = new HostStatistics(ipSubnet, addrFilter, logPath);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -43,13 +43,11 @@ protected:
|
|||
std::string getSubnet() { return ipSubnet; }
|
||||
std::string getAddrFilter() { return addrFilter; }
|
||||
std::string getLogPath() { return logPath; }
|
||||
uint16_t getLogIntervall() { return logInt; }
|
||||
|
||||
private:
|
||||
std::string ipSubnet;
|
||||
std::string addrFilter;
|
||||
std::string logPath;
|
||||
uint16_t logInt;
|
||||
};
|
||||
|
||||
#endif /* HOSTSTATISTICSCFG_H_ */
|
||||
|
|
|
@ -110,8 +110,9 @@ char ** get_filenames(const char * directory, int * num_of_files) {
|
|||
while ( pDirEnt != NULL ) {
|
||||
/* Skip hidden entries starting with dot */
|
||||
if( pDirEnt->d_name[0] != '.' ) {
|
||||
int fileNameSize = snprintf(filename, sizeof(filename), "%s/%s", directory, pDirEnt->d_name);
|
||||
/* Skip non-regular files (e.g. directories) */
|
||||
if ( (snprintf(filename, sizeof(filename), "%s/%s", directory, pDirEnt->d_name) < sizeof(filename))
|
||||
if ( ((fileNameSize < (int)sizeof(filename)) && (fileNameSize > 0))
|
||||
&& (stat(filename, &dirEntStat) == 0) && (S_ISREG(dirEntStat.st_mode)) ) {
|
||||
//printf( "FOUND: %s\n", pDirEnt->d_name );
|
||||
filecounter++;
|
||||
|
@ -139,8 +140,9 @@ char ** get_filenames(const char * directory, int * num_of_files) {
|
|||
//printf( "%s\n", pDirEnt->d_name );
|
||||
/* Skip hidden entries starting with dot */
|
||||
if( pDirEnt->d_name[0] != '.' ) {
|
||||
/* Skip non-regular files (e.g. directories) */
|
||||
if ( (snprintf(filename, sizeof(filename), "%s/%s", directory, pDirEnt->d_name) < sizeof(filename))
|
||||
int fileNameSize = snprintf(filename, sizeof(filename), "%s/%s", directory, pDirEnt->d_name);
|
||||
/* Skip non-regular files (e.g. directories) */
|
||||
if ( ((fileNameSize < (int)sizeof(filename)) && (fileNameSize > 0))
|
||||
&& (stat(filename, &dirEntStat) == 0) && (S_ISREG(dirEntStat.st_mode)) ) {
|
||||
snprintf(filenames[i], MAX_SIZE_OF_FILENAME-1, "%s", pDirEnt->d_name);
|
||||
//printf( "ADDED: %s\n", filenames[i] );
|
||||
|
|
|
@ -18,9 +18,9 @@ InstanceManager<IDMEFMessage> PacketIDMEFReporter::idmefManager("ReporterIDMEFMe
|
|||
|
||||
|
||||
|
||||
PacketIDMEFReporter::PacketIDMEFReporter(string idmeftemplate, string analyzerid, uint16_t snapshotoff, uint16_t snapshotlen)
|
||||
PacketIDMEFReporter::PacketIDMEFReporter(string idmeftemplate, string analyzerid, uint16_t snapshotlen)
|
||||
: analyzerId(analyzerid), idmefTemplate(idmeftemplate),
|
||||
snapshotOffset(snapshotoff), snapshotLength(snapshotlen)
|
||||
snapshotLength(snapshotlen)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
static const char* PAR_SNAPSHOT;
|
||||
|
||||
|
||||
PacketIDMEFReporter(string idmeftemplate, string analyzerid, uint16_t snapshotoff, uint16_t snapshotlen);
|
||||
PacketIDMEFReporter(string idmeftemplate, string analyzerid, uint16_t snapshotlen);
|
||||
virtual ~PacketIDMEFReporter();
|
||||
|
||||
virtual void receive(Packet* p);
|
||||
|
@ -35,7 +35,6 @@ public:
|
|||
private:
|
||||
string analyzerId; /**< analyzer id for IDMEF messages */
|
||||
string idmefTemplate; /**< template file for IDMEF messages */
|
||||
uint16_t snapshotOffset; /**< offset from start of payload where snapshot is taken */
|
||||
uint16_t snapshotLength; /**< length of snapshot */
|
||||
char snapshotBuffer[3000]; /**< buffer for holding hexdump of snapshot */
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ PacketIDMEFReporterCfg* PacketIDMEFReporterCfg::create(XMLElement* e)
|
|||
|
||||
PacketIDMEFReporterCfg::PacketIDMEFReporterCfg(XMLElement* elem)
|
||||
: CfgHelper<PacketIDMEFReporter, PacketIDMEFReporterCfg>(elem, "packetIdmefReporter"),
|
||||
snapshotOffset(0), snapshotLength(0)
|
||||
snapshotLength(0)
|
||||
{
|
||||
if (!elem) return;
|
||||
|
||||
|
@ -22,9 +22,7 @@ PacketIDMEFReporterCfg::PacketIDMEFReporterCfg(XMLElement* elem)
|
|||
it++) {
|
||||
XMLElement* e = *it;
|
||||
|
||||
if (e->matches("snapshotoffset")) {
|
||||
snapshotOffset = getInt("snapshotoffset");
|
||||
} else if (e->matches("snapshotlength")) {
|
||||
if (e->matches("snapshotlength")) {
|
||||
snapshotLength = getInt("snapshotlength");
|
||||
} else if (e->matches("analyzerid")) {
|
||||
analyzerId = e->getFirstText();
|
||||
|
@ -46,7 +44,7 @@ PacketIDMEFReporterCfg::~PacketIDMEFReporterCfg()
|
|||
|
||||
PacketIDMEFReporter* PacketIDMEFReporterCfg::createInstance()
|
||||
{
|
||||
instance = new PacketIDMEFReporter(idmefTemplate, analyzerId, snapshotOffset, snapshotLength);
|
||||
instance = new PacketIDMEFReporter(idmefTemplate, analyzerId, snapshotLength);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ protected:
|
|||
|
||||
string analyzerId; /**< analyzer id for IDMEF messages */
|
||||
string idmefTemplate; /**< template file for IDMEF messages */
|
||||
uint16_t snapshotOffset; /**< offset from start of payload where snapshot is taken */
|
||||
uint16_t snapshotLength; /**< length of snapshot */
|
||||
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
IpfixCollectorCfg::IpfixCollectorCfg(XMLElement* elem)
|
||||
: CfgHelper<IpfixCollector, IpfixCollectorCfg>(elem, "ipfixCollector"),
|
||||
listener(NULL),
|
||||
ipfixCollector(NULL)
|
||||
listener(NULL)
|
||||
{
|
||||
if (!elem)
|
||||
return;
|
||||
|
|
|
@ -53,7 +53,6 @@ private:
|
|||
std::string caPath;
|
||||
|
||||
|
||||
IpfixCollector* ipfixCollector;
|
||||
|
||||
int32_t udpTemplateLifetime;
|
||||
};
|
||||
|
|
|
@ -68,7 +68,6 @@ class IpfixCsExporter : public Module, public Source<NullEmitable*>, public Ipfi
|
|||
FILE *currentFile;
|
||||
char currentFilename[512];
|
||||
char currentTmpname[512];
|
||||
uint16_t globalIterator;
|
||||
uint32_t maxFileSize; /**< maximum filesize in KiB, i.e. maximumFilesize * 1024 == maximum filesize in bytes */
|
||||
uint32_t maxChunkBufferTime; /**< maximum Chunk Buffer Time (in seconds) */
|
||||
uint32_t maxChunkBufferRecords; /**< maximum Chunk Buffer Records (in records) */
|
||||
|
|
|
@ -50,8 +50,6 @@ class IpfixFileWriter : public IpfixSender
|
|||
private:
|
||||
std::string filenamePrefix;
|
||||
std::string destinationPath;
|
||||
//maximum filesize in KiB, i.e. maximumFilesize * 1024 == maximum filesize in bytes
|
||||
uint32_t maximumFilesize;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,6 @@ private:
|
|||
bool ignore_timestamps;
|
||||
float stretchTime;
|
||||
uint16_t stretchTimeInt;
|
||||
int fh;
|
||||
std::ifstream packetFile;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
IpfixReceiverFileCfg::IpfixReceiverFileCfg(XMLElement* elem)
|
||||
: CfgHelper<IpfixCollector,IpfixReceiverFileCfg>(elem, "ipfixReceiverFile"),
|
||||
ipfixCollector(NULL),
|
||||
packetFileBasename("ipfix.dump"),
|
||||
packetFileDirectory("./"),
|
||||
c_from(0),
|
||||
|
|
|
@ -39,8 +39,6 @@ public:
|
|||
bool deriveFrom(IpfixReceiverFileCfg* old);
|
||||
|
||||
private:
|
||||
IpfixCollector* ipfixCollector;
|
||||
uint16_t observationDomainId;
|
||||
std::string packetFileBasename;
|
||||
std::string packetFileDirectory;
|
||||
int c_from;
|
||||
|
|
|
@ -41,9 +41,8 @@
|
|||
* Does SCTP/IPv4 specific initialization.
|
||||
* @param port Port to listen on
|
||||
*/
|
||||
IpfixReceiverSctpIpV4::IpfixReceiverSctpIpV4(int port, std::string ipAddr, uint32_t buffer,
|
||||
unsigned int moduleId)
|
||||
: statReceivedPackets(0), moduleId(moduleId)
|
||||
IpfixReceiverSctpIpV4::IpfixReceiverSctpIpV4(int port, std::string ipAddr, uint32_t buffer)
|
||||
: statReceivedPackets(0)
|
||||
{
|
||||
receiverPort = port;
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@
|
|||
class IpfixReceiverSctpIpV4 : public IpfixReceiver, Sensor {
|
||||
#ifdef SUPPORT_SCTP
|
||||
public:
|
||||
IpfixReceiverSctpIpV4(int port, std::string ipAddr = "", uint32_t buffer = 0,
|
||||
unsigned int moduleId = 0);
|
||||
IpfixReceiverSctpIpV4(int port, std::string ipAddr = "", uint32_t buffer = 0);
|
||||
virtual ~IpfixReceiverSctpIpV4();
|
||||
|
||||
virtual void run();
|
||||
|
@ -51,7 +50,6 @@ class IpfixReceiverSctpIpV4 : public IpfixReceiver, Sensor {
|
|||
private:
|
||||
int listen_socket;
|
||||
uint32_t statReceivedPackets; /**< number of received packets */
|
||||
unsigned int moduleId;
|
||||
#else
|
||||
public:
|
||||
IpfixReceiverSctpIpV4(int port, std::string ipAddr, uint32_t buffer = 0) {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
IpfixReceiverTcpIpV4::IpfixReceiverTcpIpV4(int port, std::string ipAddr,
|
||||
const uint32_t buffer, unsigned int moduleId)
|
||||
: statReceivedMessages(0), moduleId(moduleId)
|
||||
: statReceivedMessages(0)
|
||||
{
|
||||
receiverPort = port;
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ class IpfixReceiverTcpIpV4 : public IpfixReceiver, Sensor {
|
|||
private:
|
||||
int listen_socket;
|
||||
uint32_t statReceivedMessages; /**< number of received messages */
|
||||
unsigned int moduleId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@ using namespace std;
|
|||
*/
|
||||
IpfixReceiverUdpIpV4::IpfixReceiverUdpIpV4(int port, std::string ipAddr,
|
||||
const uint32_t buffer, unsigned int moduleId)
|
||||
: statReceivedPackets(0), moduleId(moduleId)
|
||||
: statReceivedPackets(0)
|
||||
{
|
||||
receiverPort = port;
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ class IpfixReceiverUdpIpV4 : public IpfixReceiver, Sensor {
|
|||
private:
|
||||
int listen_socket;
|
||||
uint32_t statReceivedPackets; /**< number of received packets */
|
||||
unsigned int moduleId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -119,7 +119,7 @@ PSAMPExporterModule* PSAMPExporterCfg::createInstance()
|
|||
}
|
||||
msg(MSG_DEBUG, "%sPsampExporter: adding collector %s://%s:%d on VRF %s",
|
||||
vrf_log,
|
||||
collectors[i]->getProtocol()==132?"SCTP":"UDP",
|
||||
collectors[i]->getProtocol()==ipfix_transport_protocol::SCTP?"SCTP":"UDP",
|
||||
collectors[i]->getIpAddress().c_str(),
|
||||
collectors[i]->getPort(),
|
||||
collectors[i]->getVrfName().c_str());
|
||||
|
|
Loading…
Reference in New Issue