From 467d0806fd1b13b44286afdf4ea646237522ca56 Mon Sep 17 00:00:00 2001 From: laforge Date: Sun, 17 Feb 2002 21:28:51 +0000 Subject: dscp fixes --- extensions/libipt_DSCP.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'extensions/libipt_DSCP.c') diff --git a/extensions/libipt_DSCP.c b/extensions/libipt_DSCP.c index 4ac8960..12fa4cb 100644 --- a/extensions/libipt_DSCP.c +++ b/extensions/libipt_DSCP.c @@ -17,11 +17,6 @@ #include #include -struct finfo { - struct ipt_entry_target t; - u_int8_t dscp; -}; - static void init(struct ipt_entry_target *t, unsigned int *nfcache) { } @@ -42,7 +37,7 @@ static struct option opts[] = { }; static void -parse_dscp(const unsigned char *s, struct ipt_DSCP_info *finfo) +parse_dscp(const unsigned char *s, struct ipt_DSCP_info *dinfo) { unsigned int dscp; @@ -50,11 +45,11 @@ parse_dscp(const unsigned char *s, struct ipt_DSCP_info *finfo) exit_error(PARAMETER_PROBLEM, "Invalid dscp `%s'\n", s); - if (dscp & ~IPT_DSCP_MASK) { + if (dscp > IPT_DSCP_MAX) exit_error(PARAMETER_PROBLEM, "DSCP `%d` out of range\n", dscp); - finfo->dscp = (u_int8_t )ftos; + dinfo->dscp = (u_int8_t )dscp; return; } @@ -63,7 +58,7 @@ parse(int c, char **argv, int invert, unsigned int *flags, const struct ipt_entry *entry, struct ipt_entry_target **target) { - struct ipt_DSCP_info *finfo + struct ipt_DSCP_info *dinfo = (struct ipt_DSCP_info *)(*target)->data; switch (c) { @@ -71,7 +66,7 @@ parse(int c, char **argv, int invert, unsigned int *flags, if (*flags) exit_error(PARAMETER_PROBLEM, "DSCP target: Only use --set-dscp ONCE!"); - parse_dscp(optarg, finfo); + parse_dscp(optarg, dinfo); *flags = 1; break; @@ -91,7 +86,7 @@ final_check(unsigned int flags) } static void -print_dscp(u_int8_t ftos, int numeric) +print_dscp(u_int8_t dscp, int numeric) { printf("0x%02x ", dscp); } @@ -102,20 +97,20 @@ print(const struct ipt_ip *ip, const struct ipt_entry_target *target, int numeric) { - const struct ipt_DSCP_info *finfo = + const struct ipt_DSCP_info *dinfo = (const struct ipt_DSCP_info *)target->data; printf("DSCP set "); - print_dscp(finfo->ftos, numeric); + print_dscp(dinfo->dscp, numeric); } /* Saves the union ipt_targinfo in parsable form to stdout. */ static void save(const struct ipt_ip *ip, const struct ipt_entry_target *target) { - const struct ipt_DSCP_info *finfo = + const struct ipt_DSCP_info *dinfo = (const struct ipt_DSCP_info *)target->data; - printf("--set-dscp 0x%02x ", finfo->ftos); + printf("--set-dscp 0x%02x ", dinfo->dscp); } static -- cgit v1.2.3