diff --git a/trie/trie.c b/trie/trie.c index bd47ced..e275698 100644 --- a/trie/trie.c +++ b/trie/trie.c @@ -1,13 +1,9 @@ #include "trie.h" -#define RULES_FILE "../data/routing-data" -#define TEST_FILE "../data/test-data" -#define TEST_ROWS 11 /*17217*/ #define READ_MODE "r" #define RULE_NOT_FOUND -1 #define GET_BIT(key, bit) ( ( key.s[ bit / 16 ] & (1u << (15 - bit % 16)) ) != 0 ) - trie_node_t create_node() { trie_node_t ret = calloc(1, sizeof(struct trie_node)); /* sets null childs and invalid */ return ret; @@ -57,8 +53,7 @@ int trie_insert(trie_holder_t t, ipv6_t key, int val, int mask) { iter->_rule_valid = VALID_RULE; iter->_rule = val; - - return 1; + return ++t->_size;; } int trie_search(trie_holder_t t, ipv6_t key) { @@ -81,12 +76,15 @@ int trie_search(trie_holder_t t, ipv6_t key) { - /*--------------------------------------------------------------------------------*/ /* TESTING */ /*--------------------------------------------------------------------------------*/ #include +#define RULES_FILE "../data/routing-data" +#define TEST_FILE "../data/test-data" +#define TEST_ROWS 5721 + int parse_line(ipv6_t* key, int* val, int* mask, FILE* f) { /*! assumes only good input */ memset(key, 0, sizeof(ipv6_t)); @@ -157,7 +155,7 @@ int fire_tests(trie_holder_t t, ipv6_t* ips, int* ref, int num_tests ) { for (row = 0; row < TEST_ROWS; ++ row) { if (trie_search(t, ips[row]) != ref[row]) { - printf("%d %d @ %d\n", trie_search(t, ips[row]), ref[row], row ); + printf("ref: %d got: %d @ %d\n", ref[row], trie_search(t, ips[row]), row ); ++wrong; } }