summaryrefslogtreecommitdiff
path: root/lib/flowspec.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-12-09 04:23:01 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-12-09 04:23:01 +0100
commitff2ca10cba9c5a3be690ec1a77a068e23395ef20 (patch)
treecd6b3d8f0a1b825755d5731e02925618725a0867 /lib/flowspec.c
parent21d09632a524c0d2a7f44a51f877370ad07b983c (diff)
Filter: Add support for src/dst accessors for Flowspec and SADR
Diffstat (limited to 'lib/flowspec.c')
-rw-r--r--lib/flowspec.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/flowspec.c b/lib/flowspec.c
index e9290b88..ef19aa96 100644
--- a/lib/flowspec.c
+++ b/lib/flowspec.c
@@ -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
*/