Home | History | Annotate | Download | only in libiptc

Lines Matching full: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;
438 struct xtc_handle *handle)
440 return __iptcc_bsearch_chain_index(name, 0, idx, handle, BSEARCH_NAME);
447 struct xtc_handle *handle)
454 if (!handle->sorted_offsets)
455 pos = handle->chains.next;
457 pos = __iptcc_bsearch_chain_index(NULL, offset, idx, handle,
467 iptcc_linearly_search_chain_index(const char *name, struct xtc_handle *handle)
473 list_pos = &handle->chains;
475 if (handle->chain_index_sz)
476 list_pos = &handle->chain_index[0]->list;
480 for (i=0; i < handle->chain_index_sz; i++) {
481 if (handle->chain_index[i]) {
482 res = strcmp(handle->chain_index[i]->name, name);
485 list_pos = &handle->chain_index[i]->list;
687 iptcc_find_chain_by_offset(struct xtc_handle *handle, unsigned int offset)
693 if (list_empty(&handle->chains))
697 list_start_pos = iptcc_bsearch_chain_offset(offset, &i, handle);
704 // list_for_each(pos, &handle->chains) {
719 iptcc_find_label(const char *name, struct xtc_handle *handle)
726 if (list_empty(&handle->chains))
730 list_for_each(pos, &handle->chains) {
739 //list_start_pos = iptcc_linearly_search_chain_index(name, handle);
740 list_start_pos = iptcc_bsearch_chain_index(name, &i, handle);
743 if (list_start_pos == &handle->chains) {
751 test_pos = iptcc_linearly_search_chain_index(name, handle);
766 if (handle->num_chains == 0)
784 if (pos == &handle->chains) {
859 /* Handle the case, where chain.name is smaller than index[0] */
1120 /* handle jumps */
1277 /* Allocate handle of given size */
1419 static int dump_entry(STRUCT_ENTRY *e, struct xtc_handle *const handle);
1422 TC_DUMP_ENTRIES(struct xtc_handle *const handle)
1425 CHECK(handle);
1428 XTABLES_VERSION, handle->entries->size);
1429 printf("Table `%s'\n", handle->info.name);
1431 handle->info.hook_entry[HOOK_PRE_ROUTING],
1432 handle->info.hook_entry[HOOK_LOCAL_IN],
1433 handle->info.hook_entry[HOOK_FORWARD],
1434 handle->info.hook_entry[HOOK_LOCAL_OUT],
1435 handle->info.hook_entry[HOOK_POST_ROUTING]);
1437 handle->info.underflow[HOOK_PRE_ROUTING],
1438 handle->info.underflow[HOOK_LOCAL_IN],
1439 handle->info.underflow[HOOK_FORWARD],
1440 handle->info.underflow[HOOK_LOCAL_OUT],
1441 handle->info.underflow[HOOK_POST_ROUTING]);
1443 ENTRY_ITERATE(handle->entries->entrytable, handle->entries->size,
1444 dump_entry, handle);
1448 int TC_IS_CHAIN(const char *chain, struct xtc_handle *const handle)
1451 return iptcc_find_label(chain, handle) != NULL;
1454 static void iptcc_chain_iterator_advance(struct xtc_handle *handle)
1456 struct chain_head *c = handle->chain_iterator_cur;
1458 if (c->list.next == &handle->chains)
1459 handle->chain_iterator_cur = NULL;
1461 handle->chain_iterator_cur =
1467 TC_FIRST_CHAIN(struct xtc_handle *handle)
1469 struct chain_head *c = list_entry(handle->chains.next,
1475 if (list_empty(&handle->chains)) {
1480 handle->chain_iterator_cur = c;
1481 iptcc_chain_iterator_advance(handle);
1489 TC_NEXT_CHAIN(struct xtc_handle *handle)
1491 struct chain_head *c = handle->chain_iterator_cur;
1500 iptcc_chain_iterator_advance(handle);
1508 TC_FIRST_RULE(const char *chain, struct xtc_handle *handle)
1517 c = iptcc_find_label(chain, handle);
1530 handle->rule_iterator_cur = r;
1538 TC_NEXT_RULE(const STRUCT_ENTRY *prev, struct xtc_handle *handle)
1543 DEBUGP("rule_iterator_cur=%p...", handle->rule_iterator_cur);
1545 if (handle->rule_iterator_cur == NULL) {
1550 r = list_entry(handle->rule_iterator_cur->list.next,
1556 &handle->rule_iterator_cur->chain->rules);
1558 if (&r->list == &handle->rule_iterator_cur->chain->rules) {
1559 handle->rule_iterator_cur = NULL;
1564 handle->rule_iterator_cur = r;
1599 struct xtc_handle *handle)
1630 TC_BUILTIN(const char *chain, struct xtc_handle *const handle)
1636 c = iptcc_find_label(chain, handle);
1649 struct xtc_handle *handle)
1657 c = iptcc_find_label(chain, handle);
1695 iptcc_map_target(struct xtc_handle *const handle,
1715 else if (TC_BUILTIN(t->u.user.name, handle)) {
1724 c = iptcc_find_label(t->u.user.name, handle);
1741 set_changed(handle);
1750 struct xtc_handle *handle)
1758 if (!(c = iptcc_find_label(chain, handle))) {
1791 if (!iptcc_map_target(handle, r)) {
1799 set_changed(handle);
1809 struct xtc_handle *handle)
1816 if (!(c = iptcc_find_label(chain, handle))) {
1841 if (!iptcc_map_target(handle, r)) {
1849 set_changed(handle);
1859 struct xtc_handle *handle)
1865 if (!(c = iptcc_find_label(chain, handle))) {
1880 if (!iptcc_map_target(handle, r)) {
1889 set_changed(handle);
1965 unsigned char *matchmask, struct xtc_handle *handle,
1972 if (!(c = iptcc_find_label(chain, handle))) {
1986 if (!iptcc_map_target(handle, r)) {
2019 if (i == handle->rule_iterator_cur) {
2020 handle->rule_iterator_cur =
2021 list_entry(handle->rule_iterator_cur->list.prev,
2028 set_changed(handle);
2040 unsigned char *matchmask, struct xtc_handle *handle)
2043 return delete_entry(chain, origfw, matchmask, handle, true);
2048 unsigned char *matchmask, struct xtc_handle *handle)
2050 return delete_entry(chain, origfw, matchmask, handle, false);
2057 struct xtc_handle *handle)
2064 if (!(c = iptcc_find_label(chain, handle))) {
2084 if (r == handle->rule_iterator_cur) {
2085 handle->rule_iterator_cur =
2086 list_entry(handle->rule_iterator_cur->list.prev,
2093 set_changed(handle);
2100 TC_FLUSH_ENTRIES(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2106 if (!(c = iptcc_find_label(chain, handle))) {
2117 set_changed(handle);
2124 TC_ZERO_ENTRIES(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2130 if (!(c = iptcc_find_label(chain, handle))) {
2143 set_changed(handle);
2151 struct xtc_handle *handle)
2157 CHECK(*handle);
2159 if (!(c = iptcc_find_label(chain, handle))) {
2175 struct xtc_handle *handle)
2181 CHECK(handle);
2183 if (!(c = iptcc_find_label(chain, handle))) {
2196 set_changed(handle);
2205 struct xtc_handle *handle)
2212 CHECK(handle);
2214 if (!(c = iptcc_find_label(chain, handle))) {
2229 set_changed(handle);
2238 TC_CREATE_CHAIN(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2248 if (iptcc_find_label(chain, handle)
2271 handle->num_chains++; /* New user defined chain */
2274 iptc_insert_chain(handle, c); /* Insert sorted */
2282 capacity = handle->chain_index_sz * CHAIN_INDEX_BUCKET_LEN;
2283 exceeded = handle->num_chains - capacity;
2286 capacity, exceeded, handle->num_chains);
2287 iptcc_chain_index_rebuild(handle);
2290 set_changed(handle);
2298 struct xtc_handle *handle)
2303 if (!(c = iptcc_find_label(chain, handle))) {
2315 TC_DELETE_CHAIN(const IPT_CHAINLABEL chain, struct xtc_handle *handle)
2322 if (!(c = iptcc_find_label(chain, handle))) {
2328 if (TC_BUILTIN(chain, handle)) {
2334 if (!TC_GET_REFERENCES(&references, chain, handle)) {
2353 if (c == handle->chain_iterator_cur)
2354 iptcc_chain_iterator_advance(handle);
2356 handle->num_chains--; /* One user defined chain deleted */
2359 iptcc_chain_index_delete_chain(c, handle);
2364 set_changed(handle);
2372 struct xtc_handle *handle)
2379 if (iptcc_find_label(newname, handle)
2388 if (!(c = iptcc_find_label(oldname, handle))
2389 || TC_BUILTIN(oldname, handle)) {
2400 iptcc_chain_index_delete_chain(c, handle);
2406 iptc_insert_chain(handle, c);
2408 set_changed(handle);
2418 struct xtc_handle *handle)
2424 if (!(c = iptcc_find_label(chain, handle))) {
2453 set_changed(handle);
2525 TC_COMMIT(struct xtc_handle *handle)
2537 CHECK(*handle);
2540 if (!handle->changed)
2543 new_number = iptcc_compile_table_prep(handle, &new_size);
2557 TC_DUMP_ENTRIES(*handle);
2565 * handle->info.num_entries);
2578 strcpy(repl->name, handle->info.name);
2582 repl->num_counters = handle->info.num_entries;
2583 repl->valid_hooks = handle->info.valid_hooks;
2588 ret = iptcc_compile_table(handle, repl);
2606 ret = setsockopt(handle->sockfd, TC_IPPROTO, SO_SET_REPLACE, repl,
2612 strcpy(newcounters->name, handle->info.name);
2615 list_for_each_entry(c, &handle->chains, list) {
2682 ret = setsockopt(handle->sockfd, TC_IPPROTO, SO_SET_ADD_COUNTERS,