From 9aa8d1dc47adabc9ffbe29caf4d15db18e7115c9 Mon Sep 17 00:00:00 2001 From: Jan Maria Matejka Date: Tue, 17 Apr 2018 15:30:08 +0200 Subject: [PATCH] Flowspec formatting: removed excessive spaces --- filter/test.conf | 1 + lib/flowspec.c | 10 +++++----- lib/flowspec_test.c | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/filter/test.conf b/filter/test.conf index 989dab14..17926b69 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -558,6 +558,7 @@ prefix p; bt_assert(p !~ [ 10.0.0.0/8 ] ); bt_assert(format(flow4 { dst 10.0.0.0/8; proto = 23; }) = "flow4 { dst 10.0.0.0/8; proto 23; }"); + print(flow4 { dst 10.0.0.0/8; proto = 23; }); bt_assert(format(flow6 { dst ::1/128; src ::2/127; }) = "flow6 { dst ::1/128; src ::2/127; }"); bt_assert(format(flow6 { next header false 42; }) = "flow6 { next header false 42; }"); bt_assert(format(flow6 { port 80; }) = "flow6 { port 80; }"); diff --git a/lib/flowspec.c b/lib/flowspec.c index 387a2715..440f0616 100644 --- a/lib/flowspec.c +++ b/lib/flowspec.c @@ -966,13 +966,13 @@ net_format_flow_ip(buffer *b, const byte *part, int ipv6) { uint pxoffset = *(part+2); if (pxoffset) - buffer_print(b, "%I6/%u offset %u; ", flow_read_ip6(part+3,pxlen,pxoffset), pxlen, pxoffset); + buffer_print(b, "%I6/%u offset %u;", flow_read_ip6(part+3,pxlen,pxoffset), pxlen, pxoffset); else - buffer_print(b, "%I6/%u; ", flow_read_ip6(part+3,pxlen,0), pxlen); + buffer_print(b, "%I6/%u;", flow_read_ip6(part+3,pxlen,0), pxlen); } else { - buffer_print(b, "%I4/%u; ", flow_read_ip4(part+2,pxlen), pxlen); + buffer_print(b, "%I4/%u;", flow_read_ip4(part+2,pxlen), pxlen); } } @@ -1028,7 +1028,7 @@ net_format_flow_num(buffer *b, const byte *part) if (isset_end(op)) { - buffer_puts(b, "; "); + buffer_puts(b, ";"); break; } else @@ -1087,7 +1087,7 @@ net_format_flow_bitmask(buffer *b, const byte *part) if (isset_end(op)) { - buffer_puts(b, "; "); + buffer_puts(b, ";"); break; } else diff --git a/lib/flowspec_test.c b/lib/flowspec_test.c index dd71dc7b..02664985 100644 --- a/lib/flowspec_test.c +++ b/lib/flowspec_test.c @@ -584,7 +584,7 @@ t_formatting4(void) const char *expect = "flow4 { dst 10.0.0.0/8; proto 23; dport > 24 && < 30 || 40..50,60..70,80 && >= 90; sport > 24 && < 30 || 40,50,60..70,80; icmp type 80; icmp code 90; tcp flags 0x3/0x3,0x0/0xc; length 0..65535; dscp 63; fragment dont_fragment || !is_fragment; }"; - bt_assert(flow4_net_format(b, sizeof(b), input) == strlen(expect)); + bt_assert(flow4_net_format(b, sizeof(b), input, " ") == strlen(expect)); bt_debug(" expect: '%s',\n output: '%s'\n", expect, b); bt_assert(strcmp(b, expect) == 0); @@ -611,7 +611,7 @@ t_formatting6(void) const char *expect = "flow6 { dst ::1:1234:5678:9800:0/103 offset 61; src c000::/8; next header 6; port 20..40,273; label !0x0/0x12345678; }"; - bt_assert(flow6_net_format(b, sizeof(b), input) == strlen(expect)); + bt_assert(flow6_net_format(b, sizeof(b), input, " ") == strlen(expect)); bt_debug(" expect: '%s',\n output: '%s'\n", expect, b); bt_assert(strcmp(b, expect) == 0);