mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Deprecate internal_val() and internal_const_val()
Replaced with zeek::lookup_val() and zeek::lookup_const()
This commit is contained in:
parent
ac06259eec
commit
a83941d64d
10 changed files with 85 additions and 49 deletions
3
NEWS
3
NEWS
|
@ -161,6 +161,9 @@ Deprecated Functionality
|
|||
|
||||
- ``internal_type()`` is deprecated, use ``zeek::lookup_type()``.
|
||||
|
||||
- ``internal_val()`` and ``internal_const_val()`` are deprecated, use
|
||||
``zeek::lookup_val()`` or ``zeek::lookup_const()``.
|
||||
|
||||
Zeek 3.1.0
|
||||
==========
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2d9b8606d5d7e4ec4a67cc11a72d38c2241ee871
|
||||
Subproject commit 883d7174c8d80a44910855b05482fe107a60e55c
|
|
@ -219,7 +219,7 @@ void init_general_global_var()
|
|||
log_rotate_base_time = opt_internal_string("log_rotate_base_time");
|
||||
|
||||
peer_description =
|
||||
internal_val("peer_description")->AsStringVal();
|
||||
zeek::lookup_val("peer_description")->AsStringVal();
|
||||
|
||||
packet_filter_default = opt_internal_int("packet_filter_default");
|
||||
|
||||
|
@ -230,12 +230,12 @@ void init_general_global_var()
|
|||
|
||||
suppress_local_output = opt_internal_int("suppress_local_output");
|
||||
|
||||
trace_output_file = internal_val("trace_output_file")->AsStringVal();
|
||||
trace_output_file = zeek::lookup_val("trace_output_file")->AsStringVal();
|
||||
|
||||
record_all_packets = opt_internal_int("record_all_packets");
|
||||
|
||||
cmd_line_bpf_filter =
|
||||
internal_val("cmd_line_bpf_filter")->AsStringVal();
|
||||
zeek::lookup_val("cmd_line_bpf_filter")->AsStringVal();
|
||||
|
||||
global_hash_seed = opt_internal_string("global_hash_seed");
|
||||
|
||||
|
@ -306,31 +306,31 @@ void init_net_var()
|
|||
opt_internal_double("tcp_storm_interarrival_thresh");
|
||||
|
||||
tcp_reassembler_ports_orig =
|
||||
internal_val("tcp_reassembler_ports_orig")->AsTableVal();
|
||||
zeek::lookup_val("tcp_reassembler_ports_orig")->AsTableVal();
|
||||
tcp_reassembler_ports_resp =
|
||||
internal_val("tcp_reassembler_ports_resp")->AsTableVal();
|
||||
zeek::lookup_val("tcp_reassembler_ports_resp")->AsTableVal();
|
||||
|
||||
tcp_content_delivery_ports_orig =
|
||||
internal_val("tcp_content_delivery_ports_orig")->AsTableVal();
|
||||
zeek::lookup_val("tcp_content_delivery_ports_orig")->AsTableVal();
|
||||
tcp_content_delivery_ports_resp =
|
||||
internal_val("tcp_content_delivery_ports_resp")->AsTableVal();
|
||||
zeek::lookup_val("tcp_content_delivery_ports_resp")->AsTableVal();
|
||||
tcp_content_deliver_all_orig =
|
||||
bool(internal_val("tcp_content_deliver_all_orig")->AsBool());
|
||||
bool(zeek::lookup_val("tcp_content_deliver_all_orig")->AsBool());
|
||||
tcp_content_deliver_all_resp =
|
||||
bool(internal_val("tcp_content_deliver_all_resp")->AsBool());
|
||||
bool(zeek::lookup_val("tcp_content_deliver_all_resp")->AsBool());
|
||||
|
||||
udp_content_delivery_ports_orig =
|
||||
internal_val("udp_content_delivery_ports_orig")->AsTableVal();
|
||||
zeek::lookup_val("udp_content_delivery_ports_orig")->AsTableVal();
|
||||
udp_content_delivery_ports_resp =
|
||||
internal_val("udp_content_delivery_ports_resp")->AsTableVal();
|
||||
zeek::lookup_val("udp_content_delivery_ports_resp")->AsTableVal();
|
||||
udp_content_ports =
|
||||
internal_val("udp_content_ports")->AsTableVal();
|
||||
zeek::lookup_val("udp_content_ports")->AsTableVal();
|
||||
udp_content_deliver_all_orig =
|
||||
bool(internal_val("udp_content_deliver_all_orig")->AsBool());
|
||||
bool(zeek::lookup_val("udp_content_deliver_all_orig")->AsBool());
|
||||
udp_content_deliver_all_resp =
|
||||
bool(internal_val("udp_content_deliver_all_resp")->AsBool());
|
||||
bool(zeek::lookup_val("udp_content_deliver_all_resp")->AsBool());
|
||||
udp_content_delivery_ports_use_resp =
|
||||
bool(internal_val("udp_content_delivery_ports_use_resp")->AsBool());
|
||||
bool(zeek::lookup_val("udp_content_delivery_ports_use_resp")->AsBool());
|
||||
|
||||
dns_session_timeout = opt_internal_double("dns_session_timeout");
|
||||
rpc_timeout = opt_internal_double("rpc_timeout");
|
||||
|
@ -377,15 +377,15 @@ void init_net_var()
|
|||
dns_dnskey_rr = lookup_type("dns_dnskey_rr")->AsRecordType();
|
||||
dns_nsec3_rr = lookup_type("dns_nsec3_rr")->AsRecordType();
|
||||
dns_ds_rr = lookup_type("dns_ds_rr")->AsRecordType();
|
||||
dns_skip_auth = internal_val("dns_skip_auth")->AsTableVal();
|
||||
dns_skip_addl = internal_val("dns_skip_addl")->AsTableVal();
|
||||
dns_skip_auth = zeek::lookup_val("dns_skip_auth")->AsTableVal();
|
||||
dns_skip_addl = zeek::lookup_val("dns_skip_addl")->AsTableVal();
|
||||
dns_skip_all_auth = opt_internal_int("dns_skip_all_auth");
|
||||
dns_skip_all_addl = opt_internal_int("dns_skip_all_addl");
|
||||
dns_max_queries = opt_internal_int("dns_max_queries");
|
||||
|
||||
stp_delta = opt_internal_double("stp_delta");
|
||||
stp_idle_min = opt_internal_double("stp_idle_min");
|
||||
stp_skip_src = internal_val("stp_skip_src")->AsTableVal();
|
||||
stp_skip_src = zeek::lookup_val("stp_skip_src")->AsTableVal();
|
||||
|
||||
orig_addr_anonymization = opt_internal_int("orig_addr_anonymization");
|
||||
resp_addr_anonymization = opt_internal_int("resp_addr_anonymization");
|
||||
|
@ -398,7 +398,7 @@ void init_net_var()
|
|||
connection_status_update_interval =
|
||||
opt_internal_double("connection_status_update_interval");
|
||||
|
||||
profiling_file = internal_val("profiling_file");
|
||||
profiling_file = zeek::lookup_val("profiling_file").get();
|
||||
expensive_profiling_multiple =
|
||||
opt_internal_int("expensive_profiling_multiple");
|
||||
profiling_interval = opt_internal_double("profiling_interval");
|
||||
|
@ -422,7 +422,7 @@ void init_net_var()
|
|||
dpd_late_match_stop = opt_internal_int("dpd_late_match_stop");
|
||||
dpd_ignore_ports = opt_internal_int("dpd_ignore_ports");
|
||||
|
||||
likely_server_ports = internal_val("likely_server_ports")->AsTableVal();
|
||||
likely_server_ports = zeek::lookup_val("likely_server_ports")->AsTableVal();
|
||||
|
||||
timer_mgr_inactivity_timeout =
|
||||
opt_internal_double("timer_mgr_inactivity_timeout");
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "Net.h"
|
||||
#include "Conn.h"
|
||||
#include "Timer.h"
|
||||
#include "Var.h" // for internal_val()
|
||||
#include "Var.h"
|
||||
#include "EventHandler.h"
|
||||
#include "plugin/Plugin.h"
|
||||
#include "plugin/Manager.h"
|
||||
|
@ -63,13 +63,13 @@ Reporter::~Reporter()
|
|||
|
||||
void Reporter::InitOptions()
|
||||
{
|
||||
info_to_stderr = internal_val("Reporter::info_to_stderr")->AsBool();
|
||||
warnings_to_stderr = internal_val("Reporter::warnings_to_stderr")->AsBool();
|
||||
errors_to_stderr = internal_val("Reporter::errors_to_stderr")->AsBool();
|
||||
weird_sampling_rate = internal_val("Weird::sampling_rate")->AsCount();
|
||||
weird_sampling_threshold = internal_val("Weird::sampling_threshold")->AsCount();
|
||||
weird_sampling_duration = internal_val("Weird::sampling_duration")->AsInterval();
|
||||
auto wl_val = internal_val("Weird::sampling_whitelist")->AsTableVal();
|
||||
info_to_stderr = zeek::lookup_val("Reporter::info_to_stderr")->AsBool();
|
||||
warnings_to_stderr = zeek::lookup_val("Reporter::warnings_to_stderr")->AsBool();
|
||||
errors_to_stderr = zeek::lookup_val("Reporter::errors_to_stderr")->AsBool();
|
||||
weird_sampling_rate = zeek::lookup_val("Weird::sampling_rate")->AsCount();
|
||||
weird_sampling_threshold = zeek::lookup_val("Weird::sampling_threshold")->AsCount();
|
||||
weird_sampling_duration = zeek::lookup_val("Weird::sampling_duration")->AsInterval();
|
||||
auto wl_val = zeek::lookup_val("Weird::sampling_whitelist")->AsTableVal();
|
||||
auto wl_table = wl_val->AsTable();
|
||||
|
||||
HashKey* k;
|
||||
|
|
|
@ -237,7 +237,7 @@ IntrusivePtr<Val> PrintStmt::DoExec(std::vector<IntrusivePtr<Val>> vals,
|
|||
}
|
||||
|
||||
static auto print_log_type = static_cast<BifEnum::Log::PrintLogType>(
|
||||
internal_val("Log::print_to_log")->AsEnum());
|
||||
zeek::lookup_val("Log::print_to_log")->AsEnum());
|
||||
|
||||
switch ( print_log_type ) {
|
||||
case BifEnum::Log::REDIRECT_NONE:
|
||||
|
|
42
src/Var.cc
42
src/Var.cc
|
@ -657,12 +657,7 @@ void end_func(IntrusivePtr<Stmt> body)
|
|||
|
||||
Val* internal_val(const char* name)
|
||||
{
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
|
||||
if ( ! id )
|
||||
reporter->InternalError("internal variable %s missing", name);
|
||||
|
||||
return id->GetVal().get();
|
||||
return zeek::lookup_val(name).get();
|
||||
}
|
||||
|
||||
id_list gather_outer_ids(Scope* scope, Stmt* body)
|
||||
|
@ -687,14 +682,7 @@ id_list gather_outer_ids(Scope* scope, Stmt* body)
|
|||
|
||||
Val* internal_const_val(const char* name)
|
||||
{
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
if ( ! id )
|
||||
reporter->InternalError("internal variable %s missing", name);
|
||||
|
||||
if ( ! id->IsConst() )
|
||||
reporter->InternalError("internal variable %s is not constant", name);
|
||||
|
||||
return id->GetVal().get();
|
||||
return zeek::lookup_const(name).get();
|
||||
}
|
||||
|
||||
Val* opt_internal_val(const char* name)
|
||||
|
@ -765,6 +753,29 @@ BroType* internal_type(const char* name)
|
|||
return zeek::lookup_type(name).get();
|
||||
}
|
||||
|
||||
const IntrusivePtr<Val>& zeek::lookup_val(const char* name)
|
||||
{
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
|
||||
if ( ! id )
|
||||
reporter->InternalError("Failed to find variable named: %s", name);
|
||||
|
||||
return id->GetVal();
|
||||
}
|
||||
|
||||
const IntrusivePtr<Val>& zeek::lookup_const(const char* name)
|
||||
{
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
|
||||
if ( ! id )
|
||||
reporter->InternalError("Failed to find variable named: %s", name);
|
||||
|
||||
if ( ! id->IsConst() )
|
||||
reporter->InternalError("Variable is not 'const', but expected to be: %s", name);
|
||||
|
||||
return id->GetVal();
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& zeek::lookup_type(const char* name)
|
||||
{
|
||||
auto id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
|
@ -776,7 +787,8 @@ const IntrusivePtr<BroType>& zeek::lookup_type(const char* name)
|
|||
|
||||
Func* internal_func(const char* name)
|
||||
{
|
||||
Val* v = internal_val(name);
|
||||
const auto& v = zeek::lookup_val(name);
|
||||
|
||||
if ( v )
|
||||
return v->AsFunc();
|
||||
else
|
||||
|
|
21
src/Var.h
21
src/Var.h
|
@ -40,8 +40,12 @@ extern void end_func(IntrusivePtr<Stmt> body);
|
|||
// Gather all IDs referenced inside a body that aren't part of a given scope.
|
||||
extern id_list gather_outer_ids(Scope* scope, Stmt* body);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::lookup_val().")]]
|
||||
extern Val* internal_val(const char* name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::lookup_const().")]]
|
||||
extern Val* internal_const_val(const char* name); // internal error if not const
|
||||
|
||||
extern Val* opt_internal_val(const char* name); // returns nil if not defined
|
||||
extern double opt_internal_double(const char* name);
|
||||
extern bro_int_t opt_internal_int(const char* name);
|
||||
|
@ -54,6 +58,7 @@ extern ListVal* internal_list_val(const char* name);
|
|||
extern BroType* internal_type(const char* name);
|
||||
|
||||
extern Func* internal_func(const char* name);
|
||||
|
||||
extern EventHandlerPtr internal_handler(const char* name);
|
||||
|
||||
extern int signal_val; // 0 if no signal pending
|
||||
|
@ -78,4 +83,20 @@ template<class T>
|
|||
IntrusivePtr<T> lookup_type(const char* name)
|
||||
{ return cast_intrusive<T>(lookup_type(name)); }
|
||||
|
||||
/**
|
||||
* Lookup an ID by its name and return its value. A fatal occurs if the ID
|
||||
* does not exist.
|
||||
* @param name The identifier name to lookup
|
||||
* @return The current value of the identifier
|
||||
*/
|
||||
const IntrusivePtr<Val>& lookup_val(const char* name);
|
||||
|
||||
/**
|
||||
* Lookup an ID by its name and return its value. A fatal occurs if the ID
|
||||
* does not exist or if it is not "const".
|
||||
* @param name The identifier name to lookup
|
||||
* @return The current value of the identifier
|
||||
*/
|
||||
const IntrusivePtr<Val>& lookup_const(const char* name);
|
||||
|
||||
} // namespace zeek
|
||||
|
|
|
@ -432,7 +432,7 @@ string Manager::GetFileID(const analyzer::Tag& tag, Connection* c, bool is_orig)
|
|||
bool Manager::IsDisabled(const analyzer::Tag& tag)
|
||||
{
|
||||
if ( ! disabled )
|
||||
disabled = internal_const_val("Files::disable")->AsTableVal();
|
||||
disabled = zeek::lookup_const("Files::disable")->AsTableVal();
|
||||
|
||||
auto index = val_mgr->Count(bool(tag));
|
||||
auto yield = disabled->Lookup(index.get());
|
||||
|
|
|
@ -313,7 +313,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
streams[idx]->event = event ? event_registry->Lookup(event->Name()) : nullptr;
|
||||
streams[idx]->columns = columns->Ref()->AsRecordType();
|
||||
|
||||
streams[idx]->enable_remote = internal_val("Log::enable_remote_logging")->AsBool();
|
||||
streams[idx]->enable_remote = zeek::lookup_val("Log::enable_remote_logging")->AsBool();
|
||||
|
||||
DBG_LOG(DBG_LOGGING, "Created new logging stream '%s', raising event %s",
|
||||
streams[idx]->name.c_str(), event ? streams[idx]->event->Name() : "<none>");
|
||||
|
|
|
@ -363,7 +363,7 @@ static std::vector<std::string> get_script_signature_files()
|
|||
|
||||
// Parse rule files defined on the script level.
|
||||
char* script_signature_files =
|
||||
copy_string(internal_val("signature_files")->AsString()->CheckString());
|
||||
copy_string(zeek::lookup_val("signature_files")->AsString()->CheckString());
|
||||
|
||||
char* tmp = script_signature_files;
|
||||
char* s;
|
||||
|
@ -724,7 +724,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
|
||||
if ( ! options.pcap_file && ! options.interface )
|
||||
{
|
||||
Val* interfaces_val = internal_val("interfaces");
|
||||
const auto& interfaces_val = zeek::lookup_val("interfaces");
|
||||
if ( interfaces_val )
|
||||
{
|
||||
char* interfaces_str =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue