netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
parse.c File Reference
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <netdb.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <libipset/debug.h>
#include <libipset/data.h>
#include <libipset/icmp.h>
#include <libipset/icmpv6.h>
#include <libipset/pfxlen.h>
#include <libipset/session.h>
#include <libipset/types.h>
#include <libipset/utils.h>
#include <libipset/parse.h>
#include "../config.h"
Include dependency graph for parse.c:

Macros

#define ULLONG_MAX   18446744073709551615ULL
 
#define cidr_separator(str)   ipset_strchr(str, IPSET_CIDR_SEPARATOR)
 
#define range_separator(str)   ipset_strchr(str, IPSET_RANGE_SEPARATOR)
 
#define elem_separator(str)   ipset_strchr(str, IPSET_ELEM_SEPARATOR)
 
#define name_separator(str)   ipset_strchr(str, IPSET_NAME_SEPARATOR)
 
#define proto_separator(str)   ipset_strchr(str, IPSET_PROTO_SEPARATOR)
 
#define syntax_err(fmt, args...)   ipset_err(session, "Syntax error: " fmt , ## args)
 
#define check_setname(str, saved)
 
#define parse_elem(s, t, d, str)
 
#define elem_syntax_err(fmt, args...)
 

Enumerations

enum  ipaddr_type {
  IPADDR_ANY,
  IPADDR_PLAIN,
  IPADDR_NET,
  IPADDR_RANGE
}
 

Functions

int ipset_parse_ether (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_ether - parse ethernet address : session structure : option kind of the data : string to parse More...
 
int ipset_parse_port (struct ipset_session *session, enum ipset_opt opt, const char *str, const char *proto)
 ipset_parse_single_port - parse a single port number or name : session structure : option kind of the data : string to parse : protocol More...
 
int ipset_parse_mark (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_mark - parse a mark : session structure : option kind of the data : string to parse More...
 
int ipset_parse_tcpudp_port (struct ipset_session *session, enum ipset_opt opt, const char *str, const char *proto)
 ipset_parse_tcpudp_port - parse TCP/UDP port name, number, or range of them : session structure : option kind of the data : string to parse : TCP|UDP More...
 
int ipset_parse_tcp_port (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_tcp_port - parse TCP port name, number, or range of them : session structure : option kind of the data : string to parse More...
 
int ipset_parse_single_tcp_port (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_single_tcp_port - parse TCP port name or number : session structure : option kind of the data : string to parse More...
 
int ipset_parse_proto (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_proto - parse protocol name : session structure : option kind of the data : string to parse More...
 
int ipset_parse_icmp (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_icmp - parse an ICMP name or type/code : session structure : option kind of the data : string to parse More...
 
int ipset_parse_icmpv6 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_icmpv6 - parse an ICMPv6 name or type/code : session structure : option kind of the data : string to parse More...
 
int ipset_parse_proto_port (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_proto_port - parse (optional) protocol and a single port : session structure : option kind of the data : string to parse More...
 
int ipset_parse_tcp_udp_port (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_tcp_udp_port - parse (optional) protocol and a single port : session structure : option kind of the data : string to parse More...
 
int ipset_parse_family (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_family - parse INET|INET6 family names : session structure : option kind of the data : string to parse More...
 
int ipset_parse_ip (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_ip - parse IPv4|IPv6 address, range or netblock : session structure : option kind of the data : string to parse More...
 
int ipset_parse_single_ip (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_single_ip - parse a single IPv4|IPv6 address : session structure : option kind of the data : string to parse More...
 
int ipset_parse_net (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_net - parse IPv4|IPv6 address/cidr : session structure : option kind of the data : string to parse More...
 
int ipset_parse_range (struct ipset_session *session, enum ipset_opt opt ASSERT_UNUSED, const char *str)
 ipset_parse_range - parse IPv4|IPv6 ranges : session structure : option kind of the data : string to parse More...
 
int ipset_parse_netrange (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_netrange - parse IPv4|IPv6 address/cidr or range : session structure : option kind of the data : string to parse More...
 
int ipset_parse_iprange (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_iprange - parse IPv4|IPv6 address or range : session structure : option kind of the data : string to parse More...
 
int ipset_parse_ipnet (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_ipnet - parse IPv4|IPv6 address or address/cidr pattern : session structure : option kind of the data : string to parse More...
 
int ipset_parse_ip4_single6 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_ip4_single6 - parse IPv4 address, range or netblock or IPv6 address : session structure : option kind of the data : string to parse More...
 
int ipset_parse_ip4_net6 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_ip4_net6 - parse IPv4|IPv6 address or address/cidr pattern : session structure : option kind of the data : string to parse More...
 
int ipset_parse_timeout (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_timeout - parse timeout parameter : session structure : option kind of the data : string to parse More...
 
int ipset_parse_iptimeout (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_iptimeout - parse IPv4|IPv6 address and timeout : session structure : option kind of the data : string to parse More...
 
int ipset_parse_name_compat (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_name_compat - parse setname as element : session structure : option kind of the data : string to parse More...
 
int ipset_parse_setname (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_setname - parse string as a setname : session structure : option kind of the data : string to parse More...
 
int ipset_parse_before (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_before - parse string as "before" reference setname : session structure : option kind of the data : string to parse More...
 
int ipset_parse_after (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_after - parse string as "after" reference setname : session structure : option kind of the data : string to parse More...
 
int ipset_parse_uint64 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_uint64 - parse string as an unsigned long integer : session structure : option kind of the data : string to parse More...
 
int ipset_parse_uint32 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_uint32 - parse string as an unsigned integer : session structure : option kind of the data : string to parse More...
 
int ipset_parse_uint16 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 
int ipset_parse_uint8 (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_uint8 - parse string as an unsigned short integer : session structure : option kind of the data : string to parse More...
 
int ipset_parse_netmask (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_netmask - parse string as a CIDR netmask value : session structure : option kind of the data : string to parse More...
 
int ipset_parse_flag (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_flag - "parse" option flags : session structure : option kind of the data : string to parse More...
 
int ipset_parse_typename (struct ipset_session *session, enum ipset_opt opt ASSERT_UNUSED, const char *str)
 ipset_parse_type - parse ipset type name : session structure : option kind of the data : string to parse More...
 
int ipset_parse_iface (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_iface - parse string as an interface name : session structure : option kind of the data : string to parse More...
 
int ipset_parse_comment (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_comment - parse string as a comment : session structure : option kind of the data : string to parse More...
 
int ipset_parse_skbmark (struct ipset_session *session, enum ipset_opt opt, const char *str)
 
int ipset_parse_skbprio (struct ipset_session *session, enum ipset_opt opt, const char *str)
 
int ipset_parse_output (struct ipset_session *session, int opt UNUSED, const char *str)
 ipset_parse_output - parse output format name : session structure : option kind of the data : string to parse More...
 
int ipset_parse_ignored (struct ipset_session *session, enum ipset_opt opt, const char *str)
 ipset_parse_ignored - "parse" ignored option : session structure : option kind of the data : string to parse More...
 
int ipset_call_parser (struct ipset_session *session, const struct ipset_arg *arg, const char *str)
 ipset_call_parser - call a parser function : session structure : parser function : option name : option kind of the data : string to parse More...
 
int ipset_parse_elem (struct ipset_session *session, bool optional, const char *str)
 ipset_parse_elem - parse ADT elem, depending on settype : session structure : option kind of the data : string to parse More...
 

Macro Definition Documentation

#define check_setname (   str,
  saved 
)
Value:
do { \
if (strlen(str) > IPSET_MAXNAMELEN - 1) { \
if (saved != NULL) \
free(saved); \
return syntax_err("setname '%s' is longer than %u characters",\
str, IPSET_MAXNAMELEN - 1); \
} \
} while (0)
#define syntax_err(fmt, args...)
Definition: parse.c:41
#define NULL
Definition: linux_stddef.h:8
#define IPSET_MAXNAMELEN
Definition: linux_ip_set.h:20

Referenced by ipset_parse_after(), ipset_parse_before(), ipset_parse_name_compat(), and ipset_parse_setname().

#define cidr_separator (   str)    ipset_strchr(str, IPSET_CIDR_SEPARATOR)
#define elem_separator (   str)    ipset_strchr(str, IPSET_ELEM_SEPARATOR)
#define elem_syntax_err (   fmt,
  args... 
)
Value:
do { \
free(saved); \
return syntax_err(fmt , ## args);\
} while (0)
#define syntax_err(fmt, args...)
Definition: parse.c:41

Referenced by ipset_parse_elem().

#define name_separator (   str)    ipset_strchr(str, IPSET_NAME_SEPARATOR)
#define parse_elem (   s,
  t,
  d,
  str 
)
Value:
do { \
if (!(t)->elem[d - 1].parse) \
goto internal; \
ret = (t)->elem[d - 1].parse(s, (t)->elem[d - 1].opt, str); \
if (ret) \
goto out; \
} while (0)
#define s
Definition: libip6t_ah.c:20

Referenced by ipset_parse_elem().

#define proto_separator (   str)    ipset_strchr(str, IPSET_PROTO_SEPARATOR)

Referenced by ipset_parse_proto_port().

#define range_separator (   str)    ipset_strchr(str, IPSET_RANGE_SEPARATOR)
#define ULLONG_MAX   18446744073709551615ULL

Referenced by ipset_parse_uint64().

Enumeration Type Documentation

Enumerator
IPADDR_ANY 
IPADDR_PLAIN 
IPADDR_NET 
IPADDR_RANGE 

Function Documentation

int ipset_call_parser ( struct ipset_session session,
const struct ipset_arg arg,
const char *  str 
)

ipset_call_parser - call a parser function : session structure : parser function : option name : option kind of the data : string to parse

Wrapper to call the parser functions so that ignored options are handled properly.

Returns 0 on success or a negative error code.

References ipset_data_flags_test(), ipset_data_test_ignored(), IPSET_FLAG, IPSET_OPT_FAMILY, ipset_session_data(), ipset_arg::name, ipset_arg::opt, ipset_arg::parse, and syntax_err.

Here is the call graph for this function:

int ipset_parse_after ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_after - parse string as "after" reference setname : session structure : option kind of the data : string to parse

Parse string as a "after" reference setname for list:set type of sets. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References check_setname, data, ipset_data_flags_test(), ipset_data_set(), IPSET_FLAG, IPSET_OPT_NAMEREF, ipset_session_data(), NULL, and syntax_err.

Here is the call graph for this function:

int ipset_parse_before ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_before - parse string as "before" reference setname : session structure : option kind of the data : string to parse

Parse string as a "before" reference setname for list:set type of sets. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References check_setname, data, ipset_data_flags_test(), ipset_data_set(), IPSET_FLAG, IPSET_OPT_BEFORE, IPSET_OPT_NAMEREF, ipset_session_data(), NULL, and syntax_err.

Here is the call graph for this function:

int ipset_parse_comment ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_comment - parse string as a comment : session structure : option kind of the data : string to parse

Parse string for use as a comment on an ipset entry. Gets stored in the data blob as usual.

Returns 0 on success or a negative error code.

References data, ipset_data_set(), IPSET_MAX_COMMENT_SIZE, IPSET_OPT_ADT_COMMENT, ipset_session_data(), and syntax_err.

Here is the call graph for this function:

int ipset_parse_elem ( struct ipset_session session,
bool  optional,
const char *  str 
)

ipset_parse_elem - parse ADT elem, depending on settype : session structure : option kind of the data : string to parse

Parse string as a (multipart) element according to the settype. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_type::compat_parse_elem, D, ipset_type::dimension, ipset_type::elem, elem_separator, elem_syntax_err, IPSET_DIM_ONE, IPSET_DIM_THREE, IPSET_DIM_TWO, ipset_err, IPSET_OPT_TYPE, ipset_session_data_get, ipset_type::name, NULL, ipset_elem::opt, parse_elem, and type.

Referenced by parse_commandline().

Here is the caller graph for this function:

int ipset_parse_ether ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_ether - parse ethernet address : session structure : option kind of the data : string to parse

Parse string as an ethernet address. The parsed ethernet address is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References error, ETH_ALEN, ether, IPSET_OPT_ETHER, ipset_session_data_set, len, and syntax_err.

int ipset_parse_family ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_family - parse INET|INET6 family names : session structure : option kind of the data : string to parse

Parse string as an INET|INET6 family name. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References data, ipset_data::family, ipset_data_flags_test(), ipset_data_set(), ipset_data_test_ignored(), IPSET_FLAG, IPSET_OPT_FAMILY, ipset_session_data(), NFPROTO_IPV4, NFPROTO_IPV6, NFPROTO_UNSPEC, STREQ, and syntax_err.

Here is the call graph for this function:

int ipset_parse_flag ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_flag - "parse" option flags : session structure : option kind of the data : string to parse

Parse option flags :-) The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_session_data_set.

int ipset_parse_icmp ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_icmp - parse an ICMP name or type/code : session structure : option kind of the data : string to parse

Parse string as an ICMP name or type/code numbers. The parsed ICMP type/code is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPSET_OPT_PORT, ipset_session_data_set, and name_to_icmp().

Referenced by ipset_parse_proto_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_icmpv6 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_icmpv6 - parse an ICMPv6 name or type/code : session structure : option kind of the data : string to parse

Parse string as an ICMPv6 name or type/code numbers. The parsed ICMPv6 type/code is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPSET_OPT_PORT, ipset_session_data_set, and name_to_icmpv6().

Referenced by ipset_parse_proto_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_iface ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_iface - parse string as an interface name : session structure : option kind of the data : string to parse

Parse string as an interface name, optionally with 'physdev:' prefix. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References data, IFNAMSIZ, ipset_data_set(), IPSET_OPT_IFACE, IPSET_OPT_PHYSDEV, ipset_session_data(), STRNEQ, and syntax_err.

Here is the call graph for this function:

int ipset_parse_ignored ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_ignored - "parse" ignored option : session structure : option kind of the data : string to parse

Ignore deprecated options. A single warning is generated for every ignored opton.

Returns 0.

References ipset_data_ignored(), ipset_session_data(), and ipset_warn.

Here is the call graph for this function:

int ipset_parse_ip ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_ip - parse IPv4|IPv6 address, range or netblock : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address or address range or netblock. Hostnames are resolved. If family is not set yet in the data blob, INET is assumed. The values are stored in the data blob of the session.

FIXME: if the hostname resolves to multiple addresses, the first one is used only.

Returns 0 on success or a negative error code.

References IPADDR_ANY, IPSET_OPT_IP, and IPSET_OPT_IP2.

Referenced by ipset_parse_ip4_single6().

Here is the caller graph for this function:

int ipset_parse_ip4_net6 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_ip4_net6 - parse IPv4|IPv6 address or address/cidr pattern : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address or address/cidr pattern. For IPv4, address range is valid too. If family is not set yet in the data blob, INET is assumed. The values are stored in the data blob of the session.

FIXME: if the hostname resolves to multiple addresses, the first one is used only.

Returns 0 on success or a negative error code.

References data, ipset_data::family, IPADDR_ANY, ipset_data_family(), ipset_data_set(), IPSET_OPT_FAMILY, IPSET_OPT_IP, IPSET_OPT_IP2, ipset_parse_ipnet(), ipset_session_data(), NFPROTO_IPV4, and NFPROTO_UNSPEC.

Here is the call graph for this function:

int ipset_parse_ip4_single6 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_ip4_single6 - parse IPv4 address, range or netblock or IPv6 address : session structure : option kind of the data : string to parse

Parse string as an IPv4 address or address range or netblock or and IPv6 address. Hostnames are resolved. If family is not set yet in the data blob, INET is assumed. The values are stored in the data blob of the session.

FIXME: if the hostname resolves to multiple addresses, the first one is used only.

Returns 0 on success or a negative error code.

References data, ipset_data::family, ipset_data_family(), ipset_data_set(), IPSET_OPT_FAMILY, IPSET_OPT_IP, IPSET_OPT_IP2, ipset_parse_ip(), ipset_parse_single_ip(), ipset_session_data(), NFPROTO_IPV4, and NFPROTO_UNSPEC.

Here is the call graph for this function:

int ipset_parse_ipnet ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_ipnet - parse IPv4|IPv6 address or address/cidr pattern : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address or address/cidr pattern. If family is not set yet in the data blob, INET is assumed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPADDR_ANY, IPSET_OPT_IP, IPSET_OPT_IP2, and syntax_err.

Referenced by ipset_parse_ip4_net6().

Here is the caller graph for this function:

int ipset_parse_iprange ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_iprange - parse IPv4|IPv6 address or range : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address pattern or a range of addresses separated by a dash. If family is not set yet in the data blob, INET is assumed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References cidr_separator, IPADDR_ANY, IPSET_OPT_IP, IPSET_OPT_IP2, and syntax_err.

int ipset_parse_iptimeout ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_iptimeout - parse IPv4|IPv6 address and timeout : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address and timeout parameter. If family is not set yet in the data blob, INET is assumed. The value is stored in the data blob of the session.

Compatibility parser.

Returns 0 on success or a negative error code.

References elem_separator, IPADDR_ANY, ipset_data_flags_test(), IPSET_FLAG, IPSET_OPT_IP, IPSET_OPT_TIMEOUT, ipset_parse_timeout(), ipset_session_data(), NULL, and syntax_err.

Here is the call graph for this function:

int ipset_parse_mark ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_mark - parse a mark : session structure : option kind of the data : string to parse

Parse string as a mark. The parsed mark number is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_session_data_set, ipset_session_report_reset(), and mark.

Here is the call graph for this function:

int ipset_parse_name_compat ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_name_compat - parse setname as element : session structure : option kind of the data : string to parse

Parse string as a setname or a setname element to add to a set. The pattern "setname,before|after,setname" is recognized and parsed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References check_setname, data, elem_separator, ipset_data_flags_test(), ipset_data_set(), IPSET_ELEM_SEPARATOR, ipset_err, IPSET_FLAG, IPSET_OPT_BEFORE, IPSET_OPT_NAME, IPSET_OPT_NAMEREF, ipset_session_data(), NULL, STREQ, and syntax_err.

Here is the call graph for this function:

int ipset_parse_net ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_net - parse IPv4|IPv6 address/cidr : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address/cidr pattern. If family is not set yet in the data blob, INET is assumed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPADDR_NET, IPSET_OPT_IP, and IPSET_OPT_IP2.

int ipset_parse_netmask ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_netmask - parse string as a CIDR netmask value : session structure : option kind of the data : string to parse

Parse string as a CIDR netmask value, depending on family type. If family is not set yet, INET is assumed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_data::cidr, data, ipset_data::family, ipset_data_family(), ipset_data_set(), IPSET_OPT_FAMILY, IPSET_OPT_NETMASK, ipset_session_data(), NFPROTO_IPV4, NFPROTO_UNSPEC, and syntax_err.

Here is the call graph for this function:

int ipset_parse_netrange ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_netrange - parse IPv4|IPv6 address/cidr or range : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address/cidr pattern or a range of addresses separated by a dash. If family is not set yet in the data blob, INET is assumed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References cidr_separator, IPADDR_ANY, IPSET_OPT_IP, IPSET_OPT_IP2, and syntax_err.

int ipset_parse_output ( struct ipset_session session,
int opt  UNUSED,
const char *  str 
)

ipset_parse_output - parse output format name : session structure : option kind of the data : string to parse

Parse output format names and set session mode. The value is stored in the session.

Returns 0 on success or a negative error code.

References IPSET_LIST_PLAIN, IPSET_LIST_SAVE, IPSET_LIST_XML, ipset_session_output(), STREQ, and syntax_err.

Here is the call graph for this function:

int ipset_parse_port ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str,
const char *  proto 
)

ipset_parse_single_port - parse a single port number or name : session structure : option kind of the data : string to parse : protocol

Parse string as a single port number or name. The parsed port number is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPSET_OPT_PORT, IPSET_OPT_PORT_TO, ipset_session_data_set, and ipset_session_report_reset().

Referenced by ipset_parse_single_tcp_port(), and ipset_parse_tcpudp_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_proto ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_proto - parse protocol name : session structure : option kind of the data : string to parse

Parse string as a protocol name. The parsed protocol is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPSET_OPT_PROTO, ipset_session_data_set, NULL, and syntax_err.

Referenced by ipset_parse_proto_port().

Here is the caller graph for this function:

int ipset_parse_proto_port ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_proto_port - parse (optional) protocol and a single port : session structure : option kind of the data : string to parse

Parse string as a protocol and port, separated by a colon. The protocol part is optional. The parsed protocol and port numbers are stored in the data blob of the session.

Returns 0 on success or a negative error code.

References data, error, IPPROTO_SCTP, IPPROTO_UDPLITE, ipset_data_family(), ipset_data_flags_set(), ipset_data_get(), ipset_data_set(), IPSET_FLAG, IPSET_OPT_PORT, IPSET_OPT_PROTO, ipset_parse_icmp(), ipset_parse_icmpv6(), ipset_parse_proto(), ipset_parse_tcpudp_port(), ipset_session_data(), NFPROTO_IPV4, NFPROTO_IPV6, NULL, ipset_data::proto, proto_separator, STREQ, and syntax_err.

Referenced by ipset_parse_tcp_udp_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_range ( struct ipset_session session,
enum ipset_opt opt  ASSERT_UNUSED,
const char *  str 
)

ipset_parse_range - parse IPv4|IPv6 ranges : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 range separated by a dash. If family is not set yet in the data blob, INET is assumed. The values are stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPADDR_RANGE, IPSET_OPT_IP, and IPSET_OPT_IP2.

int ipset_parse_setname ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_setname - parse string as a setname : session structure : option kind of the data : string to parse

Parse string as a setname. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References check_setname, IPSET_OPT_NAME, IPSET_OPT_SETNAME2, ipset_session_data_set, IPSET_SETNAME, and NULL.

Referenced by parse_commandline().

Here is the caller graph for this function:

int ipset_parse_single_ip ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_single_ip - parse a single IPv4|IPv6 address : session structure : option kind of the data : string to parse

Parse string as an IPv4|IPv6 address or hostname. If family is not set yet in the data blob, INET is assumed. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPADDR_PLAIN, IPSET_OPT_IP, IPSET_OPT_IP2, and IPSET_OPT_IP_TO.

Referenced by ipset_parse_ip4_single6().

Here is the caller graph for this function:

int ipset_parse_single_tcp_port ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_single_tcp_port - parse TCP port name or number : session structure : option kind of the data : string to parse

Parse string as a single TCP port name or number. The parsed port number is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPSET_OPT_PORT, IPSET_OPT_PORT_TO, and ipset_parse_port().

Here is the call graph for this function:

int ipset_parse_skbmark ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

References data, ipset_data_set(), IPSET_OPT_SKBMARK, ipset_session_data(), mark, mask, and syntax_err.

Here is the call graph for this function:

int ipset_parse_skbprio ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

References data, ipset_data_set(), IPSET_OPT_SKBPRIO, ipset_session_data(), min, and syntax_err.

Here is the call graph for this function:

int ipset_parse_tcp_port ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_tcp_port - parse TCP port name, number, or range of them : session structure : option kind of the data : string to parse

Parse string as a TCP port name or number or range of them separated by a dash. The parsed port numbers are stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_parse_tcpudp_port().

Here is the call graph for this function:

int ipset_parse_tcp_udp_port ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_tcp_udp_port - parse (optional) protocol and a single port : session structure : option kind of the data : string to parse

Parse string as a protocol and port, separated by a colon. The protocol part is optional, but may only be "tcp" or "udp". The parsed port numbers are stored in the data blob of the session.

Returns 0 on success or a negative error code.

References data, ipset_data_flags_unset(), ipset_data_get(), IPSET_FLAG, IPSET_OPT_PROTO, ipset_parse_proto_port(), ipset_session_data(), and syntax_err.

Here is the call graph for this function:

int ipset_parse_tcpudp_port ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str,
const char *  proto 
)

ipset_parse_tcpudp_port - parse TCP/UDP port name, number, or range of them : session structure : option kind of the data : string to parse : TCP|UDP

Parse string as a TCP/UDP port name or number or range of them separated by a dash. The parsed port numbers are stored in the data blob of the session.

Returns 0 on success or a negative error code.

References error, IPSET_OPT_PORT, IPSET_OPT_PORT_TO, ipset_parse_port(), and NULL.

Referenced by ipset_parse_proto_port(), and ipset_parse_tcp_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_timeout ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_timeout - parse timeout parameter : session structure : option kind of the data : string to parse

Parse string as a timeout parameter. We have to take into account the jiffies storage in kernel.

Returns 0 on success or a negative error code.

References IPSET_OPT_TIMEOUT, ipset_session_data_set, and string_to_number_ll().

Referenced by ipset_parse_iptimeout().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_typename ( struct ipset_session session,
enum ipset_opt opt  ASSERT_UNUSED,
const char *  str 
)

ipset_parse_type - parse ipset type name : session structure : option kind of the data : string to parse

Parse ipset module type: supports both old and new formats. The type name is looked up and the type found is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References IPSET_CMD_CREATE, IPSET_MAXNAMELEN, IPSET_OPT_TYPE, IPSET_OPT_TYPENAME, ipset_session_data_set, ipset_type_get(), ipset_typename_resolve(), NULL, syntax_err, and type.

Referenced by parse_commandline().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_parse_uint16 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

References ipset_session_data_set, and value.

int ipset_parse_uint32 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_uint32 - parse string as an unsigned integer : session structure : option kind of the data : string to parse

Parse string as an unsigned integer number. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_session_data_set, and value.

int ipset_parse_uint64 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_uint64 - parse string as an unsigned long integer : session structure : option kind of the data : string to parse

Parse string as an unsigned long integer number. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_session_data_set, string_to_number_ll(), ULLONG_MAX, and value.

Here is the call graph for this function:

int ipset_parse_uint8 ( struct ipset_session session,
enum ipset_opt  opt,
const char *  str 
)

ipset_parse_uint8 - parse string as an unsigned short integer : session structure : option kind of the data : string to parse

Parse string as an unsigned short integer number. The value is stored in the data blob of the session.

Returns 0 on success or a negative error code.

References ipset_session_data_set, and value.