mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
beautify script calls, track filters
This commit is contained in:
parent
72736510de
commit
2aa0f6da57
2 changed files with 68 additions and 7 deletions
|
@ -20,7 +20,68 @@ export {
|
||||||
pred: function(typ: Input::Event, left: any, right: any): bool &optional;
|
pred: function(typ: Input::Event, left: any, right: any): bool &optional;
|
||||||
## decision function, that decides if an inserton, update or removal should really be executed
|
## decision function, that decides if an inserton, update or removal should really be executed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const no_filter: Filter = [$name="<not found>"]; # Sentinel.
|
||||||
|
|
||||||
|
global create_reader: function(id: Log::ID, description: Input::ReaderDescription) : bool;
|
||||||
|
global remove_reader: function(id: Log::ID) : bool;
|
||||||
|
global force_update: function(id: Log::ID) : bool;
|
||||||
|
global add_event: function(id: Log::ID, name: string) : bool;
|
||||||
|
global remove_event: function(id: Log::ID, name: string) : bool;
|
||||||
|
global add_filter: function(id: Log::ID, filter: Input::Filter) : bool;
|
||||||
|
global remove_filter: function(id: Log::ID, name: string) : bool;
|
||||||
|
global get_filter: function(id: ID, name: string) : Filter;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@load base/input.bif
|
@load base/input.bif
|
||||||
|
|
||||||
|
|
||||||
|
module Input;
|
||||||
|
|
||||||
|
global filters: table[ID, string] of Filter;
|
||||||
|
|
||||||
|
function create_reader(id: Log::ID, description: Input::ReaderDescription) : bool
|
||||||
|
{
|
||||||
|
return __create_reader(id, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_reader(id: Log::ID) : bool
|
||||||
|
{
|
||||||
|
return __remove_reader(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function force_update(id: Log::ID) : bool
|
||||||
|
{
|
||||||
|
return __force_update(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_event(id: Log::ID, name: string) : bool
|
||||||
|
{
|
||||||
|
return __add_event(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_event(id: Log::ID, name: string) : bool
|
||||||
|
{
|
||||||
|
return __remove_event(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_filter(id: Log::ID, filter: Input::Filter) : bool
|
||||||
|
{
|
||||||
|
filters[id, filter$name] = filter;
|
||||||
|
return __add_filter(id, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_filter(id: Log::ID, name: string) : bool
|
||||||
|
{
|
||||||
|
delete filters[id, name];
|
||||||
|
return __remove_filter(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_filter(id: ID, name: string) : Filter
|
||||||
|
{
|
||||||
|
if ( [id, name] in filters )
|
||||||
|
return filters[id, name];
|
||||||
|
|
||||||
|
return no_filter;
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@ function Input::__create_reader%(id: Log::ID, description: Input::ReaderDescript
|
||||||
return new Val( the_reader != 0, TYPE_BOOL );
|
return new Val( the_reader != 0, TYPE_BOOL );
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
function Input::__remove_reader%(id: Log::ID%) : bool
|
||||||
|
%{
|
||||||
|
bool res = input_mgr->RemoveReader(id->AsEnumVal());
|
||||||
|
return new Val( res, TYPE_BOOL );
|
||||||
|
%}
|
||||||
|
|
||||||
function Input::__force_update%(id: Log::ID%) : bool
|
function Input::__force_update%(id: Log::ID%) : bool
|
||||||
%{
|
%{
|
||||||
bool res = input_mgr->ForceUpdate(id->AsEnumVal());
|
bool res = input_mgr->ForceUpdate(id->AsEnumVal());
|
||||||
|
@ -34,12 +40,6 @@ function Input::__remove_event%(id: Log::ID, name: string%) : bool
|
||||||
return new Val( res, TYPE_BOOL );
|
return new Val( res, TYPE_BOOL );
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function Input::__remove_reader%(id: Log::ID%) : bool
|
|
||||||
%{
|
|
||||||
bool res = input_mgr->RemoveReader(id->AsEnumVal());
|
|
||||||
return new Val( res, TYPE_BOOL );
|
|
||||||
%}
|
|
||||||
|
|
||||||
function Input::__add_filter%(id: Log::ID, filter: Input::Filter%) : bool
|
function Input::__add_filter%(id: Log::ID, filter: Input::Filter%) : bool
|
||||||
%{
|
%{
|
||||||
bool res = input_mgr->AddFilter(id->AsEnumVal(), filter->AsRecordVal());
|
bool res = input_mgr->AddFilter(id->AsEnumVal(), filter->AsRecordVal());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue