--- ./check_icmp.c.old	2007-12-11 06:57:35.000000000 +0100
+++ ./check_icmp.c	2008-06-25 10:50:28.000000000 +0200
@@ -6,8 +6,10 @@
 * Copyright (c) 2005-2007 nagios-plugins team
 *
 * Original Author : Andreas Ericsson <ae@op5.se>
+*			
+*	set TOS-bist (-T): Georg von Zengen <gvz@ciphron.de>		
 *
-* Last Modified: $Date: 2007-12-11 05:57:35 +0000 (Tue, 11 Dec 2007) $
+* Last Modified: $Date: 2008-06-24 17:06:35 +0000 (Tue, 24 JUN 2008) $
 *
 * Description:
 *
@@ -215,7 +217,7 @@
 static int min_hosts_alive = -1;
 float pkt_backoff_factor = 1.5;
 float target_backoff_factor = 1.5;
-
+int tos=0;
 /** code start **/
 static void
 crash(const char *fmt, ...)
@@ -446,8 +448,20 @@
 
 	/* parse the arguments */
 	for(i = 1; i < argc; i++) {
-		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:i:b:I:l:m:")) != EOF) {
+		while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:i:b:I:l:m:T:")) != EOF) {
 			switch(arg) {
+			case 'T':
+				//tos = strtoul(optarg, NULL, 0);
+				sscanf(optarg,"%x",&tos);
+				if (tos > 0xff){
+					crash("value of -T must not be greater than 0xFF\n");
+				}
+				if(tos < 0){
+					crash("value of -T must be greater than 0x00\n");
+				}
+				//tos = xtoi(tos, NULL, 0);
+			//	printf("\n%d\n",tos);
+				break;
 			case 'v':
 				debug++;
 				break;
@@ -536,7 +550,9 @@
 			else printf("ttl set to %u\n", ttl);
 		}
 	}
-
+	if(tos > 0) {
+		result = setsockopt(icmp_sock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
+	}
 	/* stupid users should be able to give whatever thresholds they want
 	 * (nothing will break if they do), but some anal plugin maintainer
 	 * will probably add some printf() thing here later, so it might be
@@ -1251,6 +1267,7 @@
   printf ("%u)\n", timeout);
   printf (" %s\n", "-b");
   printf ("    %s\n", _("icmp packet size (currenly ignored)"));
+  printf (" -T\n    set TOS-bits in Hex\n"); 
   printf (" %s\n", "-v");
   printf ("    %s\n", _("verbose"));
 
