mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/dnthayer/broker-namespace'
* origin/topic/dnthayer/broker-namespace: Split the broker main.bro into two scripts Rename the BrokerStore namespace to Broker Rename the BrokerComm namespace to Broker BIT-1563 #merged
This commit is contained in:
commit
e7ec537ed5
97 changed files with 1240 additions and 1220 deletions
7
CHANGES
7
CHANGES
|
@ -1,4 +1,11 @@
|
|||
|
||||
2.4-466 | 2016-04-22 16:25:33 -0700
|
||||
|
||||
* Rename BrokerStore and BrokerComm to Broker. Also split broker main.bro
|
||||
into two scripts. (Daniel Thayer)
|
||||
|
||||
* Add get_current_packet_header bif. (Jan Grashoefer)
|
||||
|
||||
2.4-457 | 2016-04-22 08:36:27 -0700
|
||||
|
||||
* Fix Intel framework not checking the CERT_HASH indicator type. (Johanna Amann)
|
||||
|
|
5
NEWS
5
NEWS
|
@ -45,6 +45,9 @@ New Functionality
|
|||
argument that will be used for decoding errors into weird.log
|
||||
(instead of reporter.log).
|
||||
|
||||
- A new get_current_packet_header bif returning the headers of the current
|
||||
packet
|
||||
|
||||
- Two new built-in functions for handling set[subnet] and table[subnet]:
|
||||
|
||||
- check_subnet(subnet, table) checks if a specific subnet is a member
|
||||
|
@ -84,6 +87,8 @@ New Functionality
|
|||
Changed Functionality
|
||||
---------------------
|
||||
|
||||
- The BrokerComm and BrokerStore namespaces were renamed to Broker
|
||||
|
||||
- ``SSH::skip_processing_after_detection`` was removed. The functionality was
|
||||
replaced by ``SSH::disable_analyzer_after_detection``.
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.4-457
|
||||
2.4-466
|
||||
|
|
|
@ -17,20 +17,20 @@ Connecting to Peers
|
|||
===================
|
||||
|
||||
Communication via Broker must first be turned on via
|
||||
:bro:see:`BrokerComm::enable`.
|
||||
:bro:see:`Broker::enable`.
|
||||
|
||||
Bro can accept incoming connections by calling :bro:see:`BrokerComm::listen`
|
||||
Bro can accept incoming connections by calling :bro:see:`Broker::listen`
|
||||
and then monitor connection status updates via the
|
||||
:bro:see:`BrokerComm::incoming_connection_established` and
|
||||
:bro:see:`BrokerComm::incoming_connection_broken` events.
|
||||
:bro:see:`Broker::incoming_connection_established` and
|
||||
:bro:see:`Broker::incoming_connection_broken` events.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/connecting-listener.bro
|
||||
|
||||
Bro can initiate outgoing connections by calling :bro:see:`BrokerComm::connect`
|
||||
Bro can initiate outgoing connections by calling :bro:see:`Broker::connect`
|
||||
and then monitor connection status updates via the
|
||||
:bro:see:`BrokerComm::outgoing_connection_established`,
|
||||
:bro:see:`BrokerComm::outgoing_connection_broken`, and
|
||||
:bro:see:`BrokerComm::outgoing_connection_incompatible` events.
|
||||
:bro:see:`Broker::outgoing_connection_established`,
|
||||
:bro:see:`Broker::outgoing_connection_broken`, and
|
||||
:bro:see:`Broker::outgoing_connection_incompatible` events.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/connecting-connector.bro
|
||||
|
||||
|
@ -38,14 +38,14 @@ Remote Printing
|
|||
===============
|
||||
|
||||
To receive remote print messages, first use the
|
||||
:bro:see:`BrokerComm::subscribe_to_prints` function to advertise to peers a
|
||||
:bro:see:`Broker::subscribe_to_prints` function to advertise to peers a
|
||||
topic prefix of interest and then create an event handler for
|
||||
:bro:see:`BrokerComm::print_handler` to handle any print messages that are
|
||||
:bro:see:`Broker::print_handler` to handle any print messages that are
|
||||
received.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/printing-listener.bro
|
||||
|
||||
To send remote print messages, just call :bro:see:`BrokerComm::print`.
|
||||
To send remote print messages, just call :bro:see:`Broker::print`.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/printing-connector.bro
|
||||
|
||||
|
@ -69,14 +69,14 @@ Remote Events
|
|||
=============
|
||||
|
||||
Receiving remote events is similar to remote prints. Just use the
|
||||
:bro:see:`BrokerComm::subscribe_to_events` function and possibly define any
|
||||
:bro:see:`Broker::subscribe_to_events` function and possibly define any
|
||||
new events along with handlers that peers may want to send.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/events-listener.bro
|
||||
|
||||
There are two different ways to send events. The first is to call the
|
||||
:bro:see:`BrokerComm::event` function directly. The second option is to call
|
||||
the :bro:see:`BrokerComm::auto_event` function where you specify a
|
||||
:bro:see:`Broker::event` function directly. The second option is to call
|
||||
the :bro:see:`Broker::auto_event` function where you specify a
|
||||
particular event that will be automatically sent to peers whenever the
|
||||
event is called locally via the normal event invocation syntax.
|
||||
|
||||
|
@ -104,14 +104,14 @@ Remote Logging
|
|||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/testlog.bro
|
||||
|
||||
Use the :bro:see:`BrokerComm::subscribe_to_logs` function to advertise interest
|
||||
Use the :bro:see:`Broker::subscribe_to_logs` function to advertise interest
|
||||
in logs written by peers. The topic names that Bro uses are implicitly of the
|
||||
form "bro/log/<stream-name>".
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/logs-listener.bro
|
||||
|
||||
To send remote logs either redef :bro:see:`Log::enable_remote_logging` or
|
||||
use the :bro:see:`BrokerComm::enable_remote_logs` function. The former
|
||||
use the :bro:see:`Broker::enable_remote_logs` function. The former
|
||||
allows any log stream to be sent to peers while the latter enables remote
|
||||
logging for particular streams.
|
||||
|
||||
|
@ -137,24 +137,24 @@ Tuning Access Control
|
|||
By default, endpoints do not restrict the message topics that it sends
|
||||
to peers and do not restrict what message topics and data store
|
||||
identifiers get advertised to peers. These are the default
|
||||
:bro:see:`BrokerComm::EndpointFlags` supplied to :bro:see:`BrokerComm::enable`.
|
||||
:bro:see:`Broker::EndpointFlags` supplied to :bro:see:`Broker::enable`.
|
||||
|
||||
If not using the ``auto_publish`` flag, one can use the
|
||||
:bro:see:`BrokerComm::publish_topic` and :bro:see:`BrokerComm::unpublish_topic`
|
||||
:bro:see:`Broker::publish_topic` and :bro:see:`Broker::unpublish_topic`
|
||||
functions to manipulate the set of message topics (must match exactly)
|
||||
that are allowed to be sent to peer endpoints. These settings take
|
||||
precedence over the per-message ``peers`` flag supplied to functions
|
||||
that take a :bro:see:`BrokerComm::SendFlags` such as :bro:see:`BrokerComm::print`,
|
||||
:bro:see:`BrokerComm::event`, :bro:see:`BrokerComm::auto_event` or
|
||||
:bro:see:`BrokerComm::enable_remote_logs`.
|
||||
that take a :bro:see:`Broker::SendFlags` such as :bro:see:`Broker::print`,
|
||||
:bro:see:`Broker::event`, :bro:see:`Broker::auto_event` or
|
||||
:bro:see:`Broker::enable_remote_logs`.
|
||||
|
||||
If not using the ``auto_advertise`` flag, one can use the
|
||||
:bro:see:`BrokerComm::advertise_topic` and
|
||||
:bro:see:`BrokerComm::unadvertise_topic` functions
|
||||
:bro:see:`Broker::advertise_topic` and
|
||||
:bro:see:`Broker::unadvertise_topic` functions
|
||||
to manipulate the set of topic prefixes that are allowed to be
|
||||
advertised to peers. If an endpoint does not advertise a topic prefix, then
|
||||
the only way peers can send messages to it is via the ``unsolicited``
|
||||
flag of :bro:see:`BrokerComm::SendFlags` and choosing a topic with a matching
|
||||
flag of :bro:see:`Broker::SendFlags` and choosing a topic with a matching
|
||||
prefix (i.e. full topic may be longer than receivers prefix, just the
|
||||
prefix needs to match).
|
||||
|
||||
|
@ -192,8 +192,8 @@ last modification time.
|
|||
.. btest-include:: ${DOC_ROOT}/frameworks/broker/stores-connector.bro
|
||||
|
||||
In the above example, if a local copy of the store contents isn't
|
||||
needed, just replace the :bro:see:`BrokerStore::create_clone` call with
|
||||
:bro:see:`BrokerStore::create_frontend`. Queries will then be made against
|
||||
needed, just replace the :bro:see:`Broker::create_clone` call with
|
||||
:bro:see:`Broker::create_frontend`. Queries will then be made against
|
||||
the remote master store instead of the local clone.
|
||||
|
||||
Note that all data store queries must be made within Bro's asynchronous
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
event Broker::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;
|
||||
print "Broker::incoming_connection_broken", peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "hi", 0));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "hi", 0));
|
||||
event my_auto_event("stuff", 88);
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "...", 1));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "...", 1));
|
||||
event my_auto_event("more stuff", 51);
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "bye", 2));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "bye", 2));
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event my_event(msg: string, c: count)
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
redef Log::enable_local_logging = F;
|
||||
redef Log::enable_remote_logging = F;
|
||||
global n = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::enable_remote_logs(Test::LOG);
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event do_write()
|
||||
|
@ -24,16 +24,16 @@ event do_write()
|
|||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_logs("bro/log/Test::LOG");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
BrokerComm::print("bro/print/hi", "hello");
|
||||
BrokerComm::print("bro/print/stuff", "...");
|
||||
BrokerComm::print("bro/print/bye", "goodbye");
|
||||
Broker::print("bro/print/hi", "hello");
|
||||
Broker::print("bro/print/stuff", "...");
|
||||
Broker::print("bro/print/bye", "goodbye");
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_prints("bro/print/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++msg_count;
|
||||
print "got print message", msg;
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
@ -47,7 +47,7 @@ event BrokerComm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -21,15 +21,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 0)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 1)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 2)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 3)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 1)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 2)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 3)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -37,7 +37,7 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/ready");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test, $path="test"]);
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
@load ./main
|
||||
@load ./store
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
##! Various data structure definitions for use with Bro's communication system.
|
||||
|
||||
module BrokerComm;
|
||||
module Broker;
|
||||
|
||||
export {
|
||||
|
||||
## A name used to identify this endpoint to peers.
|
||||
## .. bro:see:: BrokerComm::connect BrokerComm::listen
|
||||
## .. bro:see:: Broker::connect Broker::listen
|
||||
const endpoint_name = "" &redef;
|
||||
|
||||
## Change communication behavior.
|
||||
|
@ -32,11 +32,11 @@ export {
|
|||
|
||||
## Opaque communication data.
|
||||
type Data: record {
|
||||
d: opaque of BrokerComm::Data &optional;
|
||||
d: opaque of Broker::Data &optional;
|
||||
};
|
||||
|
||||
## Opaque communication data.
|
||||
type DataVector: vector of BrokerComm::Data;
|
||||
type DataVector: vector of Broker::Data;
|
||||
|
||||
## Opaque event communication data.
|
||||
type EventArgs: record {
|
||||
|
@ -49,55 +49,7 @@ export {
|
|||
## Opaque communication data used as a convenient way to wrap key-value
|
||||
## pairs that comprise table entries.
|
||||
type TableItem : record {
|
||||
key: BrokerComm::Data;
|
||||
val: BrokerComm::Data;
|
||||
};
|
||||
}
|
||||
|
||||
module BrokerStore;
|
||||
|
||||
export {
|
||||
|
||||
## Whether a data store query could be completed or not.
|
||||
type QueryStatus: enum {
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
};
|
||||
|
||||
## An expiry time for a key-value pair inserted in to a data store.
|
||||
type ExpiryTime: record {
|
||||
## Absolute point in time at which to expire the entry.
|
||||
absolute: time &optional;
|
||||
## A point in time relative to the last modification time at which
|
||||
## to expire the entry. New modifications will delay the expiration.
|
||||
since_last_modification: interval &optional;
|
||||
};
|
||||
|
||||
## The result of a data store query.
|
||||
type QueryResult: record {
|
||||
## Whether the query completed or not.
|
||||
status: BrokerStore::QueryStatus;
|
||||
## The result of the query. Certain queries may use a particular
|
||||
## data type (e.g. querying store size always returns a count, but
|
||||
## a lookup may return various data types).
|
||||
result: BrokerComm::Data;
|
||||
};
|
||||
|
||||
## Options to tune the SQLite storage backend.
|
||||
type SQLiteOptions: record {
|
||||
## File system path of the database.
|
||||
path: string &default = "store.sqlite";
|
||||
};
|
||||
|
||||
## Options to tune the RocksDB storage backend.
|
||||
type RocksDBOptions: record {
|
||||
## File system path of the database.
|
||||
path: string &default = "store.rocksdb";
|
||||
};
|
||||
|
||||
## Options to tune the particular storage backends.
|
||||
type BackendOptions: record {
|
||||
sqlite: SQLiteOptions &default = SQLiteOptions();
|
||||
rocksdb: RocksDBOptions &default = RocksDBOptions();
|
||||
key: Broker::Data;
|
||||
val: Broker::Data;
|
||||
};
|
||||
}
|
||||
|
|
51
scripts/base/frameworks/broker/store.bro
Normal file
51
scripts/base/frameworks/broker/store.bro
Normal file
|
@ -0,0 +1,51 @@
|
|||
##! Various data structure definitions for use with Bro's communication system.
|
||||
|
||||
@load ./main
|
||||
|
||||
module Broker;
|
||||
|
||||
export {
|
||||
|
||||
## Whether a data store query could be completed or not.
|
||||
type QueryStatus: enum {
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
};
|
||||
|
||||
## An expiry time for a key-value pair inserted in to a data store.
|
||||
type ExpiryTime: record {
|
||||
## Absolute point in time at which to expire the entry.
|
||||
absolute: time &optional;
|
||||
## A point in time relative to the last modification time at which
|
||||
## to expire the entry. New modifications will delay the expiration.
|
||||
since_last_modification: interval &optional;
|
||||
};
|
||||
|
||||
## The result of a data store query.
|
||||
type QueryResult: record {
|
||||
## Whether the query completed or not.
|
||||
status: Broker::QueryStatus;
|
||||
## The result of the query. Certain queries may use a particular
|
||||
## data type (e.g. querying store size always returns a count, but
|
||||
## a lookup may return various data types).
|
||||
result: Broker::Data;
|
||||
};
|
||||
|
||||
## Options to tune the SQLite storage backend.
|
||||
type SQLiteOptions: record {
|
||||
## File system path of the database.
|
||||
path: string &default = "store.sqlite";
|
||||
};
|
||||
|
||||
## Options to tune the RocksDB storage backend.
|
||||
type RocksDBOptions: record {
|
||||
## File system path of the database.
|
||||
path: string &default = "store.rocksdb";
|
||||
};
|
||||
|
||||
## Options to tune the particular storage backends.
|
||||
type BackendOptions: record {
|
||||
sqlite: SQLiteOptions &default = SQLiteOptions();
|
||||
rocksdb: RocksDBOptions &default = RocksDBOptions();
|
||||
};
|
||||
}
|
|
@ -227,7 +227,7 @@ function acld_add_rule_fun(p: PluginState, r: Rule) : bool
|
|||
if ( ar$command == "" )
|
||||
return F;
|
||||
|
||||
BrokerComm::event(p$acld_config$acld_topic, BrokerComm::event_args(acld_add_rule, p$acld_id, r, ar));
|
||||
Broker::event(p$acld_config$acld_topic, Broker::event_args(acld_add_rule, p$acld_id, r, ar));
|
||||
return T;
|
||||
}
|
||||
|
||||
|
@ -242,18 +242,18 @@ function acld_remove_rule_fun(p: PluginState, r: Rule) : bool
|
|||
else
|
||||
return F;
|
||||
|
||||
BrokerComm::event(p$acld_config$acld_topic, BrokerComm::event_args(acld_remove_rule, p$acld_id, r, ar));
|
||||
Broker::event(p$acld_config$acld_topic, Broker::event_args(acld_remove_rule, p$acld_id, r, ar));
|
||||
return T;
|
||||
}
|
||||
|
||||
function acld_init(p: PluginState)
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect(cat(p$acld_config$acld_host), p$acld_config$acld_port, 1sec);
|
||||
BrokerComm::subscribe_to_events(p$acld_config$acld_topic);
|
||||
Broker::enable();
|
||||
Broker::connect(cat(p$acld_config$acld_host), p$acld_config$acld_port, 1sec);
|
||||
Broker::subscribe_to_events(p$acld_config$acld_topic);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string, peer_port: port, peer_name: string)
|
||||
event Broker::outgoing_connection_established(peer_address: string, peer_port: port, peer_name: string)
|
||||
{
|
||||
if ( [peer_port, peer_address] !in netcontrol_acld_peers )
|
||||
# ok, this one was none of ours...
|
||||
|
|
|
@ -96,24 +96,24 @@ function broker_name(p: PluginState) : string
|
|||
|
||||
function broker_add_rule_fun(p: PluginState, r: Rule) : bool
|
||||
{
|
||||
BrokerComm::event(p$broker_topic, BrokerComm::event_args(broker_add_rule, p$broker_id, r));
|
||||
Broker::event(p$broker_topic, Broker::event_args(broker_add_rule, p$broker_id, r));
|
||||
return T;
|
||||
}
|
||||
|
||||
function broker_remove_rule_fun(p: PluginState, r: Rule) : bool
|
||||
{
|
||||
BrokerComm::event(p$broker_topic, BrokerComm::event_args(broker_remove_rule, p$broker_id, r));
|
||||
Broker::event(p$broker_topic, Broker::event_args(broker_remove_rule, p$broker_id, r));
|
||||
return T;
|
||||
}
|
||||
|
||||
function broker_init(p: PluginState)
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect(cat(p$broker_host), p$broker_port, 1sec);
|
||||
BrokerComm::subscribe_to_events(p$broker_topic);
|
||||
Broker::enable();
|
||||
Broker::connect(cat(p$broker_host), p$broker_port, 1sec);
|
||||
Broker::subscribe_to_events(p$broker_topic);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string, peer_port: port, peer_name: string)
|
||||
event Broker::outgoing_connection_established(peer_address: string, peer_port: port, peer_name: string)
|
||||
{
|
||||
if ( [peer_port, peer_address] !in netcontrol_broker_peers )
|
||||
return;
|
||||
|
|
|
@ -47,26 +47,26 @@ function broker_describe(state: ControllerState): string
|
|||
|
||||
function broker_flow_mod_fun(state: ControllerState, match: ofp_match, flow_mod: OpenFlow::ofp_flow_mod): bool
|
||||
{
|
||||
BrokerComm::event(state$broker_topic, BrokerComm::event_args(broker_flow_mod, state$_name, state$broker_dpid, match, flow_mod));
|
||||
Broker::event(state$broker_topic, Broker::event_args(broker_flow_mod, state$_name, state$broker_dpid, match, flow_mod));
|
||||
|
||||
return T;
|
||||
}
|
||||
|
||||
function broker_flow_clear_fun(state: OpenFlow::ControllerState): bool
|
||||
{
|
||||
BrokerComm::event(state$broker_topic, BrokerComm::event_args(broker_flow_clear, state$_name, state$broker_dpid));
|
||||
Broker::event(state$broker_topic, Broker::event_args(broker_flow_clear, state$_name, state$broker_dpid));
|
||||
|
||||
return T;
|
||||
}
|
||||
|
||||
function broker_init(state: OpenFlow::ControllerState)
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect(cat(state$broker_host), state$broker_port, 1sec);
|
||||
BrokerComm::subscribe_to_events(state$broker_topic); # openflow success and failure events are directly sent back via the other plugin via broker.
|
||||
Broker::enable();
|
||||
Broker::connect(cat(state$broker_host), state$broker_port, 1sec);
|
||||
Broker::subscribe_to_events(state$broker_topic); # openflow success and failure events are directly sent back via the other plugin via broker.
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string, peer_port: port, peer_name: string)
|
||||
event Broker::outgoing_connection_established(peer_address: string, peer_port: port, peer_name: string)
|
||||
{
|
||||
if ( [peer_port, peer_address] !in broker_peers )
|
||||
# ok, this one was none of ours...
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
@load base/frameworks/reporter
|
||||
@load base/frameworks/sumstats
|
||||
@load base/frameworks/tunnels
|
||||
@ifdef ( BrokerComm::enable )
|
||||
@ifdef ( Broker::enable )
|
||||
@load base/frameworks/openflow
|
||||
@load base/frameworks/netcontrol
|
||||
@endif
|
||||
|
|
|
@ -539,7 +539,7 @@ broker::util::optional<broker::data> bro_broker::val_to_data(Val* v)
|
|||
return {rval};
|
||||
}
|
||||
default:
|
||||
reporter->Error("unsupported BrokerComm::Data type: %s",
|
||||
reporter->Error("unsupported Broker::Data type: %s",
|
||||
type_name(v->Type()->Tag()));
|
||||
break;
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ broker::util::optional<broker::data> bro_broker::val_to_data(Val* v)
|
|||
|
||||
RecordVal* bro_broker::make_data_val(Val* v)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
auto data = val_to_data(v);
|
||||
|
||||
if ( data )
|
||||
|
@ -560,7 +560,7 @@ RecordVal* bro_broker::make_data_val(Val* v)
|
|||
|
||||
RecordVal* bro_broker::make_data_val(broker::data d)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
rval->Assign(0, new DataVal(move(d)));
|
||||
return rval;
|
||||
}
|
||||
|
@ -570,92 +570,92 @@ struct data_type_getter {
|
|||
|
||||
result_type operator()(bool a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::BOOL,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::BOOL,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(uint64_t a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::COUNT,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::COUNT,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(int64_t a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::INT,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::INT,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(double a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::DOUBLE,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::DOUBLE,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const std::string& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::STRING,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::STRING,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::address& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::ADDR,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::ADDR,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::subnet& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::SUBNET,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::SUBNET,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::port& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::PORT,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::PORT,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::time_point& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::TIME,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::TIME,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::time_duration& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::INTERVAL,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::INTERVAL,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::enum_value& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::ENUM,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::ENUM,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::set& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::SET,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::SET,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::table& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::TABLE,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::TABLE,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::vector& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::VECTOR,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::VECTOR,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::record& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::BrokerComm::RECORD,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
return new EnumVal(BifEnum::Broker::RECORD,
|
||||
BifType::Enum::Broker::DataType);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -670,7 +670,7 @@ broker::data& bro_broker::opaque_field_to_data(RecordVal* v, Frame* f)
|
|||
|
||||
if ( ! d )
|
||||
reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
|
||||
"BrokerComm::Data's opaque field is not set");
|
||||
"Broker::Data's opaque field is not set");
|
||||
|
||||
return static_cast<DataVal*>(d)->data;
|
||||
}
|
||||
|
|
|
@ -21,25 +21,25 @@ extern OpaqueType* opaque_of_record_iterator;
|
|||
TransportProto to_bro_port_proto(broker::port::protocol tp);
|
||||
|
||||
/**
|
||||
* Create a BrokerComm::Data value from a Bro value.
|
||||
* Create a Broker::Data value from a Bro value.
|
||||
* @param v the Bro value to convert to a Broker data value.
|
||||
* @return a BrokerComm::Data value, where the optional field is set if the conversion
|
||||
* @return a Broker::Data value, where the optional field is set if the conversion
|
||||
* was possible, else it is unset.
|
||||
*/
|
||||
RecordVal* make_data_val(Val* v);
|
||||
|
||||
/**
|
||||
* Create a BrokerComm::Data value from a Broker data value.
|
||||
* Create a Broker::Data value from a Broker data value.
|
||||
* @param d the Broker value to wrap in an opaque type.
|
||||
* @return a BrokerComm::Data value that wraps the Broker value.
|
||||
* @return a Broker::Data value that wraps the Broker value.
|
||||
*/
|
||||
RecordVal* make_data_val(broker::data d);
|
||||
|
||||
/**
|
||||
* Get the type of Broker data that BrokerComm::Data wraps.
|
||||
* @param v a BrokerComm::Data value.
|
||||
* Get the type of Broker data that Broker::Data wraps.
|
||||
* @param v a Broker::Data value.
|
||||
* @param frame used to get location info upon error.
|
||||
* @return a BrokerComm::DataType value.
|
||||
* @return a Broker::DataType value.
|
||||
*/
|
||||
EnumVal* get_data_type(RecordVal* v, Frame* frame);
|
||||
|
||||
|
@ -141,8 +141,8 @@ struct type_name_getter {
|
|||
};
|
||||
|
||||
/**
|
||||
* Retrieve Broker data value associated with a BrokerComm::Data Bro value.
|
||||
* @param v a BrokerComm::Data value.
|
||||
* Retrieve Broker data value associated with a Broker::Data Bro value.
|
||||
* @param v a Broker::Data value.
|
||||
* @param f used to get location information on error.
|
||||
* @return a reference to the wrapped Broker data value. A runtime interpreter
|
||||
* exception is thrown if the the optional opaque value of \a v is not set.
|
||||
|
@ -183,9 +183,9 @@ inline T& require_data_type(RecordVal* v, TypeTag tag, Frame* f)
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert a BrokerComm::Data Bro value to a Bro value of a given type.
|
||||
* Convert a Broker::Data Bro value to a Bro value of a given type.
|
||||
* @tparam a type that a Broker data variant may contain.
|
||||
* @param v a BrokerComm::Data value.
|
||||
* @param v a Broker::Data value.
|
||||
* @param tag a Bro type to convert to.
|
||||
* @param f used to get location information on error.
|
||||
* A runtime interpret exception is thrown if trying to access a type which
|
||||
|
|
|
@ -77,20 +77,20 @@ bool bro_broker::Manager::Enable(Val* broker_endpoint_flags)
|
|||
if ( endpoint != nullptr )
|
||||
return true;
|
||||
|
||||
auto send_flags_type = internal_type("BrokerComm::SendFlags")->AsRecordType();
|
||||
auto send_flags_type = internal_type("Broker::SendFlags")->AsRecordType();
|
||||
send_flags_self_idx = require_field(send_flags_type, "self");
|
||||
send_flags_peers_idx = require_field(send_flags_type, "peers");
|
||||
send_flags_unsolicited_idx = require_field(send_flags_type, "unsolicited");
|
||||
|
||||
log_id_type = internal_type("Log::ID")->AsEnumType();
|
||||
|
||||
bro_broker::opaque_of_data_type = new OpaqueType("BrokerComm::Data");
|
||||
bro_broker::opaque_of_set_iterator = new OpaqueType("BrokerComm::SetIterator");
|
||||
bro_broker::opaque_of_table_iterator = new OpaqueType("BrokerComm::TableIterator");
|
||||
bro_broker::opaque_of_vector_iterator = new OpaqueType("BrokerComm::VectorIterator");
|
||||
bro_broker::opaque_of_record_iterator = new OpaqueType("BrokerComm::RecordIterator");
|
||||
bro_broker::opaque_of_store_handle = new OpaqueType("BrokerStore::Handle");
|
||||
vector_of_data_type = new VectorType(internal_type("BrokerComm::Data")->Ref());
|
||||
bro_broker::opaque_of_data_type = new OpaqueType("Broker::Data");
|
||||
bro_broker::opaque_of_set_iterator = new OpaqueType("Broker::SetIterator");
|
||||
bro_broker::opaque_of_table_iterator = new OpaqueType("Broker::TableIterator");
|
||||
bro_broker::opaque_of_vector_iterator = new OpaqueType("Broker::VectorIterator");
|
||||
bro_broker::opaque_of_record_iterator = new OpaqueType("Broker::RecordIterator");
|
||||
bro_broker::opaque_of_store_handle = new OpaqueType("Broker::Handle");
|
||||
vector_of_data_type = new VectorType(internal_type("Broker::Data")->Ref());
|
||||
|
||||
auto res = broker::init();
|
||||
|
||||
|
@ -110,7 +110,7 @@ bool bro_broker::Manager::Enable(Val* broker_endpoint_flags)
|
|||
}
|
||||
|
||||
const char* name;
|
||||
auto name_from_script = internal_val("BrokerComm::endpoint_name")->AsString();
|
||||
auto name_from_script = internal_val("Broker::endpoint_name")->AsString();
|
||||
|
||||
if ( name_from_script->Len() )
|
||||
name = name_from_script->CheckString();
|
||||
|
@ -290,7 +290,7 @@ bool bro_broker::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
|||
|
||||
if ( event->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
reporter->Error("BrokerComm::auto_event must operate on an event");
|
||||
reporter->Error("Broker::auto_event must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ bool bro_broker::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
|||
|
||||
if ( event_val->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("BrokerComm::auto_event must operate on an event");
|
||||
reporter->Error("Broker::auto_event must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ bool bro_broker::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
|||
|
||||
if ( ! handler )
|
||||
{
|
||||
reporter->Error("BrokerComm::auto_event failed to lookup event '%s'",
|
||||
reporter->Error("Broker::auto_event failed to lookup event '%s'",
|
||||
event_val->Name());
|
||||
return false;
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ bool bro_broker::Manager::AutoEventStop(const string& topic, Val* event)
|
|||
|
||||
if ( event->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
reporter->Error("BrokerComm::auto_event_stop must operate on an event");
|
||||
reporter->Error("Broker::auto_event_stop must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ bool bro_broker::Manager::AutoEventStop(const string& topic, Val* event)
|
|||
|
||||
if ( event_val->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("BrokerComm::auto_event_stop must operate on an event");
|
||||
reporter->Error("Broker::auto_event_stop must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ bool bro_broker::Manager::AutoEventStop(const string& topic, Val* event)
|
|||
|
||||
if ( ! handler )
|
||||
{
|
||||
reporter->Error("BrokerComm::auto_event_stop failed to lookup event '%s'",
|
||||
reporter->Error("Broker::auto_event_stop failed to lookup event '%s'",
|
||||
event_val->Name());
|
||||
return false;
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
|||
if ( ! Enabled() )
|
||||
return nullptr;
|
||||
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::EventArgs);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::EventArgs);
|
||||
auto arg_vec = new VectorVal(vector_of_data_type);
|
||||
rval->Assign(1, arg_vec);
|
||||
Func* func = 0;
|
||||
|
@ -368,7 +368,7 @@ RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
|||
|
||||
if ( arg_val->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
reporter->Error("1st param of BrokerComm::event_args must be event");
|
||||
reporter->Error("1st param of Broker::event_args must be event");
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
|||
|
||||
if ( func->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("1st param of BrokerComm::event_args must be event");
|
||||
reporter->Error("1st param of Broker::event_args must be event");
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
|||
|
||||
if ( num_args != args->length() - 1 )
|
||||
{
|
||||
reporter->Error("bad # of BrokerComm::event_args: got %d, expect %d",
|
||||
reporter->Error("bad # of Broker::event_args: got %d, expect %d",
|
||||
args->length(), num_args + 1);
|
||||
return rval;
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
|||
if ( ! same_type((*args)[i]->Type(), expected_type) )
|
||||
{
|
||||
rval->Assign(0, 0);
|
||||
reporter->Error("BrokerComm::event_args param %d type mismatch", i);
|
||||
reporter->Error("Broker::event_args param %d type mismatch", i);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
|||
{
|
||||
Unref(data_val);
|
||||
rval->Assign(0, 0);
|
||||
reporter->Error("BrokerComm::event_args unsupported event/params");
|
||||
reporter->Error("Broker::event_args unsupported event/params");
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ struct response_converter {
|
|||
case broker::store::query::tag::lookup:
|
||||
// A boolean result means the key doesn't exist (if it did, then
|
||||
// the result would contain the broker::data value, not a bool).
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
default:
|
||||
return bro_broker::make_data_val(broker::data{d});
|
||||
}
|
||||
|
@ -639,36 +639,36 @@ void bro_broker::Manager::Process()
|
|||
{
|
||||
switch ( u.status ) {
|
||||
case broker::outgoing_connection_status::tag::established:
|
||||
if ( BrokerComm::outgoing_connection_established )
|
||||
if ( Broker::outgoing_connection_established )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.relation.remote_tuple().first));
|
||||
vl->append(new PortVal(u.relation.remote_tuple().second,
|
||||
TRANSPORT_TCP));
|
||||
vl->append(new StringVal(u.peer_name));
|
||||
mgr.QueueEvent(BrokerComm::outgoing_connection_established, vl);
|
||||
mgr.QueueEvent(Broker::outgoing_connection_established, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
case broker::outgoing_connection_status::tag::disconnected:
|
||||
if ( BrokerComm::outgoing_connection_broken )
|
||||
if ( Broker::outgoing_connection_broken )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.relation.remote_tuple().first));
|
||||
vl->append(new PortVal(u.relation.remote_tuple().second,
|
||||
TRANSPORT_TCP));
|
||||
mgr.QueueEvent(BrokerComm::outgoing_connection_broken, vl);
|
||||
mgr.QueueEvent(Broker::outgoing_connection_broken, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
case broker::outgoing_connection_status::tag::incompatible:
|
||||
if ( BrokerComm::outgoing_connection_incompatible )
|
||||
if ( Broker::outgoing_connection_incompatible )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.relation.remote_tuple().first));
|
||||
vl->append(new PortVal(u.relation.remote_tuple().second,
|
||||
TRANSPORT_TCP));
|
||||
mgr.QueueEvent(BrokerComm::outgoing_connection_incompatible, vl);
|
||||
mgr.QueueEvent(Broker::outgoing_connection_incompatible, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -684,20 +684,20 @@ void bro_broker::Manager::Process()
|
|||
{
|
||||
switch ( u.status ) {
|
||||
case broker::incoming_connection_status::tag::established:
|
||||
if ( BrokerComm::incoming_connection_established )
|
||||
if ( Broker::incoming_connection_established )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.peer_name));
|
||||
mgr.QueueEvent(BrokerComm::incoming_connection_established, vl);
|
||||
mgr.QueueEvent(Broker::incoming_connection_established, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
case broker::incoming_connection_status::tag::disconnected:
|
||||
if ( BrokerComm::incoming_connection_broken )
|
||||
if ( Broker::incoming_connection_broken )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.peer_name));
|
||||
mgr.QueueEvent(BrokerComm::incoming_connection_broken, vl);
|
||||
mgr.QueueEvent(Broker::incoming_connection_broken, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -718,7 +718,7 @@ void bro_broker::Manager::Process()
|
|||
|
||||
ps.second.received += print_messages.size();
|
||||
|
||||
if ( ! BrokerComm::print_handler )
|
||||
if ( ! Broker::print_handler )
|
||||
continue;
|
||||
|
||||
for ( auto& pm : print_messages )
|
||||
|
@ -741,7 +741,7 @@ void bro_broker::Manager::Process()
|
|||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(move(*msg)));
|
||||
mgr.QueueEvent(BrokerComm::print_handler, vl);
|
||||
mgr.QueueEvent(Broker::print_handler, vl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
/**
|
||||
* Enable use of communication.
|
||||
* @param flags used to tune the local Broker endpoint's behavior.
|
||||
* See the BrokerComm::EndpointFlags record type.
|
||||
* See the Broker::EndpointFlags record type.
|
||||
* @return true if communication is successfully initialized.
|
||||
*/
|
||||
bool Enable(Val* flags);
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
* of this topic name.
|
||||
* @param msg the string to send to peers.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* See the Broker::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Print(std::string topic, std::string msg, Val* flags);
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
* @param msg the event to send to peers, which is the name of the event
|
||||
* as a string followed by all of its arguments.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* See the Broker::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Event(std::string topic, broker::message msg, int flags);
|
||||
|
@ -146,9 +146,9 @@ public:
|
|||
* Peers advertise interest by registering a subscription to some prefix
|
||||
* of this topic name.
|
||||
* @param args the event and its arguments to send to peers. See the
|
||||
* BrokerComm::EventArgs record type.
|
||||
* Broker::EventArgs record type.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* See the Broker::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Event(std::string topic, RecordVal* args, Val* flags);
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
* @param columns the data which comprises the log entry.
|
||||
* @param info the record type corresponding to the log's columns.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* See the Broker::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Log(EnumVal* stream_id, RecordVal* columns, RecordType* info,
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
* of this topic name.
|
||||
* @param event a Bro event value.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* See the Broker::SendFlags record type.
|
||||
* @return true if automatic event sending is now enabled.
|
||||
*/
|
||||
bool AutoEvent(std::string topic, Val* event, Val* flags);
|
||||
|
@ -320,7 +320,7 @@ public:
|
|||
Stats ConsumeStatistics();
|
||||
|
||||
/**
|
||||
* Convert BrokerComm::SendFlags to int flags for use with broker::send().
|
||||
* Convert Broker::SendFlags to int flags for use with broker::send().
|
||||
*/
|
||||
static int send_flags_to_int(Val* flags);
|
||||
|
||||
|
@ -335,7 +335,7 @@ private:
|
|||
void Process() override;
|
||||
|
||||
const char* Tag() override
|
||||
{ return "BrokerComm::Manager"; }
|
||||
{ return "Broker::Manager"; }
|
||||
|
||||
broker::endpoint& Endpoint()
|
||||
{ return *endpoint; }
|
||||
|
|
|
@ -14,12 +14,12 @@ OpaqueType* bro_broker::opaque_of_store_handle;
|
|||
|
||||
bro_broker::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
||||
bro_broker::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> arg_back,
|
||||
broker::util::optional<BifEnum::Broker::BackendType> arg_back,
|
||||
RecordVal* backend_options, std::chrono::duration<double> resync)
|
||||
: OpaqueVal(opaque_of_store_handle),
|
||||
store(), store_type(arg_type), backend_type(arg_back)
|
||||
{
|
||||
using BifEnum::BrokerStore::BackendType;
|
||||
using BifEnum::Broker::BackendType;
|
||||
std::unique_ptr<broker::store::backend> backend;
|
||||
|
||||
if ( backend_type )
|
||||
|
@ -91,7 +91,7 @@ bro_broker::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
|||
|
||||
void bro_broker::StoreHandleVal::ValDescribe(ODesc* d) const
|
||||
{
|
||||
using BifEnum::BrokerStore::BackendType;
|
||||
using BifEnum::Broker::BackendType;
|
||||
d->Add("broker::store::");
|
||||
|
||||
switch ( store_type ) {
|
||||
|
|
|
@ -25,9 +25,9 @@ enum StoreType {
|
|||
};
|
||||
|
||||
/**
|
||||
* Create a BrokerStore::QueryStatus value.
|
||||
* Create a Broker::QueryStatus value.
|
||||
* @param success whether the query status should be set to success or failure.
|
||||
* @return a BrokerStore::QueryStatus value.
|
||||
* @return a Broker::QueryStatus value.
|
||||
*/
|
||||
inline EnumVal* query_status(bool success)
|
||||
{
|
||||
|
@ -37,34 +37,34 @@ inline EnumVal* query_status(bool success)
|
|||
|
||||
if ( ! store_query_status )
|
||||
{
|
||||
store_query_status = internal_type("BrokerStore::QueryStatus")->AsEnumType();
|
||||
success_val = store_query_status->Lookup("BrokerStore", "SUCCESS");
|
||||
failure_val = store_query_status->Lookup("BrokerStore", "FAILURE");
|
||||
store_query_status = internal_type("Broker::QueryStatus")->AsEnumType();
|
||||
success_val = store_query_status->Lookup("Broker", "SUCCESS");
|
||||
failure_val = store_query_status->Lookup("Broker", "FAILURE");
|
||||
}
|
||||
|
||||
return new EnumVal(success ? success_val : failure_val, store_query_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a BrokerStore::QueryResult value that has a BrokerStore::QueryStatus indicating
|
||||
* @return a Broker::QueryResult value that has a Broker::QueryStatus indicating
|
||||
* a failure.
|
||||
*/
|
||||
inline RecordVal* query_result()
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::BrokerStore::QueryResult);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::QueryResult);
|
||||
rval->Assign(0, query_status(false));
|
||||
rval->Assign(1, new RecordVal(BifType::Record::BrokerComm::Data));
|
||||
rval->Assign(1, new RecordVal(BifType::Record::Broker::Data));
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data the result of the query.
|
||||
* @return a BrokerStore::QueryResult value that has a BrokerStore::QueryStatus indicating
|
||||
* @return a Broker::QueryResult value that has a Broker::QueryStatus indicating
|
||||
* a success.
|
||||
*/
|
||||
inline RecordVal* query_result(RecordVal* data)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::BrokerStore::QueryResult);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::QueryResult);
|
||||
rval->Assign(0, query_status(true));
|
||||
rval->Assign(1, data);
|
||||
return rval;
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
|
||||
StoreHandleVal(broker::store::identifier id,
|
||||
bro_broker::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> arg_back,
|
||||
broker::util::optional<BifEnum::Broker::BackendType> arg_back,
|
||||
RecordVal* backend_options,
|
||||
std::chrono::duration<double> resync = std::chrono::seconds(1));
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
|
||||
broker::store::frontend* store;
|
||||
bro_broker::StoreType store_type;
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> backend_type;
|
||||
broker::util::optional<BifEnum::Broker::BackendType> backend_type;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -5,124 +5,124 @@
|
|||
#include "broker/Manager.h"
|
||||
%%}
|
||||
|
||||
module BrokerComm;
|
||||
module Broker;
|
||||
|
||||
type BrokerComm::EndpointFlags: record;
|
||||
type Broker::EndpointFlags: record;
|
||||
|
||||
## Enable use of communication.
|
||||
##
|
||||
## flags: used to tune the local Broker endpoint behavior.
|
||||
##
|
||||
## Returns: true if communication is successfully initialized.
|
||||
function BrokerComm::enable%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
function Broker::enable%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
%{
|
||||
return new Val(broker_mgr->Enable(flags), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Changes endpoint flags originally supplied to :bro:see:`BrokerComm::enable`.
|
||||
## Changes endpoint flags originally supplied to :bro:see:`Broker::enable`.
|
||||
##
|
||||
## flags: the new endpoint behavior flags to use.
|
||||
##
|
||||
## Returns: true if flags were changed.
|
||||
function BrokerComm::set_endpoint_flags%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
function Broker::set_endpoint_flags%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
%{
|
||||
return new Val(broker_mgr->SetEndpointFlags(flags), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Allow sending messages to peers if associated with the given topic.
|
||||
## This has no effect if auto publication behavior is enabled via the flags
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`Broker::enable` or :bro:see:`Broker::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to allow messages to be published under.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function BrokerComm::publish_topic%(topic: string%): bool
|
||||
function Broker::publish_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(broker_mgr->PublishTopic(topic->CheckString()), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Disallow sending messages to peers if associated with the given topic.
|
||||
## This has no effect if auto publication behavior is enabled via the flags
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`Broker::enable` or :bro:see:`Broker::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to disallow messages to be published under.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function BrokerComm::unpublish_topic%(topic: string%): bool
|
||||
function Broker::unpublish_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(broker_mgr->UnpublishTopic(topic->CheckString()), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Allow advertising interest in the given topic to peers.
|
||||
## This has no effect if auto advertise behavior is enabled via the flags
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`Broker::enable` or :bro:see:`Broker::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to allow advertising interest/subscription to peers.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function BrokerComm::advertise_topic%(topic: string%): bool
|
||||
function Broker::advertise_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(broker_mgr->AdvertiseTopic(topic->CheckString()), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Disallow advertising interest in the given topic to peers.
|
||||
## This has no effect if auto advertise behavior is enabled via the flags
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`Broker::enable` or :bro:see:`Broker::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to disallow advertising interest/subscription to peers.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function BrokerComm::unadvertise_topic%(topic: string%): bool
|
||||
function Broker::unadvertise_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(broker_mgr->UnadvertiseTopic(topic->CheckString()), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Generated when a connection has been established due to a previous call
|
||||
## to :bro:see:`BrokerComm::connect`.
|
||||
## to :bro:see:`Broker::connect`.
|
||||
##
|
||||
## peer_address: the address used to connect to the peer.
|
||||
##
|
||||
## peer_port: the port used to connect to the peer.
|
||||
##
|
||||
## peer_name: the name by which the peer identified itself.
|
||||
event BrokerComm::outgoing_connection_established%(peer_address: string,
|
||||
event Broker::outgoing_connection_established%(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string%);
|
||||
|
||||
## Generated when a previously established connection becomes broken.
|
||||
## Reconnection will automatically be attempted at a frequency given
|
||||
## by the original call to :bro:see:`BrokerComm::connect`.
|
||||
## by the original call to :bro:see:`Broker::connect`.
|
||||
##
|
||||
## peer_address: the address used to connect to the peer.
|
||||
##
|
||||
## peer_port: the port used to connect to the peer.
|
||||
##
|
||||
## .. bro:see:: BrokerComm::outgoing_connection_established
|
||||
event BrokerComm::outgoing_connection_broken%(peer_address: string,
|
||||
## .. bro:see:: Broker::outgoing_connection_established
|
||||
event Broker::outgoing_connection_broken%(peer_address: string,
|
||||
peer_port: port%);
|
||||
|
||||
## Generated when a connection via :bro:see:`BrokerComm::connect` has failed
|
||||
## Generated when a connection via :bro:see:`Broker::connect` has failed
|
||||
## because the remote side is incompatible.
|
||||
##
|
||||
## peer_address: the address used to connect to the peer.
|
||||
##
|
||||
## peer_port: the port used to connect to the peer.
|
||||
event BrokerComm::outgoing_connection_incompatible%(peer_address: string,
|
||||
event Broker::outgoing_connection_incompatible%(peer_address: string,
|
||||
peer_port: port%);
|
||||
|
||||
## Generated when a peer has established a connection with this process
|
||||
## as a result of previously performing a :bro:see:`BrokerComm::listen`.
|
||||
## as a result of previously performing a :bro:see:`Broker::listen`.
|
||||
##
|
||||
## peer_name: the name by which the peer identified itself.
|
||||
event BrokerComm::incoming_connection_established%(peer_name: string%);
|
||||
event Broker::incoming_connection_established%(peer_name: string%);
|
||||
|
||||
## Generated when a peer that previously established a connection with this
|
||||
## process becomes disconnected.
|
||||
##
|
||||
## peer_name: the name by which the peer identified itself.
|
||||
##
|
||||
## .. bro:see:: BrokerComm::incoming_connection_established
|
||||
event BrokerComm::incoming_connection_broken%(peer_name: string%);
|
||||
## .. bro:see:: Broker::incoming_connection_established
|
||||
event Broker::incoming_connection_broken%(peer_name: string%);
|
||||
|
||||
## Listen for remote connections.
|
||||
##
|
||||
|
@ -135,8 +135,8 @@ event BrokerComm::incoming_connection_broken%(peer_name: string%);
|
|||
##
|
||||
## Returns: true if the local endpoint is now listening for connections.
|
||||
##
|
||||
## .. bro:see:: BrokerComm::incoming_connection_established
|
||||
function BrokerComm::listen%(p: port, a: string &default = "",
|
||||
## .. bro:see:: Broker::incoming_connection_established
|
||||
function Broker::listen%(p: port, a: string &default = "",
|
||||
reuse: bool &default = T%): bool
|
||||
%{
|
||||
if ( ! p->IsTCP() )
|
||||
|
@ -164,8 +164,8 @@ function BrokerComm::listen%(p: port, a: string &default = "",
|
|||
## it's a new peer. The actual connection may not be established
|
||||
## until a later point in time.
|
||||
##
|
||||
## .. bro:see:: BrokerComm::outgoing_connection_established
|
||||
function BrokerComm::connect%(a: string, p: port, retry: interval%): bool
|
||||
## .. bro:see:: Broker::outgoing_connection_established
|
||||
function Broker::connect%(a: string, p: port, retry: interval%): bool
|
||||
%{
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
@ -180,13 +180,13 @@ function BrokerComm::connect%(a: string, p: port, retry: interval%): bool
|
|||
|
||||
## Remove a remote connection.
|
||||
##
|
||||
## a: the address used in previous successful call to :bro:see:`BrokerComm::connect`.
|
||||
## a: the address used in previous successful call to :bro:see:`Broker::connect`.
|
||||
##
|
||||
## p: the port used in previous successful call to :bro:see:`BrokerComm::connect`.
|
||||
## p: the port used in previous successful call to :bro:see:`Broker::connect`.
|
||||
##
|
||||
## Returns: true if the arguments match a previously successful call to
|
||||
## :bro:see:`BrokerComm::connect`.
|
||||
function BrokerComm::disconnect%(a: string, p: port%): bool
|
||||
## :bro:see:`Broker::connect`.
|
||||
function Broker::disconnect%(a: string, p: port%): bool
|
||||
%{
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "broker/Data.h"
|
||||
%%}
|
||||
|
||||
module BrokerComm;
|
||||
module Broker;
|
||||
|
||||
## Enumerates the possible types that :bro:see:`BrokerComm::Data` may be in
|
||||
## Enumerates the possible types that :bro:see:`Broker::Data` may be in
|
||||
## terms of Bro data types.
|
||||
enum DataType %{
|
||||
BOOL,
|
||||
|
@ -27,9 +27,9 @@ enum DataType %{
|
|||
RECORD,
|
||||
%}
|
||||
|
||||
type BrokerComm::Data: record;
|
||||
type Broker::Data: record;
|
||||
|
||||
type BrokerComm::TableItem: record;
|
||||
type Broker::TableItem: record;
|
||||
|
||||
## Convert any Bro value to communication data.
|
||||
##
|
||||
|
@ -39,7 +39,7 @@ type BrokerComm::TableItem: record;
|
|||
## field will not be set if the conversion was not possible (this can
|
||||
## happen if the Bro data type does not support being converted to
|
||||
## communication data).
|
||||
function BrokerComm::data%(d: any%): BrokerComm::Data
|
||||
function Broker::data%(d: any%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(d);
|
||||
%}
|
||||
|
@ -49,75 +49,75 @@ function BrokerComm::data%(d: any%): BrokerComm::Data
|
|||
## d: the communication data.
|
||||
##
|
||||
## Returns: the data type associated with the communication data.
|
||||
function BrokerComm::data_type%(d: BrokerComm::Data%): BrokerComm::DataType
|
||||
function Broker::data_type%(d: Broker::Data%): Broker::DataType
|
||||
%{
|
||||
return bro_broker::get_data_type(d->AsRecordVal(), frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::BOOL` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::BOOL` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_bool%(d: BrokerComm::Data%): bool
|
||||
function Broker::refine_to_bool%(d: Broker::Data%): bool
|
||||
%{
|
||||
return bro_broker::refine<bool>(d->AsRecordVal(), TYPE_BOOL, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::INT` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::INT` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_int%(d: BrokerComm::Data%): int
|
||||
function Broker::refine_to_int%(d: Broker::Data%): int
|
||||
%{
|
||||
return bro_broker::refine<int64_t>(d->AsRecordVal(), TYPE_INT, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::COUNT` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::COUNT` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_count%(d: BrokerComm::Data%): count
|
||||
function Broker::refine_to_count%(d: Broker::Data%): count
|
||||
%{
|
||||
return bro_broker::refine<uint64_t>(d->AsRecordVal(), TYPE_COUNT, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::DOUBLE` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::DOUBLE` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_double%(d: BrokerComm::Data%): double
|
||||
function Broker::refine_to_double%(d: Broker::Data%): double
|
||||
%{
|
||||
return bro_broker::refine<double>(d->AsRecordVal(), TYPE_DOUBLE, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::STRING` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::STRING` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_string%(d: BrokerComm::Data%): string
|
||||
function Broker::refine_to_string%(d: Broker::Data%): string
|
||||
%{
|
||||
return new StringVal(bro_broker::require_data_type<std::string>(d->AsRecordVal(),
|
||||
TYPE_STRING,
|
||||
frame));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::ADDR` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::ADDR` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_addr%(d: BrokerComm::Data%): addr
|
||||
function Broker::refine_to_addr%(d: Broker::Data%): addr
|
||||
%{
|
||||
auto& a = bro_broker::require_data_type<broker::address>(d->AsRecordVal(),
|
||||
TYPE_ADDR, frame);
|
||||
|
@ -125,13 +125,13 @@ function BrokerComm::refine_to_addr%(d: BrokerComm::Data%): addr
|
|||
return new AddrVal(IPAddr(*bits));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::SUBNET` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::SUBNET` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_subnet%(d: BrokerComm::Data%): subnet
|
||||
function Broker::refine_to_subnet%(d: Broker::Data%): subnet
|
||||
%{
|
||||
auto& a = bro_broker::require_data_type<broker::subnet>(d->AsRecordVal(),
|
||||
TYPE_SUBNET, frame);
|
||||
|
@ -139,53 +139,53 @@ function BrokerComm::refine_to_subnet%(d: BrokerComm::Data%): subnet
|
|||
return new SubNetVal(IPPrefix(IPAddr(*bits), a.length()));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::PORT` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::PORT` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_port%(d: BrokerComm::Data%): port
|
||||
function Broker::refine_to_port%(d: Broker::Data%): port
|
||||
%{
|
||||
auto& a = bro_broker::require_data_type<broker::port>(d->AsRecordVal(),
|
||||
TYPE_SUBNET, frame);
|
||||
return new PortVal(a.number(), bro_broker::to_bro_port_proto(a.type()));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::TIME` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::TIME` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_time%(d: BrokerComm::Data%): time
|
||||
function Broker::refine_to_time%(d: Broker::Data%): time
|
||||
%{
|
||||
auto v = bro_broker::require_data_type<broker::time_point>(d->AsRecordVal(),
|
||||
TYPE_TIME, frame).value;
|
||||
return new Val(v, TYPE_TIME);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::INTERVAL` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::INTERVAL` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function BrokerComm::refine_to_interval%(d: BrokerComm::Data%): interval
|
||||
function Broker::refine_to_interval%(d: Broker::Data%): interval
|
||||
%{
|
||||
auto v = bro_broker::require_data_type<broker::time_duration>(d->AsRecordVal(),
|
||||
TYPE_TIME, frame).value;
|
||||
return new Val(v, TYPE_INTERVAL);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::ENUM` to
|
||||
## Convert communication data with a type of :bro:see:`Broker::ENUM` to
|
||||
## the name of the enum value. :bro:see:`lookup_ID` may be used to convert
|
||||
## the name to the actual enum value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the enum name retrieved from the communication data.
|
||||
function BrokerComm::refine_to_enum_name%(d: BrokerComm::Data%): string
|
||||
function Broker::refine_to_enum_name%(d: Broker::Data%): string
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::enum_value>(d->AsRecordVal(),
|
||||
TYPE_ENUM, frame).name;
|
||||
|
@ -193,7 +193,7 @@ function BrokerComm::refine_to_enum_name%(d: BrokerComm::Data%): string
|
|||
%}
|
||||
|
||||
## Create communication data of type "set".
|
||||
function BrokerComm::set_create%(%): BrokerComm::Data
|
||||
function Broker::set_create%(%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::set());
|
||||
%}
|
||||
|
@ -203,7 +203,7 @@ function BrokerComm::set_create%(%): BrokerComm::Data
|
|||
## s: the set to clear.
|
||||
##
|
||||
## Returns: always true.
|
||||
function BrokerComm::set_clear%(s: BrokerComm::Data%): bool
|
||||
function Broker::set_clear%(s: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
|
@ -216,7 +216,7 @@ function BrokerComm::set_clear%(s: BrokerComm::Data%): bool
|
|||
## s: the set to query.
|
||||
##
|
||||
## Returns: the number of elements in the set.
|
||||
function BrokerComm::set_size%(s: BrokerComm::Data%): count
|
||||
function Broker::set_size%(s: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
|
@ -230,7 +230,7 @@ function BrokerComm::set_size%(s: BrokerComm::Data%): count
|
|||
## key: the element to check for existence.
|
||||
##
|
||||
## Returns: true if the key exists in the set.
|
||||
function BrokerComm::set_contains%(s: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
function Broker::set_contains%(s: Broker::Data, key: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
|
@ -245,7 +245,7 @@ function BrokerComm::set_contains%(s: BrokerComm::Data, key: BrokerComm::Data%):
|
|||
## key: the element to insert.
|
||||
##
|
||||
## Returns: true if the key was inserted, or false if it already existed.
|
||||
function BrokerComm::set_insert%(s: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
function Broker::set_insert%(s: Broker::Data, key: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
|
@ -260,7 +260,7 @@ function BrokerComm::set_insert%(s: BrokerComm::Data, key: BrokerComm::Data%): b
|
|||
## key: the element to remove.
|
||||
##
|
||||
## Returns: true if the element existed in the set and is now removed.
|
||||
function BrokerComm::set_remove%(s: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
function Broker::set_remove%(s: Broker::Data, key: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
|
@ -274,7 +274,7 @@ function BrokerComm::set_remove%(s: BrokerComm::Data, key: BrokerComm::Data%): b
|
|||
## s: the set to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function BrokerComm::set_iterator%(s: BrokerComm::Data%): opaque of BrokerComm::SetIterator
|
||||
function Broker::set_iterator%(s: Broker::Data%): opaque of Broker::SetIterator
|
||||
%{
|
||||
return new bro_broker::SetIterator(s->AsRecordVal(), TYPE_TABLE, frame);
|
||||
%}
|
||||
|
@ -285,7 +285,7 @@ function BrokerComm::set_iterator%(s: BrokerComm::Data%): opaque of BrokerComm::
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function BrokerComm::set_iterator_last%(it: opaque of BrokerComm::SetIterator%): bool
|
||||
function Broker::set_iterator_last%(it: opaque of Broker::SetIterator%): bool
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
return new Val(set_it->it == set_it->dat.end(), TYPE_BOOL);
|
||||
|
@ -298,7 +298,7 @@ function BrokerComm::set_iterator_last%(it: opaque of BrokerComm::SetIterator%):
|
|||
## Returns: true if the iterator, after advancing, still references an element
|
||||
## in the collection. False if the iterator, after advancing, is
|
||||
## one-past-the-final-element.
|
||||
function BrokerComm::set_iterator_next%(it: opaque of BrokerComm::SetIterator%): bool
|
||||
function Broker::set_iterator_next%(it: opaque of Broker::SetIterator%): bool
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
|
||||
|
@ -314,10 +314,10 @@ function BrokerComm::set_iterator_next%(it: opaque of BrokerComm::SetIterator%):
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function BrokerComm::set_iterator_value%(it: opaque of BrokerComm::SetIterator%): BrokerComm::Data
|
||||
function Broker::set_iterator_value%(it: opaque of Broker::SetIterator%): Broker::Data
|
||||
%{
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
if ( set_it->it == set_it->dat.end() )
|
||||
{
|
||||
|
@ -332,7 +332,7 @@ function BrokerComm::set_iterator_value%(it: opaque of BrokerComm::SetIterator%)
|
|||
%}
|
||||
|
||||
## Create communication data of type "table".
|
||||
function BrokerComm::table_create%(%): BrokerComm::Data
|
||||
function Broker::table_create%(%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::table());
|
||||
%}
|
||||
|
@ -342,7 +342,7 @@ function BrokerComm::table_create%(%): BrokerComm::Data
|
|||
## t: the table to clear.
|
||||
##
|
||||
## Returns: always true.
|
||||
function BrokerComm::table_clear%(t: BrokerComm::Data%): bool
|
||||
function Broker::table_clear%(t: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
|
@ -355,7 +355,7 @@ function BrokerComm::table_clear%(t: BrokerComm::Data%): bool
|
|||
## t: the table to query.
|
||||
##
|
||||
## Returns: the number of elements in the table.
|
||||
function BrokerComm::table_size%(t: BrokerComm::Data%): count
|
||||
function Broker::table_size%(t: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
|
@ -369,7 +369,7 @@ function BrokerComm::table_size%(t: BrokerComm::Data%): count
|
|||
## key: the key to check for existence.
|
||||
##
|
||||
## Returns: true if the key exists in the table.
|
||||
function BrokerComm::table_contains%(t: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
function Broker::table_contains%(t: Broker::Data, key: Broker::Data%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
|
@ -387,7 +387,7 @@ function BrokerComm::table_contains%(t: BrokerComm::Data, key: BrokerComm::Data%
|
|||
##
|
||||
## Returns: true if the key-value pair was inserted, or false if the key
|
||||
## already existed in the table.
|
||||
function BrokerComm::table_insert%(t: BrokerComm::Data, key: BrokerComm::Data, val: BrokerComm::Data%): BrokerComm::Data
|
||||
function Broker::table_insert%(t: Broker::Data, key: Broker::Data, val: Broker::Data%): Broker::Data
|
||||
%{
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
|
@ -404,7 +404,7 @@ function BrokerComm::table_insert%(t: BrokerComm::Data, key: BrokerComm::Data, v
|
|||
catch (const std::out_of_range&)
|
||||
{
|
||||
table[k] = v;
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -416,7 +416,7 @@ function BrokerComm::table_insert%(t: BrokerComm::Data, key: BrokerComm::Data, v
|
|||
##
|
||||
## Returns: the value associated with the key. If the key did not exist, then
|
||||
## the optional field of the returned record is not set.
|
||||
function BrokerComm::table_remove%(t: BrokerComm::Data, key: BrokerComm::Data%): BrokerComm::Data
|
||||
function Broker::table_remove%(t: Broker::Data, key: Broker::Data%): Broker::Data
|
||||
%{
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
|
@ -424,7 +424,7 @@ function BrokerComm::table_remove%(t: BrokerComm::Data, key: BrokerComm::Data%):
|
|||
auto it = table.find(k);
|
||||
|
||||
if ( it == table.end() )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
else
|
||||
{
|
||||
auto rval = bro_broker::make_data_val(move(it->second));
|
||||
|
@ -441,7 +441,7 @@ function BrokerComm::table_remove%(t: BrokerComm::Data, key: BrokerComm::Data%):
|
|||
##
|
||||
## Returns: the value associated with the key. If the key did not exist, then
|
||||
## the optional field of the returned record is not set.
|
||||
function BrokerComm::table_lookup%(t: BrokerComm::Data, key: BrokerComm::Data%): BrokerComm::Data
|
||||
function Broker::table_lookup%(t: Broker::Data, key: Broker::Data%): Broker::Data
|
||||
%{
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
|
@ -449,7 +449,7 @@ function BrokerComm::table_lookup%(t: BrokerComm::Data, key: BrokerComm::Data%):
|
|||
auto it = table.find(k);
|
||||
|
||||
if ( it == table.end() )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
else
|
||||
return bro_broker::make_data_val(it->second);
|
||||
%}
|
||||
|
@ -460,7 +460,7 @@ function BrokerComm::table_lookup%(t: BrokerComm::Data, key: BrokerComm::Data%):
|
|||
## t: the table to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function BrokerComm::table_iterator%(t: BrokerComm::Data%): opaque of BrokerComm::TableIterator
|
||||
function Broker::table_iterator%(t: Broker::Data%): opaque of Broker::TableIterator
|
||||
%{
|
||||
return new bro_broker::TableIterator(t->AsRecordVal(), TYPE_TABLE, frame);
|
||||
%}
|
||||
|
@ -471,7 +471,7 @@ function BrokerComm::table_iterator%(t: BrokerComm::Data%): opaque of BrokerComm
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function BrokerComm::table_iterator_last%(it: opaque of BrokerComm::TableIterator%): bool
|
||||
function Broker::table_iterator_last%(it: opaque of Broker::TableIterator%): bool
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
return new Val(ti->it == ti->dat.end(), TYPE_BOOL);
|
||||
|
@ -484,7 +484,7 @@ function BrokerComm::table_iterator_last%(it: opaque of BrokerComm::TableIterato
|
|||
## Returns: true if the iterator, after advancing, still references an element
|
||||
## in the collection. False if the iterator, after advancing, is
|
||||
## one-past-the-final-element.
|
||||
function BrokerComm::table_iterator_next%(it: opaque of BrokerComm::TableIterator%): bool
|
||||
function Broker::table_iterator_next%(it: opaque of Broker::TableIterator%): bool
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
|
||||
|
@ -500,12 +500,12 @@ function BrokerComm::table_iterator_next%(it: opaque of BrokerComm::TableIterato
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function BrokerComm::table_iterator_value%(it: opaque of BrokerComm::TableIterator%): BrokerComm::TableItem
|
||||
function Broker::table_iterator_value%(it: opaque of Broker::TableIterator%): Broker::TableItem
|
||||
%{
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::TableItem);
|
||||
auto key_val = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto val_val = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::TableItem);
|
||||
auto key_val = new RecordVal(BifType::Record::Broker::Data);
|
||||
auto val_val = new RecordVal(BifType::Record::Broker::Data);
|
||||
rval->Assign(0, key_val);
|
||||
rval->Assign(1, val_val);
|
||||
|
||||
|
@ -523,7 +523,7 @@ function BrokerComm::table_iterator_value%(it: opaque of BrokerComm::TableIterat
|
|||
%}
|
||||
|
||||
## Create communication data of type "vector".
|
||||
function BrokerComm::vector_create%(%): BrokerComm::Data
|
||||
function Broker::vector_create%(%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::vector());
|
||||
%}
|
||||
|
@ -533,7 +533,7 @@ function BrokerComm::vector_create%(%): BrokerComm::Data
|
|||
## v: the vector to clear.
|
||||
##
|
||||
## Returns: always true.
|
||||
function BrokerComm::vector_clear%(v: BrokerComm::Data%): bool
|
||||
function Broker::vector_clear%(v: Broker::Data%): bool
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
@ -546,7 +546,7 @@ function BrokerComm::vector_clear%(v: BrokerComm::Data%): bool
|
|||
## v: the vector to query.
|
||||
##
|
||||
## Returns: the number of elements in the vector.
|
||||
function BrokerComm::vector_size%(v: BrokerComm::Data%): count
|
||||
function Broker::vector_size%(v: Broker::Data%): count
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
@ -564,7 +564,7 @@ function BrokerComm::vector_size%(v: BrokerComm::Data%): count
|
|||
## current size of the vector, the element is inserted at the end.
|
||||
##
|
||||
## Returns: always true.
|
||||
function BrokerComm::vector_insert%(v: BrokerComm::Data, d: BrokerComm::Data, idx: count%): bool
|
||||
function Broker::vector_insert%(v: Broker::Data, d: Broker::Data, idx: count%): bool
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
@ -584,14 +584,14 @@ function BrokerComm::vector_insert%(v: BrokerComm::Data, d: BrokerComm::Data, id
|
|||
##
|
||||
## Returns: the value that was just evicted. If the index was larger than any
|
||||
## valid index, the optional field of the returned record is not set.
|
||||
function BrokerComm::vector_replace%(v: BrokerComm::Data, d: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
function Broker::vector_replace%(v: Broker::Data, d: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
auto& item = bro_broker::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
auto rval = bro_broker::make_data_val(move(vec[idx]));
|
||||
vec[idx] = item;
|
||||
|
@ -606,13 +606,13 @@ function BrokerComm::vector_replace%(v: BrokerComm::Data, d: BrokerComm::Data, i
|
|||
##
|
||||
## Returns: the value that was just evicted. If the index was larger than any
|
||||
## valid index, the optional field of the returned record is not set.
|
||||
function BrokerComm::vector_remove%(v: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
function Broker::vector_remove%(v: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
auto rval = bro_broker::make_data_val(move(vec[idx]));
|
||||
vec.erase(vec.begin() + idx);
|
||||
|
@ -627,13 +627,13 @@ function BrokerComm::vector_remove%(v: BrokerComm::Data, idx: count%): BrokerCom
|
|||
##
|
||||
## Returns: the value at the index. If the index was larger than any
|
||||
## valid index, the optional field of the returned record is not set.
|
||||
function BrokerComm::vector_lookup%(v: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
function Broker::vector_lookup%(v: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
return bro_broker::make_data_val(vec[idx]);
|
||||
%}
|
||||
|
@ -644,7 +644,7 @@ function BrokerComm::vector_lookup%(v: BrokerComm::Data, idx: count%): BrokerCom
|
|||
## v: the vector to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function BrokerComm::vector_iterator%(v: BrokerComm::Data%): opaque of BrokerComm::VectorIterator
|
||||
function Broker::vector_iterator%(v: Broker::Data%): opaque of Broker::VectorIterator
|
||||
%{
|
||||
return new bro_broker::VectorIterator(v->AsRecordVal(), TYPE_VECTOR, frame);
|
||||
%}
|
||||
|
@ -655,7 +655,7 @@ function BrokerComm::vector_iterator%(v: BrokerComm::Data%): opaque of BrokerCom
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function BrokerComm::vector_iterator_last%(it: opaque of BrokerComm::VectorIterator%): bool
|
||||
function Broker::vector_iterator_last%(it: opaque of Broker::VectorIterator%): bool
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
return new Val(vi->it == vi->dat.end(), TYPE_BOOL);
|
||||
|
@ -668,7 +668,7 @@ function BrokerComm::vector_iterator_last%(it: opaque of BrokerComm::VectorItera
|
|||
## Returns: true if the iterator, after advancing, still references an element
|
||||
## in the collection. False if the iterator, after advancing, is
|
||||
## one-past-the-final-element.
|
||||
function BrokerComm::vector_iterator_next%(it: opaque of BrokerComm::VectorIterator%): bool
|
||||
function Broker::vector_iterator_next%(it: opaque of Broker::VectorIterator%): bool
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
|
||||
|
@ -684,10 +684,10 @@ function BrokerComm::vector_iterator_next%(it: opaque of BrokerComm::VectorItera
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function BrokerComm::vector_iterator_value%(it: opaque of BrokerComm::VectorIterator%): BrokerComm::Data
|
||||
function Broker::vector_iterator_value%(it: opaque of Broker::VectorIterator%): Broker::Data
|
||||
%{
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
if ( vi->it == vi->dat.end() )
|
||||
{
|
||||
|
@ -706,7 +706,7 @@ function BrokerComm::vector_iterator_value%(it: opaque of BrokerComm::VectorIter
|
|||
## sz: the number of fields in the record.
|
||||
##
|
||||
## Returns: record data, with all fields uninitialized.
|
||||
function BrokerComm::record_create%(sz: count%): BrokerComm::Data
|
||||
function Broker::record_create%(sz: count%): Broker::Data
|
||||
%{
|
||||
return bro_broker::make_data_val(broker::record(std::vector<broker::record::field>(sz)));
|
||||
%}
|
||||
|
@ -716,7 +716,7 @@ function BrokerComm::record_create%(sz: count%): BrokerComm::Data
|
|||
## r: the record to query.
|
||||
##
|
||||
## Returns: the number of fields in the record.
|
||||
function BrokerComm::record_size%(r: BrokerComm::Data%): count
|
||||
function Broker::record_size%(r: Broker::Data%): count
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
|
@ -732,7 +732,7 @@ function BrokerComm::record_size%(r: BrokerComm::Data%): count
|
|||
## idx: the index to replace.
|
||||
##
|
||||
## Returns: false if the index was larger than any valid index, else true.
|
||||
function BrokerComm::record_assign%(r: BrokerComm::Data, d: BrokerComm::Data, idx: count%): bool
|
||||
function Broker::record_assign%(r: Broker::Data, d: Broker::Data, idx: count%): bool
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
|
@ -754,16 +754,16 @@ function BrokerComm::record_assign%(r: BrokerComm::Data, d: BrokerComm::Data, id
|
|||
## Returns: the value at the index. The optional field of the returned record
|
||||
## may not be set if the field of the record has no value or if the
|
||||
## index was not valid.
|
||||
function BrokerComm::record_lookup%(r: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
function Broker::record_lookup%(r: Broker::Data, idx: count%): Broker::Data
|
||||
%{
|
||||
auto& v = bro_broker::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
|
||||
if ( idx >= v.size() )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
if ( ! v.fields[idx] )
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
return new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
return bro_broker::make_data_val(*v.fields[idx]);
|
||||
%}
|
||||
|
@ -774,7 +774,7 @@ function BrokerComm::record_lookup%(r: BrokerComm::Data, idx: count%): BrokerCom
|
|||
## r: the record to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function BrokerComm::record_iterator%(r: BrokerComm::Data%): opaque of BrokerComm::RecordIterator
|
||||
function Broker::record_iterator%(r: Broker::Data%): opaque of Broker::RecordIterator
|
||||
%{
|
||||
return new bro_broker::RecordIterator(r->AsRecordVal(), TYPE_RECORD, frame);
|
||||
%}
|
||||
|
@ -785,7 +785,7 @@ function BrokerComm::record_iterator%(r: BrokerComm::Data%): opaque of BrokerCom
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function BrokerComm::record_iterator_last%(it: opaque of BrokerComm::RecordIterator%): bool
|
||||
function Broker::record_iterator_last%(it: opaque of Broker::RecordIterator%): bool
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
return new Val(ri->it == ri->dat.fields.end(), TYPE_BOOL);
|
||||
|
@ -798,7 +798,7 @@ function BrokerComm::record_iterator_last%(it: opaque of BrokerComm::RecordItera
|
|||
## Returns: true if the iterator, after advancing, still references an element
|
||||
## in the collection. False if the iterator, after advancing, is
|
||||
## one-past-the-final-element.
|
||||
function BrokerComm::record_iterator_next%(it: opaque of BrokerComm::RecordIterator%): bool
|
||||
function Broker::record_iterator_next%(it: opaque of Broker::RecordIterator%): bool
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
|
||||
|
@ -814,10 +814,10 @@ function BrokerComm::record_iterator_next%(it: opaque of BrokerComm::RecordItera
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function BrokerComm::record_iterator_value%(it: opaque of BrokerComm::RecordIterator%): BrokerComm::Data
|
||||
function Broker::record_iterator_value%(it: opaque of Broker::RecordIterator%): Broker::Data
|
||||
%{
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::Broker::Data);
|
||||
|
||||
if ( ri->it == ri->dat.fields.end() )
|
||||
{
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#include "logging/Manager.h"
|
||||
%%}
|
||||
|
||||
module BrokerComm;
|
||||
module Broker;
|
||||
|
||||
type BrokerComm::SendFlags: record;
|
||||
type Broker::SendFlags: record;
|
||||
|
||||
type BrokerComm::EventArgs: record;
|
||||
type Broker::EventArgs: record;
|
||||
|
||||
## Used to handle remote print messages from peers that call
|
||||
## :bro:see:`BrokerComm::print`.
|
||||
event BrokerComm::print_handler%(msg: string%);
|
||||
## :bro:see:`Broker::print`.
|
||||
event Broker::print_handler%(msg: string%);
|
||||
|
||||
## Print a simple message to any interested peers. The receiver can use
|
||||
## :bro:see:`BrokerComm::print_handler` to handle messages.
|
||||
## :bro:see:`Broker::print_handler` to handle messages.
|
||||
##
|
||||
## topic: a topic associated with the printed message.
|
||||
##
|
||||
|
@ -26,7 +26,7 @@ event BrokerComm::print_handler%(msg: string%);
|
|||
## flags: tune the behavior of how the message is sent.
|
||||
##
|
||||
## Returns: true if the message is sent.
|
||||
function BrokerComm::print%(topic: string, msg: string,
|
||||
function Broker::print%(topic: string, msg: string,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->Print(topic->CheckString(), msg->CheckString(),
|
||||
|
@ -35,14 +35,14 @@ function BrokerComm::print%(topic: string, msg: string,
|
|||
%}
|
||||
|
||||
## Register interest in all peer print messages that use a certain topic prefix.
|
||||
## Use :bro:see:`BrokerComm::print_handler` to handle received messages.
|
||||
## Use :bro:see:`Broker::print_handler` to handle received messages.
|
||||
##
|
||||
## topic_prefix: a prefix to match against remote message topics.
|
||||
## e.g. an empty prefix matches everything and "a" matches
|
||||
## "alice" and "amy" but not "bob".
|
||||
##
|
||||
## Returns: true if it's a new print subscription and it is now registered.
|
||||
function BrokerComm::subscribe_to_prints%(topic_prefix: string%): bool
|
||||
function Broker::subscribe_to_prints%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->SubscribeToPrints(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -51,23 +51,23 @@ function BrokerComm::subscribe_to_prints%(topic_prefix: string%): bool
|
|||
## Unregister interest in all peer print messages that use a topic prefix.
|
||||
##
|
||||
## topic_prefix: a prefix previously supplied to a successful call to
|
||||
## :bro:see:`BrokerComm::subscribe_to_prints`.
|
||||
## :bro:see:`Broker::subscribe_to_prints`.
|
||||
##
|
||||
## Returns: true if interest in the topic prefix is no longer advertised.
|
||||
function BrokerComm::unsubscribe_to_prints%(topic_prefix: string%): bool
|
||||
function Broker::unsubscribe_to_prints%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->UnsubscribeToPrints(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Create a data structure that may be used to send a remote event via
|
||||
## :bro:see:`BrokerComm::event`.
|
||||
## :bro:see:`Broker::event`.
|
||||
##
|
||||
## args: an event, followed by a list of argument values that may be used
|
||||
## to call it.
|
||||
##
|
||||
## Returns: opaque communication data that may be used to send a remote event.
|
||||
function BrokerComm::event_args%(...%): BrokerComm::EventArgs
|
||||
function Broker::event_args%(...%): Broker::EventArgs
|
||||
%{
|
||||
auto rval = broker_mgr->MakeEventArgs(@ARGS@);
|
||||
return rval;
|
||||
|
@ -77,12 +77,12 @@ function BrokerComm::event_args%(...%): BrokerComm::EventArgs
|
|||
##
|
||||
## topic: a topic associated with the event message.
|
||||
##
|
||||
## args: event arguments as made by :bro:see:`BrokerComm::event_args`.
|
||||
## args: event arguments as made by :bro:see:`Broker::event_args`.
|
||||
##
|
||||
## flags: tune the behavior of how the message is sent.
|
||||
##
|
||||
## Returns: true if the message is sent.
|
||||
function BrokerComm::event%(topic: string, args: BrokerComm::EventArgs,
|
||||
function Broker::event%(topic: string, args: Broker::EventArgs,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->Event(topic->CheckString(), args->AsRecordVal(),
|
||||
|
@ -102,7 +102,7 @@ function BrokerComm::event%(topic: string, args: BrokerComm::EventArgs,
|
|||
## flags: tune the behavior of how the message is sent.
|
||||
##
|
||||
## Returns: true if automatic event sending is now enabled.
|
||||
function BrokerComm::auto_event%(topic: string, ev: any,
|
||||
function Broker::auto_event%(topic: string, ev: any,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->AutoEvent(topic->CheckString(), ev, flags);
|
||||
|
@ -111,12 +111,12 @@ function BrokerComm::auto_event%(topic: string, ev: any,
|
|||
|
||||
## Stop automatically sending an event to peers upon local dispatch.
|
||||
##
|
||||
## topic: a topic originally given to :bro:see:`BrokerComm::auto_event`.
|
||||
## topic: a topic originally given to :bro:see:`Broker::auto_event`.
|
||||
##
|
||||
## ev: an event originally given to :bro:see:`BrokerComm::auto_event`.
|
||||
## ev: an event originally given to :bro:see:`Broker::auto_event`.
|
||||
##
|
||||
## Returns: true if automatic events will not occur for the topic/event pair.
|
||||
function BrokerComm::auto_event_stop%(topic: string, ev: any%): bool
|
||||
function Broker::auto_event_stop%(topic: string, ev: any%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->AutoEventStop(topic->CheckString(), ev);
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -129,7 +129,7 @@ function BrokerComm::auto_event_stop%(topic: string, ev: any%): bool
|
|||
## "alice" and "amy" but not "bob".
|
||||
##
|
||||
## Returns: true if it's a new event subscription and it is now registered.
|
||||
function BrokerComm::subscribe_to_events%(topic_prefix: string%): bool
|
||||
function Broker::subscribe_to_events%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->SubscribeToEvents(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -138,10 +138,10 @@ function BrokerComm::subscribe_to_events%(topic_prefix: string%): bool
|
|||
## Unregister interest in all peer event messages that use a topic prefix.
|
||||
##
|
||||
## topic_prefix: a prefix previously supplied to a successful call to
|
||||
## :bro:see:`BrokerComm::subscribe_to_events`.
|
||||
## :bro:see:`Broker::subscribe_to_events`.
|
||||
##
|
||||
## Returns: true if interest in the topic prefix is no longer advertised.
|
||||
function BrokerComm::unsubscribe_to_events%(topic_prefix: string%): bool
|
||||
function Broker::unsubscribe_to_events%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->UnsubscribeToEvents(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -155,7 +155,7 @@ function BrokerComm::unsubscribe_to_events%(topic_prefix: string%): bool
|
|||
##
|
||||
## Returns: true if remote logs are enabled for the stream.
|
||||
function
|
||||
BrokerComm::enable_remote_logs%(id: Log::ID,
|
||||
Broker::enable_remote_logs%(id: Log::ID,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = log_mgr->EnableRemoteLogs(id->AsEnumVal(),
|
||||
|
@ -168,7 +168,7 @@ BrokerComm::enable_remote_logs%(id: Log::ID,
|
|||
## id: the log stream to disable remote logs for.
|
||||
##
|
||||
## Returns: true if remote logs are disabled for the stream.
|
||||
function BrokerComm::disable_remote_logs%(id: Log::ID%): bool
|
||||
function Broker::disable_remote_logs%(id: Log::ID%): bool
|
||||
%{
|
||||
auto rval = log_mgr->DisableRemoteLogs(id->AsEnumVal());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -179,7 +179,7 @@ function BrokerComm::disable_remote_logs%(id: Log::ID%): bool
|
|||
## id: the log stream to check.
|
||||
##
|
||||
## Returns: true if remote logs are enabled for the given stream.
|
||||
function BrokerComm::remote_logs_enabled%(id: Log::ID%): bool
|
||||
function Broker::remote_logs_enabled%(id: Log::ID%): bool
|
||||
%{
|
||||
auto rval = log_mgr->RemoteLogsAreEnabled(id->AsEnumVal());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -194,7 +194,7 @@ function BrokerComm::remote_logs_enabled%(id: Log::ID%): bool
|
|||
## "alice" and "amy" but not "bob".
|
||||
##
|
||||
## Returns: true if it's a new log subscription and it is now registered.
|
||||
function BrokerComm::subscribe_to_logs%(topic_prefix: string%): bool
|
||||
function Broker::subscribe_to_logs%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->SubscribeToLogs(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -205,10 +205,10 @@ function BrokerComm::subscribe_to_logs%(topic_prefix: string%): bool
|
|||
## receiving side processes them through the logging framework as usual.
|
||||
##
|
||||
## topic_prefix: a prefix previously supplied to a successful call to
|
||||
## :bro:see:`BrokerComm::subscribe_to_logs`.
|
||||
## :bro:see:`Broker::subscribe_to_logs`.
|
||||
##
|
||||
## Returns: true if interest in the topic prefix is no longer advertised.
|
||||
function BrokerComm::unsubscribe_to_logs%(topic_prefix: string%): bool
|
||||
function Broker::unsubscribe_to_logs%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = broker_mgr->UnsubscribeToLogs(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
#include "Trigger.h"
|
||||
%%}
|
||||
|
||||
module BrokerStore;
|
||||
module Broker;
|
||||
|
||||
type BrokerStore::ExpiryTime: record;
|
||||
type Broker::ExpiryTime: record;
|
||||
|
||||
type BrokerStore::QueryResult: record;
|
||||
type Broker::QueryResult: record;
|
||||
|
||||
type BrokerStore::BackendOptions: record;
|
||||
type Broker::BackendOptions: record;
|
||||
|
||||
## Enumerates the possible storage backends.
|
||||
enum BackendType %{
|
||||
|
@ -32,8 +32,8 @@ enum BackendType %{
|
|||
## options: tunes how some storage backends operate.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function BrokerStore::create_master%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of BrokerStore::Handle
|
||||
function Broker::create_master%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of Broker::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = bro_broker::StoreType::MASTER;
|
||||
|
@ -46,7 +46,7 @@ function BrokerStore::create_master%(id: string, b: BackendType &default = MEMOR
|
|||
}
|
||||
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::BrokerStore::BackendType>(b->AsEnum()),
|
||||
static_cast<BifEnum::Broker::BackendType>(b->AsEnum()),
|
||||
options->AsRecordVal());
|
||||
auto added = broker_mgr->AddStore(rval);
|
||||
assert(added);
|
||||
|
@ -75,9 +75,9 @@ function BrokerStore::create_master%(id: string, b: BackendType &default = MEMOR
|
|||
## but updates will be lost until the master is once again available.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY,
|
||||
function Broker::create_clone%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions(),
|
||||
resync: interval &default = 1sec%): opaque of BrokerStore::Handle
|
||||
resync: interval &default = 1sec%): opaque of Broker::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = bro_broker::StoreType::CLONE;
|
||||
|
@ -90,7 +90,7 @@ function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY
|
|||
}
|
||||
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::BrokerStore::BackendType>(b->AsEnum()),
|
||||
static_cast<BifEnum::Broker::BackendType>(b->AsEnum()),
|
||||
options->AsRecordVal(),
|
||||
std::chrono::duration<double>(resync));
|
||||
auto added = broker_mgr->AddStore(rval);
|
||||
|
@ -104,7 +104,7 @@ function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY
|
|||
## id: the unique name which identifies the master data store.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function BrokerStore::create_frontend%(id: string%): opaque of BrokerStore::Handle
|
||||
function Broker::create_frontend%(id: string%): opaque of Broker::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = bro_broker::StoreType::FRONTEND;
|
||||
|
@ -128,7 +128,7 @@ function BrokerStore::create_frontend%(id: string%): opaque of BrokerStore::Hand
|
|||
##
|
||||
## Returns: true if store was valid and is now closed. The handle can no
|
||||
## longer be used for data store operations.
|
||||
function BrokerStore::close_by_handle%(h: opaque of BrokerStore::Handle%): bool
|
||||
function Broker::close_by_handle%(h: opaque of Broker::Handle%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -154,9 +154,9 @@ function BrokerStore::close_by_handle%(h: opaque of BrokerStore::Handle%): bool
|
|||
## e: the expiration time of the key-value pair.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::insert%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, v: BrokerComm::Data,
|
||||
e: BrokerStore::ExpiryTime &default = BrokerStore::ExpiryTime()%): bool
|
||||
function Broker::insert%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, v: Broker::Data,
|
||||
e: Broker::ExpiryTime &default = Broker::ExpiryTime()%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -198,7 +198,7 @@ function BrokerStore::insert%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key to remove.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::erase%(h: opaque of BrokerStore::Handle, k: BrokerComm::Data%): bool
|
||||
function Broker::erase%(h: opaque of Broker::Handle, k: Broker::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -215,7 +215,7 @@ function BrokerStore::erase%(h: opaque of BrokerStore::Handle, k: BrokerComm::Da
|
|||
## h: the handle of the store to modify.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::clear%(h: opaque of BrokerStore::Handle%): bool
|
||||
function Broker::clear%(h: opaque of Broker::Handle%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -236,8 +236,8 @@ function BrokerStore::clear%(h: opaque of BrokerStore::Handle%): bool
|
|||
## create it with an implicit value of zero before incrementing.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::increment%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, by: int &default = +1%): bool
|
||||
function Broker::increment%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, by: int &default = +1%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -259,8 +259,8 @@ function BrokerStore::increment%(h: opaque of BrokerStore::Handle,
|
|||
## create it with an implicit value of zero before decrementing.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::decrement%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, by: int &default = +1%): bool
|
||||
function Broker::decrement%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, by: int &default = +1%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -282,8 +282,8 @@ function BrokerStore::decrement%(h: opaque of BrokerStore::Handle,
|
|||
## create it with an implicit empty set value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::add_to_set%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, element: BrokerComm::Data%): bool
|
||||
function Broker::add_to_set%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, element: Broker::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -306,8 +306,8 @@ function BrokerStore::add_to_set%(h: opaque of BrokerStore::Handle,
|
|||
## implicitly create an empty set value associated with the key.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::remove_from_set%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, element: BrokerComm::Data%): bool
|
||||
function Broker::remove_from_set%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data, element: Broker::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -330,8 +330,8 @@ function BrokerStore::remove_from_set%(h: opaque of BrokerStore::Handle,
|
|||
## create an empty vector value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::push_left%(h: opaque of BrokerStore::Handle, k: BrokerComm::Data,
|
||||
items: BrokerComm::DataVector%): bool
|
||||
function Broker::push_left%(h: opaque of Broker::Handle, k: Broker::Data,
|
||||
items: Broker::DataVector%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -363,8 +363,8 @@ function BrokerStore::push_left%(h: opaque of BrokerStore::Handle, k: BrokerComm
|
|||
## create an empty vector value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function BrokerStore::push_right%(h: opaque of BrokerStore::Handle, k: BrokerComm::Data,
|
||||
items: BrokerComm::DataVector%): bool
|
||||
function Broker::push_right%(h: opaque of Broker::Handle, k: Broker::Data,
|
||||
items: Broker::DataVector%): bool
|
||||
%{
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
|
@ -401,7 +401,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( ! (*handle)->store )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("BrokerStore query has an invalid data store");
|
||||
reporter->Error("Broker query has an invalid data store");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( ! trigger )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("BrokerStore queries can only be called inside when-condition");
|
||||
reporter->Error("Broker queries can only be called inside when-condition");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( *timeout < 0 )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("BrokerStore queries must specify a timeout block");
|
||||
reporter->Error("Broker queries must specify a timeout block");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -444,8 +444,8 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
## k: the key associated with the vector to modify.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function BrokerStore::pop_left%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
function Broker::pop_left%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -474,8 +474,8 @@ function BrokerStore::pop_left%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key associated with the vector to modify.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function BrokerStore::pop_right%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
function Broker::pop_right%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -504,8 +504,8 @@ function BrokerStore::pop_right%(h: opaque of BrokerStore::Handle,
|
|||
## k: the key to lookup.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function BrokerStore::lookup%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
function Broker::lookup%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -533,9 +533,9 @@ function BrokerStore::lookup%(h: opaque of BrokerStore::Handle,
|
|||
##
|
||||
## k: the key to check for existence.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`BrokerComm::BOOL`).
|
||||
function BrokerStore::exists%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
## Returns: the result of the query (uses :bro:see:`Broker::BOOL`).
|
||||
function Broker::exists%(h: opaque of Broker::Handle,
|
||||
k: Broker::Data%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
@ -561,8 +561,8 @@ function BrokerStore::exists%(h: opaque of BrokerStore::Handle,
|
|||
##
|
||||
## h: the handle of the store to query.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`BrokerComm::VECTOR`).
|
||||
function BrokerStore::keys%(h: opaque of BrokerStore::Handle%): BrokerStore::QueryResult
|
||||
## Returns: the result of the query (uses :bro:see:`Broker::VECTOR`).
|
||||
function Broker::keys%(h: opaque of Broker::Handle%): Broker::QueryResult
|
||||
%{
|
||||
double timeout;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
|
@ -579,8 +579,8 @@ function BrokerStore::keys%(h: opaque of BrokerStore::Handle%): BrokerStore::Que
|
|||
##
|
||||
## h: the handle of the store to query.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`BrokerComm::COUNT`).
|
||||
function BrokerStore::size%(h: opaque of BrokerStore::Handle%): BrokerStore::QueryResult
|
||||
## Returns: the result of the query (uses :bro:see:`Broker::COUNT`).
|
||||
function Broker::size%(h: opaque of Broker::Handle%): Broker::QueryResult
|
||||
%{
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
clone keys, [status=BrokerStore::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, myset, [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, two, [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myvec, [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
clone keys, [status=Broker::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, two, [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, one, [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, myvec, [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
lookup, myset, [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
BrokerComm::incoming_connection_established, connector
|
||||
BrokerComm::incoming_connection_broken, connector
|
||||
Broker::incoming_connection_established, connector
|
||||
Broker::incoming_connection_broken, connector
|
||||
|
|
|
@ -1 +1 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp, listener
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp, listener
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
BrokerComm::BOOL
|
||||
BrokerComm::INT
|
||||
BrokerComm::COUNT
|
||||
BrokerComm::DOUBLE
|
||||
BrokerComm::STRING
|
||||
BrokerComm::ADDR
|
||||
BrokerComm::SUBNET
|
||||
BrokerComm::PORT
|
||||
BrokerComm::TIME
|
||||
BrokerComm::INTERVAL
|
||||
BrokerComm::ENUM
|
||||
BrokerComm::SET
|
||||
BrokerComm::TABLE
|
||||
BrokerComm::VECTOR
|
||||
BrokerComm::RECORD
|
||||
Broker::BOOL
|
||||
Broker::INT
|
||||
Broker::COUNT
|
||||
Broker::DOUBLE
|
||||
Broker::STRING
|
||||
Broker::ADDR
|
||||
Broker::SUBNET
|
||||
Broker::PORT
|
||||
Broker::TIME
|
||||
Broker::INTERVAL
|
||||
Broker::ENUM
|
||||
Broker::SET
|
||||
Broker::TABLE
|
||||
Broker::VECTOR
|
||||
Broker::RECORD
|
||||
***************************
|
||||
T
|
||||
F
|
||||
|
@ -29,7 +29,7 @@ hello
|
|||
22/tcp
|
||||
42.0
|
||||
180.0
|
||||
BrokerComm::BOOL
|
||||
Broker::BOOL
|
||||
***************************
|
||||
{
|
||||
two,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
lookup(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=BrokerStore::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=BrokerStore::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=BrokerStore::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
lookup(two): [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(myset): [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
lookup(four): [status=Broker::SUCCESS, result=[d=<uninitialized>]]
|
||||
exists(two): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(one): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_left(myvec): [status=Broker::SUCCESS, result=[d=broker::data{delta}]]
|
||||
pop_right(myvec): [status=Broker::SUCCESS, result=[d=broker::data{omega}]]
|
||||
keys: [status=Broker::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=Broker::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
got event msg, pong, 0
|
||||
got auto event msg, ping, 0
|
||||
got event msg, pong, 1
|
||||
|
|
|
@ -1 +1 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
got print msg, pong 0
|
||||
got print msg, pong 1
|
||||
got print msg, pong 2
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
clone keys, [status=BrokerStore::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, two, [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myset, [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, myvec, [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
clone keys, [status=Broker::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, two, [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myset, [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, myvec, [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
BrokerComm::BOOL
|
||||
BrokerComm::INT
|
||||
BrokerComm::COUNT
|
||||
BrokerComm::DOUBLE
|
||||
BrokerComm::STRING
|
||||
BrokerComm::ADDR
|
||||
BrokerComm::SUBNET
|
||||
BrokerComm::PORT
|
||||
BrokerComm::TIME
|
||||
BrokerComm::INTERVAL
|
||||
BrokerComm::ENUM
|
||||
BrokerComm::SET
|
||||
BrokerComm::TABLE
|
||||
BrokerComm::VECTOR
|
||||
BrokerComm::RECORD
|
||||
Broker::BOOL
|
||||
Broker::INT
|
||||
Broker::COUNT
|
||||
Broker::DOUBLE
|
||||
Broker::STRING
|
||||
Broker::ADDR
|
||||
Broker::SUBNET
|
||||
Broker::PORT
|
||||
Broker::TIME
|
||||
Broker::INTERVAL
|
||||
Broker::ENUM
|
||||
Broker::SET
|
||||
Broker::TABLE
|
||||
Broker::VECTOR
|
||||
Broker::RECORD
|
||||
***************************
|
||||
T
|
||||
F
|
||||
|
@ -29,7 +29,7 @@ hello
|
|||
22/tcp
|
||||
42.0
|
||||
180.0
|
||||
BrokerComm::BOOL
|
||||
Broker::BOOL
|
||||
***************************
|
||||
{
|
||||
two,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
lookup(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=BrokerStore::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=BrokerStore::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=BrokerStore::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=BrokerStore::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=BrokerStore::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=BrokerStore::SUCCESS, result=[d=broker::data{0}]]
|
||||
lookup(two): [status=Broker::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=Broker::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=Broker::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=Broker::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=Broker::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=Broker::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=Broker::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=Broker::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=Broker::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=Broker::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=Broker::SUCCESS, result=[d=broker::data{0}]]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
got event msg, pong, 0
|
||||
got auto event msg, ping, 0
|
||||
got event msg, pong, 1
|
||||
|
|
|
@ -1 +1 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
got print msg, pong 0
|
||||
got print msg, pong 1
|
||||
got print msg, pong 2
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#empty_field (empty)
|
||||
#unset_field -
|
||||
#path loaded_scripts
|
||||
#open 2016-04-13-04-57-15
|
||||
#open 2016-04-22-23-21-01
|
||||
#fields name
|
||||
#types string
|
||||
scripts/base/init-bare.bro
|
||||
|
@ -17,6 +17,7 @@ scripts/base/init-bare.bro
|
|||
build/scripts/base/bif/event.bif.bro
|
||||
scripts/base/frameworks/broker/__load__.bro
|
||||
scripts/base/frameworks/broker/main.bro
|
||||
scripts/base/frameworks/broker/store.bro
|
||||
scripts/base/frameworks/logging/__load__.bro
|
||||
scripts/base/frameworks/logging/main.bro
|
||||
build/scripts/base/bif/logging.bif.bro
|
||||
|
@ -130,4 +131,4 @@ scripts/base/init-bare.bro
|
|||
build/scripts/base/bif/plugins/Bro_SQLiteWriter.sqlite.bif.bro
|
||||
scripts/policy/misc/loaded-scripts.bro
|
||||
scripts/base/utils/paths.bro
|
||||
#close 2016-04-13-04-57-15
|
||||
#close 2016-04-22-23-21-01
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#empty_field (empty)
|
||||
#unset_field -
|
||||
#path loaded_scripts
|
||||
#open 2016-04-13-04-57-25
|
||||
#open 2016-04-22-23-21-18
|
||||
#fields name
|
||||
#types string
|
||||
scripts/base/init-bare.bro
|
||||
|
@ -17,6 +17,7 @@ scripts/base/init-bare.bro
|
|||
build/scripts/base/bif/event.bif.bro
|
||||
scripts/base/frameworks/broker/__load__.bro
|
||||
scripts/base/frameworks/broker/main.bro
|
||||
scripts/base/frameworks/broker/store.bro
|
||||
scripts/base/frameworks/logging/__load__.bro
|
||||
scripts/base/frameworks/logging/main.bro
|
||||
build/scripts/base/bif/logging.bif.bro
|
||||
|
@ -301,4 +302,4 @@ scripts/base/init-default.bro
|
|||
scripts/base/misc/find-checksum-offloading.bro
|
||||
scripts/base/misc/find-filtered-trace.bro
|
||||
scripts/policy/misc/loaded-scripts.bro
|
||||
#close 2016-04-13-04-57-25
|
||||
#close 2016-04-22-23-21-18
|
||||
|
|
|
@ -4,19 +4,19 @@ connecting-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,21 +4,21 @@ connecting-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
event Broker::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;
|
||||
print "Broker::incoming_connection_broken", peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,31 +4,31 @@ events-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "hi", 0));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "hi", 0));
|
||||
event my_auto_event("stuff", 88);
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "...", 1));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "...", 1));
|
||||
event my_auto_event("more stuff", 51);
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "bye", 2));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "bye", 2));
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -4,21 +4,21 @@ events-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event my_event(msg: string, c: count)
|
||||
|
|
|
@ -6,16 +6,16 @@ logs-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
redef Log::enable_local_logging = F;
|
||||
redef Log::enable_remote_logging = F;
|
||||
global n = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::enable_remote_logs(Test::LOG);
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event do_write()
|
||||
|
@ -28,16 +28,16 @@ event do_write()
|
|||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -6,18 +6,18 @@ logs-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_logs("bro/log/Test::LOG");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
|
|
@ -4,26 +4,26 @@ printing-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
BrokerComm::print("bro/print/hi", "hello");
|
||||
BrokerComm::print("bro/print/stuff", "...");
|
||||
BrokerComm::print("bro/print/bye", "goodbye");
|
||||
Broker::print("bro/print/hi", "hello");
|
||||
Broker::print("bro/print/stuff", "...");
|
||||
Broker::print("bro/print/bye", "goodbye");
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -4,22 +4,22 @@ printing-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_prints("bro/print/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++msg_count;
|
||||
print "got print message", msg;
|
||||
|
|
|
@ -5,42 +5,42 @@ stores-connector.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
@ -51,7 +51,7 @@ event BrokerComm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ stores-listener.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -25,15 +25,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 0)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 1)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 2)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 3)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 1)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 2)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 3)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -41,7 +41,7 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/ready");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test, $path="test"]);
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@
|
|||
0.000000 MetaHookPost CallFunction(Log::__create_stream, <frame>, (Weird::LOG, [columns=<no value description>, ev=Weird::log_weird, path=weird])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::__create_stream, <frame>, (X509::LOG, [columns=<no value description>, ev=X509::log_x509, path=x509])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::__create_stream, <frame>, (mysql::LOG, [columns=<no value description>, ev=MySQL::log_mysql, path=mysql])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::__write, <frame>, (PacketFilter::LOG, [ts=1460523470.220624, node=bro, filter=ip or not ip, init=T, success=T])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::__write, <frame>, (PacketFilter::LOG, [ts=1461367323.154279, node=bro, filter=ip or not ip, init=T, success=T])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::add_default_filter, <frame>, (Cluster::LOG)) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::add_default_filter, <frame>, (Communication::LOG)) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::add_default_filter, <frame>, (Conn::LOG)) -> <no result>
|
||||
|
@ -351,7 +351,7 @@
|
|||
0.000000 MetaHookPost CallFunction(Log::create_stream, <frame>, (Weird::LOG, [columns=<no value description>, ev=Weird::log_weird, path=weird])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::create_stream, <frame>, (X509::LOG, [columns=<no value description>, ev=X509::log_x509, path=x509])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::create_stream, <frame>, (mysql::LOG, [columns=<no value description>, ev=MySQL::log_mysql, path=mysql])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::write, <frame>, (PacketFilter::LOG, [ts=1460523470.220624, node=bro, filter=ip or not ip, init=T, success=T])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Log::write, <frame>, (PacketFilter::LOG, [ts=1461367323.154279, node=bro, filter=ip or not ip, init=T, success=T])) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(NetControl::check_plugins, <frame>, ()) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(NetControl::init, <null>, ()) -> <no result>
|
||||
0.000000 MetaHookPost CallFunction(Notice::want_pp, <frame>, ()) -> <no result>
|
||||
|
@ -524,6 +524,7 @@
|
|||
0.000000 MetaHookPost LoadFile(./shunt) -> -1
|
||||
0.000000 MetaHookPost LoadFile(./site) -> -1
|
||||
0.000000 MetaHookPost LoadFile(./std-dev) -> -1
|
||||
0.000000 MetaHookPost LoadFile(./store) -> -1
|
||||
0.000000 MetaHookPost LoadFile(./store.bif.bro) -> -1
|
||||
0.000000 MetaHookPost LoadFile(./strings.bif.bro) -> -1
|
||||
0.000000 MetaHookPost LoadFile(./sum) -> -1
|
||||
|
@ -869,7 +870,7 @@
|
|||
0.000000 MetaHookPre CallFunction(Log::__create_stream, <frame>, (Weird::LOG, [columns=<no value description>, ev=Weird::log_weird, path=weird]))
|
||||
0.000000 MetaHookPre CallFunction(Log::__create_stream, <frame>, (X509::LOG, [columns=<no value description>, ev=X509::log_x509, path=x509]))
|
||||
0.000000 MetaHookPre CallFunction(Log::__create_stream, <frame>, (mysql::LOG, [columns=<no value description>, ev=MySQL::log_mysql, path=mysql]))
|
||||
0.000000 MetaHookPre CallFunction(Log::__write, <frame>, (PacketFilter::LOG, [ts=1460523470.220624, node=bro, filter=ip or not ip, init=T, success=T]))
|
||||
0.000000 MetaHookPre CallFunction(Log::__write, <frame>, (PacketFilter::LOG, [ts=1461367323.154279, node=bro, filter=ip or not ip, init=T, success=T]))
|
||||
0.000000 MetaHookPre CallFunction(Log::add_default_filter, <frame>, (Cluster::LOG))
|
||||
0.000000 MetaHookPre CallFunction(Log::add_default_filter, <frame>, (Communication::LOG))
|
||||
0.000000 MetaHookPre CallFunction(Log::add_default_filter, <frame>, (Conn::LOG))
|
||||
|
@ -990,7 +991,7 @@
|
|||
0.000000 MetaHookPre CallFunction(Log::create_stream, <frame>, (Weird::LOG, [columns=<no value description>, ev=Weird::log_weird, path=weird]))
|
||||
0.000000 MetaHookPre CallFunction(Log::create_stream, <frame>, (X509::LOG, [columns=<no value description>, ev=X509::log_x509, path=x509]))
|
||||
0.000000 MetaHookPre CallFunction(Log::create_stream, <frame>, (mysql::LOG, [columns=<no value description>, ev=MySQL::log_mysql, path=mysql]))
|
||||
0.000000 MetaHookPre CallFunction(Log::write, <frame>, (PacketFilter::LOG, [ts=1460523470.220624, node=bro, filter=ip or not ip, init=T, success=T]))
|
||||
0.000000 MetaHookPre CallFunction(Log::write, <frame>, (PacketFilter::LOG, [ts=1461367323.154279, node=bro, filter=ip or not ip, init=T, success=T]))
|
||||
0.000000 MetaHookPre CallFunction(NetControl::check_plugins, <frame>, ())
|
||||
0.000000 MetaHookPre CallFunction(NetControl::init, <null>, ())
|
||||
0.000000 MetaHookPre CallFunction(Notice::want_pp, <frame>, ())
|
||||
|
@ -1163,6 +1164,7 @@
|
|||
0.000000 MetaHookPre LoadFile(./shunt)
|
||||
0.000000 MetaHookPre LoadFile(./site)
|
||||
0.000000 MetaHookPre LoadFile(./std-dev)
|
||||
0.000000 MetaHookPre LoadFile(./store)
|
||||
0.000000 MetaHookPre LoadFile(./store.bif.bro)
|
||||
0.000000 MetaHookPre LoadFile(./strings.bif.bro)
|
||||
0.000000 MetaHookPre LoadFile(./sum)
|
||||
|
@ -1507,7 +1509,7 @@
|
|||
0.000000 | HookCallFunction Log::__create_stream(Weird::LOG, [columns=<no value description>, ev=Weird::log_weird, path=weird])
|
||||
0.000000 | HookCallFunction Log::__create_stream(X509::LOG, [columns=<no value description>, ev=X509::log_x509, path=x509])
|
||||
0.000000 | HookCallFunction Log::__create_stream(mysql::LOG, [columns=<no value description>, ev=MySQL::log_mysql, path=mysql])
|
||||
0.000000 | HookCallFunction Log::__write(PacketFilter::LOG, [ts=1460523470.220624, node=bro, filter=ip or not ip, init=T, success=T])
|
||||
0.000000 | HookCallFunction Log::__write(PacketFilter::LOG, [ts=1461367323.154279, node=bro, filter=ip or not ip, init=T, success=T])
|
||||
0.000000 | HookCallFunction Log::add_default_filter(Cluster::LOG)
|
||||
0.000000 | HookCallFunction Log::add_default_filter(Communication::LOG)
|
||||
0.000000 | HookCallFunction Log::add_default_filter(Conn::LOG)
|
||||
|
@ -1628,7 +1630,7 @@
|
|||
0.000000 | HookCallFunction Log::create_stream(Weird::LOG, [columns=<no value description>, ev=Weird::log_weird, path=weird])
|
||||
0.000000 | HookCallFunction Log::create_stream(X509::LOG, [columns=<no value description>, ev=X509::log_x509, path=x509])
|
||||
0.000000 | HookCallFunction Log::create_stream(mysql::LOG, [columns=<no value description>, ev=MySQL::log_mysql, path=mysql])
|
||||
0.000000 | HookCallFunction Log::write(PacketFilter::LOG, [ts=1460523470.220624, node=bro, filter=ip or not ip, init=T, success=T])
|
||||
0.000000 | HookCallFunction Log::write(PacketFilter::LOG, [ts=1461367323.154279, node=bro, filter=ip or not ip, init=T, success=T])
|
||||
0.000000 | HookCallFunction NetControl::check_plugins()
|
||||
0.000000 | HookCallFunction NetControl::init()
|
||||
0.000000 | HookCallFunction Notice::want_pp()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::incoming_connection_established
|
||||
Broker::incoming_connection_established
|
||||
add_rule, 0, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=192.168.18.50/32, src_p=<uninitialized>, dst_h=74.125.239.97/32, dst_p=<uninitialized>, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP, [command=blockhosthost, cookie=2, arg=192.168.18.50 74.125.239.97, comment=here]
|
||||
add_rule, 0, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=<uninitialized>, src_p=<uninitialized>, dst_h=<uninitialized>, dst_p=443/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP, [command=droptcpport, cookie=3, arg=443, comment=there]
|
||||
add_rule, 0, [ty=NetControl::ADDRESS, conn=<uninitialized>, flow=<uninitialized>, ip=192.168.18.50/32, mac=<uninitialized>], NetControl::DROP, [command=nullzero, cookie=4, arg=192.168.18.50/32, comment=]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
rule added, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=192.168.18.50/32, src_p=<uninitialized>, dst_h=74.125.239.97/32, dst_p=<uninitialized>, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
rule added, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=<uninitialized>, src_p=<uninitialized>, dst_h=<uninitialized>, dst_p=443/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
rule added, [ty=NetControl::ADDRESS, conn=<uninitialized>, flow=<uninitialized>, ip=192.168.18.50/32, mac=<uninitialized>], NetControl::DROP
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::incoming_connection_established
|
||||
Broker::incoming_connection_established
|
||||
add_rule, 0, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=192.168.18.50/32, src_p=<uninitialized>, dst_h=74.125.239.97/32, dst_p=<uninitialized>, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP, [command=blockhosthost, cookie=2, arg=192.168.18.50 74.125.239.97, comment=here]
|
||||
add_rule, 0, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=<uninitialized>, src_p=<uninitialized>, dst_h=<uninitialized>, dst_p=443/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP, [command=droptcpport, cookie=3, arg=443, comment=there]
|
||||
add_rule, 0, [ty=NetControl::ADDRESS, conn=<uninitialized>, flow=<uninitialized>, ip=192.168.18.50/32, mac=<uninitialized>], NetControl::DROP, [command=drop, cookie=4, arg=192.168.18.50/32, comment=]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
rule added, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=192.168.18.50/32, src_p=<uninitialized>, dst_h=74.125.239.97/32, dst_p=<uninitialized>, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
rule added, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=<uninitialized>, src_p=<uninitialized>, dst_h=<uninitialized>, dst_p=443/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
rule added, [ty=NetControl::ADDRESS, conn=<uninitialized>, flow=<uninitialized>, ip=192.168.18.50/32, mac=<uninitialized>], NetControl::DROP
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::incoming_connection_established
|
||||
Broker::incoming_connection_established
|
||||
add_rule, 0, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=10.10.1.4/32, src_p=1470/tcp, dst_h=74.53.140.153/32, dst_p=25/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
add_rule, 0, [ty=NetControl::ADDRESS, conn=<uninitialized>, flow=<uninitialized>, ip=10.10.1.4/32, mac=<uninitialized>], NetControl::DROP
|
||||
remove_rule, 0, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=10.10.1.4/32, src_p=1470/tcp, dst_h=74.53.140.153/32, dst_p=25/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
rule added, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=10.10.1.4/32, src_p=1470/tcp, dst_h=74.53.140.153/32, dst_p=25/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP
|
||||
rule added, [ty=NetControl::ADDRESS, conn=<uninitialized>, flow=<uninitialized>, ip=10.10.1.4/32, mac=<uninitialized>], NetControl::DROP
|
||||
rule timeout, [ty=NetControl::FLOW, conn=<uninitialized>, flow=[src_h=10.10.1.4/32, src_p=1470/tcp, dst_h=74.53.140.153/32, dst_p=25/tcp, src_m=<uninitialized>, dst_m=<uninitialized>], ip=<uninitialized>, mac=<uninitialized>], NetControl::DROP, [duration=<uninitialized>, packet_count=<uninitialized>, byte_count=<uninitialized>]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::incoming_connection_established
|
||||
Broker::incoming_connection_established
|
||||
flow_clear, 42
|
||||
got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=<uninitialized>, nw_tos=<uninitialized>, nw_proto=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>], [cookie=4398046511105, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=0, hard_timeout=0, priority=0, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[3, 7], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]]
|
||||
got flow_mod, 42, [in_port=<uninitialized>, dl_src=<uninitialized>, dl_dst=<uninitialized>, dl_vlan=<uninitialized>, dl_vlan_pcp=<uninitialized>, dl_type=2048, nw_tos=<uninitialized>, nw_proto=6, nw_src=10.10.1.4/32, nw_dst=74.53.140.153/32, tp_src=1470, tp_dst=25], [cookie=4398046511146, table_id=<uninitialized>, command=OpenFlow::OFPFC_ADD, idle_timeout=30, hard_timeout=0, priority=5, out_port=<uninitialized>, out_group=<uninitialized>, flags=0, actions=[out_ports=[], vlan_vid=<uninitialized>, vlan_pcp=<uninitialized>, vlan_strip=F, dl_src=<uninitialized>, dl_dst=<uninitialized>, nw_tos=<uninitialized>, nw_src=<uninitialized>, nw_dst=<uninitialized>, tp_src=<uninitialized>, tp_dst=<uninitialized>]]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Broker::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
Flow_mod_success
|
||||
Flow_mod_failure
|
||||
connection established
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
|
@ -21,7 +21,7 @@ global query_timeout = 30sec;
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -38,15 +38,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 0)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 1)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 2)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 3)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 1)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 2)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 3)));
|
||||
}
|
||||
timeout query_timeout
|
||||
{
|
||||
|
@ -57,9 +57,9 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/ready");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
@ -71,42 +71,42 @@ global query_timeout = 15sec;
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{ event ready(); }
|
||||
timeout query_timeout
|
||||
{
|
||||
|
@ -117,9 +117,9 @@ event BrokerComm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable();
|
||||
Broker::auto_event("bro/event/ready", ready);
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
|
|
@ -12,22 +12,22 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;;
|
||||
print "Broker::incoming_connection_established", peer_name;;
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
event Broker::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;;
|
||||
print "Broker::incoming_connection_broken", peer_name;;
|
||||
terminate();
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,19 @@ event BrokerComm::incoming_connection_broken(peer_name: string)
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -13,210 +13,210 @@ type bro_record : record {
|
|||
c: count;
|
||||
};
|
||||
|
||||
function comm_record_to_bro_record_recurse(it: opaque of BrokerComm::RecordIterator,
|
||||
function comm_record_to_bro_record_recurse(it: opaque of Broker::RecordIterator,
|
||||
rval: bro_record,
|
||||
idx: count): bro_record
|
||||
{
|
||||
if ( BrokerComm::record_iterator_last(it) )
|
||||
if ( Broker::record_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
local field_value = BrokerComm::record_iterator_value(it);
|
||||
local field_value = Broker::record_iterator_value(it);
|
||||
|
||||
if ( field_value?$d )
|
||||
switch ( idx ) {
|
||||
case 0:
|
||||
rval$a = BrokerComm::refine_to_string(field_value);
|
||||
rval$a = Broker::refine_to_string(field_value);
|
||||
break;
|
||||
case 1:
|
||||
rval$b = BrokerComm::refine_to_string(field_value);
|
||||
rval$b = Broker::refine_to_string(field_value);
|
||||
break;
|
||||
case 2:
|
||||
rval$c = BrokerComm::refine_to_count(field_value);
|
||||
rval$c = Broker::refine_to_count(field_value);
|
||||
break;
|
||||
};
|
||||
|
||||
++idx;
|
||||
BrokerComm::record_iterator_next(it);
|
||||
Broker::record_iterator_next(it);
|
||||
return comm_record_to_bro_record_recurse(it, rval, idx);
|
||||
}
|
||||
|
||||
function comm_record_to_bro_record(d: BrokerComm::Data): bro_record
|
||||
function comm_record_to_bro_record(d: Broker::Data): bro_record
|
||||
{
|
||||
return comm_record_to_bro_record_recurse(BrokerComm::record_iterator(d),
|
||||
return comm_record_to_bro_record_recurse(Broker::record_iterator(d),
|
||||
bro_record($c = 0), 0);
|
||||
}
|
||||
|
||||
function
|
||||
comm_set_to_bro_set_recurse(it: opaque of BrokerComm::SetIterator,
|
||||
comm_set_to_bro_set_recurse(it: opaque of Broker::SetIterator,
|
||||
rval: bro_set): bro_set
|
||||
{
|
||||
if ( BrokerComm::set_iterator_last(it) )
|
||||
if ( Broker::set_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
add rval[BrokerComm::refine_to_string(BrokerComm::set_iterator_value(it))];
|
||||
BrokerComm::set_iterator_next(it);
|
||||
add rval[Broker::refine_to_string(Broker::set_iterator_value(it))];
|
||||
Broker::set_iterator_next(it);
|
||||
return comm_set_to_bro_set_recurse(it, rval);
|
||||
}
|
||||
|
||||
|
||||
function comm_set_to_bro_set(d: BrokerComm::Data): bro_set
|
||||
function comm_set_to_bro_set(d: Broker::Data): bro_set
|
||||
{
|
||||
return comm_set_to_bro_set_recurse(BrokerComm::set_iterator(d), bro_set());
|
||||
return comm_set_to_bro_set_recurse(Broker::set_iterator(d), bro_set());
|
||||
}
|
||||
|
||||
function
|
||||
comm_table_to_bro_table_recurse(it: opaque of BrokerComm::TableIterator,
|
||||
comm_table_to_bro_table_recurse(it: opaque of Broker::TableIterator,
|
||||
rval: bro_table): bro_table
|
||||
{
|
||||
if ( BrokerComm::table_iterator_last(it) )
|
||||
if ( Broker::table_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
local item = BrokerComm::table_iterator_value(it);
|
||||
rval[BrokerComm::refine_to_string(item$key)] = BrokerComm::refine_to_count(item$val);
|
||||
BrokerComm::table_iterator_next(it);
|
||||
local item = Broker::table_iterator_value(it);
|
||||
rval[Broker::refine_to_string(item$key)] = Broker::refine_to_count(item$val);
|
||||
Broker::table_iterator_next(it);
|
||||
return comm_table_to_bro_table_recurse(it, rval);
|
||||
}
|
||||
|
||||
function comm_table_to_bro_table(d: BrokerComm::Data): bro_table
|
||||
function comm_table_to_bro_table(d: Broker::Data): bro_table
|
||||
{
|
||||
return comm_table_to_bro_table_recurse(BrokerComm::table_iterator(d),
|
||||
return comm_table_to_bro_table_recurse(Broker::table_iterator(d),
|
||||
bro_table());
|
||||
}
|
||||
|
||||
function comm_vector_to_bro_vector_recurse(it: opaque of BrokerComm::VectorIterator,
|
||||
function comm_vector_to_bro_vector_recurse(it: opaque of Broker::VectorIterator,
|
||||
rval: bro_vector): bro_vector
|
||||
{
|
||||
if ( BrokerComm::vector_iterator_last(it) )
|
||||
if ( Broker::vector_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
rval[|rval|] = BrokerComm::refine_to_string(BrokerComm::vector_iterator_value(it));
|
||||
BrokerComm::vector_iterator_next(it);
|
||||
rval[|rval|] = Broker::refine_to_string(Broker::vector_iterator_value(it));
|
||||
Broker::vector_iterator_next(it);
|
||||
return comm_vector_to_bro_vector_recurse(it, rval);
|
||||
}
|
||||
|
||||
function comm_vector_to_bro_vector(d: BrokerComm::Data): bro_vector
|
||||
function comm_vector_to_bro_vector(d: Broker::Data): bro_vector
|
||||
{
|
||||
return comm_vector_to_bro_vector_recurse(BrokerComm::vector_iterator(d),
|
||||
return comm_vector_to_bro_vector_recurse(Broker::vector_iterator(d),
|
||||
bro_vector());
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
print BrokerComm::data_type(BrokerComm::data(T));
|
||||
print BrokerComm::data_type(BrokerComm::data(+1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1.1));
|
||||
print BrokerComm::data_type(BrokerComm::data("1 (how creative)"));
|
||||
print BrokerComm::data_type(BrokerComm::data(1.1.1.1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1.1.1.1/1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1/udp));
|
||||
print BrokerComm::data_type(BrokerComm::data(double_to_time(1)));
|
||||
print BrokerComm::data_type(BrokerComm::data(1sec));
|
||||
print BrokerComm::data_type(BrokerComm::data(BrokerComm::BOOL));
|
||||
Broker::enable();
|
||||
print Broker::data_type(Broker::data(T));
|
||||
print Broker::data_type(Broker::data(+1));
|
||||
print Broker::data_type(Broker::data(1));
|
||||
print Broker::data_type(Broker::data(1.1));
|
||||
print Broker::data_type(Broker::data("1 (how creative)"));
|
||||
print Broker::data_type(Broker::data(1.1.1.1));
|
||||
print Broker::data_type(Broker::data(1.1.1.1/1));
|
||||
print Broker::data_type(Broker::data(1/udp));
|
||||
print Broker::data_type(Broker::data(double_to_time(1)));
|
||||
print Broker::data_type(Broker::data(1sec));
|
||||
print Broker::data_type(Broker::data(Broker::BOOL));
|
||||
local s: bro_set = bro_set("one", "two", "three");
|
||||
local t: bro_table = bro_table(["one"] = 1, ["two"] = 2, ["three"] = 3);
|
||||
local v: bro_vector = bro_vector("zero", "one", "two");
|
||||
local r: bro_record = bro_record($c = 1);
|
||||
print BrokerComm::data_type(BrokerComm::data(s));
|
||||
print BrokerComm::data_type(BrokerComm::data(t));
|
||||
print BrokerComm::data_type(BrokerComm::data(v));
|
||||
print BrokerComm::data_type(BrokerComm::data(r));
|
||||
print Broker::data_type(Broker::data(s));
|
||||
print Broker::data_type(Broker::data(t));
|
||||
print Broker::data_type(Broker::data(v));
|
||||
print Broker::data_type(Broker::data(r));
|
||||
|
||||
print "***************************";
|
||||
|
||||
print BrokerComm::refine_to_bool(BrokerComm::data(T));
|
||||
print BrokerComm::refine_to_bool(BrokerComm::data(F));
|
||||
print BrokerComm::refine_to_int(BrokerComm::data(+1));
|
||||
print BrokerComm::refine_to_int(BrokerComm::data(+0));
|
||||
print BrokerComm::refine_to_int(BrokerComm::data(-1));
|
||||
print BrokerComm::refine_to_count(BrokerComm::data(1));
|
||||
print BrokerComm::refine_to_count(BrokerComm::data(0));
|
||||
print BrokerComm::refine_to_double(BrokerComm::data(1.1));
|
||||
print BrokerComm::refine_to_double(BrokerComm::data(-11.1));
|
||||
print BrokerComm::refine_to_string(BrokerComm::data("hello"));
|
||||
print BrokerComm::refine_to_addr(BrokerComm::data(1.2.3.4));
|
||||
print BrokerComm::refine_to_subnet(BrokerComm::data(192.168.1.1/16));
|
||||
print BrokerComm::refine_to_port(BrokerComm::data(22/tcp));
|
||||
print BrokerComm::refine_to_time(BrokerComm::data(double_to_time(42)));
|
||||
print BrokerComm::refine_to_interval(BrokerComm::data(3min));
|
||||
print BrokerComm::refine_to_enum_name(BrokerComm::data(BrokerComm::BOOL));
|
||||
print Broker::refine_to_bool(Broker::data(T));
|
||||
print Broker::refine_to_bool(Broker::data(F));
|
||||
print Broker::refine_to_int(Broker::data(+1));
|
||||
print Broker::refine_to_int(Broker::data(+0));
|
||||
print Broker::refine_to_int(Broker::data(-1));
|
||||
print Broker::refine_to_count(Broker::data(1));
|
||||
print Broker::refine_to_count(Broker::data(0));
|
||||
print Broker::refine_to_double(Broker::data(1.1));
|
||||
print Broker::refine_to_double(Broker::data(-11.1));
|
||||
print Broker::refine_to_string(Broker::data("hello"));
|
||||
print Broker::refine_to_addr(Broker::data(1.2.3.4));
|
||||
print Broker::refine_to_subnet(Broker::data(192.168.1.1/16));
|
||||
print Broker::refine_to_port(Broker::data(22/tcp));
|
||||
print Broker::refine_to_time(Broker::data(double_to_time(42)));
|
||||
print Broker::refine_to_interval(Broker::data(3min));
|
||||
print Broker::refine_to_enum_name(Broker::data(Broker::BOOL));
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cs = BrokerComm::data(s);
|
||||
local cs = Broker::data(s);
|
||||
print comm_set_to_bro_set(cs);
|
||||
cs = BrokerComm::set_create();
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_insert(cs, BrokerComm::data("hi"));
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_contains(cs, BrokerComm::data("hi"));
|
||||
print BrokerComm::set_contains(cs, BrokerComm::data("bye"));
|
||||
print BrokerComm::set_insert(cs, BrokerComm::data("bye"));
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_remove(cs, BrokerComm::data("hi"));
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_remove(cs, BrokerComm::data("hi"));
|
||||
cs = Broker::set_create();
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_insert(cs, Broker::data("hi"));
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_contains(cs, Broker::data("hi"));
|
||||
print Broker::set_contains(cs, Broker::data("bye"));
|
||||
print Broker::set_insert(cs, Broker::data("bye"));
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_remove(cs, Broker::data("hi"));
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_remove(cs, Broker::data("hi"));
|
||||
print comm_set_to_bro_set(cs);
|
||||
BrokerComm::set_clear(cs);
|
||||
print BrokerComm::set_size(cs);
|
||||
Broker::set_clear(cs);
|
||||
print Broker::set_size(cs);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local ct = BrokerComm::data(t);
|
||||
local ct = Broker::data(t);
|
||||
print comm_table_to_bro_table(ct);
|
||||
ct = BrokerComm::table_create();
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::table_insert(ct, BrokerComm::data("hi"), BrokerComm::data(42));
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::table_contains(ct, BrokerComm::data("hi"));
|
||||
print BrokerComm::refine_to_count(BrokerComm::table_lookup(ct, BrokerComm::data("hi")));
|
||||
print BrokerComm::table_contains(ct, BrokerComm::data("bye"));
|
||||
print BrokerComm::table_insert(ct, BrokerComm::data("bye"), BrokerComm::data(7));
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::table_insert(ct, BrokerComm::data("bye"), BrokerComm::data(37));
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::refine_to_count(BrokerComm::table_lookup(ct, BrokerComm::data("bye")));
|
||||
print BrokerComm::table_remove(ct, BrokerComm::data("hi"));
|
||||
print BrokerComm::table_size(ct);
|
||||
ct = Broker::table_create();
|
||||
print Broker::table_size(ct);
|
||||
print Broker::table_insert(ct, Broker::data("hi"), Broker::data(42));
|
||||
print Broker::table_size(ct);
|
||||
print Broker::table_contains(ct, Broker::data("hi"));
|
||||
print Broker::refine_to_count(Broker::table_lookup(ct, Broker::data("hi")));
|
||||
print Broker::table_contains(ct, Broker::data("bye"));
|
||||
print Broker::table_insert(ct, Broker::data("bye"), Broker::data(7));
|
||||
print Broker::table_size(ct);
|
||||
print Broker::table_insert(ct, Broker::data("bye"), Broker::data(37));
|
||||
print Broker::table_size(ct);
|
||||
print Broker::refine_to_count(Broker::table_lookup(ct, Broker::data("bye")));
|
||||
print Broker::table_remove(ct, Broker::data("hi"));
|
||||
print Broker::table_size(ct);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cv = BrokerComm::data(v);
|
||||
local cv = Broker::data(v);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
cv = BrokerComm::vector_create();
|
||||
print BrokerComm::vector_size(cv);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("hi"), 0);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("hello"), 1);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("greetings"), 2);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("salutations"), 1);
|
||||
cv = Broker::vector_create();
|
||||
print Broker::vector_size(cv);
|
||||
print Broker::vector_insert(cv, Broker::data("hi"), 0);
|
||||
print Broker::vector_insert(cv, Broker::data("hello"), 1);
|
||||
print Broker::vector_insert(cv, Broker::data("greetings"), 2);
|
||||
print Broker::vector_insert(cv, Broker::data("salutations"), 1);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print BrokerComm::vector_size(cv);
|
||||
print BrokerComm::vector_replace(cv, BrokerComm::data("bah"), 2);
|
||||
print BrokerComm::vector_lookup(cv, 2);
|
||||
print BrokerComm::vector_lookup(cv, 0);
|
||||
print Broker::vector_size(cv);
|
||||
print Broker::vector_replace(cv, Broker::data("bah"), 2);
|
||||
print Broker::vector_lookup(cv, 2);
|
||||
print Broker::vector_lookup(cv, 0);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print BrokerComm::vector_remove(cv, 2);
|
||||
print Broker::vector_remove(cv, 2);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print BrokerComm::vector_size(cv);
|
||||
print Broker::vector_size(cv);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cr = BrokerComm::data(r);
|
||||
local cr = Broker::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
r$a = "test";
|
||||
cr = BrokerComm::data(r);
|
||||
cr = Broker::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
r$b = "testagain";
|
||||
cr = BrokerComm::data(r);
|
||||
cr = Broker::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
cr = BrokerComm::record_create(3);
|
||||
print BrokerComm::record_size(cr);
|
||||
print BrokerComm::record_assign(cr, BrokerComm::data("hi"), 0);
|
||||
print BrokerComm::record_assign(cr, BrokerComm::data("hello"), 1);
|
||||
print BrokerComm::record_assign(cr, BrokerComm::data(37), 2);
|
||||
print BrokerComm::record_lookup(cr, 0);
|
||||
print BrokerComm::record_lookup(cr, 1);
|
||||
print BrokerComm::record_lookup(cr, 2);
|
||||
print BrokerComm::record_size(cr);
|
||||
cr = Broker::record_create(3);
|
||||
print Broker::record_size(cr);
|
||||
print Broker::record_assign(cr, Broker::data("hi"), 0);
|
||||
print Broker::record_assign(cr, Broker::data("hello"), 1);
|
||||
print Broker::record_assign(cr, Broker::data(37), 2);
|
||||
print Broker::record_lookup(cr, 0);
|
||||
print Broker::record_lookup(cr, 1);
|
||||
print Broker::record_lookup(cr, 2);
|
||||
print Broker::record_size(cr);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ event terminate_me() {
|
|||
}
|
||||
|
||||
event bro_init() {
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
|
||||
print "1";
|
||||
schedule 1sec { terminate_me() };
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global lookup_count = 0;
|
||||
const lookup_expect_count = 5;
|
||||
global exists_count = 0;
|
||||
|
@ -20,13 +20,13 @@ global query_timeout = 30sec;
|
|||
|
||||
event test_clear()
|
||||
{
|
||||
BrokerStore::clear(h);
|
||||
Broker::clear(h);
|
||||
event test_size("after clear");
|
||||
}
|
||||
|
||||
event test_size(where: string)
|
||||
{
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
if ( where == "" )
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ event test_size(where: string)
|
|||
|
||||
event test_keys()
|
||||
{
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print fmt("keys: %s", res);
|
||||
event test_size();
|
||||
|
@ -66,7 +66,7 @@ event test_keys()
|
|||
|
||||
event test_pop(key: string)
|
||||
{
|
||||
when ( local lres = BrokerStore::pop_left(h, BrokerComm::data(key)) )
|
||||
when ( local lres = Broker::pop_left(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_left(%s): %s", key, lres);
|
||||
++pop_count;
|
||||
|
@ -83,7 +83,7 @@ event test_pop(key: string)
|
|||
event test_keys();
|
||||
}
|
||||
|
||||
when ( local rres = BrokerStore::pop_right(h, BrokerComm::data(key)) )
|
||||
when ( local rres = Broker::pop_right(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_right(%s): %s", key, rres);
|
||||
++pop_count;
|
||||
|
@ -103,7 +103,7 @@ event test_pop(key: string)
|
|||
|
||||
function do_exists(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::exists(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::exists(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("exists(%s): %s", key, res);
|
||||
++exists_count;
|
||||
|
@ -123,7 +123,7 @@ function do_exists(key: string)
|
|||
|
||||
event test_erase()
|
||||
{
|
||||
BrokerStore::erase(h, BrokerComm::data("two"));
|
||||
Broker::erase(h, Broker::data("two"));
|
||||
do_exists("one");
|
||||
do_exists("two");
|
||||
do_exists("myset");
|
||||
|
@ -132,7 +132,7 @@ event test_erase()
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("lookup(%s): %s", key, res);
|
||||
++lookup_count;
|
||||
|
@ -150,29 +150,29 @@ function do_lookup(key: string)
|
|||
}
|
||||
}
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("master");
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
h = Broker::create_master("master");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
do_lookup("one");
|
||||
do_lookup("two");
|
||||
do_lookup("myset");
|
||||
|
|
|
@ -18,10 +18,10 @@ global auto_event_handler: event(msg: string, c: count);
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::auto_event("bro/event/my_topic", auto_event_handler);
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/");
|
||||
Broker::auto_event("bro/event/my_topic", auto_event_handler);
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
global event_count = 0;
|
||||
|
@ -39,8 +39,8 @@ event event_handler(msg: string, n: count)
|
|||
}
|
||||
|
||||
event auto_event_handler(msg, n);
|
||||
local args = BrokerComm::event_args(event_handler, "pong", n);
|
||||
BrokerComm::event("bro/event/my_topic", args);
|
||||
local args = Broker::event_args(event_handler, "pong", n);
|
||||
Broker::event("bro/event/my_topic", args);
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
@ -55,24 +55,24 @@ global auto_event_handler: event(msg: string, c: count);
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/my_topic");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/my_topic");
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global event_count = 0;
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
local args = BrokerComm::event_args(event_handler, "ping", event_count);
|
||||
BrokerComm::event("bro/event/hi", args);
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
local args = Broker::event_args(event_handler, "ping", event_count);
|
||||
Broker::event("bro/event/hi", args);
|
||||
++event_count;
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -81,8 +81,8 @@ event BrokerComm::outgoing_connection_broken(peer_address: string,
|
|||
event event_handler(msg: string, n: count)
|
||||
{
|
||||
print "got event msg", msg, n;
|
||||
local args = BrokerComm::event_args(event_handler, "ping", event_count);
|
||||
BrokerComm::event("bro/event/hi", args);
|
||||
local args = Broker::event_args(event_handler, "ping", event_count);
|
||||
Broker::event("bro/event/hi", args);
|
||||
++event_count;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test]);
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,8 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::subscribe_to_logs("bro/log/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::subscribe_to_logs("bro/log/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
@ -62,8 +62,8 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable_remote_logs(Test::LOG);
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global n = 0;
|
||||
|
@ -80,15 +80,15 @@ event do_write()
|
|||
}
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -15,16 +15,16 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
Broker::subscribe_to_prints("bro/print/");
|
||||
}
|
||||
|
||||
global messages_to_recv = 6;
|
||||
global messages_sent = 0;
|
||||
global messages_recv = 0;
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++messages_recv;
|
||||
print "got print msg", msg;
|
||||
|
@ -35,7 +35,7 @@ event BrokerComm::print_handler(msg: string)
|
|||
return;
|
||||
}
|
||||
|
||||
BrokerComm::print("bro/print/my_topic", fmt("pong %d", messages_sent));
|
||||
Broker::print("bro/print/my_topic", fmt("pong %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
|
@ -48,35 +48,35 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/my_topic");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_prints("bro/print/my_topic");
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global messages_sent = 0;
|
||||
global messages_recv = 0;
|
||||
global peer_disconnected = F;
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
BrokerComm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
Broker::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++messages_recv;
|
||||
print "got print msg", msg;
|
||||
BrokerComm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
Broker::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -34,15 +34,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 0)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 1)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 2)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 3)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 1)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 2)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 3)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -50,9 +50,9 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
Broker::subscribe_to_events("bro/event/ready");
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
@ -62,41 +62,41 @@ event bro_init()
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{ event ready(); }
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -104,10 +104,10 @@ event BrokerComm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
Broker::enable();
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
|
|
@ -16,96 +16,96 @@ type bro_record : record {
|
|||
c: count;
|
||||
};
|
||||
|
||||
function comm_record_to_bro_record_recurse(it: opaque of BrokerComm::RecordIterator,
|
||||
function comm_record_to_bro_record_recurse(it: opaque of Broker::RecordIterator,
|
||||
rval: bro_record,
|
||||
idx: count): bro_record
|
||||
{
|
||||
if ( BrokerComm::record_iterator_last(it) )
|
||||
if ( Broker::record_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
local field_value = BrokerComm::record_iterator_value(it);
|
||||
local field_value = Broker::record_iterator_value(it);
|
||||
|
||||
if ( field_value?$d )
|
||||
switch ( idx ) {
|
||||
case 0:
|
||||
rval$a = BrokerComm::refine_to_string(field_value);
|
||||
rval$a = Broker::refine_to_string(field_value);
|
||||
break;
|
||||
case 1:
|
||||
rval$b = BrokerComm::refine_to_string(field_value);
|
||||
rval$b = Broker::refine_to_string(field_value);
|
||||
break;
|
||||
case 2:
|
||||
rval$c = BrokerComm::refine_to_count(field_value);
|
||||
rval$c = Broker::refine_to_count(field_value);
|
||||
break;
|
||||
};
|
||||
|
||||
++idx;
|
||||
BrokerComm::record_iterator_next(it);
|
||||
Broker::record_iterator_next(it);
|
||||
return comm_record_to_bro_record_recurse(it, rval, idx);
|
||||
}
|
||||
|
||||
function comm_record_to_bro_record(d: BrokerComm::Data): bro_record
|
||||
function comm_record_to_bro_record(d: Broker::Data): bro_record
|
||||
{
|
||||
return comm_record_to_bro_record_recurse(BrokerComm::record_iterator(d),
|
||||
return comm_record_to_bro_record_recurse(Broker::record_iterator(d),
|
||||
bro_record($c = 0), 0);
|
||||
}
|
||||
|
||||
function
|
||||
comm_set_to_bro_set_recurse(it: opaque of BrokerComm::SetIterator,
|
||||
comm_set_to_bro_set_recurse(it: opaque of Broker::SetIterator,
|
||||
rval: bro_set): bro_set
|
||||
{
|
||||
if ( BrokerComm::set_iterator_last(it) )
|
||||
if ( Broker::set_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
add rval[BrokerComm::refine_to_string(BrokerComm::set_iterator_value(it))];
|
||||
BrokerComm::set_iterator_next(it);
|
||||
add rval[Broker::refine_to_string(Broker::set_iterator_value(it))];
|
||||
Broker::set_iterator_next(it);
|
||||
return comm_set_to_bro_set_recurse(it, rval);
|
||||
}
|
||||
|
||||
|
||||
function comm_set_to_bro_set(d: BrokerComm::Data): bro_set
|
||||
function comm_set_to_bro_set(d: Broker::Data): bro_set
|
||||
{
|
||||
return comm_set_to_bro_set_recurse(BrokerComm::set_iterator(d), bro_set());
|
||||
return comm_set_to_bro_set_recurse(Broker::set_iterator(d), bro_set());
|
||||
}
|
||||
|
||||
function
|
||||
comm_table_to_bro_table_recurse(it: opaque of BrokerComm::TableIterator,
|
||||
comm_table_to_bro_table_recurse(it: opaque of Broker::TableIterator,
|
||||
rval: bro_table): bro_table
|
||||
{
|
||||
if ( BrokerComm::table_iterator_last(it) )
|
||||
if ( Broker::table_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
local item = BrokerComm::table_iterator_value(it);
|
||||
rval[BrokerComm::refine_to_string(item$key)] = BrokerComm::refine_to_count(item$val);
|
||||
BrokerComm::table_iterator_next(it);
|
||||
local item = Broker::table_iterator_value(it);
|
||||
rval[Broker::refine_to_string(item$key)] = Broker::refine_to_count(item$val);
|
||||
Broker::table_iterator_next(it);
|
||||
return comm_table_to_bro_table_recurse(it, rval);
|
||||
}
|
||||
|
||||
function comm_table_to_bro_table(d: BrokerComm::Data): bro_table
|
||||
function comm_table_to_bro_table(d: Broker::Data): bro_table
|
||||
{
|
||||
return comm_table_to_bro_table_recurse(BrokerComm::table_iterator(d),
|
||||
return comm_table_to_bro_table_recurse(Broker::table_iterator(d),
|
||||
bro_table());
|
||||
}
|
||||
|
||||
function comm_vector_to_bro_vector_recurse(it: opaque of BrokerComm::VectorIterator,
|
||||
function comm_vector_to_bro_vector_recurse(it: opaque of Broker::VectorIterator,
|
||||
rval: bro_vector): bro_vector
|
||||
{
|
||||
if ( BrokerComm::vector_iterator_last(it) )
|
||||
if ( Broker::vector_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
rval[|rval|] = BrokerComm::refine_to_string(BrokerComm::vector_iterator_value(it));
|
||||
BrokerComm::vector_iterator_next(it);
|
||||
rval[|rval|] = Broker::refine_to_string(Broker::vector_iterator_value(it));
|
||||
Broker::vector_iterator_next(it);
|
||||
return comm_vector_to_bro_vector_recurse(it, rval);
|
||||
}
|
||||
|
||||
function comm_vector_to_bro_vector(d: BrokerComm::Data): bro_vector
|
||||
function comm_vector_to_bro_vector(d: Broker::Data): bro_vector
|
||||
{
|
||||
return comm_vector_to_bro_vector_recurse(BrokerComm::vector_iterator(d),
|
||||
return comm_vector_to_bro_vector_recurse(Broker::vector_iterator(d),
|
||||
bro_vector());
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
}
|
||||
|
||||
global did_it = F;
|
||||
|
@ -114,120 +114,120 @@ event new_connection(c: connection)
|
|||
{
|
||||
if ( did_it ) return;
|
||||
did_it = T;
|
||||
print BrokerComm::data_type(BrokerComm::data(T));
|
||||
print BrokerComm::data_type(BrokerComm::data(+1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1.1));
|
||||
print BrokerComm::data_type(BrokerComm::data("1 (how creative)"));
|
||||
print BrokerComm::data_type(BrokerComm::data(1.1.1.1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1.1.1.1/1));
|
||||
print BrokerComm::data_type(BrokerComm::data(1/udp));
|
||||
print BrokerComm::data_type(BrokerComm::data(double_to_time(1)));
|
||||
print BrokerComm::data_type(BrokerComm::data(1sec));
|
||||
print BrokerComm::data_type(BrokerComm::data(BrokerComm::BOOL));
|
||||
print Broker::data_type(Broker::data(T));
|
||||
print Broker::data_type(Broker::data(+1));
|
||||
print Broker::data_type(Broker::data(1));
|
||||
print Broker::data_type(Broker::data(1.1));
|
||||
print Broker::data_type(Broker::data("1 (how creative)"));
|
||||
print Broker::data_type(Broker::data(1.1.1.1));
|
||||
print Broker::data_type(Broker::data(1.1.1.1/1));
|
||||
print Broker::data_type(Broker::data(1/udp));
|
||||
print Broker::data_type(Broker::data(double_to_time(1)));
|
||||
print Broker::data_type(Broker::data(1sec));
|
||||
print Broker::data_type(Broker::data(Broker::BOOL));
|
||||
local s: bro_set = bro_set("one", "two", "three");
|
||||
local t: bro_table = bro_table(["one"] = 1, ["two"] = 2, ["three"] = 3);
|
||||
local v: bro_vector = bro_vector("zero", "one", "two");
|
||||
local r: bro_record = bro_record($c = 1);
|
||||
print BrokerComm::data_type(BrokerComm::data(s));
|
||||
print BrokerComm::data_type(BrokerComm::data(t));
|
||||
print BrokerComm::data_type(BrokerComm::data(v));
|
||||
print BrokerComm::data_type(BrokerComm::data(r));
|
||||
print Broker::data_type(Broker::data(s));
|
||||
print Broker::data_type(Broker::data(t));
|
||||
print Broker::data_type(Broker::data(v));
|
||||
print Broker::data_type(Broker::data(r));
|
||||
|
||||
print "***************************";
|
||||
|
||||
print BrokerComm::refine_to_bool(BrokerComm::data(T));
|
||||
print BrokerComm::refine_to_bool(BrokerComm::data(F));
|
||||
print BrokerComm::refine_to_int(BrokerComm::data(+1));
|
||||
print BrokerComm::refine_to_int(BrokerComm::data(+0));
|
||||
print BrokerComm::refine_to_int(BrokerComm::data(-1));
|
||||
print BrokerComm::refine_to_count(BrokerComm::data(1));
|
||||
print BrokerComm::refine_to_count(BrokerComm::data(0));
|
||||
print BrokerComm::refine_to_double(BrokerComm::data(1.1));
|
||||
print BrokerComm::refine_to_double(BrokerComm::data(-11.1));
|
||||
print BrokerComm::refine_to_string(BrokerComm::data("hello"));
|
||||
print BrokerComm::refine_to_addr(BrokerComm::data(1.2.3.4));
|
||||
print BrokerComm::refine_to_subnet(BrokerComm::data(192.168.1.1/16));
|
||||
print BrokerComm::refine_to_port(BrokerComm::data(22/tcp));
|
||||
print BrokerComm::refine_to_time(BrokerComm::data(double_to_time(42)));
|
||||
print BrokerComm::refine_to_interval(BrokerComm::data(3min));
|
||||
print BrokerComm::refine_to_enum_name(BrokerComm::data(BrokerComm::BOOL));
|
||||
print Broker::refine_to_bool(Broker::data(T));
|
||||
print Broker::refine_to_bool(Broker::data(F));
|
||||
print Broker::refine_to_int(Broker::data(+1));
|
||||
print Broker::refine_to_int(Broker::data(+0));
|
||||
print Broker::refine_to_int(Broker::data(-1));
|
||||
print Broker::refine_to_count(Broker::data(1));
|
||||
print Broker::refine_to_count(Broker::data(0));
|
||||
print Broker::refine_to_double(Broker::data(1.1));
|
||||
print Broker::refine_to_double(Broker::data(-11.1));
|
||||
print Broker::refine_to_string(Broker::data("hello"));
|
||||
print Broker::refine_to_addr(Broker::data(1.2.3.4));
|
||||
print Broker::refine_to_subnet(Broker::data(192.168.1.1/16));
|
||||
print Broker::refine_to_port(Broker::data(22/tcp));
|
||||
print Broker::refine_to_time(Broker::data(double_to_time(42)));
|
||||
print Broker::refine_to_interval(Broker::data(3min));
|
||||
print Broker::refine_to_enum_name(Broker::data(Broker::BOOL));
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cs = BrokerComm::data(s);
|
||||
local cs = Broker::data(s);
|
||||
print comm_set_to_bro_set(cs);
|
||||
cs = BrokerComm::set_create();
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_insert(cs, BrokerComm::data("hi"));
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_contains(cs, BrokerComm::data("hi"));
|
||||
print BrokerComm::set_contains(cs, BrokerComm::data("bye"));
|
||||
print BrokerComm::set_insert(cs, BrokerComm::data("bye"));
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_remove(cs, BrokerComm::data("hi"));
|
||||
print BrokerComm::set_size(cs);
|
||||
print BrokerComm::set_remove(cs, BrokerComm::data("hi"));
|
||||
cs = Broker::set_create();
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_insert(cs, Broker::data("hi"));
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_contains(cs, Broker::data("hi"));
|
||||
print Broker::set_contains(cs, Broker::data("bye"));
|
||||
print Broker::set_insert(cs, Broker::data("bye"));
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_remove(cs, Broker::data("hi"));
|
||||
print Broker::set_size(cs);
|
||||
print Broker::set_remove(cs, Broker::data("hi"));
|
||||
print comm_set_to_bro_set(cs);
|
||||
BrokerComm::set_clear(cs);
|
||||
print BrokerComm::set_size(cs);
|
||||
Broker::set_clear(cs);
|
||||
print Broker::set_size(cs);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local ct = BrokerComm::data(t);
|
||||
local ct = Broker::data(t);
|
||||
print comm_table_to_bro_table(ct);
|
||||
ct = BrokerComm::table_create();
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::table_insert(ct, BrokerComm::data("hi"), BrokerComm::data(42));
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::table_contains(ct, BrokerComm::data("hi"));
|
||||
print BrokerComm::refine_to_count(BrokerComm::table_lookup(ct, BrokerComm::data("hi")));
|
||||
print BrokerComm::table_contains(ct, BrokerComm::data("bye"));
|
||||
print BrokerComm::table_insert(ct, BrokerComm::data("bye"), BrokerComm::data(7));
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::table_insert(ct, BrokerComm::data("bye"), BrokerComm::data(37));
|
||||
print BrokerComm::table_size(ct);
|
||||
print BrokerComm::refine_to_count(BrokerComm::table_lookup(ct, BrokerComm::data("bye")));
|
||||
print BrokerComm::table_remove(ct, BrokerComm::data("hi"));
|
||||
print BrokerComm::table_size(ct);
|
||||
ct = Broker::table_create();
|
||||
print Broker::table_size(ct);
|
||||
print Broker::table_insert(ct, Broker::data("hi"), Broker::data(42));
|
||||
print Broker::table_size(ct);
|
||||
print Broker::table_contains(ct, Broker::data("hi"));
|
||||
print Broker::refine_to_count(Broker::table_lookup(ct, Broker::data("hi")));
|
||||
print Broker::table_contains(ct, Broker::data("bye"));
|
||||
print Broker::table_insert(ct, Broker::data("bye"), Broker::data(7));
|
||||
print Broker::table_size(ct);
|
||||
print Broker::table_insert(ct, Broker::data("bye"), Broker::data(37));
|
||||
print Broker::table_size(ct);
|
||||
print Broker::refine_to_count(Broker::table_lookup(ct, Broker::data("bye")));
|
||||
print Broker::table_remove(ct, Broker::data("hi"));
|
||||
print Broker::table_size(ct);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cv = BrokerComm::data(v);
|
||||
local cv = Broker::data(v);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
cv = BrokerComm::vector_create();
|
||||
print BrokerComm::vector_size(cv);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("hi"), 0);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("hello"), 1);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("greetings"), 2);
|
||||
print BrokerComm::vector_insert(cv, BrokerComm::data("salutations"), 1);
|
||||
cv = Broker::vector_create();
|
||||
print Broker::vector_size(cv);
|
||||
print Broker::vector_insert(cv, Broker::data("hi"), 0);
|
||||
print Broker::vector_insert(cv, Broker::data("hello"), 1);
|
||||
print Broker::vector_insert(cv, Broker::data("greetings"), 2);
|
||||
print Broker::vector_insert(cv, Broker::data("salutations"), 1);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print BrokerComm::vector_size(cv);
|
||||
print BrokerComm::vector_replace(cv, BrokerComm::data("bah"), 2);
|
||||
print BrokerComm::vector_lookup(cv, 2);
|
||||
print BrokerComm::vector_lookup(cv, 0);
|
||||
print Broker::vector_size(cv);
|
||||
print Broker::vector_replace(cv, Broker::data("bah"), 2);
|
||||
print Broker::vector_lookup(cv, 2);
|
||||
print Broker::vector_lookup(cv, 0);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print BrokerComm::vector_remove(cv, 2);
|
||||
print Broker::vector_remove(cv, 2);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print BrokerComm::vector_size(cv);
|
||||
print Broker::vector_size(cv);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cr = BrokerComm::data(r);
|
||||
local cr = Broker::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
r$a = "test";
|
||||
cr = BrokerComm::data(r);
|
||||
cr = Broker::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
r$b = "testagain";
|
||||
cr = BrokerComm::data(r);
|
||||
cr = Broker::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
cr = BrokerComm::record_create(3);
|
||||
print BrokerComm::record_size(cr);
|
||||
print BrokerComm::record_assign(cr, BrokerComm::data("hi"), 0);
|
||||
print BrokerComm::record_assign(cr, BrokerComm::data("hello"), 1);
|
||||
print BrokerComm::record_assign(cr, BrokerComm::data(37), 2);
|
||||
print BrokerComm::record_lookup(cr, 0);
|
||||
print BrokerComm::record_lookup(cr, 1);
|
||||
print BrokerComm::record_lookup(cr, 2);
|
||||
print BrokerComm::record_size(cr);
|
||||
cr = Broker::record_create(3);
|
||||
print Broker::record_size(cr);
|
||||
print Broker::record_assign(cr, Broker::data("hi"), 0);
|
||||
print Broker::record_assign(cr, Broker::data("hello"), 1);
|
||||
print Broker::record_assign(cr, Broker::data(37), 2);
|
||||
print Broker::record_lookup(cr, 0);
|
||||
print Broker::record_lookup(cr, 1);
|
||||
print Broker::record_lookup(cr, 2);
|
||||
print Broker::record_size(cr);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global lookup_count = 0;
|
||||
const lookup_expect_count = 5;
|
||||
global exists_count = 0;
|
||||
|
@ -20,13 +20,13 @@ global test_size: event(where: string &default = "");
|
|||
|
||||
event test_clear()
|
||||
{
|
||||
BrokerStore::clear(h);
|
||||
Broker::clear(h);
|
||||
event test_size("after clear");
|
||||
}
|
||||
|
||||
event test_size(where: string)
|
||||
{
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
if ( where == "" )
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ event test_size(where: string)
|
|||
|
||||
event test_keys()
|
||||
{
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print fmt("keys: %s", res);
|
||||
event test_size();
|
||||
|
@ -56,7 +56,7 @@ event test_keys()
|
|||
|
||||
event test_pop(key: string)
|
||||
{
|
||||
when ( local lres = BrokerStore::pop_left(h, BrokerComm::data(key)) )
|
||||
when ( local lres = Broker::pop_left(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_left(%s): %s", key, lres);
|
||||
++pop_count;
|
||||
|
@ -67,7 +67,7 @@ event test_pop(key: string)
|
|||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
||||
when ( local rres = BrokerStore::pop_right(h, BrokerComm::data(key)) )
|
||||
when ( local rres = Broker::pop_right(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("pop_right(%s): %s", key, rres);
|
||||
++pop_count;
|
||||
|
@ -81,7 +81,7 @@ event test_pop(key: string)
|
|||
|
||||
function do_exists(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::exists(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::exists(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("exists(%s): %s", key, res);
|
||||
++exists_count;
|
||||
|
@ -95,7 +95,7 @@ function do_exists(key: string)
|
|||
|
||||
event test_erase()
|
||||
{
|
||||
BrokerStore::erase(h, BrokerComm::data("two"));
|
||||
Broker::erase(h, Broker::data("two"));
|
||||
do_exists("one");
|
||||
do_exists("two");
|
||||
do_exists("myset");
|
||||
|
@ -104,7 +104,7 @@ event test_erase()
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
print fmt("lookup(%s): %s", key, res);
|
||||
++lookup_count;
|
||||
|
@ -116,9 +116,9 @@ function do_lookup(key: string)
|
|||
{ print "timeout"; }
|
||||
}
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ global did_it = F;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
h = BrokerStore::create_master("master");
|
||||
Broker::enable();
|
||||
h = Broker::create_master("master");
|
||||
}
|
||||
|
||||
event new_connection(c: connection)
|
||||
|
@ -137,16 +137,16 @@ event new_connection(c: connection)
|
|||
did_it = T;
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
do_lookup("one");
|
||||
do_lookup("two");
|
||||
do_lookup("myset");
|
||||
|
|
|
@ -20,10 +20,10 @@ global auto_event_handler: event(msg: string, c: count);
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::auto_event("bro/event/my_topic", auto_event_handler);
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
Broker::subscribe_to_events("bro/event/");
|
||||
Broker::auto_event("bro/event/my_topic", auto_event_handler);
|
||||
}
|
||||
|
||||
global event_count = 0;
|
||||
|
@ -41,8 +41,8 @@ event event_handler(msg: string, n: count)
|
|||
}
|
||||
|
||||
event auto_event_handler(msg, n);
|
||||
local args = BrokerComm::event_args(event_handler, "pong", n);
|
||||
BrokerComm::event("bro/event/my_topic", args);
|
||||
local args = Broker::event_args(event_handler, "pong", n);
|
||||
Broker::event("bro/event/my_topic", args);
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
@ -57,24 +57,24 @@ global auto_event_handler: event(msg: string, c: count);
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/my_topic");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/my_topic");
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global event_count = 0;
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
local args = BrokerComm::event_args(event_handler, "ping", event_count);
|
||||
BrokerComm::event("bro/event/hi", args);
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
local args = Broker::event_args(event_handler, "ping", event_count);
|
||||
Broker::event("bro/event/hi", args);
|
||||
++event_count;
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -83,8 +83,8 @@ event BrokerComm::outgoing_connection_broken(peer_address: string,
|
|||
event event_handler(msg: string, n: count)
|
||||
{
|
||||
print "got event msg", msg, n;
|
||||
local args = BrokerComm::event_args(event_handler, "ping", event_count);
|
||||
BrokerComm::event("bro/event/hi", args);
|
||||
local args = Broker::event_args(event_handler, "ping", event_count);
|
||||
Broker::event("bro/event/hi", args);
|
||||
++event_count;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test]);
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_logs("bro/log/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
Broker::subscribe_to_logs("bro/log/");
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
@ -63,8 +63,8 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable_remote_logs(Test::LOG);
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global n = 0;
|
||||
|
@ -81,15 +81,15 @@ event do_write()
|
|||
}
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -17,16 +17,16 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
Broker::subscribe_to_prints("bro/print/");
|
||||
}
|
||||
|
||||
global messages_to_recv = 6;
|
||||
global messages_sent = 0;
|
||||
global messages_recv = 0;
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++messages_recv;
|
||||
print "got print msg", msg;
|
||||
|
@ -37,7 +37,7 @@ event BrokerComm::print_handler(msg: string)
|
|||
return;
|
||||
}
|
||||
|
||||
BrokerComm::print("bro/print/my_topic", fmt("pong %d", messages_sent));
|
||||
Broker::print("bro/print/my_topic", fmt("pong %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
|
@ -50,35 +50,35 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/my_topic");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_prints("bro/print/my_topic");
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global messages_sent = 0;
|
||||
global messages_recv = 0;
|
||||
global peer_disconnected = F;
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
BrokerComm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
Broker::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++messages_recv;
|
||||
print "got print msg", msg;
|
||||
BrokerComm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
Broker::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,19 +4,19 @@ connecting-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,21 +4,21 @@ connecting-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
event Broker::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;
|
||||
print "Broker::incoming_connection_broken", peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,31 +4,31 @@ events-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "hi", 0));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "hi", 0));
|
||||
event my_auto_event("stuff", 88);
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "...", 1));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "...", 1));
|
||||
event my_auto_event("more stuff", 51);
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "bye", 2));
|
||||
Broker::event("bro/event/my_event", Broker::event_args(my_event, "bye", 2));
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -4,21 +4,21 @@ events-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event my_event(msg: string, c: count)
|
||||
|
|
|
@ -6,16 +6,16 @@ logs-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
redef Log::enable_local_logging = F;
|
||||
redef Log::enable_remote_logging = F;
|
||||
global n = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::enable_remote_logs(Test::LOG);
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event do_write()
|
||||
|
@ -28,16 +28,16 @@ event do_write()
|
|||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -6,18 +6,18 @@ logs-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_logs("bro/log/Test::LOG");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
|
|
@ -4,26 +4,26 @@ printing-connector.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Broker::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
print "Broker::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
BrokerComm::print("bro/print/hi", "hello");
|
||||
BrokerComm::print("bro/print/stuff", "...");
|
||||
BrokerComm::print("bro/print/bye", "goodbye");
|
||||
Broker::print("bro/print/hi", "hello");
|
||||
Broker::print("bro/print/stuff", "...");
|
||||
Broker::print("bro/print/bye", "goodbye");
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -4,22 +4,22 @@ printing-listener.bro
|
|||
|
||||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
redef Broker::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_prints("bro/print/");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
print "Broker::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
event Broker::print_handler(msg: string)
|
||||
{
|
||||
++msg_count;
|
||||
print "got print message", msg;
|
||||
|
|
|
@ -5,42 +5,42 @@ stores-connector.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
function dv(d: Broker::Data): Broker::DataVector
|
||||
{
|
||||
local rval: BrokerComm::DataVector;
|
||||
local rval: Broker::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = BrokerStore::create_master("mystore");
|
||||
BrokerStore::insert(h, BrokerComm::data("one"), BrokerComm::data(110));
|
||||
BrokerStore::insert(h, BrokerComm::data("two"), BrokerComm::data(223));
|
||||
BrokerStore::insert(h, BrokerComm::data("myset"), BrokerComm::data(myset));
|
||||
BrokerStore::insert(h, BrokerComm::data("myvec"), BrokerComm::data(myvec));
|
||||
BrokerStore::increment(h, BrokerComm::data("one"));
|
||||
BrokerStore::decrement(h, BrokerComm::data("two"));
|
||||
BrokerStore::add_to_set(h, BrokerComm::data("myset"), BrokerComm::data("d"));
|
||||
BrokerStore::remove_from_set(h, BrokerComm::data("myset"), BrokerComm::data("b"));
|
||||
BrokerStore::push_left(h, BrokerComm::data("myvec"), dv(BrokerComm::data("delta")));
|
||||
BrokerStore::push_right(h, BrokerComm::data("myvec"), dv(BrokerComm::data("omega")));
|
||||
h = Broker::create_master("mystore");
|
||||
Broker::insert(h, Broker::data("one"), Broker::data(110));
|
||||
Broker::insert(h, Broker::data("two"), Broker::data(223));
|
||||
Broker::insert(h, Broker::data("myset"), Broker::data(myset));
|
||||
Broker::insert(h, Broker::data("myvec"), Broker::data(myvec));
|
||||
Broker::increment(h, Broker::data("one"));
|
||||
Broker::decrement(h, Broker::data("two"));
|
||||
Broker::add_to_set(h, Broker::data("myset"), Broker::data("d"));
|
||||
Broker::remove_from_set(h, Broker::data("myset"), Broker::data("b"));
|
||||
Broker::push_left(h, Broker::data("myvec"), dv(Broker::data("delta")));
|
||||
Broker::push_right(h, Broker::data("myvec"), dv(Broker::data("omega")));
|
||||
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
when ( local res = Broker::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
@ -51,7 +51,7 @@ event BrokerComm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
Broker::enable();
|
||||
Broker::connect("127.0.0.1", broker_port, 1secs);
|
||||
Broker::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ stores-listener.bro
|
|||
const broker_port: port = 9999/tcp &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global h: opaque of Broker::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
when ( local res = Broker::lookup(h, Broker::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -25,15 +25,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
h = Broker::create_clone("mystore");
|
||||
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
when ( local res = Broker::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 0)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 1)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 2)));
|
||||
do_lookup(BrokerComm::refine_to_string(BrokerComm::vector_lookup(res$result, 3)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 0)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 1)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 2)));
|
||||
do_lookup(Broker::refine_to_string(Broker::vector_lookup(res$result, 3)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -41,7 +41,7 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/ready");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
BrokerComm::enable();
|
||||
Broker::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test, $path="test"]);
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ event NetControl::init_done()
|
|||
continue_processing();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -91,28 +91,28 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/netcontroltest");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/netcontroltest");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established";
|
||||
print "Broker::incoming_connection_established";
|
||||
}
|
||||
|
||||
event NetControl::acld_add_rule(id: count, r: NetControl::Rule, ar: NetControl::AclRule)
|
||||
{
|
||||
print "add_rule", id, r$entity, r$ty, ar;
|
||||
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::acld_rule_added, id, r, ar$command));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::acld_rule_added, id, r, ar$command));
|
||||
}
|
||||
|
||||
event NetControl::acld_remove_rule(id: count, r: NetControl::Rule, ar: NetControl::AclRule)
|
||||
{
|
||||
print "remove_rule", id, r$entity, r$ty, ar;
|
||||
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::acld_rule_removed, id, r, ar$command));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::acld_rule_removed, id, r, ar$command));
|
||||
|
||||
if ( r$cid == 4 )
|
||||
terminate();
|
||||
|
|
|
@ -21,11 +21,11 @@ event NetControl::init()
|
|||
NetControl::activate(netcontrol_acld, 0);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
}
|
||||
|
||||
event NetControl::init_done()
|
||||
|
@ -33,7 +33,7 @@ event NetControl::init_done()
|
|||
continue_processing();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -84,28 +84,28 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/netcontroltest");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/netcontroltest");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established";
|
||||
print "Broker::incoming_connection_established";
|
||||
}
|
||||
|
||||
event NetControl::acld_add_rule(id: count, r: NetControl::Rule, ar: NetControl::AclRule)
|
||||
{
|
||||
print "add_rule", id, r$entity, r$ty, ar;
|
||||
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::acld_rule_added, id, r, ar$command));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::acld_rule_added, id, r, ar$command));
|
||||
}
|
||||
|
||||
event NetControl::acld_remove_rule(id: count, r: NetControl::Rule, ar: NetControl::AclRule)
|
||||
{
|
||||
print "remove_rule", id, r$entity, r$ty, ar;
|
||||
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::acld_rule_removed, id, r, ar$command));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::acld_rule_removed, id, r, ar$command));
|
||||
|
||||
if ( r$cid == 4 )
|
||||
terminate();
|
||||
|
|
|
@ -27,14 +27,14 @@ event NetControl::init_done()
|
|||
continue_processing();
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -75,29 +75,29 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/netcontroltest");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/netcontroltest");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established";
|
||||
print "Broker::incoming_connection_established";
|
||||
}
|
||||
|
||||
event NetControl::broker_add_rule(id: count, r: NetControl::Rule)
|
||||
{
|
||||
print "add_rule", id, r$entity, r$ty;
|
||||
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::broker_rule_added, id, r, ""));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::broker_rule_added, id, r, ""));
|
||||
}
|
||||
|
||||
event NetControl::broker_remove_rule(id: count, r: NetControl::Rule)
|
||||
{
|
||||
print "remove_rule", id, r$entity, r$ty;
|
||||
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::broker_rule_timeout, id, r, NetControl::FlowInfo()));
|
||||
BrokerComm::event("bro/event/netcontroltest", BrokerComm::event_args(NetControl::broker_rule_removed, id, r, ""));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::broker_rule_timeout, id, r, NetControl::FlowInfo()));
|
||||
Broker::event("bro/event/netcontroltest", Broker::event_args(NetControl::broker_rule_removed, id, r, ""));
|
||||
|
||||
if ( r$cid == 3 )
|
||||
terminate();
|
||||
|
|
|
@ -23,11 +23,11 @@ event bro_init()
|
|||
of_controller = OpenFlow::broker_new("broker1", 127.0.0.1, broker_port, "bro/event/openflow", 42);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
event Broker::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "Broker::outgoing_connection_established", peer_address, peer_port;
|
||||
}
|
||||
|
||||
event OpenFlow::controller_activated(name: string, controller: OpenFlow::Controller)
|
||||
|
@ -37,7 +37,7 @@ event OpenFlow::controller_activated(name: string, controller: OpenFlow::Control
|
|||
OpenFlow::flow_mod(of_controller, [], [$cookie=OpenFlow::generate_cookie(1), $command=OpenFlow::OFPFC_ADD, $actions=[$out_ports=vector(3, 7)]]);
|
||||
}
|
||||
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
event Broker::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -83,14 +83,14 @@ global msg_count: count = 0;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/openflow");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
Broker::enable();
|
||||
Broker::subscribe_to_events("bro/event/openflow");
|
||||
Broker::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
event Broker::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "BrokerComm::incoming_connection_established";
|
||||
print "Broker::incoming_connection_established";
|
||||
}
|
||||
|
||||
function got_message()
|
||||
|
@ -104,8 +104,8 @@ function got_message()
|
|||
event OpenFlow::broker_flow_mod(name: string, dpid: count, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod)
|
||||
{
|
||||
print "got flow_mod", dpid, match, flow_mod;
|
||||
BrokerComm::event("bro/event/openflow", BrokerComm::event_args(OpenFlow::flow_mod_success, name, match, flow_mod, ""));
|
||||
BrokerComm::event("bro/event/openflow", BrokerComm::event_args(OpenFlow::flow_mod_failure, name, match, flow_mod, ""));
|
||||
Broker::event("bro/event/openflow", Broker::event_args(OpenFlow::flow_mod_success, name, match, flow_mod, ""));
|
||||
Broker::event("bro/event/openflow", Broker::event_args(OpenFlow::flow_mod_failure, name, match, flow_mod, ""));
|
||||
got_message();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue