#include "address.c"
+static unsigned char db_imp_ski[] = {
+ 0x0e, 0xe9, 0x6a, 0x8e, 0x2f, 0xac, 0x50, 0xce, 0x6c, 0x5f,
+ 0x93, 0x3e, 0xde, 0x6a, 0xa7, 0x80, 0xa6, 0x85, 0x0e, 0x31 };
+
+static unsigned char db_imp_spk[] = {
+ 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce,
+ 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
+ 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xfa, 0xb9, 0x12,
+ 0x2d, 0x79, 0x4f, 0xa4, 0xbf, 0xe6, 0xf8, 0xbe, 0xc2, 0x7c,
+ 0x27, 0xca, 0xae, 0xfd, 0x45, 0x1e, 0xb3, 0x39, 0xe4, 0x5b,
+ 0x08, 0x73, 0xc7, 0xcc, 0x96, 0x78, 0xc7, 0x13, 0xa6, 0x39,
+ 0x9d, 0x3b, 0x82, 0x9f, 0x75, 0x20, 0x59, 0xf0, 0x95, 0xea,
+ 0xc6, 0x2e, 0x19, 0x46, 0x73, 0x3d, 0x9d, 0x04, 0xcb, 0xa0,
+ 0x2f, 0x7b, 0x39, 0x9f, 0x70, 0x42, 0xd4, 0x07, 0xce, 0xde,
+ 0x04 };
+
static int iteration = 0;
static void
handler->arg));
}
+static void
+add_rk(struct validation_handler *handler, uint32_t as)
+{
+ ck_assert_int_eq(0, handler->handle_router_key(db_imp_ski, as,
+ db_imp_spk, handler->arg));
+}
+
int
__handle_roa_v4(uint32_t as, struct ipv4_prefix const *prefix,
uint8_t max_length, void *arg)
case 0:
add_v4(&handler, 0);
add_v6(&handler, 0);
+ add_rk(&handler, 0);
break;
case 1:
add_v4(&handler, 0);
add_v6(&handler, 0);
+ add_rk(&handler, 0);
add_v4(&handler, 1);
add_v6(&handler, 1);
+ add_rk(&handler, 1);
break;
case 2:
add_v4(&handler, 1);
add_v6(&handler, 1);
+ add_rk(&handler, 1);
break;
case 3:
add_v4(&handler, 0);
add_v6(&handler, 0);
+ add_rk(&handler, 0);
break;
default:
ck_abort_msg("perform_standalone_validation() was called too many times (%d).",
* 1: IPv4, ASN 1
* 2: IPv6, ASN 0
* 3: IPv6, ASN 1
+ * 4: Router key, ASN 0
+ * 5: Router key, ASN 1
*/
-static const bool iteration0_base[] = { 1, 0, 1, 0, };
-static const bool iteration1_base[] = { 1, 1, 1, 1, };
-static const bool iteration2_base[] = { 0, 1, 0, 1, };
-static const bool iteration3_base[] = { 1, 0, 1, 0, };
+static const bool iteration0_base[] = { 1, 0, 1, 0, 1, 0, };
+static const bool iteration1_base[] = { 1, 1, 1, 1, 1, 1, };
+static const bool iteration2_base[] = { 0, 1, 0, 1, 0, 1, };
+static const bool iteration3_base[] = { 1, 0, 1, 0, 1, 0, };
/*
* DELTA
- * 0: Withdrawal, IPv4, ASN 0 4: Announcement, IPv4, ASN 0
- * 1: Withdrawal, IPv4, ASN 1 5: Announcement, IPv4, ASN 1
- * 2: Withdrawal, IPv6, ASN 0 6: Announcement, IPv6, ASN 0
- * 3: Withdrawal, IPv6, ASN 1 7: Announcement, IPv6, ASN 1
+ * 0: Withdrawal, IPv4, ASN 0 6: Announcement, IPv4, ASN 0
+ * 1: Withdrawal, IPv4, ASN 1 7: Announcement, IPv4, ASN 1
+ * 2: Withdrawal, IPv6, ASN 0 8: Announcement, IPv6, ASN 0
+ * 3: Withdrawal, IPv6, ASN 1 9: Announcement, IPv6, ASN 1
+ * 4: Withdrawal, RK, ASN 0 10: Announcement, RK, ASN 0
+ * 5: Withdrawal, RK, ASN 1 11: Announcement, RK, ASN 1
*/
-static const bool deltas_0to0[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_0to0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
-static const bool deltas_0to1[] = { 0, 0, 0, 0, 0, 1, 0, 1, };
-static const bool deltas_1to1[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_0to1[] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, };
+static const bool deltas_1to1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
-static const bool deltas_0to2[] = { 1, 0, 1, 0, 0, 1, 0, 1, };
-static const bool deltas_1to2[] = { 1, 0, 1, 0, 0, 0, 0, 0, };
-static const bool deltas_2to2[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_0to2[] = { 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, };
+static const bool deltas_1to2[] = { 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_2to2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
/* Deltas with rules that override each other */
-static const bool deltas_0to3_ovrd[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
-static const bool deltas_1to3_ovrd[] = { 1, 1, 1, 1, 1, 0, 1, 0, };
-static const bool deltas_2to3_ovrd[] = { 0, 1, 0, 1, 1, 0, 1, 0, };
-static const bool deltas_3to3_ovrd[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_0to3_ovrd[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
+static const bool deltas_1to3_ovrd[] = { 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, };
+static const bool deltas_2to3_ovrd[] = { 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, };
+static const bool deltas_3to3_ovrd[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
/* Deltas cleaned up */
-static const bool deltas_0to3_clean[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
-static const bool deltas_1to3_clean[] = { 0, 1, 0, 1, 0, 0, 0, 0, };
-static const bool deltas_2to3_clean[] = { 0, 1, 0, 1, 1, 0, 1, 0, };
-static const bool deltas_3to3_clean[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_0to3_clean[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_1to3_clean[] = { 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, };
+static const bool deltas_2to3_clean[] = { 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, };
+static const bool deltas_3to3_clean[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
/* Impersonator functions */
}
static array_index
-get_delta_index(struct delta_vrp const *delta)
+get_rk_index(struct router_key const *rk)
+{
+ array_index i;
+
+ for (i = 0; i < RK_SKI_LEN; i++)
+ ck_assert_uint_eq(rk->ski[i], db_imp_ski[i]);
+
+ ck_assert_msg(rk->as <= 1, "Unexpected AS number: %u", rk->as);
+
+ for (i = 0; i < RK_SPKI_LEN; i++)
+ ck_assert_uint_eq(rk->spk[i], db_imp_spk[i]);
+
+ return rk->as + 4;
+}
+
+static array_index
+get_delta_vrp_index(struct delta_vrp const *delta)
{
array_index result;
result = get_vrp_index(&delta->vrp);
- ck_assert_msg(delta->flags <= 1, "Unexpected flags: %u", delta->flags);
+ ck_assert_msg(delta->flags <= 1, "VRP Unexpected flags: %u",
+ delta->flags);
+
+ return result + (delta->flags ? 6 : 0);
+}
+
+static array_index
+get_delta_rk_index(struct delta_router_key const *delta)
+{
+ array_index result;
+
+ result = get_rk_index(&delta->router_key);
+ ck_assert_msg(delta->flags <= 1, "RK Unexpected flags: %u",
+ delta->flags);
- return (delta->flags << 2) | result;
+ return result + (delta->flags ? 6 : 0);
}
static int
static int
rk_check(struct router_key const *rk, void *arg)
{
- /* FIXME (now) add index with Router key examples */
+ bool *array = arg;
+ array_index index;
+
+ index = get_rk_index(rk);
+ ck_assert_uint_eq(false, array[index]);
+ array[index] = true;
+
return 0;
}
static int
-delta_check(struct delta_vrp const *delta, void *arg)
+delta_vrp_check(struct delta_vrp const *delta, void *arg)
{
bool *array = arg;
array_index index;
- index = get_delta_index(delta);
+ index = get_delta_vrp_index(delta);
ck_assert_uint_eq(false, array[index]);
array[index] = true;
static int
delta_rk_check(struct delta_router_key const *delta, void *arg)
{
- /* FIXME (now) add index with Router key examples */
+ bool *array = arg;
+ array_index index;
+
+ index = get_delta_rk_index(delta);
+ ck_assert_uint_eq(false, array[index]);
+ array[index] = true;
+
return 0;
}
check_base(serial_t expected_serial, bool const *expected_base)
{
serial_t actual_serial;
- bool actual_base[4];
+ bool actual_base[6];
array_index i;
memset(actual_base, 0, sizeof(actual_base));
bool filter)
{
serial_t actual_serial;
- bool actual_deltas[8];
+ bool actual_deltas[12];
struct deltas_db deltas;
struct delta_group *group;
array_index i;
memset(actual_deltas, 0, sizeof(actual_deltas));
ARRAYLIST_FOREACH(&deltas, group, i)
ck_assert_int_eq(0, deltas_foreach(group->serial, group->deltas,
- delta_check, delta_rk_check, actual_deltas));
+ delta_vrp_check, delta_rk_check, actual_deltas));
for (i = 0; i < ARRAY_LEN(actual_deltas); i++)
ck_assert_uint_eq(expected_deltas[i], actual_deltas[i]);
}
struct deltas_db deltas;
serial_t serial;
bool changed;
- bool iterated_entries[8];
+ bool iterated_entries[12];
create_deltas_0to1(&deltas, &serial, &changed, iterated_entries);
struct deltas_db deltas;
serial_t serial;
bool changed;
- bool iterated_entries[8];
+ bool iterated_entries[12];
create_deltas_0to1(&deltas, &serial, &changed, iterated_entries);
struct deltas_db deltas;
serial_t serial;
bool changed;
- bool iterated_entries[8];
+ bool iterated_entries[12];
create_deltas_0to1(&deltas, &serial, &changed, iterated_entries);
{
request->pdu = query;
request->bytes_len = 0;
- query->header.protocol_version = RTR_V0;
+ query->header.protocol_version = RTR_V1;
query->header.pdu_type = PDU_TYPE_RESET_QUERY;
query->header.m.reserved = 0;
query->header.length = 8;
{
request->pdu = query;
request->bytes_len = 0;
- query->header.protocol_version = RTR_V0;
+ query->header.protocol_version = RTR_V1;
query->header.pdu_type = PDU_TYPE_SERIAL_QUERY;
- query->header.m.session_id = get_current_session_id(RTR_V0);
+ query->header.m.session_id = get_current_session_id(RTR_V1);
query->header.length = 12;
query->serial_number = serial;
}
clients_get_rtr_version_set(int fd, bool *is_set, uint8_t *rtr_version)
{
(*is_set) = true;
- (*rtr_version) = RTR_V0;
+ (*rtr_version) = RTR_V1;
return 0;
}
handle_delta(struct delta_vrp const *delta, void *arg)
{
int *fd = arg;
- ck_assert_int_eq(0, send_prefix_pdu(*fd, RTR_V0, &delta->vrp,
+ ck_assert_int_eq(0, send_prefix_pdu(*fd, RTR_V1, &delta->vrp,
delta->flags));
return 0;
}
handle_delta_router_key(struct delta_router_key const *delta, void *arg)
{
int *fd = arg;
- ck_assert_int_eq(0, send_router_key_pdu(*fd, RTR_V0, &delta->router_key,
+ ck_assert_int_eq(0, send_router_key_pdu(*fd, RTR_V1, &delta->router_key,
delta->flags));
return 0;
}
/* Tests */
-/* https://tools.ietf.org/html/rfc6810#section-6.1 */
+/* https://tools.ietf.org/html/rfc8210#section-8.1 */
START_TEST(test_start_or_restart)
{
struct rtr_request request;
expected_pdu_add(PDU_TYPE_CACHE_RESPONSE);
expected_pdu_add(PDU_TYPE_IPV4_PREFIX);
expected_pdu_add(PDU_TYPE_IPV6_PREFIX);
+ expected_pdu_add(PDU_TYPE_ROUTER_KEY);
expected_pdu_add(PDU_TYPE_END_OF_DATA);
/* Run and validate */
}
END_TEST
-/* https://tools.ietf.org/html/rfc6810#section-6.2 */
+/* https://tools.ietf.org/html/rfc8210#section-8.2 */
START_TEST(test_typical_exchange)
{
struct rtr_request request;
expected_pdu_add(PDU_TYPE_CACHE_RESPONSE);
expected_pdu_add(PDU_TYPE_IPV4_PREFIX);
expected_pdu_add(PDU_TYPE_IPV6_PREFIX);
+ expected_pdu_add(PDU_TYPE_ROUTER_KEY);
expected_pdu_add(PDU_TYPE_IPV4_PREFIX);
expected_pdu_add(PDU_TYPE_IPV6_PREFIX);
+ expected_pdu_add(PDU_TYPE_ROUTER_KEY);
expected_pdu_add(PDU_TYPE_END_OF_DATA);
/* From serial 0: Run and validate */
expected_pdu_add(PDU_TYPE_CACHE_RESPONSE);
expected_pdu_add(PDU_TYPE_IPV4_PREFIX);
expected_pdu_add(PDU_TYPE_IPV6_PREFIX);
+ expected_pdu_add(PDU_TYPE_ROUTER_KEY);
expected_pdu_add(PDU_TYPE_END_OF_DATA);
/* From serial 1: Run and validate */
}
END_TEST
-/* https://tools.ietf.org/html/rfc6810#section-6.3 */
+/* https://tools.ietf.org/html/rfc8210#section-8.3 */
START_TEST(test_no_incremental_update_available)
{
struct rtr_request request;
}
END_TEST
-/* https://tools.ietf.org/html/rfc6810#section-6.4 */
+/* https://tools.ietf.org/html/rfc8210#section-8.4 */
START_TEST(test_cache_has_no_data_available)
{
struct rtr_request request;
Suite *suite;
TCase *core, *error;
- core = tcase_create("RFC6810-Defined Protocol Sequences");
+ core = tcase_create("RFC8210-Defined Protocol Sequences");
tcase_add_test(core, test_start_or_restart);
tcase_add_test(core, test_typical_exchange);
tcase_add_test(core, test_no_incremental_update_available);