Deprecate functions with "bro" in them.

* "bro_is_terminating" is now "zeek_is_terminating"

* "bro_version" is now "zeek_version"

The old function names still exist for now, but are deprecated.
This commit is contained in:
Jon Siwek 2019-06-05 16:11:55 -07:00
parent b5050437fa
commit dfed213f31
19 changed files with 62 additions and 29 deletions

10
CHANGES
View file

@ -1,4 +1,14 @@
2.6-377 | 2019-06-05 16:15:58 -0700
* Deprecate functions with "bro" in them. (Jon Siwek, Corelight)
* "bro_is_terminating" is now "zeek_is_terminating"
* "bro_version" is now "zeek_version"
The old functions still exist for now, but are deprecated.
2.6-376 | 2019-06-05 13:29:57 -0700
* GH-379: move catch-and-release and unified2 scripts to policy/ (Jon Siwek, Corelight)

3
NEWS
View file

@ -361,6 +361,9 @@ Deprecated Functionality
such that existing code will not break, but will emit a deprecation
warning.
- The ``bro_is_terminating`` and ``bro_version`` function are deprecated and
replaced by functions named ``zeek_is_terminating`` and ``zeek_version``.
- The ``rotate_file``, ``rotate_file_by_name`` and ``calc_next_rotate`` functions
were marked as deprecated. These functions were used with the old pre-2.0 logging
framework and are no longer used. They also were marked as deprecated in their

View file

@ -1 +1 @@
2.6-376
2.6-377

2
doc

@ -1 +1 @@
Subproject commit 09d21c86c3f68b1fde426fe93d0b044ca839b968
Subproject commit 69a337c5c7958014566f138bfbce9ce95db47b3d

View file

@ -889,7 +889,7 @@ function remove_rule_impl(id: string, reason: string) : bool
function rule_expire_impl(r: Rule, p: PluginState) &priority=-5
{
# do not emit timeout events on shutdown
if ( bro_is_terminating() )
if ( zeek_is_terminating() )
return;
if ( r$id !in rules )

View file

@ -405,7 +405,7 @@ function email_headers(subject_desc: string, dest: string): string
"From: ", mail_from, "\n",
"Subject: ", mail_subject_prefix, " ", subject_desc, "\n",
"To: ", dest, "\n",
"User-Agent: Bro-IDS/", bro_version(), "\n");
"User-Agent: Bro-IDS/", zeek_version(), "\n");
if ( reply_to != "" )
header_text = string_cat(header_text, "Reply-To: ", reply_to, "\n");
return header_text;

View file

@ -11,7 +11,7 @@ const COOKIE_BID_SIZE = 16777216;
# start at bit 40 (1 << 40)
const COOKIE_BID_START = 1099511627776;
# Zeek specific cookie ID shall have the 42 bit set (1 << 42)
const BRO_COOKIE_ID = 4;
const ZEEK_COOKIE_ID = 4;
# 8 bits group identifier
const COOKIE_GID_SIZE = 256;
# start at bit 32 (1 << 32)

View file

@ -198,7 +198,7 @@ function match_conn(id: conn_id, reverse: bool &default=F): ofp_match
# 42 bit of the cookie set.
function generate_cookie(cookie: count &default=0): count
{
local c = BRO_COOKIE_ID * COOKIE_BID_START;
local c = ZEEK_COOKIE_ID * COOKIE_BID_START;
if ( cookie >= COOKIE_UID_SIZE )
Reporter::warning(fmt("The given cookie uid '%d' is > 32bit and will be discarded", cookie));
@ -211,7 +211,7 @@ function generate_cookie(cookie: count &default=0): count
# local function to check if a given flow_mod cookie is forged from this framework.
function is_valid_cookie(cookie: count): bool
{
if ( cookie / COOKIE_BID_START == BRO_COOKIE_ID )
if ( cookie / COOKIE_BID_START == ZEEK_COOKIE_ID )
return T;
Reporter::warning(fmt("The given Openflow cookie '%d' is not valid", cookie));
@ -231,7 +231,7 @@ function get_cookie_gid(cookie: count): count
{
if( is_valid_cookie(cookie) )
return (
(cookie - (COOKIE_BID_START * BRO_COOKIE_ID) -
(cookie - (COOKIE_BID_START * ZEEK_COOKIE_ID) -
(cookie - ((cookie / COOKIE_GID_START) * COOKIE_GID_START))) /
COOKIE_GID_START
);

View file

@ -89,7 +89,7 @@ export {
## Opaque controller-issued identifier.
# This is optional in the specification - but let's force
# it so we always can identify our flows...
cookie: count; # &default=BRO_COOKIE_ID * COOKIE_BID_START;
cookie: count; # &default=ZEEK_COOKIE_ID * COOKIE_BID_START;
# Flow actions
## Table to put the flow in. OFPTT_ALL can be used for delete,
## to delete flows from all matching tables.

View file

@ -35,7 +35,7 @@ event SumStats::finish_epoch(ss: SumStat)
{
local data = result_store[ss$name];
local now = network_time();
if ( bro_is_terminating() )
if ( zeek_is_terminating() )
{
for ( key, val in data )
ss$epoch_result(now, key, val);

View file

@ -78,10 +78,10 @@ export {
## The format of the number is ABBCC with A being the major version,
## bb being the minor version (2 digits) and CC being the patchlevel (2 digits).
## As an example, Zeek 2.4.1 results in the number 20401
const number = Version::parse(bro_version())$version_number;
const number = Version::parse(zeek_version())$version_number;
## `VersionDescription` record pertaining to the currently running version of Zeek.
const info = Version::parse(bro_version());
const info = Version::parse(zeek_version());
}
function at_least(version_string: string): bool

View file

@ -141,7 +141,7 @@ function join_data_expiration(t: table[count] of Info, idx: count): interval
# Also, if Zeek is shutting down.
if ( (now - info$last_message_ts) > 5sec ||
(now - info$ts) > max_txid_watch_time ||
bro_is_terminating() )
zeek_is_terminating() )
{
Log::write(LOG, info);

View file

@ -99,7 +99,7 @@ event check_stats(then: time, last_ns: NetStats, last_cs: ConnStats, last_ps: Pr
local fs = get_file_analysis_stats();
local ds = get_dns_stats();
if ( bro_is_terminating() )
if ( zeek_is_terminating() )
# No more stats will be written or scheduled when Zeek is
# shutting down.
return;

View file

@ -17,7 +17,7 @@ export {
event TrimTraceFile::go(first_trim: bool)
{
if ( bro_is_terminating() || trace_output_file == "" )
if ( zeek_is_terminating() || trace_output_file == "" )
return;
if ( ! first_trim )

View file

@ -1735,15 +1735,24 @@ function getpid%(%) : count
%}
%%{
extern const char* bro_version();
extern const char* zeek_version();
%%}
## Returns the Bro version string.
## Returns the Zeek version string. This function is deprecated, use
## :zeek:see:`zeek_version` instead.
##
## Returns: Bro's version, e.g., 2.0-beta-47-debug.
function bro_version%(%): string
## Returns: Zeek's version, e.g., 2.0-beta-47-debug.
function bro_version%(%): string &deprecated
%{
return new StringVal(bro_version());
return new StringVal(zeek_version());
%}
## Returns the Zeek version string.
##
## Returns: Zeek's version, e.g., 2.0-beta-47-debug.
function zeek_version%(%): string
%{
return new StringVal(zeek_version());
%}
## Converts a record type name to a vector of strings, where each element is
@ -2068,12 +2077,23 @@ function dump_rule_stats%(f: file%): bool
return val_mgr->GetBool(1);
%}
## Checks if Bro is terminating.
## Checks if Zeek is terminating. This function is deprecated, use
## :zeek:see:`zeek_is_terminating` instead.
##
## Returns: True if Bro is in the process of shutting down.
## Returns: True if Zeek is in the process of shutting down.
##
## .. zeek:see:: terminate
function bro_is_terminating%(%): bool
function bro_is_terminating%(%): bool &deprecated
%{
return val_mgr->GetBool(terminating);
%}
## Checks if Zeek is terminating.
##
## Returns: True if Zeek is in the process of shutting down.
##
## .. zeek:see:: terminate
function zeek_is_terminating%(%): bool
%{
return val_mgr->GetBool(terminating);
%}

View file

@ -127,7 +127,7 @@ OpaqueType* ocsp_resp_opaque_type = 0;
int bro_argc;
char** bro_argv;
const char* bro_version()
const char* zeek_version()
{
#ifdef DEBUG
static char* debug_version = 0;
@ -152,7 +152,7 @@ bool bro_dns_fake()
void usage(int code = 1)
{
fprintf(stderr, "bro version %s\n", bro_version());
fprintf(stderr, "zeek version %s\n", zeek_version());
fprintf(stderr, "usage: %s [options] [file ...]\n", prog);
fprintf(stderr, " <file> | policy file, or read stdin\n");
fprintf(stderr, " -a|--parse-only | exit immediately after parsing scripts\n");
@ -569,7 +569,7 @@ int main(int argc, char** argv)
break;
case 'v':
fprintf(stdout, "%s version %s\n", prog, bro_version());
fprintf(stdout, "%s version %s\n", prog, zeek_version());
exit(0);
break;

View file

@ -69,7 +69,7 @@ extern const char* hook_name(HookType h);
struct VersionNumber {
int major; //< Major version number.
int minor; //< Minor version number.
int patch; //< Patch version number (available since Bro 2.7).
int patch; //< Patch version number (available since Zeek 3.0).
/**
* Constructor.

View file

@ -3,7 +3,7 @@
event zeek_init()
{
local a = bro_version();
local a = zeek_version();
if ( |a| == 0 )
exit(1);
}

View file

@ -22,7 +22,7 @@ print Version::parse("1.12-beta-drunk");
print Version::parse("JustARandomString");
# check that current running version of Zeek parses without error
Version::parse(bro_version());
Version::parse(zeek_version());
@TEST-START-NEXT