diff --git a/ci/update-zeekygen-docs.sh b/ci/update-zeekygen-docs.sh index 807e6c698a..115a23836f 100755 --- a/ci/update-zeekygen-docs.sh +++ b/ci/update-zeekygen-docs.sh @@ -59,6 +59,7 @@ generate_index "script_index" "autogenerated-script-index.rst" generate_index "package_index" "autogenerated-package-index.rst" generate_index "file_analyzer" "autogenerated-file-analyzer-index.rst" generate_index "proto_analyzer" "autogenerated-protocol-analyzer-index.rst" +generate_index "packet_analyzer" "autogenerated-packet-analyzer-index.rst" echo diff --git a/doc b/doc index d8e692e091..8ba9b1a65c 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit d8e692e091b963f08504c17c4f46c16d601486d5 +Subproject commit 8ba9b1a65c67d16365a218198ef9edb338f84c64 diff --git a/src/zeekygen/Configuration.cc b/src/zeekygen/Configuration.cc index fad29f80b0..2c86c18d05 100644 --- a/src/zeekygen/Configuration.cc +++ b/src/zeekygen/Configuration.cc @@ -21,6 +21,7 @@ static TargetFactory create_target_factory() rval.Register("package"); rval.Register("proto_analyzer"); rval.Register("file_analyzer"); + rval.Register("packet_analyzer"); rval.Register("script_summary"); rval.Register("script_index"); rval.Register("script"); diff --git a/src/zeekygen/Target.cc b/src/zeekygen/Target.cc index ee9aa818d5..83c2e6a39b 100644 --- a/src/zeekygen/Target.cc +++ b/src/zeekygen/Target.cc @@ -12,6 +12,7 @@ #include "analyzer/Manager.h" #include "analyzer/Component.h" #include "file_analysis/Manager.h" +#include "packet_analysis/Manager.h" #include #include @@ -45,6 +46,17 @@ static void write_analyzer_component(FILE* f, const analyzer::Component* c) fprintf(f, ":zeek:enum:`Analyzer::%s`\n\n", tag.c_str()); } +static void write_analyzer_component(FILE* f, const packet_analysis::Component* c) + { + const auto& atag = packet_mgr->GetTagType(); + string tag = util::fmt("ANALYZER_%s", c->CanonicalName().c_str()); + + if ( atag->Lookup("PacketAnalyzer", tag.c_str()) < 0 ) + reporter->InternalError("missing packet analyzer tag for %s", tag.c_str()); + + fprintf(f, ":zeek:enum:`PacketAnalyzer::%s`\n\n", tag.c_str()); + } + static void write_analyzer_component(FILE* f, const file_analysis::Component* c) { const auto& atag = file_mgr->GetTagType(); @@ -78,6 +90,18 @@ static void write_plugin_components(FILE* f, const plugin::Plugin* p) } break; + case plugin::component::PACKET_ANALYZER: + { + const packet_analysis::Component* c = + dynamic_cast(component); + + if ( c ) + write_analyzer_component(f, c); + else + reporter->InternalError("component type mismatch"); + } + break; + case plugin::component::FILE_ANALYZER: { const auto* c = @@ -285,6 +309,32 @@ void ProtoAnalyzerTarget::DoCreateAnalyzerDoc(FILE* f) const } } +void PacketAnalyzerTarget::DoCreateAnalyzerDoc(FILE* f) const + { + fprintf(f, "Packet Analyzers\n"); + fprintf(f, "================\n\n"); + + WriteAnalyzerTagDefn(f, "PacketAnalyzer"); + + plugin::Manager::plugin_list plugins = plugin_mgr->ActivePlugins(); + plugin::Manager::plugin_list::const_iterator it; + + for ( it = plugins.begin(); it != plugins.end(); ++it ) + { + if ( ! ComponentsMatch(*it, plugin::component::PACKET_ANALYZER) ) + continue; + + write_plugin_section_heading(f, *it); + write_plugin_components(f, *it); + write_plugin_bif_items(f, *it, plugin::BifItem::CONSTANT, + "Options/Constants"); + write_plugin_bif_items(f, *it, plugin::BifItem::GLOBAL, "Globals"); + write_plugin_bif_items(f, *it, plugin::BifItem::TYPE, "Types"); + write_plugin_bif_items(f, *it, plugin::BifItem::EVENT, "Events"); + write_plugin_bif_items(f, *it, plugin::BifItem::FUNCTION, "Functions"); + } + } + void FileAnalyzerTarget::DoCreateAnalyzerDoc(FILE* f) const { fprintf(f, "File Analyzers\n"); diff --git a/src/zeekygen/Target.h b/src/zeekygen/Target.h index 3c48a6976c..f437c461ff 100644 --- a/src/zeekygen/Target.h +++ b/src/zeekygen/Target.h @@ -233,6 +233,26 @@ private: void DoCreateAnalyzerDoc(FILE* f) const override; }; +/** + * Target to build packet analyzer documentation. + */ +class PacketAnalyzerTarget : public AnalyzerTarget { +public: + + /** + * Ctor. + * @param name Output file name. + * @param pattern Dependency pattern. + */ + PacketAnalyzerTarget(const std::string& name, const std::string& pattern) + : AnalyzerTarget(name, pattern) + { } + +private: + + void DoCreateAnalyzerDoc(FILE* f) const override; +}; + /** * Target to build package documentation. */