All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] DSCP match/target patches
@ 2002-06-10 13:49 zenadsl3030
  2002-06-11  7:41 ` Harald Welte
  0 siblings, 1 reply; 4+ messages in thread
From: zenadsl3030 @ 2002-06-10 13:49 UTC (permalink / raw)
  To: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

Hi,

Here is a simple patch to the DSCP match to allow the use of DiffServ class names in the matches, in a similar manner to the target.

Also attached is a one line fix for a typo in the DSCP target where CS6 was defined twice in the match list.

Iain


[-- Attachment #2: libipt_DSCP-target.diff --]
[-- Type: application/octet-stream, Size: 267 bytes --]

--- libipt_DSCP.c.orig	Mon Jun 10 14:35:14 2002
+++ libipt_DSCP.c	Mon Jun 10 14:35:24 2002
@@ -35,7 +35,7 @@
 	{ "CS4",  0x20 },
 	{ "CS5",  0x28 },
 	{ "CS6",  0x30 },
-	{ "CS6",  0x38 },
+	{ "CS7",  0x38 },
 	{ "BE",    0 },
 	{ "AF11", 0x0a },
 	{ "AF12", 0x0c },

[-- Attachment #3: libipt_dscp-match.diff --]
[-- Type: application/octet-stream, Size: 2390 bytes --]

--- libipt_dscp.c.orig	Thu Mar 14 12:19:43 2002
+++ libipt_dscp.c	Mon Jun 10 14:32:38 2002
@@ -9,6 +9,7 @@
  * For a list of DSCP codepoints see 
  * http://www.iana.org/assignments/dscp-registry
  *
+ * DiffServ class support by Iain Barnes.
  */
 #include <stdio.h>
 #include <string.h>
@@ -19,6 +20,39 @@
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv4/ipt_dscp.h>
 
+
+static struct ds_class
+{
+	char *class;
+	unsigned int dscp;
+} ds_classes[] = 
+{
+	{ "CS0", 0 },
+	{ "CS1", 0x08 },
+	{ "CS2", 0x10 },
+	{ "CS3", 0x18 },
+	{ "CS4", 0x20 },
+	{ "CS5", 0x28 },
+	{ "CS6", 0x30 },
+	{ "CS7", 0x38 },
+	{ "BE",  0 },
+	{ "AF11", 0x0a },
+	{ "AF12", 0x0c },
+	{ "AF13", 0x0e },
+	{ "AF21", 0x12 },
+	{ "AF22", 0x14 },
+	{ "AF23", 0x16 },
+	{ "AF31", 0x1a },
+	{ "AF32", 0x1c },
+	{ "AF33", 0x1e },
+	{ "AF41", 0x22 },
+	{ "AF42", 0x24 },
+	{ "AF43", 0x26 },
+	{ "EF", 0x2e }
+};
+
+
+
 static void init(struct ipt_entry_match *m, unsigned int *nfcache) 
 {
 	*nfcache |= NFC_IP_TOS;
@@ -30,12 +64,15 @@
 "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", NETFILTER_VERSION
+"               		or in hex (ex: 0x20)\n"
+"[!] --class name		Match the DiffServ Class names such as\n"
+"				AFxx,BE,EF or CSx\n", NETFILTER_VERSION
 );
 }
 
 static struct option opts[] = {
 	{ "dscp", 1, 0, 'F' },
+	{ "class", 1, 0, 'G' },
 	{ 0 }
 };
 
@@ -56,6 +93,23 @@
     	return;
 }
 
+
+static void
+parse_class(const unsigned char *s, struct ipt_dscp_info *dinfo)
+{
+	int i;
+
+	for(i = 0; i < sizeof(ds_classes) / sizeof(struct ds_class); i++) {
+		if (!strncasecmp (s, ds_classes[i].class,
+					strlen(ds_classes[i].class))) {
+			dinfo->dscp = (u_int8_t)ds_classes[i].dscp;
+			return;
+		}
+	}
+
+	exit_error(PARAMETER_PROBLEM, "Invalid DiffServ class '%s'\n", s);
+}
+
 static int
 parse(int c, char **argv, int invert, unsigned int *flags,
       const struct ipt_entry *entry,
@@ -77,6 +131,18 @@
 		*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;
 	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-06-21 17:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-10 13:49 [PATCH] DSCP match/target patches zenadsl3030
2002-06-11  7:41 ` Harald Welte
2002-06-17 17:50   ` Iain Barnes
2002-06-21 17:28     ` Harald Welte

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.