Lines Matching defs:ni

104 static uint32_t objhash_hash_name(struct namedobj_instance *ni,
106 static uint32_t objhash_hash_idx(struct namedobj_instance *ni, uint32_t val);
169 static int export_objhash_ntlv(struct namedobj_instance *ni, uint16_t kidx,
902 swap_sets_cb(struct namedobj_instance *ni, struct named_object *no,
916 move_sets_cb(struct namedobj_instance *ni, struct named_object *no,
928 test_sets_cb(struct namedobj_instance *ni, struct named_object *no,
936 if (ipfw_objhash_lookup_name_type(ni, args->new_set,
946 ipfw_obj_manage_sets(struct namedobj_instance *ni, uint16_t type,
956 return (ipfw_objhash_foreach_type(ni, swap_sets_cb,
959 return (ipfw_objhash_foreach_type(ni, test_sets_cb,
962 return (ipfw_objhash_foreach_type(ni, move_sets_cb,
970 no = ipfw_objhash_lookup_kidx(ni, set);
978 no = ipfw_objhash_lookup_kidx(ni, set);
990 if (ipfw_objhash_lookup_name_type(ni, new_set, type,
996 no = ipfw_objhash_lookup_kidx(ni, set);
2251 * Export named object info in instance @ni, identified by @kidx
2257 export_objhash_ntlv(struct namedobj_instance *ni, uint16_t kidx,
2263 no = ipfw_objhash_lookup_kidx(ni, kidx);
2275 export_named_objects(struct namedobj_instance *ni, struct dump_args *da,
2283 if ((error = export_objhash_ntlv(ni, i, sd)) != 0)
3351 export_objhash_ntlv_internal(struct namedobj_instance *ni,
4284 ipfw_objhash_bitmap_merge(struct namedobj_instance *ni, void **idx, int *blocks)
4290 old_idx = ni->idx_mask;
4291 old_blocks = ni->max_blocks;
4302 * Swaps current @ni index with new one.
4305 ipfw_objhash_bitmap_swap(struct namedobj_instance *ni, void **idx, int *blocks)
4310 old_idx = ni->idx_mask;
4311 old_blocks = ni->max_blocks;
4313 ni->idx_mask = *idx;
4314 ni->max_blocks = *blocks;
4336 struct namedobj_instance *ni;
4344 ni = malloc(size, M_IPFW, M_WAITOK | M_ZERO);
4345 ni->nn_size = NAMEDOBJ_HASH_SIZE;
4346 ni->nv_size = NAMEDOBJ_HASH_SIZE;
4348 ni->names = (struct namedobjects_head *)(ni +1);
4349 ni->values = &ni->names[ni->nn_size];
4351 for (i = 0; i < ni->nn_size; i++)
4352 TAILQ_INIT(&ni->names[i]);
4354 for (i = 0; i < ni->nv_size; i++)
4355 TAILQ_INIT(&ni->values[i]);
4358 ni->hash_f = objhash_hash_name;
4359 ni->cmp_f = objhash_cmp_name;
4362 ipfw_objhash_bitmap_alloc(items, (void*)&ni->idx_mask, &ni->max_blocks);
4364 return (ni);
4368 ipfw_objhash_destroy(struct namedobj_instance *ni)
4371 free(ni->idx_mask, M_IPFW);
4372 free(ni, M_IPFW);
4376 ipfw_objhash_set_funcs(struct namedobj_instance *ni, objhash_hash_f *hash_f,
4380 ni->hash_f = hash_f;
4381 ni->cmp_f = cmp_f;
4385 objhash_hash_name(struct namedobj_instance *ni, const void *name, uint32_t set)
4402 objhash_hash_idx(struct namedobj_instance *ni, uint32_t val)
4406 v = val % (ni->nv_size - 1);
4412 ipfw_objhash_lookup_name(struct namedobj_instance *ni, uint32_t set, char *name)
4417 hash = ni->hash_f(ni, name, set) % ni->nn_size;
4419 TAILQ_FOREACH(no, &ni->names[hash], nn_next) {
4420 if (ni->cmp_f(no, name, set) == 0)
4479 ipfw_objhash_find_type(struct namedobj_instance *ni, struct tid_info *ti,
4500 *pno = ipfw_objhash_lookup_name(ni, set, name);
4510 ipfw_objhash_lookup_name_type(struct namedobj_instance *ni, uint32_t set,
4516 hash = ni->hash_f(ni, name, set) % ni->nn_size;
4518 TAILQ_FOREACH(no, &ni->names[hash], nn_next) {
4519 if (ni->cmp_f(no, name, set) == 0 &&
4528 ipfw_objhash_lookup_kidx(struct namedobj_instance *ni, uint16_t kidx)
4533 hash = objhash_hash_idx(ni, kidx);
4535 TAILQ_FOREACH(no, &ni->values[hash], nv_next) {
4544 ipfw_objhash_same_name(struct namedobj_instance *ni, struct named_object *a,
4555 ipfw_objhash_add(struct namedobj_instance *ni, struct named_object *no)
4559 hash = ni->hash_f(ni, no->name, no->set) % ni->nn_size;
4560 TAILQ_INSERT_HEAD(&ni->names[hash], no, nn_next);
4562 hash = objhash_hash_idx(ni, no->kidx);
4563 TAILQ_INSERT_HEAD(&ni->values[hash], no, nv_next);
4565 ni->count++;
4569 ipfw_objhash_del(struct namedobj_instance *ni, struct named_object *no)
4573 hash = ni->hash_f(ni, no->name, no->set) % ni->nn_size;
4574 TAILQ_REMOVE(&ni->names[hash], no, nn_next);
4576 hash = objhash_hash_idx(ni, no->kidx);
4577 TAILQ_REMOVE(&ni->values[hash], no, nv_next);
4579 ni->count--;
4583 ipfw_objhash_count(struct namedobj_instance *ni)
4586 return (ni->count);
4590 ipfw_objhash_count_type(struct namedobj_instance *ni, uint16_t type)
4597 for (i = 0; i < ni->nn_size; i++) {
4598 TAILQ_FOREACH(no, &ni->names[i], nn_next) {
4611 ipfw_objhash_foreach(struct namedobj_instance *ni, objhash_cb_t *f, void *arg)
4616 for (i = 0; i < ni->nn_size; i++) {
4617 TAILQ_FOREACH_SAFE(no, &ni->names[i], nn_next, no_tmp) {
4618 ret = f(ni, no, arg);
4631 ipfw_objhash_foreach_type(struct namedobj_instance *ni, objhash_cb_t *f,
4637 for (i = 0; i < ni->nn_size; i++) {
4638 TAILQ_FOREACH_SAFE(no, &ni->names[i], nn_next, no_tmp) {
4641 ret = f(ni, no, arg);
4654 ipfw_objhash_free_idx(struct namedobj_instance *ni, uint16_t idx)
4662 if (i >= ni->max_blocks)
4665 mask = &ni->idx_mask[i];
4674 if (ni->free_off[0] > i)
4675 ni->free_off[0] = i;
4687 struct namedobj_instance *ni;
4691 ni = (struct namedobj_instance *)n;
4693 off = ni->free_off[0];
4694 mask = &ni->idx_mask[off];
4696 for (i = off; i < ni->max_blocks; i++, mask++) {
4703 ni->free_off[0] = i;