mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add Zeekygen documentation support for packet analyzers
This commit is contained in:
parent
b0db3cc76f
commit
0d58e97349
5 changed files with 73 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
2
doc
2
doc
|
@ -1 +1 @@
|
|||
Subproject commit d8e692e091b963f08504c17c4f46c16d601486d5
|
||||
Subproject commit 8ba9b1a65c67d16365a218198ef9edb338f84c64
|
|
@ -21,6 +21,7 @@ static TargetFactory create_target_factory()
|
|||
rval.Register<PackageTarget>("package");
|
||||
rval.Register<ProtoAnalyzerTarget>("proto_analyzer");
|
||||
rval.Register<FileAnalyzerTarget>("file_analyzer");
|
||||
rval.Register<PacketAnalyzerTarget>("packet_analyzer");
|
||||
rval.Register<ScriptSummaryTarget>("script_summary");
|
||||
rval.Register<ScriptIndexTarget>("script_index");
|
||||
rval.Register<ScriptTarget>("script");
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "analyzer/Manager.h"
|
||||
#include "analyzer/Component.h"
|
||||
#include "file_analysis/Manager.h"
|
||||
#include "packet_analysis/Manager.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -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<const packet_analysis::Component*>(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");
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue