mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Change routing0_data_to_addrs BIF to return vector of addresses.
Because the order of addresses in type 0 routing headers is interesting/important.
This commit is contained in:
parent
d889f14638
commit
0ceca706f6
3 changed files with 14 additions and 13 deletions
|
@ -46,6 +46,13 @@ type index_vec: vector of count;
|
|||
## then remove this alias.
|
||||
type string_vec: vector of string;
|
||||
|
||||
## A vector of addresses.
|
||||
##
|
||||
## .. todo:: We need this type definition only for declaring builtin functions via
|
||||
## ``bifcl``. We should extend ``bifcl`` to understand composite types directly and
|
||||
## then remove this alias.
|
||||
type addr_vec: vector of addr;
|
||||
|
||||
## A table of strings indexed by strings.
|
||||
##
|
||||
## .. todo:: We need this type definition only for declaring builtin functions via
|
||||
|
|
15
src/bro.bif
15
src/bro.bif
|
@ -2050,18 +2050,15 @@ function is_v6_addr%(a: addr%): bool
|
|||
# ===========================================================================
|
||||
|
||||
## Converts the *data* field of :bro:type:`ip6_routing` records that have
|
||||
## *rtype* of 0 into a set of addresses.
|
||||
## *rtype* of 0 into a vector of addresses.
|
||||
##
|
||||
## s: The *data* field of an :bro:type:`ip6_routing` record that has
|
||||
## an *rtype* of 0.
|
||||
##
|
||||
## Returns: The set of addresses contained in the routing header data.
|
||||
function routing0_data_to_addrs%(s: string%): addr_set
|
||||
## Returns: The vector of addresses contained in the routing header data.
|
||||
function routing0_data_to_addrs%(s: string%): addr_vec
|
||||
%{
|
||||
BroType* index_type = base_type(TYPE_ADDR);
|
||||
TypeList* set_index = new TypeList(index_type);
|
||||
set_index->Append(index_type);
|
||||
TableVal* tv = new TableVal(new SetType(set_index, 0));
|
||||
VectorVal* rval = new VectorVal(new VectorType(base_type(TYPE_ADDR)));
|
||||
|
||||
int len = s->Len();
|
||||
const u_char* bytes = s->Bytes();
|
||||
|
@ -2074,12 +2071,12 @@ function routing0_data_to_addrs%(s: string%): addr_set
|
|||
while ( len > 0 )
|
||||
{
|
||||
IPAddr a(IPAddr::IPv6, (const uint32*) bytes, IPAddr::Network);
|
||||
tv->Assign(new AddrVal(a), 0);
|
||||
rval->Assign(rval->Size(), new AddrVal(a), 0);
|
||||
bytes += 16;
|
||||
len -= 16;
|
||||
}
|
||||
|
||||
return tv;
|
||||
return rval;
|
||||
%}
|
||||
|
||||
## Converts a :bro:type:`addr` to a :bro:type:`index_vec`.
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
{
|
||||
2001:78:1:32::1,
|
||||
2001:78:1:32::2
|
||||
}
|
||||
[2001:78:1:32::1, 2001:78:1:32::2]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue