Woops sorry, Missed a couple of return statements from the last patch
Here is a fixed one. Iain --- libipt_DSCP.c.orig Wed Apr 10 18:03:53 2002 +++ libipt_DSCP.c Wed Apr 10 18:03:43 2002 @@ -6,7 +6,7 @@ * This program is distributed under the terms of GNU GPL v2, 1991 * * libipt_DSCP.c borrowed heavily from libipt_TOS.c - * + * --set-class added by Iain Barnes */ #include <stdio.h> #include <string.h> @@ -17,6 +17,32 @@ #include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv4/ipt_DSCP.h> + +#define EF 46 +#define BE 0 + +static struct ds_class +{ + char *class; + unsigned int dscp; +} af_classes[] = +{ + { "AF11", 10 }, + { "AF12", 12 }, + { "AF13", 14 }, + { "AF21", 18 }, + { "AF22", 20 }, + { "AF23", 22 }, + { "AF31", 26 }, + { "AF32", 28 }, + { "AF33", 30 }, + { "AF41", 34 }, + { "AF42", 36 }, + { "AF43", 38 } +}; + + + static void init(struct ipt_entry_target *t, unsigned int *nfcache) { } @@ -28,11 +54,17 @@ " --set-dscp value Set DSCP field in packet header to value\n" " This value can be in decimal (ex: 32)\n" " or in hex (ex: 0x20)\n" +" --set-class class Set the DSCP field in packet header to the va lue\n" +" represented by the DiffServ class value.\n" +" This class may be EF,BE or any of the AFxx cl asses.\n" +"\n" +" These two options are mutually exclusive !\n" ); } static struct option opts[] = { { "set-dscp", 1, 0, 'F' }, + { "set-class", 1, 0, 'G' }, { 0 } }; @@ -53,6 +85,31 @@ return; } + +static void +parse_class(const unsigned char *s, struct ipt_DSCP_info *dinfo) +{ + int i; + + if (strncasecmp(s, "EF", 2) == 0) { + dinfo->dscp = (u_int8_t)EF; + return; + } else if (strncasecmp(s, "BE", 2) == 0) { + dinfo->dscp = (u_int8_t)BE; + return; + } else { + for (i = 0; i < sizeof(af_classes) / sizeof(struct ds_class); i++) { + if (strncasecmp(s, af_classes[i].class, 4) == 0) { + dinfo->dscp = (u_int8_t)af_classes[i].dscp; + return; + } + } + } + + exit_error(PARAMETER_PROBLEM, "Invalid DSCP class value '%s'", s); +}
dscp.diff
Description: Binary data