mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes
* origin/master: (33 commits) Fix location where CI places build.tgz Update submodule(s) Disable some deprecation diagnostics for GCC Compare pcap_next_ex() result to PCAP_ERROR/PCAP_ERROR_BREAK Optimize Connection::RemovalEvent() for bare-mode usage Rename BroType to Type Update NEWS Review cleanup Move Type types to zeek namespace Review cleanup Restrict Cirrus CI to only zeek repo's branches GH-977: Improve pcap error handling Remove not-useful code in iosource::Manager::OpenPktSrc GH-999: Stop formatting DHCP Client ID Hardware Type 0 as MAC Remove inline from some static KeyedHash members Improve Func.h inclusion Fix NVT analyzer memory leak from multiple telnet authn name options Rename aux/ to auxil/ Move Flare/Pipe from the bro namespace to zeek::detail Move Attr to the zeek::detail namespace ...
This commit is contained in:
commit
c8a3a90339
324 changed files with 4779 additions and 3673 deletions
32
.cirrus.yml
32
.cirrus.yml
|
@ -3,7 +3,7 @@ btest_jobs: &BTEST_JOBS 4
|
||||||
btest_retries: &BTEST_RETRIES 2
|
btest_retries: &BTEST_RETRIES 2
|
||||||
memory: &MEMORY 4GB
|
memory: &MEMORY 4GB
|
||||||
|
|
||||||
config: &CONFIG --build-type=release --enable-cpp-tests --disable-broker-tests
|
config: &CONFIG --build-type=release --enable-cpp-tests --disable-broker-tests --prefix=$CIRRUS_WORKING_DIR/install
|
||||||
memcheck_config: &MEMCHECK_CONFIG --build-type=debug --enable-cpp-tests --disable-broker-tests --sanitizers=address --enable-fuzzers
|
memcheck_config: &MEMCHECK_CONFIG --build-type=debug --enable-cpp-tests --disable-broker-tests --sanitizers=address --enable-fuzzers
|
||||||
|
|
||||||
resources_template: &RESOURCES_TEMPLATE
|
resources_template: &RESOURCES_TEMPLATE
|
||||||
|
@ -13,8 +13,12 @@ resources_template: &RESOURCES_TEMPLATE
|
||||||
ci_template: &CI_TEMPLATE
|
ci_template: &CI_TEMPLATE
|
||||||
only_if: >
|
only_if: >
|
||||||
$CIRRUS_PR != '' ||
|
$CIRRUS_PR != '' ||
|
||||||
$CIRRUS_BRANCH == 'master' ||
|
( $CIRRUS_REPO_NAME == 'zeek' &&
|
||||||
$CIRRUS_BRANCH =~ 'release/.*'
|
(
|
||||||
|
$CIRRUS_BRANCH == 'master' ||
|
||||||
|
$CIRRUS_BRANCH =~ 'release/.*'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Default timeout is 60 minutes, Cirrus hard limit is 120 minutes for free
|
# Default timeout is 60 minutes, Cirrus hard limit is 120 minutes for free
|
||||||
# tasks, so may as well ask for full time.
|
# tasks, so may as well ask for full time.
|
||||||
|
@ -53,6 +57,16 @@ env:
|
||||||
# the zeek-testing-private repository.
|
# the zeek-testing-private repository.
|
||||||
ZEEK_TESTING_PRIVATE_SSH_KEY: ENCRYPTED[!dbdba93df9c166f926480cebff52dab303589257b3b3ee53aa392021aff2881ed9aafefef26aa9a1b71a49d663d1361c!]
|
ZEEK_TESTING_PRIVATE_SSH_KEY: ENCRYPTED[!dbdba93df9c166f926480cebff52dab303589257b3b3ee53aa392021aff2881ed9aafefef26aa9a1b71a49d663d1361c!]
|
||||||
|
|
||||||
|
# This is the key used to create HMAC auth keys for the benchmark script. This
|
||||||
|
# was generated by creating a new key using openssl, and then running sha256
|
||||||
|
# on it.
|
||||||
|
ZEEK_BENCHMARK_HMAC_KEY: ENCRYPTED[412224bbea9652030da976537f4d96c79ee79a0ba5a2f93b6c32953e1be0362defdf5fa07b3dc54ae61f9a52be30eac7]
|
||||||
|
|
||||||
|
# This is the https endpoint host and port used for benchmarking. It's kept
|
||||||
|
# encrypted as a security measure to avoid leaking the host's information.
|
||||||
|
ZEEK_BENCHMARK_HOST: ENCRYPTED[62ecdc93e839800d754d09d9a9070e9cb9b209e7d7dd2472ba38648f786ff272d0e0ea71233d0910025f2c6f3771259c]
|
||||||
|
ZEEK_BENCHMARK_PORT: ENCRYPTED[fb34ae2d51bac798fc01da052f3772154e17bbe2c1c5615509e82935248e748053fda399a0caf909632b6272cebff9f4]
|
||||||
|
|
||||||
# Linux EOL timelines: https://linuxlifecycle.com/
|
# Linux EOL timelines: https://linuxlifecycle.com/
|
||||||
# Fedora (~13 months): https://fedoraproject.org/wiki/Fedora_Release_Life_Cycle
|
# Fedora (~13 months): https://fedoraproject.org/wiki/Fedora_Release_Life_Cycle
|
||||||
|
|
||||||
|
@ -70,6 +84,18 @@ centos7_task:
|
||||||
<< : *RESOURCES_TEMPLATE
|
<< : *RESOURCES_TEMPLATE
|
||||||
<< : *CI_TEMPLATE
|
<< : *CI_TEMPLATE
|
||||||
|
|
||||||
|
centos8_task:
|
||||||
|
container:
|
||||||
|
# CentOS 8 EOL: May 31, 2029
|
||||||
|
dockerfile: ci/centos-8/Dockerfile
|
||||||
|
<< : *RESOURCES_TEMPLATE
|
||||||
|
env:
|
||||||
|
ZEEK_CI_CREATE_ARTIFACT: 1
|
||||||
|
<< : *CI_TEMPLATE
|
||||||
|
upload_binary_artifacts:
|
||||||
|
path: build.tgz
|
||||||
|
benchmark_script: ./ci/benchmark.sh
|
||||||
|
|
||||||
debian9_task:
|
debian9_task:
|
||||||
container:
|
container:
|
||||||
# Debian 9 EOL: June 2022
|
# Debian 9 EOL: June 2022
|
||||||
|
|
44
.gitmodules
vendored
44
.gitmodules
vendored
|
@ -1,14 +1,14 @@
|
||||||
[submodule "aux/zeek-aux"]
|
[submodule "auxil/zeek-aux"]
|
||||||
path = aux/zeek-aux
|
path = auxil/zeek-aux
|
||||||
url = https://github.com/zeek/zeek-aux
|
url = https://github.com/zeek/zeek-aux
|
||||||
[submodule "aux/binpac"]
|
[submodule "auxil/binpac"]
|
||||||
path = aux/binpac
|
path = auxil/binpac
|
||||||
url = https://github.com/zeek/binpac
|
url = https://github.com/zeek/binpac
|
||||||
[submodule "aux/zeekctl"]
|
[submodule "auxil/zeekctl"]
|
||||||
path = aux/zeekctl
|
path = auxil/zeekctl
|
||||||
url = https://github.com/zeek/zeekctl
|
url = https://github.com/zeek/zeekctl
|
||||||
[submodule "aux/btest"]
|
[submodule "auxil/btest"]
|
||||||
path = aux/btest
|
path = auxil/btest
|
||||||
url = https://github.com/zeek/btest
|
url = https://github.com/zeek/btest
|
||||||
[submodule "cmake"]
|
[submodule "cmake"]
|
||||||
path = cmake
|
path = cmake
|
||||||
|
@ -16,27 +16,27 @@
|
||||||
[submodule "src/3rdparty"]
|
[submodule "src/3rdparty"]
|
||||||
path = src/3rdparty
|
path = src/3rdparty
|
||||||
url = https://github.com/zeek/zeek-3rdparty
|
url = https://github.com/zeek/zeek-3rdparty
|
||||||
[submodule "aux/broker"]
|
[submodule "auxil/broker"]
|
||||||
path = aux/broker
|
path = auxil/broker
|
||||||
url = https://github.com/zeek/broker
|
url = https://github.com/zeek/broker
|
||||||
[submodule "aux/netcontrol-connectors"]
|
[submodule "auxil/netcontrol-connectors"]
|
||||||
path = aux/netcontrol-connectors
|
path = auxil/netcontrol-connectors
|
||||||
url = https://github.com/zeek/zeek-netcontrol
|
url = https://github.com/zeek/zeek-netcontrol
|
||||||
[submodule "aux/bifcl"]
|
[submodule "auxil/bifcl"]
|
||||||
path = aux/bifcl
|
path = auxil/bifcl
|
||||||
url = https://github.com/zeek/bifcl
|
url = https://github.com/zeek/bifcl
|
||||||
[submodule "doc"]
|
[submodule "doc"]
|
||||||
path = doc
|
path = doc
|
||||||
url = https://github.com/zeek/zeek-docs
|
url = https://github.com/zeek/zeek-docs
|
||||||
[submodule "aux/paraglob"]
|
[submodule "auxil/paraglob"]
|
||||||
path = aux/paraglob
|
path = auxil/paraglob
|
||||||
url = https://github.com/zeek/paraglob
|
url = https://github.com/zeek/paraglob
|
||||||
[submodule "aux/rapidjson"]
|
[submodule "auxil/rapidjson"]
|
||||||
path = aux/rapidjson
|
path = auxil/rapidjson
|
||||||
url = https://github.com/zeek/rapidjson
|
url = https://github.com/zeek/rapidjson
|
||||||
[submodule "aux/libkqueue"]
|
[submodule "auxil/libkqueue"]
|
||||||
path = aux/libkqueue
|
path = auxil/libkqueue
|
||||||
url = https://github.com/zeek/libkqueue
|
url = https://github.com/zeek/libkqueue
|
||||||
[submodule "aux/highwayhash"]
|
[submodule "auxil/highwayhash"]
|
||||||
path = aux/highwayhash
|
path = auxil/highwayhash
|
||||||
url = https://github.com/zeek/highwayhash
|
url = https://github.com/zeek/highwayhash
|
||||||
|
|
131
CHANGES
131
CHANGES
|
@ -1,4 +1,135 @@
|
||||||
|
|
||||||
|
3.2.0-dev.788 | 2020-06-15 11:04:20 -0700
|
||||||
|
|
||||||
|
* Fix location where CI places build.tgz (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
3.2.0-dev.787 | 2020-06-15 10:27:48 -0700
|
||||||
|
|
||||||
|
* Add new CI task for running benchmarks on a remote host (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
3.2.0-dev.783 | 2020-06-11 23:21:41 -0700
|
||||||
|
|
||||||
|
* Compare pcap_next_ex() result to PCAP_ERROR/PCAP_ERROR_BREAK (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
* GH-977: Improve pcap error handling (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Switches from pcap_next() to pcap_next_ex() to better handle all error
|
||||||
|
conditions. This allows, for example, to have a non-zero exit code for
|
||||||
|
a Zeek process that fails to fully process all packets in a pcap file.
|
||||||
|
|
||||||
|
* Remove not-useful code in iosource::Manager::OpenPktSrc (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
3.2.0-dev.779 | 2020-06-11 23:17:46 -0700
|
||||||
|
|
||||||
|
* Rename BroType to zeek::Type (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Move Type types to zeek namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Move Flare/Pipe from the bro namespace to zeek::detail (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Move Attr to the zeek::detail namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Move Trigger into the zeek::detail namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Move ID to the zeek::detail namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Move Anon.h into zeek::detail namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Mark all of the aliased classes in plugin/Plugin.h deprecated (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
And fix all of the plugins that were using them
|
||||||
|
|
||||||
|
* Move all of the base plugin classes into the zeek::plugin namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Expr: move all classes into zeek::detail (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Stmt: move Stmt classes into zeek::detail namespace (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
* Add utility macro for creating namespaced aliases for classes (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
|
3.2.0-dev.763 | 2020-06-10 16:34:31 -0700
|
||||||
|
|
||||||
|
* Optimize Connection::RemovalEvent() for bare-mode usage (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
It was creating RecordVals even if they wouldn't be used by any event
|
||||||
|
handler and that situation is common/expected for `zeek -b` mode.
|
||||||
|
Normally, there's at least the tunnel scripts with a `new_connection`
|
||||||
|
handler causing the connection RecordVals to be built.
|
||||||
|
|
||||||
|
3.2.0-dev.762 | 2020-06-09 15:19:15 -0700
|
||||||
|
|
||||||
|
* Restrict Cirrus CI to only zeek repo's branches (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
3.2.0-dev.761 | 2020-06-09 09:39:31 -0700
|
||||||
|
|
||||||
|
* Prevent IP fragment reassembly on packets without minimal IP header (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
The IP fragment reassembly process assumes a packet contains at least
|
||||||
|
the minimum IP header, but such a check did not previously occur,
|
||||||
|
resulting in a heap buffer over-read. For example, a self-reported
|
||||||
|
IPv4 IHL field with a value less than minimum IPv4 header length of
|
||||||
|
20 bytes. Such packets likely aren't routable on their own, but one
|
||||||
|
can create an artifical pcap like that or possibly encapsulate it
|
||||||
|
within another protocol to trigger this bug.
|
||||||
|
|
||||||
|
* Fix potential leak of Analyzers added to tree during Analyzer::Done (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Credit to OSS-Fuzz for discovery
|
||||||
|
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22630
|
||||||
|
|
||||||
|
* Fix multiple content-transfer-encoding headers causing a memory leak (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
The MIME analyzer may also leak if it sees many multipart boundary
|
||||||
|
parameters.
|
||||||
|
|
||||||
|
Credit to OSS-Fuzz for discovery
|
||||||
|
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22871
|
||||||
|
|
||||||
|
* Fix potential stack overflow in NVT analyzer (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
The NVT_Analyzer (e.g. as instantiated to support the FTP analyzer)
|
||||||
|
uses a recursive parsing function that may only advance one byte at a
|
||||||
|
time and can easily cause a stack overflow as a result. This change
|
||||||
|
replaces the recursive calls with equivalent iterative logic.
|
||||||
|
|
||||||
|
Credit to OSS-Fuzz for discovery
|
||||||
|
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22898
|
||||||
|
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22972
|
||||||
|
|
||||||
|
* Fix NVT analyzer memory leak from multiple telnet authn name options (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Credit to OSS-Fuzz for discovery
|
||||||
|
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23069
|
||||||
|
|
||||||
|
3.2.0-dev.751 | 2020-06-08 22:30:18 +0000
|
||||||
|
|
||||||
|
* GH-999: Stop formatting DHCP Client ID Hardware Type 0 as MAC
|
||||||
|
|
||||||
|
For `DHCP::ClientID$hwtype` fields equal to 0, the `hwaddr` field is
|
||||||
|
no longer misformatted as a MAC and instead just contains the raw bytes
|
||||||
|
seen in the DHCP Client ID Option. (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
3.2.0-dev.749 | 2020-06-08 11:22:45 -0700
|
||||||
|
|
||||||
|
* Remove inline from some static KeyedHash members (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Coverity Scan builds currently encounter catastrophic error, claiming
|
||||||
|
alignas requires use on both declaration and definition, so appears to
|
||||||
|
actually not understand "static inline" in combo with alignas.
|
||||||
|
|
||||||
|
* Improve Func.h inclusion (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Now forward declares some Broker types since Broker/CAF headers
|
||||||
|
generally slow things down and also Coverity Scan currently has a
|
||||||
|
catastrophic error on some CAF headers.
|
||||||
|
|
||||||
|
Also a few other changes to EventHandler/BifReturnVal to reduce number
|
||||||
|
of places that depend on Func.h.
|
||||||
|
|
||||||
|
* Rename aux/ to auxil/ (Jon Siwek, Corelight)
|
||||||
|
|
||||||
|
Since "aux" is not an allowed file/dir name on Windows.
|
||||||
|
|
||||||
3.2.0-dev.744 | 2020-06-04 15:11:56 -0700
|
3.2.0-dev.744 | 2020-06-04 15:11:56 -0700
|
||||||
|
|
||||||
* Fix use-after-move of proc_status_file breaking -U flag (Jon Siwek, Corelight)
|
* Fix use-after-move of proc_status_file breaking -U flag (Jon Siwek, Corelight)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# When changing the minimum version here, also adapt
|
# When changing the minimum version here, also adapt
|
||||||
# aux/zeek-aux/plugin-support/skeleton/CMakeLists.txt
|
# auxil/zeek-aux/plugin-support/skeleton/CMakeLists.txt
|
||||||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
||||||
|
|
||||||
project(Zeek C CXX)
|
project(Zeek C CXX)
|
||||||
|
@ -186,7 +186,7 @@ FindRequiredPackage(OpenSSL)
|
||||||
FindRequiredPackage(BIND)
|
FindRequiredPackage(BIND)
|
||||||
FindRequiredPackage(ZLIB)
|
FindRequiredPackage(ZLIB)
|
||||||
|
|
||||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/binpac/CMakeLists.txt)
|
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/auxil/binpac/CMakeLists.txt)
|
||||||
|
|
||||||
set(ENABLE_STATIC_ONLY_SAVED ${ENABLE_STATIC_ONLY})
|
set(ENABLE_STATIC_ONLY_SAVED ${ENABLE_STATIC_ONLY})
|
||||||
|
|
||||||
|
@ -194,13 +194,13 @@ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/binpac/CMakeLists.txt)
|
||||||
set(ENABLE_STATIC_ONLY true)
|
set(ENABLE_STATIC_ONLY true)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(aux/binpac)
|
add_subdirectory(auxil/binpac)
|
||||||
set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED})
|
set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED})
|
||||||
endif ()
|
endif ()
|
||||||
FindRequiredPackage(BinPAC)
|
FindRequiredPackage(BinPAC)
|
||||||
|
|
||||||
if ( NOT BIFCL_EXE_PATH )
|
if ( NOT BIFCL_EXE_PATH )
|
||||||
add_subdirectory(aux/bifcl)
|
add_subdirectory(auxil/bifcl)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (ENABLE_JEMALLOC)
|
if (ENABLE_JEMALLOC)
|
||||||
|
@ -228,7 +228,7 @@ if ( CAF_ROOT_DIR )
|
||||||
find_package(CAF COMPONENTS core io openssl REQUIRED)
|
find_package(CAF COMPONENTS core io openssl REQUIRED)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_subdirectory(aux/paraglob)
|
add_subdirectory(auxil/paraglob)
|
||||||
set(zeekdeps ${zeekdeps} paraglob)
|
set(zeekdeps ${zeekdeps} paraglob)
|
||||||
|
|
||||||
if ( BROKER_ROOT_DIR )
|
if ( BROKER_ROOT_DIR )
|
||||||
|
@ -250,7 +250,7 @@ else ()
|
||||||
set(ENABLE_STATIC_ONLY true)
|
set(ENABLE_STATIC_ONLY true)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(aux/broker)
|
add_subdirectory(auxil/broker)
|
||||||
set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED})
|
set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED})
|
||||||
|
|
||||||
if ( BUILD_STATIC_BROKER )
|
if ( BUILD_STATIC_BROKER )
|
||||||
|
@ -258,17 +258,17 @@ else ()
|
||||||
else()
|
else()
|
||||||
set(zeekdeps ${zeekdeps} broker)
|
set(zeekdeps ${zeekdeps} broker)
|
||||||
endif()
|
endif()
|
||||||
set(broker_includes ${CMAKE_CURRENT_SOURCE_DIR}/aux/broker/include ${CMAKE_CURRENT_BINARY_DIR}/aux/broker/include)
|
set(broker_includes ${CMAKE_CURRENT_SOURCE_DIR}/auxil/broker/include ${CMAKE_CURRENT_BINARY_DIR}/auxil/broker/include)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# CAF_LIBRARIES and CAF_INCLUDE_DIRS are defined either by calling
|
# CAF_LIBRARIES and CAF_INCLUDE_DIRS are defined either by calling
|
||||||
# find_package(CAF) or by calling add_subdirectory(aux/broker). In either case,
|
# find_package(CAF) or by calling add_subdirectory(auxil/broker). In either case,
|
||||||
# we have to care about CAF here because Broker headers can pull in CAF
|
# we have to care about CAF here because Broker headers can pull in CAF
|
||||||
# headers.
|
# headers.
|
||||||
set(zeekdeps ${zeekdeps} ${CAF_LIBRARIES})
|
set(zeekdeps ${zeekdeps} ${CAF_LIBRARIES})
|
||||||
include_directories(BEFORE ${broker_includes} ${CAF_INCLUDE_DIRS})
|
include_directories(BEFORE ${broker_includes} ${CAF_INCLUDE_DIRS})
|
||||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/aux/paraglob/include)
|
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/auxil/paraglob/include)
|
||||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/aux/rapidjson/include)
|
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/auxil/rapidjson/include)
|
||||||
include_directories(BEFORE
|
include_directories(BEFORE
|
||||||
${PCAP_INCLUDE_DIR}
|
${PCAP_INCLUDE_DIR}
|
||||||
${BIND_INCLUDE_DIR}
|
${BIND_INCLUDE_DIR}
|
||||||
|
@ -277,7 +277,7 @@ include_directories(BEFORE
|
||||||
${JEMALLOC_INCLUDE_DIR}
|
${JEMALLOC_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/aux/rapidjson/include/rapidjson
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/auxil/rapidjson/include/rapidjson
|
||||||
DESTINATION include/zeek/3rdparty/rapidjson/include)
|
DESTINATION include/zeek/3rdparty/rapidjson/include)
|
||||||
|
|
||||||
# Optional Dependencies
|
# Optional Dependencies
|
||||||
|
@ -332,7 +332,7 @@ endif ()
|
||||||
include_directories(BEFORE ${OPENSSL_INCLUDE_DIR})
|
include_directories(BEFORE ${OPENSSL_INCLUDE_DIR})
|
||||||
|
|
||||||
# Make everyone find the highwayhash includes
|
# Make everyone find the highwayhash includes
|
||||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/aux/highwayhash)
|
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/auxil/highwayhash)
|
||||||
|
|
||||||
# Alpine support
|
# Alpine support
|
||||||
if ( ${CMAKE_SYSTEM_NAME} MATCHES Linux AND EXISTS /etc/os-release )
|
if ( ${CMAKE_SYSTEM_NAME} MATCHES Linux AND EXISTS /etc/os-release )
|
||||||
|
@ -437,8 +437,8 @@ add_subdirectory(man)
|
||||||
|
|
||||||
include(CheckOptionalBuildSources)
|
include(CheckOptionalBuildSources)
|
||||||
|
|
||||||
CheckOptionalBuildSources(aux/zeekctl ZeekControl INSTALL_ZEEKCTL)
|
CheckOptionalBuildSources(auxil/zeekctl ZeekControl INSTALL_ZEEKCTL)
|
||||||
CheckOptionalBuildSources(aux/zeek-aux Zeek-Aux INSTALL_AUX_TOOLS)
|
CheckOptionalBuildSources(auxil/zeek-aux Zeek-Aux INSTALL_AUX_TOOLS)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
## Packaging Setup
|
## Packaging Setup
|
||||||
|
|
|
@ -500,7 +500,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
%%% aux/highwayhash
|
%%% auxil/highwayhash
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -42,7 +42,7 @@ dist:
|
||||||
@tar -czf $(VERSION_FULL).tar.gz $(VERSION_FULL)
|
@tar -czf $(VERSION_FULL).tar.gz $(VERSION_FULL)
|
||||||
@echo Package: $(VERSION_FULL).tar.gz
|
@echo Package: $(VERSION_FULL).tar.gz
|
||||||
@mv $(VERSION_FULL) $(VERSION_MIN)
|
@mv $(VERSION_FULL) $(VERSION_MIN)
|
||||||
@(cd $(VERSION_MIN) && for i in aux/*; do rm -rf $$i/*; done)
|
@(cd $(VERSION_MIN) && for i in auxil/*; do rm -rf $$i/*; done)
|
||||||
@tar -czf $(VERSION_MIN).tar.gz $(VERSION_MIN)
|
@tar -czf $(VERSION_MIN).tar.gz $(VERSION_MIN)
|
||||||
@echo Package: $(VERSION_MIN).tar.gz
|
@echo Package: $(VERSION_MIN).tar.gz
|
||||||
@rm -rf $(VERSION_MIN)
|
@rm -rf $(VERSION_MIN)
|
||||||
|
@ -55,10 +55,10 @@ test:
|
||||||
-@( cd testing && make )
|
-@( cd testing && make )
|
||||||
|
|
||||||
test-aux:
|
test-aux:
|
||||||
-test -d aux/zeekctl && ( cd aux/zeekctl && make test-all )
|
-test -d auxil/zeekctl && ( cd auxil/zeekctl && make test-all )
|
||||||
-test -d aux/btest && ( cd aux/btest && make test )
|
-test -d auxil/btest && ( cd auxil/btest && make test )
|
||||||
-test -d aux/zeek-aux && ( cd aux/zeek-aux && make test )
|
-test -d auxil/zeek-aux && ( cd auxil/zeek-aux && make test )
|
||||||
-test -d aux/plugins && ( cd aux/plugins && make test-all )
|
-test -d auxil/plugins && ( cd auxil/plugins && make test-all )
|
||||||
|
|
||||||
test-all: test test-aux
|
test-all: test test-aux
|
||||||
|
|
||||||
|
|
16
NEWS
16
NEWS
|
@ -83,7 +83,7 @@ Changed Functionality
|
||||||
|
|
||||||
- "using namespace std" was removed from the Zeek header files; Zeek now always
|
- "using namespace std" was removed from the Zeek header files; Zeek now always
|
||||||
explicitly specifies std when using STL functionality in headers. This may
|
explicitly specifies std when using STL functionality in headers. This may
|
||||||
necessitate small changes in external plugins, if they relied on the using
|
necessitate small changes in external plugins, if they relied on the using
|
||||||
statement in Zeek headers.
|
statement in Zeek headers.
|
||||||
|
|
||||||
- The ``connection_external`` event was removed. This functionality that could
|
- The ``connection_external`` event was removed. This functionality that could
|
||||||
|
@ -107,6 +107,14 @@ Changed Functionality
|
||||||
- ``Attributes::Attrs()`` now returns ``const std::vector<IntrusivePtr<Attr>>&``
|
- ``Attributes::Attrs()`` now returns ``const std::vector<IntrusivePtr<Attr>>&``
|
||||||
instead of ``attr_list*``
|
instead of ``attr_list*``
|
||||||
|
|
||||||
|
- Moved a large number of classes from the global namespace into either the
|
||||||
|
``zeek`` or ``zeek::detail`` namespace. See https://github.com/zeek/zeek/issues/266
|
||||||
|
for the rationale behind these changes. Most types that were moved and functions
|
||||||
|
that used them have been marked as deprecated and will generate compiler
|
||||||
|
warnings if used (a few exceptions will not generate compiler warnings,
|
||||||
|
but the Deprecated Functionality section below will mention those
|
||||||
|
ones specifically).
|
||||||
|
|
||||||
Removed Functionality
|
Removed Functionality
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
@ -124,6 +132,12 @@ Deprecated Functionality
|
||||||
method to now use is called ``HookFunctionCall`` and uses ``IntrusivePtr``
|
method to now use is called ``HookFunctionCall`` and uses ``IntrusivePtr``
|
||||||
arguments and return value.
|
arguments and return value.
|
||||||
|
|
||||||
|
- The ``plugin::Plugin::MetaHookPre()`` and ``MetaHookPost()`` methods are
|
||||||
|
deprecated. Note that compilers will not emit a deprecation warning, but
|
||||||
|
the replacement methods are named the same except use
|
||||||
|
``zeek::plugin::HookType`` arguments (the type is now from the "zeek"
|
||||||
|
namespace).
|
||||||
|
|
||||||
- The ``Func::Call(val_list*, ...)`` method is now deprecated. Use ``Invoke()``
|
- The ``Func::Call(val_list*, ...)`` method is now deprecated. Use ``Invoke()``
|
||||||
instead which takes a ``zeek::Args`` (``std::vector<IntrusivePtr<Val>>``).
|
instead which takes a ``zeek::Args`` (``std::vector<IntrusivePtr<Val>>``).
|
||||||
There's also a variadic template for ``Invoke()`` that forwards all arguments
|
There's also a variadic template for ``Invoke()`` that forwards all arguments
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
3.2.0-dev.744
|
3.2.0-dev.788
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 7d474ff6ac0ff1870eef6159bef93a1bfed953df
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 8bba3c45c85d99752dc6f8da9b40b768e3c39804
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 8615abced86b5559fa3203264be55e664b887094
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit bee11c63923b69a4468838d56067f15bc6ae3a52
|
|
1
auxil/bifcl
Submodule
1
auxil/bifcl
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 9c10bb74bb62aa7fb10efc079f1b2e5926e9798c
|
1
auxil/broker
Submodule
1
auxil/broker
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 1db381f1d145164db6c9ce1025833e6a2c0b2b8f
|
1
auxil/zeek-aux
Submodule
1
auxil/zeek-aux
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 131e9fb1184af9da29745b5fb27d4cd59fc6825d
|
1
auxil/zeekctl
Submodule
1
auxil/zeekctl
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6e39564420c47b3fd6d03d4383758d7871bc87bf
|
43
ci/benchmark.sh
Executable file
43
ci/benchmark.sh
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
ZEEK_BENCHMARK_ENDPOINT="/zeek"
|
||||||
|
|
||||||
|
# Setting this causes any command failures to immediately cause the script to fail.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Don't do this for any branch that isn't from the main zeek repo.
|
||||||
|
# TODO: is it possible to do this from cirrus.yml instead of here?
|
||||||
|
if [ "${CIRRUS_REPO_OWNER}" != "zeek" ]; then
|
||||||
|
echo "Benchmarks are skipped for repositories outside of the main Zeek project"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_URL="https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/${CIRRUS_TASK_NAME}/upload_binary/build.tgz"
|
||||||
|
|
||||||
|
# Generate an md5 hash of the build file. We can do this here because the path to the
|
||||||
|
# file still exists from the prior scripts.
|
||||||
|
BUILD_HASH=$(sha256sum build.tgz | awk '{print $1}')
|
||||||
|
|
||||||
|
# Generate an HMAC digest for the path plus a timestamp to send as an authentication
|
||||||
|
# header. Openssl outputs a hex string here so there's no need to base64 encode it.
|
||||||
|
TIMESTAMP=$(date -u +'%s')
|
||||||
|
HMAC_DIGEST=$(echo "${ZEEK_BENCHMARK_ENDPOINT}-${TIMESTAMP}-${BUILD_HASH}" | openssl dgst -sha256 -hmac ${ZEEK_BENCHMARK_HMAC_KEY} | awk '{print $2}')
|
||||||
|
|
||||||
|
TARGET="https://${ZEEK_BENCHMARK_HOST}:${ZEEK_BENCHMARK_PORT}${ZEEK_BENCHMARK_ENDPOINT}"
|
||||||
|
|
||||||
|
# Turn this back off because we want to be able to capture the output from curl if
|
||||||
|
# it fails.
|
||||||
|
set +e
|
||||||
|
|
||||||
|
# Make a request to the benchmark host.
|
||||||
|
RESULTS=$(curl -sS --stderr - --fail --insecure -X POST -H "Zeek-HMAC: ${HMAC_DIGEST}" -H "Zeek-HMAC-Timestamp: ${TIMESTAMP}" "${TARGET}?branch=${CIRRUS_BRANCH}&build=${BUILD_URL}&build_hash=${BUILD_HASH}")
|
||||||
|
STATUS=$?
|
||||||
|
|
||||||
|
# If we got a bad status back from the host, we want to make sure to mask the host
|
||||||
|
# and port from the output.
|
||||||
|
if [ $STATUS -ne 0 ]; then
|
||||||
|
RESULTS=$(echo "${RESULTS}" | sed "s/${ZEEK_BENCHMARK_HOST}/<secret>/g" | sed "s/:${ZEEK_BENCHMARK_PORT}/:<secret>/g")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$RESULTS"
|
||||||
|
exit $STATUS
|
14
ci/build.sh
14
ci/build.sh
|
@ -3,6 +3,14 @@
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
./configure ${ZEEK_CI_CONFIGURE_FLAGS}
|
if [ "${ZEEK_CI_CREATE_ARTIFACT}" != "1" ]; then
|
||||||
cd build
|
./configure ${ZEEK_CI_CONFIGURE_FLAGS}
|
||||||
make -j ${ZEEK_CI_CPUS}
|
cd build
|
||||||
|
make -j ${ZEEK_CI_CPUS}
|
||||||
|
else
|
||||||
|
./configure ${ZEEK_CI_CONFIGURE_FLAGS} --prefix=${CIRRUS_WORKING_DIR}/install
|
||||||
|
cd build
|
||||||
|
make -j ${ZEEK_CI_CPUS} install
|
||||||
|
cd ..
|
||||||
|
tar -czf build.tgz ${CIRRUS_WORKING_DIR}/install
|
||||||
|
fi
|
||||||
|
|
35
ci/centos-8/Dockerfile
Normal file
35
ci/centos-8/Dockerfile
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
FROM centos:8
|
||||||
|
|
||||||
|
RUN dnf -y install epel-release dnf-plugins-core \
|
||||||
|
&& dnf clean all && rm -rf /var/cache/dnf
|
||||||
|
|
||||||
|
RUN dnf config-manager --set-enabled PowerTools
|
||||||
|
|
||||||
|
RUN dnf -y update && dnf -y install \
|
||||||
|
git \
|
||||||
|
cmake3 \
|
||||||
|
make \
|
||||||
|
gcc \
|
||||||
|
gcc-c++ \
|
||||||
|
flex \
|
||||||
|
bison \
|
||||||
|
swig \
|
||||||
|
openssl \
|
||||||
|
openssl-devel \
|
||||||
|
libpcap-devel \
|
||||||
|
python3 \
|
||||||
|
python3-devel \
|
||||||
|
python3-pip \
|
||||||
|
zlib-devel \
|
||||||
|
libsqlite3x-devel \
|
||||||
|
findutils \
|
||||||
|
which \
|
||||||
|
&& dnf clean all && rm -rf /var/cache/dnf
|
||||||
|
|
||||||
|
# Many distros adhere to PEP 394's recommendation for `python` = `python2` so
|
||||||
|
# this is a simple workaround until we drop Python 2 support and explicitly
|
||||||
|
# use `python3` for all invocations (e.g. in shebangs).
|
||||||
|
RUN ln -sf /usr/bin/python3 /usr/local/bin/python
|
||||||
|
RUN ln -sf /usr/bin/pip3 /usr/local/bin/pip
|
||||||
|
|
||||||
|
RUN pip install junit2html
|
|
@ -5,7 +5,7 @@
|
||||||
# the value of `nproc` if available, otherwise just a single core.
|
# the value of `nproc` if available, otherwise just a single core.
|
||||||
|
|
||||||
result=0
|
result=0
|
||||||
BTEST=$(pwd)/aux/btest/btest
|
BTEST=$(pwd)/auxil/btest/btest
|
||||||
|
|
||||||
if [[ -z "${CIRRUS_CI}" ]]; then
|
if [[ -z "${CIRRUS_CI}" ]]; then
|
||||||
# Set default values to use in place of env. variables set by Cirrus CI.
|
# Set default values to use in place of env. variables set by Cirrus CI.
|
||||||
|
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
||||||
Subproject commit 23f4b88f91c537c59ef9a3ad56ec08f021ec2b2c
|
Subproject commit 6cb83a5a4a41adb7f7a5cc97661088caaa863180
|
2
doc
2
doc
|
@ -1 +1 @@
|
||||||
Subproject commit 23dbe360d105d1ffadc231b1d9fb06dea437b110
|
Subproject commit 60546010f9d0e5858b79e01a2982cd6c5b64323b
|
12
src/Anon.cc
12
src/Anon.cc
|
@ -14,7 +14,9 @@
|
||||||
#include "ID.h"
|
#include "ID.h"
|
||||||
#include "IPAddr.h"
|
#include "IPAddr.h"
|
||||||
|
|
||||||
AnonymizeIPAddr* ip_anonymizer[NUM_ADDR_ANONYMIZATION_METHODS] = {nullptr};
|
using namespace zeek::detail;
|
||||||
|
|
||||||
|
AnonymizeIPAddr* zeek::detail::ip_anonymizer[NUM_ADDR_ANONYMIZATION_METHODS] = {nullptr};
|
||||||
|
|
||||||
static uint32_t rand32()
|
static uint32_t rand32()
|
||||||
{
|
{
|
||||||
|
@ -22,7 +24,7 @@ static uint32_t rand32()
|
||||||
}
|
}
|
||||||
|
|
||||||
// From tcpdpriv.
|
// From tcpdpriv.
|
||||||
int bi_ffs(uint32_t value)
|
static int bi_ffs(uint32_t value)
|
||||||
{
|
{
|
||||||
int add = 0;
|
int add = 0;
|
||||||
static uint8_t bvals[] = {
|
static uint8_t bvals[] = {
|
||||||
|
@ -360,7 +362,7 @@ static IntrusivePtr<TableVal> anon_preserve_orig_addr;
|
||||||
static IntrusivePtr<TableVal> anon_preserve_resp_addr;
|
static IntrusivePtr<TableVal> anon_preserve_resp_addr;
|
||||||
static IntrusivePtr<TableVal> anon_preserve_other_addr;
|
static IntrusivePtr<TableVal> anon_preserve_other_addr;
|
||||||
|
|
||||||
void init_ip_addr_anonymizers()
|
void zeek::detail::init_ip_addr_anonymizers()
|
||||||
{
|
{
|
||||||
ip_anonymizer[KEEP_ORIG_ADDR] = nullptr;
|
ip_anonymizer[KEEP_ORIG_ADDR] = nullptr;
|
||||||
ip_anonymizer[SEQUENTIALLY_NUMBERED] = new AnonymizeIPAddr_Seq();
|
ip_anonymizer[SEQUENTIALLY_NUMBERED] = new AnonymizeIPAddr_Seq();
|
||||||
|
@ -384,7 +386,7 @@ void init_ip_addr_anonymizers()
|
||||||
anon_preserve_other_addr = cast_intrusive<TableVal>(id->GetVal());
|
anon_preserve_other_addr = cast_intrusive<TableVal>(id->GetVal());
|
||||||
}
|
}
|
||||||
|
|
||||||
ipaddr32_t anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_class_t cl)
|
ipaddr32_t zeek::detail::anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_class_t cl)
|
||||||
{
|
{
|
||||||
TableVal* preserve_addr = nullptr;
|
TableVal* preserve_addr = nullptr;
|
||||||
auto addr = make_intrusive<AddrVal>(ip);
|
auto addr = make_intrusive<AddrVal>(ip);
|
||||||
|
@ -439,7 +441,7 @@ ipaddr32_t anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_class_t cl)
|
||||||
#include "NetVar.h"
|
#include "NetVar.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
void log_anonymization_mapping(ipaddr32_t input, ipaddr32_t output)
|
void zeek::detail::log_anonymization_mapping(ipaddr32_t input, ipaddr32_t output)
|
||||||
{
|
{
|
||||||
if ( anonymization_mapping )
|
if ( anonymization_mapping )
|
||||||
mgr.Enqueue(anonymization_mapping,
|
mgr.Enqueue(anonymization_mapping,
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
// TODO: Anon.h may not be the right place to put these functions ...
|
// TODO: Anon.h may not be the right place to put these functions ...
|
||||||
|
|
||||||
enum ip_addr_anonymization_class_t {
|
enum ip_addr_anonymization_class_t {
|
||||||
|
@ -126,3 +128,5 @@ ipaddr32_t anonymize_ip(ipaddr32_t ip, enum ip_addr_anonymization_class_t cl);
|
||||||
|
|
||||||
#define LOG_ANONYMIZATION_MAPPING
|
#define LOG_ANONYMIZATION_MAPPING
|
||||||
void log_anonymization_mapping(ipaddr32_t input, ipaddr32_t output);
|
void log_anonymization_mapping(ipaddr32_t input, ipaddr32_t output);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
36
src/Attr.cc
36
src/Attr.cc
|
@ -9,6 +9,8 @@
|
||||||
#include "IntrusivePtr.h"
|
#include "IntrusivePtr.h"
|
||||||
#include "threading/SerialTypes.h"
|
#include "threading/SerialTypes.h"
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
const char* attr_name(attr_tag t)
|
const char* attr_name(attr_tag t)
|
||||||
{
|
{
|
||||||
static const char* attr_names[int(NUM_ATTRS)] = {
|
static const char* attr_names[int(NUM_ATTRS)] = {
|
||||||
|
@ -36,9 +38,20 @@ Attr::Attr(attr_tag t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
Attr::Attr(::attr_tag t, IntrusivePtr<Expr> e) : Attr(static_cast<attr_tag>(t), e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Attr::Attr(::attr_tag t) : Attr(static_cast<attr_tag>(t))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
Attr::~Attr() = default;
|
Attr::~Attr() = default;
|
||||||
|
|
||||||
void Attr::SetAttrExpr(IntrusivePtr<Expr> e)
|
void Attr::SetAttrExpr(IntrusivePtr<zeek::detail::Expr> e)
|
||||||
{ expr = std::move(e); }
|
{ expr = std::move(e); }
|
||||||
|
|
||||||
void Attr::Describe(ODesc* d) const
|
void Attr::Describe(ODesc* d) const
|
||||||
|
@ -137,7 +150,7 @@ void Attr::AddTag(ODesc* d) const
|
||||||
d->Add(attr_name(Tag()));
|
d->Add(attr_name(Tag()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes::Attributes(attr_list* a, IntrusivePtr<BroType> t, bool arg_in_record, bool is_global)
|
Attributes::Attributes(attr_list* a, IntrusivePtr<Type> t, bool arg_in_record, bool is_global)
|
||||||
{
|
{
|
||||||
attrs.reserve(a->length());
|
attrs.reserve(a->length());
|
||||||
in_record = arg_in_record;
|
in_record = arg_in_record;
|
||||||
|
@ -155,14 +168,14 @@ Attributes::Attributes(attr_list* a, IntrusivePtr<BroType> t, bool arg_in_record
|
||||||
delete a;
|
delete a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes::Attributes(IntrusivePtr<BroType> t,
|
Attributes::Attributes(IntrusivePtr<Type> t,
|
||||||
bool arg_in_record, bool is_global)
|
bool arg_in_record, bool is_global)
|
||||||
: Attributes(std::vector<IntrusivePtr<Attr>>{}, std::move(t),
|
: Attributes(std::vector<IntrusivePtr<Attr>>{}, std::move(t),
|
||||||
arg_in_record, is_global)
|
arg_in_record, is_global)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Attributes::Attributes(std::vector<IntrusivePtr<Attr>> a,
|
Attributes::Attributes(std::vector<IntrusivePtr<Attr>> a,
|
||||||
IntrusivePtr<BroType> t,
|
IntrusivePtr<Type> t,
|
||||||
bool arg_in_record, bool is_global)
|
bool arg_in_record, bool is_global)
|
||||||
: type(std::move(t))
|
: type(std::move(t))
|
||||||
{
|
{
|
||||||
|
@ -245,6 +258,19 @@ void Attributes::RemoveAttr(attr_tag t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
Attr* Attributes::FindAttr(::attr_tag t) const
|
||||||
|
{
|
||||||
|
return FindAttr(static_cast<attr_tag>(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Attributes::RemoveAttr(::attr_tag t)
|
||||||
|
{
|
||||||
|
RemoveAttr(static_cast<attr_tag>(t));
|
||||||
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
void Attributes::Describe(ODesc* d) const
|
void Attributes::Describe(ODesc* d) const
|
||||||
{
|
{
|
||||||
if ( attrs.empty() )
|
if ( attrs.empty() )
|
||||||
|
@ -686,3 +712,5 @@ bool Attributes::operator==(const Attributes& other) const
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
74
src/Attr.h
74
src/Attr.h
|
@ -8,13 +8,13 @@
|
||||||
#include "BroList.h"
|
#include "BroList.h"
|
||||||
#include "IntrusivePtr.h"
|
#include "IntrusivePtr.h"
|
||||||
|
|
||||||
class Expr;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
// Note that there are two kinds of attributes: the kind (here) which
|
// Note that there are two kinds of attributes: the kind (here) which
|
||||||
// modify expressions or supply metadata on types, and the kind that
|
// modify expressions or supply metadata on types, and the kind that
|
||||||
// are extra metadata on every variable instance.
|
// are extra metadata on every variable instance.
|
||||||
|
|
||||||
typedef enum {
|
enum [[deprecated("Remove in v4.1. Use zeek::detail::attr_tag instead.")]] attr_tag {
|
||||||
ATTR_OPTIONAL,
|
ATTR_OPTIONAL,
|
||||||
ATTR_DEFAULT,
|
ATTR_DEFAULT,
|
||||||
ATTR_REDEF,
|
ATTR_REDEF,
|
||||||
|
@ -34,26 +34,61 @@ typedef enum {
|
||||||
ATTR_ON_CHANGE, // for table change tracking
|
ATTR_ON_CHANGE, // for table change tracking
|
||||||
ATTR_BROKER_STORE, // for broker-store backed tables
|
ATTR_BROKER_STORE, // for broker-store backed tables
|
||||||
ATTR_DEPRECATED,
|
ATTR_DEPRECATED,
|
||||||
#define NUM_ATTRS (int(ATTR_DEPRECATED) + 1)
|
NUM_ATTRS // this item should always be last
|
||||||
} attr_tag;
|
};
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
enum attr_tag {
|
||||||
|
ATTR_OPTIONAL,
|
||||||
|
ATTR_DEFAULT,
|
||||||
|
ATTR_REDEF,
|
||||||
|
ATTR_ADD_FUNC,
|
||||||
|
ATTR_DEL_FUNC,
|
||||||
|
ATTR_EXPIRE_FUNC,
|
||||||
|
ATTR_EXPIRE_READ,
|
||||||
|
ATTR_EXPIRE_WRITE,
|
||||||
|
ATTR_EXPIRE_CREATE,
|
||||||
|
ATTR_RAW_OUTPUT,
|
||||||
|
ATTR_PRIORITY,
|
||||||
|
ATTR_GROUP,
|
||||||
|
ATTR_LOG,
|
||||||
|
ATTR_ERROR_HANDLER,
|
||||||
|
ATTR_TYPE_COLUMN, // for input framework
|
||||||
|
ATTR_TRACKED, // hidden attribute, tracked by NotifierRegistry
|
||||||
|
ATTR_ON_CHANGE, // for table change tracking
|
||||||
|
ATTR_BROKER_STORE, // for broker-store backed tables
|
||||||
|
ATTR_DEPRECATED,
|
||||||
|
NUM_ATTRS // this item should always be last
|
||||||
|
};
|
||||||
|
|
||||||
class Attr final : public BroObj {
|
class Attr final : public BroObj {
|
||||||
public:
|
public:
|
||||||
static inline const IntrusivePtr<Attr> nil;
|
static inline const IntrusivePtr<zeek::detail::Attr> nil;
|
||||||
|
|
||||||
Attr(attr_tag t, IntrusivePtr<Expr> e);
|
Attr(attr_tag t, IntrusivePtr<zeek::detail::Expr> e);
|
||||||
explicit Attr(attr_tag t);
|
explicit Attr(attr_tag t);
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]]
|
||||||
|
Attr(::attr_tag t, IntrusivePtr<zeek::detail::Expr> e);
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]]
|
||||||
|
explicit Attr(::attr_tag t);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
~Attr() override;
|
~Attr() override;
|
||||||
|
|
||||||
attr_tag Tag() const { return tag; }
|
attr_tag Tag() const { return tag; }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetExpr().")]]
|
[[deprecated("Remove in v4.1. Use GetExpr().")]]
|
||||||
Expr* AttrExpr() const { return expr.get(); }
|
zeek::detail::Expr* AttrExpr() const { return expr.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<Expr>& GetExpr() const
|
const IntrusivePtr<zeek::detail::Expr>& GetExpr() const
|
||||||
{ return expr; }
|
{ return expr; }
|
||||||
|
|
||||||
void SetAttrExpr(IntrusivePtr<Expr> e);
|
void SetAttrExpr(IntrusivePtr<zeek::detail::Expr> e);
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
void DescribeReST(ODesc* d, bool shorten = false) const;
|
void DescribeReST(ODesc* d, bool shorten = false) const;
|
||||||
|
@ -83,11 +118,11 @@ protected:
|
||||||
class Attributes final : public BroObj {
|
class Attributes final : public BroObj {
|
||||||
public:
|
public:
|
||||||
[[deprecated("Remove in v4.1. Construct using IntrusivePtrs instead.")]]
|
[[deprecated("Remove in v4.1. Construct using IntrusivePtrs instead.")]]
|
||||||
Attributes(attr_list* a, IntrusivePtr<BroType> t, bool in_record, bool is_global);
|
Attributes(attr_list* a, IntrusivePtr<Type> t, bool in_record, bool is_global);
|
||||||
|
|
||||||
Attributes(std::vector<IntrusivePtr<Attr>> a, IntrusivePtr<BroType> t,
|
Attributes(std::vector<IntrusivePtr<Attr>> a, IntrusivePtr<Type> t,
|
||||||
bool in_record, bool is_global);
|
bool in_record, bool is_global);
|
||||||
Attributes(IntrusivePtr<BroType> t, bool in_record, bool is_global);
|
Attributes(IntrusivePtr<Type> t, bool in_record, bool is_global);
|
||||||
|
|
||||||
void AddAttr(IntrusivePtr<Attr> a);
|
void AddAttr(IntrusivePtr<Attr> a);
|
||||||
|
|
||||||
|
@ -103,6 +138,14 @@ public:
|
||||||
|
|
||||||
void RemoveAttr(attr_tag t);
|
void RemoveAttr(attr_tag t);
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]]
|
||||||
|
Attr* FindAttr(::attr_tag t) const;
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag.")]]
|
||||||
|
void RemoveAttr(::attr_tag t);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
void DescribeReST(ODesc* d, bool shorten = false) const;
|
void DescribeReST(ODesc* d, bool shorten = false) const;
|
||||||
|
|
||||||
|
@ -114,8 +157,13 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void CheckAttr(Attr* attr);
|
void CheckAttr(Attr* attr);
|
||||||
|
|
||||||
IntrusivePtr<BroType> type;
|
IntrusivePtr<Type> type;
|
||||||
std::vector<IntrusivePtr<Attr>> attrs;
|
std::vector<IntrusivePtr<Attr>> attrs;
|
||||||
bool in_record;
|
bool in_record;
|
||||||
bool global_var;
|
bool global_var;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using Attr [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attr;
|
||||||
|
using Attributes [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attributes;
|
||||||
|
|
11
src/BifReturnVal.cc
Normal file
11
src/BifReturnVal.cc
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
|
#include "BifReturnVal.h"
|
||||||
|
#include "Val.h"
|
||||||
|
|
||||||
|
BifReturnVal::BifReturnVal(std::nullptr_t) noexcept
|
||||||
|
{}
|
||||||
|
|
||||||
|
BifReturnVal::BifReturnVal(Val* v) noexcept
|
||||||
|
: rval(AdoptRef{}, v)
|
||||||
|
{}
|
28
src/BifReturnVal.h
Normal file
28
src/BifReturnVal.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IntrusivePtr.h"
|
||||||
|
|
||||||
|
class Val;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple wrapper class to use for the return value of BIFs so that
|
||||||
|
* they may return either a Val* or IntrusivePtr<Val> (the former could
|
||||||
|
* potentially be deprecated).
|
||||||
|
*/
|
||||||
|
class BifReturnVal {
|
||||||
|
public:
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
BifReturnVal(IntrusivePtr<T> v) noexcept
|
||||||
|
: rval(AdoptRef{}, v.release())
|
||||||
|
{ }
|
||||||
|
|
||||||
|
BifReturnVal(std::nullptr_t) noexcept;
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Return an IntrusivePtr instead.")]]
|
||||||
|
BifReturnVal(Val* v) noexcept;
|
||||||
|
|
||||||
|
IntrusivePtr<Val> rval;
|
||||||
|
};
|
|
@ -4,23 +4,24 @@
|
||||||
|
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
|
|
||||||
class Expr;
|
|
||||||
typedef PList<Expr> expr_list;
|
|
||||||
|
|
||||||
class ID;
|
|
||||||
typedef PList<ID> id_list;
|
|
||||||
|
|
||||||
class Val;
|
class Val;
|
||||||
typedef PList<Val> val_list;
|
using val_list = PList<Val>;
|
||||||
|
|
||||||
class Stmt;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
typedef PList<Stmt> stmt_list;
|
using expr_list = PList<zeek::detail::Expr>;
|
||||||
|
|
||||||
class BroType;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
typedef PList<BroType> type_list;
|
using id_list = PList<zeek::detail::ID>;
|
||||||
|
|
||||||
class Attr;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
typedef PList<Attr> attr_list;
|
using stmt_list = PList<zeek::detail::Stmt>;
|
||||||
|
|
||||||
|
namespace zeek { class Type; }
|
||||||
|
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||||
|
using type_list = PList<zeek::Type>;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
|
||||||
|
using attr_list = PList<zeek::detail::Attr>;
|
||||||
|
|
||||||
class Timer;
|
class Timer;
|
||||||
typedef PList<Timer, ListOrder::UNORDERED> timer_list;
|
using timer_list = PList<Timer, ListOrder::UNORDERED>;
|
||||||
|
|
|
@ -26,7 +26,7 @@ Brofiler::~Brofiler()
|
||||||
Unref(s);
|
Unref(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Brofiler::AddStmt(Stmt* s)
|
void Brofiler::AddStmt(zeek::detail::Stmt* s)
|
||||||
{
|
{
|
||||||
if ( ignoring != 0 )
|
if ( ignoring != 0 )
|
||||||
return;
|
return;
|
||||||
|
@ -127,7 +127,7 @@ bool Brofiler::WriteStats()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( list<Stmt*>::const_iterator it = stmts.begin();
|
for ( list<zeek::detail::Stmt*>::const_iterator it = stmts.begin();
|
||||||
it != stmts.end(); ++it )
|
it != stmts.end(); ++it )
|
||||||
{
|
{
|
||||||
ODesc location_info;
|
ODesc location_info;
|
||||||
|
@ -154,4 +154,3 @@ bool Brofiler::WriteStats()
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Stmt;
|
#include "util.h"
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple class for managing stats of Bro script coverage across Bro runs.
|
* A simple class for managing stats of Bro script coverage across Bro runs.
|
||||||
|
@ -39,13 +40,13 @@ public:
|
||||||
void IncIgnoreDepth() { ignoring++; }
|
void IncIgnoreDepth() { ignoring++; }
|
||||||
void DecIgnoreDepth() { ignoring--; }
|
void DecIgnoreDepth() { ignoring--; }
|
||||||
|
|
||||||
void AddStmt(Stmt* s);
|
void AddStmt(zeek::detail::Stmt* s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The current, global Brofiler instance creates this list at parse-time.
|
* The current, global Brofiler instance creates this list at parse-time.
|
||||||
*/
|
*/
|
||||||
std::list<Stmt*> stmts;
|
std::list<zeek::detail::Stmt*> stmts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether new statments will not be considered as part of
|
* Indicates whether new statments will not be considered as part of
|
||||||
|
|
|
@ -218,6 +218,7 @@ set(MAIN_SRCS
|
||||||
Anon.cc
|
Anon.cc
|
||||||
Attr.cc
|
Attr.cc
|
||||||
Base64.cc
|
Base64.cc
|
||||||
|
BifReturnVal.cc
|
||||||
Brofiler.cc
|
Brofiler.cc
|
||||||
BroString.cc
|
BroString.cc
|
||||||
CCL.cc
|
CCL.cc
|
||||||
|
@ -325,14 +326,14 @@ set(THIRD_PARTY_SRCS
|
||||||
# Highwayhash. Highwayhash is a bit special since it has architecture dependent code...
|
# Highwayhash. Highwayhash is a bit special since it has architecture dependent code...
|
||||||
|
|
||||||
set(HH_SRCS
|
set(HH_SRCS
|
||||||
../aux/highwayhash/highwayhash/sip_hash.cc
|
../auxil/highwayhash/highwayhash/sip_hash.cc
|
||||||
../aux/highwayhash/highwayhash/sip_tree_hash.cc
|
../auxil/highwayhash/highwayhash/sip_tree_hash.cc
|
||||||
../aux/highwayhash/highwayhash/scalar_sip_tree_hash.cc
|
../auxil/highwayhash/highwayhash/scalar_sip_tree_hash.cc
|
||||||
../aux/highwayhash/highwayhash/arch_specific.cc
|
../auxil/highwayhash/highwayhash/arch_specific.cc
|
||||||
../aux/highwayhash/highwayhash/instruction_sets.cc
|
../auxil/highwayhash/highwayhash/instruction_sets.cc
|
||||||
../aux/highwayhash/highwayhash/nanobenchmark.cc
|
../auxil/highwayhash/highwayhash/nanobenchmark.cc
|
||||||
../aux/highwayhash/highwayhash/os_specific.cc
|
../auxil/highwayhash/highwayhash/os_specific.cc
|
||||||
../aux/highwayhash/highwayhash/hh_portable.cc
|
../auxil/highwayhash/highwayhash/hh_portable.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${COMPILER_ARCHITECTURE} STREQUAL "arm")
|
if (${COMPILER_ARCHITECTURE} STREQUAL "arm")
|
||||||
|
@ -340,23 +341,23 @@ if (${COMPILER_ARCHITECTURE} STREQUAL "arm")
|
||||||
-mfloat-abi=hard -march=armv7-a -mfpu=neon)
|
-mfloat-abi=hard -march=armv7-a -mfpu=neon)
|
||||||
elseif (${COMPILER_ARCHITECTURE} STREQUAL "aarch64")
|
elseif (${COMPILER_ARCHITECTURE} STREQUAL "aarch64")
|
||||||
list(APPEND HH_SRCS
|
list(APPEND HH_SRCS
|
||||||
../aux/highwayhash/highwayhash/hh_neon.cc
|
../auxil/highwayhash/highwayhash/hh_neon.cc
|
||||||
)
|
)
|
||||||
elseif (${COMPILER_ARCHITECTURE} STREQUAL "power")
|
elseif (${COMPILER_ARCHITECTURE} STREQUAL "power")
|
||||||
set_source_files_properties(../aux/highwayhash/highwayhash/hh_avx2.cc PROPERTIES COMPILE_FLAGS
|
set_source_files_properties(../auxil/highwayhash/highwayhash/hh_avx2.cc PROPERTIES COMPILE_FLAGS
|
||||||
-mvsx)
|
-mvsx)
|
||||||
list(APPEND HH_SRCS
|
list(APPEND HH_SRCS
|
||||||
../aux/highwayhash/highwayhash/hh_vsc.cc
|
../auxil/highwayhash/highwayhash/hh_vsc.cc
|
||||||
)
|
)
|
||||||
elseif(${COMPILER_ARCHITECTURE} STREQUAL "x86_64")
|
elseif(${COMPILER_ARCHITECTURE} STREQUAL "x86_64")
|
||||||
set_source_files_properties(../aux/highwayhash/highwayhash/hh_avx2.cc PROPERTIES COMPILE_FLAGS
|
set_source_files_properties(../auxil/highwayhash/highwayhash/hh_avx2.cc PROPERTIES COMPILE_FLAGS
|
||||||
-mavx2)
|
-mavx2)
|
||||||
set_source_files_properties(../aux/highwayhash/highwayhash/hh_sse41.cc PROPERTIES COMPILE_FLAGS
|
set_source_files_properties(../auxil/highwayhash/highwayhash/hh_sse41.cc PROPERTIES COMPILE_FLAGS
|
||||||
-msse4.1)
|
-msse4.1)
|
||||||
|
|
||||||
list(APPEND HH_SRCS
|
list(APPEND HH_SRCS
|
||||||
../aux/highwayhash/highwayhash/hh_avx2.cc
|
../auxil/highwayhash/highwayhash/hh_avx2.cc
|
||||||
../aux/highwayhash/highwayhash/hh_sse41.cc
|
../auxil/highwayhash/highwayhash/hh_sse41.cc
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
207
src/CompHash.cc
207
src/CompHash.cc
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "zeek-config.h"
|
#include "zeek-config.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -14,17 +15,17 @@
|
||||||
#include "Func.h"
|
#include "Func.h"
|
||||||
#include "IPAddr.h"
|
#include "IPAddr.h"
|
||||||
|
|
||||||
CompositeHash::CompositeHash(IntrusivePtr<TypeList> composite_type)
|
CompositeHash::CompositeHash(IntrusivePtr<zeek::TypeList> composite_type)
|
||||||
: type(std::move(composite_type))
|
: type(std::move(composite_type))
|
||||||
{
|
{
|
||||||
singleton_tag = TYPE_INTERNAL_ERROR;
|
singleton_tag = zeek::TYPE_INTERNAL_ERROR;
|
||||||
|
|
||||||
// If the only element is a record, don't treat it as a
|
// If the only element is a record, don't treat it as a
|
||||||
// singleton, since it needs to be evaluated specially.
|
// singleton, since it needs to be evaluated specially.
|
||||||
|
|
||||||
if ( type->Types().size() == 1 )
|
if ( type->Types().size() == 1 )
|
||||||
{
|
{
|
||||||
if ( type->Types()[0]->Tag() == TYPE_RECORD )
|
if ( type->Types()[0]->Tag() == zeek::TYPE_RECORD )
|
||||||
{
|
{
|
||||||
is_complex_type = true;
|
is_complex_type = true;
|
||||||
is_singleton = false;
|
is_singleton = false;
|
||||||
|
@ -71,10 +72,10 @@ CompositeHash::~CompositeHash()
|
||||||
|
|
||||||
// Computes the piece of the hash for Val*, returning the new kp.
|
// Computes the piece of the hash for Val*, returning the new kp.
|
||||||
char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
BroType* bt, Val* v, bool optional) const
|
zeek::Type* bt, Val* v, bool optional) const
|
||||||
{
|
{
|
||||||
char* kp1 = nullptr;
|
char* kp1 = nullptr;
|
||||||
InternalTypeTag t = bt->InternalType();
|
zeek::InternalTypeTag t = bt->InternalType();
|
||||||
|
|
||||||
if ( optional )
|
if ( optional )
|
||||||
{
|
{
|
||||||
|
@ -89,13 +90,13 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
|
|
||||||
if ( type_check )
|
if ( type_check )
|
||||||
{
|
{
|
||||||
InternalTypeTag vt = v->GetType()->InternalType();
|
zeek::InternalTypeTag vt = v->GetType()->InternalType();
|
||||||
if ( vt != t )
|
if ( vt != t )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( t ) {
|
switch ( t ) {
|
||||||
case TYPE_INTERNAL_INT:
|
case zeek::TYPE_INTERNAL_INT:
|
||||||
{
|
{
|
||||||
bro_int_t* kp = AlignAndPadType<bro_int_t>(kp0);
|
bro_int_t* kp = AlignAndPadType<bro_int_t>(kp0);
|
||||||
*kp = v->ForceAsInt();
|
*kp = v->ForceAsInt();
|
||||||
|
@ -103,7 +104,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||||
{
|
{
|
||||||
bro_uint_t* kp = AlignAndPadType<bro_uint_t>(kp0);
|
bro_uint_t* kp = AlignAndPadType<bro_uint_t>(kp0);
|
||||||
*kp = v->ForceAsUInt();
|
*kp = v->ForceAsUInt();
|
||||||
|
@ -111,7 +112,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ADDR:
|
case zeek::TYPE_INTERNAL_ADDR:
|
||||||
{
|
{
|
||||||
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
||||||
v->AsAddr().CopyIPv6(kp);
|
v->AsAddr().CopyIPv6(kp);
|
||||||
|
@ -119,7 +120,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_SUBNET:
|
case zeek::TYPE_INTERNAL_SUBNET:
|
||||||
{
|
{
|
||||||
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
||||||
v->AsSubNet().Prefix().CopyIPv6(kp);
|
v->AsSubNet().Prefix().CopyIPv6(kp);
|
||||||
|
@ -128,7 +129,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_DOUBLE:
|
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||||
{
|
{
|
||||||
double* kp = AlignAndPadType<double>(kp0);
|
double* kp = AlignAndPadType<double>(kp0);
|
||||||
*kp = v->InternalDouble();
|
*kp = v->InternalDouble();
|
||||||
|
@ -136,11 +137,11 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_VOID:
|
case zeek::TYPE_INTERNAL_VOID:
|
||||||
case TYPE_INTERNAL_OTHER:
|
case zeek::TYPE_INTERNAL_OTHER:
|
||||||
{
|
{
|
||||||
switch ( v->GetType()->Tag() ) {
|
switch ( v->GetType()->Tag() ) {
|
||||||
case TYPE_FUNC:
|
case zeek::TYPE_FUNC:
|
||||||
{
|
{
|
||||||
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
|
||||||
*kp = v->AsFunc()->GetUniqueFuncID();
|
*kp = v->AsFunc()->GetUniqueFuncID();
|
||||||
|
@ -148,7 +149,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_PATTERN:
|
case zeek::TYPE_PATTERN:
|
||||||
{
|
{
|
||||||
const char* texts[2] = {
|
const char* texts[2] = {
|
||||||
v->AsPattern()->PatternText(),
|
v->AsPattern()->PatternText(),
|
||||||
|
@ -172,19 +173,19 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_RECORD:
|
case zeek::TYPE_RECORD:
|
||||||
{
|
{
|
||||||
char* kp = kp0;
|
char* kp = kp0;
|
||||||
RecordVal* rv = v->AsRecordVal();
|
RecordVal* rv = v->AsRecordVal();
|
||||||
RecordType* rt = bt->AsRecordType();
|
zeek::RecordType* rt = bt->AsRecordType();
|
||||||
int num_fields = rt->NumFields();
|
int num_fields = rt->NumFields();
|
||||||
|
|
||||||
for ( int i = 0; i < num_fields; ++i )
|
for ( int i = 0; i < num_fields; ++i )
|
||||||
{
|
{
|
||||||
auto rv_i = rv->GetField(i).get();
|
auto rv_i = rv->GetField(i).get();
|
||||||
|
|
||||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||||
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
bool optional = (a && a->Find(zeek::detail::ATTR_OPTIONAL));
|
||||||
|
|
||||||
if ( ! (rv_i || optional) )
|
if ( ! (rv_i || optional) )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -199,7 +200,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case zeek::TYPE_TABLE:
|
||||||
{
|
{
|
||||||
int* kp = AlignAndPadType<int>(kp0);
|
int* kp = AlignAndPadType<int>(kp0);
|
||||||
TableVal* tv = v->AsTableVal();
|
TableVal* tv = v->AsTableVal();
|
||||||
|
@ -208,7 +209,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
|
|
||||||
auto tbl = tv->AsTable();
|
auto tbl = tv->AsTable();
|
||||||
auto it = tbl->InitForIteration();
|
auto it = tbl->InitForIteration();
|
||||||
auto lv = make_intrusive<ListVal>(TYPE_ANY);
|
auto lv = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||||
|
|
||||||
struct HashKeyComparer {
|
struct HashKeyComparer {
|
||||||
bool operator()(const HashKey* a, const HashKey* b) const
|
bool operator()(const HashKey* a, const HashKey* b) const
|
||||||
|
@ -258,11 +259,11 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_VECTOR:
|
case zeek::TYPE_VECTOR:
|
||||||
{
|
{
|
||||||
unsigned int* kp = AlignAndPadType<unsigned int>(kp0);
|
unsigned int* kp = AlignAndPadType<unsigned int>(kp0);
|
||||||
VectorVal* vv = v->AsVectorVal();
|
VectorVal* vv = v->AsVectorVal();
|
||||||
VectorType* vt = v->GetType()->AsVectorType();
|
zeek::VectorType* vt = v->GetType()->AsVectorType();
|
||||||
*kp = vv->Size();
|
*kp = vv->Size();
|
||||||
kp1 = reinterpret_cast<char*>(kp+1);
|
kp1 = reinterpret_cast<char*>(kp+1);
|
||||||
for ( unsigned int i = 0; i < vv->Size(); ++i )
|
for ( unsigned int i = 0; i < vv->Size(); ++i )
|
||||||
|
@ -286,7 +287,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_LIST:
|
case zeek::TYPE_LIST:
|
||||||
{
|
{
|
||||||
int* kp = AlignAndPadType<int>(kp0);
|
int* kp = AlignAndPadType<int>(kp0);
|
||||||
ListVal* lv = v->AsListVal();
|
ListVal* lv = v->AsListVal();
|
||||||
|
@ -309,10 +310,10 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break; // case TYPE_INTERNAL_VOID/OTHER
|
break; // case zeek::TYPE_INTERNAL_VOID/OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_INTERNAL_STRING:
|
case zeek::TYPE_INTERNAL_STRING:
|
||||||
{
|
{
|
||||||
// Align to int for the length field.
|
// Align to int for the length field.
|
||||||
int* kp = AlignAndPadType<int>(kp0);
|
int* kp = AlignAndPadType<int>(kp0);
|
||||||
|
@ -327,7 +328,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ERROR:
|
case zeek::TYPE_INTERNAL_ERROR:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,9 +343,9 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
||||||
if ( is_singleton )
|
if ( is_singleton )
|
||||||
return ComputeSingletonHash(v, type_check);
|
return ComputeSingletonHash(v, type_check);
|
||||||
|
|
||||||
if ( is_complex_type && v->GetType()->Tag() != TYPE_LIST )
|
if ( is_complex_type && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||||
{
|
{
|
||||||
ListVal lv(TYPE_ANY);
|
ListVal lv(zeek::TYPE_ANY);
|
||||||
|
|
||||||
// Cast away const to use ListVal - but since we
|
// Cast away const to use ListVal - but since we
|
||||||
// re-introduce const on the recursive call, it should
|
// re-introduce const on the recursive call, it should
|
||||||
|
@ -368,7 +369,7 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
||||||
|
|
||||||
const auto& tl = type->Types();
|
const auto& tl = type->Types();
|
||||||
|
|
||||||
if ( type_check && v->GetType()->Tag() != TYPE_LIST )
|
if ( type_check && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto lv = v->AsListVal();
|
auto lv = v->AsListVal();
|
||||||
|
@ -389,7 +390,7 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
||||||
|
|
||||||
std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool type_check) const
|
std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool type_check) const
|
||||||
{
|
{
|
||||||
if ( v->GetType()->Tag() == TYPE_LIST )
|
if ( v->GetType()->Tag() == zeek::TYPE_LIST )
|
||||||
{
|
{
|
||||||
auto lv = v->AsListVal();
|
auto lv = v->AsListVal();
|
||||||
|
|
||||||
|
@ -403,25 +404,25 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
switch ( singleton_tag ) {
|
switch ( singleton_tag ) {
|
||||||
case TYPE_INTERNAL_INT:
|
case zeek::TYPE_INTERNAL_INT:
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||||
return std::make_unique<HashKey>(v->ForceAsInt());
|
return std::make_unique<HashKey>(v->ForceAsInt());
|
||||||
|
|
||||||
case TYPE_INTERNAL_ADDR:
|
case zeek::TYPE_INTERNAL_ADDR:
|
||||||
return v->AsAddr().MakeHashKey();
|
return v->AsAddr().MakeHashKey();
|
||||||
|
|
||||||
case TYPE_INTERNAL_SUBNET:
|
case zeek::TYPE_INTERNAL_SUBNET:
|
||||||
return v->AsSubNet().MakeHashKey();
|
return v->AsSubNet().MakeHashKey();
|
||||||
|
|
||||||
case TYPE_INTERNAL_DOUBLE:
|
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||||
return std::make_unique<HashKey>(v->InternalDouble());
|
return std::make_unique<HashKey>(v->InternalDouble());
|
||||||
|
|
||||||
case TYPE_INTERNAL_VOID:
|
case zeek::TYPE_INTERNAL_VOID:
|
||||||
case TYPE_INTERNAL_OTHER:
|
case zeek::TYPE_INTERNAL_OTHER:
|
||||||
if ( v->GetType()->Tag() == TYPE_FUNC )
|
if ( v->GetType()->Tag() == zeek::TYPE_FUNC )
|
||||||
return std::make_unique<HashKey>(v->AsFunc()->GetUniqueFuncID());
|
return std::make_unique<HashKey>(v->AsFunc()->GetUniqueFuncID());
|
||||||
|
|
||||||
if ( v->GetType()->Tag() == TYPE_PATTERN )
|
if ( v->GetType()->Tag() == zeek::TYPE_PATTERN )
|
||||||
{
|
{
|
||||||
const char* texts[2] = {
|
const char* texts[2] = {
|
||||||
v->AsPattern()->PatternText(),
|
v->AsPattern()->PatternText(),
|
||||||
|
@ -437,10 +438,10 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
||||||
reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash");
|
reporter->InternalError("bad index type in CompositeHash::ComputeSingletonHash");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
case TYPE_INTERNAL_STRING:
|
case zeek::TYPE_INTERNAL_STRING:
|
||||||
return std::make_unique<HashKey>(v->AsString());
|
return std::make_unique<HashKey>(v->AsString());
|
||||||
|
|
||||||
case TYPE_INTERNAL_ERROR:
|
case zeek::TYPE_INTERNAL_ERROR:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -449,53 +450,53 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
int CompositeHash::SingleTypeKeySize(zeek::Type* bt, const Val* v,
|
||||||
bool type_check, int sz, bool optional,
|
bool type_check, int sz, bool optional,
|
||||||
bool calc_static_size) const
|
bool calc_static_size) const
|
||||||
{
|
{
|
||||||
InternalTypeTag t = bt->InternalType();
|
zeek::InternalTypeTag t = bt->InternalType();
|
||||||
|
|
||||||
if ( optional )
|
if ( optional )
|
||||||
sz = SizeAlign(sz, sizeof(char));
|
sz = SizeAlign(sz, sizeof(char));
|
||||||
|
|
||||||
if ( type_check && v )
|
if ( type_check && v )
|
||||||
{
|
{
|
||||||
InternalTypeTag vt = v->GetType()->InternalType();
|
zeek::InternalTypeTag vt = v->GetType()->InternalType();
|
||||||
if ( vt != t )
|
if ( vt != t )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( t ) {
|
switch ( t ) {
|
||||||
case TYPE_INTERNAL_INT:
|
case zeek::TYPE_INTERNAL_INT:
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||||
sz = SizeAlign(sz, sizeof(bro_int_t));
|
sz = SizeAlign(sz, sizeof(bro_int_t));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ADDR:
|
case zeek::TYPE_INTERNAL_ADDR:
|
||||||
sz = SizeAlign(sz, sizeof(uint32_t));
|
sz = SizeAlign(sz, sizeof(uint32_t));
|
||||||
sz += sizeof(uint32_t) * 3; // to make a total of 4 words
|
sz += sizeof(uint32_t) * 3; // to make a total of 4 words
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_SUBNET:
|
case zeek::TYPE_INTERNAL_SUBNET:
|
||||||
sz = SizeAlign(sz, sizeof(uint32_t));
|
sz = SizeAlign(sz, sizeof(uint32_t));
|
||||||
sz += sizeof(uint32_t) * 4; // to make a total of 5 words
|
sz += sizeof(uint32_t) * 4; // to make a total of 5 words
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_DOUBLE:
|
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||||
sz = SizeAlign(sz, sizeof(double));
|
sz = SizeAlign(sz, sizeof(double));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_VOID:
|
case zeek::TYPE_INTERNAL_VOID:
|
||||||
case TYPE_INTERNAL_OTHER:
|
case zeek::TYPE_INTERNAL_OTHER:
|
||||||
{
|
{
|
||||||
switch ( bt->Tag() ) {
|
switch ( bt->Tag() ) {
|
||||||
case TYPE_FUNC:
|
case zeek::TYPE_FUNC:
|
||||||
{
|
{
|
||||||
sz = SizeAlign(sz, sizeof(uint32_t));
|
sz = SizeAlign(sz, sizeof(uint32_t));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_PATTERN:
|
case zeek::TYPE_PATTERN:
|
||||||
{
|
{
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return (optional && ! calc_static_size) ? sz : 0;
|
return (optional && ! calc_static_size) ? sz : 0;
|
||||||
|
@ -506,16 +507,16 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_RECORD:
|
case zeek::TYPE_RECORD:
|
||||||
{
|
{
|
||||||
const RecordVal* rv = v ? v->AsRecordVal() : nullptr;
|
const RecordVal* rv = v ? v->AsRecordVal() : nullptr;
|
||||||
RecordType* rt = bt->AsRecordType();
|
zeek::RecordType* rt = bt->AsRecordType();
|
||||||
int num_fields = rt->NumFields();
|
int num_fields = rt->NumFields();
|
||||||
|
|
||||||
for ( int i = 0; i < num_fields; ++i )
|
for ( int i = 0; i < num_fields; ++i )
|
||||||
{
|
{
|
||||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||||
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
bool optional = (a && a->Find(zeek::detail::ATTR_OPTIONAL));
|
||||||
|
|
||||||
sz = SingleTypeKeySize(rt->GetFieldType(i).get(),
|
sz = SingleTypeKeySize(rt->GetFieldType(i).get(),
|
||||||
rv ? rv->GetField(i).get() : nullptr,
|
rv ? rv->GetField(i).get() : nullptr,
|
||||||
|
@ -528,7 +529,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case zeek::TYPE_TABLE:
|
||||||
{
|
{
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return (optional && ! calc_static_size) ? sz : 0;
|
return (optional && ! calc_static_size) ? sz : 0;
|
||||||
|
@ -557,7 +558,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_VECTOR:
|
case zeek::TYPE_VECTOR:
|
||||||
{
|
{
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return (optional && ! calc_static_size) ? sz : 0;
|
return (optional && ! calc_static_size) ? sz : 0;
|
||||||
|
@ -579,7 +580,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_LIST:
|
case zeek::TYPE_LIST:
|
||||||
{
|
{
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return (optional && ! calc_static_size) ? sz : 0;
|
return (optional && ! calc_static_size) ? sz : 0;
|
||||||
|
@ -603,10 +604,10 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break; // case TYPE_INTERNAL_VOID/OTHER
|
break; // case zeek::TYPE_INTERNAL_VOID/OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_INTERNAL_STRING:
|
case zeek::TYPE_INTERNAL_STRING:
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return (optional && ! calc_static_size) ? sz : 0;
|
return (optional && ! calc_static_size) ? sz : 0;
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||||
sz += v->AsString()->Len();
|
sz += v->AsString()->Len();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ERROR:
|
case zeek::TYPE_INTERNAL_ERROR:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +629,7 @@ int CompositeHash::ComputeKeySize(const Val* v, bool type_check, bool calc_stati
|
||||||
|
|
||||||
if ( v )
|
if ( v )
|
||||||
{
|
{
|
||||||
if ( type_check && v->GetType()->Tag() != TYPE_LIST )
|
if ( type_check && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto lv = v->AsListVal();
|
auto lv = v->AsListVal();
|
||||||
|
@ -710,7 +711,7 @@ int CompositeHash::SizeAlign(int offset, unsigned int size) const
|
||||||
|
|
||||||
IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
||||||
{
|
{
|
||||||
auto l = make_intrusive<ListVal>(TYPE_ANY);
|
auto l = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||||
const auto& tl = type->Types();
|
const auto& tl = type->Types();
|
||||||
const char* kp = (const char*) k.Key();
|
const char* kp = (const char*) k.Key();
|
||||||
const char* const k_end = kp + k.Size();
|
const char* const k_end = kp + k.Size();
|
||||||
|
@ -730,15 +731,15 @@ IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
const char* const k_end, BroType* t,
|
const char* const k_end, zeek::Type* t,
|
||||||
IntrusivePtr<Val>* pval, bool optional) const
|
IntrusivePtr<Val>* pval, bool optional) const
|
||||||
{
|
{
|
||||||
// k->Size() == 0 for a single empty string.
|
// k->Size() == 0 for a single empty string.
|
||||||
if ( kp0 >= k_end && k.Size() > 0 )
|
if ( kp0 >= k_end && k.Size() > 0 )
|
||||||
reporter->InternalError("over-ran key in CompositeHash::RecoverVals");
|
reporter->InternalError("over-ran key in CompositeHash::RecoverVals");
|
||||||
|
|
||||||
TypeTag tag = t->Tag();
|
zeek::TypeTag tag = t->Tag();
|
||||||
InternalTypeTag it = t->InternalType();
|
zeek::InternalTypeTag it = t->InternalType();
|
||||||
const char* kp1 = nullptr;
|
const char* kp1 = nullptr;
|
||||||
|
|
||||||
if ( optional )
|
if ( optional )
|
||||||
|
@ -754,16 +755,16 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( it ) {
|
switch ( it ) {
|
||||||
case TYPE_INTERNAL_INT:
|
case zeek::TYPE_INTERNAL_INT:
|
||||||
{
|
{
|
||||||
const bro_int_t* const kp = AlignType<bro_int_t>(kp0);
|
const bro_int_t* const kp = AlignType<bro_int_t>(kp0);
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
|
|
||||||
if ( tag == TYPE_ENUM )
|
if ( tag == zeek::TYPE_ENUM )
|
||||||
*pval = t->AsEnumType()->GetVal(*kp);
|
*pval = t->AsEnumType()->GetVal(*kp);
|
||||||
else if ( tag == TYPE_BOOL )
|
else if ( tag == zeek::TYPE_BOOL )
|
||||||
*pval = val_mgr->Bool(*kp);
|
*pval = val_mgr->Bool(*kp);
|
||||||
else if ( tag == TYPE_INT )
|
else if ( tag == zeek::TYPE_INT )
|
||||||
*pval = val_mgr->Int(*kp);
|
*pval = val_mgr->Int(*kp);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -773,18 +774,18 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case zeek::TYPE_INTERNAL_UNSIGNED:
|
||||||
{
|
{
|
||||||
const bro_uint_t* const kp = AlignType<bro_uint_t>(kp0);
|
const bro_uint_t* const kp = AlignType<bro_uint_t>(kp0);
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
|
|
||||||
switch ( tag ) {
|
switch ( tag ) {
|
||||||
case TYPE_COUNT:
|
case zeek::TYPE_COUNT:
|
||||||
case TYPE_COUNTER:
|
case zeek::TYPE_COUNTER:
|
||||||
*pval = val_mgr->Count(*kp);
|
*pval = val_mgr->Count(*kp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PORT:
|
case zeek::TYPE_PORT:
|
||||||
*pval = val_mgr->Port(*kp);
|
*pval = val_mgr->Port(*kp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -796,21 +797,21 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_DOUBLE:
|
case zeek::TYPE_INTERNAL_DOUBLE:
|
||||||
{
|
{
|
||||||
const double* const kp = AlignType<double>(kp0);
|
const double* const kp = AlignType<double>(kp0);
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
|
|
||||||
if ( tag == TYPE_INTERVAL )
|
if ( tag == zeek::TYPE_INTERVAL )
|
||||||
*pval = make_intrusive<IntervalVal>(*kp, 1.0);
|
*pval = make_intrusive<IntervalVal>(*kp, 1.0);
|
||||||
else if ( tag == TYPE_TIME )
|
else if ( tag == zeek::TYPE_TIME )
|
||||||
*pval = make_intrusive<TimeVal>(*kp);
|
*pval = make_intrusive<TimeVal>(*kp);
|
||||||
else
|
else
|
||||||
*pval = make_intrusive<DoubleVal>(*kp);
|
*pval = make_intrusive<DoubleVal>(*kp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ADDR:
|
case zeek::TYPE_INTERNAL_ADDR:
|
||||||
{
|
{
|
||||||
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
||||||
kp1 = reinterpret_cast<const char*>(kp+4);
|
kp1 = reinterpret_cast<const char*>(kp+4);
|
||||||
|
@ -818,7 +819,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
IPAddr addr(IPv6, kp, IPAddr::Network);
|
IPAddr addr(IPv6, kp, IPAddr::Network);
|
||||||
|
|
||||||
switch ( tag ) {
|
switch ( tag ) {
|
||||||
case TYPE_ADDR:
|
case zeek::TYPE_ADDR:
|
||||||
*pval = make_intrusive<AddrVal>(addr);
|
*pval = make_intrusive<AddrVal>(addr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -830,7 +831,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_SUBNET:
|
case zeek::TYPE_INTERNAL_SUBNET:
|
||||||
{
|
{
|
||||||
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
||||||
kp1 = reinterpret_cast<const char*>(kp+5);
|
kp1 = reinterpret_cast<const char*>(kp+5);
|
||||||
|
@ -838,11 +839,11 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_VOID:
|
case zeek::TYPE_INTERNAL_VOID:
|
||||||
case TYPE_INTERNAL_OTHER:
|
case zeek::TYPE_INTERNAL_OTHER:
|
||||||
{
|
{
|
||||||
switch ( t->Tag() ) {
|
switch ( t->Tag() ) {
|
||||||
case TYPE_FUNC:
|
case zeek::TYPE_FUNC:
|
||||||
{
|
{
|
||||||
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
const uint32_t* const kp = AlignType<uint32_t>(kp0);
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
|
@ -858,18 +859,18 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
if ( ! pvt )
|
if ( ! pvt )
|
||||||
reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()");
|
reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()");
|
||||||
|
|
||||||
else if ( t->Tag() != TYPE_FUNC && ! same_type(pvt, t) )
|
else if ( t->Tag() != zeek::TYPE_FUNC && ! same_type(pvt, t) )
|
||||||
// ### Maybe fix later, but may be fundamentally
|
// ### Maybe fix later, but may be fundamentally
|
||||||
// un-checkable --US
|
// un-checkable --US
|
||||||
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
|
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
|
||||||
|
|
||||||
// ### A crude approximation for now.
|
// ### A crude approximation for now.
|
||||||
else if ( t->Tag() == TYPE_FUNC && pvt->Tag() != TYPE_FUNC )
|
else if ( t->Tag() == zeek::TYPE_FUNC && pvt->Tag() != zeek::TYPE_FUNC )
|
||||||
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
|
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PATTERN:
|
case zeek::TYPE_PATTERN:
|
||||||
{
|
{
|
||||||
RE_Matcher* re = nullptr;
|
RE_Matcher* re = nullptr;
|
||||||
if ( is_singleton )
|
if ( is_singleton )
|
||||||
|
@ -896,10 +897,10 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_RECORD:
|
case zeek::TYPE_RECORD:
|
||||||
{
|
{
|
||||||
const char* kp = kp0;
|
const char* kp = kp0;
|
||||||
RecordType* rt = t->AsRecordType();
|
zeek::RecordType* rt = t->AsRecordType();
|
||||||
int num_fields = rt->NumFields();
|
int num_fields = rt->NumFields();
|
||||||
|
|
||||||
std::vector<IntrusivePtr<Val>> values;
|
std::vector<IntrusivePtr<Val>> values;
|
||||||
|
@ -908,8 +909,8 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
{
|
{
|
||||||
IntrusivePtr<Val> v;
|
IntrusivePtr<Val> v;
|
||||||
|
|
||||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
zeek::detail::Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||||
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
bool optional = (a && a->Find(zeek::detail::ATTR_OPTIONAL));
|
||||||
|
|
||||||
kp = RecoverOneVal(k, kp, k_end,
|
kp = RecoverOneVal(k, kp, k_end,
|
||||||
rt->GetFieldType(i).get(), &v, optional);
|
rt->GetFieldType(i).get(), &v, optional);
|
||||||
|
@ -939,13 +940,13 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case zeek::TYPE_TABLE:
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
const int* const kp = AlignType<int>(kp0);
|
const int* const kp = AlignType<int>(kp0);
|
||||||
n = *kp;
|
n = *kp;
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
TableType* tt = t->AsTableType();
|
zeek::TableType* tt = t->AsTableType();
|
||||||
auto tv = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt});
|
auto tv = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, tt});
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i )
|
for ( int i = 0; i < n; ++i )
|
||||||
|
@ -968,13 +969,13 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_VECTOR:
|
case zeek::TYPE_VECTOR:
|
||||||
{
|
{
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
const unsigned int* kp = AlignType<unsigned int>(kp0);
|
const unsigned int* kp = AlignType<unsigned int>(kp0);
|
||||||
n = *kp;
|
n = *kp;
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
VectorType* vt = t->AsVectorType();
|
zeek::VectorType* vt = t->AsVectorType();
|
||||||
auto vv = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, vt});
|
auto vv = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, vt});
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < n; ++i )
|
for ( unsigned int i = 0; i < n; ++i )
|
||||||
|
@ -998,19 +999,19 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_LIST:
|
case zeek::TYPE_LIST:
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
const int* const kp = AlignType<int>(kp0);
|
const int* const kp = AlignType<int>(kp0);
|
||||||
n = *kp;
|
n = *kp;
|
||||||
kp1 = reinterpret_cast<const char*>(kp+1);
|
kp1 = reinterpret_cast<const char*>(kp+1);
|
||||||
TypeList* tl = t->AsTypeList();
|
zeek::TypeList* tl = t->AsTypeList();
|
||||||
auto lv = make_intrusive<ListVal>(TYPE_ANY);
|
auto lv = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i )
|
for ( int i = 0; i < n; ++i )
|
||||||
{
|
{
|
||||||
IntrusivePtr<Val> v;
|
IntrusivePtr<Val> v;
|
||||||
BroType* it = tl->Types()[i].get();
|
zeek::Type* it = tl->Types()[i].get();
|
||||||
kp1 = RecoverOneVal(k, kp1, k_end, it, &v, false);
|
kp1 = RecoverOneVal(k, kp1, k_end, it, &v, false);
|
||||||
lv->Append(std::move(v));
|
lv->Append(std::move(v));
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1028,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_STRING:
|
case zeek::TYPE_INTERNAL_STRING:
|
||||||
{
|
{
|
||||||
// There is a minor issue here -- the pointer does not have to
|
// There is a minor issue here -- the pointer does not have to
|
||||||
// be aligned by int in the singleton case.
|
// be aligned by int in the singleton case.
|
||||||
|
@ -1050,7 +1051,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INTERNAL_ERROR:
|
case zeek::TYPE_INTERNAL_ERROR:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class HashKey;
|
||||||
|
|
||||||
class CompositeHash {
|
class CompositeHash {
|
||||||
public:
|
public:
|
||||||
explicit CompositeHash(IntrusivePtr<TypeList> composite_type);
|
explicit CompositeHash(IntrusivePtr<zeek::TypeList> composite_type);
|
||||||
~CompositeHash();
|
~CompositeHash();
|
||||||
|
|
||||||
// Compute the hash corresponding to the given index val,
|
// Compute the hash corresponding to the given index val,
|
||||||
|
@ -37,7 +37,7 @@ protected:
|
||||||
|
|
||||||
// Computes the piece of the hash for Val*, returning the new kp.
|
// Computes the piece of the hash for Val*, returning the new kp.
|
||||||
// Used as a helper for ComputeHash in the non-singleton case.
|
// Used as a helper for ComputeHash in the non-singleton case.
|
||||||
char* SingleValHash(bool type_check, char* kp, BroType* bt, Val* v,
|
char* SingleValHash(bool type_check, char* kp, zeek::Type* bt, Val* v,
|
||||||
bool optional) const;
|
bool optional) const;
|
||||||
|
|
||||||
// Recovers just one Val of possibly many; called from RecoverVals.
|
// Recovers just one Val of possibly many; called from RecoverVals.
|
||||||
|
@ -46,7 +46,7 @@ protected:
|
||||||
// upon errors, so there is no return value for invalid input.
|
// upon errors, so there is no return value for invalid input.
|
||||||
const char* RecoverOneVal(const HashKey& k,
|
const char* RecoverOneVal(const HashKey& k,
|
||||||
const char* kp, const char* const k_end,
|
const char* kp, const char* const k_end,
|
||||||
BroType* t, IntrusivePtr<Val>* pval, bool optional) const;
|
zeek::Type* t, IntrusivePtr<Val>* pval, bool optional) const;
|
||||||
|
|
||||||
// Rounds the given pointer up to the nearest multiple of the
|
// Rounds the given pointer up to the nearest multiple of the
|
||||||
// given size, if not already a multiple.
|
// given size, if not already a multiple.
|
||||||
|
@ -85,11 +85,11 @@ protected:
|
||||||
int ComputeKeySize(const Val* v, bool type_check,
|
int ComputeKeySize(const Val* v, bool type_check,
|
||||||
bool calc_static_size) const;
|
bool calc_static_size) const;
|
||||||
|
|
||||||
int SingleTypeKeySize(BroType*, const Val*,
|
int SingleTypeKeySize(zeek::Type*, const Val*,
|
||||||
bool type_check, int sz, bool optional,
|
bool type_check, int sz, bool optional,
|
||||||
bool calc_static_size) const;
|
bool calc_static_size) const;
|
||||||
|
|
||||||
IntrusivePtr<TypeList> type;
|
IntrusivePtr<zeek::TypeList> type;
|
||||||
char* key; // space for composite key
|
char* key; // space for composite key
|
||||||
int size;
|
int size;
|
||||||
bool is_singleton; // if just one type in index
|
bool is_singleton; // if just one type in index
|
||||||
|
@ -97,5 +97,5 @@ protected:
|
||||||
// If one type, but not normal "singleton", e.g. record.
|
// If one type, but not normal "singleton", e.g. record.
|
||||||
bool is_complex_type;
|
bool is_complex_type;
|
||||||
|
|
||||||
InternalTypeTag singleton_tag;
|
zeek::InternalTypeTag singleton_tag;
|
||||||
};
|
};
|
||||||
|
|
|
@ -457,13 +457,11 @@ void Connection::Match(Rule::PatternType type, const u_char* data, int len, bool
|
||||||
|
|
||||||
void Connection::RemovalEvent()
|
void Connection::RemovalEvent()
|
||||||
{
|
{
|
||||||
auto cv = ConnVal();
|
|
||||||
|
|
||||||
if ( connection_state_remove )
|
if ( connection_state_remove )
|
||||||
EnqueueEvent(connection_state_remove, nullptr, cv);
|
EnqueueEvent(connection_state_remove, nullptr, ConnVal());
|
||||||
|
|
||||||
if ( is_successful && successful_connection_remove )
|
if ( is_successful && successful_connection_remove )
|
||||||
EnqueueEvent(successful_connection_remove, nullptr, cv);
|
EnqueueEvent(successful_connection_remove, nullptr, ConnVal());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::Event(EventHandlerPtr f, analyzer::Analyzer* analyzer, const char* name)
|
void Connection::Event(EventHandlerPtr f, analyzer::Analyzer* analyzer, const char* name)
|
||||||
|
|
|
@ -175,10 +175,10 @@ void DNS_Mgr_mapping_delete_func(void* v)
|
||||||
|
|
||||||
static IntrusivePtr<TableVal> empty_addr_set()
|
static IntrusivePtr<TableVal> empty_addr_set()
|
||||||
{
|
{
|
||||||
auto addr_t = base_type(TYPE_ADDR);
|
auto addr_t = zeek::base_type(zeek::TYPE_ADDR);
|
||||||
auto set_index = make_intrusive<TypeList>(addr_t);
|
auto set_index = make_intrusive<zeek::TypeList>(addr_t);
|
||||||
set_index->Append(std::move(addr_t));
|
set_index->Append(std::move(addr_t));
|
||||||
auto s = make_intrusive<SetType>(std::move(set_index), nullptr);
|
auto s = make_intrusive<zeek::SetType>(std::move(set_index), nullptr);
|
||||||
return make_intrusive<TableVal>(std::move(s));
|
return make_intrusive<TableVal>(std::move(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ IntrusivePtr<ListVal> DNS_Mapping::Addrs()
|
||||||
|
|
||||||
if ( ! addrs_val )
|
if ( ! addrs_val )
|
||||||
{
|
{
|
||||||
auto addrs_val = make_intrusive<ListVal>(TYPE_ADDR);
|
auto addrs_val = make_intrusive<ListVal>(zeek::TYPE_ADDR);
|
||||||
|
|
||||||
for ( int i = 0; i < num_addrs; ++i )
|
for ( int i = 0; i < num_addrs; ++i )
|
||||||
addrs_val->Append(make_intrusive<AddrVal>(addrs[i]));
|
addrs_val->Append(make_intrusive<AddrVal>(addrs[i]));
|
||||||
|
@ -450,7 +450,7 @@ void DNS_Mgr::InitSource()
|
||||||
|
|
||||||
void DNS_Mgr::InitPostScript()
|
void DNS_Mgr::InitPostScript()
|
||||||
{
|
{
|
||||||
dm_rec = zeek::id::find_type<RecordType>("dns_mapping");
|
dm_rec = zeek::id::find_type<zeek::RecordType>("dns_mapping");
|
||||||
|
|
||||||
// Registering will call Init()
|
// Registering will call Init()
|
||||||
iosource_mgr->Register(this, true);
|
iosource_mgr->Register(this, true);
|
||||||
|
@ -465,7 +465,7 @@ static IntrusivePtr<TableVal> fake_name_lookup_result(const char* name)
|
||||||
{
|
{
|
||||||
hash128_t hash;
|
hash128_t hash;
|
||||||
KeyedHash::StaticHash128(name, strlen(name), &hash);
|
KeyedHash::StaticHash128(name, strlen(name), &hash);
|
||||||
auto hv = make_intrusive<ListVal>(TYPE_ADDR);
|
auto hv = make_intrusive<ListVal>(zeek::TYPE_ADDR);
|
||||||
hv->Append(make_intrusive<AddrVal>(reinterpret_cast<const uint32_t*>(&hash)));
|
hv->Append(make_intrusive<AddrVal>(reinterpret_cast<const uint32_t*>(&hash)));
|
||||||
return hv->ToSetVal();
|
return hv->ToSetVal();
|
||||||
}
|
}
|
||||||
|
@ -872,7 +872,7 @@ void DNS_Mgr::CompareMappings(DNS_Mapping* prev_dm, DNS_Mapping* new_dm)
|
||||||
|
|
||||||
IntrusivePtr<ListVal> DNS_Mgr::AddrListDelta(ListVal* al1, ListVal* al2)
|
IntrusivePtr<ListVal> DNS_Mgr::AddrListDelta(ListVal* al1, ListVal* al2)
|
||||||
{
|
{
|
||||||
auto delta = make_intrusive<ListVal>(TYPE_ADDR);
|
auto delta = make_intrusive<ListVal>(zeek::TYPE_ADDR);
|
||||||
|
|
||||||
for ( int i = 0; i < al1->Length(); ++i )
|
for ( int i = 0; i < al1->Length(); ++i )
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "EventHandler.h"
|
#include "EventHandler.h"
|
||||||
#include "iosource/IOSource.h"
|
#include "iosource/IOSource.h"
|
||||||
#include "IPAddr.h"
|
#include "IPAddr.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
template <class T> class IntrusivePtr;
|
template <class T> class IntrusivePtr;
|
||||||
class Val;
|
class Val;
|
||||||
|
@ -18,9 +19,10 @@ class ListVal;
|
||||||
class TableVal;
|
class TableVal;
|
||||||
class Func;
|
class Func;
|
||||||
class EventHandler;
|
class EventHandler;
|
||||||
class RecordType;
|
|
||||||
class DNS_Mgr_Request;
|
class DNS_Mgr_Request;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
|
||||||
|
|
||||||
typedef PList<DNS_Mgr_Request> DNS_mgr_request_list;
|
typedef PList<DNS_Mgr_Request> DNS_mgr_request_list;
|
||||||
|
|
||||||
struct nb_dns_info;
|
struct nb_dns_info;
|
||||||
|
@ -149,7 +151,7 @@ protected:
|
||||||
|
|
||||||
bool did_init;
|
bool did_init;
|
||||||
|
|
||||||
IntrusivePtr<RecordType> dm_rec;
|
IntrusivePtr<zeek::RecordType> dm_rec;
|
||||||
|
|
||||||
typedef std::list<LookupCallback*> CallbackList;
|
typedef std::list<LookupCallback*> CallbackList;
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DbgBreakpoint::SetLocation(Stmt* stmt)
|
bool DbgBreakpoint::SetLocation(zeek::detail::Stmt* stmt)
|
||||||
{
|
{
|
||||||
if ( ! stmt )
|
if ( ! stmt )
|
||||||
return false;
|
return false;
|
||||||
|
@ -258,8 +258,8 @@ BreakCode DbgBreakpoint::HasHit()
|
||||||
return bcHit;
|
return bcHit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! IsIntegral(yes->GetType()->Tag()) &&
|
if ( ! zeek::IsIntegral(yes->GetType()->Tag()) &&
|
||||||
! IsBool(yes->GetType()->Tag()) )
|
! zeek::IsBool(yes->GetType()->Tag()) )
|
||||||
{
|
{
|
||||||
PrintHitMsg();
|
PrintHitMsg();
|
||||||
debug_msg("Breakpoint condition should return an integral type");
|
debug_msg("Breakpoint condition should return an integral type");
|
||||||
|
@ -290,7 +290,7 @@ BreakCode DbgBreakpoint::HasHit()
|
||||||
return bcHit;
|
return bcHit;
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakCode DbgBreakpoint::ShouldBreak(Stmt* s)
|
BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s)
|
||||||
{
|
{
|
||||||
if ( ! IsEnabled() )
|
if ( ! IsEnabled() )
|
||||||
return bcNoHit;
|
return bcNoHit;
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct ParseLocationRec;
|
struct ParseLocationRec;
|
||||||
class Stmt;
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
|
||||||
enum BreakCode { bcNoHit, bcHit, bcHitAndDelete };
|
enum BreakCode { bcNoHit, bcHit, bcHitAndDelete };
|
||||||
class DbgBreakpoint {
|
class DbgBreakpoint {
|
||||||
|
@ -20,7 +22,7 @@ public:
|
||||||
|
|
||||||
// True if breakpoint could be set; false otherwise
|
// True if breakpoint could be set; false otherwise
|
||||||
bool SetLocation(ParseLocationRec plr, std::string_view loc_str);
|
bool SetLocation(ParseLocationRec plr, std::string_view loc_str);
|
||||||
bool SetLocation(Stmt* stmt);
|
bool SetLocation(zeek::detail::Stmt* stmt);
|
||||||
bool SetLocation(double time);
|
bool SetLocation(double time);
|
||||||
|
|
||||||
bool Reset(); // cancel and re-apply bpt when restarting execution
|
bool Reset(); // cancel and re-apply bpt when restarting execution
|
||||||
|
@ -35,7 +37,7 @@ public:
|
||||||
//
|
//
|
||||||
// NOTE: If it returns a hit, the DbgBreakpoint object will take
|
// NOTE: If it returns a hit, the DbgBreakpoint object will take
|
||||||
// appropriate action (e.g., resetting counters).
|
// appropriate action (e.g., resetting counters).
|
||||||
BreakCode ShouldBreak(Stmt* s);
|
BreakCode ShouldBreak(zeek::detail::Stmt* s);
|
||||||
BreakCode ShouldBreak(double t);
|
BreakCode ShouldBreak(double t);
|
||||||
|
|
||||||
const std::string& GetCondition() const { return condition; }
|
const std::string& GetCondition() const { return condition; }
|
||||||
|
@ -70,7 +72,7 @@ protected:
|
||||||
bool enabled; // ### comment this and next
|
bool enabled; // ### comment this and next
|
||||||
bool temporary;
|
bool temporary;
|
||||||
|
|
||||||
Stmt* at_stmt;
|
zeek::detail::Stmt* at_stmt;
|
||||||
double at_time; // break when the virtual time is this
|
double at_time; // break when the virtual time is this
|
||||||
|
|
||||||
// Support for conditional and N'th time breakpoints.
|
// Support for conditional and N'th time breakpoints.
|
||||||
|
|
|
@ -12,7 +12,7 @@ DbgWatch::DbgWatch(BroObj* var_to_watch)
|
||||||
reporter->InternalError("DbgWatch unimplemented");
|
reporter->InternalError("DbgWatch unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgWatch::DbgWatch(Expr* expr_to_watch)
|
DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch)
|
||||||
{
|
{
|
||||||
reporter->InternalError("DbgWatch unimplemented");
|
reporter->InternalError("DbgWatch unimplemented");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,19 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class BroObj;
|
class BroObj;
|
||||||
class Expr;
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
class DbgWatch {
|
class DbgWatch {
|
||||||
public:
|
public:
|
||||||
explicit DbgWatch(BroObj* var_to_watch);
|
explicit DbgWatch(BroObj* var_to_watch);
|
||||||
explicit DbgWatch(Expr* expr_to_watch);
|
explicit DbgWatch(zeek::detail::Expr* expr_to_watch);
|
||||||
~DbgWatch();
|
~DbgWatch();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BroObj* var;
|
BroObj* var;
|
||||||
Expr* expr;
|
zeek::detail::Expr* expr;
|
||||||
};
|
};
|
||||||
|
|
20
src/Debug.cc
20
src/Debug.cc
|
@ -135,7 +135,7 @@ int TraceState::LogTrace(const char* fmt, ...)
|
||||||
// Prefix includes timestamp and file/line info.
|
// Prefix includes timestamp and file/line info.
|
||||||
fprintf(trace_file, "%.6f ", network_time);
|
fprintf(trace_file, "%.6f ", network_time);
|
||||||
|
|
||||||
const Stmt* stmt;
|
const zeek::detail::Stmt* stmt;
|
||||||
Location loc;
|
Location loc;
|
||||||
loc.filename = nullptr;
|
loc.filename = nullptr;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ int TraceState::LogTrace(const char* fmt, ...)
|
||||||
|
|
||||||
|
|
||||||
// Helper functions.
|
// Helper functions.
|
||||||
void get_first_statement(Stmt* list, Stmt*& first, Location& loc)
|
void get_first_statement(zeek::detail::Stmt* list, zeek::detail::Stmt*& first, Location& loc)
|
||||||
{
|
{
|
||||||
if ( ! list )
|
if ( ! list )
|
||||||
{
|
{
|
||||||
|
@ -231,7 +231,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stmt* body = nullptr; // the particular body we care about; 0 = all
|
zeek::detail::Stmt* body = nullptr; // the particular body we care about; 0 = all
|
||||||
|
|
||||||
if ( bodies.size() == 1 )
|
if ( bodies.size() == 1 )
|
||||||
body = bodies[0].stmts.get();
|
body = bodies[0].stmts.get();
|
||||||
|
@ -243,7 +243,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
||||||
"Please choose one of the following options:\n");
|
"Please choose one of the following options:\n");
|
||||||
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
for ( unsigned int i = 0; i < bodies.size(); ++i )
|
||||||
{
|
{
|
||||||
Stmt* first;
|
zeek::detail::Stmt* first;
|
||||||
Location stmt_loc;
|
Location stmt_loc;
|
||||||
get_first_statement(bodies[i].stmts.get(), first, stmt_loc);
|
get_first_statement(bodies[i].stmts.get(), first, stmt_loc);
|
||||||
debug_msg("[%d] %s:%d\n", i+1, stmt_loc.filename, stmt_loc.first_line);
|
debug_msg("[%d] %s:%d\n", i+1, stmt_loc.filename, stmt_loc.first_line);
|
||||||
|
@ -286,7 +286,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
||||||
plr.type = plrFunction;
|
plr.type = plrFunction;
|
||||||
|
|
||||||
// Find first atomic (non-STMT_LIST) statement
|
// Find first atomic (non-STMT_LIST) statement
|
||||||
Stmt* first;
|
zeek::detail::Stmt* first;
|
||||||
Location stmt_loc;
|
Location stmt_loc;
|
||||||
|
|
||||||
if ( body )
|
if ( body )
|
||||||
|
@ -728,7 +728,7 @@ static char* get_prompt(bool reset_counter = false)
|
||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_context_description(const Stmt* stmt, const Frame* frame)
|
string get_context_description(const zeek::detail::Stmt* stmt, const Frame* frame)
|
||||||
{
|
{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
const BroFunc* func = frame ? frame->GetFunction() : nullptr;
|
const BroFunc* func = frame ? frame->GetFunction() : nullptr;
|
||||||
|
@ -776,7 +776,7 @@ int dbg_handle_debug_input()
|
||||||
else
|
else
|
||||||
current_module = GLOBAL_MODULE_NAME;
|
current_module = GLOBAL_MODULE_NAME;
|
||||||
|
|
||||||
const Stmt* stmt = curr_frame->GetNextStmt();
|
const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt();
|
||||||
if ( ! stmt )
|
if ( ! stmt )
|
||||||
reporter->InternalError("Assertion failed: stmt != 0");
|
reporter->InternalError("Assertion failed: stmt != 0");
|
||||||
|
|
||||||
|
@ -840,7 +840,7 @@ int dbg_handle_debug_input()
|
||||||
|
|
||||||
|
|
||||||
// Return true to continue execution, false to abort.
|
// Return true to continue execution, false to abort.
|
||||||
bool pre_execute_stmt(Stmt* stmt, Frame* f)
|
bool pre_execute_stmt(zeek::detail::Stmt* stmt, Frame* f)
|
||||||
{
|
{
|
||||||
if ( ! g_policy_debug ||
|
if ( ! g_policy_debug ||
|
||||||
stmt->Tag() == STMT_LIST || stmt->Tag() == STMT_NULL )
|
stmt->Tag() == STMT_LIST || stmt->Tag() == STMT_NULL )
|
||||||
|
@ -905,7 +905,7 @@ bool pre_execute_stmt(Stmt* stmt, Frame* f)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool post_execute_stmt(Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow)
|
bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow)
|
||||||
{
|
{
|
||||||
// Handle the case where someone issues a "next" debugger command,
|
// Handle the case where someone issues a "next" debugger command,
|
||||||
// but we're at a return statement, so the next statement is in
|
// but we're at a return statement, so the next statement is in
|
||||||
|
@ -935,7 +935,7 @@ bool post_execute_stmt(Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow)
|
||||||
|
|
||||||
// Evaluates the given expression in the context of the currently selected
|
// Evaluates the given expression in the context of the currently selected
|
||||||
// frame. Returns the resulting value, or nil if none (or there was an error).
|
// frame. Returns the resulting value, or nil if none (or there was an error).
|
||||||
Expr* g_curr_debug_expr = nullptr;
|
zeek::detail::Expr* g_curr_debug_expr = nullptr;
|
||||||
const char* g_curr_debug_error = nullptr;
|
const char* g_curr_debug_error = nullptr;
|
||||||
bool in_debug = false;
|
bool in_debug = false;
|
||||||
|
|
||||||
|
|
20
src/Debug.h
20
src/Debug.h
|
@ -5,6 +5,7 @@
|
||||||
#include "Obj.h"
|
#include "Obj.h"
|
||||||
#include "Queue.h"
|
#include "Queue.h"
|
||||||
#include "StmtEnums.h"
|
#include "StmtEnums.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -12,14 +13,15 @@
|
||||||
|
|
||||||
template <class T> class IntrusivePtr;
|
template <class T> class IntrusivePtr;
|
||||||
class Val;
|
class Val;
|
||||||
class Stmt;
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
|
||||||
// This needs to be defined before we do the includes that come after it.
|
// This needs to be defined before we do the includes that come after it.
|
||||||
enum ParseLocationRecType { plrUnknown, plrFileAndLine, plrFunction };
|
enum ParseLocationRecType { plrUnknown, plrFileAndLine, plrFunction };
|
||||||
struct ParseLocationRec {
|
struct ParseLocationRec {
|
||||||
ParseLocationRecType type;
|
ParseLocationRecType type;
|
||||||
int32_t line;
|
int32_t line;
|
||||||
Stmt* stmt;
|
zeek::detail::Stmt* stmt;
|
||||||
const char* filename;
|
const char* filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ class DbgDisplay;
|
||||||
class StmtHashFn;
|
class StmtHashFn;
|
||||||
|
|
||||||
typedef std::map<int, DbgBreakpoint*> BPIDMapType;
|
typedef std::map<int, DbgBreakpoint*> BPIDMapType;
|
||||||
typedef std::multimap<const Stmt*, DbgBreakpoint*> BPMapType;
|
typedef std::multimap<const zeek::detail::Stmt*, DbgBreakpoint*> BPMapType;
|
||||||
|
|
||||||
extern std::string current_module;
|
extern std::string current_module;
|
||||||
|
|
||||||
|
@ -104,15 +106,15 @@ private:
|
||||||
class StmtLocMapping {
|
class StmtLocMapping {
|
||||||
public:
|
public:
|
||||||
StmtLocMapping() { }
|
StmtLocMapping() { }
|
||||||
StmtLocMapping(const Location* l, Stmt* s) { loc = *l; stmt = s; }
|
StmtLocMapping(const Location* l, zeek::detail::Stmt* s) { loc = *l; stmt = s; }
|
||||||
|
|
||||||
bool StartsAfter(const StmtLocMapping* m2);
|
bool StartsAfter(const StmtLocMapping* m2);
|
||||||
const Location& Loc() const { return loc; }
|
const Location& Loc() const { return loc; }
|
||||||
Stmt* Statement() const { return stmt; }
|
zeek::detail::Stmt* Statement() const { return stmt; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Location loc;
|
Location loc;
|
||||||
Stmt* stmt;
|
zeek::detail::Stmt* stmt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,8 +145,8 @@ std::vector<ParseLocationRec> parse_location_string(const std::string& s);
|
||||||
// Debugging hooks.
|
// Debugging hooks.
|
||||||
|
|
||||||
// Return true to continue execution, false to abort.
|
// Return true to continue execution, false to abort.
|
||||||
bool pre_execute_stmt(Stmt* stmt, Frame* f);
|
bool pre_execute_stmt(zeek::detail::Stmt* stmt, Frame* f);
|
||||||
bool post_execute_stmt(Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow);
|
bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow);
|
||||||
|
|
||||||
// Returns 1 if successful, 0 otherwise.
|
// Returns 1 if successful, 0 otherwise.
|
||||||
// If cmdfile is non-nil, it contains the location of a file of commands
|
// If cmdfile is non-nil, it contains the location of a file of commands
|
||||||
|
@ -168,7 +170,7 @@ IntrusivePtr<Val> dbg_eval_expr(const char* expr);
|
||||||
int dbg_read_internal_state();
|
int dbg_read_internal_state();
|
||||||
|
|
||||||
// Get line that looks like "In FnFoo(arg = val) at File:Line".
|
// Get line that looks like "In FnFoo(arg = val) at File:Line".
|
||||||
std::string get_context_description(const Stmt* stmt, const Frame* frame);
|
std::string get_context_description(const zeek::detail::Stmt* stmt, const Frame* frame);
|
||||||
|
|
||||||
extern Frame* g_dbg_locals; // variables created within debugger context
|
extern Frame* g_dbg_locals; // variables created within debugger context
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,13 @@ using namespace std;
|
||||||
//
|
//
|
||||||
// Helper routines
|
// Helper routines
|
||||||
//
|
//
|
||||||
bool string_is_regex(const string& s)
|
static bool string_is_regex(const string& s)
|
||||||
{
|
{
|
||||||
return strpbrk(s.data(), "?*\\+");
|
return strpbrk(s.data(), "?*\\+");
|
||||||
}
|
}
|
||||||
|
|
||||||
void lookup_global_symbols_regex(const string& orig_regex, vector<ID*>& matches,
|
static void lookup_global_symbols_regex(const string& orig_regex, vector<zeek::detail::ID*>& matches,
|
||||||
bool func_only = false)
|
bool func_only = false)
|
||||||
{
|
{
|
||||||
if ( streq(orig_regex.c_str(), "") )
|
if ( streq(orig_regex.c_str(), "") )
|
||||||
return;
|
return;
|
||||||
|
@ -61,18 +61,18 @@ void lookup_global_symbols_regex(const string& orig_regex, vector<ID*>& matches,
|
||||||
Scope* global = global_scope();
|
Scope* global = global_scope();
|
||||||
const auto& syms = global->Vars();
|
const auto& syms = global->Vars();
|
||||||
|
|
||||||
ID* nextid;
|
zeek::detail::ID* nextid;
|
||||||
for ( const auto& sym : syms )
|
for ( const auto& sym : syms )
|
||||||
{
|
{
|
||||||
ID* nextid = sym.second.get();
|
zeek::detail::ID* nextid = sym.second.get();
|
||||||
if ( ! func_only || nextid->GetType()->Tag() == TYPE_FUNC )
|
if ( ! func_only || nextid->GetType()->Tag() == zeek::TYPE_FUNC )
|
||||||
if ( ! regexec (&re, nextid->Name(), 0, 0, 0) )
|
if ( ! regexec (&re, nextid->Name(), 0, 0, 0) )
|
||||||
matches.push_back(nextid);
|
matches.push_back(nextid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void choose_global_symbols_regex(const string& regex, vector<ID*>& choices,
|
static void choose_global_symbols_regex(const string& regex, vector<zeek::detail::ID*>& choices,
|
||||||
bool func_only = false)
|
bool func_only = false)
|
||||||
{
|
{
|
||||||
lookup_global_symbols_regex(regex, choices, func_only);
|
lookup_global_symbols_regex(regex, choices, func_only);
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void choose_global_symbols_regex(const string& regex, vector<ID*>& choices,
|
||||||
int option = atoi(input.c_str());
|
int option = atoi(input.c_str());
|
||||||
if ( option > 0 && option <= (int) choices.size() )
|
if ( option > 0 && option <= (int) choices.size() )
|
||||||
{
|
{
|
||||||
ID* choice = choices[option - 1];
|
zeek::detail::ID* choice = choices[option - 1];
|
||||||
choices.clear();
|
choices.clear();
|
||||||
choices.push_back(choice);
|
choices.push_back(choice);
|
||||||
return;
|
return;
|
||||||
|
@ -216,7 +216,7 @@ static int dbg_backtrace_internal(int start, int end)
|
||||||
for ( int i = start; i >= end; --i )
|
for ( int i = start; i >= end; --i )
|
||||||
{
|
{
|
||||||
const Frame* f = g_frame_stack[i];
|
const Frame* f = g_frame_stack[i];
|
||||||
const Stmt* stmt = f ? f->GetNextStmt() : nullptr;
|
const zeek::detail::Stmt* stmt = f ? f->GetNextStmt() : nullptr;
|
||||||
|
|
||||||
string context = get_context_description(stmt, f);
|
string context = get_context_description(stmt, f);
|
||||||
debug_msg("#%d %s\n",
|
debug_msg("#%d %s\n",
|
||||||
|
@ -333,7 +333,7 @@ int dbg_cmd_frame(DebugCmd cmd, const vector<string>& args)
|
||||||
|
|
||||||
// Set the current location to the new frame being looked at
|
// Set the current location to the new frame being looked at
|
||||||
// for 'list', 'break', etc.
|
// for 'list', 'break', etc.
|
||||||
const Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
|
const zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
|
||||||
if ( ! stmt )
|
if ( ! stmt )
|
||||||
reporter->InternalError("Assertion failed: %s", "stmt != 0");
|
reporter->InternalError("Assertion failed: %s", "stmt != 0");
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector<string>& args)
|
||||||
g_frame_stack.size() - 1 -
|
g_frame_stack.size() - 1 -
|
||||||
g_debugger_state.curr_frame_idx;
|
g_debugger_state.curr_frame_idx;
|
||||||
|
|
||||||
Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
|
zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
|
||||||
if ( ! stmt )
|
if ( ! stmt )
|
||||||
reporter->InternalError("Assertion failed: %s", "stmt != 0");
|
reporter->InternalError("Assertion failed: %s", "stmt != 0");
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector<string>& args)
|
||||||
vector<string> locstrings;
|
vector<string> locstrings;
|
||||||
if ( string_is_regex(args[0]) )
|
if ( string_is_regex(args[0]) )
|
||||||
{
|
{
|
||||||
vector<ID*> choices;
|
vector<zeek::detail::ID*> choices;
|
||||||
choose_global_symbols_regex(args[0], choices, true);
|
choose_global_symbols_regex(args[0], choices, true);
|
||||||
for ( unsigned int i = 0; i < choices.size(); ++i )
|
for ( unsigned int i = 0; i < choices.size(); ++i )
|
||||||
locstrings.push_back(choices[i]->Name());
|
locstrings.push_back(choices[i]->Name());
|
||||||
|
|
|
@ -163,7 +163,7 @@ void DebugLogger::Log(DebugStream stream, const char* fmt, ...)
|
||||||
fflush(file);
|
fflush(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugLogger::Log(const plugin::Plugin& plugin, const char* fmt, ...)
|
void DebugLogger::Log(const zeek::plugin::Plugin& plugin, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
std::string tok = std::string("plugin-") + plugin.Name();
|
std::string tok = std::string("plugin-") + plugin.Name();
|
||||||
tok = strreplace(tok, "::", "-");
|
tok = strreplace(tok, "::", "-");
|
||||||
|
|
|
@ -45,7 +45,7 @@ enum DebugStream {
|
||||||
|
|
||||||
#define PLUGIN_DBG_LOG(plugin, args...) debug_logger.Log(plugin, args)
|
#define PLUGIN_DBG_LOG(plugin, args...) debug_logger.Log(plugin, args)
|
||||||
|
|
||||||
namespace plugin { class Plugin; }
|
namespace zeek::plugin { class Plugin; }
|
||||||
|
|
||||||
class DebugLogger {
|
class DebugLogger {
|
||||||
public:
|
public:
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
void OpenDebugLog(const char* filename = 0);
|
void OpenDebugLog(const char* filename = 0);
|
||||||
|
|
||||||
void Log(DebugStream stream, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
void Log(DebugStream stream, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||||
void Log(const plugin::Plugin& plugin, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
void Log(const zeek::plugin::Plugin& plugin, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||||
|
|
||||||
void PushIndent(DebugStream stream)
|
void PushIndent(DebugStream stream)
|
||||||
{ ++streams[int(stream)].indent; }
|
{ ++streams[int(stream)].indent; }
|
||||||
|
|
|
@ -403,19 +403,19 @@ void ODesc::Clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ODesc::PushType(const BroType* type)
|
bool ODesc::PushType(const zeek::Type* type)
|
||||||
{
|
{
|
||||||
auto res = encountered_types.insert(type);
|
auto res = encountered_types.insert(type);
|
||||||
return std::get<1>(res);
|
return std::get<1>(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ODesc::PopType(const BroType* type)
|
bool ODesc::PopType(const zeek::Type* type)
|
||||||
{
|
{
|
||||||
size_t res = encountered_types.erase(type);
|
size_t res = encountered_types.erase(type);
|
||||||
return (res == 1);
|
return (res == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ODesc::FindType(const BroType* type)
|
bool ODesc::FindType(const zeek::Type* type)
|
||||||
{
|
{
|
||||||
auto res = encountered_types.find(type);
|
auto res = encountered_types.find(type);
|
||||||
|
|
||||||
|
|
12
src/Desc.h
12
src/Desc.h
|
@ -25,7 +25,9 @@ typedef enum {
|
||||||
class BroFile;
|
class BroFile;
|
||||||
class IPAddr;
|
class IPAddr;
|
||||||
class IPPrefix;
|
class IPPrefix;
|
||||||
class BroType;
|
|
||||||
|
namespace zeek { class Type; }
|
||||||
|
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||||
|
|
||||||
class ODesc {
|
class ODesc {
|
||||||
public:
|
public:
|
||||||
|
@ -146,9 +148,9 @@ public:
|
||||||
|
|
||||||
// Used to determine recursive types. Records push their types on here;
|
// Used to determine recursive types. Records push their types on here;
|
||||||
// if the same type (by address) is re-encountered, processing aborts.
|
// if the same type (by address) is re-encountered, processing aborts.
|
||||||
bool PushType(const BroType* type);
|
bool PushType(const zeek::Type* type);
|
||||||
bool PopType(const BroType* type);
|
bool PopType(const zeek::Type* type);
|
||||||
bool FindType(const BroType* type);
|
bool FindType(const zeek::Type* type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Indent();
|
void Indent();
|
||||||
|
@ -204,5 +206,5 @@ protected:
|
||||||
bool do_flush;
|
bool do_flush;
|
||||||
bool include_stats;
|
bool include_stats;
|
||||||
|
|
||||||
std::set<const BroType*> encountered_types;
|
std::set<const zeek::Type*> encountered_types;
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,7 +145,7 @@ protected:
|
||||||
analyzer::ID current_aid;
|
analyzer::ID current_aid;
|
||||||
RecordVal* src_val;
|
RecordVal* src_val;
|
||||||
bool draining;
|
bool draining;
|
||||||
bro::Flare queue_flare;
|
zeek::detail::Flare queue_flare;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EventMgr mgr;
|
extern EventMgr mgr;
|
||||||
|
|
|
@ -26,7 +26,7 @@ EventHandler::operator bool() const
|
||||||
|| ! auto_publish.empty());
|
|| ! auto_publish.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<FuncType>& EventHandler::GetType(bool check_export)
|
const IntrusivePtr<zeek::FuncType>& EventHandler::GetType(bool check_export)
|
||||||
{
|
{
|
||||||
if ( type )
|
if ( type )
|
||||||
return type;
|
return type;
|
||||||
|
@ -35,15 +35,21 @@ const IntrusivePtr<FuncType>& EventHandler::GetType(bool check_export)
|
||||||
check_export);
|
check_export);
|
||||||
|
|
||||||
if ( ! id )
|
if ( ! id )
|
||||||
return FuncType::nil;
|
return zeek::FuncType::nil;
|
||||||
|
|
||||||
if ( id->GetType()->Tag() != TYPE_FUNC )
|
if ( id->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||||
return FuncType::nil;
|
return zeek::FuncType::nil;
|
||||||
|
|
||||||
type = id->GetType<FuncType>();
|
type = id->GetType<zeek::FuncType>();
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventHandler::SetFunc(IntrusivePtr<Func> f)
|
||||||
|
{ local = std::move(f); }
|
||||||
|
|
||||||
|
void EventHandler::SetLocalHandler(Func* f)
|
||||||
|
{ SetFunc({NewRef{}, f}); }
|
||||||
|
|
||||||
void EventHandler::Call(zeek::Args* vl, bool no_remote)
|
void EventHandler::Call(zeek::Args* vl, bool no_remote)
|
||||||
{
|
{
|
||||||
#ifdef PROFILE_BRO_FUNCTIONS
|
#ifdef PROFILE_BRO_FUNCTIONS
|
||||||
|
@ -111,7 +117,7 @@ void EventHandler::NewEvent(zeek::Args* vl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& args = GetType()->Params();
|
const auto& args = GetType()->Params();
|
||||||
static auto call_argument_vector = zeek::id::find_type<VectorType>("call_argument_vector");
|
static auto call_argument_vector = zeek::id::find_type<zeek::VectorType>("call_argument_vector");
|
||||||
auto vargs = make_intrusive<VectorVal>(call_argument_vector);
|
auto vargs = make_intrusive<VectorVal>(call_argument_vector);
|
||||||
|
|
||||||
for ( int i = 0; i < args->NumFields(); i++ )
|
for ( int i = 0; i < args->NumFields(); i++ )
|
||||||
|
@ -120,7 +126,7 @@ void EventHandler::NewEvent(zeek::Args* vl)
|
||||||
const auto& ftype = args->GetFieldType(i);
|
const auto& ftype = args->GetFieldType(i);
|
||||||
auto fdefault = args->FieldDefault(i);
|
auto fdefault = args->FieldDefault(i);
|
||||||
|
|
||||||
static auto call_argument = zeek::id::find_type<RecordType>("call_argument");
|
static auto call_argument = zeek::id::find_type<zeek::RecordType>("call_argument");
|
||||||
auto rec = make_intrusive<RecordVal>(call_argument);
|
auto rec = make_intrusive<RecordVal>(call_argument);
|
||||||
rec->Assign(0, make_intrusive<StringVal>(fname));
|
rec->Assign(0, make_intrusive<StringVal>(fname));
|
||||||
|
|
||||||
|
@ -144,4 +150,3 @@ void EventHandler::NewEvent(zeek::Args* vl)
|
||||||
});
|
});
|
||||||
mgr.Dispatch(ev);
|
mgr.Dispatch(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#include "BroList.h"
|
#include "BroList.h"
|
||||||
#include "ZeekArgs.h"
|
#include "ZeekArgs.h"
|
||||||
#include "Type.h"
|
#include "Type.h"
|
||||||
#include "Func.h"
|
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
class Func;
|
||||||
|
|
||||||
class EventHandler {
|
class EventHandler {
|
||||||
public:
|
public:
|
||||||
explicit EventHandler(std::string name);
|
explicit EventHandler(std::string name);
|
||||||
|
@ -22,18 +23,16 @@ public:
|
||||||
[[deprecated("Remove in v4.1. Use GetFunc().")]]
|
[[deprecated("Remove in v4.1. Use GetFunc().")]]
|
||||||
Func* LocalHandler() { return local.get(); }
|
Func* LocalHandler() { return local.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<FuncType>& GetType(bool check_export = true);
|
const IntrusivePtr<zeek::FuncType>& GetType(bool check_export = true);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||||
FuncType* FType(bool check_export = true)
|
zeek::FuncType* FType(bool check_export = true)
|
||||||
{ return GetType().get(); }
|
{ return GetType().get(); }
|
||||||
|
|
||||||
void SetFunc(IntrusivePtr<Func> f)
|
void SetFunc(IntrusivePtr<Func> f);
|
||||||
{ local = std::move(f); }
|
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use SetFunc().")]]
|
[[deprecated("Remove in v4.1. Use SetFunc().")]]
|
||||||
void SetLocalHandler(Func* f)
|
void SetLocalHandler(Func* f);
|
||||||
{ SetFunc({NewRef{}, f}); }
|
|
||||||
|
|
||||||
void AutoPublish(std::string topic)
|
void AutoPublish(std::string topic)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +69,7 @@ private:
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
IntrusivePtr<Func> local;
|
IntrusivePtr<Func> local;
|
||||||
IntrusivePtr<FuncType> type;
|
IntrusivePtr<zeek::FuncType> type;
|
||||||
bool used; // this handler is indeed used somewhere
|
bool used; // this handler is indeed used somewhere
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool error_handler; // this handler reports error messages.
|
bool error_handler; // this handler reports error messages.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "EventRegistry.h"
|
#include "EventRegistry.h"
|
||||||
#include "EventHandler.h"
|
#include "EventHandler.h"
|
||||||
|
#include "Func.h"
|
||||||
#include "RE.h"
|
#include "RE.h"
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
|
|
||||||
|
|
502
src/Expr.cc
502
src/Expr.cc
File diff suppressed because it is too large
Load diff
123
src/Expr.h
123
src/Expr.h
|
@ -17,6 +17,13 @@
|
||||||
#include "Val.h"
|
#include "Val.h"
|
||||||
#include "ZeekArgs.h"
|
#include "ZeekArgs.h"
|
||||||
|
|
||||||
|
template <class T> class IntrusivePtr;
|
||||||
|
class Frame;
|
||||||
|
class Scope;
|
||||||
|
struct function_ingredients;
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
enum BroExprTag : int {
|
enum BroExprTag : int {
|
||||||
EXPR_ANY = -1,
|
EXPR_ANY = -1,
|
||||||
EXPR_NAME, EXPR_CONST,
|
EXPR_NAME, EXPR_CONST,
|
||||||
|
@ -58,26 +65,20 @@ enum BroExprTag : int {
|
||||||
|
|
||||||
extern const char* expr_name(BroExprTag t);
|
extern const char* expr_name(BroExprTag t);
|
||||||
|
|
||||||
template <class T> class IntrusivePtr;
|
|
||||||
class Stmt;
|
|
||||||
class Frame;
|
|
||||||
class Scope;
|
|
||||||
class ListExpr;
|
class ListExpr;
|
||||||
class NameExpr;
|
class NameExpr;
|
||||||
class IndexExpr;
|
class IndexExpr;
|
||||||
class AssignExpr;
|
class AssignExpr;
|
||||||
class CallExpr;
|
class CallExpr;
|
||||||
class EventExpr;
|
class EventExpr;
|
||||||
|
class Stmt;
|
||||||
struct function_ingredients;
|
|
||||||
|
|
||||||
|
|
||||||
class Expr : public BroObj {
|
class Expr : public BroObj {
|
||||||
public:
|
public:
|
||||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||||
BroType* Type() const { return type.get(); }
|
zeek::Type* Type() const { return type.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& GetType() const
|
const IntrusivePtr<zeek::Type>& GetType() const
|
||||||
{ return type; }
|
{ return type; }
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -96,7 +97,7 @@ public:
|
||||||
// into the given aggregate of the given type. Note that
|
// into the given aggregate of the given type. Note that
|
||||||
// return type is void since it's updating an existing
|
// return type is void since it's updating an existing
|
||||||
// value, rather than creating a new one.
|
// value, rather than creating a new one.
|
||||||
virtual void EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f)
|
virtual void EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f)
|
||||||
const;
|
const;
|
||||||
|
|
||||||
// Assign to the given value, if appropriate.
|
// Assign to the given value, if appropriate.
|
||||||
|
@ -104,7 +105,7 @@ public:
|
||||||
|
|
||||||
// Returns the type corresponding to this expression interpreted
|
// Returns the type corresponding to this expression interpreted
|
||||||
// as an initialization. Returns nil if the initialization is illegal.
|
// as an initialization. Returns nil if the initialization is illegal.
|
||||||
virtual IntrusivePtr<BroType> InitType() const;
|
virtual IntrusivePtr<zeek::Type> InitType() const;
|
||||||
|
|
||||||
// Returns true if this expression, interpreted as an initialization,
|
// Returns true if this expression, interpreted as an initialization,
|
||||||
// constitutes a record element, false otherwise. If the TypeDecl*
|
// constitutes a record element, false otherwise. If the TypeDecl*
|
||||||
|
@ -117,7 +118,7 @@ public:
|
||||||
// with the given type. If "aggr" is non-nil, then this expression
|
// with the given type. If "aggr" is non-nil, then this expression
|
||||||
// is an element of the given aggregate, and it is added to it
|
// is an element of the given aggregate, and it is added to it
|
||||||
// accordingly.
|
// accordingly.
|
||||||
virtual IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const;
|
virtual IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const;
|
||||||
|
|
||||||
// True if the expression has no side effects, false otherwise.
|
// True if the expression has no side effects, false otherwise.
|
||||||
virtual bool IsPure() const;
|
virtual bool IsPure() const;
|
||||||
|
@ -222,7 +223,7 @@ protected:
|
||||||
// Puts the expression in canonical form.
|
// Puts the expression in canonical form.
|
||||||
virtual void Canonicize();
|
virtual void Canonicize();
|
||||||
|
|
||||||
void SetType(IntrusivePtr<BroType> t);
|
void SetType(IntrusivePtr<zeek::Type> t);
|
||||||
|
|
||||||
// Reports the given error and sets the expression's type to
|
// Reports the given error and sets the expression's type to
|
||||||
// TYPE_ERROR.
|
// TYPE_ERROR.
|
||||||
|
@ -234,7 +235,7 @@ protected:
|
||||||
[[noreturn]] void RuntimeErrorWithCallStack(const std::string& msg) const;
|
[[noreturn]] void RuntimeErrorWithCallStack(const std::string& msg) const;
|
||||||
|
|
||||||
BroExprTag tag;
|
BroExprTag tag;
|
||||||
IntrusivePtr<BroType> type;
|
IntrusivePtr<zeek::Type> type;
|
||||||
bool paren;
|
bool paren;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -523,10 +524,10 @@ public:
|
||||||
const IntrusivePtr<Attributes>& attrs = nullptr);
|
const IntrusivePtr<Attributes>& attrs = nullptr);
|
||||||
|
|
||||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||||
void EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const override;
|
void EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f) const override;
|
||||||
IntrusivePtr<BroType> InitType() const override;
|
IntrusivePtr<zeek::Type> InitType() const override;
|
||||||
bool IsRecordElement(TypeDecl* td) const override;
|
bool IsRecordElement(TypeDecl* td) const override;
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
bool IsPure() const override;
|
bool IsPure() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -623,7 +624,7 @@ public:
|
||||||
~RecordConstructorExpr() override;
|
~RecordConstructorExpr() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
IntrusivePtr<Val> Fold(Val* v) const override;
|
IntrusivePtr<Val> Fold(Val* v) const override;
|
||||||
|
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
|
@ -633,7 +634,7 @@ class TableConstructorExpr final : public UnaryExpr {
|
||||||
public:
|
public:
|
||||||
TableConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
TableConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs,
|
||||||
IntrusivePtr<BroType> arg_type = nullptr);
|
IntrusivePtr<zeek::Type> arg_type = nullptr);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetAttrs().")]]
|
[[deprecated("Remove in v4.1. Use GetAttrs().")]]
|
||||||
Attributes* Attrs() { return attrs.get(); }
|
Attributes* Attrs() { return attrs.get(); }
|
||||||
|
@ -644,7 +645,7 @@ public:
|
||||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
|
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
|
|
||||||
|
@ -655,7 +656,7 @@ class SetConstructorExpr final : public UnaryExpr {
|
||||||
public:
|
public:
|
||||||
SetConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
SetConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs,
|
||||||
IntrusivePtr<BroType> arg_type = nullptr);
|
IntrusivePtr<zeek::Type> arg_type = nullptr);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetAttrs().")]]
|
[[deprecated("Remove in v4.1. Use GetAttrs().")]]
|
||||||
Attributes* Attrs() { return attrs.get(); }
|
Attributes* Attrs() { return attrs.get(); }
|
||||||
|
@ -666,7 +667,7 @@ public:
|
||||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
|
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
|
|
||||||
|
@ -676,12 +677,12 @@ protected:
|
||||||
class VectorConstructorExpr final : public UnaryExpr {
|
class VectorConstructorExpr final : public UnaryExpr {
|
||||||
public:
|
public:
|
||||||
explicit VectorConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
explicit VectorConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||||
IntrusivePtr<BroType> arg_type = nullptr);
|
IntrusivePtr<zeek::Type> arg_type = nullptr);
|
||||||
|
|
||||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
|
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
};
|
};
|
||||||
|
@ -692,7 +693,7 @@ public:
|
||||||
|
|
||||||
const char* FieldName() const { return field_name.c_str(); }
|
const char* FieldName() const { return field_name.c_str(); }
|
||||||
|
|
||||||
void EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const override;
|
void EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f) const override;
|
||||||
bool IsRecordElement(TypeDecl* td) const override;
|
bool IsRecordElement(TypeDecl* td) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -703,7 +704,7 @@ protected:
|
||||||
|
|
||||||
class ArithCoerceExpr final : public UnaryExpr {
|
class ArithCoerceExpr final : public UnaryExpr {
|
||||||
public:
|
public:
|
||||||
ArithCoerceExpr(IntrusivePtr<Expr> op, TypeTag t);
|
ArithCoerceExpr(IntrusivePtr<Expr> op, zeek::TypeTag t);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> FoldSingleVal(Val* v, InternalTypeTag t) const;
|
IntrusivePtr<Val> FoldSingleVal(Val* v, InternalTypeTag t) const;
|
||||||
|
@ -716,7 +717,7 @@ public:
|
||||||
~RecordCoerceExpr() override;
|
~RecordCoerceExpr() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
IntrusivePtr<Val> Fold(Val* v) const override;
|
IntrusivePtr<Val> Fold(Val* v) const override;
|
||||||
|
|
||||||
// For each super-record slot, gives subrecord slot with which to
|
// For each super-record slot, gives subrecord slot with which to
|
||||||
|
@ -867,15 +868,15 @@ public:
|
||||||
|
|
||||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||||
|
|
||||||
IntrusivePtr<BroType> InitType() const override;
|
IntrusivePtr<zeek::Type> InitType() const override;
|
||||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||||
IntrusivePtr<Expr> MakeLvalue() override;
|
IntrusivePtr<Expr> MakeLvalue() override;
|
||||||
void Assign(Frame* f, IntrusivePtr<Val> v) override;
|
void Assign(Frame* f, IntrusivePtr<Val> v) override;
|
||||||
|
|
||||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> AddSetInit(const BroType* t, IntrusivePtr<Val> aggr) const;
|
IntrusivePtr<Val> AddSetInit(const zeek::Type* t, IntrusivePtr<Val> aggr) const;
|
||||||
|
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
|
|
||||||
|
@ -890,7 +891,7 @@ public:
|
||||||
|
|
||||||
class CastExpr final : public UnaryExpr {
|
class CastExpr final : public UnaryExpr {
|
||||||
public:
|
public:
|
||||||
CastExpr(IntrusivePtr<Expr> op, IntrusivePtr<BroType> t);
|
CastExpr(IntrusivePtr<Expr> op, IntrusivePtr<zeek::Type> t);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||||
|
@ -899,14 +900,14 @@ protected:
|
||||||
|
|
||||||
class IsExpr final : public UnaryExpr {
|
class IsExpr final : public UnaryExpr {
|
||||||
public:
|
public:
|
||||||
IsExpr(IntrusivePtr<Expr> op, IntrusivePtr<BroType> t);
|
IsExpr(IntrusivePtr<Expr> op, IntrusivePtr<zeek::Type> t);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Val> Fold(Val* v) const override;
|
IntrusivePtr<Val> Fold(Val* v) const override;
|
||||||
void ExprDescribe(ODesc* d) const override;
|
void ExprDescribe(ODesc* d) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IntrusivePtr<BroType> t;
|
IntrusivePtr<zeek::Type> t;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Val* Expr::ExprVal() const
|
inline Val* Expr::ExprVal() const
|
||||||
|
@ -935,11 +936,11 @@ IntrusivePtr<Expr> get_assign_expr(IntrusivePtr<Expr> op1,
|
||||||
* Returns nullptr if the expression cannot match or a promoted
|
* Returns nullptr if the expression cannot match or a promoted
|
||||||
* expression.
|
* expression.
|
||||||
*/
|
*/
|
||||||
extern IntrusivePtr<Expr> check_and_promote_expr(Expr* e, BroType* t);
|
extern IntrusivePtr<Expr> check_and_promote_expr(Expr* e, Type* t);
|
||||||
|
|
||||||
extern bool check_and_promote_exprs(ListExpr* elements, TypeList* types);
|
extern bool check_and_promote_exprs(ListExpr* elements, TypeList* types);
|
||||||
extern bool check_and_promote_args(ListExpr* args, RecordType* types);
|
extern bool check_and_promote_args(ListExpr* args, RecordType* types);
|
||||||
extern bool check_and_promote_exprs_to_type(ListExpr* elements, BroType* type);
|
extern bool check_and_promote_exprs_to_type(ListExpr* elements, Type* type);
|
||||||
|
|
||||||
// Returns a ListExpr simplified down to a list a values, or nil
|
// Returns a ListExpr simplified down to a list a values, or nil
|
||||||
// if they couldn't all be reduced.
|
// if they couldn't all be reduced.
|
||||||
|
@ -953,3 +954,55 @@ extern bool expr_greater(const Expr* e1, const Expr* e2);
|
||||||
// True if the given Expr* has a vector type
|
// True if the given Expr* has a vector type
|
||||||
inline bool is_vector(Expr* e) { return e->GetType()->Tag() == TYPE_VECTOR; }
|
inline bool is_vector(Expr* e) { return e->GetType()->Tag() == TYPE_VECTOR; }
|
||||||
inline bool is_vector(const IntrusivePtr<Expr>& e) { return is_vector(e.get()); }
|
inline bool is_vector(const IntrusivePtr<Expr>& e) { return is_vector(e.get()); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using Expr [[deprecated("Remove in v4.1. Use zeek::detail::Expr instead.")]] = zeek::detail::Expr;
|
||||||
|
using NameExpr [[deprecated("Remove in v4.1. Use zeek::detail::NameExpr instead.")]] = zeek::detail::NameExpr;
|
||||||
|
using ConstExpr [[deprecated("Remove in v4.1. Use zeek::detail::ConstExpr instead.")]] = zeek::detail::ConstExpr;
|
||||||
|
using UnaryExpr [[deprecated("Remove in v4.1. Use zeek::detail::UnaryExpr instead.")]] = zeek::detail::UnaryExpr;
|
||||||
|
using BinaryExpr [[deprecated("Remove in v4.1. Use zeek::detail::BinaryExpr instead.")]] = zeek::detail::BinaryExpr;
|
||||||
|
using CloneExpr [[deprecated("Remove in v4.1. Use zeek::detail::CloneExpr instead.")]] = zeek::detail::CloneExpr;
|
||||||
|
using IncrExpr [[deprecated("Remove in v4.1. Use zeek::detail::IncrExpr instead.")]] = zeek::detail::IncrExpr;
|
||||||
|
using ComplementExpr [[deprecated("Remove in v4.1. Use zeek::detail::ComplementExpr instead.")]] = zeek::detail::ComplementExpr;
|
||||||
|
using NotExpr [[deprecated("Remove in v4.1. Use zeek::detail::NotExpr instead.")]] = zeek::detail::NotExpr;
|
||||||
|
using PosExpr [[deprecated("Remove in v4.1. Use zeek::detail::PosExpr instead.")]] = zeek::detail::PosExpr;
|
||||||
|
using NegExpr [[deprecated("Remove in v4.1. Use zeek::detail::NegExpr instead.")]] = zeek::detail::NegExpr;
|
||||||
|
using SizeExpr [[deprecated("Remove in v4.1. Use zeek::detail::SizeExpr instead.")]] = zeek::detail::SizeExpr;
|
||||||
|
using AddExpr [[deprecated("Remove in v4.1. Use zeek::detail::AddExpr instead.")]] = zeek::detail::AddExpr;
|
||||||
|
using AddToExpr [[deprecated("Remove in v4.1. Use zeek::detail::AddToExpr instead.")]] = zeek::detail::AddToExpr;
|
||||||
|
using RemoveFromExpr [[deprecated("Remove in v4.1. Use zeek::detail::RemoveFromExpr instead.")]] = zeek::detail::RemoveFromExpr;
|
||||||
|
using SubExpr [[deprecated("Remove in v4.1. Use zeek::detail::SubExpr instead.")]] = zeek::detail::SubExpr;
|
||||||
|
using TimesExpr [[deprecated("Remove in v4.1. Use zeek::detail::TimesExpr instead.")]] = zeek::detail::TimesExpr;
|
||||||
|
using DivideExpr [[deprecated("Remove in v4.1. Use zeek::detail::DivideExpr instead.")]] = zeek::detail::DivideExpr;
|
||||||
|
using ModExpr [[deprecated("Remove in v4.1. Use zeek::detail::ModExpr instead.")]] = zeek::detail::ModExpr;
|
||||||
|
using BoolExpr [[deprecated("Remove in v4.1. Use zeek::detail::BoolExpr instead.")]] = zeek::detail::BoolExpr;
|
||||||
|
using BitExpr [[deprecated("Remove in v4.1. Use zeek::detail::BitExpr instead.")]] = zeek::detail::BitExpr;
|
||||||
|
using EqExpr [[deprecated("Remove in v4.1. Use zeek::detail::EqExpr instead.")]] = zeek::detail::EqExpr;
|
||||||
|
using RelExpr [[deprecated("Remove in v4.1. Use zeek::detail::RelExpr instead.")]] = zeek::detail::RelExpr;
|
||||||
|
using CondExpr [[deprecated("Remove in v4.1. Use zeek::detail::CondExpr instead.")]] = zeek::detail::CondExpr;
|
||||||
|
using RefExpr [[deprecated("Remove in v4.1. Use zeek::detail::RefExpr instead.")]] = zeek::detail::RefExpr;
|
||||||
|
using AssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::AssignExpr instead.")]] = zeek::detail::AssignExpr;
|
||||||
|
using IndexSliceAssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::IndexSliceAssignExpr instead.")]] = zeek::detail::IndexSliceAssignExpr;
|
||||||
|
using IndexExpr [[deprecated("Remove in v4.1. Use zeek::detail::IndexExpr instead.")]] = zeek::detail::IndexExpr;
|
||||||
|
using FieldExpr [[deprecated("Remove in v4.1. Use zeek::detail::FieldExpr instead.")]] = zeek::detail::FieldExpr;
|
||||||
|
using HasFieldExpr [[deprecated("Remove in v4.1. Use zeek::detail::HasFieldExpr instead.")]] = zeek::detail::HasFieldExpr;
|
||||||
|
using RecordConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::RecordConstructorExpr instead.")]] = zeek::detail::RecordConstructorExpr;
|
||||||
|
using TableConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::TableConstructorExpr instead.")]] = zeek::detail::TableConstructorExpr;
|
||||||
|
using SetConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::SetConstructorExpr instead.")]] = zeek::detail::SetConstructorExpr;
|
||||||
|
using VectorConstructorExpr [[deprecated("Remove in v4.1. Use zeek::detail::VectorConstructorExpr instead.")]] = zeek::detail::VectorConstructorExpr;
|
||||||
|
using FieldAssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::FieldAssignExpr instead.")]] = zeek::detail::FieldAssignExpr;
|
||||||
|
using ArithCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::ArithCoerceExpr instead.")]] = zeek::detail::ArithCoerceExpr;
|
||||||
|
using RecordCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::RecordCoerceExpr instead.")]] = zeek::detail::RecordCoerceExpr;
|
||||||
|
using TableCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::TableCoerceExpr instead.")]] = zeek::detail::TableCoerceExpr;
|
||||||
|
using VectorCoerceExpr [[deprecated("Remove in v4.1. Use zeek::detail::VectorCoerceExpr instead.")]] = zeek::detail::VectorCoerceExpr;
|
||||||
|
using ScheduleTimer [[deprecated("Remove in v4.1. Use zeek::detail::ScheduleTimer instead.")]] = zeek::detail::ScheduleTimer;
|
||||||
|
using ScheduleExpr [[deprecated("Remove in v4.1. Use zeek::detail::ScheduleExpr instead.")]] = zeek::detail::ScheduleExpr;
|
||||||
|
using InExpr [[deprecated("Remove in v4.1. Use zeek::detail::InExpr instead.")]] = zeek::detail::InExpr;
|
||||||
|
using CallExpr [[deprecated("Remove in v4.1. Use zeek::detail::CallExpr instead.")]] = zeek::detail::CallExpr;
|
||||||
|
using LambdaExpr [[deprecated("Remove in v4.1. Use zeek::detail::LambdaExpr instead.")]] = zeek::detail::LambdaExpr;
|
||||||
|
using EventExpr [[deprecated("Remove in v4.1. Use zeek::detail::EventExpr instead.")]] = zeek::detail::EventExpr;
|
||||||
|
using ListExpr [[deprecated("Remove in v4.1. Use zeek::detail::ListExpr instead.")]] = zeek::detail::ListExpr;
|
||||||
|
using RecordAssignExpr [[deprecated("Remove in v4.1. Use zeek::detail::RecordAssignExpr instead.")]] = zeek::detail::RecordAssignExpr;
|
||||||
|
using CastExpr [[deprecated("Remove in v4.1. Use zeek::detail::CastExpr instead.")]] = zeek::detail::CastExpr;
|
||||||
|
using IsExpr [[deprecated("Remove in v4.1. Use zeek::detail::IsExpr instead.")]] = zeek::detail::IsExpr;
|
||||||
|
|
12
src/File.cc
12
src/File.cc
|
@ -58,7 +58,7 @@ BroFile::BroFile(FILE* arg_f)
|
||||||
Init();
|
Init();
|
||||||
f = arg_f;
|
f = arg_f;
|
||||||
name = access = nullptr;
|
name = access = nullptr;
|
||||||
t = base_type(TYPE_STRING);
|
t = zeek::base_type(zeek::TYPE_STRING);
|
||||||
is_open = (f != nullptr);
|
is_open = (f != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ BroFile::BroFile(FILE* arg_f, const char* arg_name, const char* arg_access)
|
||||||
f = arg_f;
|
f = arg_f;
|
||||||
name = copy_string(arg_name);
|
name = copy_string(arg_name);
|
||||||
access = copy_string(arg_access);
|
access = copy_string(arg_access);
|
||||||
t = base_type(TYPE_STRING);
|
t = zeek::base_type(zeek::TYPE_STRING);
|
||||||
is_open = (f != nullptr);
|
is_open = (f != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access)
|
||||||
f = nullptr;
|
f = nullptr;
|
||||||
name = copy_string(arg_name);
|
name = copy_string(arg_name);
|
||||||
access = copy_string(arg_access);
|
access = copy_string(arg_access);
|
||||||
t = base_type(TYPE_STRING);
|
t = zeek::base_type(zeek::TYPE_STRING);
|
||||||
|
|
||||||
if ( streq(name, "/dev/stdin") )
|
if ( streq(name, "/dev/stdin") )
|
||||||
f = stdin;
|
f = stdin;
|
||||||
|
@ -257,7 +257,7 @@ void BroFile::Describe(ODesc* d) const
|
||||||
d->Add("(no type)");
|
d->Add("(no type)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BroFile::SetAttrs(Attributes* arg_attrs)
|
void BroFile::SetAttrs(zeek::detail::Attributes* arg_attrs)
|
||||||
{
|
{
|
||||||
if ( ! arg_attrs )
|
if ( ! arg_attrs )
|
||||||
return;
|
return;
|
||||||
|
@ -265,7 +265,7 @@ void BroFile::SetAttrs(Attributes* arg_attrs)
|
||||||
attrs = arg_attrs;
|
attrs = arg_attrs;
|
||||||
Ref(attrs);
|
Ref(attrs);
|
||||||
|
|
||||||
if ( attrs->Find(ATTR_RAW_OUTPUT) )
|
if ( attrs->Find(zeek::detail::ATTR_RAW_OUTPUT) )
|
||||||
EnableRawOutput();
|
EnableRawOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ RecordVal* BroFile::Rotate()
|
||||||
if ( f == stdin || f == stdout || f == stderr )
|
if ( f == stdin || f == stdout || f == stderr )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
static auto rotate_info = zeek::id::find_type<RecordType>("rotate_info");
|
static auto rotate_info = zeek::id::find_type<zeek::RecordType>("rotate_info");
|
||||||
RecordVal* info = new RecordVal(rotate_info);
|
RecordVal* info = new RecordVal(rotate_info);
|
||||||
FILE* newf = rotate_file(name, info);
|
FILE* newf = rotate_file(name, info);
|
||||||
|
|
||||||
|
|
33
src/File.h
33
src/File.h
|
@ -2,23 +2,28 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Obj.h"
|
|
||||||
#include "IntrusivePtr.h"
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
# ifdef NEED_KRB5_H
|
#ifdef NEED_KRB5_H
|
||||||
# include <krb5.h>
|
#include <krb5.h>
|
||||||
# endif // NEED_KRB5_H
|
#endif // NEED_KRB5_H
|
||||||
|
|
||||||
|
#include "Obj.h"
|
||||||
|
#include "IntrusivePtr.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class Attributes;
|
|
||||||
class BroType;
|
|
||||||
class RecordVal;
|
class RecordVal;
|
||||||
|
|
||||||
|
namespace zeek { class Type; }
|
||||||
|
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(PrintStmt, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail);
|
||||||
|
|
||||||
class BroFile final : public BroObj {
|
class BroFile final : public BroObj {
|
||||||
public:
|
public:
|
||||||
explicit BroFile(FILE* arg_f);
|
explicit BroFile(FILE* arg_f);
|
||||||
|
@ -38,9 +43,9 @@ public:
|
||||||
void SetBuf(bool buffered); // false=line buffered, true=fully buffered
|
void SetBuf(bool buffered); // false=line buffered, true=fully buffered
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||||
BroType* FType() const { return t.get(); }
|
zeek::Type* FType() const { return t.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& GetType() const
|
const IntrusivePtr<zeek::Type>& GetType() const
|
||||||
{ return t; }
|
{ return t; }
|
||||||
|
|
||||||
// Whether the file is open in a general sense; it might
|
// Whether the file is open in a general sense; it might
|
||||||
|
@ -58,7 +63,7 @@ public:
|
||||||
RecordVal* Rotate();
|
RecordVal* Rotate();
|
||||||
|
|
||||||
// Set &raw_output attribute.
|
// Set &raw_output attribute.
|
||||||
void SetAttrs(Attributes* attrs);
|
void SetAttrs(zeek::detail::Attributes* attrs);
|
||||||
|
|
||||||
// Returns the current size of the file, after fresh stat'ing.
|
// Returns the current size of the file, after fresh stat'ing.
|
||||||
double Size();
|
double Size();
|
||||||
|
@ -77,7 +82,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
friend class PrintStmt;
|
friend class zeek::detail::PrintStmt;
|
||||||
|
|
||||||
BroFile() { Init(); }
|
BroFile() { Init(); }
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -101,10 +106,10 @@ protected:
|
||||||
void RaiseOpenEvent();
|
void RaiseOpenEvent();
|
||||||
|
|
||||||
FILE* f;
|
FILE* f;
|
||||||
IntrusivePtr<BroType> t;
|
IntrusivePtr<zeek::Type> t;
|
||||||
char* name;
|
char* name;
|
||||||
char* access;
|
char* access;
|
||||||
Attributes* attrs;
|
zeek::detail::Attributes* attrs;
|
||||||
double open_time;
|
double open_time;
|
||||||
bool is_open; // whether the file is open in a general sense
|
bool is_open; // whether the file is open in a general sense
|
||||||
bool buffered;
|
bool buffered;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
using namespace bro;
|
using namespace zeek::detail;
|
||||||
|
|
||||||
Flare::Flare()
|
Flare::Flare()
|
||||||
: pipe(FD_CLOEXEC, FD_CLOEXEC, O_NONBLOCK, O_NONBLOCK)
|
: pipe(FD_CLOEXEC, FD_CLOEXEC, O_NONBLOCK, O_NONBLOCK)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "Pipe.h"
|
#include "Pipe.h"
|
||||||
|
|
||||||
namespace bro {
|
namespace zeek::detail {
|
||||||
|
|
||||||
class Flare {
|
class Flare {
|
||||||
public:
|
public:
|
||||||
|
@ -21,8 +21,7 @@ public:
|
||||||
* @return a file descriptor that will become ready if the flare has been
|
* @return a file descriptor that will become ready if the flare has been
|
||||||
* Fire()'d and not yet Extinguished()'d.
|
* Fire()'d and not yet Extinguished()'d.
|
||||||
*/
|
*/
|
||||||
int FD() const
|
int FD() const { return pipe.ReadFD(); }
|
||||||
{ return pipe.ReadFD(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put the object in the "ready" state.
|
* Put the object in the "ready" state.
|
||||||
|
@ -44,4 +43,4 @@ private:
|
||||||
Pipe pipe;
|
Pipe pipe;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace bro
|
} // namespace zeek::detail
|
||||||
|
|
20
src/Frame.cc
20
src/Frame.cc
|
@ -77,7 +77,7 @@ void Frame::SetElementWeak(int n, Val* v)
|
||||||
frame[n] = {{AdoptRef{}, v}, true};
|
frame[n] = {{AdoptRef{}, v}, true};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::SetElement(const ID* id, IntrusivePtr<Val> v)
|
void Frame::SetElement(const zeek::detail::ID* id, IntrusivePtr<Val> v)
|
||||||
{
|
{
|
||||||
if ( closure )
|
if ( closure )
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ void Frame::SetElement(const ID* id, IntrusivePtr<Val> v)
|
||||||
SetElement(id->Offset(), std::move(v));
|
SetElement(id->Offset(), std::move(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<Val>& Frame::GetElementByID(const ID* id) const
|
const IntrusivePtr<Val>& Frame::GetElementByID(const zeek::detail::ID* id) const
|
||||||
{
|
{
|
||||||
if ( closure )
|
if ( closure )
|
||||||
{
|
{
|
||||||
|
@ -175,7 +175,7 @@ Frame* Frame::Clone() const
|
||||||
|
|
||||||
static bool val_is_func(const IntrusivePtr<Val>& v, BroFunc* func)
|
static bool val_is_func(const IntrusivePtr<Val>& v, BroFunc* func)
|
||||||
{
|
{
|
||||||
if ( v->GetType()->Tag() != TYPE_FUNC )
|
if ( v->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return v->AsFunc() == func;
|
return v->AsFunc() == func;
|
||||||
|
@ -333,7 +333,7 @@ broker::expected<broker::data> Frame::Serialize(const Frame* target, const id_li
|
||||||
|
|
||||||
const auto& val = target->frame[location].val;
|
const auto& val = target->frame[location].val;
|
||||||
|
|
||||||
TypeTag tag = val->GetType()->Tag();
|
zeek::TypeTag tag = val->GetType()->Tag();
|
||||||
|
|
||||||
auto expected = bro_broker::val_to_data(val.get());
|
auto expected = bro_broker::val_to_data(val.get());
|
||||||
if ( ! expected )
|
if ( ! expected )
|
||||||
|
@ -460,7 +460,7 @@ std::pair<bool, IntrusivePtr<Frame>> Frame::Unserialize(const broker::vector& da
|
||||||
return std::make_pair(false, nullptr);
|
return std::make_pair(false, nullptr);
|
||||||
|
|
||||||
broker::integer g = *has_type;
|
broker::integer g = *has_type;
|
||||||
BroType t( static_cast<TypeTag>(g) );
|
zeek::Type t( static_cast<zeek::TypeTag>(g) );
|
||||||
|
|
||||||
auto val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
auto val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
||||||
if ( ! val )
|
if ( ! val )
|
||||||
|
@ -478,7 +478,7 @@ void Frame::AddKnownOffsets(const id_list& ids)
|
||||||
offset_map = std::make_unique<OffsetMap>();
|
offset_map = std::make_unique<OffsetMap>();
|
||||||
|
|
||||||
std::transform(ids.begin(), ids.end(), std::inserter(*offset_map, offset_map->end()),
|
std::transform(ids.begin(), ids.end(), std::inserter(*offset_map, offset_map->end()),
|
||||||
[] (const ID* id) -> std::pair<std::string, int>
|
[] (const zeek::detail::ID* id) -> std::pair<std::string, int>
|
||||||
{
|
{
|
||||||
return std::make_pair(std::string(id->Name()), id->Offset());
|
return std::make_pair(std::string(id->Name()), id->Offset());
|
||||||
});
|
});
|
||||||
|
@ -505,7 +505,7 @@ void Frame::CaptureClosure(Frame* c, id_list arg_outer_ids)
|
||||||
// if (c) closure = c->SelectiveClone(outer_ids);
|
// if (c) closure = c->SelectiveClone(outer_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::SetTrigger(IntrusivePtr<trigger::Trigger> arg_trigger)
|
void Frame::SetTrigger(IntrusivePtr<zeek::detail::trigger::Trigger> arg_trigger)
|
||||||
{
|
{
|
||||||
trigger = std::move(arg_trigger);
|
trigger = std::move(arg_trigger);
|
||||||
}
|
}
|
||||||
|
@ -523,10 +523,10 @@ void Frame::ClearElement(int n)
|
||||||
frame[n] = {nullptr, false};
|
frame[n] = {nullptr, false};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::IsOuterID(const ID* in) const
|
bool Frame::IsOuterID(const zeek::detail::ID* in) const
|
||||||
{
|
{
|
||||||
return std::any_of(outer_ids.begin(), outer_ids.end(),
|
return std::any_of(outer_ids.begin(), outer_ids.end(),
|
||||||
[&in](ID* id)-> bool { return strcmp(id->Name(), in->Name()) == 0; });
|
[&in](zeek::detail::ID* id)-> bool { return strcmp(id->Name(), in->Name()) == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
broker::expected<broker::data> Frame::SerializeIDList(const id_list& in)
|
broker::expected<broker::data> Frame::SerializeIDList(const id_list& in)
|
||||||
|
@ -588,7 +588,7 @@ Frame::UnserializeIDList(const broker::vector& data)
|
||||||
return std::make_pair(false, std::move(rval));
|
return std::make_pair(false, std::move(rval));
|
||||||
}
|
}
|
||||||
|
|
||||||
ID* id = new ID(has_name->c_str(), SCOPE_FUNCTION, false);
|
auto* id = new zeek::detail::ID(has_name->c_str(), zeek::detail::SCOPE_FUNCTION, false);
|
||||||
id->SetOffset(*has_offset);
|
id->SetOffset(*has_offset);
|
||||||
rval.push_back(id);
|
rval.push_back(id);
|
||||||
std::advance(where, 1);
|
std::advance(where, 1);
|
||||||
|
|
35
src/Frame.h
35
src/Frame.h
|
@ -16,10 +16,11 @@
|
||||||
#include <broker/data.hh>
|
#include <broker/data.hh>
|
||||||
#include <broker/expected.hh>
|
#include <broker/expected.hh>
|
||||||
|
|
||||||
namespace trigger { class Trigger; }
|
|
||||||
class CallExpr;
|
|
||||||
class BroFunc;
|
class BroFunc;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Trigger, zeek::detail::trigger);
|
||||||
|
|
||||||
class Frame : public BroObj {
|
class Frame : public BroObj {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -65,8 +66,8 @@ public:
|
||||||
* @param id the ID to associate
|
* @param id the ID to associate
|
||||||
* @param v the value to associate it with
|
* @param v the value to associate it with
|
||||||
*/
|
*/
|
||||||
void SetElement(const ID* id, IntrusivePtr<Val> v);
|
void SetElement(const zeek::detail::ID* id, IntrusivePtr<Val> v);
|
||||||
void SetElement(const IntrusivePtr<ID>& id, IntrusivePtr<Val> v)
|
void SetElement(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<Val> v)
|
||||||
{ SetElement(id.get(), std::move(v)); }
|
{ SetElement(id.get(), std::move(v)); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,11 +77,11 @@ public:
|
||||||
* @param id the id who's value to retreive
|
* @param id the id who's value to retreive
|
||||||
* @return the value associated with *id*
|
* @return the value associated with *id*
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<Val>& GetElementByID(const IntrusivePtr<ID>& id) const
|
const IntrusivePtr<Val>& GetElementByID(const IntrusivePtr<zeek::detail::ID>& id) const
|
||||||
{ return GetElementByID(id.get()); }
|
{ return GetElementByID(id.get()); }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetElementByID().")]]
|
[[deprecated("Remove in v4.1. Use GetElementByID().")]]
|
||||||
Val* GetElement(const ID* id) const
|
Val* GetElement(const zeek::detail::ID* id) const
|
||||||
{ return GetElementByID(id).get(); }
|
{ return GetElementByID(id).get(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,12 +119,12 @@ public:
|
||||||
*
|
*
|
||||||
* @param stmt the statement to set it to.
|
* @param stmt the statement to set it to.
|
||||||
*/
|
*/
|
||||||
void SetNextStmt(Stmt* stmt) { next_stmt = stmt; }
|
void SetNextStmt(zeek::detail::Stmt* stmt) { next_stmt = stmt; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the next statement to be executed in the context of the frame.
|
* @return the next statement to be executed in the context of the frame.
|
||||||
*/
|
*/
|
||||||
Stmt* GetNextStmt() const { return next_stmt; }
|
zeek::detail::Stmt* GetNextStmt() const { return next_stmt; }
|
||||||
|
|
||||||
/** Used to implement "next" command in debugger. */
|
/** Used to implement "next" command in debugger. */
|
||||||
void BreakBeforeNextStmt(bool should_break)
|
void BreakBeforeNextStmt(bool should_break)
|
||||||
|
@ -215,13 +216,13 @@ public:
|
||||||
|
|
||||||
// If the frame is run in the context of a trigger condition evaluation,
|
// If the frame is run in the context of a trigger condition evaluation,
|
||||||
// the trigger needs to be registered.
|
// the trigger needs to be registered.
|
||||||
void SetTrigger(IntrusivePtr<trigger::Trigger> arg_trigger);
|
void SetTrigger(IntrusivePtr<zeek::detail::trigger::Trigger> arg_trigger);
|
||||||
void ClearTrigger();
|
void ClearTrigger();
|
||||||
trigger::Trigger* GetTrigger() const { return trigger.get(); }
|
zeek::detail::trigger::Trigger* GetTrigger() const { return trigger.get(); }
|
||||||
|
|
||||||
void SetCall(const CallExpr* arg_call) { call = arg_call; }
|
void SetCall(const zeek::detail::CallExpr* arg_call) { call = arg_call; }
|
||||||
void ClearCall() { call = nullptr; }
|
void ClearCall() { call = nullptr; }
|
||||||
const CallExpr* GetCall() const { return call; }
|
const zeek::detail::CallExpr* GetCall() const { return call; }
|
||||||
|
|
||||||
void SetDelayed() { delayed = true; }
|
void SetDelayed() { delayed = true; }
|
||||||
bool HasDelayed() const { return delayed; }
|
bool HasDelayed() const { return delayed; }
|
||||||
|
@ -246,7 +247,7 @@ private:
|
||||||
bool weak_ref;
|
bool weak_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IntrusivePtr<Val>& GetElementByID(const ID* id) const;
|
const IntrusivePtr<Val>& GetElementByID(const zeek::detail::ID* id) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the element at index *n* of the underlying array to *v*, but does
|
* Sets the element at index *n* of the underlying array to *v*, but does
|
||||||
|
@ -272,7 +273,7 @@ private:
|
||||||
void ClearElement(int n);
|
void ClearElement(int n);
|
||||||
|
|
||||||
/** Have we captured this id? */
|
/** Have we captured this id? */
|
||||||
bool IsOuterID(const ID* in) const;
|
bool IsOuterID(const zeek::detail::ID* in) const;
|
||||||
|
|
||||||
/** Serializes an offset_map */
|
/** Serializes an offset_map */
|
||||||
static broker::expected<broker::data>
|
static broker::expected<broker::data>
|
||||||
|
@ -319,10 +320,10 @@ private:
|
||||||
const zeek::Args* func_args;
|
const zeek::Args* func_args;
|
||||||
|
|
||||||
/** The next statement to be evaluted in the context of this frame. */
|
/** The next statement to be evaluted in the context of this frame. */
|
||||||
Stmt* next_stmt;
|
zeek::detail::Stmt* next_stmt;
|
||||||
|
|
||||||
IntrusivePtr<trigger::Trigger> trigger;
|
IntrusivePtr<zeek::detail::trigger::Trigger> trigger;
|
||||||
const CallExpr* call;
|
const zeek::detail::CallExpr* call;
|
||||||
|
|
||||||
std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference;
|
std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference;
|
||||||
};
|
};
|
||||||
|
|
109
src/Func.cc
109
src/Func.cc
|
@ -121,8 +121,8 @@ Func::Func(Kind arg_kind) : kind(arg_kind)
|
||||||
|
|
||||||
Func::~Func() = default;
|
Func::~Func() = default;
|
||||||
|
|
||||||
void Func::AddBody(IntrusivePtr<Stmt> /* new_body */,
|
void Func::AddBody(IntrusivePtr<zeek::detail::Stmt> /* new_body */,
|
||||||
const std::vector<IntrusivePtr<ID>>& /* new_inits */,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& /* new_inits */,
|
||||||
size_t /* new_frame_size */, int /* priority */)
|
size_t /* new_frame_size */, int /* priority */)
|
||||||
{
|
{
|
||||||
Internal("Func::AddBody called");
|
Internal("Func::AddBody called");
|
||||||
|
@ -216,7 +216,7 @@ void Func::CopyStateInto(Func* other) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||||
function_flavor flavor) const
|
zeek::FunctionFlavor flavor) const
|
||||||
{
|
{
|
||||||
// Helper function factoring out this code from BroFunc:Call() for
|
// Helper function factoring out this code from BroFunc:Call() for
|
||||||
// better readability.
|
// better readability.
|
||||||
|
@ -232,32 +232,32 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( flavor ) {
|
switch ( flavor ) {
|
||||||
case FUNC_FLAVOR_EVENT:
|
case zeek::FUNC_FLAVOR_EVENT:
|
||||||
if ( hook_result )
|
if ( hook_result )
|
||||||
reporter->InternalError("plugin returned non-void result for event %s",
|
reporter->InternalError("plugin returned non-void result for event %s",
|
||||||
this->Name());
|
this->Name());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUNC_FLAVOR_HOOK:
|
case zeek::FUNC_FLAVOR_HOOK:
|
||||||
if ( hook_result->GetType()->Tag() != TYPE_BOOL )
|
if ( hook_result->GetType()->Tag() != zeek::TYPE_BOOL )
|
||||||
reporter->InternalError("plugin returned non-bool for hook %s",
|
reporter->InternalError("plugin returned non-bool for hook %s",
|
||||||
this->Name());
|
this->Name());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUNC_FLAVOR_FUNCTION:
|
case zeek::FUNC_FLAVOR_FUNCTION:
|
||||||
{
|
{
|
||||||
const auto& yt = GetType()->Yield();
|
const auto& yt = GetType()->Yield();
|
||||||
|
|
||||||
if ( (! yt) || yt->Tag() == TYPE_VOID )
|
if ( (! yt) || yt->Tag() == zeek::TYPE_VOID )
|
||||||
{
|
{
|
||||||
if ( hook_result )
|
if ( hook_result )
|
||||||
reporter->InternalError("plugin returned non-void result for void method %s",
|
reporter->InternalError("plugin returned non-void result for void method %s",
|
||||||
this->Name());
|
this->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != TYPE_ANY )
|
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() && yt->Tag() != zeek::TYPE_ANY )
|
||||||
{
|
{
|
||||||
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
|
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
|
||||||
hook_result->GetType()->Tag(), yt->Tag(), this->Name());
|
hook_result->GetType()->Tag(), yt->Tag(), this->Name());
|
||||||
|
@ -268,13 +268,13 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BroFunc::BroFunc(const IntrusivePtr<ID>& arg_id, IntrusivePtr<Stmt> arg_body,
|
BroFunc::BroFunc(const IntrusivePtr<zeek::detail::ID>& arg_id, IntrusivePtr<zeek::detail::Stmt> arg_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& aggr_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& aggr_inits,
|
||||||
size_t arg_frame_size, int priority)
|
size_t arg_frame_size, int priority)
|
||||||
: Func(BRO_FUNC)
|
: Func(BRO_FUNC)
|
||||||
{
|
{
|
||||||
name = arg_id->Name();
|
name = arg_id->Name();
|
||||||
type = arg_id->GetType<FuncType>();
|
type = arg_id->GetType<zeek::FuncType>();
|
||||||
frame_size = arg_frame_size;
|
frame_size = arg_frame_size;
|
||||||
|
|
||||||
if ( arg_body )
|
if ( arg_body )
|
||||||
|
@ -326,8 +326,8 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
if ( bodies.empty() )
|
if ( bodies.empty() )
|
||||||
{
|
{
|
||||||
// Can only happen for events and hooks.
|
// Can only happen for events and hooks.
|
||||||
assert(Flavor() == FUNC_FLAVOR_EVENT || Flavor() == FUNC_FLAVOR_HOOK);
|
assert(Flavor() == zeek::FUNC_FLAVOR_EVENT || Flavor() == zeek::FUNC_FLAVOR_HOOK);
|
||||||
return Flavor() == FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
|
return Flavor() == zeek::FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto f = make_intrusive<Frame>(frame_size, this, args);
|
auto f = make_intrusive<Frame>(frame_size, this, args);
|
||||||
|
@ -343,7 +343,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
}
|
}
|
||||||
|
|
||||||
g_frame_stack.push_back(f.get()); // used for backtracing
|
g_frame_stack.push_back(f.get()); // used for backtracing
|
||||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
const zeek::detail::CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||||
|
|
||||||
if ( g_trace_state.DoTrace() )
|
if ( g_trace_state.DoTrace() )
|
||||||
|
@ -384,7 +384,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
catch ( InterpreterException& e )
|
catch ( InterpreterException& e )
|
||||||
{
|
{
|
||||||
// Already reported, but now determine whether to unwind further.
|
// Already reported, but now determine whether to unwind further.
|
||||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
if ( Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||||
{
|
{
|
||||||
g_frame_stack.pop_back();
|
g_frame_stack.pop_back();
|
||||||
call_stack.pop_back();
|
call_stack.pop_back();
|
||||||
|
@ -404,7 +404,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
if ( Flavor() == zeek::FUNC_FLAVOR_HOOK )
|
||||||
{
|
{
|
||||||
// Ignore any return values of hook bodies, final return value
|
// Ignore any return values of hook bodies, final return value
|
||||||
// depends on whether a body returns as a result of break statement.
|
// depends on whether a body returns as a result of break statement.
|
||||||
|
@ -421,7 +421,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
|
|
||||||
call_stack.pop_back();
|
call_stack.pop_back();
|
||||||
|
|
||||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
if ( Flavor() == zeek::FUNC_FLAVOR_HOOK )
|
||||||
{
|
{
|
||||||
if ( ! result )
|
if ( ! result )
|
||||||
result = val_mgr->True();
|
result = val_mgr->True();
|
||||||
|
@ -429,7 +429,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
|
|
||||||
// Warn if the function returns something, but we returned from
|
// Warn if the function returns something, but we returned from
|
||||||
// the function without an explicit return, or without a value.
|
// the function without an explicit return, or without a value.
|
||||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID &&
|
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != zeek::TYPE_VOID &&
|
||||||
(flow != FLOW_RETURN /* we fell off the end */ ||
|
(flow != FLOW_RETURN /* we fell off the end */ ||
|
||||||
! result /* explicit return with no result */) &&
|
! result /* explicit return with no result */) &&
|
||||||
! f->HasDelayed() )
|
! f->HasDelayed() )
|
||||||
|
@ -449,8 +449,8 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BroFunc::AddBody(IntrusivePtr<Stmt> new_body,
|
void BroFunc::AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||||
size_t new_frame_size, int priority)
|
size_t new_frame_size, int priority)
|
||||||
{
|
{
|
||||||
if ( new_frame_size > frame_size )
|
if ( new_frame_size > frame_size )
|
||||||
|
@ -463,7 +463,7 @@ void BroFunc::AddBody(IntrusivePtr<Stmt> new_body,
|
||||||
|
|
||||||
new_body = AddInits(std::move(new_body), new_inits);
|
new_body = AddInits(std::move(new_body), new_inits);
|
||||||
|
|
||||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION )
|
if ( Flavor() == zeek::FUNC_FLAVOR_FUNCTION )
|
||||||
{
|
{
|
||||||
// For functions, we replace the old body with the new one.
|
// For functions, we replace the old body with the new one.
|
||||||
assert(bodies.size() <= 1);
|
assert(bodies.size() <= 1);
|
||||||
|
@ -574,14 +574,14 @@ void BroFunc::Describe(ODesc* d) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Stmt> BroFunc::AddInits(IntrusivePtr<Stmt> body,
|
IntrusivePtr<zeek::detail::Stmt> BroFunc::AddInits(IntrusivePtr<zeek::detail::Stmt> body,
|
||||||
const std::vector<IntrusivePtr<ID>>& inits)
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits)
|
||||||
{
|
{
|
||||||
if ( inits.empty() )
|
if ( inits.empty() )
|
||||||
return body;
|
return body;
|
||||||
|
|
||||||
auto stmt_series = make_intrusive<StmtList>();
|
auto stmt_series = make_intrusive<zeek::detail::StmtList>();
|
||||||
stmt_series->Stmts().push_back(new InitStmt(inits));
|
stmt_series->Stmts().push_back(new zeek::detail::InitStmt(inits));
|
||||||
stmt_series->Stmts().push_back(body.release());
|
stmt_series->Stmts().push_back(body.release());
|
||||||
|
|
||||||
return stmt_series;
|
return stmt_series;
|
||||||
|
@ -601,7 +601,7 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name,
|
||||||
if ( id->HasVal() )
|
if ( id->HasVal() )
|
||||||
reporter->InternalError("built-in function %s multiply defined", Name());
|
reporter->InternalError("built-in function %s multiply defined", Name());
|
||||||
|
|
||||||
type = id->GetType<FuncType>();
|
type = id->GetType<zeek::FuncType>();
|
||||||
id->SetVal(make_intrusive<Val>(IntrusivePtr{NewRef{}, this}));
|
id->SetVal(make_intrusive<Val>(IntrusivePtr{NewRef{}, this}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +628,7 @@ IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
HookCallFunction(this, parent, args),
|
HookCallFunction(this, parent, args),
|
||||||
empty_hook_result);
|
empty_hook_result);
|
||||||
|
|
||||||
CheckPluginResult(handled, hook_result, FUNC_FLAVOR_FUNCTION);
|
CheckPluginResult(handled, hook_result, zeek::FUNC_FLAVOR_FUNCTION);
|
||||||
|
|
||||||
if ( handled )
|
if ( handled )
|
||||||
return hook_result;
|
return hook_result;
|
||||||
|
@ -641,7 +641,7 @@ IntrusivePtr<Val> BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
g_trace_state.LogTrace("\tBuiltin Function called: %s\n", d.Description());
|
g_trace_state.LogTrace("\tBuiltin Function called: %s\n", d.Description());
|
||||||
}
|
}
|
||||||
|
|
||||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
const zeek::detail::CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||||
auto result = std::move(func(parent, args).rval);
|
auto result = std::move(func(parent, args).rval);
|
||||||
call_stack.pop_back();
|
call_stack.pop_back();
|
||||||
|
@ -675,7 +675,7 @@ void builtin_error(const char* msg, IntrusivePtr<Val> arg)
|
||||||
|
|
||||||
void builtin_error(const char* msg, BroObj* arg)
|
void builtin_error(const char* msg, BroObj* arg)
|
||||||
{
|
{
|
||||||
auto emit = [=](const CallExpr* ce)
|
auto emit = [=](const zeek::detail::CallExpr* ce)
|
||||||
{
|
{
|
||||||
if ( ce )
|
if ( ce )
|
||||||
ce->Error(msg, arg);
|
ce->Error(msg, arg);
|
||||||
|
@ -758,19 +758,19 @@ void builtin_error(const char* msg, BroObj* arg)
|
||||||
|
|
||||||
void init_builtin_funcs()
|
void init_builtin_funcs()
|
||||||
{
|
{
|
||||||
ProcStats = zeek::id::find_type<RecordType>("ProcStats");
|
ProcStats = zeek::id::find_type<zeek::RecordType>("ProcStats");
|
||||||
NetStats = zeek::id::find_type<RecordType>("NetStats");
|
NetStats = zeek::id::find_type<zeek::RecordType>("NetStats");
|
||||||
MatcherStats = zeek::id::find_type<RecordType>("MatcherStats");
|
MatcherStats = zeek::id::find_type<zeek::RecordType>("MatcherStats");
|
||||||
ConnStats = zeek::id::find_type<RecordType>("ConnStats");
|
ConnStats = zeek::id::find_type<zeek::RecordType>("ConnStats");
|
||||||
ReassemblerStats = zeek::id::find_type<RecordType>("ReassemblerStats");
|
ReassemblerStats = zeek::id::find_type<zeek::RecordType>("ReassemblerStats");
|
||||||
DNSStats = zeek::id::find_type<RecordType>("DNSStats");
|
DNSStats = zeek::id::find_type<zeek::RecordType>("DNSStats");
|
||||||
GapStats = zeek::id::find_type<RecordType>("GapStats");
|
GapStats = zeek::id::find_type<zeek::RecordType>("GapStats");
|
||||||
EventStats = zeek::id::find_type<RecordType>("EventStats");
|
EventStats = zeek::id::find_type<zeek::RecordType>("EventStats");
|
||||||
TimerStats = zeek::id::find_type<RecordType>("TimerStats");
|
TimerStats = zeek::id::find_type<zeek::RecordType>("TimerStats");
|
||||||
FileAnalysisStats = zeek::id::find_type<RecordType>("FileAnalysisStats");
|
FileAnalysisStats = zeek::id::find_type<zeek::RecordType>("FileAnalysisStats");
|
||||||
ThreadStats = zeek::id::find_type<RecordType>("ThreadStats");
|
ThreadStats = zeek::id::find_type<zeek::RecordType>("ThreadStats");
|
||||||
BrokerStats = zeek::id::find_type<RecordType>("BrokerStats");
|
BrokerStats = zeek::id::find_type<zeek::RecordType>("BrokerStats");
|
||||||
ReporterStats = zeek::id::find_type<RecordType>("ReporterStats");
|
ReporterStats = zeek::id::find_type<zeek::RecordType>("ReporterStats");
|
||||||
|
|
||||||
var_sizes = zeek::id::find_type("var_sizes")->AsTableType();
|
var_sizes = zeek::id::find_type("var_sizes")->AsTableType();
|
||||||
|
|
||||||
|
@ -789,7 +789,7 @@ void init_builtin_funcs_subdirs()
|
||||||
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
|
#include "__all__.bif.init.cc" // Autogenerated for compiling in the bif_target() code.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call)
|
||||||
{
|
{
|
||||||
if ( f->TheFunc() != zeek::BifFunc::fmt_bif)
|
if ( f->TheFunc() != zeek::BifFunc::fmt_bif)
|
||||||
return true;
|
return true;
|
||||||
|
@ -802,8 +802,8 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Expr* fmt_str_arg = args[0];
|
const zeek::detail::Expr* fmt_str_arg = args[0];
|
||||||
if ( fmt_str_arg->GetType()->Tag() != TYPE_STRING )
|
if ( fmt_str_arg->GetType()->Tag() != zeek::TYPE_STRING )
|
||||||
{
|
{
|
||||||
call->Error("first argument to fmt() needs to be a format string");
|
call->Error("first argument to fmt() needs to be a format string");
|
||||||
return false;
|
return false;
|
||||||
|
@ -844,16 +844,16 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
|
||||||
|
|
||||||
// Gets a function's priority from its Scope's attributes. Errors if it sees any
|
// Gets a function's priority from its Scope's attributes. Errors if it sees any
|
||||||
// problems.
|
// problems.
|
||||||
static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
|
static int get_func_priority(const std::vector<IntrusivePtr<zeek::detail::Attr>>& attrs)
|
||||||
{
|
{
|
||||||
int priority = 0;
|
int priority = 0;
|
||||||
|
|
||||||
for ( const auto& a : attrs )
|
for ( const auto& a : attrs )
|
||||||
{
|
{
|
||||||
if ( a->Tag() == ATTR_DEPRECATED )
|
if ( a->Tag() == zeek::detail::ATTR_DEPRECATED )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( a->Tag() != ATTR_PRIORITY )
|
if ( a->Tag() != zeek::detail::ATTR_PRIORITY )
|
||||||
{
|
{
|
||||||
a->Error("illegal attribute for function body");
|
a->Error("illegal attribute for function body");
|
||||||
continue;
|
continue;
|
||||||
|
@ -867,7 +867,7 @@ static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! IsIntegral(v->GetType()->Tag()) )
|
if ( ! zeek::IsIntegral(v->GetType()->Tag()) )
|
||||||
{
|
{
|
||||||
a->Error("expression is not of integral type");
|
a->Error("expression is not of integral type");
|
||||||
continue;
|
continue;
|
||||||
|
@ -879,7 +879,7 @@ static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<Stmt> body)
|
function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body)
|
||||||
{
|
{
|
||||||
frame_size = scope->Length();
|
frame_size = scope->Length();
|
||||||
inits = scope->GetInits();
|
inits = scope->GetInits();
|
||||||
|
@ -892,10 +892,3 @@ function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusiveP
|
||||||
priority = (attrs ? get_func_priority(*attrs) : 0);
|
priority = (attrs ? get_func_priority(*attrs) : 0);
|
||||||
this->body = std::move(body);
|
this->body = std::move(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
BifReturnVal::BifReturnVal(std::nullptr_t) noexcept
|
|
||||||
{ }
|
|
||||||
|
|
||||||
BifReturnVal::BifReturnVal(Val* v) noexcept
|
|
||||||
: rval(AdoptRef{}, v)
|
|
||||||
{ }
|
|
||||||
|
|
86
src/Func.h
86
src/Func.h
|
@ -9,25 +9,33 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include <broker/data.hh>
|
|
||||||
#include <broker/expected.hh>
|
|
||||||
|
|
||||||
#include "BroList.h"
|
#include "BroList.h"
|
||||||
#include "Obj.h"
|
#include "Obj.h"
|
||||||
#include "IntrusivePtr.h"
|
#include "IntrusivePtr.h"
|
||||||
#include "Type.h" /* for function_flavor */
|
#include "Type.h" /* for function_flavor */
|
||||||
#include "TraverseTypes.h"
|
#include "TraverseTypes.h"
|
||||||
#include "ZeekArgs.h"
|
#include "ZeekArgs.h"
|
||||||
|
#include "BifReturnVal.h"
|
||||||
|
|
||||||
class Val;
|
class Val;
|
||||||
class ListExpr;
|
|
||||||
class FuncType;
|
|
||||||
class Stmt;
|
|
||||||
class Frame;
|
class Frame;
|
||||||
class ID;
|
|
||||||
class CallExpr;
|
|
||||||
class Scope;
|
class Scope;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(FuncType, zeek);
|
||||||
|
|
||||||
|
namespace caf {
|
||||||
|
template <class> class expected;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace broker {
|
||||||
|
class data;
|
||||||
|
using vector = std::vector<data>;
|
||||||
|
using caf::expected;
|
||||||
|
}
|
||||||
|
|
||||||
class Func : public BroObj {
|
class Func : public BroObj {
|
||||||
public:
|
public:
|
||||||
static inline const IntrusivePtr<Func> nil;
|
static inline const IntrusivePtr<Func> nil;
|
||||||
|
@ -39,10 +47,10 @@ public:
|
||||||
~Func() override;
|
~Func() override;
|
||||||
|
|
||||||
virtual bool IsPure() const = 0;
|
virtual bool IsPure() const = 0;
|
||||||
function_flavor Flavor() const { return GetType()->Flavor(); }
|
zeek::FunctionFlavor Flavor() const { return GetType()->Flavor(); }
|
||||||
|
|
||||||
struct Body {
|
struct Body {
|
||||||
IntrusivePtr<Stmt> stmts;
|
IntrusivePtr<zeek::detail::Stmt> stmts;
|
||||||
int priority;
|
int priority;
|
||||||
bool operator<(const Body& other) const
|
bool operator<(const Body& other) const
|
||||||
{ return priority > other.priority; } // reverse sort
|
{ return priority > other.priority; } // reverse sort
|
||||||
|
@ -78,17 +86,17 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new event handler to an existing function (event).
|
// Add a new event handler to an existing function (event).
|
||||||
virtual void AddBody(IntrusivePtr<Stmt> new_body,
|
virtual void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||||
size_t new_frame_size, int priority = 0);
|
size_t new_frame_size, int priority = 0);
|
||||||
|
|
||||||
virtual void SetScope(IntrusivePtr<Scope> newscope);
|
virtual void SetScope(IntrusivePtr<Scope> newscope);
|
||||||
virtual Scope* GetScope() const { return scope.get(); }
|
virtual Scope* GetScope() const { return scope.get(); }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||||
virtual FuncType* FType() const { return type.get(); }
|
virtual zeek::FuncType* FType() const { return type.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<FuncType>& GetType() const
|
const IntrusivePtr<zeek::FuncType>& GetType() const
|
||||||
{ return type; }
|
{ return type; }
|
||||||
|
|
||||||
Kind GetKind() const { return kind; }
|
Kind GetKind() const { return kind; }
|
||||||
|
@ -115,13 +123,13 @@ protected:
|
||||||
|
|
||||||
// Helper function for checking result of plugin hook.
|
// Helper function for checking result of plugin hook.
|
||||||
void CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
void CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||||
function_flavor flavor) const;
|
zeek::FunctionFlavor flavor) const;
|
||||||
|
|
||||||
std::vector<Body> bodies;
|
std::vector<Body> bodies;
|
||||||
IntrusivePtr<Scope> scope;
|
IntrusivePtr<Scope> scope;
|
||||||
Kind kind;
|
Kind kind;
|
||||||
uint32_t unique_id;
|
uint32_t unique_id;
|
||||||
IntrusivePtr<FuncType> type;
|
IntrusivePtr<zeek::FuncType> type;
|
||||||
std::string name;
|
std::string name;
|
||||||
static inline std::vector<IntrusivePtr<Func>> unique_ids;
|
static inline std::vector<IntrusivePtr<Func>> unique_ids;
|
||||||
};
|
};
|
||||||
|
@ -129,8 +137,8 @@ protected:
|
||||||
|
|
||||||
class BroFunc final : public Func {
|
class BroFunc final : public Func {
|
||||||
public:
|
public:
|
||||||
BroFunc(const IntrusivePtr<ID>& id, IntrusivePtr<Stmt> body,
|
BroFunc(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::detail::Stmt> body,
|
||||||
const std::vector<IntrusivePtr<ID>>& inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits,
|
||||||
size_t frame_size, int priority);
|
size_t frame_size, int priority);
|
||||||
|
|
||||||
~BroFunc() override;
|
~BroFunc() override;
|
||||||
|
@ -167,8 +175,8 @@ public:
|
||||||
*/
|
*/
|
||||||
broker::expected<broker::data> SerializeClosure() const;
|
broker::expected<broker::data> SerializeClosure() const;
|
||||||
|
|
||||||
void AddBody(IntrusivePtr<Stmt> new_body,
|
void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||||
size_t new_frame_size, int priority) override;
|
size_t new_frame_size, int priority) override;
|
||||||
|
|
||||||
/** Sets this function's outer_id list. */
|
/** Sets this function's outer_id list. */
|
||||||
|
@ -179,8 +187,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BroFunc() : Func(BRO_FUNC) {}
|
BroFunc() : Func(BRO_FUNC) {}
|
||||||
IntrusivePtr<Stmt> AddInits(IntrusivePtr<Stmt> body,
|
IntrusivePtr<zeek::detail::Stmt> AddInits(
|
||||||
const std::vector<IntrusivePtr<ID>>& inits);
|
IntrusivePtr<zeek::detail::Stmt> body,
|
||||||
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones this function along with its closures.
|
* Clones this function along with its closures.
|
||||||
|
@ -205,27 +214,6 @@ private:
|
||||||
bool weak_closure_ref = false;
|
bool weak_closure_ref = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple wrapper class to use for the return value of BIFs so that
|
|
||||||
* they may return either a Val* or IntrusivePtr<Val> (the former could
|
|
||||||
* potentially be deprecated).
|
|
||||||
*/
|
|
||||||
class BifReturnVal {
|
|
||||||
public:
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
BifReturnVal(IntrusivePtr<T> v) noexcept
|
|
||||||
: rval(AdoptRef{}, v.release())
|
|
||||||
{ }
|
|
||||||
|
|
||||||
BifReturnVal(std::nullptr_t) noexcept;
|
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Return an IntrusivePtr instead.")]]
|
|
||||||
BifReturnVal(Val* v) noexcept;
|
|
||||||
|
|
||||||
IntrusivePtr<Val> rval;
|
|
||||||
};
|
|
||||||
|
|
||||||
using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args);
|
using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args);
|
||||||
|
|
||||||
class BuiltinFunc final : public Func {
|
class BuiltinFunc final : public Func {
|
||||||
|
@ -253,10 +241,10 @@ extern void builtin_error(const char* msg, BroObj* arg);
|
||||||
extern void init_builtin_funcs();
|
extern void init_builtin_funcs();
|
||||||
extern void init_builtin_funcs_subdirs();
|
extern void init_builtin_funcs_subdirs();
|
||||||
|
|
||||||
extern bool check_built_in_call(BuiltinFunc* f, CallExpr* call);
|
extern bool check_built_in_call(BuiltinFunc* f, zeek::detail::CallExpr* call);
|
||||||
|
|
||||||
struct CallInfo {
|
struct CallInfo {
|
||||||
const CallExpr* call;
|
const zeek::detail::CallExpr* call;
|
||||||
const Func* func;
|
const Func* func;
|
||||||
const zeek::Args& args;
|
const zeek::Args& args;
|
||||||
};
|
};
|
||||||
|
@ -267,11 +255,11 @@ struct function_ingredients {
|
||||||
|
|
||||||
// Gathers all of the information from a scope and a function body needed
|
// Gathers all of the information from a scope and a function body needed
|
||||||
// to build a function.
|
// to build a function.
|
||||||
function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<Stmt> body);
|
function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body);
|
||||||
|
|
||||||
IntrusivePtr<ID> id;
|
IntrusivePtr<zeek::detail::ID> id;
|
||||||
IntrusivePtr<Stmt> body;
|
IntrusivePtr<zeek::detail::Stmt> body;
|
||||||
std::vector<IntrusivePtr<ID>> inits;
|
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||||
int frame_size;
|
int frame_size;
|
||||||
int priority;
|
int priority;
|
||||||
IntrusivePtr<Scope> scope;
|
IntrusivePtr<Scope> scope;
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include "highwayhash/highwayhash_target.h"
|
#include "highwayhash/highwayhash_target.h"
|
||||||
#include "highwayhash/instruction_sets.h"
|
#include "highwayhash/instruction_sets.h"
|
||||||
|
|
||||||
|
alignas(32) uint64_t KeyedHash::shared_highwayhash_key[4];
|
||||||
|
alignas(32) uint64_t KeyedHash::cluster_highwayhash_key[4];
|
||||||
|
alignas(16) unsigned long long KeyedHash::shared_siphash_key[2];
|
||||||
|
|
||||||
// we use the following lines to not pull in the highwayhash headers in Hash.h - but to check the types did not change underneath us.
|
// we use the following lines to not pull in the highwayhash headers in Hash.h - but to check the types did not change underneath us.
|
||||||
static_assert(std::is_same<hash64_t, highwayhash::HHResult64>::value, "Highwayhash return values must match hash_x_t");
|
static_assert(std::is_same<hash64_t, highwayhash::HHResult64>::value, "Highwayhash return values must match hash_x_t");
|
||||||
static_assert(std::is_same<hash128_t, highwayhash::HHResult128>::value, "Highwayhash return values must match hash_x_t");
|
static_assert(std::is_same<hash128_t, highwayhash::HHResult128>::value, "Highwayhash return values must match hash_x_t");
|
||||||
|
|
|
@ -186,11 +186,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// actually HHKey. This key changes each start (unless a seed is specified)
|
// actually HHKey. This key changes each start (unless a seed is specified)
|
||||||
alignas(32) inline static uint64_t shared_highwayhash_key[4];
|
alignas(32) static uint64_t shared_highwayhash_key[4];
|
||||||
// actually HHKey. This key is installation specific and sourced from the digest_salt script-level const.
|
// actually HHKey. This key is installation specific and sourced from the digest_salt script-level const.
|
||||||
alignas(32) inline static uint64_t cluster_highwayhash_key[4];
|
alignas(32) static uint64_t cluster_highwayhash_key[4];
|
||||||
// actually HH_U64, which has the same type. This key changes each start (unless a seed is specified)
|
// actually HH_U64, which has the same type. This key changes each start (unless a seed is specified)
|
||||||
alignas(16) inline static unsigned long long shared_siphash_key[2];
|
alignas(16) static unsigned long long shared_siphash_key[2];
|
||||||
// This key changes each start (unless a seed is specified)
|
// This key changes each start (unless a seed is specified)
|
||||||
inline static uint8_t shared_hmac_md5_key[16];
|
inline static uint8_t shared_hmac_md5_key[16];
|
||||||
inline static bool seeds_initialized = false;
|
inline static bool seeds_initialized = false;
|
||||||
|
|
89
src/ID.cc
89
src/ID.cc
|
@ -19,24 +19,24 @@
|
||||||
#include "zeekygen/ScriptInfo.h"
|
#include "zeekygen/ScriptInfo.h"
|
||||||
#include "module_util.h"
|
#include "module_util.h"
|
||||||
|
|
||||||
IntrusivePtr<RecordType> zeek::id::conn_id;
|
IntrusivePtr<zeek::RecordType> zeek::id::conn_id;
|
||||||
IntrusivePtr<RecordType> zeek::id::endpoint;
|
IntrusivePtr<zeek::RecordType> zeek::id::endpoint;
|
||||||
IntrusivePtr<RecordType> zeek::id::connection;
|
IntrusivePtr<zeek::RecordType> zeek::id::connection;
|
||||||
IntrusivePtr<RecordType> zeek::id::fa_file;
|
IntrusivePtr<zeek::RecordType> zeek::id::fa_file;
|
||||||
IntrusivePtr<RecordType> zeek::id::fa_metadata;
|
IntrusivePtr<zeek::RecordType> zeek::id::fa_metadata;
|
||||||
IntrusivePtr<EnumType> zeek::id::transport_proto;
|
IntrusivePtr<zeek::EnumType> zeek::id::transport_proto;
|
||||||
IntrusivePtr<TableType> zeek::id::string_set;
|
IntrusivePtr<zeek::TableType> zeek::id::string_set;
|
||||||
IntrusivePtr<TableType> zeek::id::string_array;
|
IntrusivePtr<zeek::TableType> zeek::id::string_array;
|
||||||
IntrusivePtr<TableType> zeek::id::count_set;
|
IntrusivePtr<zeek::TableType> zeek::id::count_set;
|
||||||
IntrusivePtr<VectorType> zeek::id::string_vec;
|
IntrusivePtr<zeek::VectorType> zeek::id::string_vec;
|
||||||
IntrusivePtr<VectorType> zeek::id::index_vec;
|
IntrusivePtr<zeek::VectorType> zeek::id::index_vec;
|
||||||
|
|
||||||
const IntrusivePtr<ID>& zeek::id::find(std::string_view name)
|
const IntrusivePtr<zeek::detail::ID>& zeek::id::find(std::string_view name)
|
||||||
{
|
{
|
||||||
return global_scope()->Find(name);
|
return global_scope()->Find(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& zeek::id::find_type(std::string_view name)
|
const IntrusivePtr<zeek::Type>& zeek::id::find_type(std::string_view name)
|
||||||
{
|
{
|
||||||
auto id = global_scope()->Find(name);
|
auto id = global_scope()->Find(name);
|
||||||
|
|
||||||
|
@ -89,19 +89,21 @@ IntrusivePtr<Func> zeek::id::find_func(std::string_view name)
|
||||||
|
|
||||||
void zeek::id::detail::init()
|
void zeek::id::detail::init()
|
||||||
{
|
{
|
||||||
conn_id = zeek::id::find_type<RecordType>("conn_id");
|
conn_id = zeek::id::find_type<zeek::RecordType>("conn_id");
|
||||||
endpoint = zeek::id::find_type<RecordType>("endpoint");
|
endpoint = zeek::id::find_type<zeek::RecordType>("endpoint");
|
||||||
connection = zeek::id::find_type<RecordType>("connection");
|
connection = zeek::id::find_type<zeek::RecordType>("connection");
|
||||||
fa_file = zeek::id::find_type<RecordType>("fa_file");
|
fa_file = zeek::id::find_type<zeek::RecordType>("fa_file");
|
||||||
fa_metadata = zeek::id::find_type<RecordType>("fa_metadata");
|
fa_metadata = zeek::id::find_type<zeek::RecordType>("fa_metadata");
|
||||||
transport_proto = zeek::id::find_type<EnumType>("transport_proto");
|
transport_proto = zeek::id::find_type<zeek::EnumType>("transport_proto");
|
||||||
string_set = zeek::id::find_type<TableType>("string_set");
|
string_set = zeek::id::find_type<zeek::TableType>("string_set");
|
||||||
string_array = zeek::id::find_type<TableType>("string_array");
|
string_array = zeek::id::find_type<zeek::TableType>("string_array");
|
||||||
count_set = zeek::id::find_type<TableType>("count_set");
|
count_set = zeek::id::find_type<zeek::TableType>("count_set");
|
||||||
string_vec = zeek::id::find_type<VectorType>("string_vec");
|
string_vec = zeek::id::find_type<zeek::VectorType>("string_vec");
|
||||||
index_vec = zeek::id::find_type<VectorType>("index_vec");
|
index_vec = zeek::id::find_type<zeek::VectorType>("index_vec");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
||||||
{
|
{
|
||||||
name = copy_string(arg_name);
|
name = copy_string(arg_name);
|
||||||
|
@ -118,6 +120,12 @@ ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
||||||
SetLocationInfo(&start_location, &end_location);
|
SetLocationInfo(&start_location, &end_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
ID::ID(const char* arg_name, ::IDScope arg_scope, bool arg_is_export) :
|
||||||
|
ID(arg_name, static_cast<IDScope>(arg_scope), arg_is_export) {}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
ID::~ID()
|
ID::~ID()
|
||||||
{
|
{
|
||||||
delete [] name;
|
delete [] name;
|
||||||
|
@ -128,7 +136,7 @@ std::string ID::ModuleName() const
|
||||||
return extract_module_name(name);
|
return extract_module_name(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::SetType(IntrusivePtr<BroType> t)
|
void ID::SetType(IntrusivePtr<zeek::Type> t)
|
||||||
{
|
{
|
||||||
type = std::move(t);
|
type = std::move(t);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +223,19 @@ void ID::SetVal(IntrusivePtr<Expr> ev, init_class c)
|
||||||
EvalFunc(a->GetExpr(), std::move(ev));
|
EvalFunc(a->GetExpr(), std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
void ID::SetVal(IntrusivePtr<Val> v, ::init_class c)
|
||||||
|
{
|
||||||
|
SetVal(v, static_cast<init_class>(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ID::SetVal(IntrusivePtr<Expr> ev, ::init_class c)
|
||||||
|
{
|
||||||
|
SetVal(ev, static_cast<init_class>(c));
|
||||||
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
bool ID::IsRedefinable() const
|
bool ID::IsRedefinable() const
|
||||||
{
|
{
|
||||||
return GetAttr(ATTR_REDEF) != nullptr;
|
return GetAttr(ATTR_REDEF) != nullptr;
|
||||||
|
@ -252,7 +273,7 @@ void ID::UpdateValAttrs()
|
||||||
if ( attr )
|
if ( attr )
|
||||||
{
|
{
|
||||||
// Apply &log to all record fields.
|
// Apply &log to all record fields.
|
||||||
RecordType* rt = GetType()->AsRecordType();
|
zeek::RecordType* rt = GetType()->AsRecordType();
|
||||||
for ( int i = 0; i < rt->NumFields(); ++i )
|
for ( int i = 0; i < rt->NumFields(); ++i )
|
||||||
{
|
{
|
||||||
TypeDecl* fd = rt->FieldDecl(i);
|
TypeDecl* fd = rt->FieldDecl(i);
|
||||||
|
@ -292,7 +313,7 @@ std::string ID::GetDeprecationWarning() const
|
||||||
|
|
||||||
if ( depr_attr )
|
if ( depr_attr )
|
||||||
{
|
{
|
||||||
auto expr = static_cast<ConstExpr*>(depr_attr->GetExpr().get());
|
auto expr = static_cast<zeek::detail::ConstExpr*>(depr_attr->GetExpr().get());
|
||||||
if ( expr )
|
if ( expr )
|
||||||
{
|
{
|
||||||
StringVal* text = expr->Value()->AsStringVal();
|
StringVal* text = expr->Value()->AsStringVal();
|
||||||
|
@ -322,6 +343,14 @@ void ID::RemoveAttr(attr_tag a)
|
||||||
attrs->RemoveAttr(a);
|
attrs->RemoveAttr(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
void ID::RemoveAttr(::attr_tag a)
|
||||||
|
{
|
||||||
|
RemoveAttr(static_cast<attr_tag>(a));
|
||||||
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
void ID::SetOption()
|
void ID::SetOption()
|
||||||
{
|
{
|
||||||
if ( is_option )
|
if ( is_option )
|
||||||
|
@ -339,8 +368,8 @@ void ID::SetOption()
|
||||||
|
|
||||||
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
||||||
{
|
{
|
||||||
auto arg1 = make_intrusive<ConstExpr>(val);
|
auto arg1 = make_intrusive<zeek::detail::ConstExpr>(val);
|
||||||
auto args = make_intrusive<ListExpr>();
|
auto args = make_intrusive<zeek::detail::ListExpr>();
|
||||||
args->Append(std::move(arg1));
|
args->Append(std::move(arg1));
|
||||||
args->Append(std::move(ev));
|
args->Append(std::move(ev));
|
||||||
auto ce = make_intrusive<CallExpr>(std::move(ef), std::move(args));
|
auto ce = make_intrusive<CallExpr>(std::move(ef), std::move(args));
|
||||||
|
@ -655,3 +684,5 @@ std::vector<Func*> ID::GetOptionHandlers() const
|
||||||
v.push_back(element.second.get());
|
v.push_back(element.second.get());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
100
src/ID.h
100
src/ID.h
|
@ -14,23 +14,39 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Val;
|
class Val;
|
||||||
class Expr;
|
|
||||||
class Func;
|
class Func;
|
||||||
class BroType;
|
|
||||||
class RecordType;
|
|
||||||
class TableType;
|
|
||||||
class VectorType;
|
|
||||||
class EnumType;
|
|
||||||
class Attributes;
|
|
||||||
|
|
||||||
typedef enum { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, } init_class;
|
namespace zeek { class Type; }
|
||||||
typedef enum { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL } IDScope;
|
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(TableType, zeek);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(EnumType, zeek);
|
||||||
|
|
||||||
|
enum [[deprecated("Remove in v4.1. Use zeek::detail::init_class instead.")]] init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, };
|
||||||
|
enum [[deprecated("Remove in v4.1. Use zeek::detail::IDScope instead.")]] IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
class Attributes;
|
||||||
|
class Expr;
|
||||||
|
|
||||||
|
enum init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, };
|
||||||
|
enum IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
|
||||||
|
|
||||||
class ID final : public BroObj, public notifier::Modifiable {
|
class ID final : public BroObj, public notifier::Modifiable {
|
||||||
public:
|
public:
|
||||||
static inline const IntrusivePtr<ID> nil;
|
static inline const IntrusivePtr<ID> nil;
|
||||||
|
|
||||||
ID(const char* name, IDScope arg_scope, bool arg_is_export);
|
ID(const char* name, IDScope arg_scope, bool arg_is_export);
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::IDScope")]]
|
||||||
|
ID(const char* name, ::IDScope arg_scope, bool arg_is_export);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
~ID() override;
|
~ID() override;
|
||||||
|
|
||||||
const char* Name() const { return name; }
|
const char* Name() const { return name; }
|
||||||
|
@ -43,14 +59,14 @@ public:
|
||||||
|
|
||||||
std::string ModuleName() const;
|
std::string ModuleName() const;
|
||||||
|
|
||||||
void SetType(IntrusivePtr<BroType> t);
|
void SetType(IntrusivePtr<Type> t);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||||
BroType* Type() { return type.get(); }
|
zeek::Type* Type() { return type.get(); }
|
||||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||||
const BroType* Type() const { return type.get(); }
|
const zeek::Type* Type() const { return type.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& GetType() const
|
const IntrusivePtr<zeek::Type>& GetType() const
|
||||||
{ return type; }
|
{ return type; }
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
@ -58,9 +74,9 @@ public:
|
||||||
{ return cast_intrusive<T>(type); }
|
{ return cast_intrusive<T>(type); }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
|
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
|
||||||
BroType* AsType() { return is_type ? GetType().get() : nullptr; }
|
zeek::Type* AsType() { return is_type ? GetType().get() : nullptr; }
|
||||||
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
|
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
|
||||||
const BroType* AsType() const { return is_type ? GetType().get() : nullptr; }
|
const zeek::Type* AsType() const { return is_type ? GetType().get() : nullptr; }
|
||||||
|
|
||||||
bool IsType() const
|
bool IsType() const
|
||||||
{ return is_type; }
|
{ return is_type; }
|
||||||
|
@ -72,6 +88,14 @@ public:
|
||||||
void SetVal(IntrusivePtr<Val> v, init_class c);
|
void SetVal(IntrusivePtr<Val> v, init_class c);
|
||||||
void SetVal(IntrusivePtr<Expr> ev, init_class c);
|
void SetVal(IntrusivePtr<Expr> ev, init_class c);
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::init_class")]]
|
||||||
|
void SetVal(IntrusivePtr<Val> v, ::init_class c);
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::init_class")]]
|
||||||
|
void SetVal(IntrusivePtr<Expr> ev, ::init_class c);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
bool HasVal() const { return val != nullptr; }
|
bool HasVal() const { return val != nullptr; }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetVal().")]]
|
[[deprecated("Remove in v4.1. Use GetVal().")]]
|
||||||
|
@ -101,6 +125,11 @@ public:
|
||||||
void SetAttrs(IntrusivePtr<Attributes> attr);
|
void SetAttrs(IntrusivePtr<Attributes> attr);
|
||||||
void AddAttrs(IntrusivePtr<Attributes> attr);
|
void AddAttrs(IntrusivePtr<Attributes> attr);
|
||||||
void RemoveAttr(attr_tag a);
|
void RemoveAttr(attr_tag a);
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::attr_tag")]]
|
||||||
|
void RemoveAttr(::attr_tag a);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
void UpdateValAttrs();
|
void UpdateValAttrs();
|
||||||
|
|
||||||
const IntrusivePtr<Attributes>& GetAttrs() const
|
const IntrusivePtr<Attributes>& GetAttrs() const
|
||||||
|
@ -109,11 +138,14 @@ public:
|
||||||
[[deprecated("Remove in 4.1. Use GetAttrs().")]]
|
[[deprecated("Remove in 4.1. Use GetAttrs().")]]
|
||||||
Attributes* Attrs() const { return attrs.get(); }
|
Attributes* Attrs() const { return attrs.get(); }
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
[[deprecated("Remove in 4.1. Use GetAttr().")]]
|
[[deprecated("Remove in 4.1. Use GetAttr().")]]
|
||||||
Attr* FindAttr(attr_tag t) const
|
Attr* FindAttr(::attr_tag t) const
|
||||||
{ return GetAttr(t).get(); }
|
{ return GetAttr(static_cast<zeek::detail::attr_tag>(t)).get(); }
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
const IntrusivePtr<Attr>& GetAttr(attr_tag t) const;
|
const IntrusivePtr<zeek::detail::Attr>& GetAttr(zeek::detail::attr_tag t) const;
|
||||||
|
|
||||||
bool IsDeprecated() const;
|
bool IsDeprecated() const;
|
||||||
|
|
||||||
|
@ -154,7 +186,7 @@ protected:
|
||||||
IDScope scope;
|
IDScope scope;
|
||||||
bool is_export;
|
bool is_export;
|
||||||
bool infer_return_type;
|
bool infer_return_type;
|
||||||
IntrusivePtr<BroType> type;
|
IntrusivePtr<zeek::Type> type;
|
||||||
bool is_const, is_enum_const, is_type, is_option;
|
bool is_const, is_enum_const, is_type, is_option;
|
||||||
int offset;
|
int offset;
|
||||||
IntrusivePtr<Val> val;
|
IntrusivePtr<Val> val;
|
||||||
|
@ -164,6 +196,10 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using ID [[deprecated("Remove in v4.1. Use zeek::detail::ID instead.")]] = zeek::detail::ID;
|
||||||
|
|
||||||
namespace zeek::id {
|
namespace zeek::id {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +208,7 @@ namespace zeek::id {
|
||||||
* @return The identifier, which may reference a nil object if no such
|
* @return The identifier, which may reference a nil object if no such
|
||||||
* name exists.
|
* name exists.
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<ID>& find(std::string_view name);
|
const IntrusivePtr<zeek::detail::ID>& find(std::string_view name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup an ID by its name and return its type. A fatal occurs if the ID
|
* Lookup an ID by its name and return its type. A fatal occurs if the ID
|
||||||
|
@ -180,7 +216,7 @@ const IntrusivePtr<ID>& find(std::string_view name);
|
||||||
* @param name The identifier name to lookup
|
* @param name The identifier name to lookup
|
||||||
* @return The type of the identifier.
|
* @return The type of the identifier.
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<BroType>& find_type(std::string_view name);
|
const IntrusivePtr<zeek::Type>& find_type(std::string_view name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup an ID by its name and return its type (as cast to @c T).
|
* Lookup an ID by its name and return its type (as cast to @c T).
|
||||||
|
@ -236,17 +272,17 @@ IntrusivePtr<T> find_const(std::string_view name)
|
||||||
*/
|
*/
|
||||||
IntrusivePtr<Func> find_func(std::string_view name);
|
IntrusivePtr<Func> find_func(std::string_view name);
|
||||||
|
|
||||||
extern IntrusivePtr<RecordType> conn_id;
|
extern IntrusivePtr<zeek::RecordType> conn_id;
|
||||||
extern IntrusivePtr<RecordType> endpoint;
|
extern IntrusivePtr<zeek::RecordType> endpoint;
|
||||||
extern IntrusivePtr<RecordType> connection;
|
extern IntrusivePtr<zeek::RecordType> connection;
|
||||||
extern IntrusivePtr<RecordType> fa_file;
|
extern IntrusivePtr<zeek::RecordType> fa_file;
|
||||||
extern IntrusivePtr<RecordType> fa_metadata;
|
extern IntrusivePtr<zeek::RecordType> fa_metadata;
|
||||||
extern IntrusivePtr<EnumType> transport_proto;
|
extern IntrusivePtr<zeek::EnumType> transport_proto;
|
||||||
extern IntrusivePtr<TableType> string_set;
|
extern IntrusivePtr<zeek::TableType> string_set;
|
||||||
extern IntrusivePtr<TableType> string_array;
|
extern IntrusivePtr<zeek::TableType> string_array;
|
||||||
extern IntrusivePtr<TableType> count_set;
|
extern IntrusivePtr<zeek::TableType> count_set;
|
||||||
extern IntrusivePtr<VectorType> string_vec;
|
extern IntrusivePtr<zeek::VectorType> string_vec;
|
||||||
extern IntrusivePtr<VectorType> index_vec;
|
extern IntrusivePtr<zeek::VectorType> index_vec;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
|
66
src/IP.cc
66
src/IP.cc
|
@ -15,11 +15,11 @@
|
||||||
|
|
||||||
static IntrusivePtr<VectorVal> BuildOptionsVal(const u_char* data, int len)
|
static IntrusivePtr<VectorVal> BuildOptionsVal(const u_char* data, int len)
|
||||||
{
|
{
|
||||||
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<VectorType>("ip6_options"));
|
auto vv = make_intrusive<VectorVal>(zeek::id::find_type<zeek::VectorType>("ip6_options"));
|
||||||
|
|
||||||
while ( len > 0 )
|
while ( len > 0 )
|
||||||
{
|
{
|
||||||
static auto ip6_option_type = zeek::id::find_type<RecordType>("ip6_option");
|
static auto ip6_option_type = zeek::id::find_type<zeek::RecordType>("ip6_option");
|
||||||
const struct ip6_opt* opt = (const struct ip6_opt*) data;
|
const struct ip6_opt* opt = (const struct ip6_opt*) data;
|
||||||
auto rv = make_intrusive<RecordVal>(ip6_option_type);
|
auto rv = make_intrusive<RecordVal>(ip6_option_type);
|
||||||
rv->Assign(0, val_mgr->Count(opt->ip6o_type));
|
rv->Assign(0, val_mgr->Count(opt->ip6o_type));
|
||||||
|
@ -56,7 +56,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case IPPROTO_IPV6:
|
case IPPROTO_IPV6:
|
||||||
{
|
{
|
||||||
static auto ip6_hdr_type = zeek::id::find_type<RecordType>("ip6_hdr");
|
static auto ip6_hdr_type = zeek::id::find_type<zeek::RecordType>("ip6_hdr");
|
||||||
rv = make_intrusive<RecordVal>(ip6_hdr_type);
|
rv = make_intrusive<RecordVal>(ip6_hdr_type);
|
||||||
const struct ip6_hdr* ip6 = (const struct ip6_hdr*)data;
|
const struct ip6_hdr* ip6 = (const struct ip6_hdr*)data;
|
||||||
rv->Assign(0, val_mgr->Count((ntohl(ip6->ip6_flow) & 0x0ff00000)>>20));
|
rv->Assign(0, val_mgr->Count((ntohl(ip6->ip6_flow) & 0x0ff00000)>>20));
|
||||||
|
@ -68,14 +68,14 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
rv->Assign(6, make_intrusive<AddrVal>(IPAddr(ip6->ip6_dst)));
|
rv->Assign(6, make_intrusive<AddrVal>(IPAddr(ip6->ip6_dst)));
|
||||||
if ( ! chain )
|
if ( ! chain )
|
||||||
chain = make_intrusive<VectorVal>(
|
chain = make_intrusive<VectorVal>(
|
||||||
zeek::id::find_type<VectorType>("ip6_ext_hdr_chain"));
|
zeek::id::find_type<zeek::VectorType>("ip6_ext_hdr_chain"));
|
||||||
rv->Assign(7, std::move(chain));
|
rv->Assign(7, std::move(chain));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IPPROTO_HOPOPTS:
|
case IPPROTO_HOPOPTS:
|
||||||
{
|
{
|
||||||
static auto ip6_hopopts_type = zeek::id::find_type<RecordType>("ip6_hopopts");
|
static auto ip6_hopopts_type = zeek::id::find_type<zeek::RecordType>("ip6_hopopts");
|
||||||
rv = make_intrusive<RecordVal>(ip6_hopopts_type);
|
rv = make_intrusive<RecordVal>(ip6_hopopts_type);
|
||||||
const struct ip6_hbh* hbh = (const struct ip6_hbh*)data;
|
const struct ip6_hbh* hbh = (const struct ip6_hbh*)data;
|
||||||
rv->Assign(0, val_mgr->Count(hbh->ip6h_nxt));
|
rv->Assign(0, val_mgr->Count(hbh->ip6h_nxt));
|
||||||
|
@ -88,7 +88,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
|
|
||||||
case IPPROTO_DSTOPTS:
|
case IPPROTO_DSTOPTS:
|
||||||
{
|
{
|
||||||
static auto ip6_dstopts_type = zeek::id::find_type<RecordType>("ip6_dstopts");
|
static auto ip6_dstopts_type = zeek::id::find_type<zeek::RecordType>("ip6_dstopts");
|
||||||
rv = make_intrusive<RecordVal>(ip6_dstopts_type);
|
rv = make_intrusive<RecordVal>(ip6_dstopts_type);
|
||||||
const struct ip6_dest* dst = (const struct ip6_dest*)data;
|
const struct ip6_dest* dst = (const struct ip6_dest*)data;
|
||||||
rv->Assign(0, val_mgr->Count(dst->ip6d_nxt));
|
rv->Assign(0, val_mgr->Count(dst->ip6d_nxt));
|
||||||
|
@ -100,7 +100,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
|
|
||||||
case IPPROTO_ROUTING:
|
case IPPROTO_ROUTING:
|
||||||
{
|
{
|
||||||
static auto ip6_routing_type = zeek::id::find_type<RecordType>("ip6_routing");
|
static auto ip6_routing_type = zeek::id::find_type<zeek::RecordType>("ip6_routing");
|
||||||
rv = make_intrusive<RecordVal>(ip6_routing_type);
|
rv = make_intrusive<RecordVal>(ip6_routing_type);
|
||||||
const struct ip6_rthdr* rt = (const struct ip6_rthdr*)data;
|
const struct ip6_rthdr* rt = (const struct ip6_rthdr*)data;
|
||||||
rv->Assign(0, val_mgr->Count(rt->ip6r_nxt));
|
rv->Assign(0, val_mgr->Count(rt->ip6r_nxt));
|
||||||
|
@ -114,7 +114,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
|
|
||||||
case IPPROTO_FRAGMENT:
|
case IPPROTO_FRAGMENT:
|
||||||
{
|
{
|
||||||
static auto ip6_fragment_type = zeek::id::find_type<RecordType>("ip6_fragment");
|
static auto ip6_fragment_type = zeek::id::find_type<zeek::RecordType>("ip6_fragment");
|
||||||
rv = make_intrusive<RecordVal>(ip6_fragment_type);
|
rv = make_intrusive<RecordVal>(ip6_fragment_type);
|
||||||
const struct ip6_frag* frag = (const struct ip6_frag*)data;
|
const struct ip6_frag* frag = (const struct ip6_frag*)data;
|
||||||
rv->Assign(0, val_mgr->Count(frag->ip6f_nxt));
|
rv->Assign(0, val_mgr->Count(frag->ip6f_nxt));
|
||||||
|
@ -128,7 +128,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
|
|
||||||
case IPPROTO_AH:
|
case IPPROTO_AH:
|
||||||
{
|
{
|
||||||
static auto ip6_ah_type = zeek::id::find_type<RecordType>("ip6_ah");
|
static auto ip6_ah_type = zeek::id::find_type<zeek::RecordType>("ip6_ah");
|
||||||
rv = make_intrusive<RecordVal>(ip6_ah_type);
|
rv = make_intrusive<RecordVal>(ip6_ah_type);
|
||||||
rv->Assign(0, val_mgr->Count(((ip6_ext*)data)->ip6e_nxt));
|
rv->Assign(0, val_mgr->Count(((ip6_ext*)data)->ip6e_nxt));
|
||||||
rv->Assign(1, val_mgr->Count(((ip6_ext*)data)->ip6e_len));
|
rv->Assign(1, val_mgr->Count(((ip6_ext*)data)->ip6e_len));
|
||||||
|
@ -148,7 +148,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
|
|
||||||
case IPPROTO_ESP:
|
case IPPROTO_ESP:
|
||||||
{
|
{
|
||||||
static auto ip6_esp_type = zeek::id::find_type<RecordType>("ip6_esp");
|
static auto ip6_esp_type = zeek::id::find_type<zeek::RecordType>("ip6_esp");
|
||||||
rv = make_intrusive<RecordVal>(ip6_esp_type);
|
rv = make_intrusive<RecordVal>(ip6_esp_type);
|
||||||
const uint32_t* esp = (const uint32_t*)data;
|
const uint32_t* esp = (const uint32_t*)data;
|
||||||
rv->Assign(0, val_mgr->Count(ntohl(esp[0])));
|
rv->Assign(0, val_mgr->Count(ntohl(esp[0])));
|
||||||
|
@ -159,7 +159,7 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
#ifdef ENABLE_MOBILE_IPV6
|
#ifdef ENABLE_MOBILE_IPV6
|
||||||
case IPPROTO_MOBILITY:
|
case IPPROTO_MOBILITY:
|
||||||
{
|
{
|
||||||
static auto ip6_mob_type = zeek::id::find_type<RecordType>("ip6_mobility_hdr");
|
static auto ip6_mob_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_hdr");
|
||||||
rv = make_intrusive<RecordVal>(ip6_mob_type);
|
rv = make_intrusive<RecordVal>(ip6_mob_type);
|
||||||
const struct ip6_mobility* mob = (const struct ip6_mobility*) data;
|
const struct ip6_mobility* mob = (const struct ip6_mobility*) data;
|
||||||
rv->Assign(0, val_mgr->Count(mob->ip6mob_payload));
|
rv->Assign(0, val_mgr->Count(mob->ip6mob_payload));
|
||||||
|
@ -168,21 +168,21 @@ IntrusivePtr<RecordVal> IPv6_Hdr::ToVal(IntrusivePtr<VectorVal> chain) const
|
||||||
rv->Assign(3, val_mgr->Count(mob->ip6mob_rsv));
|
rv->Assign(3, val_mgr->Count(mob->ip6mob_rsv));
|
||||||
rv->Assign(4, val_mgr->Count(ntohs(mob->ip6mob_chksum)));
|
rv->Assign(4, val_mgr->Count(ntohs(mob->ip6mob_chksum)));
|
||||||
|
|
||||||
static auto ip6_mob_msg_type = zeek::id::find_type<RecordType>("ip6_mobility_msg");
|
static auto ip6_mob_msg_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_msg");
|
||||||
auto msg = make_intrusive<RecordVal>(ip6_mob_msg_type);
|
auto msg = make_intrusive<RecordVal>(ip6_mob_msg_type);
|
||||||
msg->Assign(0, val_mgr->Count(mob->ip6mob_type));
|
msg->Assign(0, val_mgr->Count(mob->ip6mob_type));
|
||||||
|
|
||||||
uint16_t off = sizeof(ip6_mobility);
|
uint16_t off = sizeof(ip6_mobility);
|
||||||
const u_char* msg_data = data + off;
|
const u_char* msg_data = data + off;
|
||||||
|
|
||||||
static auto ip6_mob_brr_type = zeek::id::find_type<RecordType>("ip6_mobility_brr");
|
static auto ip6_mob_brr_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_brr");
|
||||||
static auto ip6_mob_hoti_type = zeek::id::find_type<RecordType>("ip6_mobility_hoti");
|
static auto ip6_mob_hoti_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_hoti");
|
||||||
static auto ip6_mob_coti_type = zeek::id::find_type<RecordType>("ip6_mobility_coti");
|
static auto ip6_mob_coti_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_coti");
|
||||||
static auto ip6_mob_hot_type = zeek::id::find_type<RecordType>("ip6_mobility_hot");
|
static auto ip6_mob_hot_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_hot");
|
||||||
static auto ip6_mob_cot_type = zeek::id::find_type<RecordType>("ip6_mobility_cot");
|
static auto ip6_mob_cot_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_cot");
|
||||||
static auto ip6_mob_bu_type = zeek::id::find_type<RecordType>("ip6_mobility_bu");
|
static auto ip6_mob_bu_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_bu");
|
||||||
static auto ip6_mob_back_type = zeek::id::find_type<RecordType>("ip6_mobility_back");
|
static auto ip6_mob_back_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_back");
|
||||||
static auto ip6_mob_be_type = zeek::id::find_type<RecordType>("ip6_mobility_be");
|
static auto ip6_mob_be_type = zeek::id::find_type<zeek::RecordType>("ip6_mobility_be");
|
||||||
|
|
||||||
switch ( mob->ip6mob_type ) {
|
switch ( mob->ip6mob_type ) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -332,7 +332,7 @@ IntrusivePtr<RecordVal> IP_Hdr::ToIPHdrVal() const
|
||||||
|
|
||||||
if ( ip4 )
|
if ( ip4 )
|
||||||
{
|
{
|
||||||
static auto ip4_hdr_type = zeek::id::find_type<RecordType>("ip4_hdr");
|
static auto ip4_hdr_type = zeek::id::find_type<zeek::RecordType>("ip4_hdr");
|
||||||
rval = make_intrusive<RecordVal>(ip4_hdr_type);
|
rval = make_intrusive<RecordVal>(ip4_hdr_type);
|
||||||
rval->Assign(0, val_mgr->Count(ip4->ip_hl * 4));
|
rval->Assign(0, val_mgr->Count(ip4->ip_hl * 4));
|
||||||
rval->Assign(1, val_mgr->Count(ip4->ip_tos));
|
rval->Assign(1, val_mgr->Count(ip4->ip_tos));
|
||||||
|
@ -358,7 +358,7 @@ RecordVal* IP_Hdr::BuildIPHdrVal() const
|
||||||
|
|
||||||
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal() const
|
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal() const
|
||||||
{
|
{
|
||||||
static auto pkt_hdr_type = zeek::id::find_type<RecordType>("pkt_hdr");
|
static auto pkt_hdr_type = zeek::id::find_type<zeek::RecordType>("pkt_hdr");
|
||||||
return ToPktHdrVal(make_intrusive<RecordVal>(pkt_hdr_type), 0);
|
return ToPktHdrVal(make_intrusive<RecordVal>(pkt_hdr_type), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,9 +369,9 @@ RecordVal* IP_Hdr::BuildPktHdrVal() const
|
||||||
|
|
||||||
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal(IntrusivePtr<RecordVal> pkt_hdr, int sindex) const
|
IntrusivePtr<RecordVal> IP_Hdr::ToPktHdrVal(IntrusivePtr<RecordVal> pkt_hdr, int sindex) const
|
||||||
{
|
{
|
||||||
static auto tcp_hdr_type = zeek::id::find_type<RecordType>("tcp_hdr");
|
static auto tcp_hdr_type = zeek::id::find_type<zeek::RecordType>("tcp_hdr");
|
||||||
static auto udp_hdr_type = zeek::id::find_type<RecordType>("udp_hdr");
|
static auto udp_hdr_type = zeek::id::find_type<zeek::RecordType>("udp_hdr");
|
||||||
static auto icmp_hdr_type = zeek::id::find_type<RecordType>("icmp_hdr");
|
static auto icmp_hdr_type = zeek::id::find_type<zeek::RecordType>("icmp_hdr");
|
||||||
|
|
||||||
if ( ip4 )
|
if ( ip4 )
|
||||||
pkt_hdr->Assign(sindex + 0, ToIPHdrVal());
|
pkt_hdr->Assign(sindex + 0, ToIPHdrVal());
|
||||||
|
@ -678,14 +678,14 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
|
||||||
|
|
||||||
IntrusivePtr<VectorVal> IPv6_Hdr_Chain::ToVal() const
|
IntrusivePtr<VectorVal> IPv6_Hdr_Chain::ToVal() const
|
||||||
{
|
{
|
||||||
static auto ip6_ext_hdr_type = zeek::id::find_type<RecordType>("ip6_ext_hdr");
|
static auto ip6_ext_hdr_type = zeek::id::find_type<zeek::RecordType>("ip6_ext_hdr");
|
||||||
static auto ip6_hopopts_type = zeek::id::find_type<RecordType>("ip6_hopopts");
|
static auto ip6_hopopts_type = zeek::id::find_type<zeek::RecordType>("ip6_hopopts");
|
||||||
static auto ip6_dstopts_type = zeek::id::find_type<RecordType>("ip6_dstopts");
|
static auto ip6_dstopts_type = zeek::id::find_type<zeek::RecordType>("ip6_dstopts");
|
||||||
static auto ip6_routing_type = zeek::id::find_type<RecordType>("ip6_routing");
|
static auto ip6_routing_type = zeek::id::find_type<zeek::RecordType>("ip6_routing");
|
||||||
static auto ip6_fragment_type = zeek::id::find_type<RecordType>("ip6_fragment");
|
static auto ip6_fragment_type = zeek::id::find_type<zeek::RecordType>("ip6_fragment");
|
||||||
static auto ip6_ah_type = zeek::id::find_type<RecordType>("ip6_ah");
|
static auto ip6_ah_type = zeek::id::find_type<zeek::RecordType>("ip6_ah");
|
||||||
static auto ip6_esp_type = zeek::id::find_type<RecordType>("ip6_esp");
|
static auto ip6_esp_type = zeek::id::find_type<zeek::RecordType>("ip6_esp");
|
||||||
static auto ip6_ext_hdr_chain_type = zeek::id::find_type<VectorType>("ip6_ext_hdr_chain");
|
static auto ip6_ext_hdr_chain_type = zeek::id::find_type<zeek::VectorType>("ip6_ext_hdr_chain");
|
||||||
auto rval = make_intrusive<VectorVal>(ip6_ext_hdr_chain_type);
|
auto rval = make_intrusive<VectorVal>(ip6_ext_hdr_chain_type);
|
||||||
|
|
||||||
for ( size_t i = 1; i < chain.size(); ++i )
|
for ( size_t i = 1; i < chain.size(); ++i )
|
||||||
|
|
|
@ -199,7 +199,7 @@ void net_init(const std::optional<std::string>& interface,
|
||||||
reporter->Error("trace_output_file not defined in bro.init");
|
reporter->Error("trace_output_file not defined in bro.init");
|
||||||
}
|
}
|
||||||
|
|
||||||
init_ip_addr_anonymizers();
|
zeek::detail::init_ip_addr_anonymizers();
|
||||||
|
|
||||||
sessions = new NetSessions();
|
sessions = new NetSessions();
|
||||||
|
|
||||||
|
@ -409,8 +409,8 @@ void net_delete()
|
||||||
|
|
||||||
delete sessions;
|
delete sessions;
|
||||||
|
|
||||||
for ( int i = 0; i < NUM_ADDR_ANONYMIZATION_METHODS; ++i )
|
for ( int i = 0; i < zeek::detail::NUM_ADDR_ANONYMIZATION_METHODS; ++i )
|
||||||
delete ip_anonymizer[i];
|
delete zeek::detail::ip_anonymizer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _processing_suspended = 0;
|
int _processing_suspended = 0;
|
||||||
|
|
100
src/NetVar.cc
100
src/NetVar.cc
|
@ -8,27 +8,27 @@
|
||||||
#include "Val.h"
|
#include "Val.h"
|
||||||
#include "ID.h"
|
#include "ID.h"
|
||||||
|
|
||||||
RecordType* conn_id;
|
zeek::RecordType* conn_id;
|
||||||
RecordType* endpoint;
|
zeek::RecordType* endpoint;
|
||||||
RecordType* endpoint_stats;
|
zeek::RecordType* endpoint_stats;
|
||||||
RecordType* connection_type;
|
zeek::RecordType* connection_type;
|
||||||
RecordType* fa_file_type;
|
zeek::RecordType* fa_file_type;
|
||||||
RecordType* fa_metadata_type;
|
zeek::RecordType* fa_metadata_type;
|
||||||
RecordType* icmp_conn;
|
zeek::RecordType* icmp_conn;
|
||||||
RecordType* icmp_context;
|
zeek::RecordType* icmp_context;
|
||||||
RecordType* SYN_packet;
|
zeek::RecordType* SYN_packet;
|
||||||
RecordType* pcap_packet;
|
zeek::RecordType* pcap_packet;
|
||||||
RecordType* raw_pkt_hdr_type;
|
zeek::RecordType* raw_pkt_hdr_type;
|
||||||
RecordType* l2_hdr_type;
|
zeek::RecordType* l2_hdr_type;
|
||||||
RecordType* signature_state;
|
zeek::RecordType* signature_state;
|
||||||
EnumType* transport_proto;
|
zeek::EnumType* transport_proto;
|
||||||
TableType* string_set;
|
zeek::TableType* string_set;
|
||||||
TableType* string_array;
|
zeek::TableType* string_array;
|
||||||
TableType* count_set;
|
zeek::TableType* count_set;
|
||||||
VectorType* string_vec;
|
zeek::VectorType* string_vec;
|
||||||
VectorType* index_vec;
|
zeek::VectorType* index_vec;
|
||||||
VectorType* mime_matches;
|
zeek::VectorType* mime_matches;
|
||||||
RecordType* mime_match;
|
zeek::RecordType* mime_match;
|
||||||
|
|
||||||
int watchdog_interval;
|
int watchdog_interval;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ int tcp_max_above_hole_without_any_acks;
|
||||||
int tcp_excessive_data_without_further_acks;
|
int tcp_excessive_data_without_further_acks;
|
||||||
int tcp_max_old_segments;
|
int tcp_max_old_segments;
|
||||||
|
|
||||||
RecordType* socks_address;
|
zeek::RecordType* socks_address;
|
||||||
|
|
||||||
double non_analyzed_lifetime;
|
double non_analyzed_lifetime;
|
||||||
double tcp_inactivity_timeout;
|
double tcp_inactivity_timeout;
|
||||||
|
@ -86,32 +86,32 @@ double rpc_timeout;
|
||||||
|
|
||||||
int mime_segment_length;
|
int mime_segment_length;
|
||||||
int mime_segment_overlap_length;
|
int mime_segment_overlap_length;
|
||||||
RecordType* mime_header_rec;
|
zeek::RecordType* mime_header_rec;
|
||||||
TableType* mime_header_list;
|
zeek::TableType* mime_header_list;
|
||||||
|
|
||||||
int http_entity_data_delivery_size;
|
int http_entity_data_delivery_size;
|
||||||
RecordType* http_stats_rec;
|
zeek::RecordType* http_stats_rec;
|
||||||
RecordType* http_message_stat;
|
zeek::RecordType* http_message_stat;
|
||||||
int truncate_http_URI;
|
int truncate_http_URI;
|
||||||
|
|
||||||
RecordType* pm_mapping;
|
zeek::RecordType* pm_mapping;
|
||||||
TableType* pm_mappings;
|
zeek::TableType* pm_mappings;
|
||||||
RecordType* pm_port_request;
|
zeek::RecordType* pm_port_request;
|
||||||
RecordType* pm_callit_request;
|
zeek::RecordType* pm_callit_request;
|
||||||
|
|
||||||
RecordType* geo_location;
|
zeek::RecordType* geo_location;
|
||||||
|
|
||||||
RecordType* entropy_test_result;
|
zeek::RecordType* entropy_test_result;
|
||||||
|
|
||||||
RecordType* dns_msg;
|
zeek::RecordType* dns_msg;
|
||||||
RecordType* dns_answer;
|
zeek::RecordType* dns_answer;
|
||||||
RecordType* dns_soa;
|
zeek::RecordType* dns_soa;
|
||||||
RecordType* dns_edns_additional;
|
zeek::RecordType* dns_edns_additional;
|
||||||
RecordType* dns_tsig_additional;
|
zeek::RecordType* dns_tsig_additional;
|
||||||
RecordType* dns_rrsig_rr;
|
zeek::RecordType* dns_rrsig_rr;
|
||||||
RecordType* dns_dnskey_rr;
|
zeek::RecordType* dns_dnskey_rr;
|
||||||
RecordType* dns_nsec3_rr;
|
zeek::RecordType* dns_nsec3_rr;
|
||||||
RecordType* dns_ds_rr;
|
zeek::RecordType* dns_ds_rr;
|
||||||
TableVal* dns_skip_auth;
|
TableVal* dns_skip_auth;
|
||||||
TableVal* dns_skip_addl;
|
TableVal* dns_skip_addl;
|
||||||
int dns_skip_all_auth;
|
int dns_skip_all_auth;
|
||||||
|
@ -134,7 +134,7 @@ TableVal* preserve_orig_addr;
|
||||||
TableVal* preserve_resp_addr;
|
TableVal* preserve_resp_addr;
|
||||||
TableVal* preserve_other_addr;
|
TableVal* preserve_other_addr;
|
||||||
|
|
||||||
RecordType* rotate_info;
|
zeek::RecordType* rotate_info;
|
||||||
StringVal* log_rotate_base_time;
|
StringVal* log_rotate_base_time;
|
||||||
|
|
||||||
StringVal* peer_description;
|
StringVal* peer_description;
|
||||||
|
@ -153,8 +153,8 @@ int packet_filter_default;
|
||||||
|
|
||||||
int sig_max_group_size;
|
int sig_max_group_size;
|
||||||
|
|
||||||
TableType* irc_join_list;
|
zeek::TableType* irc_join_list;
|
||||||
RecordType* irc_join_info;
|
zeek::RecordType* irc_join_info;
|
||||||
|
|
||||||
int dpd_reassemble_first_packets;
|
int dpd_reassemble_first_packets;
|
||||||
int dpd_buffer_size;
|
int dpd_buffer_size;
|
||||||
|
@ -172,12 +172,12 @@ StringVal* trace_output_file;
|
||||||
|
|
||||||
int record_all_packets;
|
int record_all_packets;
|
||||||
|
|
||||||
RecordType* script_id;
|
zeek::RecordType* script_id;
|
||||||
TableType* id_table;
|
zeek::TableType* id_table;
|
||||||
RecordType* record_field;
|
zeek::RecordType* record_field;
|
||||||
TableType* record_field_table;
|
zeek::TableType* record_field_table;
|
||||||
RecordType* call_argument;
|
zeek::RecordType* call_argument;
|
||||||
VectorType* call_argument_vector;
|
zeek::VectorType* call_argument_vector;
|
||||||
|
|
||||||
StringVal* cmd_line_bpf_filter;
|
StringVal* cmd_line_bpf_filter;
|
||||||
|
|
||||||
|
|
100
src/NetVar.h
100
src/NetVar.h
|
@ -7,47 +7,47 @@
|
||||||
#include "Stats.h"
|
#include "Stats.h"
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::conn_id.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::conn_id.")]]
|
||||||
extern RecordType* conn_id;
|
extern zeek::RecordType* conn_id;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::endpoint.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::endpoint.")]]
|
||||||
extern RecordType* endpoint;
|
extern zeek::RecordType* endpoint;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* endpoint_stats;
|
extern zeek::RecordType* endpoint_stats;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::connection.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::connection.")]]
|
||||||
extern RecordType* connection_type;
|
extern zeek::RecordType* connection_type;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::fa_file.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::fa_file.")]]
|
||||||
extern RecordType* fa_file_type;
|
extern zeek::RecordType* fa_file_type;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::fa_metadata.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::fa_metadata.")]]
|
||||||
extern RecordType* fa_metadata_type;
|
extern zeek::RecordType* fa_metadata_type;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* icmp_conn;
|
extern zeek::RecordType* icmp_conn;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* icmp_context;
|
extern zeek::RecordType* icmp_context;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* signature_state;
|
extern zeek::RecordType* signature_state;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* SYN_packet;
|
extern zeek::RecordType* SYN_packet;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* pcap_packet;
|
extern zeek::RecordType* pcap_packet;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* raw_pkt_hdr_type;
|
extern zeek::RecordType* raw_pkt_hdr_type;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* l2_hdr_type;
|
extern zeek::RecordType* l2_hdr_type;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::transport_proto.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::transport_proto.")]]
|
||||||
extern EnumType* transport_proto;
|
extern zeek::EnumType* transport_proto;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::string_set.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::string_set.")]]
|
||||||
extern TableType* string_set;
|
extern zeek::TableType* string_set;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::string_array.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::string_array.")]]
|
||||||
extern TableType* string_array;
|
extern zeek::TableType* string_array;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::count_set.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::count_set.")]]
|
||||||
extern TableType* count_set;
|
extern zeek::TableType* count_set;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::string_vec.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::string_vec.")]]
|
||||||
extern VectorType* string_vec;
|
extern zeek::VectorType* string_vec;
|
||||||
[[deprecated("Remove in v4.1. Use zeek::id::index_vec.")]]
|
[[deprecated("Remove in v4.1. Use zeek::id::index_vec.")]]
|
||||||
extern VectorType* index_vec;
|
extern zeek::VectorType* index_vec;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern VectorType* mime_matches;
|
extern zeek::VectorType* mime_matches;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* mime_match;
|
extern zeek::RecordType* mime_match;
|
||||||
|
|
||||||
extern int watchdog_interval;
|
extern int watchdog_interval;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ extern int tcp_excessive_data_without_further_acks;
|
||||||
extern int tcp_max_old_segments;
|
extern int tcp_max_old_segments;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* socks_address;
|
extern zeek::RecordType* socks_address;
|
||||||
|
|
||||||
extern double non_analyzed_lifetime;
|
extern double non_analyzed_lifetime;
|
||||||
extern double tcp_inactivity_timeout;
|
extern double tcp_inactivity_timeout;
|
||||||
|
@ -114,50 +114,50 @@ extern double rpc_timeout;
|
||||||
extern int mime_segment_length;
|
extern int mime_segment_length;
|
||||||
extern int mime_segment_overlap_length;
|
extern int mime_segment_overlap_length;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* mime_header_rec;
|
extern zeek::RecordType* mime_header_rec;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern TableType* mime_header_list;
|
extern zeek::TableType* mime_header_list;
|
||||||
|
|
||||||
extern int http_entity_data_delivery_size;
|
extern int http_entity_data_delivery_size;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* http_stats_rec;
|
extern zeek::RecordType* http_stats_rec;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* http_message_stat;
|
extern zeek::RecordType* http_message_stat;
|
||||||
extern int truncate_http_URI;
|
extern int truncate_http_URI;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* pm_mapping;
|
extern zeek::RecordType* pm_mapping;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern TableType* pm_mappings;
|
extern zeek::TableType* pm_mappings;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* pm_port_request;
|
extern zeek::RecordType* pm_port_request;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* pm_callit_request;
|
extern zeek::RecordType* pm_callit_request;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* geo_location;
|
extern zeek::RecordType* geo_location;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* entropy_test_result;
|
extern zeek::RecordType* entropy_test_result;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_msg;
|
extern zeek::RecordType* dns_msg;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_answer;
|
extern zeek::RecordType* dns_answer;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_soa;
|
extern zeek::RecordType* dns_soa;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_edns_additional;
|
extern zeek::RecordType* dns_edns_additional;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_tsig_additional;
|
extern zeek::RecordType* dns_tsig_additional;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_rrsig_rr;
|
extern zeek::RecordType* dns_rrsig_rr;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_dnskey_rr;
|
extern zeek::RecordType* dns_dnskey_rr;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_nsec3_rr;
|
extern zeek::RecordType* dns_nsec3_rr;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* dns_ds_rr;
|
extern zeek::RecordType* dns_ds_rr;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern TableVal* dns_skip_auth;
|
extern TableVal* dns_skip_auth;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
|
@ -187,7 +187,7 @@ extern TableVal* preserve_other_addr;
|
||||||
extern double connection_status_update_interval;
|
extern double connection_status_update_interval;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* rotate_info;
|
extern zeek::RecordType* rotate_info;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern StringVal* log_rotate_base_time;
|
extern StringVal* log_rotate_base_time;
|
||||||
|
|
||||||
|
@ -212,9 +212,9 @@ extern int packet_filter_default;
|
||||||
extern int sig_max_group_size;
|
extern int sig_max_group_size;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern TableType* irc_join_list;
|
extern zeek::TableType* irc_join_list;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* irc_join_info;
|
extern zeek::RecordType* irc_join_info;
|
||||||
|
|
||||||
extern int dpd_reassemble_first_packets;
|
extern int dpd_reassemble_first_packets;
|
||||||
extern int dpd_buffer_size;
|
extern int dpd_buffer_size;
|
||||||
|
@ -235,17 +235,17 @@ extern StringVal* trace_output_file;
|
||||||
extern int record_all_packets;
|
extern int record_all_packets;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* script_id;
|
extern zeek::RecordType* script_id;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern TableType* id_table;
|
extern zeek::TableType* id_table;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* record_field;
|
extern zeek::RecordType* record_field;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern TableType* record_field_table;
|
extern zeek::TableType* record_field_table;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern RecordType* call_argument;
|
extern zeek::RecordType* call_argument;
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern VectorType* call_argument_vector;
|
extern zeek::VectorType* call_argument_vector;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
[[deprecated("Remove in v4.1. Perform your own lookup.")]]
|
||||||
extern StringVal* cmd_line_bpf_filter;
|
extern StringVal* cmd_line_bpf_filter;
|
||||||
|
|
|
@ -37,10 +37,10 @@ OpaqueMgr* OpaqueMgr::mgr()
|
||||||
return &mgr;
|
return &mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpaqueVal::OpaqueVal(OpaqueType* t) : OpaqueVal({NewRef{}, t})
|
OpaqueVal::OpaqueVal(zeek::OpaqueType* t) : OpaqueVal({NewRef{}, t})
|
||||||
{}
|
{}
|
||||||
|
|
||||||
OpaqueVal::OpaqueVal(IntrusivePtr<OpaqueType> t) : Val(std::move(t))
|
OpaqueVal::OpaqueVal(IntrusivePtr<zeek::OpaqueType> t) : Val(std::move(t))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
OpaqueVal::~OpaqueVal()
|
OpaqueVal::~OpaqueVal()
|
||||||
|
@ -96,12 +96,12 @@ IntrusivePtr<OpaqueVal> OpaqueVal::Unserialize(const broker::data& data)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<BroType>& t)
|
broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<zeek::Type>& t)
|
||||||
{
|
{
|
||||||
if ( t->InternalType() == TYPE_INTERNAL_ERROR )
|
if ( t->InternalType() == zeek::TYPE_INTERNAL_ERROR )
|
||||||
return broker::ec::invalid_data;
|
return broker::ec::invalid_data;
|
||||||
|
|
||||||
if ( t->InternalType() == TYPE_INTERNAL_OTHER )
|
if ( t->InternalType() == zeek::TYPE_INTERNAL_OTHER )
|
||||||
{
|
{
|
||||||
// Serialize by name.
|
// Serialize by name.
|
||||||
assert(t->GetName().size());
|
assert(t->GetName().size());
|
||||||
|
@ -112,7 +112,7 @@ broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<BroTy
|
||||||
return {broker::vector{false, static_cast<uint64_t>(t->Tag())}};
|
return {broker::vector{false, static_cast<uint64_t>(t->Tag())}};
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<BroType> OpaqueVal::UnserializeType(const broker::data& data)
|
IntrusivePtr<zeek::Type> OpaqueVal::UnserializeType(const broker::data& data)
|
||||||
{
|
{
|
||||||
auto v = caf::get_if<broker::vector>(&data);
|
auto v = caf::get_if<broker::vector>(&data);
|
||||||
if ( ! (v && v->size() == 2) )
|
if ( ! (v && v->size() == 2) )
|
||||||
|
@ -142,7 +142,7 @@ IntrusivePtr<BroType> OpaqueVal::UnserializeType(const broker::data& data)
|
||||||
if ( ! tag )
|
if ( ! tag )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return base_type(static_cast<TypeTag>(*tag));
|
return zeek::base_type(static_cast<zeek::TypeTag>(*tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Val> OpaqueVal::DoClone(CloneState* state)
|
IntrusivePtr<Val> OpaqueVal::DoClone(CloneState* state)
|
||||||
|
@ -206,12 +206,12 @@ IntrusivePtr<StringVal> HashVal::DoGet()
|
||||||
return val_mgr->EmptyString();
|
return val_mgr->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
HashVal::HashVal(IntrusivePtr<OpaqueType> t) : OpaqueVal(std::move(t))
|
HashVal::HashVal(IntrusivePtr<zeek::OpaqueType> t) : OpaqueVal(std::move(t))
|
||||||
{
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashVal::HashVal(OpaqueType* t) : HashVal({NewRef{}, t})
|
HashVal::HashVal(zeek::OpaqueType* t) : HashVal({NewRef{}, t})
|
||||||
{}
|
{}
|
||||||
|
|
||||||
MD5Val::MD5Val() : HashVal(md5_type)
|
MD5Val::MD5Val() : HashVal(md5_type)
|
||||||
|
@ -226,7 +226,7 @@ MD5Val::~MD5Val()
|
||||||
|
|
||||||
void HashVal::digest_one(EVP_MD_CTX* h, const Val* v)
|
void HashVal::digest_one(EVP_MD_CTX* h, const Val* v)
|
||||||
{
|
{
|
||||||
if ( v->GetType()->Tag() == TYPE_STRING )
|
if ( v->GetType()->Tag() == zeek::TYPE_STRING )
|
||||||
{
|
{
|
||||||
const BroString* str = v->AsString();
|
const BroString* str = v->AsString();
|
||||||
hash_update(h, str->Bytes(), str->Len());
|
hash_update(h, str->Bytes(), str->Len());
|
||||||
|
@ -723,14 +723,14 @@ IntrusivePtr<Val> BloomFilterVal::DoClone(CloneState* state)
|
||||||
return state->NewClone(this, make_intrusive<BloomFilterVal>());
|
return state->NewClone(this, make_intrusive<BloomFilterVal>());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BloomFilterVal::Typify(IntrusivePtr<BroType> arg_type)
|
bool BloomFilterVal::Typify(IntrusivePtr<zeek::Type> arg_type)
|
||||||
{
|
{
|
||||||
if ( type )
|
if ( type )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
type = std::move(arg_type);
|
type = std::move(arg_type);
|
||||||
|
|
||||||
auto tl = make_intrusive<TypeList>(type);
|
auto tl = make_intrusive<zeek::TypeList>(type);
|
||||||
tl->Append(type);
|
tl->Append(type);
|
||||||
hash = new CompositeHash(std::move(tl));
|
hash = new CompositeHash(std::move(tl));
|
||||||
|
|
||||||
|
@ -882,14 +882,14 @@ IntrusivePtr<Val> CardinalityVal::DoClone(CloneState* state)
|
||||||
make_intrusive<CardinalityVal>(new probabilistic::CardinalityCounter(*c)));
|
make_intrusive<CardinalityVal>(new probabilistic::CardinalityCounter(*c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardinalityVal::Typify(IntrusivePtr<BroType> arg_type)
|
bool CardinalityVal::Typify(IntrusivePtr<zeek::Type> arg_type)
|
||||||
{
|
{
|
||||||
if ( type )
|
if ( type )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
type = std::move(arg_type);
|
type = std::move(arg_type);
|
||||||
|
|
||||||
auto tl = make_intrusive<TypeList>(type);
|
auto tl = make_intrusive<zeek::TypeList>(type);
|
||||||
tl->Append(type);
|
tl->Append(type);
|
||||||
hash = new CompositeHash(std::move(tl));
|
hash = new CompositeHash(std::move(tl));
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,8 @@ private:
|
||||||
class OpaqueVal : public Val {
|
class OpaqueVal : public Val {
|
||||||
public:
|
public:
|
||||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||||
explicit OpaqueVal(OpaqueType* t);
|
explicit OpaqueVal(zeek::OpaqueType* t);
|
||||||
explicit OpaqueVal(IntrusivePtr<OpaqueType> t);
|
explicit OpaqueVal(IntrusivePtr<zeek::OpaqueType> t);
|
||||||
~OpaqueVal() override;
|
~OpaqueVal() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,13 +148,13 @@ protected:
|
||||||
* Helper function for derived class that need to record a type
|
* Helper function for derived class that need to record a type
|
||||||
* during serialization.
|
* during serialization.
|
||||||
*/
|
*/
|
||||||
static broker::expected<broker::data> SerializeType(const IntrusivePtr<BroType>& t);
|
static broker::expected<broker::data> SerializeType(const IntrusivePtr<zeek::Type>& t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function for derived class that need to restore a type
|
* Helper function for derived class that need to restore a type
|
||||||
* during unserialization. Returns the type at reference count +1.
|
* during unserialization. Returns the type at reference count +1.
|
||||||
*/
|
*/
|
||||||
static IntrusivePtr<BroType> UnserializeType(const broker::data& data);
|
static IntrusivePtr<zeek::Type> UnserializeType(const broker::data& data);
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace probabilistic {
|
namespace probabilistic {
|
||||||
|
@ -187,8 +187,8 @@ protected:
|
||||||
HashVal() { valid = false; }
|
HashVal() { valid = false; }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||||
explicit HashVal(OpaqueType* t);
|
explicit HashVal(zeek::OpaqueType* t);
|
||||||
explicit HashVal(IntrusivePtr<OpaqueType> t);
|
explicit HashVal(IntrusivePtr<zeek::OpaqueType> t);
|
||||||
|
|
||||||
virtual bool DoInit();
|
virtual bool DoInit();
|
||||||
virtual bool DoFeed(const void* data, size_t size);
|
virtual bool DoFeed(const void* data, size_t size);
|
||||||
|
@ -304,10 +304,10 @@ public:
|
||||||
|
|
||||||
IntrusivePtr<Val> DoClone(CloneState* state) override;
|
IntrusivePtr<Val> DoClone(CloneState* state) override;
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& Type() const
|
const IntrusivePtr<zeek::Type>& Type() const
|
||||||
{ return type; }
|
{ return type; }
|
||||||
|
|
||||||
bool Typify(IntrusivePtr<BroType> type);
|
bool Typify(IntrusivePtr<zeek::Type> type);
|
||||||
|
|
||||||
void Add(const Val* val);
|
void Add(const Val* val);
|
||||||
size_t Count(const Val* val) const;
|
size_t Count(const Val* val) const;
|
||||||
|
@ -328,7 +328,7 @@ private:
|
||||||
BloomFilterVal(const BloomFilterVal&);
|
BloomFilterVal(const BloomFilterVal&);
|
||||||
BloomFilterVal& operator=(const BloomFilterVal&);
|
BloomFilterVal& operator=(const BloomFilterVal&);
|
||||||
|
|
||||||
IntrusivePtr<BroType> type;
|
IntrusivePtr<zeek::Type> type;
|
||||||
CompositeHash* hash;
|
CompositeHash* hash;
|
||||||
probabilistic::BloomFilter* bloom_filter;
|
probabilistic::BloomFilter* bloom_filter;
|
||||||
};
|
};
|
||||||
|
@ -343,10 +343,10 @@ public:
|
||||||
|
|
||||||
void Add(const Val* val);
|
void Add(const Val* val);
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& Type() const
|
const IntrusivePtr<zeek::Type>& Type() const
|
||||||
{ return type; }
|
{ return type; }
|
||||||
|
|
||||||
bool Typify(IntrusivePtr<BroType> type);
|
bool Typify(IntrusivePtr<zeek::Type> type);
|
||||||
|
|
||||||
probabilistic::CardinalityCounter* Get() { return c; };
|
probabilistic::CardinalityCounter* Get() { return c; };
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ protected:
|
||||||
|
|
||||||
DECLARE_OPAQUE_VALUE(CardinalityVal)
|
DECLARE_OPAQUE_VALUE(CardinalityVal)
|
||||||
private:
|
private:
|
||||||
IntrusivePtr<BroType> type;
|
IntrusivePtr<zeek::Type> type;
|
||||||
CompositeHash* hash;
|
CompositeHash* hash;
|
||||||
probabilistic::CardinalityCounter* c;
|
probabilistic::CardinalityCounter* c;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
using namespace bro;
|
using namespace zeek::detail;
|
||||||
|
|
||||||
static void pipe_fail(int eno)
|
static void pipe_fail(int eno)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace bro {
|
namespace zeek::detail {
|
||||||
|
|
||||||
class Pipe {
|
class Pipe {
|
||||||
public:
|
public:
|
||||||
|
@ -136,4 +136,4 @@ private:
|
||||||
bool swapped = false;
|
bool swapped = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace bro
|
} // namespace zeek::detail
|
||||||
|
|
|
@ -43,16 +43,16 @@ void* PrefixTable::Insert(const IPAddr& addr, int width, void* data)
|
||||||
void* PrefixTable::Insert(const Val* value, void* data)
|
void* PrefixTable::Insert(const Val* value, void* data)
|
||||||
{
|
{
|
||||||
// [elem] -> elem
|
// [elem] -> elem
|
||||||
if ( value->GetType()->Tag() == TYPE_LIST &&
|
if ( value->GetType()->Tag() == zeek::TYPE_LIST &&
|
||||||
value->AsListVal()->Length() == 1 )
|
value->AsListVal()->Length() == 1 )
|
||||||
value = value->AsListVal()->Idx(0).get();
|
value = value->AsListVal()->Idx(0).get();
|
||||||
|
|
||||||
switch ( value->GetType()->Tag() ) {
|
switch ( value->GetType()->Tag() ) {
|
||||||
case TYPE_ADDR:
|
case zeek::TYPE_ADDR:
|
||||||
return Insert(value->AsAddr(), 128, data);
|
return Insert(value->AsAddr(), 128, data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_SUBNET:
|
case zeek::TYPE_SUBNET:
|
||||||
return Insert(value->AsSubNet().Prefix(),
|
return Insert(value->AsSubNet().Prefix(),
|
||||||
value->AsSubNet().LengthIPv6(), data);
|
value->AsSubNet().LengthIPv6(), data);
|
||||||
break;
|
break;
|
||||||
|
@ -103,16 +103,16 @@ void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
|
||||||
void* PrefixTable::Lookup(const Val* value, bool exact) const
|
void* PrefixTable::Lookup(const Val* value, bool exact) const
|
||||||
{
|
{
|
||||||
// [elem] -> elem
|
// [elem] -> elem
|
||||||
if ( value->GetType()->Tag() == TYPE_LIST &&
|
if ( value->GetType()->Tag() == zeek::TYPE_LIST &&
|
||||||
value->AsListVal()->Length() == 1 )
|
value->AsListVal()->Length() == 1 )
|
||||||
value = value->AsListVal()->Idx(0).get();
|
value = value->AsListVal()->Idx(0).get();
|
||||||
|
|
||||||
switch ( value->GetType()->Tag() ) {
|
switch ( value->GetType()->Tag() ) {
|
||||||
case TYPE_ADDR:
|
case zeek::TYPE_ADDR:
|
||||||
return Lookup(value->AsAddr(), 128, exact);
|
return Lookup(value->AsAddr(), 128, exact);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_SUBNET:
|
case zeek::TYPE_SUBNET:
|
||||||
return Lookup(value->AsSubNet().Prefix(),
|
return Lookup(value->AsSubNet().Prefix(),
|
||||||
value->AsSubNet().LengthIPv6(), exact);
|
value->AsSubNet().LengthIPv6(), exact);
|
||||||
break;
|
break;
|
||||||
|
@ -142,16 +142,16 @@ void* PrefixTable::Remove(const IPAddr& addr, int width)
|
||||||
void* PrefixTable::Remove(const Val* value)
|
void* PrefixTable::Remove(const Val* value)
|
||||||
{
|
{
|
||||||
// [elem] -> elem
|
// [elem] -> elem
|
||||||
if ( value->GetType()->Tag() == TYPE_LIST &&
|
if ( value->GetType()->Tag() == zeek::TYPE_LIST &&
|
||||||
value->AsListVal()->Length() == 1 )
|
value->AsListVal()->Length() == 1 )
|
||||||
value = value->AsListVal()->Idx(0).get();
|
value = value->AsListVal()->Idx(0).get();
|
||||||
|
|
||||||
switch ( value->GetType()->Tag() ) {
|
switch ( value->GetType()->Tag() ) {
|
||||||
case TYPE_ADDR:
|
case zeek::TYPE_ADDR:
|
||||||
return Remove(value->AsAddr(), 128);
|
return Remove(value->AsAddr(), 128);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_SUBNET:
|
case zeek::TYPE_SUBNET:
|
||||||
return Remove(value->AsSubNet().Prefix(),
|
return Remove(value->AsSubNet().Prefix(),
|
||||||
value->AsSubNet().LengthIPv6());
|
value->AsSubNet().LengthIPv6());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -143,7 +143,7 @@ void Reporter::FatalErrorWithCore(const char* fmt, ...)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reporter::ExprRuntimeError(const Expr* expr, const char* fmt, ...)
|
void Reporter::ExprRuntimeError(const zeek::detail::Expr* expr, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
++errors;
|
++errors;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPAddr;
|
class IPAddr;
|
||||||
class Expr;
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
|
||||||
#define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess.
|
#define FMT_ATTR __attribute__((format(printf, 2, 3))) // sic! 1st is "this" I guess.
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public:
|
||||||
|
|
||||||
// Report a runtime error in evaluating a Bro script expression. This
|
// Report a runtime error in evaluating a Bro script expression. This
|
||||||
// function will not return but raise an InterpreterException.
|
// function will not return but raise an InterpreterException.
|
||||||
[[noreturn]] void ExprRuntimeError(const Expr* expr, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
[[noreturn]] void ExprRuntimeError(const zeek::detail::Expr* expr, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||||
|
|
||||||
// Report a runtime error in evaluating a Bro script expression. This
|
// Report a runtime error in evaluating a Bro script expression. This
|
||||||
// function will not return but raise an InterpreterException.
|
// function will not return but raise an InterpreterException.
|
||||||
|
|
|
@ -136,18 +136,18 @@ RuleConditionEval::RuleConditionEval(const char* func)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( id->GetType()->Tag() == TYPE_FUNC )
|
if ( id->GetType()->Tag() == zeek::TYPE_FUNC )
|
||||||
{
|
{
|
||||||
// Validate argument quantity and type.
|
// Validate argument quantity and type.
|
||||||
FuncType* f = id->GetType()->AsFuncType();
|
zeek::FuncType* f = id->GetType()->AsFuncType();
|
||||||
|
|
||||||
if ( f->Yield()->Tag() != TYPE_BOOL )
|
if ( f->Yield()->Tag() != zeek::TYPE_BOOL )
|
||||||
rules_error("eval function type must yield a 'bool'", func);
|
rules_error("eval function type must yield a 'bool'", func);
|
||||||
|
|
||||||
static auto signature_state = zeek::id::find_type<RecordType>("signature_state");
|
static auto signature_state = zeek::id::find_type<zeek::RecordType>("signature_state");
|
||||||
TypeList tl;
|
zeek::TypeList tl;
|
||||||
tl.Append(signature_state);
|
tl.Append(signature_state);
|
||||||
tl.Append(base_type(TYPE_STRING));
|
tl.Append(zeek::base_type(zeek::TYPE_STRING));
|
||||||
|
|
||||||
if ( ! f->CheckArgs(tl.Types()) )
|
if ( ! f->CheckArgs(tl.Types()) )
|
||||||
rules_error("eval function parameters must be a 'signature_state' "
|
rules_error("eval function parameters must be a 'signature_state' "
|
||||||
|
@ -164,7 +164,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( id->GetType()->Tag() != TYPE_FUNC )
|
if ( id->GetType()->Tag() != zeek::TYPE_FUNC )
|
||||||
return id->GetVal()->AsBool();
|
return id->GetVal()->AsBool();
|
||||||
|
|
||||||
// Call function with a signature_state value as argument.
|
// Call function with a signature_state value as argument.
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
#include <stdint.h> // for u_char
|
#include <stdint.h> // for u_char
|
||||||
#include <sys/types.h> // for u_char
|
#include <sys/types.h> // for u_char
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class ID;
|
|
||||||
class Rule;
|
class Rule;
|
||||||
class RuleEndpointState;
|
class RuleEndpointState;
|
||||||
|
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
// Base class for all rule conditions except patterns and "header".
|
// Base class for all rule conditions except patterns and "header".
|
||||||
class RuleCondition {
|
class RuleCondition {
|
||||||
public:
|
public:
|
||||||
|
@ -111,7 +113,5 @@ public:
|
||||||
|
|
||||||
void PrintDebug() override;
|
void PrintDebug() override;
|
||||||
private:
|
private:
|
||||||
ID* id;
|
zeek::detail::ID* id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ RuleHdrTest::RuleHdrTest(Prot arg_prot, Comp arg_comp, vector<IPPrefix> arg_v)
|
||||||
Val* RuleMatcher::BuildRuleStateValue(const Rule* rule,
|
Val* RuleMatcher::BuildRuleStateValue(const Rule* rule,
|
||||||
const RuleEndpointState* state) const
|
const RuleEndpointState* state) const
|
||||||
{
|
{
|
||||||
static auto signature_state = zeek::id::find_type<RecordType>("signature_state");
|
static auto signature_state = zeek::id::find_type<zeek::RecordType>("signature_state");
|
||||||
RecordVal* val = new RecordVal(signature_state);
|
RecordVal* val = new RecordVal(signature_state);
|
||||||
val->Assign(0, make_intrusive<StringVal>(rule->ID()));
|
val->Assign(0, make_intrusive<StringVal>(rule->ID()));
|
||||||
val->Assign(1, state->GetAnalyzer()->ConnVal());
|
val->Assign(1, state->GetAnalyzer()->ConnVal());
|
||||||
|
@ -1294,20 +1294,20 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to,
|
||||||
MaskedValue* mval = new MaskedValue;
|
MaskedValue* mval = new MaskedValue;
|
||||||
|
|
||||||
switch ( v->GetType()->Tag() ) {
|
switch ( v->GetType()->Tag() ) {
|
||||||
case TYPE_PORT:
|
case zeek::TYPE_PORT:
|
||||||
mval->val = v->AsPortVal()->Port();
|
mval->val = v->AsPortVal()->Port();
|
||||||
mval->mask = 0xffffffff;
|
mval->mask = 0xffffffff;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_BOOL:
|
case zeek::TYPE_BOOL:
|
||||||
case TYPE_COUNT:
|
case zeek::TYPE_COUNT:
|
||||||
case TYPE_ENUM:
|
case zeek::TYPE_ENUM:
|
||||||
case TYPE_INT:
|
case zeek::TYPE_INT:
|
||||||
mval->val = v->CoerceToUnsigned();
|
mval->val = v->CoerceToUnsigned();
|
||||||
mval->mask = 0xffffffff;
|
mval->mask = 0xffffffff;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_SUBNET:
|
case zeek::TYPE_SUBNET:
|
||||||
{
|
{
|
||||||
if ( prefix_vector )
|
if ( prefix_vector )
|
||||||
{
|
{
|
||||||
|
@ -1362,7 +1362,7 @@ void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( v->GetType()->Tag() == TYPE_TABLE )
|
if ( v->GetType()->Tag() == zeek::TYPE_TABLE )
|
||||||
{
|
{
|
||||||
auto lv = v->AsTableVal()->ToPureListVal();
|
auto lv = v->AsTableVal()->ToPureListVal();
|
||||||
|
|
||||||
|
@ -1384,7 +1384,7 @@ char* id_to_str(const char* id)
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ( v->GetType()->Tag() != TYPE_STRING )
|
if ( v->GetType()->Tag() != zeek::TYPE_STRING )
|
||||||
{
|
{
|
||||||
rules_error("Identifier must refer to string");
|
rules_error("Identifier must refer to string");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1407,10 +1407,10 @@ uint32_t id_to_uint(const char* id)
|
||||||
if ( ! v )
|
if ( ! v )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TypeTag t = v->GetType()->Tag();
|
zeek::TypeTag t = v->GetType()->Tag();
|
||||||
|
|
||||||
if ( t == TYPE_BOOL || t == TYPE_COUNT || t == TYPE_ENUM ||
|
if ( t == zeek::TYPE_BOOL || t == zeek::TYPE_COUNT || t == zeek::TYPE_ENUM ||
|
||||||
t == TYPE_INT || t == TYPE_PORT )
|
t == zeek::TYPE_INT || t == zeek::TYPE_PORT )
|
||||||
return v->CoerceToUnsigned();
|
return v->CoerceToUnsigned();
|
||||||
|
|
||||||
rules_error("Identifier must refer to integer");
|
rules_error("Identifier must refer to integer");
|
||||||
|
|
52
src/Scope.cc
52
src/Scope.cc
|
@ -15,8 +15,8 @@ typedef PList<Scope> scope_list;
|
||||||
static scope_list scopes;
|
static scope_list scopes;
|
||||||
static Scope* top_scope;
|
static Scope* top_scope;
|
||||||
|
|
||||||
Scope::Scope(IntrusivePtr<ID> id,
|
Scope::Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al)
|
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> al)
|
||||||
: scope_id(std::move(id)), attrs(std::move(al))
|
: scope_id(std::move(id)), attrs(std::move(al))
|
||||||
{
|
{
|
||||||
return_type = nullptr;
|
return_type = nullptr;
|
||||||
|
@ -25,27 +25,27 @@ Scope::Scope(IntrusivePtr<ID> id,
|
||||||
{
|
{
|
||||||
const auto& id_type = scope_id->GetType();
|
const auto& id_type = scope_id->GetType();
|
||||||
|
|
||||||
if ( id_type->Tag() == TYPE_ERROR )
|
if ( id_type->Tag() == zeek::TYPE_ERROR )
|
||||||
return;
|
return;
|
||||||
else if ( id_type->Tag() != TYPE_FUNC )
|
else if ( id_type->Tag() != zeek::TYPE_FUNC )
|
||||||
reporter->InternalError("bad scope id");
|
reporter->InternalError("bad scope id");
|
||||||
|
|
||||||
FuncType* ft = id->GetType()->AsFuncType();
|
zeek::FuncType* ft = id->GetType()->AsFuncType();
|
||||||
return_type = ft->Yield();
|
return_type = ft->Yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<ID>& Scope::Find(std::string_view name) const
|
const IntrusivePtr<zeek::detail::ID>& Scope::Find(std::string_view name) const
|
||||||
{
|
{
|
||||||
auto entry = local.find(name);
|
auto entry = local.find(name);
|
||||||
|
|
||||||
if ( entry != local.end() )
|
if ( entry != local.end() )
|
||||||
return entry->second;
|
return entry->second;
|
||||||
|
|
||||||
return ID::nil;
|
return zeek::detail::ID::nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<ID> Scope::Remove(std::string_view name)
|
IntrusivePtr<zeek::detail::ID> Scope::Remove(std::string_view name)
|
||||||
{
|
{
|
||||||
auto entry = local.find(name);
|
auto entry = local.find(name);
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ IntrusivePtr<ID> Scope::Remove(std::string_view name)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<ID> Scope::GenerateTemporary(const char* name)
|
IntrusivePtr<zeek::detail::ID> Scope::GenerateTemporary(const char* name)
|
||||||
{
|
{
|
||||||
return make_intrusive<ID>(name, SCOPE_FUNCTION, false);
|
return make_intrusive<zeek::detail::ID>(name, zeek::detail::SCOPE_FUNCTION, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<IntrusivePtr<ID>> Scope::GetInits()
|
std::vector<IntrusivePtr<zeek::detail::ID>> Scope::GetInits()
|
||||||
{
|
{
|
||||||
auto rval = std::move(inits);
|
auto rval = std::move(inits);
|
||||||
inits = {};
|
inits = {};
|
||||||
|
@ -100,7 +100,7 @@ void Scope::Describe(ODesc* d) const
|
||||||
|
|
||||||
for ( const auto& entry : local )
|
for ( const auto& entry : local )
|
||||||
{
|
{
|
||||||
ID* id = entry.second.get();
|
zeek::detail::ID* id = entry.second.get();
|
||||||
id->Describe(d);
|
id->Describe(d);
|
||||||
d->NL();
|
d->NL();
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
|
||||||
{
|
{
|
||||||
for ( const auto& entry : local )
|
for ( const auto& entry : local )
|
||||||
{
|
{
|
||||||
ID* id = entry.second.get();
|
zeek::detail::ID* id = entry.second.get();
|
||||||
TraversalCode tc = id->Traverse(cb);
|
TraversalCode tc = id->Traverse(cb);
|
||||||
HANDLE_TC_STMT_PRE(tc);
|
HANDLE_TC_STMT_PRE(tc);
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const IntrusivePtr<ID>& lookup_ID(const char* name, const char* curr_module,
|
const IntrusivePtr<zeek::detail::ID>& lookup_ID(const char* name, const char* curr_module,
|
||||||
bool no_global, bool same_module_only,
|
bool no_global, bool same_module_only,
|
||||||
bool check_export)
|
bool check_export)
|
||||||
{
|
{
|
||||||
std::string fullname = make_full_var_name(curr_module, name);
|
std::string fullname = make_full_var_name(curr_module, name);
|
||||||
|
|
||||||
|
@ -150,30 +150,30 @@ const IntrusivePtr<ID>& lookup_ID(const char* name, const char* curr_module,
|
||||||
return global_scope()->Find(globalname);
|
return global_scope()->Find(globalname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ID::nil;
|
return zeek::detail::ID::nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<ID> install_ID(const char* name, const char* module_name,
|
IntrusivePtr<zeek::detail::ID> install_ID(const char* name, const char* module_name,
|
||||||
bool is_global, bool is_export)
|
bool is_global, bool is_export)
|
||||||
{
|
{
|
||||||
if ( scopes.empty() && ! is_global )
|
if ( scopes.empty() && ! is_global )
|
||||||
reporter->InternalError("local identifier in global scope");
|
reporter->InternalError("local identifier in global scope");
|
||||||
|
|
||||||
IDScope scope;
|
zeek::detail::IDScope scope;
|
||||||
if ( is_export || ! module_name ||
|
if ( is_export || ! module_name ||
|
||||||
(is_global &&
|
(is_global &&
|
||||||
normalized_module_name(module_name) == GLOBAL_MODULE_NAME) )
|
normalized_module_name(module_name) == GLOBAL_MODULE_NAME) )
|
||||||
scope = SCOPE_GLOBAL;
|
scope = zeek::detail::SCOPE_GLOBAL;
|
||||||
else if ( is_global )
|
else if ( is_global )
|
||||||
scope = SCOPE_MODULE;
|
scope = zeek::detail::SCOPE_MODULE;
|
||||||
else
|
else
|
||||||
scope = SCOPE_FUNCTION;
|
scope = zeek::detail::SCOPE_FUNCTION;
|
||||||
|
|
||||||
std::string full_name = make_full_var_name(module_name, name);
|
std::string full_name = make_full_var_name(module_name, name);
|
||||||
|
|
||||||
auto id = make_intrusive<ID>(full_name.data(), scope, is_export);
|
auto id = make_intrusive<zeek::detail::ID>(full_name.data(), scope, is_export);
|
||||||
|
|
||||||
if ( SCOPE_FUNCTION != scope )
|
if ( zeek::detail::SCOPE_FUNCTION != scope )
|
||||||
global_scope()->Insert(std::move(full_name), id);
|
global_scope()->Insert(std::move(full_name), id);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -189,8 +189,8 @@ void push_existing_scope(Scope* scope)
|
||||||
scopes.push_back(scope);
|
scopes.push_back(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_scope(IntrusivePtr<ID> id,
|
void push_scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||||
{
|
{
|
||||||
top_scope = new Scope(std::move(id), std::move(attrs));
|
top_scope = new Scope(std::move(id), std::move(attrs));
|
||||||
scopes.push_back(top_scope);
|
scopes.push_back(top_scope);
|
||||||
|
|
58
src/Scope.h
58
src/Scope.h
|
@ -13,53 +13,55 @@
|
||||||
#include "TraverseTypes.h"
|
#include "TraverseTypes.h"
|
||||||
|
|
||||||
template <class T> class IntrusivePtr;
|
template <class T> class IntrusivePtr;
|
||||||
class ID;
|
|
||||||
class BroType;
|
|
||||||
class ListVal;
|
class ListVal;
|
||||||
|
|
||||||
|
namespace zeek { class Type; }
|
||||||
|
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
class Scope : public BroObj {
|
class Scope : public BroObj {
|
||||||
public:
|
public:
|
||||||
explicit Scope(IntrusivePtr<ID> id,
|
explicit Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al);
|
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> al);
|
||||||
|
|
||||||
const IntrusivePtr<ID>& Find(std::string_view name) const;
|
const IntrusivePtr<zeek::detail::ID>& Find(std::string_view name) const;
|
||||||
|
|
||||||
template<typename N>
|
template<typename N>
|
||||||
[[deprecated("Remove in v4.1. Use Find().")]]
|
[[deprecated("Remove in v4.1. Use Find().")]]
|
||||||
ID* Lookup(N&& name) const
|
zeek::detail::ID* Lookup(N&& name) const
|
||||||
{ return Find(name).get(); }
|
{ return Find(name).get(); }
|
||||||
|
|
||||||
template<typename N, typename I>
|
template<typename N, typename I>
|
||||||
void Insert(N&& name, I&& id) { local[std::forward<N>(name)] = std::forward<I>(id); }
|
void Insert(N&& name, I&& id) { local[std::forward<N>(name)] = std::forward<I>(id); }
|
||||||
|
|
||||||
IntrusivePtr<ID> Remove(std::string_view name);
|
IntrusivePtr<zeek::detail::ID> Remove(std::string_view name);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetID().")]]
|
[[deprecated("Remove in v4.1. Use GetID().")]]
|
||||||
ID* ScopeID() const { return scope_id.get(); }
|
zeek::detail::ID* ScopeID() const { return scope_id.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<ID>& GetID() const
|
const IntrusivePtr<zeek::detail::ID>& GetID() const
|
||||||
{ return scope_id; }
|
{ return scope_id; }
|
||||||
|
|
||||||
const std::unique_ptr<std::vector<IntrusivePtr<Attr>>>& Attrs() const
|
const std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>>& Attrs() const
|
||||||
{ return attrs; }
|
{ return attrs; }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
||||||
BroType* ReturnType() const { return return_type.get(); }
|
zeek::Type* ReturnType() const { return return_type.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<BroType>& GetReturnType() const
|
const IntrusivePtr<zeek::Type>& GetReturnType() const
|
||||||
{ return return_type; }
|
{ return return_type; }
|
||||||
|
|
||||||
size_t Length() const { return local.size(); }
|
size_t Length() const { return local.size(); }
|
||||||
const auto& Vars() { return local; }
|
const auto& Vars() { return local; }
|
||||||
|
|
||||||
IntrusivePtr<ID> GenerateTemporary(const char* name);
|
IntrusivePtr<zeek::detail::ID> GenerateTemporary(const char* name);
|
||||||
|
|
||||||
// Returns the list of variables needing initialization, and
|
// Returns the list of variables needing initialization, and
|
||||||
// removes it from this Scope.
|
// removes it from this Scope.
|
||||||
std::vector<IntrusivePtr<ID>> GetInits();
|
std::vector<IntrusivePtr<zeek::detail::ID>> GetInits();
|
||||||
|
|
||||||
// Adds a variable to the list.
|
// Adds a variable to the list.
|
||||||
void AddInit(IntrusivePtr<ID> id)
|
void AddInit(IntrusivePtr<zeek::detail::ID> id)
|
||||||
{ inits.emplace_back(std::move(id)); }
|
{ inits.emplace_back(std::move(id)); }
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
|
@ -67,27 +69,27 @@ public:
|
||||||
TraversalCode Traverse(TraversalCallback* cb) const;
|
TraversalCode Traverse(TraversalCallback* cb) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<ID> scope_id;
|
IntrusivePtr<zeek::detail::ID> scope_id;
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs;
|
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs;
|
||||||
IntrusivePtr<BroType> return_type;
|
IntrusivePtr<zeek::Type> return_type;
|
||||||
std::map<std::string, IntrusivePtr<ID>, std::less<>> local;
|
std::map<std::string, IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||||
std::vector<IntrusivePtr<ID>> inits;
|
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern bool in_debug;
|
extern bool in_debug;
|
||||||
|
|
||||||
// If no_global is true, don't search in the default "global" namespace.
|
// If no_global is true, don't search in the default "global" namespace.
|
||||||
extern const IntrusivePtr<ID>& lookup_ID(const char* name, const char* module,
|
extern const IntrusivePtr<zeek::detail::ID>& lookup_ID(const char* name, const char* module,
|
||||||
bool no_global = false,
|
bool no_global = false,
|
||||||
bool same_module_only = false,
|
bool same_module_only = false,
|
||||||
bool check_export = true);
|
bool check_export = true);
|
||||||
|
|
||||||
extern IntrusivePtr<ID> install_ID(const char* name, const char* module_name,
|
extern IntrusivePtr<zeek::detail::ID> install_ID(const char* name, const char* module_name,
|
||||||
bool is_global, bool is_export);
|
bool is_global, bool is_export);
|
||||||
|
|
||||||
extern void push_scope(IntrusivePtr<ID> id,
|
extern void push_scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs);
|
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs);
|
||||||
extern void push_existing_scope(Scope* scope);
|
extern void push_existing_scope(Scope* scope);
|
||||||
|
|
||||||
// Returns the one popped off.
|
// Returns the one popped off.
|
||||||
|
|
|
@ -248,6 +248,23 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ip_hdr->IP4_Hdr() )
|
||||||
|
{
|
||||||
|
if ( ip_hdr_len < sizeof(struct ip) )
|
||||||
|
{
|
||||||
|
Weird("IPv4_min_header_size", pkt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ip_hdr_len < sizeof(struct ip6_hdr) )
|
||||||
|
{
|
||||||
|
Weird("IPv6_min_header_size", pkt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore if packet matches packet filter.
|
// Ignore if packet matches packet filter.
|
||||||
if ( packet_filter && packet_filter->Match(ip_hdr, len, caplen) )
|
if ( packet_filter && packet_filter->Match(ip_hdr, len, caplen) )
|
||||||
return;
|
return;
|
||||||
|
@ -906,10 +923,10 @@ FragReassembler* NetSessions::NextFragment(double t, const IP_Hdr* ip,
|
||||||
Connection* NetSessions::FindConnection(Val* v)
|
Connection* NetSessions::FindConnection(Val* v)
|
||||||
{
|
{
|
||||||
const auto& vt = v->GetType();
|
const auto& vt = v->GetType();
|
||||||
if ( ! IsRecord(vt->Tag()) )
|
if ( ! zeek::IsRecord(vt->Tag()) )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
RecordType* vr = vt->AsRecordType();
|
zeek::RecordType* vr = vt->AsRecordType();
|
||||||
auto vl = v->AsRecord();
|
auto vl = v->AsRecord();
|
||||||
|
|
||||||
int orig_h, orig_p; // indices into record's value list
|
int orig_h, orig_p; // indices into record's value list
|
||||||
|
|
|
@ -58,10 +58,10 @@ bool BroSubstring::DoesCover(const BroSubstring* bst) const
|
||||||
|
|
||||||
VectorVal* BroSubstring::VecToPolicy(Vec* vec)
|
VectorVal* BroSubstring::VecToPolicy(Vec* vec)
|
||||||
{
|
{
|
||||||
static auto sw_substring_type = zeek::id::find_type<RecordType>("sw_substring");
|
static auto sw_substring_type = zeek::id::find_type<zeek::RecordType>("sw_substring");
|
||||||
static auto sw_align_type = zeek::id::find_type<RecordType>("sw_align");
|
static auto sw_align_type = zeek::id::find_type<zeek::RecordType>("sw_align");
|
||||||
static auto sw_align_vec_type = zeek::id::find_type<VectorType>("sw_align_vec");
|
static auto sw_align_vec_type = zeek::id::find_type<zeek::VectorType>("sw_align_vec");
|
||||||
static auto sw_substring_vec_type = zeek::id::find_type<VectorType>("sw_substring_vec");
|
static auto sw_substring_vec_type = zeek::id::find_type<zeek::VectorType>("sw_substring_vec");
|
||||||
|
|
||||||
auto result = make_intrusive<VectorVal>(sw_substring_vec_type);
|
auto result = make_intrusive<VectorVal>(sw_substring_vec_type);
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ BroSubstring::Vec* smith_waterman(const BroString* s1, const BroString* s2,
|
||||||
current->swn_prev ? current->swn_prev->id : 0,
|
current->swn_prev ? current->swn_prev->id : 0,
|
||||||
string1[i-1], string2[j-1]);
|
string1[i-1], string2[j-1]);
|
||||||
#endif
|
#endif
|
||||||
//printf("%.5i ", current->swn_score);
|
//printf("%.5i ", current->swn_score);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -191,7 +191,7 @@ void ProfileLogger::Log()
|
||||||
dstats.requests, dstats.successful, dstats.failed, dstats.pending,
|
dstats.requests, dstats.successful, dstats.failed, dstats.pending,
|
||||||
dstats.cached_hosts, dstats.cached_addresses));
|
dstats.cached_hosts, dstats.cached_addresses));
|
||||||
|
|
||||||
trigger::Manager::Stats tstats;
|
zeek::detail::trigger::Manager::Stats tstats;
|
||||||
trigger_mgr->GetStats(&tstats);
|
trigger_mgr->GetStats(&tstats);
|
||||||
|
|
||||||
file->Write(fmt("%.06f Triggers: total=%lu pending=%lu\n", network_time, tstats.total, tstats.pending));
|
file->Write(fmt("%.06f Triggers: total=%lu pending=%lu\n", network_time, tstats.total, tstats.pending));
|
||||||
|
@ -252,7 +252,7 @@ void ProfileLogger::Log()
|
||||||
|
|
||||||
for ( const auto& global : globals )
|
for ( const auto& global : globals )
|
||||||
{
|
{
|
||||||
ID* id = global.second.get();
|
auto& id = global.second;
|
||||||
|
|
||||||
// We don't show/count internal globals as they are always
|
// We don't show/count internal globals as they are always
|
||||||
// contained in some other global user-visible container.
|
// contained in some other global user-visible container.
|
||||||
|
@ -270,7 +270,7 @@ void ProfileLogger::Log()
|
||||||
if ( size > 100 * 1024 )
|
if ( size > 100 * 1024 )
|
||||||
print = true;
|
print = true;
|
||||||
|
|
||||||
if ( v->GetType()->Tag() == TYPE_TABLE )
|
if ( v->GetType()->Tag() == zeek::TYPE_TABLE )
|
||||||
{
|
{
|
||||||
entries = v->AsTable()->Length();
|
entries = v->AsTable()->Length();
|
||||||
total_table_entries += entries;
|
total_table_entries += entries;
|
||||||
|
@ -339,7 +339,7 @@ void ProfileLogger::SegmentProfile(const char* name, const Location* loc,
|
||||||
|
|
||||||
SampleLogger::SampleLogger()
|
SampleLogger::SampleLogger()
|
||||||
{
|
{
|
||||||
static TableType* load_sample_info = nullptr;
|
static zeek::TableType* load_sample_info = nullptr;
|
||||||
|
|
||||||
if ( ! load_sample_info )
|
if ( ! load_sample_info )
|
||||||
load_sample_info = zeek::id::find_type("load_sample_info")->AsTableType();
|
load_sample_info = zeek::id::find_type("load_sample_info")->AsTableType();
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "zeek-config.h"
|
#include "zeek-config.h"
|
||||||
|
|
||||||
|
#include "Stmt.h"
|
||||||
|
|
||||||
#include "CompHash.h"
|
#include "CompHash.h"
|
||||||
#include "Expr.h"
|
#include "Expr.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
@ -9,7 +11,6 @@
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
#include "NetVar.h"
|
#include "NetVar.h"
|
||||||
#include "Stmt.h"
|
|
||||||
#include "Scope.h"
|
#include "Scope.h"
|
||||||
#include "Var.h"
|
#include "Var.h"
|
||||||
#include "Desc.h"
|
#include "Desc.h"
|
||||||
|
@ -34,6 +35,8 @@ const char* stmt_name(BroStmtTag t)
|
||||||
return stmt_names[int(t)];
|
return stmt_names[int(t)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
Stmt::Stmt(BroStmtTag arg_tag)
|
Stmt::Stmt(BroStmtTag arg_tag)
|
||||||
{
|
{
|
||||||
tag = arg_tag;
|
tag = arg_tag;
|
||||||
|
@ -1833,3 +1836,5 @@ TraversalCode WhenStmt::Traverse(TraversalCallback* cb) const
|
||||||
tc = cb->PostStmt(this);
|
tc = cb->PostStmt(this);
|
||||||
HANDLE_TC_STMT_POST(tc);
|
HANDLE_TC_STMT_POST(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
33
src/Stmt.h
33
src/Stmt.h
|
@ -13,12 +13,15 @@
|
||||||
|
|
||||||
#include "TraverseTypes.h"
|
#include "TraverseTypes.h"
|
||||||
|
|
||||||
class StmtList;
|
|
||||||
class CompositeHash;
|
class CompositeHash;
|
||||||
|
class Frame;
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
class StmtList;
|
||||||
|
class ForStmt;
|
||||||
class EventExpr;
|
class EventExpr;
|
||||||
class ListExpr;
|
class ListExpr;
|
||||||
class ForStmt;
|
|
||||||
class Frame;
|
|
||||||
|
|
||||||
class Stmt : public BroObj {
|
class Stmt : public BroObj {
|
||||||
public:
|
public:
|
||||||
|
@ -447,3 +450,27 @@ protected:
|
||||||
IntrusivePtr<Expr> timeout;
|
IntrusivePtr<Expr> timeout;
|
||||||
bool is_return;
|
bool is_return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using Stmt [[deprecated("Remove in v4.1. Use zeek::detail::Stmt instead.")]] = zeek::detail::Stmt;
|
||||||
|
using ExprListStmt [[deprecated("Remove in v4.1. Use zeek::detail::ExprListStmt instead.")]] = zeek::detail::ExprListStmt;
|
||||||
|
using PrintStmt [[deprecated("Remove in v4.1. Use zeek::detail::PrintStmt instead.")]] = zeek::detail::PrintStmt;
|
||||||
|
using ExprStmt [[deprecated("Remove in v4.1. Use zeek::detail::ExprStmt instead.")]] = zeek::detail::ExprStmt;
|
||||||
|
using IfStmt [[deprecated("Remove in v4.1. Use zeek::detail::IfStmt instead.")]] = zeek::detail::IfStmt;
|
||||||
|
using Case [[deprecated("Remove in v4.1. Use zeek::detail::Case instead.")]] = zeek::detail::Case;
|
||||||
|
using SwitchStmt [[deprecated("Remove in v4.1. Use zeek::detail::SwitchStmt instead.")]] = zeek::detail::SwitchStmt;
|
||||||
|
using AddStmt [[deprecated("Remove in v4.1. Use zeek::detail::AddStmt instead.")]] = zeek::detail::AddStmt;
|
||||||
|
using DelStmt [[deprecated("Remove in v4.1. Use zeek::detail::DelStmt instead.")]] = zeek::detail::DelStmt;
|
||||||
|
using EventStmt [[deprecated("Remove in v4.1. Use zeek::detail::EventStmt instead.")]] = zeek::detail::EventStmt;
|
||||||
|
using WhileStmt [[deprecated("Remove in v4.1. Use zeek::detail::WhileStmt instead.")]] = zeek::detail::WhileStmt;
|
||||||
|
using ForStmt [[deprecated("Remove in v4.1. Use zeek::detail::ForStmt instead.")]] = zeek::detail::ForStmt;
|
||||||
|
using NextStmt [[deprecated("Remove in v4.1. Use zeek::detail::NextStmt instead.")]] = zeek::detail::NextStmt;
|
||||||
|
using BreakStmt [[deprecated("Remove in v4.1. Use zeek::detail::BreakStmt instead.")]] = zeek::detail::BreakStmt;
|
||||||
|
using FallthroughStmt [[deprecated("Remove in v4.1. Use zeek::detail::FallthroughStmt instead.")]] = zeek::detail::FallthroughStmt;
|
||||||
|
using ReturnStmt [[deprecated("Remove in v4.1. Use zeek::detail::ReturnStmt instead.")]] = zeek::detail::ReturnStmt;
|
||||||
|
using StmtList [[deprecated("Remove in v4.1. Use zeek::detail::StmtList instead.")]] = zeek::detail::StmtList;
|
||||||
|
using EventBodyList [[deprecated("Remove in v4.1. Use zeek::detail::EventBodyList instead.")]] = zeek::detail::EventBodyList;
|
||||||
|
using InitStmt [[deprecated("Remove in v4.1. Use zeek::detail::InitStmt instead.")]] = zeek::detail::InitStmt;
|
||||||
|
using NullStmt [[deprecated("Remove in v4.1. Use zeek::detail::NullStmt instead.")]] = zeek::detail::NullStmt;
|
||||||
|
using WhenStmt [[deprecated("Remove in v4.1. Use zeek::detail::WhenStmt instead.")]] = zeek::detail::WhenStmt;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "Val.h"
|
#include "Val.h"
|
||||||
#include "IntrusivePtr.h"
|
#include "IntrusivePtr.h"
|
||||||
|
|
||||||
Tag::Tag(const IntrusivePtr<EnumType>& etype, type_t arg_type, subtype_t arg_subtype)
|
Tag::Tag(const IntrusivePtr<zeek::EnumType>& etype, type_t arg_type, subtype_t arg_subtype)
|
||||||
{
|
{
|
||||||
assert(arg_type > 0);
|
assert(arg_type > 0);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ Tag::Tag(const IntrusivePtr<EnumType>& etype, type_t arg_type, subtype_t arg_sub
|
||||||
val = etype->GetVal(i);
|
val = etype->GetVal(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag::Tag(EnumType* etype, type_t arg_type, subtype_t arg_subtype)
|
Tag::Tag(zeek::EnumType* etype, type_t arg_type, subtype_t arg_subtype)
|
||||||
: Tag({NewRef{}, etype}, arg_type, arg_subtype)
|
: Tag({NewRef{}, etype}, arg_type, arg_subtype)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ Tag& Tag::operator=(const Tag&& other) noexcept
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<EnumVal>& Tag::AsVal(const IntrusivePtr<EnumType>& etype) const
|
const IntrusivePtr<EnumVal>& Tag::AsVal(const IntrusivePtr<zeek::EnumType>& etype) const
|
||||||
{
|
{
|
||||||
if ( ! val )
|
if ( ! val )
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ const IntrusivePtr<EnumVal>& Tag::AsVal(const IntrusivePtr<EnumType>& etype) con
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumVal* Tag::AsEnumVal(EnumType* etype) const
|
EnumVal* Tag::AsEnumVal(zeek::EnumType* etype) const
|
||||||
{
|
{
|
||||||
return AsVal({NewRef{}, etype}).get();
|
return AsVal({NewRef{}, etype}).get();
|
||||||
}
|
}
|
||||||
|
|
17
src/Tag.h
17
src/Tag.h
|
@ -3,14 +3,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "zeek-config.h"
|
#include "zeek-config.h"
|
||||||
#include "IntrusivePtr.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "IntrusivePtr.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class EnumVal;
|
class EnumVal;
|
||||||
class EnumType;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(EnumType, zeek);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to identify an analyzer type.
|
* Class to identify an analyzer type.
|
||||||
|
@ -115,10 +116,10 @@ protected:
|
||||||
*
|
*
|
||||||
* @param etype the script-layer enum type associated with the tag.
|
* @param etype the script-layer enum type associated with the tag.
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<EnumVal>& AsVal(const IntrusivePtr<EnumType>& etype) const;
|
const IntrusivePtr<EnumVal>& AsVal(const IntrusivePtr<zeek::EnumType>& etype) const;
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use AsVal() instead.")]]
|
[[deprecated("Remove in v4.1. Use AsVal() instead.")]]
|
||||||
EnumVal* AsEnumVal(EnumType* etype) const;
|
EnumVal* AsEnumVal(zeek::EnumType* etype) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -131,10 +132,10 @@ protected:
|
||||||
* @param subtype The sub type, which is left to an analyzer for
|
* @param subtype The sub type, which is left to an analyzer for
|
||||||
* interpretation. By default it's set to zero.
|
* interpretation. By default it's set to zero.
|
||||||
*/
|
*/
|
||||||
Tag(const IntrusivePtr<EnumType>& etype, type_t type, subtype_t subtype = 0);
|
Tag(const IntrusivePtr<zeek::EnumType>& etype, type_t type, subtype_t subtype = 0);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr& instead.")]]
|
[[deprecated("Remove in v4.1. Construct from IntrusivePtr& instead.")]]
|
||||||
Tag(EnumType* etype, type_t type, subtype_t subtype = 0);
|
Tag(zeek::EnumType* etype, type_t type, subtype_t subtype = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
class Func;
|
class Func;
|
||||||
class Scope;
|
class Scope;
|
||||||
class Stmt;
|
|
||||||
class Expr;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
class ID;
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
class TraversalCallback {
|
class TraversalCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -18,20 +19,20 @@ public:
|
||||||
virtual TraversalCode PreFunction(const Func*) { return TC_CONTINUE; }
|
virtual TraversalCode PreFunction(const Func*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostFunction(const Func*) { return TC_CONTINUE; }
|
virtual TraversalCode PostFunction(const Func*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreStmt(const Stmt*) { return TC_CONTINUE; }
|
virtual TraversalCode PreStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostStmt(const Stmt*) { return TC_CONTINUE; }
|
virtual TraversalCode PostStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreExpr(const Expr*) { return TC_CONTINUE; }
|
virtual TraversalCode PreExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostExpr(const Expr*) { return TC_CONTINUE; }
|
virtual TraversalCode PostExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreID(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreID(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostID(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostID(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreTypedef(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreTypedef(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostTypedef(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostTypedef(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreDecl(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreDecl(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostDecl(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostDecl(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
Scope* current_scope;
|
Scope* current_scope;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
#include "DebugLogger.h"
|
#include "DebugLogger.h"
|
||||||
#include "iosource/Manager.h"
|
#include "iosource/Manager.h"
|
||||||
|
|
||||||
using namespace trigger;
|
using namespace zeek::detail;
|
||||||
|
using namespace zeek::detail::trigger;
|
||||||
|
|
||||||
// Callback class to traverse an expression, registering all relevant IDs and
|
// Callback class to traverse an expression, registering all relevant IDs and
|
||||||
// Vals for change notifications.
|
// Vals for change notifications.
|
||||||
|
|
||||||
namespace trigger {
|
namespace zeek::detail::trigger {
|
||||||
|
|
||||||
class TriggerTraversalCallback : public TraversalCallback {
|
class TriggerTraversalCallback : public TraversalCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -30,15 +31,13 @@ public:
|
||||||
~TriggerTraversalCallback()
|
~TriggerTraversalCallback()
|
||||||
{ Unref(trigger); }
|
{ Unref(trigger); }
|
||||||
|
|
||||||
virtual TraversalCode PreExpr(const Expr*);
|
virtual TraversalCode PreExpr(const zeek::detail::Expr*) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Trigger* trigger;
|
Trigger* trigger;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
TraversalCode zeek::detail::trigger::TriggerTraversalCallback::PreExpr(const zeek::detail::Expr* expr)
|
||||||
|
|
||||||
TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
|
||||||
{
|
{
|
||||||
// We catch all expressions here which in some way reference global
|
// We catch all expressions here which in some way reference global
|
||||||
// state.
|
// state.
|
||||||
|
@ -46,7 +45,7 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
||||||
switch ( expr->Tag() ) {
|
switch ( expr->Tag() ) {
|
||||||
case EXPR_NAME:
|
case EXPR_NAME:
|
||||||
{
|
{
|
||||||
const NameExpr* e = static_cast<const NameExpr*>(expr);
|
const auto* e = static_cast<const zeek::detail::NameExpr*>(expr);
|
||||||
if ( e->Id()->IsGlobal() )
|
if ( e->Id()->IsGlobal() )
|
||||||
trigger->Register(e->Id());
|
trigger->Register(e->Id());
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
||||||
|
|
||||||
case EXPR_INDEX:
|
case EXPR_INDEX:
|
||||||
{
|
{
|
||||||
const IndexExpr* e = static_cast<const IndexExpr*>(expr);
|
const auto* e = static_cast<const zeek::detail::IndexExpr*>(expr);
|
||||||
BroObj::SuppressErrors no_errors;
|
BroObj::SuppressErrors no_errors;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -83,8 +82,6 @@ TraversalCode TriggerTraversalCallback::PreExpr(const Expr* expr)
|
||||||
return TC_CONTINUE;
|
return TC_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace trigger {
|
|
||||||
|
|
||||||
class TriggerTimer final : public Timer {
|
class TriggerTimer final : public Timer {
|
||||||
public:
|
public:
|
||||||
TriggerTimer(double arg_timeout, Trigger* arg_trigger)
|
TriggerTimer(double arg_timeout, Trigger* arg_trigger)
|
||||||
|
@ -120,10 +117,9 @@ protected:
|
||||||
double time;
|
double time;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
Trigger::Trigger(zeek::detail::Expr* arg_cond, zeek::detail::Stmt* arg_body,
|
||||||
|
zeek::detail::Stmt* arg_timeout_stmts,
|
||||||
Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts,
|
zeek::detail::Expr* arg_timeout, Frame* arg_frame,
|
||||||
Expr* arg_timeout, Frame* arg_frame,
|
|
||||||
bool arg_is_return, const Location* arg_location)
|
bool arg_is_return, const Location* arg_location)
|
||||||
{
|
{
|
||||||
cond = arg_cond;
|
cond = arg_cond;
|
||||||
|
@ -389,7 +385,7 @@ void Trigger::Timeout()
|
||||||
Unref(this);
|
Unref(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::Register(ID* id)
|
void Trigger::Register(zeek::detail::ID* id)
|
||||||
{
|
{
|
||||||
assert(! disabled);
|
assert(! disabled);
|
||||||
notifier::registry.Register(id, this);
|
notifier::registry.Register(id, this);
|
||||||
|
@ -440,7 +436,7 @@ void Trigger::Attach(Trigger *trigger)
|
||||||
Hold();
|
Hold();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trigger::Cache(const CallExpr* expr, Val* v)
|
bool Trigger::Cache(const zeek::detail::CallExpr* expr, Val* v)
|
||||||
{
|
{
|
||||||
if ( disabled || ! v )
|
if ( disabled || ! v )
|
||||||
return false;
|
return false;
|
||||||
|
@ -463,7 +459,7 @@ bool Trigger::Cache(const CallExpr* expr, Val* v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Val* Trigger::Lookup(const CallExpr* expr)
|
Val* Trigger::Lookup(const zeek::detail::CallExpr* expr)
|
||||||
{
|
{
|
||||||
assert(! disabled);
|
assert(! disabled);
|
||||||
|
|
||||||
|
@ -553,3 +549,5 @@ void Manager::GetStats(Stats* stats)
|
||||||
stats->total = total_triggers;
|
stats->total = total_triggers;
|
||||||
stats->pending = pending->size();
|
stats->pending = pending->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Obj.h"
|
|
||||||
#include "Notifier.h"
|
|
||||||
#include "iosource/IOSource.h"
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class CallExpr;
|
#include "Obj.h"
|
||||||
class Expr;
|
#include "Notifier.h"
|
||||||
class Stmt;
|
#include "iosource/IOSource.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class Frame;
|
class Frame;
|
||||||
class Val;
|
class Val;
|
||||||
class ID;
|
|
||||||
class ODesc;
|
class ODesc;
|
||||||
|
|
||||||
namespace trigger {
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
|
namespace zeek::detail::trigger {
|
||||||
|
|
||||||
// Triggers are the heart of "when" statements: expressions that when
|
// Triggers are the heart of "when" statements: expressions that when
|
||||||
// they become true execute a body of statements.
|
// they become true execute a body of statements.
|
||||||
|
|
||||||
|
@ -29,7 +32,7 @@ public:
|
||||||
// instantiation. Note that if the condition is already true, the
|
// instantiation. Note that if the condition is already true, the
|
||||||
// statements are executed immediately and the object is deleted
|
// statements are executed immediately and the object is deleted
|
||||||
// right away.
|
// right away.
|
||||||
Trigger(Expr* cond, Stmt* body, Stmt* timeout_stmts, Expr* timeout,
|
Trigger(zeek::detail::Expr* cond, zeek::detail::Stmt* body, zeek::detail::Stmt* timeout_stmts, zeek::detail::Expr* timeout,
|
||||||
Frame* f, bool is_return, const Location* loc);
|
Frame* f, bool is_return, const Location* loc);
|
||||||
~Trigger() override;
|
~Trigger() override;
|
||||||
|
|
||||||
|
@ -60,8 +63,8 @@ public:
|
||||||
// Cache for return values of delayed function calls. Returns whether
|
// Cache for return values of delayed function calls. Returns whether
|
||||||
// the trigger is queued for later evaluation -- it may not be queued
|
// the trigger is queued for later evaluation -- it may not be queued
|
||||||
// if the Val is null or it's disabled.
|
// if the Val is null or it's disabled.
|
||||||
bool Cache(const CallExpr* expr, Val* val);
|
bool Cache(const zeek::detail::CallExpr* expr, Val* val);
|
||||||
Val* Lookup(const CallExpr*);
|
Val* Lookup(const zeek::detail::CallExpr*);
|
||||||
|
|
||||||
// Disable this trigger completely. Needed because Unref'ing the trigger
|
// Disable this trigger completely. Needed because Unref'ing the trigger
|
||||||
// may not immediately delete it as other references may still exist.
|
// may not immediately delete it as other references may still exist.
|
||||||
|
@ -87,14 +90,14 @@ private:
|
||||||
friend class TriggerTimer;
|
friend class TriggerTimer;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Register(ID* id);
|
void Register(zeek::detail::ID* id);
|
||||||
void Register(Val* val);
|
void Register(Val* val);
|
||||||
void UnregisterAll();
|
void UnregisterAll();
|
||||||
|
|
||||||
Expr* cond;
|
zeek::detail::Expr* cond;
|
||||||
Stmt* body;
|
zeek::detail::Stmt* body;
|
||||||
Stmt* timeout_stmts;
|
zeek::detail::Stmt* timeout_stmts;
|
||||||
Expr* timeout;
|
zeek::detail::Expr* timeout;
|
||||||
double timeout_value;
|
double timeout_value;
|
||||||
Frame* frame;
|
Frame* frame;
|
||||||
bool is_return;
|
bool is_return;
|
||||||
|
@ -108,7 +111,7 @@ private:
|
||||||
|
|
||||||
std::vector<std::pair<BroObj *, notifier::Modifiable*>> objs;
|
std::vector<std::pair<BroObj *, notifier::Modifiable*>> objs;
|
||||||
|
|
||||||
using ValCache = std::map<const CallExpr*, Val*>;
|
using ValCache = std::map<const zeek::detail::CallExpr*, Val*>;
|
||||||
ValCache cache;
|
ValCache cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,4 +143,9 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern trigger::Manager* trigger_mgr;
|
namespace trigger {
|
||||||
|
using Trigger [[deprecated("Remove in v4.1. Use zeek::detail::trigger::Trigger instead")]] = zeek::detail::trigger::Trigger;
|
||||||
|
using Manager [[deprecated("Remove in v4.1. Use zeek::detail::trigger::Manager instead")]] = zeek::detail::trigger::Manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern zeek::detail::trigger::Manager* trigger_mgr;
|
||||||
|
|
|
@ -3,14 +3,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "zeek-config.h"
|
#include "zeek-config.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "IntrusivePtr.h"
|
#include "IntrusivePtr.h"
|
||||||
#include "NetVar.h"
|
#include "NetVar.h"
|
||||||
#include "IPAddr.h"
|
#include "IPAddr.h"
|
||||||
#include "ID.h"
|
#include "ID.h"
|
||||||
#include "UID.h"
|
#include "UID.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class Connection;
|
class Connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +199,7 @@ public:
|
||||||
IntrusivePtr<VectorVal> ToVal() const
|
IntrusivePtr<VectorVal> ToVal() const
|
||||||
{
|
{
|
||||||
auto vv = make_intrusive<VectorVal>(
|
auto vv = make_intrusive<VectorVal>(
|
||||||
zeek::id::find_type<VectorType>("EncapsulatingConnVector"));
|
zeek::id::find_type<zeek::VectorType>("EncapsulatingConnVector"));
|
||||||
|
|
||||||
if ( conns )
|
if ( conns )
|
||||||
{
|
{
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue