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

Macros

#define SNPRINTF_FAILURE(size, len, offset)
 
#define SNPRINTF_IP(mask, f)
 
#define print_second(data)
 
#define print_third(data)   ipset_data_flags_test(data, IPSET_FLAG(IPSET_OPT_IP2))
 

Functions

int ipset_print_ether (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 ipset_print_ether - print ethernet address to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_family (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_family - print INET family : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_type (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 ipset_print_type - print ipset type string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_ip (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env)
 ipset_print_ip - print IPv4|IPv6 address to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_ipaddr (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env)
 ipset_print_ipaddr - print IPv4|IPv6 address to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_number (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 ipset_print_number - print number to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_name (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 ipset_print_name - print setname element string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_port (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_port - print port or port range : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_mark (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_mark - print mark to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_iface (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 ipset_print_iface - print interface element string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_comment (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 ipset_print_comment - print arbitrary parameter string : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_skbmark (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 
int ipset_print_skbprio (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env UNUSED)
 
int ipset_print_proto (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_proto - print protocol name : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_icmp (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_icmp - print ICMP code name or type/code : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_icmpv6 (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_icmpv6 - print ICMPv6 code name or type/code : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_proto_port (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt ASSERT_UNUSED, uint8_t env UNUSED)
 ipset_print_proto_port - print proto:port : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_elem (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt UNUSED, uint8_t env)
 ipset_print_elem - print ADT elem according to settype : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_flag (char *buf UNUSED, unsigned int len UNUSED, const struct ipset_data *data UNUSED, enum ipset_opt opt UNUSED, uint8_t env UNUSED)
 ipset_print_flag - print a flag : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 
int ipset_print_data (char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env)
 ipset_print_data - print data, generic fuction : printing buffer : length of available buffer space : data blob : the option kind : environment flags More...
 

Macro Definition Documentation

#define print_second (   data)
Value:
Definition: data.h:45
Definition: data.h:26
#define IPSET_FLAG(opt)
Definition: data.h:80
enum nf_conntrack_query query const void * data
Definition: libnetfilter_conntrack.h:570
bool ipset_data_flags_test(const struct ipset_data *data, uint64_t flags)
ipset_data_flags_test - test option bits in the data blob : data blob : the option flags to test ...
Definition: data.c:143
#define print_third (   data)    ipset_data_flags_test(data, IPSET_FLAG(IPSET_OPT_IP2))
#define SNPRINTF_FAILURE (   size,
  len,
  offset 
)
Value:
do { \
if (size < 0 || (unsigned int) size >= len) \
return size; \
offset += size; \
len -= size; \
} while (0)
u8 size
Definition: ip_set_hash_gen.h:186
int len
Definition: utils.c:56

Referenced by ipset_print_comment(), ipset_print_data(), ipset_print_elem(), ipset_print_ether(), ipset_print_iface(), ipset_print_ip(), ipset_print_mark(), ipset_print_name(), ipset_print_port(), ipset_print_proto_port(), ipset_print_skbmark(), and ipset_print_skbprio().

#define SNPRINTF_IP (   mask,
 
)
Value:
static int \
snprintf_ipv##f(char *buf, unsigned int len, int flags, \
const union nf_inet_addr *ip, uint8_t cidr) \
{ \
int size, offset = 0; \
\
size = __getnameinfo##f(buf, len, flags, ip); \
SNPRINTF_FAILURE(size, len, offset); \
D("cidr %u mask %u", cidr, mask); \
if (cidr == mask) \
return offset; \
D("print cidr"); \
size = snprintf(buf + offset, len, \
"%s%u", IPSET_CIDR_SEPARATOR, cidr); \
SNPRINTF_FAILURE(size, len, offset); \
return offset; \
}
static int struct nlattr enum ipset_adt adt u32 u32 flags
Definition: ip_set_hash_gen.h:1157
struct nf_conntrack * mask
Definition: conntrack.c:75
Definition: nf_inet_addr.h:14
#define IPSET_CIDR_SEPARATOR
Definition: parse.h:13
u_int32_t u_int32_t u_int32_t u_int32_t const unsigned char * buf
Definition: libnetfilter_queue.h:86
#define D(fmt, args...)
Definition: debug.h:28
u8 size
Definition: ip_set_hash_gen.h:186
int len
Definition: utils.c:56

Function Documentation

int ipset_print_comment ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

ipset_print_comment - print arbitrary parameter string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print arbitrary string to output buffer.

Return length of printed string or error size.

References ipset_data_get(), IPSET_OPT_ADT_COMMENT, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_data ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t  env 
)

ipset_print_data - print data, generic fuction : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Generic wrapper of the printing functions.

Return lenght of printed string or error size.

References ipset_data_setname(), IPSET_OPT_ELEM, IPSET_OPT_ELEMENTS, IPSET_OPT_FAMILY, IPSET_OPT_GC, IPSET_OPT_HASHSIZE, IPSET_OPT_IFACE, IPSET_OPT_IP, IPSET_OPT_MARKMASK, IPSET_OPT_MAXELEM, IPSET_OPT_NETMASK, IPSET_OPT_PORT, IPSET_OPT_PROBES, IPSET_OPT_REFERENCES, IPSET_OPT_RESIZE, IPSET_OPT_SIZE, IPSET_OPT_TIMEOUT, IPSET_OPT_TYPE, ipset_print_elem(), ipset_print_family(), ipset_print_iface(), ipset_print_ip(), ipset_print_number(), ipset_print_port(), ipset_print_type(), IPSET_SETNAME, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_elem ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  UNUSED,
uint8_t  env 
)

ipset_print_elem - print ADT elem according to settype : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print (multipart) element according to settype

Return lenght of printed string or error size.

References ipset_type::dimension, ipset_type::elem, IF_D, ipset_data_get(), IPSET_DIM_ONE, IPSET_DIM_THREE, IPSET_DIM_TWO, IPSET_ELEM_SEPARATOR, IPSET_OPT_TYPE, ipset_type::last_elem_optional, ipset_elem::opt, ipset_elem::print, size, SNPRINTF_FAILURE, and type.

Referenced by ipset_print_data().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_ether ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

ipset_print_ether - print ethernet address to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print Ethernet address to output buffer.

Return lenght of printed string or error size.

References ETH_ALEN, ether, ipset_data_get(), IPSET_OPT_ETHER, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_family ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_family - print INET family : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print INET family string to output buffer.

Return lenght of printed string or error size.

References ipset_data_family(), IPSET_OPT_FAMILY, and opt.

Referenced by ipset_print_data().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_flag ( char *buf  UNUSED,
unsigned int len  UNUSED,
const struct ipset_data *data  UNUSED,
enum ipset_opt opt  UNUSED,
uint8_t env  UNUSED 
)

ipset_print_flag - print a flag : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print a flag, i.e. option without value

Return lenght of printed string or error size.

int ipset_print_icmp ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_icmp - print ICMP code name or type/code : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print ICMP code name or type/code name to output buffer.

Return lenght of printed string or error size.

References icmp_to_name(), ipset_data_get(), IPSET_OPT_PORT, name, NULL, and opt.

Referenced by ipset_print_proto_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_icmpv6 ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_icmpv6 - print ICMPv6 code name or type/code : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print ICMPv6 code name or type/code name to output buffer.

Return lenght of printed string or error size.

References icmpv6_to_name(), ipset_data_get(), IPSET_OPT_PORT, name, NULL, and opt.

Referenced by ipset_print_proto_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_iface ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

ipset_print_iface - print interface element string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print interface element string to output buffer.

Return lenght of printed string or error size.

References IFNAMSIZ, ipset_data_get(), IPSET_OPT_IFACE, IPSET_OPT_PHYSDEV, name, size, and SNPRINTF_FAILURE.

Referenced by ipset_print_data().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_ip ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t  env 
)

ipset_print_ip - print IPv4|IPv6 address to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print IPv4|IPv6 address, address/cidr or address range to output buffer.

Return lenght of printed string or error size.

References D, flags, nf_inet_addr::ip, ipset_data_family(), ipset_data_get(), IPSET_ENV_RESOLVE, IPSET_OPT_CIDR, IPSET_OPT_CIDR2, IPSET_OPT_IP, IPSET_OPT_IP2, IPSET_OPT_IP_TO, IPSET_RANGE_SEPARATOR, NFPROTO_IPV4, NFPROTO_IPV6, size, and SNPRINTF_FAILURE.

Referenced by ipset_print_data().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_ipaddr ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t  env 
)

ipset_print_ipaddr - print IPv4|IPv6 address to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print IPv4|IPv6 address or address/cidr to output buffer.

Return lenght of printed string or error size.

References flags, nf_inet_addr::ip, ipset_data_family(), ipset_data_get(), IPSET_ENV_RESOLVE, IPSET_OPT_CIDR, IPSET_OPT_CIDR2, IPSET_OPT_IP, IPSET_OPT_IP2, IPSET_OPT_IP_TO, NFPROTO_IPV4, and NFPROTO_IPV6.

Here is the call graph for this function:

int ipset_print_mark ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_mark - print mark to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print mark to output buffer.

Return lenght of printed string or error size.

References ipset_data_get(), IPSET_OPT_MARK, IPSET_OPT_MARKMASK, mark, opt, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_name ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

ipset_print_name - print setname element string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print setname element string to output buffer.

Return lenght of printed string or error size.

References ipset_data_flags_test(), ipset_data_get(), IPSET_FLAG, IPSET_FLAG_BEFORE, IPSET_MAXNAMELEN, IPSET_OPT_FLAGS, IPSET_OPT_NAME, IPSET_OPT_NAMEREF, name, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_number ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

ipset_print_number - print number to string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print number to output buffer.

Return lenght of printed string or error size.

References D, ipset_data_get(), and ipset_data_sizeof().

Referenced by ipset_print_data().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_port ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_port - print port or port range : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print port or port range to output buffer.

Return lenght of printed string or error size.

References ipset_data_get(), IPSET_OPT_PORT, IPSET_OPT_PORT_TO, IPSET_RANGE_SEPARATOR, opt, size, and SNPRINTF_FAILURE.

Referenced by ipset_print_data(), and ipset_print_proto_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_proto ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_proto - print protocol name : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print protocol name to output buffer.

Return lenght of printed string or error size.

References ipset_data_get(), IPSET_OPT_PROTO, and opt.

Referenced by ipset_print_proto_port().

Here is the call graph for this function:

Here is the caller graph for this function:

int ipset_print_proto_port ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt opt  ASSERT_UNUSED,
uint8_t env  UNUSED 
)

ipset_print_proto_port - print proto:port : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print protocol and port to output buffer.

Return lenght of printed string or error size.

References IPPROTO_SCTP, IPPROTO_UDPLITE, ipset_data_flags_test(), ipset_data_get(), IPSET_FLAG, IPSET_OPT_PORT, IPSET_OPT_PROTO, ipset_print_icmp(), ipset_print_icmpv6(), ipset_print_port(), ipset_print_proto(), IPSET_PROTO_SEPARATOR, opt, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_skbmark ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

References ipset_data_get(), IPSET_OPT_SKBMARK, mark, mask, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_skbprio ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

References ipset_data_get(), IPSET_OPT_SKBPRIO, size, and SNPRINTF_FAILURE.

Here is the call graph for this function:

int ipset_print_type ( char *  buf,
unsigned int  len,
const struct ipset_data data,
enum ipset_opt  opt,
uint8_t env  UNUSED 
)

ipset_print_type - print ipset type string : printing buffer : length of available buffer space : data blob : the option kind : environment flags

Print ipset module string identifier to output buffer.

Return lenght of printed string or error size.

References ipset_data_get(), IPSET_OPT_TYPE, ipset_type::name, and type.

Referenced by ipset_print_data().

Here is the call graph for this function:

Here is the caller graph for this function: