tpws: comma separated values in --filter-tcp

This commit is contained in:
bol-van
2024-10-29 17:17:58 +03:00
parent 2464d27550
commit acfd844a49
7 changed files with 80 additions and 14 deletions

View File

@@ -448,3 +448,36 @@ bool ipset_collection_is_empty(const struct ipset_collection_head *head)
}
return true;
}
bool port_filter_add(struct port_filters_head *head, const port_filter *pf)
{
struct port_filter_item *entry = malloc(sizeof(struct port_filter_item));
if (entry)
{
entry->pf = *pf;
LIST_INSERT_HEAD(head, entry, next);
}
return entry;
}
void port_filters_destroy(struct port_filters_head *head)
{
struct port_filter_item *entry;
while ((entry = LIST_FIRST(head)))
{
LIST_REMOVE(entry, next);
free(entry);
}
}
bool port_filters_in_range(const struct port_filters_head *head, uint16_t port)
{
const struct port_filter_item *item;
if (!LIST_FIRST(head)) return true;
LIST_FOREACH(item, head, next)
{
if (pf_in_range(port, &item->pf))
return true;
}
return false;
}