Home | History | Annotate | Download | only in libiptc

Lines Matching refs:handle

337 			    unsigned int *idx, struct xtc_handle *handle,
344 list_pos=&handle->chains;
347 if (handle->chain_index_sz == 0) {
348 debug("WARNING: handle->chain_index_sz == 0\n");
353 end = handle->chain_index_sz;
361 if (!handle->chain_index[pos]) {
363 return &handle->chains; /* Be safe, return orig start pos */
367 pos, handle->chain_index[pos]->name);
372 res = strcmp(name, handle->chain_index[pos]->name);
376 handle->chain_index[pos]->head_offset,
377 handle->chain_index[pos]->foot_offset);
378 res = offset - handle->chain_index[pos]->head_offset;
389 list_pos = &handle->chain_index[pos]->list;
409 if (pos == handle->chain_index_sz-1) {
417 res = strcmp(name, handle->chain_index[pos+1]->name);
420 res = offset - handle->chain_index[pos+1]->head_offset;
440 struct xtc_handle *handle)
442 return __iptcc_bsearch_chain_index(name, 0, idx, handle, BSEARCH_NAME);
449 struct xtc_handle *handle)
456 if (!handle->sorted_offsets)
457 pos = handle->chains.next;
459 pos = __iptcc_bsearch_chain_index(NULL, offset, idx, handle,
469 iptcc_linearly_search_chain_index(const char *name, struct xtc_handle *handle)
475 list_pos = &handle->chains;
477 if (handle->chain_index_sz)
478 list_pos = &handle->chain_index[0]->list;
482 for (i=0; i < handle->chain_index_sz; i++) {
483 if (handle->chain_index[i]) {
484 res = strcmp(handle->chain_index[i]->name, name);
487 list_pos = &handle->chain_index[i]->list;
689 iptcc_find_chain_by_offset(struct xtc_handle *handle, unsigned int offset)
695 if (list_empty(&handle->chains))
699 list_start_pos = iptcc_bsearch_chain_offset(offset, &i, handle);
706 // list_for_each(pos, &handle->chains) {
721 iptcc_find_label(const char *name, struct xtc_handle *handle)
728 if (list_empty(&handle->chains))
732 list_for_each(pos, &handle->chains) {
741 //list_start_pos = iptcc_linearly_search_chain_index(name, handle);
742 list_start_pos = iptcc_bsearch_chain_index(name, &i, handle);
745 if (list_start_pos == &handle->chains) {
753 test_pos = iptcc_linearly_search_chain_index(name, handle);
768 if (handle->num_chains == 0)
786 if (pos == &handle->chains) {
861 /* Handle the case, where chain.name is smaller than index[0] */
1121 /* handle jumps */
1278 /* Allocate handle of given size */
1414 static int dump_entry(STRUCT_ENTRY *e, struct xtc_handle *const handle);
1417 TC_DUMP_ENTRIES(struct xtc_handle *const handle)
1420 CHECK(handle);
1423 XTABLES_VERSION, handle->entries->size);
1424 printf("Table `%s'\n", handle->info.name);
1426 handle->info.hook_entry[HOOK_PRE_ROUTING],
1427 handle->info.hook_entry[HOOK_LOCAL_IN],
1428 handle->info.hook_entry[HOOK_FORWARD],
1429 handle->info.hook_entry[HOOK_LOCAL_OUT],
1430 handle->info.hook_entry[HOOK_POST_ROUTING]);
1432 handle->info.underflow[HOOK_PRE_ROUTING],
1433 handle->info.underflow[HOOK_LOCAL_IN],
1434 handle->info.underflow[HOOK_FORWARD],
1435 handle->info.underflow[HOOK_LOCAL_OUT],
1436 handle->info.underflow[HOOK_POST_ROUTING]);
1438 ENTRY_ITERATE(handle->entries->entrytable, handle->entries->size,
1439 dump_entry, handle);
1443 int TC_IS_CHAIN(const char *chain, struct xtc_handle *const handle)
1446 return iptcc_find_label(chain, handle) != NULL;
1449 static void iptcc_chain_iterator_advance(struct xtc_handle *handle)
1451 struct chain_head *c = handle->chain_iterator_cur;
1453 if (c->list.next == &handle->chains)
1454 handle->chain_iterator_cur = NULL;
1456 handle->chain_iterator_cur =
1462 TC_FIRST_CHAIN(struct xtc_handle *handle)
1464 struct chain_head *c = list_entry(handle->chains.next,
1470 if (list_empty(&handle->chains)) {
1475 handle->chain_iterator_cur = c;
1476 iptcc_chain_iterator_advance(handle);
1484 TC_NEXT_CHAIN(struct xtc_handle *handle)
1486 struct chain_head *c = handle->chain_iterator_cur;
1495 iptcc_chain_iterator_advance(handle);
1503 TC_FIRST_RULE(const char *chain, struct xtc_handle *handle)
1512 c = iptcc_find_label(chain, handle);
1525 handle->rule_iterator_cur = r;
1533 TC_NEXT_RULE(const STRUCT_ENTRY *prev, struct xtc_handle *handle)
1538 DEBUGP("rule_iterator_cur=%p...", handle->rule_iterator_cur);
1540 if (handle->rule_iterator_cur == NULL) {
1545 r = list_entry(handle->rule_iterator_cur->list.next,
1551 &handle->rule_iterator_cur->chain->rules);
1553 if (&r->list == &handle->rule_iterator_cur->chain->rules) {
1554 handle->rule_iterator_cur = NULL;
1559 handle->rule_iterator_cur = r;
1594 struct xtc_handle *handle)
1625 TC_BUILTIN(const char *chain, struct xtc_handle *const handle)
1631 c = iptcc_find_label(chain, handle);
1644 struct xtc_handle *handle)
1652 c = iptcc_find_label(chain, handle);
1690 iptcc_map_target(struct xtc_handle *const handle,
1710 else if (TC_BUILTIN(t->u.user.name, handle)) {
1719 c = iptcc_find_label(t->u.user.name, handle);
1736 set_changed(handle);
1745 struct xtc_handle *handle)
1753 if (!(c = iptcc_find_label(chain, handle))) {
1786 if (!iptcc_map_target(handle, r)) {
1794 set_changed(handle);
1804 struct xtc_handle *handle)
1811 if (!(c = iptcc_find_label(chain, handle))) {
1836 if (!iptcc_map_target(handle, r)) {
1844 set_changed(handle);
1854 struct xtc_handle *handle)
1860 if (!(c = iptcc_find_label(chain, handle))) {
1875 if (!iptcc_map_target(handle, r)) {
1884 set_changed(handle);
1960 unsigned char *matchmask, struct xtc_handle *handle,
1967 if (!(c = iptcc_find_label(chain, handle))) {
1981 if (!iptcc_map_target(handle, r)) {
2012 if (i == handle->rule_iterator_cur) {
2013 handle->rule_iterator_cur =
2014 list_entry(handle->rule_iterator_cur->list.prev,
2021 set_changed(handle);
2033 unsigned char *matchmask, struct xtc_handle *handle)
2036 return delete_entry(chain, origfw, matchmask, handle, true);
2041 unsigned char *matchmask, struct xtc_handle *handle)
2043 return delete_entry(chain, origfw, matchmask, handle, false);
2050 struct xtc_handle *handle)
2057 if (!(c = iptcc_find_label(chain, handle))) {
2077 if (r == handle->rule_iterator_cur) {
2078 handle->rule_iterator_cur =
2079 list_entry(handle->rule_iterator_cur->list.prev,
2086 set_changed(handle);
2093 TC_FLUSH_ENTRIES(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2099 if (!(c = iptcc_find_label(chain, handle))) {
2110 set_changed(handle);
2117 TC_ZERO_ENTRIES(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2123 if (!(c = iptcc_find_label(chain, handle))) {
2136 set_changed(handle);
2144 struct xtc_handle *handle)
2150 CHECK(*handle);
2152 if (!(c = iptcc_find_label(chain, handle))) {
2168 struct xtc_handle *handle)
2174 CHECK(handle);
2176 if (!(c = iptcc_find_label(chain, handle))) {
2189 set_changed(handle);
2198 struct xtc_handle *handle)
2205 CHECK(handle);
2207 if (!(c = iptcc_find_label(chain, handle))) {
2222 set_changed(handle);
2231 TC_CREATE_CHAIN(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2241 if (iptcc_find_label(chain, handle)
2264 handle->num_chains++; /* New user defined chain */
2267 iptc_insert_chain(handle, c); /* Insert sorted */
2275 capacity = handle->chain_index_sz * CHAIN_INDEX_BUCKET_LEN;
2276 exceeded = handle->num_chains - capacity;
2279 capacity, exceeded, handle->num_chains);
2280 iptcc_chain_index_rebuild(handle);
2283 set_changed(handle);
2291 struct xtc_handle *handle)
2296 if (!(c = iptcc_find_label(chain, handle))) {
2308 TC_DELETE_CHAIN(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2315 if (!(c = iptcc_find_label(chain, handle))) {
2321 if (TC_BUILTIN(chain, handle)) {
2327 if (!TC_GET_REFERENCES(&references, chain, handle)) {
2346 if (c == handle->chain_iterator_cur)
2347 iptcc_chain_iterator_advance(handle);
2349 handle->num_chains--; /* One user defined chain deleted */
2352 iptcc_chain_index_delete_chain(c, handle);
2357 set_changed(handle);
2365 struct xtc_handle *handle)
2372 if (iptcc_find_label(newname, handle)
2381 if (!(c = iptcc_find_label(oldname, handle))
2382 || TC_BUILTIN(oldname, handle)) {
2393 iptcc_chain_index_delete_chain(c, handle);
2399 iptc_insert_chain(handle, c);
2401 set_changed(handle);
2411 struct xtc_handle *handle)
2417 if (!(c = iptcc_find_label(chain, handle))) {
2446 set_changed(handle);
2518 TC_COMMIT(struct xtc_handle *handle)
2530 CHECK(*handle);
2533 if (!handle->changed)
2536 new_number = iptcc_compile_table_prep(handle, &new_size);
2550 TC_DUMP_ENTRIES(*handle);
2558 * handle->info.num_entries);
2571 strcpy(repl->name, handle->info.name);
2575 repl->num_counters = handle->info.num_entries;
2576 repl->valid_hooks = handle->info.valid_hooks;
2581 ret = iptcc_compile_table(handle, repl);
2599 ret = setsockopt(handle->sockfd, TC_IPPROTO, SO_SET_REPLACE, repl,
2605 strcpy(newcounters->name, handle->info.name);
2608 list_for_each_entry(c, &handle->chains, list) {
2675 ret = setsockopt(handle->sockfd, TC_IPPROTO, SO_SET_ADD_COUNTERS,