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)
else
ret = 0;
- printf("compare returns %d\n", ret);
-
return ret;
}
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);
}
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;
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;
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;
}
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);
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;
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;
}
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);
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;
obj = table_next(t, obj);
if (obj == NULL)
break;
- printf("Found \n");
ent = &tbl->ent[tbl->cnt];
ent->addr = obj->addr;
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);
{
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);