[netfilter-cvslog] r3500 - in trunk: nfsim/core/ipv4 nfsim/tools nfsim-testsuite

rusty at netfilter.org rusty at netfilter.org
Thu Dec 23 03:36:22 CET 2004


Author: rusty at netfilter.org
Date: 2004-12-23 03:36:21 +0100 (Thu, 23 Dec 2004)
New Revision: 3500

Modified:
   trunk/nfsim-testsuite/things-to-test
   trunk/nfsim/core/ipv4/ipv4.c
   trunk/nfsim/core/ipv4/ipv4.h
   trunk/nfsim/tools/gen_ip.c
Log:
Patches from Nicolas Bouliane:
	Add the 'DSCP=' option to gen_ip.
	Add DSCP logging
	Add IPCT_DSCP flags
	Add tests for DSCP
	Remove DSCP (and length) from things-to-test
Rusty:
	Indented and used '' rather than old-style `'.


Modified: trunk/nfsim/core/ipv4/ipv4.c
===================================================================
--- trunk/nfsim/core/ipv4/ipv4.c	2004-12-23 02:23:13 UTC (rev 3499)
+++ trunk/nfsim/core/ipv4/ipv4.c	2004-12-23 02:36:21 UTC (rev 3500)
@@ -795,7 +795,9 @@
 		ptr += sprintf(ptr, "TTL=%i ", iph->ttl);
 	if (dump_flags && strstr(dump_flags, "tos"))
 		ptr += sprintf(ptr, "TOS=%i ", iph->tos);
-
+	if (dump_flags && strstr(dump_flags, "dscp"))
+		ptr += sprintf(ptr, "DSCP=0x%x ",
+			       (iph->tos >> IPT_DSCP_SHIFT));
 	ptr += sprintf(ptr, "%u.%u.%u.%u %u.%u.%u.%u ",
 		       NIPQUAD(iph->saddr),
 		       NIPQUAD(iph->daddr));

Modified: trunk/nfsim/core/ipv4/ipv4.h
===================================================================
--- trunk/nfsim/core/ipv4/ipv4.h	2004-12-23 02:23:13 UTC (rev 3499)
+++ trunk/nfsim/core/ipv4/ipv4.h	2004-12-23 02:36:21 UTC (rev 3500)
@@ -633,8 +633,8 @@
 
 inline unsigned short ip_compute_csum(unsigned char * buff, int len);
 
-#define __NFSIM_DUMP_TTL	0x01
-#define __NFSIM_DUMP_DATA	0x02
-#define __NFSIM_DUMP_TOS	0x04
+#define IPT_DSCP_MASK   0xfc
+#define IPT_DSCP_SHIFT  2
+#define IPT_DSCP_MAX    0x3f
 
 #endif /* __HAVE_IPV4_H */

Modified: trunk/nfsim/tools/gen_ip.c
===================================================================
--- trunk/nfsim/tools/gen_ip.c	2004-12-23 02:23:13 UTC (rev 3499)
+++ trunk/nfsim/tools/gen_ip.c	2004-12-23 02:36:21 UTC (rev 3500)
@@ -61,7 +61,8 @@
 	int number;
 	char *end;
 
-	number = (int)strtol(s, &end, 10);
+	/* Handle hex, octal, etc. */
+	number = (int)strtol(s, &end, 0);
 	if (*end == '\0' && end != s) {
 		/* we parsed a number, let's see if we want this */
 		if (min <= number && number <= max)
@@ -746,6 +747,25 @@
 		argv++;
 	}
 
+	if (argc > 5 && strncmp(argv[1], "DSCP=", 5) == 0) {
+		if (*dump_flags && strstr(*dump_flags, "tos")) {
+			nfsim_log(LOG_UI,
+				  "You can't use both 'TOS=' and 'DSCP='");
+			return false;
+		}
+
+		if ((tos = string_to_number(argv[1]+5, 0, IPT_DSCP_MAX))==-1) {
+			nfsim_log(LOG_UI, "`%s' not >=0, <= %i",
+				  argv[1]+5, IPT_DSCP_MAX);
+			return false;
+		}
+
+		tos = ((tos << IPT_DSCP_SHIFT) & IPT_DSCP_MASK);
+		*dump_flags = talloc_asprintf_append(*dump_flags, "dscp");
+		argc--;
+		argv++;
+	}
+
 	if (argc > 5 && strncmp(argv[1], "TTL=", 4) == 0) {
 		ttl = atoi(argv[1]+4);
 

Modified: trunk/nfsim-testsuite/things-to-test
===================================================================
--- trunk/nfsim-testsuite/things-to-test	2004-12-23 02:23:13 UTC (rev 3499)
+++ trunk/nfsim-testsuite/things-to-test	2004-12-23 02:36:21 UTC (rev 3500)
@@ -100,20 +100,17 @@
 ip_nat_tftp.c
 ip_nat_snmp_basic.c
 ipt_CLASSIFY.c
-ipt_DSCP.c
 ipt_ECN.c
 ipt_NETMAP.c
 ipt_REDIRECT.c
 ipt_SAME.c
 ipt_TCPMSS.c
-ipt_TOS.c
 ipt_ah.c
 ipt_conntrack.c
 ipt_dscp.c
 ipt_ecn.c
 ipt_esp.c
 ipt_helper.c
-ipt_length.c
 ipt_pkttype.c
 ipt_tcpmss.c
 ---------------------




More information about the netfilter-cvslog mailing list