? .servconf.c.swp
? .ssh-keyscan.c.swp
Index: defines.h
===================================================================
RCS file: /cvs/openssh/defines.h,v
retrieving revision 1.159
diff -u -p -r1.159 defines.h
--- defines.h	13 Jan 2010 23:44:34 -0000	1.159
+++ defines.h	9 Mar 2010 03:35:40 -0000
@@ -50,6 +50,35 @@ enum
 # define IPTOS_MINCOST           IPTOS_LOWCOST
 #endif /* IPTOS_LOWDELAY */
 
+/* in glibc 2.12 */
+#ifndef IPTOS_CLASS_CS0
+#define IPTOS_CLASS_CS0         0x00
+#define IPTOS_CLASS_CS1         0x20
+#define IPTOS_CLASS_CS2         0x40
+#define IPTOS_CLASS_CS3         0x60
+#define IPTOS_CLASS_CS4         0x80
+#define IPTOS_CLASS_CS5         0xa0
+#define IPTOS_CLASS_CS6         0xc0
+#define IPTOS_CLASS_CS7         0xe0
+#endif
+
+/* in glibc 2.11 */
+#ifndef IPTOS_DSCP_AF11
+#define IPTOS_DSCP_AF11         0x28
+#define IPTOS_DSCP_AF12         0x30
+#define IPTOS_DSCP_AF13         0x38
+#define IPTOS_DSCP_AF21         0x48
+#define IPTOS_DSCP_AF22         0x50
+#define IPTOS_DSCP_AF23         0x58
+#define IPTOS_DSCP_AF31         0x68
+#define IPTOS_DSCP_AF32         0x70
+#define IPTOS_DSCP_AF33         0x78
+#define IPTOS_DSCP_AF41         0x88
+#define IPTOS_DSCP_AF42         0x90
+#define IPTOS_DSCP_AF43         0x98
+#define IPTOS_DSCP_EF           0xb8
+#endif
+
 #ifndef MAXPATHLEN
 # ifdef PATH_MAX
 #  define MAXPATHLEN PATH_MAX
Index: packet.c
===================================================================
RCS file: /cvs/openssh/packet.c,v
retrieving revision 1.169
diff -u -p -r1.169 packet.c
--- packet.c	2 Oct 2009 01:49:04 -0000	1.169
+++ packet.c	9 Mar 2010 03:35:40 -0000
@@ -78,6 +78,7 @@
 #include "misc.h"
 #include "ssh.h"
 #include "roaming.h"
+#include "readconf.h"
 
 #ifdef PACKET_DEBUG
 #define DBG(x) x
@@ -87,6 +88,8 @@
 
 #define PACKET_MAX_SIZE (256 * 1024)
 
+extern Options options;
+
 struct packet_state {
 	u_int32_t seqnr;
 	u_int32_t packets;
@@ -1731,7 +1734,7 @@ static void
 packet_set_tos(int interactive)
 {
 #if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
-	int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT;
+	int tos = interactive ? options.use_qos[1] : options.use_qos[0];
 
 	if (!packet_connection_is_on_socket() ||
 	    !packet_connection_is_ipv4())
Index: readconf.c
===================================================================
RCS file: /cvs/openssh/readconf.c,v
retrieving revision 1.162
diff -u -p -r1.162 readconf.c
--- readconf.c	11 Feb 2010 22:21:03 -0000	1.162
+++ readconf.c	9 Mar 2010 03:35:40 -0000
@@ -131,6 +131,7 @@ typedef enum {
 	oSendEnv, oControlPath, oControlMaster, oHashKnownHosts,
 	oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
 	oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication,
+	oUseQoS,
 	oDeprecated, oUnsupported
 } OpCodes;
 
@@ -231,6 +232,7 @@ static struct {
 	{ "permitlocalcommand", oPermitLocalCommand },
 	{ "visualhostkey", oVisualHostKey },
 	{ "useroaming", oUseRoaming },
+	{ "useqos", oUseQoS},
 #ifdef JPAKE
 	{ "zeroknowledgepasswordauthentication",
 	    oZeroKnowledgePasswordAuthentication },
@@ -323,6 +325,49 @@ parse_token(const char *cp, const char *
 	return oBadOption;
 }
 
+struct {
+	const char *name;
+	int value;
+} qos[] = {
+	{ "cs0",	IPTOS_CLASS_CS0 },
+	{ "cs1",	IPTOS_CLASS_CS1 },
+	{ "cs2",	IPTOS_CLASS_CS2 },
+	{ "cs3",	IPTOS_CLASS_CS3 },
+	{ "cs4",	IPTOS_CLASS_CS4 },
+	{ "cs5",	IPTOS_CLASS_CS5 },
+	{ "cs6",	IPTOS_CLASS_CS6 },
+	{ "cs7",	IPTOS_CLASS_CS7 },
+	{ "af11",	IPTOS_DSCP_AF11 },
+	{ "af12",	IPTOS_DSCP_AF12 },
+	{ "af13",	IPTOS_DSCP_AF13 },
+	{ "af21",	IPTOS_DSCP_AF21 },
+	{ "af22",	IPTOS_DSCP_AF22 },
+	{ "af23",	IPTOS_DSCP_AF23 },
+	{ "af31",	IPTOS_DSCP_AF31 },
+	{ "af32",	IPTOS_DSCP_AF32 },
+	{ "af33",	IPTOS_DSCP_AF33 },
+	{ "af41",	IPTOS_DSCP_AF41 },
+	{ "af42",	IPTOS_DSCP_AF42 },
+	{ "af43",	IPTOS_DSCP_AF43 },
+	{ "ef",	  	IPTOS_DSCP_EF   },
+	{ "lowdelay",	IPTOS_LOWDELAY  },
+	{ "throughput",	IPTOS_THROUGHPUT },
+	{ "reliability", IPTOS_RELIABILITY },
+	{ "lowcost",	IPTOS_LOWCOST   },
+	{ "mincost",	IPTOS_MINCOST   },
+	{ NULL,		-1              },
+};
+
+static int parse_qos(const char *cp)
+{
+	u_int i;
+
+	for (i = 0; qos[i].name; i++)
+		if (strcasecmp(cp, qos[i].name) == 0)
+			return qos[i].value;
+	return -1;
+}
+
 /*
  * Processes a single option line as used in the configuration files. This
  * only sets those values that have not already been set.
@@ -921,6 +966,27 @@ parse_int:
 		intptr = &options->use_roaming;
 		goto parse_flag;
 
+	case oUseQoS:
+		arg = strdelim(&s);
+		if (arg == NULL || *arg == '\0')
+			fatal("%.200s line %d: Missing non-interactive QoS argument.",
+			    filename, linenum);
+
+		arg2 = strdelim(&s);
+		if (arg2 == NULL || *arg2 == '\0')
+			fatal("%.200s line %d: Missing interactive QoS argument.",
+			    filename, linenum);
+
+		value = parse_qos(arg);
+		value2 = parse_qos(arg2);
+		if (value == -1 || value2 == -1)
+			fatal("%.200s line %d: Bad QoS argument.",
+			    filename, linenum);
+
+		options->use_qos[0] = value;
+		options->use_qos[1] = value2;
+		break;
+
 	case oDeprecated:
 		debug("%s line %d: Deprecated option \"%s\"",
 		    filename, linenum, keyword);
@@ -1071,6 +1137,8 @@ initialize_options(Options * options)
 	options->local_command = NULL;
 	options->permit_local_command = -1;
 	options->use_roaming = -1;
+	options->use_qos[0] = -1;
+	options->use_qos[1] = -1;
 	options->visual_host_key = -1;
 	options->zero_knowledge_password_authentication = -1;
 }
@@ -1219,6 +1287,10 @@ fill_default_options(Options * options)
 	/* options->hostname will be set in the main program if appropriate */
 	/* options->host_key_alias should not be set by default */
 	/* options->preferred_authentications will be set in ssh */
+	if (options->use_qos[0] == -1)
+		options->use_qos[0] = IPTOS_THROUGHPUT;
+	if (options->use_qos[1] == -1)
+		options->use_qos[1] = IPTOS_LOWDELAY;
 }
 
 /*
Index: readconf.h
===================================================================
RCS file: /cvs/openssh/readconf.h,v
retrieving revision 1.74
diff -u -p -r1.74 readconf.h
--- readconf.h	11 Feb 2010 22:21:03 -0000	1.74
+++ readconf.h	9 Mar 2010 03:35:40 -0000
@@ -125,6 +125,8 @@ typedef struct {
 
 	int	use_roaming;
 
+	u_char	use_qos[2];
+
 }       Options;
 
 #define SSHCTL_MASTER_NO	0
Index: servconf.c
===================================================================
RCS file: /cvs/openssh/servconf.c,v
retrieving revision 1.199
diff -u -p -r1.199 servconf.c
--- servconf.c	4 Mar 2010 10:53:35 -0000	1.199
+++ servconf.c	9 Mar 2010 03:35:41 -0000
@@ -131,6 +131,8 @@ initialize_server_options(ServerOptions 
 	options->zero_knowledge_password_authentication = -1;
 	options->revoked_keys_file = NULL;
 	options->trusted_user_ca_keys = NULL;
+	options->use_qos[0] = -1;
+	options->use_qos[1] = -1;
 }
 
 void
@@ -265,6 +267,10 @@ fill_default_server_options(ServerOption
 		options->permit_tun = SSH_TUNMODE_NO;
 	if (options->zero_knowledge_password_authentication == -1)
 		options->zero_knowledge_password_authentication = 0;
+	if (options->use_qos[0] == -1)
+		options->use_qos[0] = IPTOS_THROUGHPUT;
+	if (options->use_qos[1] == -1)
+		options->use_qos[1] = IPTOS_LOWDELAY;
 
 	/* Turn privilege separation on by default */
 	if (use_privsep == -1)
@@ -310,7 +316,7 @@ typedef enum {
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
 	sUsePrivilegeSeparation, sAllowAgentForwarding,
 	sZeroKnowledgePasswordAuthentication, sHostCertificate,
-	sRevokedKeys, sTrustedUserCAKeys,
+	sRevokedKeys, sTrustedUserCAKeys, sUseQoS,
 	sDeprecated, sUnsupported
 } ServerOpCodes;
 
@@ -432,6 +438,7 @@ static struct {
 	{ "hostcertificate", sHostCertificate, SSHCFG_GLOBAL },
 	{ "revokedkeys", sRevokedKeys, SSHCFG_ALL },
 	{ "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
+	{ "useqos", sUseQoS, SSHCFG_ALL },
 	{ NULL, sBadOption, 0 }
 };
 
@@ -467,6 +474,49 @@ parse_token(const char *cp, const char *
 	return sBadOption;
 }
 
+struct {
+	const char *name;
+	int value;
+} qos[] = {
+	{ "cs0",	IPTOS_CLASS_CS0 },
+	{ "cs1",	IPTOS_CLASS_CS1 },
+	{ "cs2",	IPTOS_CLASS_CS2 },
+	{ "cs3",	IPTOS_CLASS_CS3 },
+	{ "cs4",	IPTOS_CLASS_CS4 },
+	{ "cs5",	IPTOS_CLASS_CS5 },
+	{ "cs6",	IPTOS_CLASS_CS6 },
+	{ "cs7",	IPTOS_CLASS_CS7 },
+	{ "af11",	IPTOS_DSCP_AF11 },
+	{ "af12",	IPTOS_DSCP_AF12 },
+	{ "af13",	IPTOS_DSCP_AF13 },
+	{ "af21",	IPTOS_DSCP_AF21 },
+	{ "af22",	IPTOS_DSCP_AF22 },
+	{ "af23",	IPTOS_DSCP_AF23 },
+	{ "af31",	IPTOS_DSCP_AF31 },
+	{ "af32",	IPTOS_DSCP_AF32 },
+	{ "af33",	IPTOS_DSCP_AF33 },
+	{ "af41",	IPTOS_DSCP_AF41 },
+	{ "af42",	IPTOS_DSCP_AF42 },
+	{ "af43",	IPTOS_DSCP_AF43 },
+	{ "ef",	  	IPTOS_DSCP_EF   },
+	{ "lowdelay",	IPTOS_LOWDELAY  },
+	{ "throughput",	IPTOS_THROUGHPUT },
+	{ "reliability", IPTOS_RELIABILITY },
+	{ "lowcost",	IPTOS_LOWCOST   },
+	{ "mincost",	IPTOS_MINCOST   },
+	{ NULL,		-1              },
+};
+
+static int parse_qos(const char *cp)
+{
+	u_int i;
+
+	for (i = 0; qos[i].name; i++)
+		if (strcasecmp(cp, qos[i].name) == 0)
+			return qos[i].value;
+	return -1;
+}
+
 char *
 derelativise_path(const char *path)
 {
@@ -661,8 +711,8 @@ process_server_config_line(ServerOptions
     const char *filename, int linenum, int *activep, const char *user,
     const char *host, const char *address)
 {
-	char *cp, **charptr, *arg, *p;
-	int cmdline = 0, *intptr, value, n;
+	char *cp, **charptr, *arg, *arg2, *p;
+	int cmdline = 0, *intptr, value, value2, n;
 	SyslogFacility *log_facility_ptr;
 	LogLevel *log_level_ptr;
 	ServerOpCodes opcode;
@@ -1335,6 +1385,27 @@ process_server_config_line(ServerOptions
 	case sRevokedKeys:
 		charptr = &options->revoked_keys_file;
 		goto parse_filename;
+
+	case sUseQoS:
+		arg = strdelim(&cp);
+		if (arg == NULL || *arg == '\0')
+			fatal("%.200s line %d: Missing non-interactive QoS argument.",
+			    filename, linenum);
+
+		arg2 = strdelim(&cp);
+		if (arg2 == NULL || *arg2 == '\0')
+			fatal("%.200s line %d: Missing interactive QoS argument.",
+			    filename, linenum);
+
+		value = parse_qos(arg);
+		value2 = parse_qos(arg2);
+		if (value == -1 || value2 == -1)
+			fatal("%.200s line %d: Bad QoS argument.",
+			    filename, linenum);
+
+		options->use_qos[0] = value;
+		options->use_qos[1] = value2;
+		break;
 
 	case sDeprecated:
 		logit("%s line %d: Deprecated option %s",
Index: servconf.h
===================================================================
RCS file: /cvs/openssh/servconf.h,v
retrieving revision 1.84
diff -u -p -r1.84 servconf.h
--- servconf.h	4 Mar 2010 10:53:35 -0000	1.84
+++ servconf.h	9 Mar 2010 03:35:41 -0000
@@ -156,6 +156,8 @@ typedef struct {
 	char   *chroot_directory;
 	char   *revoked_keys_file;
 	char   *trusted_user_ca_keys;
+
+	u_char	use_qos[2];
 }       ServerOptions;
 
 void	 initialize_server_options(ServerOptions *);
Index: ssh_config
===================================================================
RCS file: /cvs/openssh/ssh_config,v
retrieving revision 1.28
diff -u -p -r1.28 ssh_config
--- ssh_config	12 Jan 2010 08:40:27 -0000	1.28
+++ ssh_config	9 Mar 2010 03:35:41 -0000
@@ -45,3 +45,4 @@
 #   PermitLocalCommand no
 #   VisualHostKey no
 #   ProxyCommand ssh -q -W %h:%p gateway.example.com
+#   UseQoS throughput lowdelay
Index: sshd_config
===================================================================
RCS file: /cvs/openssh/sshd_config,v
retrieving revision 1.83
diff -u -p -r1.83 sshd_config
--- sshd_config	11 Oct 2009 10:51:09 -0000	1.83
+++ sshd_config	9 Mar 2010 03:35:41 -0000
@@ -107,6 +107,9 @@
 # no default banner path
 #Banner none
 
+# traditional ToS (deprecated: consider using af12 and cs2)
+#UseQoS throughput lowdelay
+
 # override default of no subsystems
 Subsystem	sftp	/usr/libexec/sftp-server
 

