diff options
author | Rich Fought <Rich.Fought@watchguard.com> | 2012-10-16 19:13:33 (GMT) |
---|---|---|
committer | Rich Fought <Rich.Fought@watchguard.com> | 2012-10-16 19:13:33 (GMT) |
commit | 2d707513c6d5e83df9e3bcf5d006ca9c819a1f07 (patch) | |
tree | af9313429099a92ce4f6305295d9aa1603ae3097 /lib | |
parent | 07418658a6dae7243f2b7d51aebe9ad0299b40ad (diff) | |
download | libnl-2d707513c6d5e83df9e3bcf5d006ca9c819a1f07.zip libnl-2d707513c6d5e83df9e3bcf5d006ca9c819a1f07.tar.gz libnl-2d707513c6d5e83df9e3bcf5d006ca9c819a1f07.tar.bz2 |
Updated nfnetlink includes; removed ifdefs; added delete exp program
Diffstat (limited to 'lib')
-rw-r--r-- | lib/netfilter/exp.c | 28 | ||||
-rw-r--r-- | lib/netfilter/exp_obj.c | 33 |
2 files changed, 6 insertions, 55 deletions
diff --git a/lib/netfilter/exp.c b/lib/netfilter/exp.c index cbe1b95..05bc044 100644 --- a/lib/netfilter/exp.c +++ b/lib/netfilter/exp.c @@ -1,5 +1,5 @@ /* - * lib/netfilter/ct.c Conntrack Expectation + * lib/netfilter/exp.c Conntrack Expectation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -10,6 +10,7 @@ * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation * Copyright (c= 2008 Patrick McHardy <kaber@trash.net> + * Copyright (c) 2012 Rich Fought <rich.fought@watchguard.com> */ /** @@ -37,17 +38,11 @@ static struct nla_policy exp_policy[CTA_EXPECT_MAX+1] = { [CTA_EXPECT_TIMEOUT] = { .type = NLA_U32 }, [CTA_EXPECT_ID] = { .type = NLA_U32 }, [CTA_EXPECT_HELP_NAME] = { .type = NLA_STRING }, -#ifdef NLE_ZONE [CTA_EXPECT_ZONE] = { .type = NLA_U16 }, // Added in kernel 2.6.34 -#endif -#ifdef NLE_FLAGS [CTA_EXPECT_FLAGS] = { .type = NLA_U32 }, // Added in kernel 2.6.37 -#endif -#ifdef NLE_NAT_FN_CLASS [CTA_EXPECT_CLASS] = { .type = NLA_U32 }, // Added in kernel 3.5 [CTA_EXPECT_NAT] = { .type = NLA_NESTED }, // Added in kernel 3.5 [CTA_EXPECT_FN] = { .type = NLA_STRING }, // Added in kernel 3.5 -#endif }; static struct nla_policy exp_tuple_policy[CTA_TUPLE_MAX+1] = { @@ -74,12 +69,10 @@ static struct nla_policy exp_proto_policy[CTA_PROTO_MAX+1] = { [CTA_PROTO_ICMPV6_CODE] = { .type = NLA_U8 }, }; -#ifdef NLE_NAT_FN_CLASS static struct nla_policy exp_nat_policy[CTA_EXPECT_NAT_MAX+1] = { [CTA_EXPECT_NAT_DIR] = { .type = NLA_U8 }, [CTA_EXPECT_NAT_TUPLE] = { .type = NLA_NESTED }, }; -#endif static int exp_parse_ip(struct nfnl_exp *exp, int tuple, struct nlattr *attr) { @@ -192,7 +185,6 @@ static int exp_parse_tuple(struct nfnl_exp *exp, int tuple, struct nlattr *attr) return 0; } -#ifdef NLE_NAT_FN_CLASS static int exp_parse_nat(struct nfnl_exp *exp, struct nlattr *attr) { struct nlattr *tb[CTA_EXPECT_NAT_MAX+1]; @@ -213,7 +205,6 @@ static int exp_parse_nat(struct nfnl_exp *exp, struct nlattr *attr) return 0; } -#endif int nfnlmsg_exp_group(struct nlmsghdr *nlh) { @@ -265,7 +256,6 @@ int nfnlmsg_exp_parse(struct nlmsghdr *nlh, struct nfnl_exp **result) goto errout; } -#ifdef NLE_NAT_FN_CLASS if (tb[CTA_EXPECT_NAT]) err = exp_parse_nat(exp, tb[CTA_EXPECT_MASK]); if (err < 0) @@ -277,7 +267,6 @@ int nfnlmsg_exp_parse(struct nlmsghdr *nlh, struct nfnl_exp **result) if (tb[CTA_EXPECT_FN]) nfnl_exp_set_fn(exp, nla_data(tb[CTA_EXPECT_FN])); -#endif if (tb[CTA_EXPECT_TIMEOUT]) @@ -289,16 +278,11 @@ int nfnlmsg_exp_parse(struct nlmsghdr *nlh, struct nfnl_exp **result) if (tb[CTA_EXPECT_HELP_NAME]) nfnl_exp_set_helper_name(exp, nla_data(tb[CTA_EXPECT_HELP_NAME])); -#ifdef NLE_ZONE if (tb[CTA_EXPECT_ZONE]) nfnl_exp_set_zone(exp, ntohs(nla_get_u16(tb[CTA_EXPECT_ZONE]))); -#endif -#ifdef NLE_FLAGS if (tb[CTA_EXPECT_FLAGS]) nfnl_exp_set_flags(exp, ntohl(nla_get_u32(tb[CTA_EXPECT_FLAGS]))); -#endif - *result = exp; return 0; @@ -425,7 +409,6 @@ nla_put_failure: return -NLE_MSGSIZE; } -#ifdef NLE_NAT_FN_CLASS static int nfnl_exp_build_nat(struct nl_msg *msg, const struct nfnl_exp *exp) { struct nlattr *nat; @@ -447,7 +430,6 @@ static int nfnl_exp_build_nat(struct nl_msg *msg, const struct nfnl_exp *exp) nla_put_failure: return -NLE_MSGSIZE; } -#endif static int nfnl_exp_build_message(const struct nfnl_exp *exp, int cmd, int flags, struct nl_msg **result) @@ -469,7 +451,6 @@ static int nfnl_exp_build_message(const struct nfnl_exp *exp, int cmd, int flags if ((err = nfnl_exp_build_tuple(msg, exp, CTA_EXPECT_MASK)) < 0) goto err_out; -#ifdef NLE_NAT_FN_CLASS if (nfnl_exp_test_src(exp, NFNL_EXP_TUPLE_NAT)) { if ((err = nfnl_exp_build_nat(msg, exp)) < 0) goto err_out; @@ -481,7 +462,6 @@ static int nfnl_exp_build_message(const struct nfnl_exp *exp, int cmd, int flags if (nfnl_exp_test_fn(exp)) NLA_PUT_STRING(msg, CTA_EXPECT_FN, nfnl_exp_get_fn(exp)); -#endif if (nfnl_exp_test_id(exp)) NLA_PUT_U32(msg, CTA_EXPECT_ID, htonl(nfnl_exp_get_id(exp))); @@ -492,15 +472,11 @@ static int nfnl_exp_build_message(const struct nfnl_exp *exp, int cmd, int flags if (nfnl_exp_test_helper_name(exp)) NLA_PUT_STRING(msg, CTA_EXPECT_HELP_NAME, nfnl_exp_get_helper_name(exp)); -#ifdef NLE_ZONE if (nfnl_exp_test_zone(exp)) NLA_PUT_U16(msg, CTA_EXPECT_ZONE, htons(nfnl_exp_get_zone(exp))); -#endif -#ifdef NLE_FLAGS if (nfnl_exp_test_flags(exp)) NLA_PUT_U32(msg, CTA_EXPECT_FLAGS, htonl(nfnl_exp_get_flags(exp))); -#endif *result = msg; return 0; diff --git a/lib/netfilter/exp_obj.c b/lib/netfilter/exp_obj.c index daf4b09..eeb05b3 100644 --- a/lib/netfilter/exp_obj.c +++ b/lib/netfilter/exp_obj.c @@ -9,6 +9,7 @@ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation + * Copyright (c) 2012 Rich Fought <rich.fought@watchguard.com> */ #include <sys/types.h> @@ -215,10 +216,8 @@ static void exp_dump_tuples(struct nfnl_exp *exp, struct nl_dump_params *p) dump_icmp(p, exp, 0); } -#ifdef NLE_NAT_FN_CLASS if (nfnl_exp_test_nat_dir(exp)) nl_dump(p, "nat dir %s ", exp->exp_nat_dir); -#endif } @@ -255,20 +254,15 @@ static void exp_dump_details(struct nl_object *a, struct nl_dump_params *p) if (nfnl_exp_test_helper_name(exp)) nl_dump(p, "helper %s ", exp->exp_helper_name); -#ifdef NLE_NAT_FN_CLASS if (nfnl_exp_test_fn(exp)) nl_dump(p, "fn %s ", exp->exp_fn); if (nfnl_exp_test_class(exp)) nl_dump(p, "class %u ", nfnl_exp_get_class(exp)); -#endif -#ifdef NLE_ZONE if (nfnl_exp_test_zone(exp)) nl_dump(p, "zone %u ", nfnl_exp_get_zone(exp)); -#endif -#ifdef NLE_FLAGS if (nfnl_exp_test_flags(exp)) nl_dump(p, "<"); #define PRINT_FLAG(str) \ @@ -284,7 +278,6 @@ static void exp_dump_details(struct nl_object *a, struct nl_dump_params *p) if (nfnl_exp_test_flags(exp)) nl_dump(p, ">"); -#endif nl_dump(p, "\n"); } @@ -612,7 +605,6 @@ uint8_t nfnl_exp_get_nat_dir(const struct nfnl_exp *exp) return exp->exp_nat_dir; } -#ifdef NLE_NAT_FN_CLASS #define EXP_GET_TUPLE(e, t) \ (t == NFNL_EXP_TUPLE_MASTER) ? \ &(e->exp_master) : \ @@ -620,13 +612,6 @@ uint8_t nfnl_exp_get_nat_dir(const struct nfnl_exp *exp) &(e->exp_mask) : \ (t == NFNL_EXP_TUPLE_NAT) ? \ &(e->exp_nat) : &(exp->exp_expect) -#else -#define EXP_GET_TUPLE(e, t) \ - (t == NFNL_EXP_TUPLE_MASTER) ? \ - &(e->exp_master) : \ - (t == NFNL_EXP_TUPLE_MASK) ? \ - &(e->exp_mask) : &(exp->exp_expect) -#endif static int exp_get_src_attr(int tuple) { @@ -639,11 +624,9 @@ static int exp_get_src_attr(int tuple) case NFNL_EXP_TUPLE_MASK: attr = EXP_ATTR_MASK_IP_SRC; break; -#ifdef NLE_NAT_FN_CLASS case NFNL_EXP_TUPLE_NAT: attr = EXP_ATTR_NAT_IP_SRC; break; -#endif case NFNL_EXP_TUPLE_EXPECT: default : attr = EXP_ATTR_EXPECT_IP_SRC; @@ -664,11 +647,9 @@ static int exp_get_dst_attr(int tuple) case NFNL_EXP_TUPLE_MASK: attr = EXP_ATTR_MASK_IP_DST; break; -#ifdef NLE_NAT_FN_CLASS case NFNL_EXP_TUPLE_NAT: attr = EXP_ATTR_NAT_IP_DST; break; -#endif case NFNL_EXP_TUPLE_EXPECT: default : attr = EXP_ATTR_EXPECT_IP_DST; @@ -752,11 +733,9 @@ static int exp_get_l4protonum_attr(int tuple) case NFNL_EXP_TUPLE_MASK: attr = EXP_ATTR_MASK_L4PROTO_NUM; break; -#ifdef NLE_NAT_FN_CLASS case NFNL_EXP_TUPLE_NAT: attr = EXP_ATTR_NAT_L4PROTO_NUM; break; -#endif case NFNL_EXP_TUPLE_EXPECT: default : attr = EXP_ATTR_EXPECT_L4PROTO_NUM; @@ -796,11 +775,9 @@ static int exp_get_l4ports_attr(int tuple) case NFNL_EXP_TUPLE_MASK: attr = EXP_ATTR_MASK_L4PROTO_PORTS; break; -#ifdef NLE_NAT_FN_CLASS case NFNL_EXP_TUPLE_NAT: attr = EXP_ATTR_NAT_L4PROTO_PORTS; break; -#endif case NFNL_EXP_TUPLE_EXPECT: default : attr = EXP_ATTR_EXPECT_L4PROTO_PORTS; @@ -849,11 +826,9 @@ static int exp_get_l4icmp_attr(int tuple) case NFNL_EXP_TUPLE_MASK: attr = EXP_ATTR_MASK_L4PROTO_ICMP; break; -#ifdef NLE_NAT_FN_CLASS case NFNL_EXP_TUPLE_NAT: attr = EXP_ATTR_NAT_L4PROTO_ICMP; break; -#endif case NFNL_EXP_TUPLE_EXPECT: default : attr = EXP_ATTR_EXPECT_L4PROTO_ICMP; @@ -906,14 +881,14 @@ uint8_t nfnl_exp_get_icmp_code(const struct nfnl_exp *exp, int tuple) struct nl_object_ops exp_obj_ops = { .oo_name = "netfilter/exp", .oo_size = sizeof(struct nfnl_exp), - .oo_free_data = exp_free_data, + .oo_free_data = exp_free_data, .oo_clone = exp_clone, .oo_dump = { - [NL_DUMP_LINE] = exp_dump_line, + [NL_DUMP_LINE] = exp_dump_line, [NL_DUMP_DETAILS] = exp_dump_details, }, .oo_compare = exp_compare, - .oo_attrs2str = exp_attrs2str, + .oo_attrs2str = exp_attrs2str, }; /** @} */ |