Commit a8b22f15 authored by Mark Karpilovskij's avatar Mark Karpilovskij Committed by Daniel Salzman

tests/rrl: check endian-independent hash input

parent 5249cde5
......@@ -21,6 +21,7 @@
#include "libknot/libknot.h"
#include "contrib/sockaddr.h"
#include "knot/modules/rrl/functions.c"
#include "stdio.h"
/* Enable time-dependent tests. */
//#define ENABLE_TIMED_TESTS
......@@ -125,7 +126,7 @@ int main(int argc, char *argv[])
rrl_table_t *rrl = rrl_create(RRL_SIZE, rate);
ok(rrl != NULL, "rrl: create");
/* 4. N unlimited requests. */
/* 2. N unlimited requests. */
knot_dname_t *zone = knot_dname_from_str_alloc("rrl.");
struct sockaddr_storage addr;
......@@ -142,6 +143,16 @@ int main(int argc, char *argv[])
}
is_int(0, ret, "rrl: unlimited IPv4/v6 requests");
/* 3. Endian-independent hash input buffer. */
uint8_t buf[RRL_CLSBLK_MAXLEN];
// CLS_LARGE + remote + dname wire length + dname wire.
uint8_t expectedv4[] = "\x10\x01\x02\x03\x00\x00\x00\x00\x00\x06\x00\x04""beef";
rrl_classify(buf, sizeof(buf), &addr, &rq, qname);
is_int(0, memcmp(buf, expectedv4, sizeof(expectedv4)), "rrl: IPv4 hash input buffer");
uint8_t expectedv6[] = "\x10\x11\x22\x33\x44\x55\x66\x77\x00\x06\x00\x04""beef";
rrl_classify(buf, sizeof(buf), &addr6, &rq, qname);
is_int(0, memcmp(buf, expectedv6, sizeof(expectedv6)), "rrl: IPv6 hash input buffer");
#ifdef ENABLE_TIMED_TESTS
/* 5. limited request */
ret = rrl_query(rrl, &addr, &rq, zone, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment