9#include <netlink/cli/utils.h> 
   10#include <netlink/cli/exp.h> 
   12#include <linux/netlink.h> 
   14static void print_usage(
void)
 
   17        "Usage: nf-exp-list [OPTION]... [EXPECTATION ENTRY]\n" 
   20        " -f, --format=TYPE     Output format { brief | details }\n" 
   21        " -h, --help            Show this help\n" 
   22        " -v, --version         Show versioning information\n" 
   24        "Expectation Selection\n" 
   25        " -i, --id=NUM                Identifier\n" 
   26        "     --expect-proto=PROTOCOL Expectation protocol\n" 
   27        "     --expect-src=ADDR       Expectation source address\n" 
   28        "     --expect-sport=PORT     Expectation source port\n" 
   29        "     --expect-dst=ADDR       Expectation destination address\n" 
   30        "     --expect-dport=PORT     Expectation destination port\n" 
   31        "     --master-proto=PROTOCOL Master conntrack protocol\n" 
   32        "     --master-src=ADDR       Master conntrack source address\n" 
   33        "     --master-sport=PORT     Master conntrack source port\n" 
   34        "     --master-dst=ADDR       Master conntrack destination address\n" 
   35        "     --master-dport=PORT     Master conntrack destination port\n" 
   36        " -F, --family=FAMILY         Address family\n" 
   37        "     --timeout=NUM           Timeout value\n" 
   38        "     --helper=STRING         Helper Name\n" 
   44int main(
int argc, 
char *argv[])
 
   47        struct nl_cache *exp_cache;
 
   54        exp = nl_cli_exp_alloc();
 
   75                static struct option long_opts[] = {
 
   76                        { 
"format", 1, 0, 
'f' },
 
   77                        { 
"help", 0, 0, 
'h' },
 
   78                        { 
"version", 0, 0, 
'v' },
 
   80                        { 
"expect-proto", 1, 0, ARG_EXPECT_PROTO },
 
   81                        { 
"expect-src", 1, 0, ARG_EXPECT_SRC },
 
   82                        { 
"expect-sport", 1, 0, ARG_EXPECT_SPORT },
 
   83                        { 
"expect-dst", 1, 0, ARG_EXPECT_DST },
 
   84                        { 
"expect-dport", 1, 0, ARG_EXPECT_DPORT },
 
   85                        { 
"master-proto", 1, 0, ARG_MASTER_PROTO },
 
   86                        { 
"master-src", 1, 0, ARG_MASTER_SRC },
 
   87                        { 
"master-sport", 1, 0, ARG_MASTER_SPORT },
 
   88                        { 
"master-dst", 1, 0, ARG_MASTER_DST },
 
   89                        { 
"master-dport", 1, 0, ARG_MASTER_DPORT },
 
   90                        { 
"family", 1, 0, 
'F' },
 
   91                        { 
"timeout", 1, 0, ARG_TIMEOUT },
 
   92                        { 
"helper", 1, 0, ARG_HELPER_NAME },
 
   93                        { 
"flags", 1, 0, ARG_FLAGS},
 
   97                c = getopt_long(argc, argv, 
"46f:hvi:p:F:", long_opts, &optidx);
 
  102                case '?': exit(NLE_INVAL);
 
  103                case '4': nfnl_exp_set_family(exp, AF_INET); 
break;
 
  104                case '6': nfnl_exp_set_family(exp, AF_INET6); 
break;
 
  105                case 'f': params.
dp_type = nl_cli_parse_dumptype(optarg); 
break;
 
  106                case 'h': print_usage(); 
break;
 
  107                case 'v': nl_cli_print_version(); 
break;
 
  108                case 'i': nl_cli_exp_parse_id(exp, optarg); 
break;
 
  109                case ARG_EXPECT_PROTO: nl_cli_exp_parse_l4protonum(exp, NFNL_EXP_TUPLE_EXPECT, optarg); 
break;
 
  110                case ARG_EXPECT_SRC: nl_cli_exp_parse_src(exp, NFNL_EXP_TUPLE_EXPECT, optarg); 
break;
 
  111                case ARG_EXPECT_SPORT: nl_cli_exp_parse_src_port(exp, NFNL_EXP_TUPLE_EXPECT, optarg); 
break;
 
  112                case ARG_EXPECT_DST: nl_cli_exp_parse_dst(exp, NFNL_EXP_TUPLE_EXPECT, optarg); 
break;
 
  113                case ARG_EXPECT_DPORT: nl_cli_exp_parse_dst_port(exp, NFNL_EXP_TUPLE_EXPECT, optarg); 
break;
 
  114                case ARG_MASTER_PROTO: nl_cli_exp_parse_l4protonum(exp, NFNL_EXP_TUPLE_MASTER, optarg); 
break;
 
  115                case ARG_MASTER_SRC: nl_cli_exp_parse_src(exp, NFNL_EXP_TUPLE_MASTER, optarg); 
break;
 
  116                case ARG_MASTER_SPORT: nl_cli_exp_parse_src_port(exp, NFNL_EXP_TUPLE_MASTER, optarg); 
break;
 
  117                case ARG_MASTER_DST: nl_cli_exp_parse_dst(exp, NFNL_EXP_TUPLE_MASTER, optarg); 
break;
 
  118                case ARG_MASTER_DPORT: nl_cli_exp_parse_dst_port(exp, NFNL_EXP_TUPLE_MASTER, optarg); 
break;
 
  119                case 'F': nl_cli_exp_parse_family(exp, optarg); 
break;
 
  120                case ARG_TIMEOUT: nl_cli_exp_parse_timeout(exp, optarg); 
break;
 
  121                case ARG_HELPER_NAME: nl_cli_exp_parse_helper_name(exp, optarg); 
break;
 
  122                case ARG_FLAGS: nl_cli_exp_parse_flags(exp, optarg); 
break;
 
  126        sock = nl_cli_alloc_socket();
 
  127        nl_cli_connect(sock, NETLINK_NETFILTER);
 
  128        exp_cache = nl_cli_exp_alloc_cache(sock);
 
void nl_cache_dump_filter(struct nl_cache *cache, struct nl_dump_params *params, struct nl_object *filter)
Dump all elements of a cache (filtered).
 
@ NL_DUMP_LINE
Dump object briefly on one line.
 
enum nl_dump_type dp_type
Specifies the type of dump that is requested.