libnl 3.7.0
exp.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
4 * Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
5 * Copyright (c) 2007 Secure Computing Corporation
6 * Copyright (c) 2012 Rich Fought <rich.fought@watchguard.com>
7 */
8
9#ifndef NETLINK_EXP_H_
10#define NETLINK_EXP_H_
11
12#include <netlink/netlink.h>
13#include <netlink/addr.h>
14#include <netlink/cache.h>
15#include <netlink/msg.h>
16
17#include <linux/version.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23struct nfnl_exp;
24
25enum nfnl_exp_tuples {
26 NFNL_EXP_TUPLE_EXPECT,
27 NFNL_EXP_TUPLE_MASTER,
28 NFNL_EXP_TUPLE_MASK,
29 NFNL_EXP_TUPLE_NAT,
30 NFNL_EXP_TUPLE_MAX
31};
32
33extern struct nl_object_ops exp_obj_ops;
34
35extern struct nfnl_exp * nfnl_exp_alloc(void);
36extern int nfnl_exp_alloc_cache(struct nl_sock *, struct nl_cache **);
37
38extern int nfnlmsg_exp_group(struct nlmsghdr *);
39extern int nfnlmsg_exp_parse(struct nlmsghdr *, struct nfnl_exp **);
40
41extern void nfnl_exp_get(struct nfnl_exp *);
42extern void nfnl_exp_put(struct nfnl_exp *);
43
44extern int nfnl_exp_dump_request(struct nl_sock *);
45
46extern int nfnl_exp_build_add_request(const struct nfnl_exp *, int,
47 struct nl_msg **);
48extern int nfnl_exp_add(struct nl_sock *, const struct nfnl_exp *, int);
49
50extern int nfnl_exp_build_delete_request(const struct nfnl_exp *, int,
51 struct nl_msg **);
52extern int nfnl_exp_del(struct nl_sock *, const struct nfnl_exp *, int);
53
54extern int nfnl_exp_build_query_request(const struct nfnl_exp *, int,
55 struct nl_msg **);
56extern int nfnl_exp_query(struct nl_sock *, const struct nfnl_exp *, int);
57
58extern void nfnl_exp_set_family(struct nfnl_exp *, uint8_t);
59extern uint8_t nfnl_exp_get_family(const struct nfnl_exp *);
60
61extern void nfnl_exp_set_timeout(struct nfnl_exp *, uint32_t);
62extern int nfnl_exp_test_timeout(const struct nfnl_exp *);
63extern uint32_t nfnl_exp_get_timeout(const struct nfnl_exp *);
64
65extern void nfnl_exp_set_id(struct nfnl_exp *, uint32_t);
66extern int nfnl_exp_test_id(const struct nfnl_exp *);
67extern uint32_t nfnl_exp_get_id(const struct nfnl_exp *);
68
69extern int nfnl_exp_set_helper_name(struct nfnl_exp *, void *);
70extern int nfnl_exp_test_helper_name(const struct nfnl_exp *);
71extern const char * nfnl_exp_get_helper_name(const struct nfnl_exp *);
72
73extern void nfnl_exp_set_zone(struct nfnl_exp *, uint16_t);
74extern int nfnl_exp_test_zone(const struct nfnl_exp *);
75extern uint16_t nfnl_exp_get_zone(const struct nfnl_exp *);
76
77extern void nfnl_exp_set_flags(struct nfnl_exp *, uint32_t);
78extern int nfnl_exp_test_flags(const struct nfnl_exp *);
79extern void nfnl_exp_unset_flags(struct nfnl_exp *exp, uint32_t flags);
80extern uint32_t nfnl_exp_get_flags(const struct nfnl_exp *);
81extern char * nfnl_exp_flags2str(int flags, char *buf, size_t len);
82int nfnl_exp_str2flags(const char *name);
83
84extern void nfnl_exp_set_class(struct nfnl_exp *, uint32_t);
85extern int nfnl_exp_test_class(const struct nfnl_exp *);
86extern uint32_t nfnl_exp_get_class(const struct nfnl_exp *);
87
88extern int nfnl_exp_set_fn(struct nfnl_exp *, void *);
89extern int nfnl_exp_test_fn(const struct nfnl_exp *);
90extern const char * nfnl_exp_get_fn(const struct nfnl_exp *);
91
92extern void nfnl_exp_set_nat_dir(struct nfnl_exp *, uint8_t);
93extern int nfnl_exp_test_nat_dir(const struct nfnl_exp *);
94extern uint8_t nfnl_exp_get_nat_dir(const struct nfnl_exp *);
95
96// The int argument specifies which nfnl_exp_dir (expect, master, mask or nat)
97// Expectation objects only use orig, not reply
98
99extern int nfnl_exp_set_src(struct nfnl_exp *, int, struct nl_addr *);
100extern int nfnl_exp_test_src(const struct nfnl_exp *, int);
101extern struct nl_addr * nfnl_exp_get_src(const struct nfnl_exp *, int);
102
103extern int nfnl_exp_set_dst(struct nfnl_exp *, int, struct nl_addr *);
104extern int nfnl_exp_test_dst(const struct nfnl_exp *, int);
105extern struct nl_addr * nfnl_exp_get_dst(const struct nfnl_exp *, int);
106
107extern void nfnl_exp_set_l4protonum(struct nfnl_exp *, int, uint8_t);
108extern int nfnl_exp_test_l4protonum(const struct nfnl_exp *, int);
109extern uint8_t nfnl_exp_get_l4protonum(const struct nfnl_exp *, int);
110
111extern void nfnl_exp_set_ports(struct nfnl_exp *, int, uint16_t, uint16_t);
112extern int nfnl_exp_test_ports(const struct nfnl_exp *, int);
113extern uint16_t nfnl_exp_get_src_port(const struct nfnl_exp *, int);
114extern uint16_t nfnl_exp_get_dst_port(const struct nfnl_exp *, int);
115
116extern void nfnl_exp_set_icmp(struct nfnl_exp *, int, uint16_t, uint8_t, uint8_t);
117extern int nfnl_exp_test_icmp(const struct nfnl_exp *, int);
118extern uint16_t nfnl_exp_get_icmp_id(const struct nfnl_exp *, int);
119extern uint8_t nfnl_exp_get_icmp_type(const struct nfnl_exp *, int);
120extern uint8_t nfnl_exp_get_icmp_code(const struct nfnl_exp *, int);
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
int nfnl_exp_alloc_cache(struct nl_sock *, struct nl_cache **)
Build a expectation cache holding all expectations currently in the kernel.
Definition: exp.c:575
int nfnl_exp_dump_request(struct nl_sock *)
Send nfnl exp dump request.
Definition: exp.c:309