--- include/libbb.h.orig	2008-09-28 20:04:26.000000000 +0200
+++ include/libbb.h	2008-12-19 11:45:09.000000000 +0100
@@ -489,6 +489,7 @@
  * If there is no suffix, port argument is used */
 int create_and_connect_stream_or_die(const char *peer, int port) FAST_FUNC;
 /* Connect to peer identified by lsa */
+int xconnect_stream_with_tc_index(const len_and_sockaddr *lsa, unsigned long tc_index) FAST_FUNC; /* AVM */
 int xconnect_stream(const len_and_sockaddr *lsa) FAST_FUNC;
 /* Return malloc'ed len_and_sockaddr with socket address of host:port
  * Currently will return IPv4 or IPv6 sockaddrs only
--- include/usage.h.orig	2008-12-19 11:45:09.000000000 +0100
+++ include/usage.h	2008-12-19 11:45:09.000000000 +0100
@@ -4552,10 +4552,10 @@
 	USE_GETOPT_LONG( \
        "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document file]\n" \
        "	[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]\n" \
-       "	[-U|--user-agent agent] url" \
+       "	[-U|--user-agent agent] [-t|--traffic-class class] url" \
 	) \
 	SKIP_GETOPT_LONG( \
-       "[-csq] [-O file] [-Y on/off] [-P DIR] [-U agent] url" \
+       "[-csq] [-O file] [-Y on/off] [-P DIR] [-U agent] [-t class] url" \
 	)
 #define wget_full_usage "\n\n" \
        "Retrieve files via HTTP or FTP\n" \
@@ -4567,6 +4567,7 @@
      "\n	-O	Save to filename ('-' for stdout)" \
      "\n	-U	Adjust 'User-Agent' field" \
      "\n	-Y	Use proxy ('on' or 'off')" \
+     "\n	-t	Traffic class" \
 
 #define which_trivial_usage \
        "[COMMAND...]"
--- libbb/xconnect.c.orig	2008-09-28 20:04:20.000000000 +0200
+++ libbb/xconnect.c	2008-12-19 11:45:09.000000000 +0100
@@ -384,3 +384,32 @@
 {
 	return sockaddr2str(sa, NI_NUMERICHOST | IGNORE_PORT);
 }
+
+#if 1 /* AVM */
+/* #include <linux\sockios.h> */ /*  SIOCSET_TC_INDEX */
+#include <sys/ioctl.h>
+#define SIOCSET_TC_INDEX	0x89d0
+
+int FAST_FUNC xconnect_stream_with_tc_index(const len_and_sockaddr *lsa, unsigned long tc_index)
+{
+	int fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0);
+	ioctl(fd, SIOCSET_TC_INDEX, &tc_index);
+	xconnect(fd, &lsa->u.sa, lsa->len);
+	return fd;
+}
+
+int xconnect_with_tc_index(struct sockaddr_in *s_addr, unsigned long tc_index)
+{
+	int s = socket(AF_INET, SOCK_STREAM, 0);
+
+	ioctl(s, SIOCSET_TC_INDEX, &tc_index);
+
+	if (connect(s, (struct sockaddr *)s_addr, sizeof(struct sockaddr_in)) < 0)
+	{
+		if (ENABLE_FEATURE_CLEAN_UP) close(s);
+		bb_perror_msg_and_die("Unable to connect to remote host (%s)",
+				inet_ntoa(s_addr->sin_addr));
+	}
+	return s;
+}
+#endif /* AVM */
--- networking/wget.c.orig	2008-09-28 20:04:11.000000000 +0200
+++ networking/wget.c	2008-12-19 11:45:09.000000000 +0100
@@ -237,15 +237,23 @@
 #endif
 
 
-static FILE *open_socket(len_and_sockaddr *lsa)
+static FILE *open_socket_with_tc_index(len_and_sockaddr *lsa, unsigned long tc_index) /* AVM */
 {
 	FILE *fp;
 
 	/* glibc 2.4 seems to try seeking on it - ??! */
 	/* hopefully it understands what ESPIPE means... */
-	fp = fdopen(xconnect_stream(lsa), "r+");
-	if (fp == NULL)
-		bb_perror_msg_and_die("fdopen");
+     if (tc_index) {
+  		fp = fdopen(xconnect_stream_with_tc_index(lsa, tc_index), "r+");
+  	} else {
+  		fp = fdopen(xconnect_stream(lsa), "r+");
+  	}
+     
+     /*fp = fdopen(xconnect_stream(lsa), "r+"); AVM */
+ 	
+     if (fp == NULL) {
+ 		bb_perror_msg_and_die("fdopen");
+     }
 
 	return fp;
 }
@@ -398,6 +406,8 @@
 	char *str;
 	char *proxy = 0;
 	char *dir_prefix = NULL;
+    char *settcclass=NULL;      /* AVM */
+    unsigned long tc_index;     /* AVM */
 #if ENABLE_FEATURE_WGET_LONG_OPTIONS
 	char *extra_headers = NULL;
 	llist_t *headers_llist = NULL;
@@ -424,8 +434,9 @@
 		WGET_OPT_PREFIX     = 0x10,
 		WGET_OPT_PROXY      = 0x20,
 		WGET_OPT_USER_AGENT = 0x40,
-		WGET_OPT_PASSIVE    = 0x80,
-		WGET_OPT_HEADER     = 0x100,
+		WGET_OPT_TRAFFICCLASS = 0x80,
+		WGET_OPT_PASSIVE    = 0x100,
+		WGET_OPT_HEADER     = 0x200,
 	};
 #if ENABLE_FEATURE_WGET_LONG_OPTIONS
 	static const char wget_longopts[] ALIGN1 =
@@ -437,6 +448,7 @@
 		"directory-prefix\0" Required_argument "P"
 		"proxy\0"            Required_argument "Y"
 		"user-agent\0"       Required_argument "U"
+		"traffic-class\0"    Required_argument  "t" /* AVM */
 		"passive-ftp\0"      No_argument       "\xff"
 		"header\0"           Required_argument "\xfe"
 		;
@@ -452,7 +464,8 @@
 	opt = getopt32(argv, "csqO:P:Y:U:" /*ignored:*/ "t:T:",
 				&fname_out, &dir_prefix,
 				&proxy_flag, &user_agent,
-				NULL, /* -t RETRIES */
+				/* NULL, -t RETRIES */
+				&settcclass, /* AVM */
 				NULL /* -T NETWORK_READ_TIMEOUT */
 				USE_FEATURE_WGET_LONG_OPTIONS(, &headers_llist)
 				);
@@ -547,7 +560,13 @@
 
 			/* Open socket to http server */
 			if (sfp) fclose(sfp);
-			sfp = open_socket(lsa);
+			
+            tc_index = 0;                                       /* AVM */
+ 			if (opt & WGET_OPT_TRAFFICCLASS) {                  /* AVM */   
+ 				tc_index = atoi(settcclass);                    /* AVM */   
+ 			}                                                   /* AVM */
+            sfp = open_socket_with_tc_index(lsa, tc_index);     /* AVM */
+            /*sfp = open_socket(lsa); AVM */
 
 			/* Send HTTP request.  */
 			if (use_proxy) {
@@ -688,7 +707,12 @@
 		if (!target.user)
 			target.user = xstrdup("anonymous:busybox@");
 
-		sfp = open_socket(lsa);
+		tc_index = 0;                                       /* AVM */
+ 		if (opt & WGET_OPT_TRAFFICCLASS) {                  /* AVM */   
+ 			tc_index = atoi(settcclass);                    /* AVM */   
+ 		}                                                   /* AVM */
+        sfp = open_socket_with_tc_index(lsa, tc_index);     /* AVM */
+        /*sfp = open_socket(lsa); AVM */
 		if (ftpcmd(NULL, NULL, sfp, buf) != 220)
 			bb_error_msg_and_die("%s", buf+4);
 
@@ -743,7 +767,13 @@
 		if (!str) goto pasv_error;
 		port += xatou_range(str+1, 0, 255) * 256;
 		set_nport(lsa, htons(port));
-		dfp = open_socket(lsa);
+        
+        tc_index = 0;                                       /* AVM */
+ 		if (opt & WGET_OPT_TRAFFICCLASS) {                  /* AVM */   
+ 			tc_index = atoi(settcclass);                    /* AVM */   
+ 		}                                                   /* AVM */
+        dfp = open_socket_with_tc_index(lsa, tc_index);     /* AVM */
+        /*dfp = open_socket(lsa); AVM */
 
 		if (beg_range) {
 			sprintf(buf, "REST %"OFF_FMT"d", beg_range);
