mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Deprecate internal_func(), replace with zeek::lookup_func()
This commit is contained in:
parent
a83941d64d
commit
26f6fe01c8
5 changed files with 34 additions and 8 deletions
2
NEWS
2
NEWS
|
@ -164,6 +164,8 @@ Deprecated Functionality
|
||||||
- ``internal_val()`` and ``internal_const_val()`` are deprecated, use
|
- ``internal_val()`` and ``internal_const_val()`` are deprecated, use
|
||||||
``zeek::lookup_val()`` or ``zeek::lookup_const()``.
|
``zeek::lookup_val()`` or ``zeek::lookup_const()``.
|
||||||
|
|
||||||
|
- ``internal_func()`` is deprecated, use ``zeek::lookup_func()``.
|
||||||
|
|
||||||
Zeek 3.1.0
|
Zeek 3.1.0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
|
|
||||||
Discarder::Discarder()
|
Discarder::Discarder()
|
||||||
{
|
{
|
||||||
check_ip = internal_func("discarder_check_ip");
|
check_ip = zeek::lookup_func("discarder_check_ip");
|
||||||
check_tcp = internal_func("discarder_check_tcp");
|
check_tcp = zeek::lookup_func("discarder_check_tcp");
|
||||||
check_udp = internal_func("discarder_check_udp");
|
check_udp = zeek::lookup_func("discarder_check_udp");
|
||||||
check_icmp = internal_func("discarder_check_icmp");
|
check_icmp = zeek::lookup_func("discarder_check_icmp");
|
||||||
|
|
||||||
discarder_maxlen = static_cast<int>(opt_internal_int("discarder_maxlen"));
|
discarder_maxlen = static_cast<int>(opt_internal_int("discarder_maxlen"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include <sys/types.h> // for u_char
|
#include <sys/types.h> // for u_char
|
||||||
|
|
||||||
|
#include "IntrusivePtr.h"
|
||||||
|
|
||||||
class IP_Hdr;
|
class IP_Hdr;
|
||||||
class Val;
|
class Val;
|
||||||
class Func;
|
class Func;
|
||||||
|
@ -20,10 +22,10 @@ public:
|
||||||
protected:
|
protected:
|
||||||
Val* BuildData(const u_char* data, int hdrlen, int len, int caplen);
|
Val* BuildData(const u_char* data, int hdrlen, int len, int caplen);
|
||||||
|
|
||||||
Func* check_ip;
|
IntrusivePtr<Func> check_ip;
|
||||||
Func* check_tcp;
|
IntrusivePtr<Func> check_tcp;
|
||||||
Func* check_udp;
|
IntrusivePtr<Func> check_udp;
|
||||||
Func* check_icmp;
|
IntrusivePtr<Func> check_icmp;
|
||||||
|
|
||||||
// Maximum amount of application data passed to filtering functions.
|
// Maximum amount of application data passed to filtering functions.
|
||||||
int discarder_maxlen;
|
int discarder_maxlen;
|
||||||
|
|
13
src/Var.cc
13
src/Var.cc
|
@ -795,6 +795,19 @@ Func* internal_func(const char* name)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntrusivePtr<Func> zeek::lookup_func(const char* name)
|
||||||
|
{
|
||||||
|
const auto& v = zeek::lookup_val(name);
|
||||||
|
|
||||||
|
if ( ! v )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if ( ! IsFunc(v->Type()->Tag()) )
|
||||||
|
reporter->InternalError("Expected variable '%s' to be a function", name);
|
||||||
|
|
||||||
|
return {NewRef{}, v->AsFunc()};
|
||||||
|
}
|
||||||
|
|
||||||
EventHandlerPtr internal_handler(const char* name)
|
EventHandlerPtr internal_handler(const char* name)
|
||||||
{
|
{
|
||||||
// If there already is an entry in the registry, we have a
|
// If there already is an entry in the registry, we have a
|
||||||
|
|
|
@ -57,6 +57,7 @@ extern ListVal* internal_list_val(const char* name);
|
||||||
[[deprecated("Remove in v4.1. Use zeek::lookup_type().")]]
|
[[deprecated("Remove in v4.1. Use zeek::lookup_type().")]]
|
||||||
extern BroType* internal_type(const char* name);
|
extern BroType* internal_type(const char* name);
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use zeek::lookup_func().")]]
|
||||||
extern Func* internal_func(const char* name);
|
extern Func* internal_func(const char* name);
|
||||||
|
|
||||||
extern EventHandlerPtr internal_handler(const char* name);
|
extern EventHandlerPtr internal_handler(const char* name);
|
||||||
|
@ -99,4 +100,12 @@ const IntrusivePtr<Val>& lookup_val(const char* name);
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<Val>& lookup_const(const char* name);
|
const IntrusivePtr<Val>& lookup_const(const char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup an ID by its name and return the function it references.
|
||||||
|
* A fatal occurs if the ID does not exist or if it is not a function.
|
||||||
|
* @param name The identifier name to lookup
|
||||||
|
* @return The current function value the identifier references.
|
||||||
|
*/
|
||||||
|
IntrusivePtr<Func> lookup_func(const char* name);
|
||||||
|
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue