netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
types.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <libipset/data.h>
#include <libipset/parse.h>
#include <libipset/print.h>
#include <libipset/linux_ip_set.h>
#include <libipset/nfproto.h>
Include dependency graph for types.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  ipset_arg
 
struct  ipset_elem
 
struct  ipset_type
 

Macros

#define IPSET_DIM_UMAX   3
 
#define _init   __attribute__((constructor)) _INIT
 

Enumerations

enum  { NFPROTO_IPSET_IPV46 = 255 }
 
enum  {
  IPSET_NO_ARG = -1,
  IPSET_OPTIONAL_ARG,
  IPSET_MANDATORY_ARG,
  IPSET_MANDATORY_ARG2
}
 
enum  {
  IPSET_KERNEL_MISMATCH = -1,
  IPSET_KERNEL_CHECK_NEEDED,
  IPSET_KERNEL_OK
}
 

Functions

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...
 
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...
 
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 struct ipset_typeipset_types (void)
 ipset_types - return the list of the set types More...
 
const char * ipset_typename_resolve (const char *str)
 ipset_typename_resolve - resolve typename alias : typename or alias More...
 
bool ipset_match_typename (const char *str, const struct ipset_type *t)
 
void ipset_load_types (void)
 ipset_load_types - load known set types More...
 

Macro Definition Documentation

#define _init   __attribute__((constructor)) _INIT
#define IPSET_DIM_UMAX   3

Enumeration Type Documentation

anonymous enum
Enumerator
NFPROTO_IPSET_IPV46 
anonymous enum
Enumerator
IPSET_NO_ARG 
IPSET_OPTIONAL_ARG 
IPSET_MANDATORY_ARG 
IPSET_MANDATORY_ARG2 
anonymous enum
Enumerator
IPSET_KERNEL_MISMATCH 
IPSET_KERNEL_CHECK_NEEDED 
IPSET_KERNEL_OK 

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 *  str,
const struct ipset_type t 
)

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: