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