mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
|
@ -7,8 +7,7 @@
|
|||
|
||||
#include "zeek/plugin/Component.h"
|
||||
|
||||
namespace zeek::iosource
|
||||
{
|
||||
namespace zeek::iosource {
|
||||
|
||||
class IOSource;
|
||||
class PktSrc;
|
||||
|
@ -17,113 +16,109 @@ class PktDumper;
|
|||
/**
|
||||
* Component description for plugins providing IOSources.
|
||||
*/
|
||||
class Component : public plugin::Component
|
||||
{
|
||||
class Component : public plugin::Component {
|
||||
public:
|
||||
using factory_callback = IOSource* (*)();
|
||||
using factory_callback = IOSource* (*)();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param name A descriptive name for the component. This name must
|
||||
* be unique across all components of this type.
|
||||
*/
|
||||
explicit Component(const std::string& name);
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param name A descriptive name for the component. This name must
|
||||
* be unique across all components of this type.
|
||||
*/
|
||||
explicit Component(const std::string& name);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~Component() override = default;
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~Component() override = default;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor to use by derived classes.
|
||||
*
|
||||
* @param type The type of the component.
|
||||
*
|
||||
* @param name A descriptive name for the component. This name must
|
||||
* be unique across all components of this type.
|
||||
*/
|
||||
Component(plugin::component::Type type, const std::string& name);
|
||||
};
|
||||
/**
|
||||
* Constructor to use by derived classes.
|
||||
*
|
||||
* @param type The type of the component.
|
||||
*
|
||||
* @param name A descriptive name for the component. This name must
|
||||
* be unique across all components of this type.
|
||||
*/
|
||||
Component(plugin::component::Type type, const std::string& name);
|
||||
};
|
||||
|
||||
/**
|
||||
* Component description for plugins providing a PktSrc for packet input.
|
||||
*/
|
||||
class PktSrcComponent : public Component
|
||||
{
|
||||
class PktSrcComponent : public Component {
|
||||
public:
|
||||
/**
|
||||
* Type of input a packet source supports.
|
||||
*/
|
||||
enum InputType
|
||||
{
|
||||
LIVE, ///< Live input.
|
||||
TRACE, ///< Offline input from trace file.
|
||||
BOTH ///< Live input as well as offline.
|
||||
};
|
||||
/**
|
||||
* Type of input a packet source supports.
|
||||
*/
|
||||
enum InputType {
|
||||
LIVE, ///< Live input.
|
||||
TRACE, ///< Offline input from trace file.
|
||||
BOTH ///< Live input as well as offline.
|
||||
};
|
||||
|
||||
using factory_callback = PktSrc* (*)(const std::string& path, bool is_live);
|
||||
using factory_callback = PktSrc* (*)(const std::string& path, bool is_live);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param name A descriptive name for the component. This name must
|
||||
* be unique across all components of this type.
|
||||
*
|
||||
* @param prefixes The list of interface/file prefixes associated
|
||||
* with this component.
|
||||
*
|
||||
* @param type Type of input the component supports.
|
||||
*
|
||||
* @param factor Factory function to instantiate component.
|
||||
*/
|
||||
PktSrcComponent(const std::string& name, const std::string& prefixes, InputType type,
|
||||
factory_callback factory);
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param name A descriptive name for the component. This name must
|
||||
* be unique across all components of this type.
|
||||
*
|
||||
* @param prefixes The list of interface/file prefixes associated
|
||||
* with this component.
|
||||
*
|
||||
* @param type Type of input the component supports.
|
||||
*
|
||||
* @param factor Factory function to instantiate component.
|
||||
*/
|
||||
PktSrcComponent(const std::string& name, const std::string& prefixes, InputType type, factory_callback factory);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~PktSrcComponent() override = default;
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~PktSrcComponent() override = default;
|
||||
|
||||
/**
|
||||
* Returns the prefix(es) passed to the constructor.
|
||||
*/
|
||||
const std::vector<std::string>& Prefixes() const;
|
||||
/**
|
||||
* Returns the prefix(es) passed to the constructor.
|
||||
*/
|
||||
const std::vector<std::string>& Prefixes() const;
|
||||
|
||||
/**
|
||||
* Returns true if the given prefix is among the one specified for the component.
|
||||
*/
|
||||
bool HandlesPrefix(const std::string& prefix) const;
|
||||
/**
|
||||
* Returns true if the given prefix is among the one specified for the component.
|
||||
*/
|
||||
bool HandlesPrefix(const std::string& prefix) const;
|
||||
|
||||
/**
|
||||
* Returns true if packet source instantiated by the component handle
|
||||
* live traffic.
|
||||
*/
|
||||
bool DoesLive() const;
|
||||
/**
|
||||
* Returns true if packet source instantiated by the component handle
|
||||
* live traffic.
|
||||
*/
|
||||
bool DoesLive() const;
|
||||
|
||||
/**
|
||||
* Returns true if packet source instantiated by the component handle
|
||||
* offline traces.
|
||||
*/
|
||||
bool DoesTrace() const;
|
||||
/**
|
||||
* Returns true if packet source instantiated by the component handle
|
||||
* offline traces.
|
||||
*/
|
||||
bool DoesTrace() const;
|
||||
|
||||
/**
|
||||
* Returns the source's factory function.
|
||||
*/
|
||||
factory_callback Factory() const;
|
||||
/**
|
||||
* Returns the source's factory function.
|
||||
*/
|
||||
factory_callback Factory() const;
|
||||
|
||||
/**
|
||||
* Generates a human-readable description of the component. This goes
|
||||
* into the output of \c "zeek -NN".
|
||||
*/
|
||||
void DoDescribe(ODesc* d) const override;
|
||||
/**
|
||||
* Generates a human-readable description of the component. This goes
|
||||
* into the output of \c "zeek -NN".
|
||||
*/
|
||||
void DoDescribe(ODesc* d) const override;
|
||||
|
||||
private:
|
||||
std::vector<std::string> prefixes;
|
||||
InputType type;
|
||||
factory_callback factory;
|
||||
};
|
||||
std::vector<std::string> prefixes;
|
||||
InputType type;
|
||||
factory_callback factory;
|
||||
};
|
||||
|
||||
/**
|
||||
* Component description for plugins providing a PktDumper for packet output.
|
||||
|
@ -131,46 +126,44 @@ private:
|
|||
* PktDumpers aren't IOSources but we locate them here to keep them along with
|
||||
* the PktSrc.
|
||||
*/
|
||||
class PktDumperComponent : public plugin::Component
|
||||
{
|
||||
class PktDumperComponent : public plugin::Component {
|
||||
public:
|
||||
using factory_callback = PktDumper* (*)(const std::string& path, bool append);
|
||||
using factory_callback = PktDumper* (*)(const std::string& path, bool append);
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*/
|
||||
PktDumperComponent(const std::string& name, const std::string& prefixes,
|
||||
factory_callback factory);
|
||||
/**
|
||||
* XXX
|
||||
*/
|
||||
PktDumperComponent(const std::string& name, const std::string& prefixes, factory_callback factory);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~PktDumperComponent() override = default;
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~PktDumperComponent() override = default;
|
||||
|
||||
/**
|
||||
* Returns the prefix(es) passed to the constructor.
|
||||
*/
|
||||
const std::vector<std::string>& Prefixes() const;
|
||||
/**
|
||||
* Returns the prefix(es) passed to the constructor.
|
||||
*/
|
||||
const std::vector<std::string>& Prefixes() const;
|
||||
|
||||
/**
|
||||
* Returns true if the given prefix is among the one specified for the component.
|
||||
*/
|
||||
bool HandlesPrefix(const std::string& prefix) const;
|
||||
/**
|
||||
* Returns true if the given prefix is among the one specified for the component.
|
||||
*/
|
||||
bool HandlesPrefix(const std::string& prefix) const;
|
||||
|
||||
/**
|
||||
* Returns the source's factory function.
|
||||
*/
|
||||
factory_callback Factory() const;
|
||||
/**
|
||||
* Returns the source's factory function.
|
||||
*/
|
||||
factory_callback Factory() const;
|
||||
|
||||
/**
|
||||
* Generates a human-readable description of the component. This goes
|
||||
* into the output of \c "zeek -NN".
|
||||
*/
|
||||
void DoDescribe(ODesc* d) const override;
|
||||
/**
|
||||
* Generates a human-readable description of the component. This goes
|
||||
* into the output of \c "zeek -NN".
|
||||
*/
|
||||
void DoDescribe(ODesc* d) const override;
|
||||
|
||||
private:
|
||||
std::vector<std::string> prefixes;
|
||||
factory_callback factory;
|
||||
};
|
||||
std::vector<std::string> prefixes;
|
||||
factory_callback factory;
|
||||
};
|
||||
|
||||
} // namespace zeek::iosource
|
||||
} // namespace zeek::iosource
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue