diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2017-03-24 06:32:41 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-24 06:32:41 +0000 |
commit | e20d6bf62b07e455e15b3d8982fb83dc99b9e564 (patch) | |
tree | 4400fe0ba9baae676633293796954b4061726d5d /extensions/libxt_dscp.c | |
parent | a1ffd5ecfa5d72c6dc4cfaf11653d61e3e9083bc (diff) | |
parent | ff45753ae3c3108c6c93ec132f7cf62190f9c628 (diff) | |
download | platform_external_iptables-e20d6bf62b07e455e15b3d8982fb83dc99b9e564.tar.gz platform_external_iptables-e20d6bf62b07e455e15b3d8982fb83dc99b9e564.tar.bz2 platform_external_iptables-e20d6bf62b07e455e15b3d8982fb83dc99b9e564.zip |
Merge changes from topic 'iptables-1.6.1' am: c784fc47e6
am: ff45753ae3
Change-Id: Ic463667ae6ac346f8eae4b6ca18888dcd24b9d6d
Diffstat (limited to 'extensions/libxt_dscp.c')
-rw-r--r-- | extensions/libxt_dscp.c | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/extensions/libxt_dscp.c b/extensions/libxt_dscp.c index 02b22a4e..d5c73236 100644 --- a/extensions/libxt_dscp.c +++ b/extensions/libxt_dscp.c @@ -91,21 +91,66 @@ static void dscp_save(const void *ip, const struct xt_entry_match *match) printf("%s --dscp 0x%02x", dinfo->invert ? " !" : "", dinfo->dscp); } -static struct xtables_match dscp_match = { - .family = NFPROTO_UNSPEC, - .name = "dscp", - .version = XTABLES_VERSION, - .size = XT_ALIGN(sizeof(struct xt_dscp_info)), - .userspacesize = XT_ALIGN(sizeof(struct xt_dscp_info)), - .help = dscp_help, - .print = dscp_print, - .save = dscp_save, - .x6_parse = dscp_parse, - .x6_fcheck = dscp_check, - .x6_options = dscp_opts, +static int __dscp_xlate(struct xt_xlate *xl, + const struct xt_xlate_mt_params *params) +{ + const struct xt_dscp_info *dinfo = + (const struct xt_dscp_info *)params->match->data; + + xt_xlate_add(xl, "dscp %s0x%02x", dinfo->invert ? "!= " : "", + dinfo->dscp); + + return 1; +} + +static int dscp_xlate(struct xt_xlate *xl, + const struct xt_xlate_mt_params *params) +{ + xt_xlate_add(xl, "ip "); + + return __dscp_xlate(xl, params); +} + +static int dscp_xlate6(struct xt_xlate *xl, + const struct xt_xlate_mt_params *params) +{ + xt_xlate_add(xl, "ip6 "); + + return __dscp_xlate(xl, params); +} + +static struct xtables_match dscp_mt_reg[] = { + { + .family = NFPROTO_IPV4, + .name = "dscp", + .version = XTABLES_VERSION, + .size = XT_ALIGN(sizeof(struct xt_dscp_info)), + .userspacesize = XT_ALIGN(sizeof(struct xt_dscp_info)), + .help = dscp_help, + .print = dscp_print, + .save = dscp_save, + .x6_parse = dscp_parse, + .x6_fcheck = dscp_check, + .x6_options = dscp_opts, + .xlate = dscp_xlate, + }, + { + .family = NFPROTO_IPV6, + .name = "dscp", + .version = XTABLES_VERSION, + .size = XT_ALIGN(sizeof(struct xt_dscp_info)), + .userspacesize = XT_ALIGN(sizeof(struct xt_dscp_info)), + .help = dscp_help, + .print = dscp_print, + .save = dscp_save, + .x6_parse = dscp_parse, + .x6_fcheck = dscp_check, + .x6_options = dscp_opts, + .xlate = dscp_xlate6, + }, }; void _init(void) { - xtables_register_match(&dscp_match); + xtables_register_matches(dscp_mt_reg, ARRAY_SIZE(dscp_mt_reg)); } |