mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
Rename broker-related namespaces.
c++ namespace "comm" -> bro_broker script module "Comm" -> BrokerComm script module "Store" -> BrokerStore
This commit is contained in:
parent
25a4d0ebed
commit
fa08083a92
65 changed files with 1142 additions and 1142 deletions
|
@ -20,20 +20,20 @@ Connecting to Peers
|
|||
===================
|
||||
|
||||
Communication via Broker must first be turned on via
|
||||
:bro:see:`Comm::enable`.
|
||||
:bro:see:`BrokerComm::enable`.
|
||||
|
||||
Bro can accept incoming connections by calling :bro:see:`Comm::listen`
|
||||
Bro can accept incoming connections by calling :bro:see:`BrokerComm::listen`
|
||||
and then monitor connection status updates via
|
||||
:bro:see:`Comm::incoming_connection_established` and
|
||||
:bro:see:`Comm::incoming_connection_broken`.
|
||||
:bro:see:`BrokerComm::incoming_connection_established` and
|
||||
:bro:see:`BrokerComm::incoming_connection_broken`.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/connecting-listener.bro
|
||||
|
||||
Bro can initiate outgoing connections by calling :bro:see:`Comm::connect`
|
||||
Bro can initiate outgoing connections by calling :bro:see:`BrokerComm::connect`
|
||||
and then monitor connection status updates via
|
||||
:bro:see:`Comm::outgoing_connection_established`,
|
||||
:bro:see:`Comm::outgoing_connection_broken`, and
|
||||
:bro:see:`Comm::outgoing_connection_incompatible`.
|
||||
:bro:see:`BrokerComm::outgoing_connection_established`,
|
||||
:bro:see:`BrokerComm::outgoing_connection_broken`, and
|
||||
:bro:see:`BrokerComm::outgoing_connection_incompatible`.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/connecting-connector.bro
|
||||
|
||||
|
@ -41,14 +41,14 @@ Remote Printing
|
|||
===============
|
||||
|
||||
To receive remote print messages, first use
|
||||
:bro:see:`Comm::subscribe_to_prints` to advertise to peers a topic
|
||||
:bro:see:`BrokerComm::subscribe_to_prints` to advertise to peers a topic
|
||||
prefix of interest and then create an event handler for
|
||||
:bro:see:`Comm::print_handler` to handle any print messages that are
|
||||
:bro:see:`BrokerComm::print_handler` to handle any print messages that are
|
||||
received.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/printing-listener.bro
|
||||
|
||||
To send remote print messages, just call :bro:see:`Comm::print`.
|
||||
To send remote print messages, just call :bro:see:`BrokerComm::print`.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/printing-connector.bro
|
||||
|
||||
|
@ -72,14 +72,14 @@ Remote Events
|
|||
=============
|
||||
|
||||
Receiving remote events is similar to remote prints. Just use
|
||||
:bro:see:`Comm::subscribe_to_events` and possibly define any new events
|
||||
:bro:see:`BrokerComm::subscribe_to_events` and possibly define any new events
|
||||
along with handlers that peers may want to send.
|
||||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/events-listener.bro
|
||||
|
||||
To send events, there are two choices. The first is to use call
|
||||
:bro:see:`Comm::event` directly. The second option is to use
|
||||
:bro:see:`Comm::auto_event` to make it so a particular event is
|
||||
:bro:see:`BrokerComm::event` directly. The second option is to use
|
||||
:bro:see:`BrokerComm::auto_event` to make it so a particular event is
|
||||
automatically sent to peers whenever it is called locally via the normal
|
||||
event invocation syntax.
|
||||
|
||||
|
@ -107,14 +107,14 @@ Remote Logging
|
|||
|
||||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/testlog.bro
|
||||
|
||||
Use :bro:see:`Comm::subscribe_to_logs` to advertise interest in logs
|
||||
Use :bro:see:`BrokerComm::subscribe_to_logs` 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/comm/logs-listener.bro
|
||||
|
||||
To send remote logs either use :bro:see:`Log::enable_remote_logging` or
|
||||
:bro:see:`Comm::enable_remote_logs`. The former allows any log stream
|
||||
:bro:see:`BrokerComm::enable_remote_logs`. The former allows any log stream
|
||||
to be sent to peers while the later toggles remote logging for
|
||||
particular streams.
|
||||
|
||||
|
@ -140,23 +140,23 @@ 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:`Comm::EndpointFlags` supplied to :bro:see:`Comm::enable`.
|
||||
:bro:see:`BrokerComm::EndpointFlags` supplied to :bro:see:`BrokerComm::enable`.
|
||||
|
||||
If not using the ``auto_publish`` flag, one can use the
|
||||
:bro:see:`Comm::publish_topic` and :bro:see:`Comm::unpublish_topic`
|
||||
:bro:see:`BrokerComm::publish_topic` and :bro:see:`BrokerComm::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:`Comm::SendFlags` such as :bro:see:`Comm::print`,
|
||||
:bro:see:`Comm::event`, :bro:see:`Comm::auto_event` or
|
||||
:bro:see:`Comm::enable_remote_logs`.
|
||||
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`.
|
||||
|
||||
If not using the ``auto_advertise`` flag, one can use the
|
||||
:bro:see:`Comm::advertise_topic` and :bro:see:`Comm::unadvertise_topic`
|
||||
:bro:see:`BrokerComm::advertise_topic` and :bro:see:`BrokerComm::unadvertise_topic`
|
||||
to manupulate the set of topic prefixes that are allowed to be
|
||||
advertised to peers. If an endpoint does not advertise a topic prefix,
|
||||
the only way a peers can send messages to it is via the ``unsolicited``
|
||||
flag of :bro:see:`Comm::SendFlags` and choosing a topic with a matching
|
||||
flag of :bro:see:`BrokerComm::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).
|
||||
|
||||
|
@ -194,8 +194,8 @@ last modification time.
|
|||
.. btest-include:: ${DOC_ROOT}/frameworks/comm/stores-connector.bro
|
||||
|
||||
In the above example, if a local copy of the store contents isn't
|
||||
needed, just replace the :bro:see:`Store::create_clone` call with
|
||||
:bro:see:`Store::create_frontend`. Queries will then be made against
|
||||
needed, just replace the :bro:see:`BrokerStore::create_clone` call with
|
||||
:bro:see:`BrokerStore::create_frontend`. Queries will then be made against
|
||||
the remote master store instead of the local clone.
|
||||
|
||||
Note that all queries are made within Bro's asynchrounous ``when``
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_broken(peer_name: string)
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_broken", peer_name;
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Comm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "hi", 0));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "hi", 0));
|
||||
event my_auto_event("stuff", 88);
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "...", 1));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "...", 1));
|
||||
event my_auto_event("more stuff", 51);
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "bye", 2));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "bye", 2));
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::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()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event my_event(msg: string, c: count)
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Log::enable_local_logging = F;
|
||||
redef Log::enable_remote_logging = F;
|
||||
global n = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::enable_remote_logs(Test::LOG);
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event do_write()
|
||||
|
@ -24,16 +24,16 @@ event do_write()
|
|||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
Comm::print("bro/print/hi", "hello");
|
||||
Comm::print("bro/print/stuff", "...");
|
||||
Comm::print("bro/print/bye", "goodbye");
|
||||
BrokerComm::print("bro/print/hi", "hello");
|
||||
BrokerComm::print("bro/print/stuff", "...");
|
||||
BrokerComm::print("bro/print/bye", "goodbye");
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_prints("bro/print/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Comm::print_handler(msg: string)
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
{
|
||||
++msg_count;
|
||||
print "got print message", msg;
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
|
||||
function dv(d: Comm::Data): Comm::DataVector
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
{
|
||||
local rval: Comm::DataVector;
|
||||
local rval: BrokerComm::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::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 = Store::create_master("mystore");
|
||||
Store::insert(h, Comm::data("one"), Comm::data(110));
|
||||
Store::insert(h, Comm::data("two"), Comm::data(223));
|
||||
Store::insert(h, Comm::data("myset"), Comm::data(myset));
|
||||
Store::insert(h, Comm::data("myvec"), Comm::data(myvec));
|
||||
Store::increment(h, Comm::data("one"));
|
||||
Store::decrement(h, Comm::data("two"));
|
||||
Store::add_to_set(h, Comm::data("myset"), Comm::data("d"));
|
||||
Store::remove_from_set(h, Comm::data("myset"), Comm::data("b"));
|
||||
Store::push_left(h, Comm::data("myvec"), dv(Comm::data("delta")));
|
||||
Store::push_right(h, Comm::data("myvec"), dv(Comm::data("omega")));
|
||||
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")));
|
||||
|
||||
when ( local res = Store::size(h) )
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
@ -47,7 +47,7 @@ event Comm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Comm::auto_event("bro/event/ready", ready);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = Store::lookup(h, Comm::data(key)) )
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -21,15 +21,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = Store::create_clone("mystore");
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
|
||||
when ( local res = Store::keys(h) )
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 0)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 1)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 2)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 3)));
|
||||
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)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -37,7 +37,7 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/ready");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
Comm::enable();
|
||||
BrokerComm::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test]);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
##! Various data structure definitions for use with Bro's communication system.
|
||||
|
||||
module Comm;
|
||||
module BrokerComm;
|
||||
|
||||
export {
|
||||
|
||||
## A name used to identify this endpoint to peers.
|
||||
## .. bro:see:: Comm::connect Comm::listen
|
||||
## .. bro:see:: BrokerComm::connect BrokerComm::listen
|
||||
const endpoint_name = "" &redef;
|
||||
|
||||
## Change communication behavior.
|
||||
|
@ -32,11 +32,11 @@ export {
|
|||
|
||||
## Opaque communication data.
|
||||
type Data: record {
|
||||
d: opaque of Comm::Data &optional;
|
||||
d: opaque of BrokerComm::Data &optional;
|
||||
};
|
||||
|
||||
## Opaque communication data.
|
||||
type DataVector: vector of Comm::Data;
|
||||
type DataVector: vector of BrokerComm::Data;
|
||||
|
||||
## Opaque event communication data.
|
||||
type EventArgs: record {
|
||||
|
@ -48,13 +48,13 @@ export {
|
|||
|
||||
## Opaque communication data used as a convenient way to wrap key-value
|
||||
## pairs that comprise table entries.
|
||||
type Comm::TableItem : record {
|
||||
key: Comm::Data;
|
||||
val: Comm::Data;
|
||||
type TableItem : record {
|
||||
key: BrokerComm::Data;
|
||||
val: BrokerComm::Data;
|
||||
};
|
||||
}
|
||||
|
||||
module Store;
|
||||
module BrokerStore;
|
||||
|
||||
export {
|
||||
|
||||
|
@ -76,11 +76,11 @@ export {
|
|||
## The result of a data store query.
|
||||
type QueryResult: record {
|
||||
## Whether the query completed or not.
|
||||
status: Store::QueryStatus;
|
||||
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: Comm::Data;
|
||||
result: BrokerComm::Data;
|
||||
};
|
||||
|
||||
## Options to tune the SQLite storage backend.
|
||||
|
|
|
@ -96,7 +96,7 @@ void EventHandler::Call(val_list* vl, bool no_remote)
|
|||
|
||||
for ( auto i = 0; i < vl->length(); ++i )
|
||||
{
|
||||
auto opt_data = comm::val_to_data((*vl)[i]);
|
||||
auto opt_data = bro_broker::val_to_data((*vl)[i]);
|
||||
|
||||
if ( opt_data )
|
||||
msg.emplace_back(move(*opt_data));
|
||||
|
@ -116,9 +116,9 @@ void EventHandler::Call(val_list* vl, bool no_remote)
|
|||
it != auto_remote_send.end(); ++it )
|
||||
{
|
||||
if ( std::next(it) == auto_remote_send.end() )
|
||||
comm_mgr->Event(it->first, move(msg), it->second);
|
||||
broker_mgr->Event(it->first, move(msg), it->second);
|
||||
else
|
||||
comm_mgr->Event(it->first, msg, it->second);
|
||||
broker_mgr->Event(it->first, msg, it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ void net_run()
|
|||
bool communication_enabled = using_communication;
|
||||
|
||||
#ifdef ENABLE_BROKER
|
||||
communication_enabled |= comm_mgr->Enabled();
|
||||
communication_enabled |= broker_mgr->Enabled();
|
||||
#endif
|
||||
|
||||
if ( src )
|
||||
|
|
|
@ -227,7 +227,7 @@ void ProfileLogger::Log()
|
|||
}
|
||||
|
||||
#ifdef ENABLE_BROKER
|
||||
auto cs = comm_mgr->ConsumeStatistics();
|
||||
auto cs = broker_mgr->ConsumeStatistics();
|
||||
|
||||
file->Write(fmt("%0.6f Comm: peers=%zu stores=%zu "
|
||||
"store_queries=%zu store_responses=%zu "
|
||||
|
|
118
src/comm/Data.cc
118
src/comm/Data.cc
|
@ -5,11 +5,11 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
OpaqueType* comm::opaque_of_data_type;
|
||||
OpaqueType* comm::opaque_of_set_iterator;
|
||||
OpaqueType* comm::opaque_of_table_iterator;
|
||||
OpaqueType* comm::opaque_of_vector_iterator;
|
||||
OpaqueType* comm::opaque_of_record_iterator;
|
||||
OpaqueType* bro_broker::opaque_of_data_type;
|
||||
OpaqueType* bro_broker::opaque_of_set_iterator;
|
||||
OpaqueType* bro_broker::opaque_of_table_iterator;
|
||||
OpaqueType* bro_broker::opaque_of_vector_iterator;
|
||||
OpaqueType* bro_broker::opaque_of_record_iterator;
|
||||
|
||||
static broker::port::protocol to_broker_port_proto(TransportProto tp)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ static broker::port::protocol to_broker_port_proto(TransportProto tp)
|
|||
}
|
||||
}
|
||||
|
||||
TransportProto comm::to_bro_port_proto(broker::port::protocol tp)
|
||||
TransportProto bro_broker::to_bro_port_proto(broker::port::protocol tp)
|
||||
{
|
||||
switch ( tp ) {
|
||||
case broker::port::protocol::tcp:
|
||||
|
@ -135,7 +135,7 @@ struct val_converter {
|
|||
result_type operator()(broker::port& a)
|
||||
{
|
||||
if ( type->Tag() == TYPE_PORT )
|
||||
return new PortVal(a.number(), comm::to_bro_port_proto(a.type()));
|
||||
return new PortVal(a.number(), bro_broker::to_bro_port_proto(a.type()));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -204,8 +204,8 @@ struct val_converter {
|
|||
|
||||
for ( auto i = 0u; i < indices->size(); ++i )
|
||||
{
|
||||
auto index_val = comm::data_to_val(move((*indices)[i]),
|
||||
(*expected_index_types)[i]);
|
||||
auto index_val = bro_broker::data_to_val(move((*indices)[i]),
|
||||
(*expected_index_types)[i]);
|
||||
|
||||
if ( ! index_val )
|
||||
{
|
||||
|
@ -257,8 +257,8 @@ struct val_converter {
|
|||
|
||||
for ( auto i = 0u; i < indices->size(); ++i )
|
||||
{
|
||||
auto index_val = comm::data_to_val(move((*indices)[i]),
|
||||
(*expected_index_types)[i]);
|
||||
auto index_val = bro_broker::data_to_val(move((*indices)[i]),
|
||||
(*expected_index_types)[i]);
|
||||
|
||||
if ( ! index_val )
|
||||
{
|
||||
|
@ -270,8 +270,8 @@ struct val_converter {
|
|||
list_val->Append(index_val);
|
||||
}
|
||||
|
||||
auto value_val = comm::data_to_val(move(item.second),
|
||||
tt->YieldType());
|
||||
auto value_val = bro_broker::data_to_val(move(item.second),
|
||||
tt->YieldType());
|
||||
|
||||
if ( ! value_val )
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ struct val_converter {
|
|||
|
||||
for ( auto& item : a )
|
||||
{
|
||||
auto item_val = comm::data_to_val(move(item), vt->YieldType());
|
||||
auto item_val = bro_broker::data_to_val(move(item), vt->YieldType());
|
||||
|
||||
if ( ! item_val )
|
||||
{
|
||||
|
@ -336,8 +336,8 @@ struct val_converter {
|
|||
continue;
|
||||
}
|
||||
|
||||
auto item_val = comm::data_to_val(move(*a.fields[i]),
|
||||
rt->FieldType(i));
|
||||
auto item_val = bro_broker::data_to_val(move(*a.fields[i]),
|
||||
rt->FieldType(i));
|
||||
|
||||
if ( ! item_val )
|
||||
{
|
||||
|
@ -352,12 +352,12 @@ struct val_converter {
|
|||
}
|
||||
};
|
||||
|
||||
Val* comm::data_to_val(broker::data d, BroType* type, bool require_log_attr)
|
||||
Val* bro_broker::data_to_val(broker::data d, BroType* type, bool require_log_attr)
|
||||
{
|
||||
return broker::visit(val_converter{type, require_log_attr}, d);
|
||||
}
|
||||
|
||||
broker::util::optional<broker::data> comm::val_to_data(Val* v)
|
||||
broker::util::optional<broker::data> bro_broker::val_to_data(Val* v)
|
||||
{
|
||||
switch ( v->Type()->Tag() ) {
|
||||
case TYPE_BOOL:
|
||||
|
@ -539,7 +539,7 @@ broker::util::optional<broker::data> comm::val_to_data(Val* v)
|
|||
return {rval};
|
||||
}
|
||||
default:
|
||||
reporter->Error("unsupported Comm::Data type: %s",
|
||||
reporter->Error("unsupported BrokerComm::Data type: %s",
|
||||
type_name(v->Type()->Tag()));
|
||||
break;
|
||||
}
|
||||
|
@ -547,9 +547,9 @@ broker::util::optional<broker::data> comm::val_to_data(Val* v)
|
|||
return {};
|
||||
}
|
||||
|
||||
RecordVal* comm::make_data_val(Val* v)
|
||||
RecordVal* bro_broker::make_data_val(Val* v)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::Comm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
auto data = val_to_data(v);
|
||||
|
||||
if ( data )
|
||||
|
@ -558,9 +558,9 @@ RecordVal* comm::make_data_val(Val* v)
|
|||
return rval;
|
||||
}
|
||||
|
||||
RecordVal* comm::make_data_val(broker::data d)
|
||||
RecordVal* bro_broker::make_data_val(broker::data d)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::Comm::Data);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
rval->Assign(0, new DataVal(move(d)));
|
||||
return rval;
|
||||
}
|
||||
|
@ -570,114 +570,114 @@ struct data_type_getter {
|
|||
|
||||
result_type operator()(bool a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::BOOL,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::BOOL,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(uint64_t a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::COUNT,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::COUNT,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(int64_t a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::INT,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::INT,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(double a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::DOUBLE,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::DOUBLE,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const std::string& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::STRING,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::STRING,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::address& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::ADDR,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::ADDR,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::subnet& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::SUBNET,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::SUBNET,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::port& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::PORT,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::PORT,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::time_point& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::TIME,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::TIME,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::time_duration& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::INTERVAL,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::INTERVAL,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::enum_value& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::ENUM,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::ENUM,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::set& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::SET,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::SET,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::table& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::TABLE,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::TABLE,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::vector& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::VECTOR,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::VECTOR,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
|
||||
result_type operator()(const broker::record& a)
|
||||
{
|
||||
return new EnumVal(BifEnum::Comm::RECORD,
|
||||
BifType::Enum::Comm::DataType);
|
||||
return new EnumVal(BifEnum::BrokerComm::RECORD,
|
||||
BifType::Enum::BrokerComm::DataType);
|
||||
}
|
||||
};
|
||||
|
||||
EnumVal* comm::get_data_type(RecordVal* v, Frame* frame)
|
||||
EnumVal* bro_broker::get_data_type(RecordVal* v, Frame* frame)
|
||||
{
|
||||
return broker::visit(data_type_getter{}, opaque_field_to_data(v, frame));
|
||||
}
|
||||
|
||||
broker::data& comm::opaque_field_to_data(RecordVal* v, Frame* f)
|
||||
broker::data& bro_broker::opaque_field_to_data(RecordVal* v, Frame* f)
|
||||
{
|
||||
Val* d = v->Lookup(0);
|
||||
|
||||
if ( ! d )
|
||||
reporter->RuntimeError(f->GetCall()->GetLocationInfo(),
|
||||
"Comm::Data's opaque field is not set");
|
||||
"BrokerComm::Data's opaque field is not set");
|
||||
|
||||
return static_cast<DataVal*>(d)->data;
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(comm::DataVal, SER_COMM_DATA_VAL);
|
||||
IMPLEMENT_SERIAL(bro_broker::DataVal, SER_COMM_DATA_VAL);
|
||||
|
||||
bool comm::DataVal::DoSerialize(SerialInfo* info) const
|
||||
bool bro_broker::DataVal::DoSerialize(SerialInfo* info) const
|
||||
{
|
||||
DO_SERIALIZE(SER_COMM_DATA_VAL, OpaqueVal);
|
||||
|
||||
|
@ -691,7 +691,7 @@ bool comm::DataVal::DoSerialize(SerialInfo* info) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::DataVal::DoUnserialize(UnserialInfo* info)
|
||||
bool bro_broker::DataVal::DoUnserialize(UnserialInfo* info)
|
||||
{
|
||||
DO_UNSERIALIZE(OpaqueVal);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Frame.h"
|
||||
#include "Expr.h"
|
||||
|
||||
namespace comm {
|
||||
namespace bro_broker {
|
||||
|
||||
extern OpaqueType* opaque_of_data_type;
|
||||
extern OpaqueType* opaque_of_set_iterator;
|
||||
|
@ -21,25 +21,25 @@ extern OpaqueType* opaque_of_record_iterator;
|
|||
TransportProto to_bro_port_proto(broker::port::protocol tp);
|
||||
|
||||
/**
|
||||
* Create a Comm::Data value from a Bro value.
|
||||
* Create a BrokerComm::Data value from a Bro value.
|
||||
* @param v the Bro value to convert to a Broker data value.
|
||||
* @return a Comm::Data value, where the optional field is set if the conversion
|
||||
* @return a BrokerComm::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 Comm::Data value from a Broker data value.
|
||||
* Create a BrokerComm::Data value from a Broker data value.
|
||||
* @param d the Broker value to wrap in an opaque type.
|
||||
* @return a Comm::Data value that wraps the Broker value.
|
||||
* @return a BrokerComm::Data value that wraps the Broker value.
|
||||
*/
|
||||
RecordVal* make_data_val(broker::data d);
|
||||
|
||||
/**
|
||||
* Get the type of Broker data that Comm::Data wraps.
|
||||
* @param v a Comm::Data value.
|
||||
* Get the type of Broker data that BrokerComm::Data wraps.
|
||||
* @param v a BrokerComm::Data value.
|
||||
* @param frame used to get location info upon error.
|
||||
* @return a Comm::DataType value.
|
||||
* @return a BrokerComm::DataType value.
|
||||
*/
|
||||
EnumVal* get_data_type(RecordVal* v, Frame* frame);
|
||||
|
||||
|
@ -68,7 +68,7 @@ class DataVal : public OpaqueVal {
|
|||
public:
|
||||
|
||||
DataVal(broker::data arg_data)
|
||||
: OpaqueVal(comm::opaque_of_data_type), data(std::move(arg_data))
|
||||
: OpaqueVal(bro_broker::opaque_of_data_type), data(std::move(arg_data))
|
||||
{}
|
||||
|
||||
void ValDescribe(ODesc* d) const override
|
||||
|
@ -141,8 +141,8 @@ struct type_name_getter {
|
|||
};
|
||||
|
||||
/**
|
||||
* Retrieve Broker data value associated with a Comm::Data Bro value.
|
||||
* @param v a Comm::Data value.
|
||||
* Retrieve Broker data value associated with a BrokerComm::Data Bro value.
|
||||
* @param v a BrokerComm::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 Comm::Data Bro value to a Bro value of a given type.
|
||||
* Convert a BrokerComm::Data Bro value to a Bro value of a given type.
|
||||
* @tparam a type that a Broker data variant may contain.
|
||||
* @param v a Comm::Data value.
|
||||
* @param v a BrokerComm::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
|
||||
|
@ -203,7 +203,7 @@ class SetIterator : public OpaqueVal {
|
|||
public:
|
||||
|
||||
SetIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
: OpaqueVal(comm::opaque_of_set_iterator),
|
||||
: OpaqueVal(bro_broker::opaque_of_set_iterator),
|
||||
dat(require_data_type<broker::set>(v, TYPE_TABLE, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -216,7 +216,7 @@ class TableIterator : public OpaqueVal {
|
|||
public:
|
||||
|
||||
TableIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
: OpaqueVal(comm::opaque_of_table_iterator),
|
||||
: OpaqueVal(bro_broker::opaque_of_table_iterator),
|
||||
dat(require_data_type<broker::table>(v, TYPE_TABLE, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -229,7 +229,7 @@ class VectorIterator : public OpaqueVal {
|
|||
public:
|
||||
|
||||
VectorIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
: OpaqueVal(comm::opaque_of_vector_iterator),
|
||||
: OpaqueVal(bro_broker::opaque_of_vector_iterator),
|
||||
dat(require_data_type<broker::vector>(v, TYPE_VECTOR, f)),
|
||||
it(dat.begin())
|
||||
{}
|
||||
|
@ -242,7 +242,7 @@ class RecordIterator : public OpaqueVal {
|
|||
public:
|
||||
|
||||
RecordIterator(RecordVal* v, TypeTag tag, Frame* f)
|
||||
: OpaqueVal(comm::opaque_of_record_iterator),
|
||||
: OpaqueVal(bro_broker::opaque_of_record_iterator),
|
||||
dat(require_data_type<broker::record>(v, TYPE_VECTOR, f)),
|
||||
it(dat.fields.begin())
|
||||
{}
|
||||
|
@ -251,6 +251,6 @@ public:
|
|||
decltype(broker::record::fields)::iterator it;
|
||||
};
|
||||
|
||||
} // namespace comm
|
||||
} // namespace bro_broker
|
||||
|
||||
#endif // BRO_COMM_DATA_H
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
VectorType* comm::Manager::vector_of_data_type;
|
||||
EnumType* comm::Manager::log_id_type;
|
||||
int comm::Manager::send_flags_self_idx;
|
||||
int comm::Manager::send_flags_peers_idx;
|
||||
int comm::Manager::send_flags_unsolicited_idx;
|
||||
VectorType* bro_broker::Manager::vector_of_data_type;
|
||||
EnumType* bro_broker::Manager::log_id_type;
|
||||
int bro_broker::Manager::send_flags_self_idx;
|
||||
int bro_broker::Manager::send_flags_peers_idx;
|
||||
int bro_broker::Manager::send_flags_unsolicited_idx;
|
||||
|
||||
comm::Manager::~Manager()
|
||||
bro_broker::Manager::~Manager()
|
||||
{
|
||||
for ( auto& s : data_stores )
|
||||
CloseStore(s.first.first, s.first.second);
|
||||
|
@ -59,25 +59,25 @@ static int endpoint_flags_to_int(Val* broker_endpoint_flags)
|
|||
return rval;
|
||||
}
|
||||
|
||||
bool comm::Manager::Enable(Val* broker_endpoint_flags)
|
||||
bool bro_broker::Manager::Enable(Val* broker_endpoint_flags)
|
||||
{
|
||||
if ( endpoint != nullptr )
|
||||
return true;
|
||||
|
||||
auto send_flags_type = internal_type("Comm::SendFlags")->AsRecordType();
|
||||
auto send_flags_type = internal_type("BrokerComm::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();
|
||||
|
||||
comm::opaque_of_data_type = new OpaqueType("Comm::Data");
|
||||
comm::opaque_of_set_iterator = new OpaqueType("Comm::SetIterator");
|
||||
comm::opaque_of_table_iterator = new OpaqueType("Comm::TableIterator");
|
||||
comm::opaque_of_vector_iterator = new OpaqueType("Comm::VectorIterator");
|
||||
comm::opaque_of_record_iterator = new OpaqueType("Comm::RecordIterator");
|
||||
comm::opaque_of_store_handle = new OpaqueType("Store::Handle");
|
||||
vector_of_data_type = new VectorType(internal_type("Comm::Data")->Ref());
|
||||
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());
|
||||
|
||||
auto res = broker::init();
|
||||
|
||||
|
@ -97,7 +97,7 @@ bool comm::Manager::Enable(Val* broker_endpoint_flags)
|
|||
}
|
||||
|
||||
const char* name;
|
||||
auto name_from_script = internal_val("Comm::endpoint_name")->AsString();
|
||||
auto name_from_script = internal_val("BrokerComm::endpoint_name")->AsString();
|
||||
|
||||
if ( name_from_script->Len() )
|
||||
name = name_from_script->CheckString();
|
||||
|
@ -117,7 +117,7 @@ bool comm::Manager::Enable(Val* broker_endpoint_flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::SetEndpointFlags(Val* broker_endpoint_flags)
|
||||
bool bro_broker::Manager::SetEndpointFlags(Val* broker_endpoint_flags)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -127,7 +127,7 @@ bool comm::Manager::SetEndpointFlags(Val* broker_endpoint_flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::Listen(uint16_t port, const char* addr, bool reuse_addr)
|
||||
bool bro_broker::Manager::Listen(uint16_t port, const char* addr, bool reuse_addr)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -144,7 +144,7 @@ bool comm::Manager::Listen(uint16_t port, const char* addr, bool reuse_addr)
|
|||
return rval;
|
||||
}
|
||||
|
||||
bool comm::Manager::Connect(string addr, uint16_t port,
|
||||
bool bro_broker::Manager::Connect(string addr, uint16_t port,
|
||||
chrono::duration<double> retry_interval)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
|
@ -159,7 +159,7 @@ bool comm::Manager::Connect(string addr, uint16_t port,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::Disconnect(const string& addr, uint16_t port)
|
||||
bool bro_broker::Manager::Disconnect(const string& addr, uint16_t port)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -174,7 +174,7 @@ bool comm::Manager::Disconnect(const string& addr, uint16_t port)
|
|||
return rval;
|
||||
}
|
||||
|
||||
bool comm::Manager::Print(string topic, string msg, Val* flags)
|
||||
bool bro_broker::Manager::Print(string topic, string msg, Val* flags)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -184,7 +184,7 @@ bool comm::Manager::Print(string topic, string msg, Val* flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::Event(std::string topic, broker::message msg, int flags)
|
||||
bool bro_broker::Manager::Event(std::string topic, broker::message msg, int flags)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -193,7 +193,7 @@ bool comm::Manager::Event(std::string topic, broker::message msg, int flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::Log(EnumVal* stream, RecordVal* columns, RecordType* info,
|
||||
bool bro_broker::Manager::Log(EnumVal* stream, RecordVal* columns, RecordType* info,
|
||||
int flags)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
|
@ -245,7 +245,7 @@ bool comm::Manager::Log(EnumVal* stream, RecordVal* columns, RecordType* info,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::Event(std::string topic, RecordVal* args, Val* flags)
|
||||
bool bro_broker::Manager::Event(std::string topic, RecordVal* args, Val* flags)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -270,14 +270,14 @@ bool comm::Manager::Event(std::string topic, RecordVal* args, Val* flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
||||
bool bro_broker::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
||||
if ( event->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
reporter->Error("Comm::auto_event must operate on an event");
|
||||
reporter->Error("BrokerComm::auto_event must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ bool comm::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
|||
|
||||
if ( event_val->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("Comm::auto_event must operate on an event");
|
||||
reporter->Error("BrokerComm::auto_event must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ bool comm::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
|||
|
||||
if ( ! handler )
|
||||
{
|
||||
reporter->Error("Comm::auto_event failed to lookup event '%s'",
|
||||
reporter->Error("BrokerComm::auto_event failed to lookup event '%s'",
|
||||
event_val->Name());
|
||||
return false;
|
||||
}
|
||||
|
@ -302,14 +302,14 @@ bool comm::Manager::AutoEvent(string topic, Val* event, Val* flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::AutoEventStop(const string& topic, Val* event)
|
||||
bool bro_broker::Manager::AutoEventStop(const string& topic, Val* event)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
||||
if ( event->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
reporter->Error("Comm::auto_event_stop must operate on an event");
|
||||
reporter->Error("BrokerComm::auto_event_stop must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ bool comm::Manager::AutoEventStop(const string& topic, Val* event)
|
|||
|
||||
if ( event_val->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("Comm::auto_event_stop must operate on an event");
|
||||
reporter->Error("BrokerComm::auto_event_stop must operate on an event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ bool comm::Manager::AutoEventStop(const string& topic, Val* event)
|
|||
|
||||
if ( ! handler )
|
||||
{
|
||||
reporter->Error("Comm::auto_event_stop failed to lookup event '%s'",
|
||||
reporter->Error("BrokerComm::auto_event_stop failed to lookup event '%s'",
|
||||
event_val->Name());
|
||||
return false;
|
||||
}
|
||||
|
@ -335,12 +335,12 @@ bool comm::Manager::AutoEventStop(const string& topic, Val* event)
|
|||
return true;
|
||||
}
|
||||
|
||||
RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
||||
RecordVal* bro_broker::Manager::MakeEventArgs(val_list* args)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return nullptr;
|
||||
|
||||
auto rval = new RecordVal(BifType::Record::Comm::EventArgs);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::EventArgs);
|
||||
auto arg_vec = new VectorVal(vector_of_data_type);
|
||||
rval->Assign(1, arg_vec);
|
||||
Func* func = 0;
|
||||
|
@ -355,7 +355,7 @@ RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
|||
|
||||
if ( arg_val->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
reporter->Error("1st param of Comm::event_args must be event");
|
||||
reporter->Error("1st param of BrokerComm::event_args must be event");
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
|||
|
||||
if ( func->Flavor() != FUNC_FLAVOR_EVENT )
|
||||
{
|
||||
reporter->Error("1st param of Comm::event_args must be event");
|
||||
reporter->Error("1st param of BrokerComm::event_args must be event");
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
|||
|
||||
if ( num_args != args->length() - 1 )
|
||||
{
|
||||
reporter->Error("bad # of Comm::event_args: got %d, expect %d",
|
||||
reporter->Error("bad # of BrokerComm::event_args: got %d, expect %d",
|
||||
args->length(), num_args + 1);
|
||||
return rval;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
|||
if ( ! same_type((*args)[i]->Type(), expected_type) )
|
||||
{
|
||||
rval->Assign(0, 0);
|
||||
reporter->Error("Comm::event_args param %d type mismatch", i);
|
||||
reporter->Error("BrokerComm::event_args param %d type mismatch", i);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
|||
{
|
||||
Unref(data_val);
|
||||
rval->Assign(0, 0);
|
||||
reporter->Error("Comm::event_args unsupported event/params");
|
||||
reporter->Error("BrokerComm::event_args unsupported event/params");
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ RecordVal* comm::Manager::MakeEventArgs(val_list* args)
|
|||
return rval;
|
||||
}
|
||||
|
||||
bool comm::Manager::SubscribeToPrints(string topic_prefix)
|
||||
bool bro_broker::Manager::SubscribeToPrints(string topic_prefix)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -419,7 +419,7 @@ bool comm::Manager::SubscribeToPrints(string topic_prefix)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::UnsubscribeToPrints(const string& topic_prefix)
|
||||
bool bro_broker::Manager::UnsubscribeToPrints(const string& topic_prefix)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -427,7 +427,7 @@ bool comm::Manager::UnsubscribeToPrints(const string& topic_prefix)
|
|||
return print_subscriptions.erase(topic_prefix);
|
||||
}
|
||||
|
||||
bool comm::Manager::SubscribeToEvents(string topic_prefix)
|
||||
bool bro_broker::Manager::SubscribeToEvents(string topic_prefix)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -441,7 +441,7 @@ bool comm::Manager::SubscribeToEvents(string topic_prefix)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::UnsubscribeToEvents(const string& topic_prefix)
|
||||
bool bro_broker::Manager::UnsubscribeToEvents(const string& topic_prefix)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -449,7 +449,7 @@ bool comm::Manager::UnsubscribeToEvents(const string& topic_prefix)
|
|||
return event_subscriptions.erase(topic_prefix);
|
||||
}
|
||||
|
||||
bool comm::Manager::SubscribeToLogs(string topic_prefix)
|
||||
bool bro_broker::Manager::SubscribeToLogs(string topic_prefix)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -463,7 +463,7 @@ bool comm::Manager::SubscribeToLogs(string topic_prefix)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::UnsubscribeToLogs(const string& topic_prefix)
|
||||
bool bro_broker::Manager::UnsubscribeToLogs(const string& topic_prefix)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -471,7 +471,7 @@ bool comm::Manager::UnsubscribeToLogs(const string& topic_prefix)
|
|||
return log_subscriptions.erase(topic_prefix);
|
||||
}
|
||||
|
||||
bool comm::Manager::PublishTopic(broker::topic t)
|
||||
bool bro_broker::Manager::PublishTopic(broker::topic t)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -480,7 +480,7 @@ bool comm::Manager::PublishTopic(broker::topic t)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::UnpublishTopic(broker::topic t)
|
||||
bool bro_broker::Manager::UnpublishTopic(broker::topic t)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -489,7 +489,7 @@ bool comm::Manager::UnpublishTopic(broker::topic t)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::AdvertiseTopic(broker::topic t)
|
||||
bool bro_broker::Manager::AdvertiseTopic(broker::topic t)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -498,7 +498,7 @@ bool comm::Manager::AdvertiseTopic(broker::topic t)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::UnadvertiseTopic(broker::topic t)
|
||||
bool bro_broker::Manager::UnadvertiseTopic(broker::topic t)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -507,7 +507,7 @@ bool comm::Manager::UnadvertiseTopic(broker::topic t)
|
|||
return true;
|
||||
}
|
||||
|
||||
int comm::Manager::send_flags_to_int(Val* flags)
|
||||
int bro_broker::Manager::send_flags_to_int(Val* flags)
|
||||
{
|
||||
auto r = flags->AsRecordVal();
|
||||
int rval = 0;
|
||||
|
@ -530,7 +530,7 @@ int comm::Manager::send_flags_to_int(Val* flags)
|
|||
return rval;
|
||||
}
|
||||
|
||||
void comm::Manager::GetFds(iosource::FD_Set* read, iosource::FD_Set* write,
|
||||
void bro_broker::Manager::GetFds(iosource::FD_Set* read, iosource::FD_Set* write,
|
||||
iosource::FD_Set* except)
|
||||
{
|
||||
read->Insert(endpoint->outgoing_connection_status().fd());
|
||||
|
@ -551,7 +551,7 @@ void comm::Manager::GetFds(iosource::FD_Set* read, iosource::FD_Set* write,
|
|||
read->Insert(broker::report::default_queue->fd());
|
||||
}
|
||||
|
||||
double comm::Manager::NextTimestamp(double* local_network_time)
|
||||
double bro_broker::Manager::NextTimestamp(double* local_network_time)
|
||||
{
|
||||
// TODO: do something better?
|
||||
return timer_mgr->Time();
|
||||
|
@ -569,25 +569,25 @@ 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::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
default:
|
||||
return comm::make_data_val(broker::data{d});
|
||||
return bro_broker::make_data_val(broker::data{d});
|
||||
}
|
||||
}
|
||||
|
||||
result_type operator()(uint64_t d)
|
||||
{
|
||||
return comm::make_data_val(broker::data{d});
|
||||
return bro_broker::make_data_val(broker::data{d});
|
||||
}
|
||||
|
||||
result_type operator()(broker::data& d)
|
||||
{
|
||||
return comm::make_data_val(move(d));
|
||||
return bro_broker::make_data_val(move(d));
|
||||
}
|
||||
|
||||
result_type operator()(std::vector<broker::data>& d)
|
||||
{
|
||||
return comm::make_data_val(broker::data{move(d)});
|
||||
return bro_broker::make_data_val(broker::data{move(d)});
|
||||
}
|
||||
|
||||
result_type operator()(broker::store::snapshot& d)
|
||||
|
@ -601,7 +601,7 @@ struct response_converter {
|
|||
table[move(key)] = move(val);
|
||||
}
|
||||
|
||||
return comm::make_data_val(broker::data{move(table)});
|
||||
return bro_broker::make_data_val(broker::data{move(table)});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -610,7 +610,7 @@ static RecordVal* response_to_val(broker::store::response r)
|
|||
return broker::visit(response_converter{r.request.type}, r.reply.value);
|
||||
}
|
||||
|
||||
void comm::Manager::Process()
|
||||
void bro_broker::Manager::Process()
|
||||
{
|
||||
bool idle = true;
|
||||
auto outgoing_connection_updates =
|
||||
|
@ -627,36 +627,36 @@ void comm::Manager::Process()
|
|||
|
||||
switch ( u.status ) {
|
||||
case broker::outgoing_connection_status::tag::established:
|
||||
if ( Comm::outgoing_connection_established )
|
||||
if ( BrokerComm::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(Comm::outgoing_connection_established, vl);
|
||||
mgr.QueueEvent(BrokerComm::outgoing_connection_established, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
case broker::outgoing_connection_status::tag::disconnected:
|
||||
if ( Comm::outgoing_connection_broken )
|
||||
if ( BrokerComm::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(Comm::outgoing_connection_broken, vl);
|
||||
mgr.QueueEvent(BrokerComm::outgoing_connection_broken, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
case broker::outgoing_connection_status::tag::incompatible:
|
||||
if ( Comm::outgoing_connection_incompatible )
|
||||
if ( BrokerComm::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(Comm::outgoing_connection_incompatible, vl);
|
||||
mgr.QueueEvent(BrokerComm::outgoing_connection_incompatible, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -674,20 +674,20 @@ void comm::Manager::Process()
|
|||
|
||||
switch ( u.status ) {
|
||||
case broker::incoming_connection_status::tag::established:
|
||||
if ( Comm::incoming_connection_established )
|
||||
if ( BrokerComm::incoming_connection_established )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.peer_name));
|
||||
mgr.QueueEvent(Comm::incoming_connection_established, vl);
|
||||
mgr.QueueEvent(BrokerComm::incoming_connection_established, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
case broker::incoming_connection_status::tag::disconnected:
|
||||
if ( Comm::incoming_connection_broken )
|
||||
if ( BrokerComm::incoming_connection_broken )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(u.peer_name));
|
||||
mgr.QueueEvent(Comm::incoming_connection_broken, vl);
|
||||
mgr.QueueEvent(BrokerComm::incoming_connection_broken, vl);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -709,7 +709,7 @@ void comm::Manager::Process()
|
|||
ps.second.received += print_messages.size();
|
||||
idle = false;
|
||||
|
||||
if ( ! Comm::print_handler )
|
||||
if ( ! BrokerComm::print_handler )
|
||||
continue;
|
||||
|
||||
for ( auto& pm : print_messages )
|
||||
|
@ -732,7 +732,7 @@ void comm::Manager::Process()
|
|||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new StringVal(move(*msg)));
|
||||
mgr.QueueEvent(Comm::print_handler, vl);
|
||||
mgr.QueueEvent(BrokerComm::print_handler, vl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,7 +975,7 @@ void comm::Manager::Process()
|
|||
SetIdle(idle);
|
||||
}
|
||||
|
||||
bool comm::Manager::AddStore(StoreHandleVal* handle)
|
||||
bool bro_broker::Manager::AddStore(StoreHandleVal* handle)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return false;
|
||||
|
@ -993,9 +993,9 @@ bool comm::Manager::AddStore(StoreHandleVal* handle)
|
|||
return true;
|
||||
}
|
||||
|
||||
comm::StoreHandleVal*
|
||||
comm::Manager::LookupStore(const broker::store::identifier& id,
|
||||
comm::StoreType type)
|
||||
bro_broker::StoreHandleVal*
|
||||
bro_broker::Manager::LookupStore(const broker::store::identifier& id,
|
||||
bro_broker::StoreType type)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
return nullptr;
|
||||
|
@ -1009,7 +1009,7 @@ comm::Manager::LookupStore(const broker::store::identifier& id,
|
|||
return it->second;
|
||||
}
|
||||
|
||||
bool comm::Manager::CloseStore(const broker::store::identifier& id,
|
||||
bool bro_broker::Manager::CloseStore(const broker::store::identifier& id,
|
||||
StoreType type)
|
||||
{
|
||||
if ( ! Enabled() )
|
||||
|
@ -1041,13 +1041,13 @@ bool comm::Manager::CloseStore(const broker::store::identifier& id,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::Manager::TrackStoreQuery(StoreQueryCallback* cb)
|
||||
bool bro_broker::Manager::TrackStoreQuery(StoreQueryCallback* cb)
|
||||
{
|
||||
assert(Enabled());
|
||||
return pending_queries.insert(cb).second;
|
||||
}
|
||||
|
||||
comm::Stats comm::Manager::ConsumeStatistics()
|
||||
bro_broker::Stats bro_broker::Manager::ConsumeStatistics()
|
||||
{
|
||||
statistics.outgoing_peer_count = peers.size();
|
||||
statistics.data_store_count = data_stores.size();
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include "iosource/IOSource.h"
|
||||
#include "Val.h"
|
||||
|
||||
namespace comm {
|
||||
namespace bro_broker {
|
||||
|
||||
/**
|
||||
* Communication statistics. Some are tracked in relation to last
|
||||
* sample (comm::Manager::ConsumeStatistics()).
|
||||
* sample (bro_broker::Manager::ConsumeStatistics()).
|
||||
*/
|
||||
struct Stats {
|
||||
// Number of outgoing peer connections (at time of sample).
|
||||
|
@ -58,20 +58,20 @@ public:
|
|||
/**
|
||||
* Enable use of communication.
|
||||
* @param flags used to tune the local Broker endpoint's behavior.
|
||||
* See the Comm::EndpointFlags record type.
|
||||
* See the BrokerComm::EndpointFlags record type.
|
||||
* @return true if communication is successfully initialized.
|
||||
*/
|
||||
bool Enable(Val* flags);
|
||||
|
||||
/**
|
||||
* Changes endpoint flags originally supplied to comm::Manager::Enable().
|
||||
* Changes endpoint flags originally supplied to bro_broker::Manager::Enable().
|
||||
* @param flags the new behavior flags to use.
|
||||
* @return true if flags were changed.
|
||||
*/
|
||||
bool SetEndpointFlags(Val* flags);
|
||||
|
||||
/**
|
||||
* @return true if comm::Manager::Enable() has previously been called and
|
||||
* @return true if bro_broker::Manager::Enable() has previously been called and
|
||||
* it succeeded.
|
||||
*/
|
||||
bool Enabled()
|
||||
|
@ -103,10 +103,10 @@ public:
|
|||
|
||||
/**
|
||||
* Remove a remote connection.
|
||||
* @param addr the address used in comm::Manager::Connect().
|
||||
* @param port the port used in comm::Manager::Connect().
|
||||
* @param addr the address used in bro_broker::Manager::Connect().
|
||||
* @param port the port used in bro_broker::Manager::Connect().
|
||||
* @return true if the arguments match a previously successful call to
|
||||
* comm::Manager::Connect().
|
||||
* bro_broker::Manager::Connect().
|
||||
*/
|
||||
bool Disconnect(const std::string& addr, uint16_t port);
|
||||
|
||||
|
@ -117,7 +117,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 Comm::SendFlags record type.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Print(std::string topic, std::string msg, Val* flags);
|
||||
|
@ -130,7 +130,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 Comm::SendFlags record type.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Event(std::string topic, broker::message msg, int flags);
|
||||
|
@ -141,9 +141,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
|
||||
* Comm::EventArgs record type.
|
||||
* BrokerComm::EventArgs record type.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the Comm::SendFlags record type.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Event(std::string topic, RecordVal* args, Val* flags);
|
||||
|
@ -155,7 +155,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 Comm::SendFlags record type.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool Log(EnumVal* stream_id, RecordVal* columns, RecordType* info,
|
||||
|
@ -169,15 +169,15 @@ public:
|
|||
* of this topic name.
|
||||
* @param event a Bro event value.
|
||||
* @param flags tune the behavior of how the message is send.
|
||||
* See the Comm::SendFlags record type.
|
||||
* See the BrokerComm::SendFlags record type.
|
||||
* @return true if automatic event sending is now enabled.
|
||||
*/
|
||||
bool AutoEvent(std::string topic, Val* event, Val* flags);
|
||||
|
||||
/**
|
||||
* Stop automatically sending an event to peers upon local dispatch.
|
||||
* @param topic a topic originally given to comm::Manager::AutoEvent().
|
||||
* @param event an event originally given to comm::Manager::AutoEvent().
|
||||
* @param topic a topic originally given to bro_broker::Manager::AutoEvent().
|
||||
* @param event an event originally given to bro_broker::Manager::AutoEvent().
|
||||
* @return true if automatic events will no occur for the topic/event pair.
|
||||
*/
|
||||
bool AutoEventStop(const std::string& topic, Val* event);
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
/**
|
||||
* Unregister interest in peer print messages.
|
||||
* @param topic_prefix a prefix previously supplied to a successful call
|
||||
* to comm::Manager::SubscribeToPrints().
|
||||
* to bro_broker::Manager::SubscribeToPrints().
|
||||
* @return true if interest in topic prefix is no longer advertised.
|
||||
*/
|
||||
bool UnsubscribeToPrints(const std::string& topic_prefix);
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
/**
|
||||
* Unregister interest in peer event messages.
|
||||
* @param topic_prefix a prefix previously supplied to a successful call
|
||||
* to comm::Manager::SubscribeToEvents().
|
||||
* to bro_broker::Manager::SubscribeToEvents().
|
||||
* @return true if interest in topic prefix is no longer advertised.
|
||||
*/
|
||||
bool UnsubscribeToEvents(const std::string& topic_prefix);
|
||||
|
@ -237,7 +237,7 @@ public:
|
|||
/**
|
||||
* Unregister interest in peer log messages.
|
||||
* @param topic_prefix a prefix previously supplied to a successful call
|
||||
* to comm::Manager::SubscribeToLogs().
|
||||
* to bro_broker::Manager::SubscribeToLogs().
|
||||
* @return true if interest in topic prefix is no longer advertised.
|
||||
*/
|
||||
bool UnsubscribeToLogs(const std::string& topic_prefix);
|
||||
|
@ -245,7 +245,7 @@ public:
|
|||
/**
|
||||
* 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 comm::Manager::Enable() or comm::Manager::SetEndpointFlags().
|
||||
* supplied to bro_broker::Manager::Enable() or bro_broker::Manager::SetEndpointFlags().
|
||||
* @param t a topic to allow messages to be published under.
|
||||
* @return true if successful.
|
||||
*/
|
||||
|
@ -254,7 +254,7 @@ public:
|
|||
/**
|
||||
* 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 comm::Manager::Enable() or comm::Manager::SetEndpointFlags().
|
||||
* supplied to bro_broker::Manager::Enable() or bro_broker::Manager::SetEndpointFlags().
|
||||
* @param t a topic to disallow messages to be published under.
|
||||
* @return true if successful.
|
||||
*/
|
||||
|
@ -263,7 +263,7 @@ public:
|
|||
/**
|
||||
* Allow advertising interest in the given topic to peers.
|
||||
* This has no effect if auto advertise behavior is enabled via the flags
|
||||
* supplied to comm::Manager::Enable() or comm::Manager::SetEndpointFlags().
|
||||
* supplied to bro_broker::Manager::Enable() or bro_broker::Manager::SetEndpointFlags().
|
||||
* @param t a topic to allow advertising interest/subscription to peers.
|
||||
* @return true if successful.
|
||||
*/
|
||||
|
@ -272,7 +272,7 @@ public:
|
|||
/**
|
||||
* Disallow advertising interest in the given topic to peers.
|
||||
* This has no effect if auto advertise behavior is enabled via the flags
|
||||
* supplied to comm::Manager::Enable() or comm::Manager::SetEndpointFlags().
|
||||
* supplied to bro_broker::Manager::Enable() or bro_broker::Manager::SetEndpointFlags().
|
||||
* @param t a topic to disallow advertising interest/subscription to peers.
|
||||
* @return true if successful.
|
||||
*/
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
Stats ConsumeStatistics();
|
||||
|
||||
/**
|
||||
* Convert Comm::SendFlags to int flags for use with broker::send().
|
||||
* Convert BrokerComm::SendFlags to int flags for use with broker::send().
|
||||
*/
|
||||
static int send_flags_to_int(Val* flags);
|
||||
|
||||
|
@ -330,7 +330,7 @@ private:
|
|||
void Process() override;
|
||||
|
||||
const char* Tag() override
|
||||
{ return "Comm::Manager"; }
|
||||
{ return "BrokerComm::Manager"; }
|
||||
|
||||
broker::endpoint& Endpoint()
|
||||
{ return *endpoint; }
|
||||
|
@ -359,8 +359,8 @@ private:
|
|||
static int send_flags_unsolicited_idx;
|
||||
};
|
||||
|
||||
} // namespace comm
|
||||
} // namespace bro_broker
|
||||
|
||||
extern comm::Manager* comm_mgr;
|
||||
extern bro_broker::Manager* broker_mgr;
|
||||
|
||||
#endif // BRO_COMM_MANAGER_H
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
#include <rocksdb/db.h>
|
||||
#endif
|
||||
|
||||
OpaqueType* comm::opaque_of_store_handle;
|
||||
OpaqueType* bro_broker::opaque_of_store_handle;
|
||||
|
||||
comm::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
||||
comm::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::Store::BackendType> arg_back,
|
||||
bro_broker::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
||||
bro_broker::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::BrokerStore::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::Store::BackendType;
|
||||
using BifEnum::BrokerStore::BackendType;
|
||||
std::unique_ptr<broker::store::backend> backend;
|
||||
|
||||
if ( backend_type )
|
||||
|
@ -73,14 +73,14 @@ comm::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
|||
|
||||
switch ( store_type ) {
|
||||
case StoreType::FRONTEND:
|
||||
store = new broker::store::frontend(comm_mgr->Endpoint(), move(id));
|
||||
store = new broker::store::frontend(broker_mgr->Endpoint(), move(id));
|
||||
break;
|
||||
case StoreType::MASTER:
|
||||
store = new broker::store::master(comm_mgr->Endpoint(), move(id),
|
||||
store = new broker::store::master(broker_mgr->Endpoint(), move(id),
|
||||
move(backend));
|
||||
break;
|
||||
case StoreType::CLONE:
|
||||
store = new broker::store::clone(comm_mgr->Endpoint(), move(id), resync,
|
||||
store = new broker::store::clone(broker_mgr->Endpoint(), move(id), resync,
|
||||
move(backend));
|
||||
break;
|
||||
default:
|
||||
|
@ -89,9 +89,9 @@ comm::StoreHandleVal::StoreHandleVal(broker::store::identifier id,
|
|||
}
|
||||
}
|
||||
|
||||
void comm::StoreHandleVal::ValDescribe(ODesc* d) const
|
||||
void bro_broker::StoreHandleVal::ValDescribe(ODesc* d) const
|
||||
{
|
||||
using BifEnum::Store::BackendType;
|
||||
using BifEnum::BrokerStore::BackendType;
|
||||
d->Add("broker::store::");
|
||||
|
||||
switch ( store_type ) {
|
||||
|
@ -133,9 +133,9 @@ void comm::StoreHandleVal::ValDescribe(ODesc* d) const
|
|||
d->Add("}");
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(comm::StoreHandleVal, SER_COMM_STORE_HANDLE_VAL);
|
||||
IMPLEMENT_SERIAL(bro_broker::StoreHandleVal, SER_COMM_STORE_HANDLE_VAL);
|
||||
|
||||
bool comm::StoreHandleVal::DoSerialize(SerialInfo* info) const
|
||||
bool bro_broker::StoreHandleVal::DoSerialize(SerialInfo* info) const
|
||||
{
|
||||
DO_SERIALIZE(SER_COMM_STORE_HANDLE_VAL, OpaqueVal);
|
||||
|
||||
|
@ -156,7 +156,7 @@ bool comm::StoreHandleVal::DoSerialize(SerialInfo* info) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool comm::StoreHandleVal::DoUnserialize(UnserialInfo* info)
|
||||
bool bro_broker::StoreHandleVal::DoUnserialize(UnserialInfo* info)
|
||||
{
|
||||
DO_UNSERIALIZE(OpaqueVal);
|
||||
|
||||
|
@ -185,7 +185,7 @@ bool comm::StoreHandleVal::DoUnserialize(UnserialInfo* info)
|
|||
broker::store::identifier id(id_str, len);
|
||||
delete [] id_str;
|
||||
|
||||
auto handle = comm_mgr->LookupStore(id, static_cast<comm::StoreType>(type));
|
||||
auto handle = broker_mgr->LookupStore(id, static_cast<bro_broker::StoreType>(type));
|
||||
|
||||
if ( ! handle )
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <broker/store/frontend.hh>
|
||||
|
||||
namespace comm {
|
||||
namespace bro_broker {
|
||||
|
||||
extern OpaqueType* opaque_of_store_handle;
|
||||
|
||||
|
@ -25,9 +25,9 @@ enum StoreType {
|
|||
};
|
||||
|
||||
/**
|
||||
* Create a Store::QueryStatus value.
|
||||
* Create a BrokerStore::QueryStatus value.
|
||||
* @param success whether the query status should be set to success or failure.
|
||||
* @return a Store::QueryStatus value.
|
||||
* @return a BrokerStore::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("Store::QueryStatus")->AsEnumType();
|
||||
success_val = store_query_status->Lookup("Store", "SUCCESS");
|
||||
failure_val = store_query_status->Lookup("Store", "FAILURE");
|
||||
store_query_status = internal_type("BrokerStore::QueryStatus")->AsEnumType();
|
||||
success_val = store_query_status->Lookup("BrokerStore", "SUCCESS");
|
||||
failure_val = store_query_status->Lookup("BrokerStore", "FAILURE");
|
||||
}
|
||||
|
||||
return new EnumVal(success ? success_val : failure_val, store_query_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a Store::QueryResult value that has a Store::QueryStatus indicating
|
||||
* @return a BrokerStore::QueryResult value that has a BrokerStore::QueryStatus indicating
|
||||
* a failure.
|
||||
*/
|
||||
inline RecordVal* query_result()
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::Store::QueryResult);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerStore::QueryResult);
|
||||
rval->Assign(0, query_status(false));
|
||||
rval->Assign(1, new RecordVal(BifType::Record::Comm::Data));
|
||||
rval->Assign(1, new RecordVal(BifType::Record::BrokerComm::Data));
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data the result of the query.
|
||||
* @return a Store::QueryResult value that has a Store::QueryStatus indicating
|
||||
* @return a BrokerStore::QueryResult value that has a BrokerStore::QueryStatus indicating
|
||||
* a success.
|
||||
*/
|
||||
inline RecordVal* query_result(RecordVal* data)
|
||||
{
|
||||
auto rval = new RecordVal(BifType::Record::Store::QueryResult);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerStore::QueryResult);
|
||||
rval->Assign(0, query_status(true));
|
||||
rval->Assign(1, data);
|
||||
return rval;
|
||||
|
@ -129,8 +129,8 @@ class StoreHandleVal : public OpaqueVal {
|
|||
public:
|
||||
|
||||
StoreHandleVal(broker::store::identifier id,
|
||||
comm::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::Store::BackendType> arg_back,
|
||||
bro_broker::StoreType arg_type,
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> arg_back,
|
||||
RecordVal* backend_options,
|
||||
std::chrono::duration<double> resync = std::chrono::seconds(1));
|
||||
|
||||
|
@ -139,8 +139,8 @@ public:
|
|||
DECLARE_SERIAL(StoreHandleVal);
|
||||
|
||||
broker::store::frontend* store;
|
||||
comm::StoreType store_type;
|
||||
broker::util::optional<BifEnum::Store::BackendType> backend_type;
|
||||
bro_broker::StoreType store_type;
|
||||
broker::util::optional<BifEnum::BrokerStore::BackendType> backend_type;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -148,6 +148,6 @@ protected:
|
|||
{}
|
||||
};
|
||||
|
||||
} // namespace comm
|
||||
} // namespace bro_broker
|
||||
|
||||
#endif // BRO_COMM_STORE_H
|
||||
|
|
|
@ -5,124 +5,124 @@
|
|||
#include "comm/Manager.h"
|
||||
%%}
|
||||
|
||||
module Comm;
|
||||
module BrokerComm;
|
||||
|
||||
type Comm::EndpointFlags: record;
|
||||
type BrokerComm::EndpointFlags: record;
|
||||
|
||||
## Enable use of communication.
|
||||
##
|
||||
## flags: used to tune the local Broker endpoint behavior.
|
||||
##
|
||||
## Returns: true if communication is successfully initialized.
|
||||
function Comm::enable%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
function BrokerComm::enable%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
%{
|
||||
return new Val(comm_mgr->Enable(flags), TYPE_BOOL);
|
||||
return new Val(broker_mgr->Enable(flags), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Changes endpoint flags originally supplied to :bro:see:`Comm::enable`.
|
||||
## Changes endpoint flags originally supplied to :bro:see:`BrokerComm::enable`.
|
||||
##
|
||||
## flags: the new endpoint behavior flags to use.
|
||||
##
|
||||
## Returns: true of flags were changed.
|
||||
function Comm::set_endpoint_flags%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
function BrokerComm::set_endpoint_flags%(flags: EndpointFlags &default = EndpointFlags()%): bool
|
||||
%{
|
||||
return new Val(comm_mgr->SetEndpointFlags(flags), TYPE_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:`Comm::enable` or :bro:see:`Comm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to allow messages to be published under.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function Comm::publish_topic%(topic: string%): bool
|
||||
function BrokerComm::publish_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(comm_mgr->PublishTopic(topic->CheckString()), TYPE_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:`Comm::enable` or :bro:see:`Comm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to disallow messages to be published under.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function Comm::unpublish_topic%(topic: string%): bool
|
||||
function BrokerComm::unpublish_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(comm_mgr->UnpublishTopic(topic->CheckString()), TYPE_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:`Comm::enable` or :bro:see:`Comm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to allow advertising interest/subscription to peers.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function Comm::advertise_topic%(topic: string%): bool
|
||||
function BrokerComm::advertise_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(comm_mgr->AdvertiseTopic(topic->CheckString()), TYPE_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:`Comm::enable` or :bro:see:`Comm::set_endpoint_flags`.
|
||||
## supplied to :bro:see:`BrokerComm::enable` or :bro:see:`BrokerComm::set_endpoint_flags`.
|
||||
##
|
||||
## topic: a topic to disallow advertising interest/subscription to peers.
|
||||
##
|
||||
## Returns: true if successful.
|
||||
function Comm::unadvertise_topic%(topic: string%): bool
|
||||
function BrokerComm::unadvertise_topic%(topic: string%): bool
|
||||
%{
|
||||
return new Val(comm_mgr->UnadvertiseTopic(topic->CheckString()), TYPE_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:`Comm::connect`.
|
||||
## to :bro:see:`BrokerComm::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 Comm::outgoing_connection_established%(peer_address: string,
|
||||
event BrokerComm::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:`Comm::connect`.
|
||||
## by the original call to :bro:see:`BrokerComm::connect`.
|
||||
##
|
||||
## peer_address: the address used to connect to the peer.
|
||||
##
|
||||
## peer_port: the port used to connect to the peer.
|
||||
##
|
||||
## .. bro:see:: Comm::outgoing_connection_established
|
||||
event Comm::outgoing_connection_broken%(peer_address: string,
|
||||
## .. bro:see:: BrokerComm::outgoing_connection_established
|
||||
event BrokerComm::outgoing_connection_broken%(peer_address: string,
|
||||
peer_port: port%);
|
||||
|
||||
## Generated when a connection via :bro:see:`Comm::connect` has failed
|
||||
## Generated when a connection via :bro:see:`BrokerComm::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 Comm::outgoing_connection_incompatible%(peer_address: string,
|
||||
event BrokerComm::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:`Comm::listen`.
|
||||
## as a result of previously performing a :bro:see:`BrokerComm::listen`.
|
||||
##
|
||||
## peer_name: the name by which the peer identified itself.
|
||||
event Comm::incoming_connection_established%(peer_name: string%);
|
||||
event BrokerComm::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:: Comm::incoming_connection_established
|
||||
event Comm::incoming_connection_broken%(peer_name: string%);
|
||||
## .. bro:see:: BrokerComm::incoming_connection_established
|
||||
event BrokerComm::incoming_connection_broken%(peer_name: string%);
|
||||
|
||||
## Listen for remote connections.
|
||||
##
|
||||
|
@ -135,8 +135,8 @@ event Comm::incoming_connection_broken%(peer_name: string%);
|
|||
##
|
||||
## Returns: true if the local endpoint is now listening for connections.
|
||||
##
|
||||
## .. bro:see:: Comm::incoming_connection_established
|
||||
function Comm::listen%(p: port, a: string &default = "",
|
||||
## .. bro:see:: BrokerComm::incoming_connection_established
|
||||
function BrokerComm::listen%(p: port, a: string &default = "",
|
||||
reuse: bool &default = T%): bool
|
||||
%{
|
||||
if ( ! p->IsTCP() )
|
||||
|
@ -145,7 +145,7 @@ function Comm::listen%(p: port, a: string &default = "",
|
|||
return new Val(false, TYPE_BOOL);
|
||||
}
|
||||
|
||||
auto rval = comm_mgr->Listen(p->Port(), a->Len() ? a->CheckString() : 0,
|
||||
auto rval = broker_mgr->Listen(p->Port(), a->Len() ? a->CheckString() : 0,
|
||||
reuse);
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -164,8 +164,8 @@ function Comm::listen%(p: port, a: string &default = "",
|
|||
## it's a new peer. The actual connection may not be established
|
||||
## a later point in time.
|
||||
##
|
||||
## .. bro:see:: Comm::outgoing_connection_established
|
||||
function Comm::connect%(a: string, p: port, retry: interval%): bool
|
||||
## .. bro:see:: BrokerComm::outgoing_connection_established
|
||||
function BrokerComm::connect%(a: string, p: port, retry: interval%): bool
|
||||
%{
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
@ -173,20 +173,20 @@ function Comm::connect%(a: string, p: port, retry: interval%): bool
|
|||
return new Val(false, TYPE_BOOL);
|
||||
}
|
||||
|
||||
auto rval = comm_mgr->Connect(a->CheckString(), p->Port(),
|
||||
auto rval = broker_mgr->Connect(a->CheckString(), p->Port(),
|
||||
std::chrono::duration<double>(retry));
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Remove a remote connection.
|
||||
##
|
||||
## a: the address used in previous successful call to :bro:see:`Comm::connect`.
|
||||
## a: the address used in previous successful call to :bro:see:`BrokerComm::connect`.
|
||||
##
|
||||
## p: the port used in previous successful call to :bro:see:`Comm::connect`.
|
||||
## p: the port used in previous successful call to :bro:see:`BrokerComm::connect`.
|
||||
##
|
||||
## Returns: true if the arguments match a previously successful call to
|
||||
## :bro:see:`Comm::connect`.
|
||||
function Comm::disconnect%(a: string, p: port%): bool
|
||||
## :bro:see:`BrokerComm::connect`.
|
||||
function BrokerComm::disconnect%(a: string, p: port%): bool
|
||||
%{
|
||||
if ( ! p->IsTCP() )
|
||||
{
|
||||
|
@ -194,6 +194,6 @@ function Comm::disconnect%(a: string, p: port%): bool
|
|||
return new Val(false, TYPE_BOOL);
|
||||
}
|
||||
|
||||
auto rval = comm_mgr->Disconnect(a->CheckString(), p->Port());
|
||||
auto rval = broker_mgr->Disconnect(a->CheckString(), p->Port());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "comm/Data.h"
|
||||
%%}
|
||||
|
||||
module Comm;
|
||||
module BrokerComm;
|
||||
|
||||
## Enumerates the possible types that :bro:see:`Comm::Data` may be in terms of
|
||||
## Enumerates the possible types that :bro:see:`BrokerComm::Data` may be in terms of
|
||||
## Bro data types.
|
||||
enum DataType %{
|
||||
BOOL,
|
||||
|
@ -27,9 +27,9 @@ enum DataType %{
|
|||
RECORD,
|
||||
%}
|
||||
|
||||
type Comm::Data: record;
|
||||
type BrokerComm::Data: record;
|
||||
|
||||
type Comm::TableItem: record;
|
||||
type BrokerComm::TableItem: record;
|
||||
|
||||
## Convert any Bro value in to communication data.
|
||||
##
|
||||
|
@ -38,9 +38,9 @@ type Comm::TableItem: record;
|
|||
## Returns: the converted communication data which may not set its only
|
||||
## opaque field of the the conversion was not possible (the Bro data
|
||||
## type does not support being converted to communicaiton data).
|
||||
function Comm::data%(d: any%): Comm::Data
|
||||
function BrokerComm::data%(d: any%): BrokerComm::Data
|
||||
%{
|
||||
return comm::make_data_val(d);
|
||||
return bro_broker::make_data_val(d);
|
||||
%}
|
||||
|
||||
## Retrieve the type of data associated with communication data.
|
||||
|
@ -48,153 +48,153 @@ function Comm::data%(d: any%): Comm::Data
|
|||
## d: the communication data.
|
||||
##
|
||||
## Returns: the data type associated with the communication data.
|
||||
function Comm::data_type%(d: Comm::Data%): Comm::DataType
|
||||
function BrokerComm::data_type%(d: BrokerComm::Data%): BrokerComm::DataType
|
||||
%{
|
||||
return comm::get_data_type(d->AsRecordVal(), frame);
|
||||
return bro_broker::get_data_type(d->AsRecordVal(), frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::BOOL` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::BOOL` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_bool%(d: Comm::Data%): bool
|
||||
function BrokerComm::refine_to_bool%(d: BrokerComm::Data%): bool
|
||||
%{
|
||||
return comm::refine<bool>(d->AsRecordVal(), TYPE_BOOL, frame);
|
||||
return bro_broker::refine<bool>(d->AsRecordVal(), TYPE_BOOL, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::INT` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::INT` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_int%(d: Comm::Data%): int
|
||||
function BrokerComm::refine_to_int%(d: BrokerComm::Data%): int
|
||||
%{
|
||||
return comm::refine<int64_t>(d->AsRecordVal(), TYPE_INT, frame);
|
||||
return bro_broker::refine<int64_t>(d->AsRecordVal(), TYPE_INT, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::COUNT` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::COUNT` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_count%(d: Comm::Data%): count
|
||||
function BrokerComm::refine_to_count%(d: BrokerComm::Data%): count
|
||||
%{
|
||||
return comm::refine<uint64_t>(d->AsRecordVal(), TYPE_COUNT, frame);
|
||||
return bro_broker::refine<uint64_t>(d->AsRecordVal(), TYPE_COUNT, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::DOUBLE` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::DOUBLE` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_double%(d: Comm::Data%): double
|
||||
function BrokerComm::refine_to_double%(d: BrokerComm::Data%): double
|
||||
%{
|
||||
return comm::refine<double>(d->AsRecordVal(), TYPE_DOUBLE, frame);
|
||||
return bro_broker::refine<double>(d->AsRecordVal(), TYPE_DOUBLE, frame);
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::STRING` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::STRING` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_string%(d: Comm::Data%): string
|
||||
function BrokerComm::refine_to_string%(d: BrokerComm::Data%): string
|
||||
%{
|
||||
return new StringVal(comm::require_data_type<std::string>(d->AsRecordVal(),
|
||||
return new StringVal(bro_broker::require_data_type<std::string>(d->AsRecordVal(),
|
||||
TYPE_STRING,
|
||||
frame));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::ADDR` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::ADDR` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_addr%(d: Comm::Data%): addr
|
||||
function BrokerComm::refine_to_addr%(d: BrokerComm::Data%): addr
|
||||
%{
|
||||
auto& a = comm::require_data_type<broker::address>(d->AsRecordVal(),
|
||||
auto& a = bro_broker::require_data_type<broker::address>(d->AsRecordVal(),
|
||||
TYPE_ADDR, frame);
|
||||
auto bits = reinterpret_cast<const in6_addr*>(&a.bytes());
|
||||
return new AddrVal(IPAddr(*bits));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::SUBNET` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::SUBNET` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_subnet%(d: Comm::Data%): subnet
|
||||
function BrokerComm::refine_to_subnet%(d: BrokerComm::Data%): subnet
|
||||
%{
|
||||
auto& a = comm::require_data_type<broker::subnet>(d->AsRecordVal(),
|
||||
auto& a = bro_broker::require_data_type<broker::subnet>(d->AsRecordVal(),
|
||||
TYPE_SUBNET, frame);
|
||||
auto bits = reinterpret_cast<const in6_addr*>(&a.network().bytes());
|
||||
return new SubNetVal(IPPrefix(IPAddr(*bits), a.length()));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::PORT` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::PORT` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_port%(d: Comm::Data%): port
|
||||
function BrokerComm::refine_to_port%(d: BrokerComm::Data%): port
|
||||
%{
|
||||
auto& a = comm::require_data_type<broker::port>(d->AsRecordVal(),
|
||||
auto& a = bro_broker::require_data_type<broker::port>(d->AsRecordVal(),
|
||||
TYPE_SUBNET, frame);
|
||||
return new PortVal(a.number(), comm::to_bro_port_proto(a.type()));
|
||||
return new PortVal(a.number(), bro_broker::to_bro_port_proto(a.type()));
|
||||
%}
|
||||
|
||||
## Convert communication data with a type of :bro:see:`Comm::TIME` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::TIME` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_time%(d: Comm::Data%): time
|
||||
function BrokerComm::refine_to_time%(d: BrokerComm::Data%): time
|
||||
%{
|
||||
auto v = comm::require_data_type<broker::time_point>(d->AsRecordVal(),
|
||||
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:`Comm::INTERVAL` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::INTERVAL` to
|
||||
## an actual Bro value.
|
||||
##
|
||||
## d: the communication data to convert.
|
||||
##
|
||||
## Returns: the value retrieved from the communication data.
|
||||
function Comm::refine_to_interval%(d: Comm::Data%): interval
|
||||
function BrokerComm::refine_to_interval%(d: BrokerComm::Data%): interval
|
||||
%{
|
||||
auto v = comm::require_data_type<broker::time_duration>(d->AsRecordVal(),
|
||||
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:`Comm::ENUM` to
|
||||
## Convert communication data with a type of :bro:see:`BrokerComm::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 Comm::refine_to_enum_name%(d: Comm::Data%): string
|
||||
function BrokerComm::refine_to_enum_name%(d: BrokerComm::Data%): string
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::enum_value>(d->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::enum_value>(d->AsRecordVal(),
|
||||
TYPE_ENUM, frame).name;
|
||||
return new StringVal(v);
|
||||
%}
|
||||
|
||||
## Create communication data of type "set".
|
||||
function Comm::set_create%(%): Comm::Data
|
||||
function BrokerComm::set_create%(%): BrokerComm::Data
|
||||
%{
|
||||
return comm::make_data_val(broker::set());
|
||||
return bro_broker::make_data_val(broker::set());
|
||||
%}
|
||||
|
||||
## Remove all elements within a set.
|
||||
|
@ -202,9 +202,9 @@ function Comm::set_create%(%): Comm::Data
|
|||
## s: the set to clear.
|
||||
##
|
||||
## Returns: always true.
|
||||
function Comm::set_clear%(s: Comm::Data%): bool
|
||||
function BrokerComm::set_clear%(s: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
v.clear();
|
||||
return new Val(true, TYPE_BOOL);
|
||||
|
@ -215,9 +215,9 @@ function Comm::set_clear%(s: Comm::Data%): bool
|
|||
## s: the set to query.
|
||||
##
|
||||
## Returns: the number of elements in the set.
|
||||
function Comm::set_size%(s: Comm::Data%): count
|
||||
function BrokerComm::set_size%(s: BrokerComm::Data%): count
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
return new Val(static_cast<uint64_t>(v.size()), TYPE_COUNT);
|
||||
%}
|
||||
|
@ -229,11 +229,11 @@ function Comm::set_size%(s: Comm::Data%): count
|
|||
## key: the element to check for existence.
|
||||
##
|
||||
## Returns: true if the key exists in the set.
|
||||
function Comm::set_contains%(s: Comm::Data, key: Comm::Data%): bool
|
||||
function BrokerComm::set_contains%(s: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
return new Val(v.find(k) != v.end(), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -244,11 +244,11 @@ function Comm::set_contains%(s: Comm::Data, key: Comm::Data%): bool
|
|||
## key: the element to insert.
|
||||
##
|
||||
## Returns: true if the key was inserted, or false if it already existed.
|
||||
function Comm::set_insert%(s: Comm::Data, key: Comm::Data%): bool
|
||||
function BrokerComm::set_insert%(s: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
return new Val(v.insert(k).second, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -259,11 +259,11 @@ function Comm::set_insert%(s: Comm::Data, key: Comm::Data%): bool
|
|||
## key: the element to remove.
|
||||
##
|
||||
## Returns: true if the element existed in the set and is now removed.
|
||||
function Comm::set_remove%(s: Comm::Data, key: Comm::Data%): bool
|
||||
function BrokerComm::set_remove%(s: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
auto& v = bro_broker::require_data_type<broker::set>(s->AsRecordVal(), TYPE_TABLE,
|
||||
frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
return new Val(v.erase(k) > 0, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -273,9 +273,9 @@ function Comm::set_remove%(s: Comm::Data, key: Comm::Data%): bool
|
|||
## s: the set to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function Comm::set_iterator%(s: Comm::Data%): opaque of Comm::SetIterator
|
||||
function BrokerComm::set_iterator%(s: BrokerComm::Data%): opaque of BrokerComm::SetIterator
|
||||
%{
|
||||
return new comm::SetIterator(s->AsRecordVal(), TYPE_TABLE, frame);
|
||||
return new bro_broker::SetIterator(s->AsRecordVal(), TYPE_TABLE, frame);
|
||||
%}
|
||||
|
||||
## Check if there are no more elements to iterate over.
|
||||
|
@ -284,9 +284,9 @@ function Comm::set_iterator%(s: Comm::Data%): opaque of Comm::SetIterator
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function Comm::set_iterator_last%(it: opaque of Comm::SetIterator%): bool
|
||||
function BrokerComm::set_iterator_last%(it: opaque of BrokerComm::SetIterator%): bool
|
||||
%{
|
||||
auto set_it = static_cast<comm::SetIterator*>(it);
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
return new Val(set_it->it == set_it->dat.end(), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -297,9 +297,9 @@ function Comm::set_iterator_last%(it: opaque of Comm::SetIterator%): bool
|
|||
## 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 Comm::set_iterator_next%(it: opaque of Comm::SetIterator%): bool
|
||||
function BrokerComm::set_iterator_next%(it: opaque of BrokerComm::SetIterator%): bool
|
||||
%{
|
||||
auto set_it = static_cast<comm::SetIterator*>(it);
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
|
||||
if ( set_it->it == set_it->dat.end() )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
@ -313,10 +313,10 @@ function Comm::set_iterator_next%(it: opaque of Comm::SetIterator%): bool
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function Comm::set_iterator_value%(it: opaque of Comm::SetIterator%): Comm::Data
|
||||
function BrokerComm::set_iterator_value%(it: opaque of BrokerComm::SetIterator%): BrokerComm::Data
|
||||
%{
|
||||
auto set_it = static_cast<comm::SetIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Comm::Data);
|
||||
auto set_it = static_cast<bro_broker::SetIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
if ( set_it->it == set_it->dat.end() )
|
||||
{
|
||||
|
@ -326,14 +326,14 @@ function Comm::set_iterator_value%(it: opaque of Comm::SetIterator%): Comm::Data
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval->Assign(0, new comm::DataVal(*set_it->it));
|
||||
rval->Assign(0, new bro_broker::DataVal(*set_it->it));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
## Create communication data of type "table".
|
||||
function Comm::table_create%(%): Comm::Data
|
||||
function BrokerComm::table_create%(%): BrokerComm::Data
|
||||
%{
|
||||
return comm::make_data_val(broker::table());
|
||||
return bro_broker::make_data_val(broker::table());
|
||||
%}
|
||||
|
||||
## Remove all elements within a table.
|
||||
|
@ -341,9 +341,9 @@ function Comm::table_create%(%): Comm::Data
|
|||
## t: the table to clear.
|
||||
##
|
||||
## Returns: always true.
|
||||
function Comm::table_clear%(t: Comm::Data%): bool
|
||||
function BrokerComm::table_clear%(t: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
v.clear();
|
||||
return new Val(true, TYPE_BOOL);
|
||||
|
@ -354,9 +354,9 @@ function Comm::table_clear%(t: Comm::Data%): bool
|
|||
## t: the table to query.
|
||||
##
|
||||
## Returns: the number of elements in the table.
|
||||
function Comm::table_size%(t: Comm::Data%): count
|
||||
function BrokerComm::table_size%(t: BrokerComm::Data%): count
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
return new Val(static_cast<uint64_t>(v.size()), TYPE_COUNT);
|
||||
%}
|
||||
|
@ -368,11 +368,11 @@ function Comm::table_size%(t: Comm::Data%): count
|
|||
## key: the key to check for existence.
|
||||
##
|
||||
## Returns: true if the key exists in the set.
|
||||
function Comm::table_contains%(t: Comm::Data, key: Comm::Data%): bool
|
||||
function BrokerComm::table_contains%(t: BrokerComm::Data, key: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
return new Val(v.find(k) != v.end(), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -386,24 +386,24 @@ function Comm::table_contains%(t: Comm::Data, key: Comm::Data%): bool
|
|||
##
|
||||
## Returns: true if the key-value pair was inserted, or false if the key
|
||||
## already existed in the table.
|
||||
function Comm::table_insert%(t: Comm::Data, key: Comm::Data, val: Comm::Data%): Comm::Data
|
||||
function BrokerComm::table_insert%(t: BrokerComm::Data, key: BrokerComm::Data, val: BrokerComm::Data%): BrokerComm::Data
|
||||
%{
|
||||
auto& table = comm::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& v = comm::opaque_field_to_data(val->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& v = bro_broker::opaque_field_to_data(val->AsRecordVal(), frame);
|
||||
|
||||
try
|
||||
{
|
||||
auto& prev = table.at(k);
|
||||
auto rval = comm::make_data_val(move(prev));
|
||||
auto rval = bro_broker::make_data_val(move(prev));
|
||||
prev = v;
|
||||
return rval;
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
table[k] = v;
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -415,18 +415,18 @@ function Comm::table_insert%(t: Comm::Data, key: Comm::Data, val: Comm::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 Comm::table_remove%(t: Comm::Data, key: Comm::Data%): Comm::Data
|
||||
function BrokerComm::table_remove%(t: BrokerComm::Data, key: BrokerComm::Data%): BrokerComm::Data
|
||||
%{
|
||||
auto& table = comm::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto it = table.find(k);
|
||||
|
||||
if ( it == table.end() )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
else
|
||||
{
|
||||
auto rval = comm::make_data_val(move(it->second));
|
||||
auto rval = bro_broker::make_data_val(move(it->second));
|
||||
table.erase(it);
|
||||
return rval;
|
||||
}
|
||||
|
@ -440,17 +440,17 @@ function Comm::table_remove%(t: Comm::Data, key: Comm::Data%): Comm::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 Comm::table_lookup%(t: Comm::Data, key: Comm::Data%): Comm::Data
|
||||
function BrokerComm::table_lookup%(t: BrokerComm::Data, key: BrokerComm::Data%): BrokerComm::Data
|
||||
%{
|
||||
auto& table = comm::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
auto& table = bro_broker::require_data_type<broker::table>(t->AsRecordVal(),
|
||||
TYPE_TABLE, frame);
|
||||
auto& k = comm::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto& k = bro_broker::opaque_field_to_data(key->AsRecordVal(), frame);
|
||||
auto it = table.find(k);
|
||||
|
||||
if ( it == table.end() )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
else
|
||||
return comm::make_data_val(it->second);
|
||||
return bro_broker::make_data_val(it->second);
|
||||
%}
|
||||
|
||||
## Create an iterator for a table. Note that this makes a copy of the table
|
||||
|
@ -459,9 +459,9 @@ function Comm::table_lookup%(t: Comm::Data, key: Comm::Data%): Comm::Data
|
|||
## t: the table to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function Comm::table_iterator%(t: Comm::Data%): opaque of Comm::TableIterator
|
||||
function BrokerComm::table_iterator%(t: BrokerComm::Data%): opaque of BrokerComm::TableIterator
|
||||
%{
|
||||
return new comm::TableIterator(t->AsRecordVal(), TYPE_TABLE, frame);
|
||||
return new bro_broker::TableIterator(t->AsRecordVal(), TYPE_TABLE, frame);
|
||||
%}
|
||||
|
||||
## Check if there are no more elements to iterate over.
|
||||
|
@ -470,9 +470,9 @@ function Comm::table_iterator%(t: Comm::Data%): opaque of Comm::TableIterator
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function Comm::table_iterator_last%(it: opaque of Comm::TableIterator%): bool
|
||||
function BrokerComm::table_iterator_last%(it: opaque of BrokerComm::TableIterator%): bool
|
||||
%{
|
||||
auto ti = static_cast<comm::TableIterator*>(it);
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
return new Val(ti->it == ti->dat.end(), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -483,9 +483,9 @@ function Comm::table_iterator_last%(it: opaque of Comm::TableIterator%): bool
|
|||
## 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 Comm::table_iterator_next%(it: opaque of Comm::TableIterator%): bool
|
||||
function BrokerComm::table_iterator_next%(it: opaque of BrokerComm::TableIterator%): bool
|
||||
%{
|
||||
auto ti = static_cast<comm::TableIterator*>(it);
|
||||
auto ti = static_cast<bro_broker::TableIterator*>(it);
|
||||
|
||||
if ( ti->it == ti->dat.end() )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
@ -499,12 +499,12 @@ function Comm::table_iterator_next%(it: opaque of Comm::TableIterator%): bool
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function Comm::table_iterator_value%(it: opaque of Comm::TableIterator%): Comm::TableItem
|
||||
function BrokerComm::table_iterator_value%(it: opaque of BrokerComm::TableIterator%): BrokerComm::TableItem
|
||||
%{
|
||||
auto ti = static_cast<comm::TableIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Comm::TableItem);
|
||||
auto key_val = new RecordVal(BifType::Record::Comm::Data);
|
||||
auto val_val = new RecordVal(BifType::Record::Comm::Data);
|
||||
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);
|
||||
rval->Assign(0, key_val);
|
||||
rval->Assign(1, val_val);
|
||||
|
||||
|
@ -516,15 +516,15 @@ function Comm::table_iterator_value%(it: opaque of Comm::TableIterator%): Comm::
|
|||
return rval;
|
||||
}
|
||||
|
||||
key_val->Assign(0, new comm::DataVal(ti->it->first));
|
||||
val_val->Assign(0, new comm::DataVal(ti->it->second));
|
||||
key_val->Assign(0, new bro_broker::DataVal(ti->it->first));
|
||||
val_val->Assign(0, new bro_broker::DataVal(ti->it->second));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
## Create communication data of type "vector".
|
||||
function Comm::vector_create%(%): Comm::Data
|
||||
function BrokerComm::vector_create%(%): BrokerComm::Data
|
||||
%{
|
||||
return comm::make_data_val(broker::vector());
|
||||
return bro_broker::make_data_val(broker::vector());
|
||||
%}
|
||||
|
||||
## Remove all elements within a vector.
|
||||
|
@ -532,9 +532,9 @@ function Comm::vector_create%(%): Comm::Data
|
|||
## v: the vector to clear.
|
||||
##
|
||||
## Returns: always true.
|
||||
function Comm::vector_clear%(v: Comm::Data%): bool
|
||||
function BrokerComm::vector_clear%(v: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto& vec = comm::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
vec.clear();
|
||||
return new Val(true, TYPE_BOOL);
|
||||
|
@ -545,9 +545,9 @@ function Comm::vector_clear%(v: Comm::Data%): bool
|
|||
## v: the vector to query.
|
||||
##
|
||||
## Returns: the number of elements in the vector.
|
||||
function Comm::vector_size%(v: Comm::Data%): count
|
||||
function BrokerComm::vector_size%(v: BrokerComm::Data%): count
|
||||
%{
|
||||
auto& vec = comm::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
return new Val(static_cast<uint64_t>(vec.size()), TYPE_COUNT);
|
||||
%}
|
||||
|
@ -563,11 +563,11 @@ function Comm::vector_size%(v: Comm::Data%): count
|
|||
## current size of the vector, the element is inserted at the end.
|
||||
##
|
||||
## Returns: always true.
|
||||
function Comm::vector_insert%(v: Comm::Data, d: Comm::Data, idx: count%): bool
|
||||
function BrokerComm::vector_insert%(v: BrokerComm::Data, d: BrokerComm::Data, idx: count%): bool
|
||||
%{
|
||||
auto& vec = comm::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
auto& item = comm::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
auto& item = bro_broker::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
idx = min(idx, static_cast<uint64_t>(vec.size()));
|
||||
vec.insert(vec.begin() + idx, item);
|
||||
return new Val(true, TYPE_BOOL);
|
||||
|
@ -583,16 +583,16 @@ function Comm::vector_insert%(v: Comm::Data, d: Comm::Data, idx: count%): bool
|
|||
##
|
||||
## 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 Comm::vector_replace%(v: Comm::Data, d: Comm::Data, idx: count%): Comm::Data
|
||||
function BrokerComm::vector_replace%(v: BrokerComm::Data, d: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
%{
|
||||
auto& vec = comm::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
auto& item = comm::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
auto& item = bro_broker::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
auto rval = comm::make_data_val(move(vec[idx]));
|
||||
auto rval = bro_broker::make_data_val(move(vec[idx]));
|
||||
vec[idx] = item;
|
||||
return rval;
|
||||
%}
|
||||
|
@ -605,15 +605,15 @@ function Comm::vector_replace%(v: Comm::Data, d: Comm::Data, idx: count%): Comm:
|
|||
##
|
||||
## 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 Comm::vector_remove%(v: Comm::Data, idx: count%): Comm::Data
|
||||
function BrokerComm::vector_remove%(v: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
%{
|
||||
auto& vec = comm::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
auto rval = comm::make_data_val(move(vec[idx]));
|
||||
auto rval = bro_broker::make_data_val(move(vec[idx]));
|
||||
vec.erase(vec.begin() + idx);
|
||||
return rval;
|
||||
%}
|
||||
|
@ -626,15 +626,15 @@ function Comm::vector_remove%(v: Comm::Data, idx: count%): Comm::Data
|
|||
##
|
||||
## 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 Comm::vector_lookup%(v: Comm::Data, idx: count%): Comm::Data
|
||||
function BrokerComm::vector_lookup%(v: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
%{
|
||||
auto& vec = comm::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
auto& vec = bro_broker::require_data_type<broker::vector>(v->AsRecordVal(),
|
||||
TYPE_VECTOR, frame);
|
||||
|
||||
if ( idx >= vec.size() )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
return comm::make_data_val(vec[idx]);
|
||||
return bro_broker::make_data_val(vec[idx]);
|
||||
%}
|
||||
|
||||
## Create an iterator for a vector. Note that this makes a copy of the vector
|
||||
|
@ -643,9 +643,9 @@ function Comm::vector_lookup%(v: Comm::Data, idx: count%): Comm::Data
|
|||
## v: the vector to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function Comm::vector_iterator%(v: Comm::Data%): opaque of Comm::VectorIterator
|
||||
function BrokerComm::vector_iterator%(v: BrokerComm::Data%): opaque of BrokerComm::VectorIterator
|
||||
%{
|
||||
return new comm::VectorIterator(v->AsRecordVal(), TYPE_VECTOR, frame);
|
||||
return new bro_broker::VectorIterator(v->AsRecordVal(), TYPE_VECTOR, frame);
|
||||
%}
|
||||
|
||||
## Check if there are no more elements to iterate over.
|
||||
|
@ -654,9 +654,9 @@ function Comm::vector_iterator%(v: Comm::Data%): opaque of Comm::VectorIterator
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function Comm::vector_iterator_last%(it: opaque of Comm::VectorIterator%): bool
|
||||
function BrokerComm::vector_iterator_last%(it: opaque of BrokerComm::VectorIterator%): bool
|
||||
%{
|
||||
auto vi = static_cast<comm::VectorIterator*>(it);
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
return new Val(vi->it == vi->dat.end(), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -667,9 +667,9 @@ function Comm::vector_iterator_last%(it: opaque of Comm::VectorIterator%): bool
|
|||
## 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 Comm::vector_iterator_next%(it: opaque of Comm::VectorIterator%): bool
|
||||
function BrokerComm::vector_iterator_next%(it: opaque of BrokerComm::VectorIterator%): bool
|
||||
%{
|
||||
auto vi = static_cast<comm::VectorIterator*>(it);
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
|
||||
if ( vi->it == vi->dat.end() )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
@ -683,10 +683,10 @@ function Comm::vector_iterator_next%(it: opaque of Comm::VectorIterator%): bool
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function Comm::vector_iterator_value%(it: opaque of Comm::VectorIterator%): Comm::Data
|
||||
function BrokerComm::vector_iterator_value%(it: opaque of BrokerComm::VectorIterator%): BrokerComm::Data
|
||||
%{
|
||||
auto vi = static_cast<comm::VectorIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Comm::Data);
|
||||
auto vi = static_cast<bro_broker::VectorIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
if ( vi->it == vi->dat.end() )
|
||||
{
|
||||
|
@ -696,7 +696,7 @@ function Comm::vector_iterator_value%(it: opaque of Comm::VectorIterator%): Comm
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval->Assign(0, new comm::DataVal(*vi->it));
|
||||
rval->Assign(0, new bro_broker::DataVal(*vi->it));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
|
@ -705,9 +705,9 @@ function Comm::vector_iterator_value%(it: opaque of Comm::VectorIterator%): Comm
|
|||
## sz: the number of fields in the record.
|
||||
##
|
||||
## Returns: record data, with all fields uninitialized.
|
||||
function Comm::record_create%(sz: count%): Comm::Data
|
||||
function BrokerComm::record_create%(sz: count%): BrokerComm::Data
|
||||
%{
|
||||
return comm::make_data_val(broker::record(std::vector<broker::record::field>(sz)));
|
||||
return bro_broker::make_data_val(broker::record(std::vector<broker::record::field>(sz)));
|
||||
%}
|
||||
|
||||
## Get the number of fields within a record.
|
||||
|
@ -715,9 +715,9 @@ function Comm::record_create%(sz: count%): Comm::Data
|
|||
## r: the record to query.
|
||||
##
|
||||
## Returns: the number of fields in the record.
|
||||
function Comm::record_size%(r: Comm::Data%): count
|
||||
function BrokerComm::record_size%(r: BrokerComm::Data%): count
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
return new Val(static_cast<uint64_t>(v.fields.size()), TYPE_COUNT);
|
||||
%}
|
||||
|
@ -731,11 +731,11 @@ function Comm::record_size%(r: Comm::Data%): count
|
|||
## idx: the index to replace.
|
||||
##
|
||||
## Returns: false if the index was larger than any valid index, else true.
|
||||
function Comm::record_assign%(r: Comm::Data, d: Comm::Data, idx: count%): bool
|
||||
function BrokerComm::record_assign%(r: BrokerComm::Data, d: BrokerComm::Data, idx: count%): bool
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
auto& item = comm::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
auto& item = bro_broker::opaque_field_to_data(d->AsRecordVal(), frame);
|
||||
|
||||
if ( idx >= v.fields.size() )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
@ -753,18 +753,18 @@ function Comm::record_assign%(r: Comm::Data, d: Comm::Data, idx: count%): bool
|
|||
## 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
|
||||
## the index was not valid.
|
||||
function Comm::record_lookup%(r: Comm::Data, idx: count%): Comm::Data
|
||||
function BrokerComm::record_lookup%(r: BrokerComm::Data, idx: count%): BrokerComm::Data
|
||||
%{
|
||||
auto& v = comm::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
auto& v = bro_broker::require_data_type<broker::record>(r->AsRecordVal(),
|
||||
TYPE_RECORD, frame);
|
||||
|
||||
if ( idx >= v.size() )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
if ( ! v.fields[idx] )
|
||||
return new RecordVal(BifType::Record::Comm::Data);
|
||||
return new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
return comm::make_data_val(*v.fields[idx]);
|
||||
return bro_broker::make_data_val(*v.fields[idx]);
|
||||
%}
|
||||
|
||||
## Create an iterator for a record. Note that this makes a copy of the record
|
||||
|
@ -773,9 +773,9 @@ function Comm::record_lookup%(r: Comm::Data, idx: count%): Comm::Data
|
|||
## r: the record to iterate over.
|
||||
##
|
||||
## Returns: an iterator.
|
||||
function Comm::record_iterator%(r: Comm::Data%): opaque of Comm::RecordIterator
|
||||
function BrokerComm::record_iterator%(r: BrokerComm::Data%): opaque of BrokerComm::RecordIterator
|
||||
%{
|
||||
return new comm::RecordIterator(r->AsRecordVal(), TYPE_RECORD, frame);
|
||||
return new bro_broker::RecordIterator(r->AsRecordVal(), TYPE_RECORD, frame);
|
||||
%}
|
||||
|
||||
## Check if there are no more elements to iterate over.
|
||||
|
@ -784,9 +784,9 @@ function Comm::record_iterator%(r: Comm::Data%): opaque of Comm::RecordIterator
|
|||
##
|
||||
## Returns: true if there are no more elements to iterator over, i.e.
|
||||
## the iterator is one-past-the-final-element.
|
||||
function Comm::record_iterator_last%(it: opaque of Comm::RecordIterator%): bool
|
||||
function BrokerComm::record_iterator_last%(it: opaque of BrokerComm::RecordIterator%): bool
|
||||
%{
|
||||
auto ri = static_cast<comm::RecordIterator*>(it);
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
return new Val(ri->it == ri->dat.fields.end(), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -797,9 +797,9 @@ function Comm::record_iterator_last%(it: opaque of Comm::RecordIterator%): bool
|
|||
## 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 Comm::record_iterator_next%(it: opaque of Comm::RecordIterator%): bool
|
||||
function BrokerComm::record_iterator_next%(it: opaque of BrokerComm::RecordIterator%): bool
|
||||
%{
|
||||
auto ri = static_cast<comm::RecordIterator*>(it);
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
|
||||
if ( ri->it == ri->dat.fields.end() )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
@ -813,10 +813,10 @@ function Comm::record_iterator_next%(it: opaque of Comm::RecordIterator%): bool
|
|||
## it: an iterator.
|
||||
##
|
||||
## Returns: element in the collection that the iterator currently references.
|
||||
function Comm::record_iterator_value%(it: opaque of Comm::RecordIterator%): Comm::Data
|
||||
function BrokerComm::record_iterator_value%(it: opaque of BrokerComm::RecordIterator%): BrokerComm::Data
|
||||
%{
|
||||
auto ri = static_cast<comm::RecordIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::Comm::Data);
|
||||
auto ri = static_cast<bro_broker::RecordIterator*>(it);
|
||||
auto rval = new RecordVal(BifType::Record::BrokerComm::Data);
|
||||
|
||||
if ( ri->it == ri->dat.fields.end() )
|
||||
{
|
||||
|
@ -829,6 +829,6 @@ function Comm::record_iterator_value%(it: opaque of Comm::RecordIterator%): Comm
|
|||
if ( ! *ri->it )
|
||||
return rval; // field isn't set
|
||||
|
||||
rval->Assign(0, new comm::DataVal(**ri->it));
|
||||
rval->Assign(0, new bro_broker::DataVal(**ri->it));
|
||||
return rval;
|
||||
%}
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#include "logging/Manager.h"
|
||||
%%}
|
||||
|
||||
module Comm;
|
||||
module BrokerComm;
|
||||
|
||||
type Comm::SendFlags: record;
|
||||
type BrokerComm::SendFlags: record;
|
||||
|
||||
type Comm::EventArgs: record;
|
||||
type BrokerComm::EventArgs: record;
|
||||
|
||||
## Used to handle remote print messages from peers that call
|
||||
## :bro:see:`Comm::print`.
|
||||
event Comm::print_handler%(msg: string%);
|
||||
## :bro:see:`BrokerComm::print`.
|
||||
event BrokerComm::print_handler%(msg: string%);
|
||||
|
||||
## Print a simple message to any interested peers. The receiver can use
|
||||
## :bro:see:`Comm::print_handler` to handle messages.
|
||||
## :bro:see:`BrokerComm::print_handler` to handle messages.
|
||||
##
|
||||
## topic: a topic associated with the printed message.
|
||||
##
|
||||
|
@ -26,50 +26,50 @@ event Comm::print_handler%(msg: string%);
|
|||
## flags: tune the behavior of how the message is sent.
|
||||
##
|
||||
## Returns: true if the message is sent.
|
||||
function Comm::print%(topic: string, msg: string,
|
||||
function BrokerComm::print%(topic: string, msg: string,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->Print(topic->CheckString(), msg->CheckString(),
|
||||
auto rval = broker_mgr->Print(topic->CheckString(), msg->CheckString(),
|
||||
flags);
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Register interest in all peer print messages that use a certain topic prefix.
|
||||
## use :bro:see:`Comm::print_handler` to handle received messages.
|
||||
## use :bro:see:`BrokerComm::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 Comm::subscribe_to_prints%(topic_prefix: string%): bool
|
||||
function BrokerComm::subscribe_to_prints%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->SubscribeToPrints(topic_prefix->CheckString());
|
||||
auto rval = broker_mgr->SubscribeToPrints(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_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:`Comm::subscribe_to_prints`.
|
||||
## :bro:see:`BrokerComm::subscribe_to_prints`.
|
||||
##
|
||||
## Returns: true if interest in the topic prefix is no longer advertised.
|
||||
function Comm::unsubscribe_to_prints%(topic_prefix: string%): bool
|
||||
function BrokerComm::unsubscribe_to_prints%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->UnsubscribeToPrints(topic_prefix->CheckString());
|
||||
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:`Comm::event`.
|
||||
## :bro:see:`BrokerComm::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 Comm::event_args%(...%): Comm::EventArgs
|
||||
function BrokerComm::event_args%(...%): BrokerComm::EventArgs
|
||||
%{
|
||||
auto rval = comm_mgr->MakeEventArgs(@ARGS@);
|
||||
auto rval = broker_mgr->MakeEventArgs(@ARGS@);
|
||||
return rval;
|
||||
%}
|
||||
|
||||
|
@ -77,15 +77,15 @@ function Comm::event_args%(...%): Comm::EventArgs
|
|||
##
|
||||
## topic: a topic associated with the event message.
|
||||
##
|
||||
## args: event arguments as made by :bro:see:`Comm::event_args`.
|
||||
## args: event arguments as made by :bro:see:`BrokerComm::event_args`.
|
||||
##
|
||||
## flags: tune the behavior of how the message is sent.
|
||||
##
|
||||
## Returns: true if the message is sent.
|
||||
function Comm::event%(topic: string, args: Comm::EventArgs,
|
||||
function BrokerComm::event%(topic: string, args: BrokerComm::EventArgs,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->Event(topic->CheckString(), args->AsRecordVal(),
|
||||
auto rval = broker_mgr->Event(topic->CheckString(), args->AsRecordVal(),
|
||||
flags);
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -102,23 +102,23 @@ function Comm::event%(topic: string, args: Comm::EventArgs,
|
|||
## flags: tune the behavior of how the message is send.
|
||||
##
|
||||
## Returns: true if automatic event sending is now enabled.
|
||||
function Comm::auto_event%(topic: string, ev: any,
|
||||
function BrokerComm::auto_event%(topic: string, ev: any,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->AutoEvent(topic->CheckString(), ev, flags);
|
||||
auto rval = broker_mgr->AutoEvent(topic->CheckString(), ev, flags);
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Stop automatically sending an event to peers upon local dispatch.
|
||||
##
|
||||
## topic: a topic originally given to :bro:see:`Comm::auto_event`.
|
||||
## topic: a topic originally given to :bro:see:`BrokerComm::auto_event`.
|
||||
##
|
||||
## ev: an event originally given to :bro:see:`Comm::auto_event`.
|
||||
## ev: an event originally given to :bro:see:`BrokerComm::auto_event`.
|
||||
##
|
||||
## Returns: true if automatic events will no occur for the topic/event pair.
|
||||
function Comm::auto_event_stop%(topic: string, ev: any%): bool
|
||||
function BrokerComm::auto_event_stop%(topic: string, ev: any%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->AutoEventStop(topic->CheckString(), ev);
|
||||
auto rval = broker_mgr->AutoEventStop(topic->CheckString(), ev);
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -129,21 +129,21 @@ function Comm::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 Comm::subscribe_to_events%(topic_prefix: string%): bool
|
||||
function BrokerComm::subscribe_to_events%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->SubscribeToEvents(topic_prefix->CheckString());
|
||||
auto rval = broker_mgr->SubscribeToEvents(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_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:`Comm::subscribe_to_events`.
|
||||
## :bro:see:`BrokerComm::subscribe_to_events`.
|
||||
##
|
||||
## Returns: true if interest in the topic prefix is no longer advertised.
|
||||
function Comm::unsubscribe_to_events%(topic_prefix: string%): bool
|
||||
function BrokerComm::unsubscribe_to_events%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->UnsubscribeToEvents(topic_prefix->CheckString());
|
||||
auto rval = broker_mgr->UnsubscribeToEvents(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -155,11 +155,11 @@ function Comm::unsubscribe_to_events%(topic_prefix: string%): bool
|
|||
##
|
||||
## Returns: true if remote logs are enabled for the stream.
|
||||
function
|
||||
Comm::enable_remote_logs%(id: Log::ID,
|
||||
BrokerComm::enable_remote_logs%(id: Log::ID,
|
||||
flags: SendFlags &default = SendFlags()%): bool
|
||||
%{
|
||||
auto rval = log_mgr->EnableRemoteLogs(id->AsEnumVal(),
|
||||
comm::Manager::send_flags_to_int(flags));
|
||||
bro_broker::Manager::send_flags_to_int(flags));
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -168,14 +168,14 @@ Comm::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 Comm::disable_remote_logs%(id: Log::ID%): bool
|
||||
function BrokerComm::disable_remote_logs%(id: Log::ID%): bool
|
||||
%{
|
||||
auto rval = log_mgr->DisableRemoteLogs(id->AsEnumVal());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
## Returns: true if remote logs are enabled for the given stream.
|
||||
function Comm::remote_logs_enabled%(id: Log::ID%): bool
|
||||
function BrokerComm::remote_logs_enabled%(id: Log::ID%): bool
|
||||
%{
|
||||
auto rval = log_mgr->RemoteLogsAreEnabled(id->AsEnumVal());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
|
@ -190,9 +190,9 @@ function Comm::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 Comm::subscribe_to_logs%(topic_prefix: string%): bool
|
||||
function BrokerComm::subscribe_to_logs%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->SubscribeToLogs(topic_prefix->CheckString());
|
||||
auto rval = broker_mgr->SubscribeToLogs(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -201,11 +201,11 @@ function Comm::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:`Comm::subscribe_to_logs`.
|
||||
## :bro:see:`BrokerComm::subscribe_to_logs`.
|
||||
##
|
||||
## Returns: true if interest in the topic prefix is no longer advertised.
|
||||
function Comm::unsubscribe_to_logs%(topic_prefix: string%): bool
|
||||
function BrokerComm::unsubscribe_to_logs%(topic_prefix: string%): bool
|
||||
%{
|
||||
auto rval = comm_mgr->UnsubscribeToLogs(topic_prefix->CheckString());
|
||||
auto rval = broker_mgr->UnsubscribeToLogs(topic_prefix->CheckString());
|
||||
return new Val(rval, TYPE_BOOL);
|
||||
%}
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
#include "Trigger.h"
|
||||
%%}
|
||||
|
||||
module Store;
|
||||
module BrokerStore;
|
||||
|
||||
type Store::ExpiryTime: record;
|
||||
type BrokerStore::ExpiryTime: record;
|
||||
|
||||
type Store::QueryResult: record;
|
||||
type BrokerStore::QueryResult: record;
|
||||
|
||||
type Store::BackendOptions: record;
|
||||
type BrokerStore::BackendOptions: record;
|
||||
|
||||
## Enumerates the possible storage backends.
|
||||
enum BackendType %{
|
||||
|
@ -32,12 +32,12 @@ enum BackendType %{
|
|||
## options: tunes how some storage backends operate.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function Store::create_master%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of Store::Handle
|
||||
function BrokerStore::create_master%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions()%): opaque of BrokerStore::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = comm::StoreType::MASTER;
|
||||
auto rval = comm_mgr->LookupStore(id_str, type);
|
||||
auto type = bro_broker::StoreType::MASTER;
|
||||
auto rval = broker_mgr->LookupStore(id_str, type);
|
||||
|
||||
if ( rval )
|
||||
{
|
||||
|
@ -45,10 +45,10 @@ function Store::create_master%(id: string, b: BackendType &default = MEMORY,
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval = new comm::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::Store::BackendType>(b->AsEnum()),
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::BrokerStore::BackendType>(b->AsEnum()),
|
||||
options->AsRecordVal());
|
||||
assert(comm_mgr->AddStore(rval));
|
||||
assert(broker_mgr->AddStore(rval));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
|
@ -74,13 +74,13 @@ function Store::create_master%(id: string, b: BackendType &default = MEMORY,
|
|||
## but updates will be lost until the master is once again available.
|
||||
##
|
||||
## Returns: a handle to the data store.
|
||||
function Store::create_clone%(id: string, b: BackendType &default = MEMORY,
|
||||
function BrokerStore::create_clone%(id: string, b: BackendType &default = MEMORY,
|
||||
options: BackendOptions &default = BackendOptions(),
|
||||
resync: interval &default = 1sec%): opaque of Store::Handle
|
||||
resync: interval &default = 1sec%): opaque of BrokerStore::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = comm::StoreType::CLONE;
|
||||
auto rval = comm_mgr->LookupStore(id_str, type);
|
||||
auto type = bro_broker::StoreType::CLONE;
|
||||
auto rval = broker_mgr->LookupStore(id_str, type);
|
||||
|
||||
if ( rval )
|
||||
{
|
||||
|
@ -88,11 +88,11 @@ function Store::create_clone%(id: string, b: BackendType &default = MEMORY,
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval = new comm::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::Store::BackendType>(b->AsEnum()),
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type,
|
||||
static_cast<BifEnum::BrokerStore::BackendType>(b->AsEnum()),
|
||||
options->AsRecordVal(),
|
||||
std::chrono::duration<double>(resync));
|
||||
assert(comm_mgr->AddStore(rval));
|
||||
assert(broker_mgr->AddStore(rval));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
|
@ -102,11 +102,11 @@ function Store::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 Store::create_frontend%(id: string%): opaque of Store::Handle
|
||||
function BrokerStore::create_frontend%(id: string%): opaque of BrokerStore::Handle
|
||||
%{
|
||||
auto id_str = id->CheckString();
|
||||
auto type = comm::StoreType::FRONTEND;
|
||||
auto rval = comm_mgr->LookupStore(id_str, type);
|
||||
auto type = bro_broker::StoreType::FRONTEND;
|
||||
auto rval = broker_mgr->LookupStore(id_str, type);
|
||||
|
||||
if ( rval )
|
||||
{
|
||||
|
@ -114,8 +114,8 @@ function Store::create_frontend%(id: string%): opaque of Store::Handle
|
|||
return rval;
|
||||
}
|
||||
|
||||
rval = new comm::StoreHandleVal(id_str, type, {}, nullptr);
|
||||
assert(comm_mgr->AddStore(rval));
|
||||
rval = new bro_broker::StoreHandleVal(id_str, type, {}, nullptr);
|
||||
assert(broker_mgr->AddStore(rval));
|
||||
return rval;
|
||||
%}
|
||||
|
||||
|
@ -125,14 +125,14 @@ function Store::create_frontend%(id: string%): opaque of Store::Handle
|
|||
##
|
||||
## Returns: true if store was valid and is now closed. The handle can no
|
||||
## longer be used for data store operations.
|
||||
function Store::close_by_handle%(h: opaque of Store::Handle%): bool
|
||||
function BrokerStore::close_by_handle%(h: opaque of BrokerStore::Handle%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
return new Val(comm_mgr->CloseStore(handle->store->id(),
|
||||
return new Val(broker_mgr->CloseStore(handle->store->id(),
|
||||
handle->store_type), TYPE_BOOL);
|
||||
%}
|
||||
|
||||
|
@ -151,17 +151,17 @@ function Store::close_by_handle%(h: opaque of Store::Handle%): bool
|
|||
## e: the expiration time of the key-value pair.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::insert%(h: opaque of Store::Handle,
|
||||
k: Comm::Data, v: Comm::Data,
|
||||
e: Store::ExpiryTime &default = Store::ExpiryTime()%): bool
|
||||
function BrokerStore::insert%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, v: BrokerComm::Data,
|
||||
e: BrokerStore::ExpiryTime &default = BrokerStore::ExpiryTime()%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& val = comm::opaque_field_to_data(v->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& val = bro_broker::opaque_field_to_data(v->AsRecordVal(), frame);
|
||||
|
||||
using broker::store::expiration_time;
|
||||
|
||||
|
@ -195,14 +195,14 @@ function Store::insert%(h: opaque of Store::Handle,
|
|||
## k: the key to remove.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::erase%(h: opaque of Store::Handle, k: Comm::Data%): bool
|
||||
function BrokerStore::erase%(h: opaque of BrokerStore::Handle, k: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
handle->store->erase(key);
|
||||
return new Val(true, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -212,9 +212,9 @@ function Store::erase%(h: opaque of Store::Handle, k: Comm::Data%): bool
|
|||
## h: the handle of the store to modify.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::clear%(h: opaque of Store::Handle%): bool
|
||||
function BrokerStore::clear%(h: opaque of BrokerStore::Handle%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
@ -233,15 +233,15 @@ function Store::clear%(h: opaque of Store::Handle%): bool
|
|||
## create it with an implicit value of zero before incrementing.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::increment%(h: opaque of Store::Handle,
|
||||
k: Comm::Data, by: int &default = +1%): bool
|
||||
function BrokerStore::increment%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, by: int &default = +1%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
handle->store->increment(key, by);
|
||||
return new Val(true, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -256,15 +256,15 @@ function Store::increment%(h: opaque of Store::Handle,
|
|||
## create it with an implicit value of zero before decrementing.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::decrement%(h: opaque of Store::Handle,
|
||||
k: Comm::Data, by: int &default = +1%): bool
|
||||
function BrokerStore::decrement%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, by: int &default = +1%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
handle->store->decrement(key, by);
|
||||
return new Val(true, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -279,16 +279,16 @@ function Store::decrement%(h: opaque of Store::Handle,
|
|||
## create it with an implicit empty set value before modifying.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::add_to_set%(h: opaque of Store::Handle,
|
||||
k: Comm::Data, element: Comm::Data%): bool
|
||||
function BrokerStore::add_to_set%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, element: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& ele = comm::opaque_field_to_data(element->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& ele = bro_broker::opaque_field_to_data(element->AsRecordVal(), frame);
|
||||
handle->store->add_to_set(key, ele);
|
||||
return new Val(true, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -303,16 +303,16 @@ function Store::add_to_set%(h: opaque of Store::Handle,
|
|||
## implicitly create an empty set value associated with the key.
|
||||
##
|
||||
## Returns: false if the store handle was not valid.
|
||||
function Store::remove_from_set%(h: opaque of Store::Handle,
|
||||
k: Comm::Data, element: Comm::Data%): bool
|
||||
function BrokerStore::remove_from_set%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data, element: BrokerComm::Data%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& ele = comm::opaque_field_to_data(element->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& ele = bro_broker::opaque_field_to_data(element->AsRecordVal(), frame);
|
||||
handle->store->remove_from_set(key, ele);
|
||||
return new Val(true, TYPE_BOOL);
|
||||
%}
|
||||
|
@ -327,21 +327,21 @@ function Store::remove_from_set%(h: opaque of Store::Handle,
|
|||
## create empty vector value before modifying.
|
||||
##
|
||||
## Returns: the handle of store to modify.
|
||||
function Store::push_left%(h: opaque of Store::Handle, k: Comm::Data,
|
||||
items: Comm::DataVector%): bool
|
||||
function BrokerStore::push_left%(h: opaque of BrokerStore::Handle, k: BrokerComm::Data,
|
||||
items: BrokerComm::DataVector%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
broker::vector items_vector;
|
||||
auto items_vv = items->AsVector();
|
||||
|
||||
for ( auto i = 0u; i < items_vv->size(); ++i )
|
||||
{
|
||||
auto& item = comm::opaque_field_to_data((*items_vv)[i]->AsRecordVal(),
|
||||
auto& item = bro_broker::opaque_field_to_data((*items_vv)[i]->AsRecordVal(),
|
||||
frame);
|
||||
items_vector.emplace_back(item);
|
||||
}
|
||||
|
@ -360,21 +360,21 @@ function Store::push_left%(h: opaque of Store::Handle, k: Comm::Data,
|
|||
## create empty vector value before modifying.
|
||||
##
|
||||
## Returns: the handle of store to modify.
|
||||
function Store::push_right%(h: opaque of Store::Handle, k: Comm::Data,
|
||||
items: Comm::DataVector%): bool
|
||||
function BrokerStore::push_right%(h: opaque of BrokerStore::Handle, k: BrokerComm::Data,
|
||||
items: BrokerComm::DataVector%): bool
|
||||
%{
|
||||
auto handle = static_cast<comm::StoreHandleVal*>(h);
|
||||
auto handle = static_cast<bro_broker::StoreHandleVal*>(h);
|
||||
|
||||
if ( ! handle->store )
|
||||
return new Val(false, TYPE_BOOL);
|
||||
|
||||
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
auto& key = bro_broker::opaque_field_to_data(k->AsRecordVal(), frame);
|
||||
broker::vector items_vector;
|
||||
auto items_vv = items->AsVector();
|
||||
|
||||
for ( auto i = 0u; i < items_vv->size(); ++i )
|
||||
{
|
||||
auto& item = comm::opaque_field_to_data((*items_vv)[i]->AsRecordVal(),
|
||||
auto& item = bro_broker::opaque_field_to_data((*items_vv)[i]->AsRecordVal(),
|
||||
frame);
|
||||
items_vector.emplace_back(item);
|
||||
}
|
||||
|
@ -389,11 +389,11 @@ function Store::push_right%(h: opaque of Store::Handle, k: Comm::Data,
|
|||
|
||||
%%{
|
||||
static bool prepare_for_query(Val* opaque, Frame* frame,
|
||||
comm::StoreHandleVal** handle,
|
||||
bro_broker::StoreHandleVal** handle,
|
||||
double* timeout,
|
||||
comm::StoreQueryCallback** cb)
|
||||
bro_broker::StoreQueryCallback** cb)
|
||||
{
|
||||
*handle = static_cast<comm::StoreHandleVal*>(opaque);
|
||||
*handle = static_cast<bro_broker::StoreHandleVal*>(opaque);
|
||||
|
||||
if ( ! (*handle)->store )
|
||||
return false;
|
||||
|
@ -403,7 +403,7 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( ! trigger )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("Store queries can only be called inside when-condition");
|
||||
reporter->Error("BrokerStore queries can only be called inside when-condition");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
@ -413,17 +413,17 @@ static bool prepare_for_query(Val* opaque, Frame* frame,
|
|||
if ( *timeout < 0 )
|
||||
{
|
||||
reporter->PushLocation(frame->GetCall()->GetLocationInfo());
|
||||
reporter->Error("Store queries must specify a timeout block");
|
||||
reporter->Error("BrokerStore queries must specify a timeout block");
|
||||
reporter->PopLocation();
|
||||
return false;
|
||||
}
|
||||
|
||||
frame->SetDelayed();
|
||||
trigger->Hold();
|
||||
*cb = new comm::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
*cb = new bro_broker::StoreQueryCallback(trigger, frame->GetCall(),
|
||||
(*handle)->store->id(),
|
||||
(*handle)->store_type);
|
||||
comm_mgr->TrackStoreQuery(*cb);
|
||||
broker_mgr->TrackStoreQuery(*cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -436,25 +436,25 @@ 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 Store::pop_left%(h: opaque of Store::Handle,
|
||||
k: Comm::Data%): Store::QueryResult
|
||||
function BrokerStore::pop_left%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
%{
|
||||
if ( ! comm_mgr->Enabled() )
|
||||
return comm::query_result();
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
||||
Val* key = k->AsRecordVal()->Lookup(0);
|
||||
|
||||
if ( ! key )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
double timeout;
|
||||
comm::StoreQueryCallback* cb;
|
||||
comm::StoreHandleVal* handle;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
bro_broker::StoreHandleVal* handle;
|
||||
|
||||
if ( ! prepare_for_query(h, frame, &handle, &timeout, &cb) )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
handle->store->pop_left(static_cast<comm::DataVal*>(key)->data,
|
||||
handle->store->pop_left(static_cast<bro_broker::DataVal*>(key)->data,
|
||||
std::chrono::duration<double>(timeout), cb);
|
||||
return 0;
|
||||
%}
|
||||
|
@ -466,25 +466,25 @@ function Store::pop_left%(h: opaque of Store::Handle,
|
|||
## k: the key associated with the vector to modify.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function Store::pop_right%(h: opaque of Store::Handle,
|
||||
k: Comm::Data%): Store::QueryResult
|
||||
function BrokerStore::pop_right%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
%{
|
||||
if ( ! comm_mgr->Enabled() )
|
||||
return comm::query_result();
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
||||
Val* key = k->AsRecordVal()->Lookup(0);
|
||||
|
||||
if ( ! key )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
double timeout;
|
||||
comm::StoreQueryCallback* cb;
|
||||
comm::StoreHandleVal* handle;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
bro_broker::StoreHandleVal* handle;
|
||||
|
||||
if ( ! prepare_for_query(h, frame, &handle, &timeout, &cb) )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
handle->store->pop_right(static_cast<comm::DataVal*>(key)->data,
|
||||
handle->store->pop_right(static_cast<bro_broker::DataVal*>(key)->data,
|
||||
std::chrono::duration<double>(timeout), cb);
|
||||
return 0;
|
||||
%}
|
||||
|
@ -496,25 +496,25 @@ function Store::pop_right%(h: opaque of Store::Handle,
|
|||
## k: the key to lookup.
|
||||
##
|
||||
## Returns: the result of the query.
|
||||
function Store::lookup%(h: opaque of Store::Handle,
|
||||
k: Comm::Data%): Store::QueryResult
|
||||
function BrokerStore::lookup%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
%{
|
||||
if ( ! comm_mgr->Enabled() )
|
||||
return comm::query_result();
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
||||
Val* key = k->AsRecordVal()->Lookup(0);
|
||||
|
||||
if ( ! key )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
double timeout;
|
||||
comm::StoreQueryCallback* cb;
|
||||
comm::StoreHandleVal* handle;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
bro_broker::StoreHandleVal* handle;
|
||||
|
||||
if ( ! prepare_for_query(h, frame, &handle, &timeout, &cb) )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
handle->store->lookup(static_cast<comm::DataVal*>(key)->data,
|
||||
handle->store->lookup(static_cast<bro_broker::DataVal*>(key)->data,
|
||||
std::chrono::duration<double>(timeout), cb);
|
||||
return 0;
|
||||
%}
|
||||
|
@ -525,26 +525,26 @@ function Store::lookup%(h: opaque of Store::Handle,
|
|||
##
|
||||
## k: the key to check for existence.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`Comm::BOOL`).
|
||||
function Store::exists%(h: opaque of Store::Handle,
|
||||
k: Comm::Data%): Store::QueryResult
|
||||
## Returns: the result of the query (uses :bro:see:`BrokerComm::BOOL`).
|
||||
function BrokerStore::exists%(h: opaque of BrokerStore::Handle,
|
||||
k: BrokerComm::Data%): BrokerStore::QueryResult
|
||||
%{
|
||||
if ( ! comm_mgr->Enabled() )
|
||||
return comm::query_result();
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
||||
Val* key = k->AsRecordVal()->Lookup(0);
|
||||
|
||||
if ( ! key )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
double timeout;
|
||||
comm::StoreQueryCallback* cb;
|
||||
comm::StoreHandleVal* handle;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
bro_broker::StoreHandleVal* handle;
|
||||
|
||||
if ( ! prepare_for_query(h, frame, &handle, &timeout, &cb) )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
handle->store->exists(static_cast<comm::DataVal*>(key)->data,
|
||||
handle->store->exists(static_cast<bro_broker::DataVal*>(key)->data,
|
||||
std::chrono::duration<double>(timeout), cb);
|
||||
return 0;
|
||||
%}
|
||||
|
@ -553,15 +553,15 @@ function Store::exists%(h: opaque of Store::Handle,
|
|||
##
|
||||
## h: the handle of the store to query.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`Comm::VECTOR`).
|
||||
function Store::keys%(h: opaque of Store::Handle%): Store::QueryResult
|
||||
## Returns: the result of the query (uses :bro:see:`BrokerComm::VECTOR`).
|
||||
function BrokerStore::keys%(h: opaque of BrokerStore::Handle%): BrokerStore::QueryResult
|
||||
%{
|
||||
double timeout;
|
||||
comm::StoreQueryCallback* cb;
|
||||
comm::StoreHandleVal* handle;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
bro_broker::StoreHandleVal* handle;
|
||||
|
||||
if ( ! prepare_for_query(h, frame, &handle, &timeout, &cb) )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
handle->store->keys(std::chrono::duration<double>(timeout), cb);
|
||||
return 0;
|
||||
|
@ -571,18 +571,18 @@ function Store::keys%(h: opaque of Store::Handle%): Store::QueryResult
|
|||
##
|
||||
## h: the handle of the store to query.
|
||||
##
|
||||
## Returns: the result of the query (uses :bro:see:`Comm::COUNT`).
|
||||
function Store::size%(h: opaque of Store::Handle%): Store::QueryResult
|
||||
## Returns: the result of the query (uses :bro:see:`BrokerComm::COUNT`).
|
||||
function BrokerStore::size%(h: opaque of BrokerStore::Handle%): BrokerStore::QueryResult
|
||||
%{
|
||||
if ( ! comm_mgr->Enabled() )
|
||||
return comm::query_result();
|
||||
if ( ! broker_mgr->Enabled() )
|
||||
return bro_broker::query_result();
|
||||
|
||||
double timeout;
|
||||
comm::StoreQueryCallback* cb;
|
||||
comm::StoreHandleVal* handle;
|
||||
bro_broker::StoreQueryCallback* cb;
|
||||
bro_broker::StoreHandleVal* handle;
|
||||
|
||||
if ( ! prepare_for_query(h, frame, &handle, &timeout, &cb) )
|
||||
return comm::query_result();
|
||||
return bro_broker::query_result();
|
||||
|
||||
handle->store->size(std::chrono::duration<double>(timeout), cb);
|
||||
return 0;
|
||||
|
|
|
@ -844,7 +844,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
|
|||
|
||||
#ifdef ENABLE_BROKER
|
||||
if ( stream->enable_remote &&
|
||||
! comm_mgr->Log(id, columns, stream->columns, stream->remote_flags) )
|
||||
! broker_mgr->Log(id, columns, stream->columns, stream->remote_flags) )
|
||||
stream->enable_remote = false;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ file_analysis::Manager* file_mgr = 0;
|
|||
broxygen::Manager* broxygen_mgr = 0;
|
||||
iosource::Manager* iosource_mgr = 0;
|
||||
#ifdef ENABLE_BROKER
|
||||
comm::Manager* comm_mgr = 0;
|
||||
bro_broker::Manager* broker_mgr = 0;
|
||||
#endif
|
||||
|
||||
const char* prog;
|
||||
|
@ -860,7 +860,7 @@ int main(int argc, char** argv)
|
|||
file_mgr = new file_analysis::Manager();
|
||||
|
||||
#ifdef ENABLE_BROKER
|
||||
comm_mgr = new comm::Manager();
|
||||
broker_mgr = new bro_broker::Manager();
|
||||
#endif
|
||||
|
||||
plugin_mgr->InitPreScript();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
clone keys, [status=Store::SUCCESS, result=[d=broker::data{[one, two, myset, myvec]}]]
|
||||
lookup, one, [status=Store::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup, two, [status=Store::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup, myset, [status=Store::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup, myvec, [status=Store::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
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]}]]
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Comm::incoming_connection_established, connector
|
||||
Comm::incoming_connection_broken, connector
|
||||
BrokerComm::incoming_connection_established, connector
|
||||
BrokerComm::incoming_connection_broken, connector
|
||||
|
|
|
@ -1 +1 @@
|
|||
Comm::outgoing_connection_established, 127.0.0.1, 9999/tcp, listener
|
||||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp, listener
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
Comm::BOOL
|
||||
Comm::INT
|
||||
Comm::COUNT
|
||||
Comm::DOUBLE
|
||||
Comm::STRING
|
||||
Comm::ADDR
|
||||
Comm::SUBNET
|
||||
Comm::PORT
|
||||
Comm::TIME
|
||||
Comm::INTERVAL
|
||||
Comm::ENUM
|
||||
Comm::SET
|
||||
Comm::TABLE
|
||||
Comm::VECTOR
|
||||
Comm::RECORD
|
||||
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
|
||||
***************************
|
||||
T
|
||||
F
|
||||
|
@ -29,7 +29,7 @@ hello
|
|||
22/tcp
|
||||
42.0
|
||||
180.0
|
||||
Comm::BOOL
|
||||
BrokerComm::BOOL
|
||||
***************************
|
||||
{
|
||||
two,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
lookup(two): [status=Store::SUCCESS, result=[d=broker::data{222}]]
|
||||
lookup(four): [status=Store::SUCCESS, result=[d=<uninitialized>]]
|
||||
lookup(myset): [status=Store::SUCCESS, result=[d=broker::data{{a, c, d}}]]
|
||||
lookup(one): [status=Store::SUCCESS, result=[d=broker::data{111}]]
|
||||
lookup(myvec): [status=Store::SUCCESS, result=[d=broker::data{[delta, alpha, beta, gamma, omega]}]]
|
||||
exists(one): [status=Store::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(two): [status=Store::SUCCESS, result=[d=broker::data{0}]]
|
||||
exists(myset): [status=Store::SUCCESS, result=[d=broker::data{1}]]
|
||||
exists(four): [status=Store::SUCCESS, result=[d=broker::data{0}]]
|
||||
pop_right(myvec): [status=Store::SUCCESS, result=[d=broker::data{omega}]]
|
||||
pop_left(myvec): [status=Store::SUCCESS, result=[d=broker::data{delta}]]
|
||||
keys: [status=Store::SUCCESS, result=[d=broker::data{[myvec, myset, one]}]]
|
||||
size: [status=Store::SUCCESS, result=[d=broker::data{3}]]
|
||||
size (after clear): [status=Store::SUCCESS, result=[d=broker::data{0}]]
|
||||
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}]]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Comm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
BrokerComm::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 @@
|
|||
Comm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Comm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
BrokerComm::outgoing_connection_established, 127.0.0.1, 9999/tcp
|
||||
got print msg, pong 0
|
||||
got print msg, pong 1
|
||||
got print msg, pong 2
|
||||
|
|
|
@ -5,19 +5,19 @@ connecting-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -5,21 +5,21 @@ connecting-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_broken(peer_name: string)
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_broken", peer_name;
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,31 +4,31 @@ events-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Comm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "hi", 0));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "hi", 0));
|
||||
event my_auto_event("stuff", 88);
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "...", 1));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "...", 1));
|
||||
event my_auto_event("more stuff", 51);
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "bye", 2));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "bye", 2));
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -5,21 +5,21 @@ events-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::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()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event my_event(msg: string, c: count)
|
||||
|
|
|
@ -6,16 +6,16 @@ logs-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Log::enable_local_logging = F;
|
||||
redef Log::enable_remote_logging = F;
|
||||
global n = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::enable_remote_logs(Test::LOG);
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event do_write()
|
||||
|
@ -28,16 +28,16 @@ event do_write()
|
|||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -6,18 +6,18 @@ logs-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
|
|
@ -4,26 +4,26 @@ printing-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
Comm::print("bro/print/hi", "hello");
|
||||
Comm::print("bro/print/stuff", "...");
|
||||
Comm::print("bro/print/bye", "goodbye");
|
||||
BrokerComm::print("bro/print/hi", "hello");
|
||||
BrokerComm::print("bro/print/stuff", "...");
|
||||
BrokerComm::print("bro/print/bye", "goodbye");
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -5,22 +5,22 @@ printing-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_prints("bro/print/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Comm::print_handler(msg: string)
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
{
|
||||
++msg_count;
|
||||
print "got print message", msg;
|
||||
|
|
|
@ -5,42 +5,42 @@ stores-connector.bro
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
|
||||
function dv(d: Comm::Data): Comm::DataVector
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
{
|
||||
local rval: Comm::DataVector;
|
||||
local rval: BrokerComm::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::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 = Store::create_master("mystore");
|
||||
Store::insert(h, Comm::data("one"), Comm::data(110));
|
||||
Store::insert(h, Comm::data("two"), Comm::data(223));
|
||||
Store::insert(h, Comm::data("myset"), Comm::data(myset));
|
||||
Store::insert(h, Comm::data("myvec"), Comm::data(myvec));
|
||||
Store::increment(h, Comm::data("one"));
|
||||
Store::decrement(h, Comm::data("two"));
|
||||
Store::add_to_set(h, Comm::data("myset"), Comm::data("d"));
|
||||
Store::remove_from_set(h, Comm::data("myset"), Comm::data("b"));
|
||||
Store::push_left(h, Comm::data("myvec"), dv(Comm::data("delta")));
|
||||
Store::push_right(h, Comm::data("myvec"), dv(Comm::data("omega")));
|
||||
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")));
|
||||
|
||||
when ( local res = Store::size(h) )
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
@ -51,7 +51,7 @@ event Comm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Comm::auto_event("bro/event/ready", ready);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ stores-listener.bro
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = Store::lookup(h, Comm::data(key)) )
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -25,15 +25,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = Store::create_clone("mystore");
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
|
||||
when ( local res = Store::keys(h) )
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 0)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 1)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 2)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 3)));
|
||||
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)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -41,7 +41,7 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/ready");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
Comm::enable();
|
||||
BrokerComm::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test]);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
|
@ -21,7 +21,7 @@ global query_timeout = 15sec;
|
|||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = Store::lookup(h, Comm::data(key)) )
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -38,15 +38,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = Store::create_clone("mystore");
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
|
||||
when ( local res = Store::keys(h) )
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 0)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 1)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 2)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 3)));
|
||||
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)));
|
||||
}
|
||||
timeout query_timeout
|
||||
{
|
||||
|
@ -57,9 +57,9 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/ready");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::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 Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
|
||||
function dv(d: Comm::Data): Comm::DataVector
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
{
|
||||
local rval: Comm::DataVector;
|
||||
local rval: BrokerComm::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::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 = Store::create_master("mystore");
|
||||
Store::insert(h, Comm::data("one"), Comm::data(110));
|
||||
Store::insert(h, Comm::data("two"), Comm::data(223));
|
||||
Store::insert(h, Comm::data("myset"), Comm::data(myset));
|
||||
Store::insert(h, Comm::data("myvec"), Comm::data(myvec));
|
||||
Store::increment(h, Comm::data("one"));
|
||||
Store::decrement(h, Comm::data("two"));
|
||||
Store::add_to_set(h, Comm::data("myset"), Comm::data("d"));
|
||||
Store::remove_from_set(h, Comm::data("myset"), Comm::data("b"));
|
||||
Store::push_left(h, Comm::data("myvec"), dv(Comm::data("delta")));
|
||||
Store::push_right(h, Comm::data("myvec"), dv(Comm::data("omega")));
|
||||
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")));
|
||||
|
||||
when ( local res = Store::size(h) )
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
{ event ready(); }
|
||||
timeout query_timeout
|
||||
{
|
||||
|
@ -117,9 +117,9 @@ event Comm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::auto_event("bro/event/ready", ready);
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
BrokerComm::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 Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;;
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_broken(peer_name: string)
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_broken", peer_name;;
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;;
|
||||
terminate();
|
||||
}
|
||||
|
||||
|
@ -37,19 +37,19 @@ event Comm::incoming_connection_broken(peer_name: string)
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::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 Comm::RecordIterator,
|
||||
function comm_record_to_bro_record_recurse(it: opaque of BrokerComm::RecordIterator,
|
||||
rval: bro_record,
|
||||
idx: count): bro_record
|
||||
{
|
||||
if ( Comm::record_iterator_last(it) )
|
||||
if ( BrokerComm::record_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
local field_value = Comm::record_iterator_value(it);
|
||||
local field_value = BrokerComm::record_iterator_value(it);
|
||||
|
||||
if ( field_value?$d )
|
||||
switch ( idx ) {
|
||||
case 0:
|
||||
rval$a = Comm::refine_to_string(field_value);
|
||||
rval$a = BrokerComm::refine_to_string(field_value);
|
||||
break;
|
||||
case 1:
|
||||
rval$b = Comm::refine_to_string(field_value);
|
||||
rval$b = BrokerComm::refine_to_string(field_value);
|
||||
break;
|
||||
case 2:
|
||||
rval$c = Comm::refine_to_count(field_value);
|
||||
rval$c = BrokerComm::refine_to_count(field_value);
|
||||
break;
|
||||
};
|
||||
|
||||
++idx;
|
||||
Comm::record_iterator_next(it);
|
||||
BrokerComm::record_iterator_next(it);
|
||||
return comm_record_to_bro_record_recurse(it, rval, idx);
|
||||
}
|
||||
|
||||
function comm_record_to_bro_record(d: Comm::Data): bro_record
|
||||
function comm_record_to_bro_record(d: BrokerComm::Data): bro_record
|
||||
{
|
||||
return comm_record_to_bro_record_recurse(Comm::record_iterator(d),
|
||||
return comm_record_to_bro_record_recurse(BrokerComm::record_iterator(d),
|
||||
bro_record($c = 0), 0);
|
||||
}
|
||||
|
||||
function
|
||||
comm_set_to_bro_set_recurse(it: opaque of Comm::SetIterator,
|
||||
comm_set_to_bro_set_recurse(it: opaque of BrokerComm::SetIterator,
|
||||
rval: bro_set): bro_set
|
||||
{
|
||||
if ( Comm::set_iterator_last(it) )
|
||||
if ( BrokerComm::set_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
add rval[Comm::refine_to_string(Comm::set_iterator_value(it))];
|
||||
Comm::set_iterator_next(it);
|
||||
add rval[BrokerComm::refine_to_string(BrokerComm::set_iterator_value(it))];
|
||||
BrokerComm::set_iterator_next(it);
|
||||
return comm_set_to_bro_set_recurse(it, rval);
|
||||
}
|
||||
|
||||
|
||||
function comm_set_to_bro_set(d: Comm::Data): bro_set
|
||||
function comm_set_to_bro_set(d: BrokerComm::Data): bro_set
|
||||
{
|
||||
return comm_set_to_bro_set_recurse(Comm::set_iterator(d), bro_set());
|
||||
return comm_set_to_bro_set_recurse(BrokerComm::set_iterator(d), bro_set());
|
||||
}
|
||||
|
||||
function
|
||||
comm_table_to_bro_table_recurse(it: opaque of Comm::TableIterator,
|
||||
comm_table_to_bro_table_recurse(it: opaque of BrokerComm::TableIterator,
|
||||
rval: bro_table): bro_table
|
||||
{
|
||||
if ( Comm::table_iterator_last(it) )
|
||||
if ( BrokerComm::table_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
local item = Comm::table_iterator_value(it);
|
||||
rval[Comm::refine_to_string(item$key)] = Comm::refine_to_count(item$val);
|
||||
Comm::table_iterator_next(it);
|
||||
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);
|
||||
return comm_table_to_bro_table_recurse(it, rval);
|
||||
}
|
||||
|
||||
function comm_table_to_bro_table(d: Comm::Data): bro_table
|
||||
function comm_table_to_bro_table(d: BrokerComm::Data): bro_table
|
||||
{
|
||||
return comm_table_to_bro_table_recurse(Comm::table_iterator(d),
|
||||
return comm_table_to_bro_table_recurse(BrokerComm::table_iterator(d),
|
||||
bro_table());
|
||||
}
|
||||
|
||||
function comm_vector_to_bro_vector_recurse(it: opaque of Comm::VectorIterator,
|
||||
function comm_vector_to_bro_vector_recurse(it: opaque of BrokerComm::VectorIterator,
|
||||
rval: bro_vector): bro_vector
|
||||
{
|
||||
if ( Comm::vector_iterator_last(it) )
|
||||
if ( BrokerComm::vector_iterator_last(it) )
|
||||
return rval;
|
||||
|
||||
rval[|rval|] = Comm::refine_to_string(Comm::vector_iterator_value(it));
|
||||
Comm::vector_iterator_next(it);
|
||||
rval[|rval|] = BrokerComm::refine_to_string(BrokerComm::vector_iterator_value(it));
|
||||
BrokerComm::vector_iterator_next(it);
|
||||
return comm_vector_to_bro_vector_recurse(it, rval);
|
||||
}
|
||||
|
||||
function comm_vector_to_bro_vector(d: Comm::Data): bro_vector
|
||||
function comm_vector_to_bro_vector(d: BrokerComm::Data): bro_vector
|
||||
{
|
||||
return comm_vector_to_bro_vector_recurse(Comm::vector_iterator(d),
|
||||
return comm_vector_to_bro_vector_recurse(BrokerComm::vector_iterator(d),
|
||||
bro_vector());
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
print Comm::data_type(Comm::data(T));
|
||||
print Comm::data_type(Comm::data(+1));
|
||||
print Comm::data_type(Comm::data(1));
|
||||
print Comm::data_type(Comm::data(1.1));
|
||||
print Comm::data_type(Comm::data("1 (how creative)"));
|
||||
print Comm::data_type(Comm::data(1.1.1.1));
|
||||
print Comm::data_type(Comm::data(1.1.1.1/1));
|
||||
print Comm::data_type(Comm::data(1/udp));
|
||||
print Comm::data_type(Comm::data(double_to_time(1)));
|
||||
print Comm::data_type(Comm::data(1sec));
|
||||
print Comm::data_type(Comm::data(Comm::BOOL));
|
||||
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));
|
||||
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 Comm::data_type(Comm::data(s));
|
||||
print Comm::data_type(Comm::data(t));
|
||||
print Comm::data_type(Comm::data(v));
|
||||
print Comm::data_type(Comm::data(r));
|
||||
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 "***************************";
|
||||
|
||||
print Comm::refine_to_bool(Comm::data(T));
|
||||
print Comm::refine_to_bool(Comm::data(F));
|
||||
print Comm::refine_to_int(Comm::data(+1));
|
||||
print Comm::refine_to_int(Comm::data(+0));
|
||||
print Comm::refine_to_int(Comm::data(-1));
|
||||
print Comm::refine_to_count(Comm::data(1));
|
||||
print Comm::refine_to_count(Comm::data(0));
|
||||
print Comm::refine_to_double(Comm::data(1.1));
|
||||
print Comm::refine_to_double(Comm::data(-11.1));
|
||||
print Comm::refine_to_string(Comm::data("hello"));
|
||||
print Comm::refine_to_addr(Comm::data(1.2.3.4));
|
||||
print Comm::refine_to_subnet(Comm::data(192.168.1.1/16));
|
||||
print Comm::refine_to_port(Comm::data(22/tcp));
|
||||
print Comm::refine_to_time(Comm::data(double_to_time(42)));
|
||||
print Comm::refine_to_interval(Comm::data(3min));
|
||||
print Comm::refine_to_enum_name(Comm::data(Comm::BOOL));
|
||||
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 "***************************";
|
||||
|
||||
local cs = Comm::data(s);
|
||||
local cs = BrokerComm::data(s);
|
||||
print comm_set_to_bro_set(cs);
|
||||
cs = Comm::set_create();
|
||||
print Comm::set_size(cs);
|
||||
print Comm::set_insert(cs, Comm::data("hi"));
|
||||
print Comm::set_size(cs);
|
||||
print Comm::set_contains(cs, Comm::data("hi"));
|
||||
print Comm::set_contains(cs, Comm::data("bye"));
|
||||
print Comm::set_insert(cs, Comm::data("bye"));
|
||||
print Comm::set_size(cs);
|
||||
print Comm::set_remove(cs, Comm::data("hi"));
|
||||
print Comm::set_size(cs);
|
||||
print Comm::set_remove(cs, Comm::data("hi"));
|
||||
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"));
|
||||
print comm_set_to_bro_set(cs);
|
||||
Comm::set_clear(cs);
|
||||
print Comm::set_size(cs);
|
||||
BrokerComm::set_clear(cs);
|
||||
print BrokerComm::set_size(cs);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local ct = Comm::data(t);
|
||||
local ct = BrokerComm::data(t);
|
||||
print comm_table_to_bro_table(ct);
|
||||
ct = Comm::table_create();
|
||||
print Comm::table_size(ct);
|
||||
print Comm::table_insert(ct, Comm::data("hi"), Comm::data(42));
|
||||
print Comm::table_size(ct);
|
||||
print Comm::table_contains(ct, Comm::data("hi"));
|
||||
print Comm::refine_to_count(Comm::table_lookup(ct, Comm::data("hi")));
|
||||
print Comm::table_contains(ct, Comm::data("bye"));
|
||||
print Comm::table_insert(ct, Comm::data("bye"), Comm::data(7));
|
||||
print Comm::table_size(ct);
|
||||
print Comm::table_insert(ct, Comm::data("bye"), Comm::data(37));
|
||||
print Comm::table_size(ct);
|
||||
print Comm::refine_to_count(Comm::table_lookup(ct, Comm::data("bye")));
|
||||
print Comm::table_remove(ct, Comm::data("hi"));
|
||||
print Comm::table_size(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);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cv = Comm::data(v);
|
||||
local cv = BrokerComm::data(v);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
cv = Comm::vector_create();
|
||||
print Comm::vector_size(cv);
|
||||
print Comm::vector_insert(cv, Comm::data("hi"), 0);
|
||||
print Comm::vector_insert(cv, Comm::data("hello"), 1);
|
||||
print Comm::vector_insert(cv, Comm::data("greetings"), 2);
|
||||
print Comm::vector_insert(cv, Comm::data("salutations"), 1);
|
||||
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);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print Comm::vector_size(cv);
|
||||
print Comm::vector_replace(cv, Comm::data("bah"), 2);
|
||||
print Comm::vector_lookup(cv, 2);
|
||||
print Comm::vector_lookup(cv, 0);
|
||||
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 comm_vector_to_bro_vector(cv);
|
||||
print Comm::vector_remove(cv, 2);
|
||||
print BrokerComm::vector_remove(cv, 2);
|
||||
print comm_vector_to_bro_vector(cv);
|
||||
print Comm::vector_size(cv);
|
||||
print BrokerComm::vector_size(cv);
|
||||
|
||||
print "***************************";
|
||||
|
||||
local cr = Comm::data(r);
|
||||
local cr = BrokerComm::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
r$a = "test";
|
||||
cr = Comm::data(r);
|
||||
cr = BrokerComm::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
r$b = "testagain";
|
||||
cr = Comm::data(r);
|
||||
cr = BrokerComm::data(r);
|
||||
print comm_record_to_bro_record(cr);
|
||||
cr = Comm::record_create(3);
|
||||
print Comm::record_size(cr);
|
||||
print Comm::record_assign(cr, Comm::data("hi"), 0);
|
||||
print Comm::record_assign(cr, Comm::data("hello"), 1);
|
||||
print Comm::record_assign(cr, Comm::data(37), 2);
|
||||
print Comm::record_lookup(cr, 0);
|
||||
print Comm::record_lookup(cr, 1);
|
||||
print Comm::record_lookup(cr, 2);
|
||||
print Comm::record_size(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);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global lookup_count = 0;
|
||||
const lookup_expect_count = 5;
|
||||
global exists_count = 0;
|
||||
|
@ -20,13 +20,13 @@ global query_timeout = 5sec;
|
|||
|
||||
event test_clear()
|
||||
{
|
||||
Store::clear(h);
|
||||
BrokerStore::clear(h);
|
||||
event test_size("after clear");
|
||||
}
|
||||
|
||||
event test_size(where: string)
|
||||
{
|
||||
when ( local res = Store::size(h) )
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
{
|
||||
if ( where == "" )
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ event test_size(where: string)
|
|||
|
||||
event test_keys()
|
||||
{
|
||||
when ( local res = Store::keys(h) )
|
||||
when ( local res = BrokerStore::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 = Store::pop_left(h, Comm::data(key)) )
|
||||
when ( local lres = BrokerStore::pop_left(h, BrokerComm::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 = Store::pop_right(h, Comm::data(key)) )
|
||||
when ( local rres = BrokerStore::pop_right(h, BrokerComm::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 = Store::exists(h, Comm::data(key)) )
|
||||
when ( local res = BrokerStore::exists(h, BrokerComm::data(key)) )
|
||||
{
|
||||
print fmt("exists(%s): %s", key, res);
|
||||
++exists_count;
|
||||
|
@ -123,7 +123,7 @@ function do_exists(key: string)
|
|||
|
||||
event test_erase()
|
||||
{
|
||||
Store::erase(h, Comm::data("two"));
|
||||
BrokerStore::erase(h, BrokerComm::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 = Store::lookup(h, Comm::data(key)) )
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
{
|
||||
print fmt("lookup(%s): %s", key, res);
|
||||
++lookup_count;
|
||||
|
@ -150,29 +150,29 @@ function do_lookup(key: string)
|
|||
}
|
||||
}
|
||||
|
||||
function dv(d: Comm::Data): Comm::DataVector
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
{
|
||||
local rval: Comm::DataVector;
|
||||
local rval: BrokerComm::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
BrokerComm::enable();
|
||||
local myset: set[string] = {"a", "b", "c"};
|
||||
local myvec: vector of string = {"alpha", "beta", "gamma"};
|
||||
h = Store::create_master("master");
|
||||
Store::insert(h, Comm::data("one"), Comm::data(110));
|
||||
Store::insert(h, Comm::data("two"), Comm::data(223));
|
||||
Store::insert(h, Comm::data("myset"), Comm::data(myset));
|
||||
Store::insert(h, Comm::data("myvec"), Comm::data(myvec));
|
||||
Store::increment(h, Comm::data("one"));
|
||||
Store::decrement(h, Comm::data("two"));
|
||||
Store::add_to_set(h, Comm::data("myset"), Comm::data("d"));
|
||||
Store::remove_from_set(h, Comm::data("myset"), Comm::data("b"));
|
||||
Store::push_left(h, Comm::data("myvec"), dv(Comm::data("delta")));
|
||||
Store::push_right(h, Comm::data("myvec"), dv(Comm::data("omega")));
|
||||
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")));
|
||||
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()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/");
|
||||
Comm::auto_event("bro/event/my_topic", auto_event_handler);
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
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");
|
||||
}
|
||||
|
||||
global event_count = 0;
|
||||
|
@ -39,8 +39,8 @@ event event_handler(msg: string, n: count)
|
|||
}
|
||||
|
||||
event auto_event_handler(msg, n);
|
||||
local args = Comm::event_args(event_handler, "pong", n);
|
||||
Comm::event("bro/event/my_topic", args);
|
||||
local args = BrokerComm::event_args(event_handler, "pong", n);
|
||||
BrokerComm::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()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/my_topic");
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/my_topic");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global event_count = 0;
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established", peer_address, peer_port;
|
||||
local args = Comm::event_args(event_handler, "ping", event_count);
|
||||
Comm::event("bro/event/hi", args);
|
||||
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);
|
||||
++event_count;
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
@ -81,8 +81,8 @@ event Comm::outgoing_connection_broken(peer_address: string,
|
|||
event event_handler(msg: string, n: count)
|
||||
{
|
||||
print "got event msg", msg, n;
|
||||
local args = Comm::event_args(event_handler, "ping", event_count);
|
||||
Comm::event("bro/event/hi", args);
|
||||
local args = BrokerComm::event_args(event_handler, "ping", event_count);
|
||||
BrokerComm::event("bro/event/hi", args);
|
||||
++event_count;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
Comm::enable();
|
||||
BrokerComm::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()
|
||||
{
|
||||
Comm::subscribe_to_logs("bro/log/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_logs("bro/log/");
|
||||
BrokerComm::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()
|
||||
{
|
||||
Comm::enable_remote_logs(Test::LOG);
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global n = 0;
|
||||
|
@ -80,15 +80,15 @@ event do_write()
|
|||
}
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established", peer_address, peer_port;
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -15,16 +15,16 @@ redef exit_only_after_terminate = T;
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
Comm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
}
|
||||
|
||||
global messages_to_recv = 6;
|
||||
global messages_sent = 0;
|
||||
global messages_recv = 0;
|
||||
|
||||
event Comm::print_handler(msg: string)
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
{
|
||||
++messages_recv;
|
||||
print "got print msg", msg;
|
||||
|
@ -35,7 +35,7 @@ event Comm::print_handler(msg: string)
|
|||
return;
|
||||
}
|
||||
|
||||
Comm::print("bro/print/my_topic", fmt("pong %d", messages_sent));
|
||||
BrokerComm::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()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_prints("bro/print/my_topic");
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/my_topic");
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
}
|
||||
|
||||
global messages_sent = 0;
|
||||
global messages_recv = 0;
|
||||
global peer_disconnected = F;
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established", peer_address, peer_port;
|
||||
Comm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
print "BrokerComm::outgoing_connection_established", peer_address, peer_port;
|
||||
BrokerComm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event Comm::print_handler(msg: string)
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
{
|
||||
++messages_recv;
|
||||
print "got print msg", msg;
|
||||
Comm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
BrokerComm::print("bro/print/hi", fmt("ping %d", messages_sent));
|
||||
++messages_sent;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,19 +5,19 @@ connecting-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -5,21 +5,21 @@ connecting-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_broken(peer_name: string)
|
||||
event BrokerComm::incoming_connection_broken(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_broken", peer_name;
|
||||
print "BrokerComm::incoming_connection_broken", peer_name;
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -4,31 +4,31 @@ events-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
global my_event: event(msg: string, c: count);
|
||||
global my_auto_event: event(msg: string, c: count);
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
Comm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::auto_event("bro/event/my_auto_event", my_auto_event);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "hi", 0));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "hi", 0));
|
||||
event my_auto_event("stuff", 88);
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "...", 1));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "...", 1));
|
||||
event my_auto_event("more stuff", 51);
|
||||
Comm::event("bro/event/my_event", Comm::event_args(my_event, "bye", 2));
|
||||
BrokerComm::event("bro/event/my_event", BrokerComm::event_args(my_event, "bye", 2));
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -5,21 +5,21 @@ events-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::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()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event my_event(msg: string, c: count)
|
||||
|
|
|
@ -6,16 +6,16 @@ logs-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
redef Log::enable_local_logging = F;
|
||||
redef Log::enable_remote_logging = F;
|
||||
global n = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::enable_remote_logs(Test::LOG);
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::enable_remote_logs(Test::LOG);
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event do_write()
|
||||
|
@ -28,16 +28,16 @@ event do_write()
|
|||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
event do_write();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -6,18 +6,18 @@ logs-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_logs("bro/log/Test::LOG");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Test::log_test(rec: Test::Info)
|
||||
|
|
|
@ -4,26 +4,26 @@ printing-connector.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "connector";
|
||||
redef BrokerComm::endpoint_name = "connector";
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1sec);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1sec);
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_established(peer_address: string,
|
||||
peer_port: port,
|
||||
peer_name: string)
|
||||
{
|
||||
print "Comm::outgoing_connection_established",
|
||||
print "BrokerComm::outgoing_connection_established",
|
||||
peer_address, peer_port, peer_name;
|
||||
Comm::print("bro/print/hi", "hello");
|
||||
Comm::print("bro/print/stuff", "...");
|
||||
Comm::print("bro/print/bye", "goodbye");
|
||||
BrokerComm::print("bro/print/hi", "hello");
|
||||
BrokerComm::print("bro/print/stuff", "...");
|
||||
BrokerComm::print("bro/print/bye", "goodbye");
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
|
|
|
@ -5,22 +5,22 @@ printing-listener.bro
|
|||
|
||||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Comm::endpoint_name = "listener";
|
||||
redef BrokerComm::endpoint_name = "listener";
|
||||
global msg_count = 0;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_prints("bro/print/");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_prints("bro/print/");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
||||
event Comm::incoming_connection_established(peer_name: string)
|
||||
event BrokerComm::incoming_connection_established(peer_name: string)
|
||||
{
|
||||
print "Comm::incoming_connection_established", peer_name;
|
||||
print "BrokerComm::incoming_connection_established", peer_name;
|
||||
}
|
||||
|
||||
event Comm::print_handler(msg: string)
|
||||
event BrokerComm::print_handler(msg: string)
|
||||
{
|
||||
++msg_count;
|
||||
print "got print message", msg;
|
||||
|
|
|
@ -5,42 +5,42 @@ stores-connector.bro
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
|
||||
function dv(d: Comm::Data): Comm::DataVector
|
||||
function dv(d: BrokerComm::Data): BrokerComm::DataVector
|
||||
{
|
||||
local rval: Comm::DataVector;
|
||||
local rval: BrokerComm::DataVector;
|
||||
rval[0] = d;
|
||||
return rval;
|
||||
}
|
||||
|
||||
global ready: event();
|
||||
|
||||
event Comm::outgoing_connection_broken(peer_address: string,
|
||||
event BrokerComm::outgoing_connection_broken(peer_address: string,
|
||||
peer_port: port)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
event Comm::outgoing_connection_established(peer_address: string,
|
||||
event BrokerComm::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 = Store::create_master("mystore");
|
||||
Store::insert(h, Comm::data("one"), Comm::data(110));
|
||||
Store::insert(h, Comm::data("two"), Comm::data(223));
|
||||
Store::insert(h, Comm::data("myset"), Comm::data(myset));
|
||||
Store::insert(h, Comm::data("myvec"), Comm::data(myvec));
|
||||
Store::increment(h, Comm::data("one"));
|
||||
Store::decrement(h, Comm::data("two"));
|
||||
Store::add_to_set(h, Comm::data("myset"), Comm::data("d"));
|
||||
Store::remove_from_set(h, Comm::data("myset"), Comm::data("b"));
|
||||
Store::push_left(h, Comm::data("myvec"), dv(Comm::data("delta")));
|
||||
Store::push_right(h, Comm::data("myvec"), dv(Comm::data("omega")));
|
||||
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")));
|
||||
|
||||
when ( local res = Store::size(h) )
|
||||
when ( local res = BrokerStore::size(h) )
|
||||
{
|
||||
print "master size", res;
|
||||
event ready();
|
||||
|
@ -51,7 +51,7 @@ event Comm::outgoing_connection_established(peer_address: string,
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::connect("127.0.0.1", broker_port, 1secs);
|
||||
Comm::auto_event("bro/event/ready", ready);
|
||||
BrokerComm::enable();
|
||||
BrokerComm::connect("127.0.0.1", broker_port, 1secs);
|
||||
BrokerComm::auto_event("bro/event/ready", ready);
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ stores-listener.bro
|
|||
const broker_port: port &redef;
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global h: opaque of Store::Handle;
|
||||
global h: opaque of BrokerStore::Handle;
|
||||
global expected_key_count = 4;
|
||||
global key_count = 0;
|
||||
|
||||
function do_lookup(key: string)
|
||||
{
|
||||
when ( local res = Store::lookup(h, Comm::data(key)) )
|
||||
when ( local res = BrokerStore::lookup(h, BrokerComm::data(key)) )
|
||||
{
|
||||
++key_count;
|
||||
print "lookup", key, res;
|
||||
|
@ -25,15 +25,15 @@ function do_lookup(key: string)
|
|||
|
||||
event ready()
|
||||
{
|
||||
h = Store::create_clone("mystore");
|
||||
h = BrokerStore::create_clone("mystore");
|
||||
|
||||
when ( local res = Store::keys(h) )
|
||||
when ( local res = BrokerStore::keys(h) )
|
||||
{
|
||||
print "clone keys", res;
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 0)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 1)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 2)));
|
||||
do_lookup(Comm::refine_to_string(Comm::vector_lookup(res$result, 3)));
|
||||
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)));
|
||||
}
|
||||
timeout 10sec
|
||||
{ print "timeout"; }
|
||||
|
@ -41,7 +41,7 @@ event ready()
|
|||
|
||||
event bro_init()
|
||||
{
|
||||
Comm::enable();
|
||||
Comm::subscribe_to_events("bro/event/ready");
|
||||
Comm::listen(broker_port, "127.0.0.1");
|
||||
BrokerComm::enable();
|
||||
BrokerComm::subscribe_to_events("bro/event/ready");
|
||||
BrokerComm::listen(broker_port, "127.0.0.1");
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ export {
|
|||
|
||||
event bro_init() &priority=5
|
||||
{
|
||||
Comm::enable();
|
||||
BrokerComm::enable();
|
||||
Log::create_stream(Test::LOG, [$columns=Test::Info, $ev=log_test]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue