summaryrefslogtreecommitdiffstats
path: root/extensions/libipt_dscp.c
diff options
context:
space:
mode:
authorlaforge <laforge>2002-06-21 17:35:55 +0000
committerlaforge <laforge>2002-06-21 17:35:55 +0000
commit728f0c5c3820faca398de339b367c3f19b767a69 (patch)
tree98a812cce0e2830992fdb0e1d0dc823416fba355 /extensions/libipt_dscp.c
parent75639251de2321df6bb55abef083c3b140c375e3 (diff)
move DSCP name/value conversion to libipt_dscp_helper.c (Iain Barnes)
Diffstat (limited to 'extensions/libipt_dscp.c')
-rw-r--r--extensions/libipt_dscp.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/extensions/libipt_dscp.c b/extensions/libipt_dscp.c
index 8378815..7718112 100644
--- a/extensions/libipt_dscp.c
+++ b/extensions/libipt_dscp.c
@@ -6,6 +6,8 @@
*
* libipt_dscp.c borrowed heavily from libipt_tos.c
*
+ * --class support added by Iain Barnes
+ *
* For a list of DSCP codepoints see
* http://www.iana.org/assignments/dscp-registry
*
@@ -19,6 +21,9 @@
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_dscp.h>
+/* This is evil, but it's my code - HW*/
+#include "libipt_dscp_helper.c"
+
static void init(struct ipt_entry_match *m, unsigned int *nfcache)
{
*nfcache |= NFC_IP_TOS;
@@ -30,12 +35,18 @@ static void help(void)
"DSCP match v%s options\n"
"[!] --dscp value Match DSCP codepoint with numerical value\n"
" This value can be in decimal (ex: 32)\n"
-" or in hex (ex: 0x20)\n", IPTABLES_VERSION
+" or in hex (ex: 0x20)\n"
+"[!] --class name Match the DiffServ class. This value may\n"
+" be any of the BE,EF, AFxx or CSx classes\n"
+"\n"
+" These two options are mutually exclusive !\n"
+ , IPTABLES_VERSION
);
}
static struct option opts[] = {
{ "dscp", 1, 0, 'F' },
+ { "class", 1, 0, 'G' },
{ 0 }
};
@@ -56,6 +67,17 @@ parse_dscp(const unsigned char *s, struct ipt_dscp_info *dinfo)
return;
}
+
+static void
+parse_class(const char *s, struct ipt_dscp_info *dinfo)
+{
+ unsigned int dscp = class_to_dscp(s);
+
+ /* Assign the value */
+ dinfo->dscp = (u_int8_t)dscp;
+}
+
+
static int
parse(int c, char **argv, int invert, unsigned int *flags,
const struct ipt_entry *entry,
@@ -77,6 +99,17 @@ parse(int c, char **argv, int invert, unsigned int *flags,
*flags = 1;
break;
+ case 'G':
+ if (*flags)
+ exit_error(PARAMETER_PROBLEM,
+ "DSCP match: Only use --class ONCE!");
+ check_inverse(optarg, &invert, &optind, 0);
+ parse_class(argv[optind - 1], dinfo);
+ if (invert)
+ dinfo->invert = 1;
+ *flags = 1;
+ break;
+
default:
return 0;
}