Work on the radix code, added support to compile on OpenWRT,
[ipfw.git] / dummynet / new_glue.c
index ce0a5a3..5ceef79 100644 (file)
@@ -35,19 +35,17 @@ static uint32_t
 simple_hash32(const void *key, uint32_t size)
 {
        uint32_t ret = *(const uint32_t *)key % size;
-       printf("%s called\n", __FUNCTION__);
-       printf("Hash returns %d\n", ret);
 
        return ret;
 }
 
 static int
-cmp_func32(const void *key1, const void *key2)
+cmp_func32(const void *key1, const void *key2, int sz)
 {
        int k1 = *(const int *)key1;
        int k2 = *(const int *)key2;
        int ret;
-       printf("(%s) k1=%d, k2=%d\n", __FUNCTION__, k1, k2);
+
        if (k1 < k2)
                ret = -1;
        else if (k1 > k2)
@@ -55,8 +53,6 @@ cmp_func32(const void *key1, const void *key2)
        else
                ret = 0;
 
-       printf("compare returns %d\n", ret);
-
        return ret;
 }
 
@@ -77,11 +73,9 @@ add_table_entry(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
        int size = 128;
        int obj_size = sizeof(struct t_o);
 
-       printf("%s called\n", __FUNCTION__);
        if (i < 0 || i > size-1) /* wrong table number */
                return 1;
        if (ch->global_tables[i] == NULL) {
-               printf("Creating table n %d\n", tbl);
                ch->global_tables[i] = new_table_init(size, obj_size,
                                simple_hash32, cmp_func32, M_IPFW_HTBL);
        }
@@ -101,8 +95,6 @@ new_del_table_entry(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr)
        int ret;
        int nr = tbl - IPFW_TABLES_MAX;
 
-       printf("%s called\n", __FUNCTION__);
-
        ret = new_table_delete_obj(ch->global_tables[nr], &addr);
 
        return ret;
@@ -112,7 +104,6 @@ int
 del_table_entry(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
     uint8_t mlen)
 {
-       printf("%s called\n", __FUNCTION__);
        if (tbl >= IPFW_TABLES_MAX && tbl < IPFW_NEWTABLES_MAX) {
                new_del_table_entry(ch, tbl, addr);
                return 0;
@@ -123,7 +114,6 @@ del_table_entry(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
 int
 new_flush_table(struct ip_fw_chain *ch, uint16_t tbl)
 {
-       printf("%s called\n", __FUNCTION__);
        new_table_destroy(ch->global_tables[tbl - IPFW_TABLES_MAX]);
        return 0;
 }
@@ -131,7 +121,6 @@ new_flush_table(struct ip_fw_chain *ch, uint16_t tbl)
 int
 flush_table(struct ip_fw_chain *ch, uint16_t tbl)
 {
-       printf("%s called\n", __FUNCTION__);
        if (tbl >= IPFW_TABLES_MAX && tbl < IPFW_NEWTABLES_MAX)
                return new_flush_table(ch, tbl);
        
@@ -142,20 +131,17 @@ int
 lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
     uint32_t *val)
 {
-       printf("%s called\n", __FUNCTION__);
        if (tbl >= IPFW_TABLES_MAX && tbl < IPFW_NEWTABLES_MAX) {
                struct new_hash_table *h;
                const struct t_o *obj;
 
                h = ch->global_tables[tbl - IPFW_TABLES_MAX];
-               printf("Search %d in table number %d\n", addr, tbl);
 
                obj = new_table_extract_obj(h, (void *)&addr);
                if (obj == NULL)
                        return 0; /* no match */
 
                *val = obj->value;
-               printf("obj->addr=%d,obj->value=%d\n",obj->addr, obj->value);
                return 1; /* match */
        }
        return 0;
@@ -164,7 +150,6 @@ lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
 int
 new_count_table_entry(struct ip_fw_chain *ch, uint32_t tbl, uint32_t *cnt)
 {
-       printf("%s called\n", __FUNCTION__);
        *cnt = new_table_get_element(ch->global_tables[tbl - IPFW_TABLES_MAX]);
        return 0;
 }
@@ -172,7 +157,6 @@ new_count_table_entry(struct ip_fw_chain *ch, uint32_t tbl, uint32_t *cnt)
 int
 count_table(struct ip_fw_chain *ch, uint32_t tbl, uint32_t *cnt)
 {
-       printf("%s called\n", __FUNCTION__);
        if (tbl >= IPFW_TABLES_MAX && tbl < IPFW_NEWTABLES_MAX) {
                new_count_table_entry(ch, tbl, cnt);
                return (0);
@@ -191,8 +175,6 @@ new_dump_table_entry(struct ip_fw_chain *ch, ipfw_table *tbl)
        int nr = tbl->tbl - IPFW_TABLES_MAX;
        struct new_hash_table *t = ch->global_tables[nr];
 
-       printf("%s called\n", __FUNCTION__);
-
        i = 0;
        tbl->cnt = 0;
 
@@ -203,7 +185,6 @@ new_dump_table_entry(struct ip_fw_chain *ch, ipfw_table *tbl)
                obj = table_next(t, obj);
                if (obj == NULL)
                        break;
-               printf("Found \n");
                ent = &tbl->ent[tbl->cnt];
 
                ent->addr = obj->addr;
@@ -211,14 +192,12 @@ new_dump_table_entry(struct ip_fw_chain *ch, ipfw_table *tbl)
                ent->masklen = obj->mask;
                tbl->cnt++;
        }
-       printf("\n");
        return 0;
 }
 
 int
 dump_table(struct ip_fw_chain *ch, ipfw_table *tbl)
 {
-       printf("%s called\n", __FUNCTION__);
        if (tbl->tbl >= IPFW_TABLES_MAX && tbl->tbl < IPFW_NEWTABLES_MAX) {
                new_dump_table_entry(ch, tbl);
                return (0);
@@ -231,7 +210,6 @@ init_tables(struct ip_fw_chain *ch)
 {
 
        int i;
-       printf("%s called\n", __FUNCTION__);
        /* Initialize new tables XXXMPD */
        for (i = 0; i < IPFW_NEWTABLES_MAX - IPFW_TABLES_MAX; i++) {
                memset(&ch->global_tables[i], sizeof(struct new_hash_table*), 0);