1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Filter: Add support for src/dst accessors for Flowspec and SADR

This commit is contained in:
Ondrej Zajicek (work)
2019-12-09 04:23:01 +01:00
parent 21d09632a5
commit ff2ca10cba
7 changed files with 104 additions and 12 deletions

View File

@@ -243,12 +243,37 @@ flow6_next_part(const byte *pos, const byte *end)
return flow_next_part(pos, end, 1);
}
static const byte *
flow_get_part(const byte *data, uint dlen, uint type, int ipv6)
{
const byte *part;
for (part = flow_first_part(data);
part && (part[0] <= type);
part = flow_next_part(part, data+dlen, ipv6))
if (part[0] == type)
return part;
return NULL;
}
const byte *
flow4_get_part(const net_addr_flow4 *f, uint type)
{
return flow_get_part(f->data, f->length - sizeof(net_addr_flow4), type, 0);
}
const byte *
flow6_get_part(const net_addr_flow6 *f, uint type)
{
return flow_get_part(f->data, f->length - sizeof(net_addr_flow6), type, 1);
}
/*
* Flowspec accessors
*/
static inline ip4_addr
flow_read_ip4(const byte *px, uint pxlen)
{
@@ -282,7 +307,6 @@ flow_read_ip6_part(const byte *part)
}
/*
* Flowspec validation
*/

View File

@@ -83,6 +83,8 @@ const byte *flow4_first_part(const net_addr_flow4 *f);
const byte *flow6_first_part(const net_addr_flow6 *f);
const byte *flow4_next_part(const byte *pos, const byte *end);
const byte *flow6_next_part(const byte *pos, const byte *end);
const byte *flow4_get_part(const net_addr_flow4 *f, uint type);
const byte *flow6_get_part(const net_addr_flow6 *f, uint type);
/*
@@ -91,6 +93,7 @@ const byte *flow6_next_part(const byte *pos, const byte *end);
ip4_addr flow_read_ip4_part(const byte *part);
ip6_addr flow_read_ip6_part(const byte *part);
static inline int flow_read_pxlen(const byte *part) { return part[1]; }
/*