summaryrefslogtreecommitdiff
path: root/lib/flowspec.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-05-23 13:12:25 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-05-23 13:12:25 +0200
commit734e9fb8a933898cd3396786c06728bce6a754e5 (patch)
tree610ffaa2286fc604be4b2f1c30a983f0076b1da8 /lib/flowspec.c
parentbb7aa06a48f52813a019861a0e06ce9fe4d20c4b (diff)
Minor cleanups and fixes
Diffstat (limited to 'lib/flowspec.c')
-rw-r--r--lib/flowspec.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/lib/flowspec.c b/lib/flowspec.c
index 3fa6bac4..87ce0206 100644
--- a/lib/flowspec.c
+++ b/lib/flowspec.c
@@ -754,7 +754,7 @@ flow_builder_add_val_mask(struct flow_builder *fb, byte op, u32 value, u32 mask)
if (a)
{
flow_builder_add_op_val(fb, op ^ 0x01, a);
- op |= 0x40;
+ op |= FLOW_OP_AND;
}
if (b)
@@ -897,28 +897,20 @@ flow_builder_clear(struct flow_builder *fb)
*/
/* Flowspec operators for [op, value]+ pairs */
-#define FLOW_TRUE 0b000
-#define FLOW_EQ 0b001
-#define FLOW_GT 0b010
-#define FLOW_GTE 0b011
-#define FLOW_LT 0b100
-#define FLOW_LTE 0b101
-#define FLOW_NEQ 0b110
-#define FLOW_FALSE 0b111
static const char *
num_op_str(const byte *op)
{
switch (*op & 0x07)
{
- case FLOW_TRUE: return "true";
- case FLOW_EQ: return "=";
- case FLOW_GT: return ">";
- case FLOW_GTE: return ">=";
- case FLOW_LT: return "<";
- case FLOW_LTE: return "<=";
- case FLOW_NEQ: return "!=";
- case FLOW_FALSE: return "false";
+ case FLOW_OP_TRUE: return "true";
+ case FLOW_OP_EQ: return "=";
+ case FLOW_OP_GT: return ">";
+ case FLOW_OP_GEQ: return ">=";
+ case FLOW_OP_LT: return "<";
+ case FLOW_OP_LEQ: return "<=";
+ case FLOW_OP_NEQ: return "!=";
+ case FLOW_OP_FALSE: return "false";
}
return NULL;
@@ -985,8 +977,8 @@ net_format_flow_num(buffer *b, const byte *part)
{
/* XXX: I don't like this so complicated if-tree */
if (!isset_and(op) &&
- ((num_op( op) == FLOW_EQ) || (num_op( op) == FLOW_GTE)) &&
- ((num_op(last_op) == FLOW_EQ) || (num_op(last_op) == FLOW_LTE)))
+ ((num_op( op) == FLOW_OP_EQ) || (num_op( op) == FLOW_OP_GEQ)) &&
+ ((num_op(last_op) == FLOW_OP_EQ) || (num_op(last_op) == FLOW_OP_LEQ)))
{
b->pos--; /* Remove last char (it is a space) */
buffer_puts(b, ",");
@@ -1002,7 +994,7 @@ net_format_flow_num(buffer *b, const byte *part)
val = get_value(op+1, len);
if (!isset_end(op) && !isset_and(op) && isset_and(op+1+len) &&
- (num_op(op) == FLOW_GTE) && (num_op(op+1+len) == FLOW_LTE))
+ (num_op(op) == FLOW_OP_GEQ) && (num_op(op+1+len) == FLOW_OP_LEQ))
{
/* Display interval */
buffer_print(b, "%u..", val);
@@ -1011,7 +1003,7 @@ net_format_flow_num(buffer *b, const byte *part)
val = get_value(op+1, len);
buffer_print(b, "%u", val);
}
- else if (num_op(op) == FLOW_EQ)
+ else if (num_op(op) == FLOW_OP_EQ)
{
buffer_print(b, "%u", val);
}