netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
types.c File Reference
#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>
Include dependency graph for types.c:

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_typeipset_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_typeipset_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_typeipset_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...
 

Macro Definition Documentation

#define MATCH_FAMILY (   type,
 
)
Value:
(f == NFPROTO_UNSPEC || type->family == f || \
struct expr
void size_t u_int16_t type
Definition: libnetfilter_conntrack.h:557
Definition: types.h:27
Definition: nfproto.h:10

Referenced by ipset_type_check().

#define set_family_and_type (   data,
  match,
  family 
)
Value:
do { \
if (family == NFPROTO_UNSPEC && match->family != NFPROTO_UNSPEC) \
family = match->family == NFPROTO_IPSET_IPV46 ? \
NFPROTO_IPV4 : match->family;\
} while (0)
Definition: nfproto.h:11
u8 family
Definition: ip_set.h:140
Definition: data.h:73
enum nf_conntrack_query query const void * data
Definition: libnetfilter_conntrack.h:570
Definition: types.h:27
Definition: data.h:19
int ipset_data_set(struct ipset_data *data, enum ipset_opt opt, const void *value)
ipset_data_set - put data into the data blob : data blob : the option kind of the data : the value of...
Definition: data.c:237
Definition: nfproto.h:10

Referenced by ipset_type_check().

Function Documentation

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.

Here is the call graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

void ipset_types_init ( void  )

Referenced by ipset_load_types().

Here is the caller graph for this function: