mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Fix packet analyzer replacement.
Also reworking the existing test, which was pretty odd/broken.
This commit is contained in:
parent
3a469b3619
commit
ccfeffaf2b
5 changed files with 26 additions and 26 deletions
|
@ -18,11 +18,23 @@ void Component::Initialize() {
|
|||
}
|
||||
|
||||
void Component::SetEnabled(bool arg_enabled) {
|
||||
plugin::Component::SetEnabled(arg_enabled);
|
||||
auto analyzer = packet_mgr->GetAnalyzer(Tag().AsVal().get());
|
||||
if ( analyzer ) {
|
||||
// We can only toggle the analyzer if it's not replacing another one,
|
||||
// otherwise our dispatching tables would be wrong.
|
||||
if ( packet_mgr->ProvidesComponentMapping(Tag()) ) {
|
||||
reporter->Warning(
|
||||
"attempt to toggle packet analyzer %s, which replaces another one; toggling replacement analyzers is "
|
||||
"not supported",
|
||||
analyzer->GetAnalyzerName());
|
||||
return;
|
||||
}
|
||||
|
||||
// If we already have instantiated an analyzer, update its state.
|
||||
if ( auto analyzer = packet_mgr->Lookup(Tag().AsVal().get(), false) )
|
||||
// Update the existing analyzer's state.
|
||||
analyzer->SetEnabled(arg_enabled);
|
||||
}
|
||||
|
||||
plugin::Component::SetEnabled(arg_enabled);
|
||||
}
|
||||
|
||||
void Component::DoDescribe(ODesc* d) const {
|
||||
|
|
|
@ -42,7 +42,7 @@ void Dispatcher::Register(uint32_t identifier, AnalyzerPtr analyzer) {
|
|||
}
|
||||
|
||||
int64_t index = identifier - lowest_identifier;
|
||||
if ( table[index] != nullptr )
|
||||
if ( table[index] != nullptr && table[index] != analyzer )
|
||||
reporter->Info("Overwriting packet analyzer mapping %#8" PRIx64 " => %s with %s", index + lowest_identifier,
|
||||
table[index]->GetAnalyzerName(), analyzer->GetAnalyzerName());
|
||||
table[index] = std::move(analyzer);
|
||||
|
|
|
@ -159,7 +159,7 @@ AnalyzerPtr Manager::InstantiateAnalyzer(const Tag& tag) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if ( tag != a->GetAnalyzerTag() ) {
|
||||
if ( tag != a->GetAnalyzerTag() && ! HasComponentMapping(tag) ) {
|
||||
reporter->InternalError(
|
||||
"Mismatch of requested analyzer %s and instantiated analyzer %s. "
|
||||
"This usually means that the plugin author made a mistake.",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue