zeek/src/FileAnalyzer.h
Jon Siwek 0141f51801 FileAnalysis: load custom mime magic database just once.
This works around a bug in libmagic since version 5.12 (current at
time of writing is 5.14) -- second call to magic_load() w/ non-default
database segfaults.
2013-04-29 12:49:22 -05:00

69 lines
1.4 KiB
C++

// Analyzer for connections that transfer binary data.
#ifndef FILEANALYZER_H
#define FILEANALYZER_H
#include "TCP.h"
#include <string>
class File_Analyzer : public TCP_ApplicationAnalyzer {
public:
File_Analyzer(AnalyzerTag::Tag tag, Connection* conn);
virtual void Done();
virtual void DeliverStream(int len, const u_char* data, bool orig);
void Undelivered(int seq, int len, bool orig);
static Analyzer* InstantiateAnalyzer(Connection* conn)
{ return new File_Analyzer(AnalyzerTag::File, conn); }
static bool Available() { return file_transferred; }
protected:
File_Analyzer() {}
void Identify();
static const int BUFFER_SIZE = 1024;
char buffer[BUFFER_SIZE];
int buffer_len;
};
class IRC_Data : public File_Analyzer {
public:
IRC_Data(Connection* conn);
virtual void Done();
virtual void DeliverStream(int len, const u_char* data, bool orig);
void Undelivered(int seq, int len, bool orig);
static Analyzer* InstantiateAnalyzer(Connection* conn)
{ return new IRC_Data(conn); }
static bool Available() { return true; }
};
class FTP_Data : public File_Analyzer {
public:
FTP_Data(Connection* conn);
virtual void Done();
virtual void DeliverStream(int len, const u_char* data, bool orig);
void Undelivered(int seq, int len, bool orig);
static Analyzer* InstantiateAnalyzer(Connection* conn)
{ return new FTP_Data(conn); }
static bool Available() { return true; }
};
#endif