MCPcopy Create free account
hub / github.com/F-Stack/f-stack / table_do_get_list

Function table_do_get_list

tools/ipfw/tables.c:1726–1755  ·  view source on GitHub ↗

* Retrieves all entries for given table @i in * eXtended format. Allocate buffer large enough * to store result. Called needs to free it later. * * Returns 0 on success. */

Source from the content-addressed store, hash-verified

1724 * Returns 0 on success.
1725 */
1726static int
1727table_do_get_list(ipfw_xtable_info *i, ipfw_obj_header **poh)
1728{
1729 ipfw_obj_header *oh;
1730 size_t sz;
1731 int c;
1732
1733 sz = 0;
1734 oh = NULL;
1735 for (c = 0; c < 8; c++) {
1736 if (sz < i->size)
1737 sz = i->size + 44;
1738 if (oh != NULL)
1739 free(oh);
1740 if ((oh = calloc(1, sz)) == NULL)
1741 continue;
1742 table_fill_objheader(oh, i);
1743 oh->opheader.version = 1; /* Current version */
1744 if (do_get3(IP_FW_TABLE_XLIST, &oh->opheader, &sz) == 0) {
1745 *poh = oh;
1746 return (0);
1747 }
1748
1749 if (errno != ENOMEM)
1750 break;
1751 }
1752 free(oh);
1753
1754 return (errno);
1755}
1756
1757/*
1758 * Shows all entries from @oh in human-readable format

Callers 1

table_show_oneFunction · 0.85

Calls 4

callocFunction · 0.85
table_fill_objheaderFunction · 0.85
do_get3Function · 0.85
freeFunction · 0.50

Tested by

no test coverage detected