Infrastructure for modularizing protocol analyzers.

There's now a new directory "src/protocols/", and the plan is for each
protocol analyzer to eventually have its own subdirectory in there
that contains everything it defines (C++/pac/bif). The infrastructure
to make that happen is in place, and two analyzers have been
converted to the new model, HTTP and SSL; there's no further
HTTP/SSL-specific code anywhere else in the core anymore (I believe :-)

Further changes:

    - -N lists available plugins, -NN lists more details on what these
      plugins provide (analyzers, bif elements). (The latter does not
      work for analyzers that haven't been converted yet).

    - *.bif.bro files now go into scripts/base/bif/; and
      scripts/base/bif/plugins/ for bif files provided by plugins.

    - I've factored out the bifcl/binpac CMake magic from
      src/CMakeLists.txt to cmake/{BifCl,Binpac}

    - There's a new cmake/BroPlugin that contains magic to allow
      plugins to have a simple CMakeLists.txt. The hope is that
      eventually the same CMakeLists.txt can be used for compiling a
      plugin either statically or dynamically.

    - bifcl has a new option -c that changes the code it generates so
      that it can be used with a plugin.

TODOs:
    - "make install" is probably broken.
    - Broxygen is probably broken for plugin-defined events.
    - event groups are broken (do we want to keep them?)
This commit is contained in:
Robin Sommer 2013-03-28 21:47:44 -07:00
parent 2be985433c
commit 19c1816ebb
44 changed files with 974 additions and 663 deletions

View file

@ -5,6 +5,8 @@
#include <list>
#include <string>
#include "Macros.h"
class ODesc;
namespace plugin {
@ -12,10 +14,6 @@ namespace plugin {
class Manager;
class Component;
static const int API_VERSION = 1;
static const int API_BUILTIN = -1;
static const int API_ERROR = -2;
struct Description {
std::string name;
std::string description;
@ -27,9 +25,18 @@ struct Description {
void Describe(ODesc* d);
};
struct BifItem {
// Values must match the integers bifcl generates.
enum Type { FUNCTION = 1, EVENT = 2, CONSTANT = 3, GLOBAL = 4, TYPE = 5 };
std::string id;
Type type;
};
class Plugin {
public:
typedef std::list<Component *> component_list;
typedef std::list<BifItem> bif_item_list;
Plugin();
virtual ~Plugin();
@ -39,6 +46,11 @@ public:
component_list Components();
void InitBif();
// Must be called after InitBif() only.
const bif_item_list& BifItems();
virtual void Init();
virtual void Done();
@ -50,9 +62,17 @@ protected:
*/
void AddComponent(Component* c);
typedef std::list<std::pair<std::string, int> > bif_init_func_result;
typedef bif_init_func_result (*bif_init_func)();
void AddBifInitFunction(bif_init_func c);
private:
typedef std::list<bif_init_func> bif_init_func_list;
plugin::Description description;
component_list components;
bif_item_list bif_items;
bif_init_func_list bif_inits;
};
}