#include <assert.h>
#include <errno.h>
#include <net/ethernet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <libmnl/libmnl.h>
#include <libipset/debug.h>
#include <libipset/data.h>
#include <libipset/session.h>
#include <libipset/utils.h>
#include <libipset/types.h>
Data Structures | |
struct | ipset |
: set name | |
ipset_cache_del - delete set from the cache Delete the named set from the internal cache. If NULL is specified as setname, the whole cache is emptied. Returns 0 on success or a negative error code. | |
#define | MATCH_FAMILY(type, f) |
#define | set_family_and_type(data, match, family) |
int | ipset_cache_add (const char *name, const struct ipset_type *type, uint8_t family) |
int | ipset_cache_del (const char *name) |
int | ipset_cache_rename (const char *from, const char *to) |
ipset_cache_rename - rename a set in the cache : the set to rename : the new name of the set More... | |
int | ipset_cache_swap (const char *from, const char *to) |
ipset_cache_swap - swap two sets in the cache : the first set : the second set More... | |
bool | ipset_match_typename (const char *name, const struct ipset_type *type) |
const struct ipset_type * | ipset_type_get (struct ipset_session *session, enum ipset_cmd cmd) |
ipset_type_get - get a set type from the kernel : session structure : the command which needs the set type More... | |
const struct ipset_type * | ipset_type_check (struct ipset_session *session) |
ipset_type_check - check the set type received from kernel : session structure More... | |
int | ipset_type_add (struct ipset_type *type) |
ipset_type_add - add (register) a userspace set type : pointer to the set type structure More... | |
const char * | ipset_typename_resolve (const char *str) |
ipset_typename_resolve - resolve typename alias : typename or alias More... | |
const struct ipset_type * | ipset_types (void) |
ipset_types - return the list of the set types More... | |
int | ipset_cache_init (void) |
ipset_cache_init - initialize set cache More... | |
void | ipset_cache_fini (void) |
ipset_cache_fini - release the set cache More... | |
void | ipset_types_init (void) |
void | ipset_load_types (void) |
ipset_load_types - load known set types More... | |
#define MATCH_FAMILY | ( | type, | |
f | |||
) |
Referenced by ipset_type_check().
#define set_family_and_type | ( | data, | |
match, | |||
family | |||
) |
Referenced by ipset_type_check().
int ipset_cache_add | ( | const char * | name, |
const struct ipset_type * | type, | ||
uint8_t | family | ||
) |
References ipset::family, IPSET_MAXNAMELEN, ipset_strlcpy(), ipset::name, ipset::next, NULL, s, STREQ, ipset::type, and type.
int ipset_cache_del | ( | const char * | name | ) |
References ipset::name, ipset::next, NULL, s, and STREQ.
void ipset_cache_fini | ( | void | ) |
ipset_cache_fini - release the set cache
Release the set cache.
References ipset::next.
Referenced by ipset_session_fini().
int ipset_cache_init | ( | void | ) |
ipset_cache_init - initialize set cache
Initialize the set cache in userspace.
Returns 0 on success or a negative error code.
Referenced by ipset_session_init().
int ipset_cache_rename | ( | const char * | from, |
const char * | to | ||
) |
ipset_cache_rename - rename a set in the cache : the set to rename : the new name of the set
Rename the given set in the cache.
Returns 0 on success or a negative error code.
References IPSET_MAXNAMELEN, ipset_strlcpy(), ipset::name, ipset::next, NULL, s, and STREQ.
int ipset_cache_swap | ( | const char * | from, |
const char * | to | ||
) |
ipset_cache_swap - swap two sets in the cache : the first set : the second set
Swap two existing sets in the cache.
Returns 0 on success or a negative error code.
References IPSET_MAXNAMELEN, ipset_strlcpy(), ipset::next, NULL, s, and STREQ.
void ipset_load_types | ( | void | ) |
ipset_load_types - load known set types
Load in (register) all known set types for the system
References ipset_types_init(), len, ipset::next, and NULL.
Referenced by main().
bool ipset_match_typename | ( | const char * | name, |
const struct ipset_type * | type | ||
) |
References ipset_type::alias, ipset_type::name, and STREQ.
Referenced by ipset_type_check(), and ipset_typename_resolve().
int ipset_type_add | ( | struct ipset_type * | type | ) |
ipset_type_add - add (register) a userspace set type : pointer to the set type structure
Add the given set type to the type list. The types are added sorted, in descending revision number.
Returns 0 on success or a negative error code.
References IPSET_MAXNAMELEN, ipset_type::name, ipset_type::next, NULL, ipset_type::revision, STREQ, and type.
Referenced by _init().
const struct ipset_type* ipset_type_check | ( | struct ipset_session * | session | ) |
ipset_type_check - check the set type received from kernel : session structure
Check the set type received from the kernel (typename, revision, family) against the userspace types looking for a matching type.
Returns the set type for success and NULL for failure.
References data, ipset_data_family(), ipset_data_get(), ipset_errptr, IPSET_KERNEL_MISMATCH, ipset_match_typename(), IPSET_OPT_REVISION, IPSET_OPT_TYPENAME, ipset_session_data(), ipset_type::kernel_check, MATCH_FAMILY, ipset_type::next, NFPROTO_UNSPEC, NULL, ipset_data::revision, ipset_type::revision, and set_family_and_type.
const struct ipset_type* ipset_type_get | ( | struct ipset_session * | session, |
enum ipset_cmd | cmd | ||
) |
ipset_type_get - get a set type from the kernel : session structure : the command which needs the set type
Build up and send a private message to the kernel in order to get the set type. When creating the set, we send the typename and family and get the supported revisions of the given set type. When adding/deleting/testing an entry, we send the setname and receive the typename, family and revision.
Returns the set type for success and NULL for failure.
References IPSET_CMD_ADD, IPSET_CMD_CREATE, IPSET_CMD_DEL, IPSET_CMD_NONE, IPSET_CMD_TEST, ipset_data_get(), IPSET_OPT_TYPE, ipset_session_data(), and NULL.
Referenced by ipset_parse_typename(), and parse_commandline().
const char* ipset_typename_resolve | ( | const char * | str | ) |
ipset_typename_resolve - resolve typename alias : typename or alias
Check the typenames (and aliases) and return the preferred name of the set type.
Returns the name of the matching set type or NULL.
References ipset_match_typename(), ipset_type::name, ipset_type::next, and NULL.
Referenced by ipset_parse_typename().
const struct ipset_type* ipset_types | ( | void | ) |
ipset_types - return the list of the set types
The types can be unchecked with respect of the running kernel. Only useful for type specific help.
Returns the list of the set types.
Referenced by parse_commandline().
void ipset_types_init | ( | void | ) |