瀏覽代碼

code cleanup nad additional comments to be ready for publishing

Nils Ohlmeier 23 年之前
父節點
當前提交
32056d3aca
共有 1 個文件被更改,包括 273 次插入141 次删除
  1. 273 141
      test/sipsak.c

+ 273 - 141
test/sipsak.c

@@ -1,12 +1,33 @@
 /*
 /*
  * $Id$
  * $Id$
+ *
+ * Copyright (C) 2002-2003 Fhg Fokus
+ *
+ * This file is sipsak, a free sip testing tool.
+ *
+ * sipsak is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * sipsak is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
  */
 
 
 /* sipsak written by nils ohlmeier ([email protected]).
 /* sipsak written by nils ohlmeier ([email protected]).
-based up on a modifyed version of shoot.
-set DEBUG on compile will produce much more output, primary
-it will print out the sended and received messages before or after
-every network action.
+   based up on a modifyed version of shoot.
+   set DEBUG on compile will produce much more output. primarily
+   it will print out the sended and received messages before or after
+   every network action.
+*/
+
+/* changes by [email protected]; now messages can be really received;
+   status code returned is 2 for some local errors , 0 for success
+   and 1 for remote error -- ICMP/timeout; can be used to test if
+   a server is alive; 1xx messages are now ignored; windows support
+   dropped
 */
 */
 
 
 /*
 /*
@@ -16,13 +37,14 @@ for any problems you may have using it.
 bouquets and brickbats to [email protected]
 bouquets and brickbats to [email protected]
 */
 */
 
 
-/* changes by [email protected]; now messages can be really received;
-   status code returned is 2 for some local errors , 0 for success
-   and 1 for remote error -- ICMP/timeout; can be used to test if
-   a server is alive; 1xx messages are now ignored; windows support
-   dropped
+/* TO-DO:
+   - filter out retransmissions
+   - support for short notation
+   - support for IPv6
 */
 */
 
 
+//set ts=4 :-)
+
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/types.h>
@@ -84,6 +106,7 @@ bouquets and brickbats to [email protected]
 #define USRLOC_EXP_DEF 15
 #define USRLOC_EXP_DEF 15
 #define FLOOD_METH "OPTIONS"
 #define FLOOD_METH "OPTIONS"
 
 
+/* lots of global variables. ugly but makes life easier. */
 long address;
 long address;
 int verbose, nameend, namebeg, expires_t, flood, warning_ext;
 int verbose, nameend, namebeg, expires_t, flood, warning_ext;
 int maxforw, lport, rport, randtrash, trashchar, numeric;
 int maxforw, lport, rport, randtrash, trashchar, numeric;
@@ -153,7 +176,8 @@ long getaddress(char *host)
 }
 }
 
 
 /* because the full qualified domain name is needed by many other
 /* because the full qualified domain name is needed by many other
-   functions it will be determined by this function.*/
+   functions it will be determined by this function.
+*/
 void get_fqdn(){
 void get_fqdn(){
 	char hname[100], dname[100], hlp[18];
 	char hname[100], dname[100], hlp[18];
 	size_t namelen=100;
 	size_t namelen=100;
@@ -205,8 +229,7 @@ void get_fqdn(){
 #endif
 #endif
 }
 }
 
 
-/* add a Via Header Field in the message.
-*/
+/* add a Via Header Field in the message. */
 void add_via(char *mes)
 void add_via(char *mes)
 {
 {
 	char *via_line, *via, *backup; 
 	char *via_line, *via, *backup; 
@@ -240,7 +263,8 @@ void add_via(char *mes)
 }
 }
 
 
 /* copy the via lines from the message to the message 
 /* copy the via lines from the message to the message 
-   reply for correct routing of our reply.*/
+   reply for correct routing of our reply.
+*/
 void cpy_vias(char *reply){
 void cpy_vias(char *reply){
 	char *first_via, *middle_via, *last_via, *backup;
 	char *first_via, *middle_via, *last_via, *backup;
 
 
@@ -257,7 +281,8 @@ void cpy_vias(char *reply){
 	last_via=strchr(last_via, '\n');
 	last_via=strchr(last_via, '\n');
 	middle_via=strchr(mes_reply, '\n')+1;
 	middle_via=strchr(mes_reply, '\n')+1;
 	/* make a backup, insert the vias after the first line and append 
 	/* make a backup, insert the vias after the first line and append 
-	backup */
+	   backup
+	*/
 	backup=malloc(strlen(middle_via)+1);
 	backup=malloc(strlen(middle_via)+1);
 	strcpy(backup, middle_via);
 	strcpy(backup, middle_via);
 	strncpy(middle_via, first_via, last_via-first_via+1);
 	strncpy(middle_via, first_via, last_via-first_via+1);
@@ -268,7 +293,7 @@ void cpy_vias(char *reply){
 #endif
 #endif
 }
 }
 
 
-/* create a valid sip header out of the given parameters */
+/* create a valid sip header for the different modes */
 void create_msg(char *buff, int action){
 void create_msg(char *buff, int action){
 	unsigned int c;
 	unsigned int c;
 	char *usern;
 	char *usern;
@@ -284,10 +309,24 @@ void create_msg(char *buff, int action){
 			sprintf(usern, "%s%i", username, namebeg);
 			sprintf(usern, "%s%i", username, namebeg);
 			/* build the register, message and the 200 we need in for 
 			/* build the register, message and the 200 we need in for 
 			   USRLOC on one function call*/
 			   USRLOC on one function call*/
-			sprintf(buff, "%s sip:%s%s%s%s:%i\r\n%s<sip:%s@%s>\r\n%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sip:%s@%s:%i>\r\n%s%i\r\n\r\n", REG_STR, domainname, SIP20_STR, VIA_STR, fqdn, lport, FROM_STR, usern, domainname, TO_STR, usern, domainname, CALL_STR, c, fqdn, CSEQ_STR, 3*namebeg+1, REG_STR, CONT_STR, usern, fqdn, lport, EXP_STR, expires_t);
+			sprintf(buff, "%s sip:%s%s%s%s:%i\r\n%s<sip:%s@%s>\r\n"
+				"%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sip:%s@%s:%i>\r\n"
+				"%s%i\r\n\r\n", REG_STR, domainname, SIP20_STR, VIA_STR, fqdn, 
+				lport, FROM_STR, usern, domainname, TO_STR, usern, domainname, 
+				CALL_STR, c, fqdn, CSEQ_STR, 3*namebeg+1, REG_STR, CONT_STR, 
+				usern, fqdn, lport, EXP_STR, expires_t);
 			c=rand();
 			c=rand();
-			sprintf(message, "%s sip:%s@%s%s%s%s:%i\r\n%s<sip:sipsak@%s:%i>\r\n%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s%s%i\r\n\r\n%s%s%i.", MES_STR, usern, domainname, SIP20_STR, VIA_STR, fqdn, lport, FROM_STR, fqdn, lport, TO_STR, usern, domainname, CALL_STR, c, fqdn, CSEQ_STR, 3*namebeg+2, MES_STR, CON_TXT_STR, CON_LEN_STR, SIPSAK_MES_STR_LEN+strlen(usern), SIPSAK_MES_STR, username, namebeg);
-			sprintf(mes_reply, "%s%s<sip:sipsak@%s:%i>\r\n%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s 0\r\n\r\n", SIP200_STR, FROM_STR, fqdn, lport, TO_STR, usern, domainname, CALL_STR, c, fqdn, CSEQ_STR, 3*namebeg+2, MES_STR, CON_LEN_STR);
+			sprintf(message, "%s sip:%s@%s%s%s%s:%i\r\n%s<sip:sipsak@%s:%i>\r\n"
+				"%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s%s%i\r\n\r\n%s%s%i.", 
+				MES_STR, usern, domainname, SIP20_STR, VIA_STR, fqdn, lport, 
+				FROM_STR, fqdn, lport, TO_STR, usern, domainname, CALL_STR, c, 
+				fqdn, CSEQ_STR, 3*namebeg+2, MES_STR, CON_TXT_STR, CON_LEN_STR, 
+				SIPSAK_MES_STR_LEN+strlen(usern), SIPSAK_MES_STR, username, 
+				namebeg);
+			sprintf(mes_reply, "%s%s<sip:sipsak@%s:%i>\r\n%s<sip:%s@%s>\r\n"
+				"%s%u@%s\r\n%s%i %s\r\n%s 0\r\n\r\n", SIP200_STR, FROM_STR, 
+				fqdn, lport, TO_STR, usern, domainname, CALL_STR, c, fqdn, 
+				CSEQ_STR, 3*namebeg+2, MES_STR, CON_LEN_STR);
 #ifdef DEBUG
 #ifdef DEBUG
 			printf("message:\n%s\n", message);
 			printf("message:\n%s\n", message);
 			printf("message reply:\n%s\n", mes_reply);
 			printf("message reply:\n%s\n", mes_reply);
@@ -295,13 +334,26 @@ void create_msg(char *buff, int action){
 			free(usern);
 			free(usern);
 			break;
 			break;
 		case REQ_OPT:
 		case REQ_OPT:
-			sprintf(buff, "%s sip:%s@%s%s%s<sip:sipsak@%s:%i>\r\n%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sip:sipsak@%s:%i>\r\n\r\n", OPT_STR, username, domainname, SIP20_STR, FROM_STR, fqdn, lport, TO_STR, username, domainname, CALL_STR, c, fqdn, CSEQ_STR, namebeg, OPT_STR, CONT_STR, fqdn, lport);
+			sprintf(buff, "%s sip:%s@%s%s%s<sip:sipsak@%s:%i>\r\n"
+				"%s<sip:%s@%s>\r\n%s%u@%s\r\n%s%i %s\r\n"
+				"%s<sip:sipsak@%s:%i>\r\n\r\n", OPT_STR, username, domainname, 
+				SIP20_STR, FROM_STR, fqdn, lport, TO_STR, username, domainname, 
+				CALL_STR, c, fqdn, CSEQ_STR, namebeg, OPT_STR, CONT_STR, fqdn, 
+				lport);
 			break;
 			break;
 		case REQ_FLOOD:
 		case REQ_FLOOD:
-			sprintf(buff, "%s sip:%s%s%s%s:9\r\n%s<sip:sipsak@%s:9>\r\n%s<sip:%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sipsak@%s:9>\r\n\r\n", FLOOD_METH, domainname, SIP20_STR, VIA_STR, fqdn, FROM_STR, fqdn, TO_STR, domainname, CALL_STR, c, fqdn, CSEQ_STR, namebeg, FLOOD_METH, CONT_STR, fqdn);
+			sprintf(buff, "%s sip:%s%s%s%s:9\r\n%s<sip:sipsak@%s:9>\r\n"
+				"%s<sip:%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sipsak@%s:9>\r\n\r\n", 
+				FLOOD_METH, domainname, SIP20_STR, VIA_STR, fqdn, FROM_STR, 
+				fqdn, TO_STR, domainname, CALL_STR, c, fqdn, CSEQ_STR, namebeg, 
+				FLOOD_METH, CONT_STR, fqdn);
 			break;
 			break;
 		case REQ_RAND:
 		case REQ_RAND:
-			sprintf(buff, "%s sip:%s%s%s%s:%i\r\n%s<sip:sipsak@%s:%i>\r\n%s<sip:%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sipsak@%s:%i>\r\n\r\n", OPT_STR, domainname, SIP20_STR, VIA_STR, fqdn, lport, FROM_STR, fqdn, lport, TO_STR, domainname, CALL_STR, c, fqdn, CSEQ_STR, namebeg, OPT_STR, CONT_STR, fqdn, lport);
+			sprintf(buff, "%s sip:%s%s%s%s:%i\r\n%s<sip:sipsak@%s:%i>\r\n"
+				"%s<sip:%s>\r\n%s%u@%s\r\n%s%i %s\r\n%s<sipsak@%s:%i>\r\n\r\n", 
+				OPT_STR, domainname, SIP20_STR, VIA_STR, fqdn, lport, FROM_STR, 
+				fqdn, lport, TO_STR, domainname, CALL_STR, c, fqdn, CSEQ_STR, 
+				namebeg, OPT_STR, CONT_STR, fqdn, lport);
 			break;
 			break;
 		default:
 		default:
 			printf("error: unknown request type to create\n");
 			printf("error: unknown request type to create\n");
@@ -375,7 +427,7 @@ void uri_replace(char *mes, char *uri)
 #endif
 #endif
 }
 }
 
 
-/* trashes one character in buff radnomly */
+/* trashes one character in buff randomly */
 void trash_random(char *message)
 void trash_random(char *message)
 {
 {
 	int r;
 	int r;
@@ -419,7 +471,8 @@ void warning_extract(char *message)
 }
 }
 
 
 /* this function is taken from traceroute-1.4_p12 
 /* this function is taken from traceroute-1.4_p12 
-   which is distributed under the GPL */
+   which is distributed under the GPL and it returns
+   the difference between to timeval structs */
 double deltaT(struct timeval *t1p, struct timeval *t2p)
 double deltaT(struct timeval *t1p, struct timeval *t2p)
 {
 {
         register double dt;
         register double dt;
@@ -429,18 +482,7 @@ double deltaT(struct timeval *t1p, struct timeval *t2p)
         return (dt);
         return (dt);
 }
 }
 
 
-/*
-shoot:
-takes:
-	1. the text message of buff to 
-	2. the address (network orderd byte order)
-	3. local- and remote-port (not network byte ordered).
-	4. and lots of boolean for the different modi
-
-starting from half a second, times-out on replies and
-keeps retrying with exponential back-off that flattens out
-at 5 seconds (5000 milliseconds).
-*/
+/* this is the main function with the loops and modes */
 void shoot(char *buff)
 void shoot(char *buff)
 {
 {
 	struct sockaddr_in	addr, sockname;
 	struct sockaddr_in	addr, sockname;
@@ -453,10 +495,9 @@ void shoot(char *buff)
 	char reply[BUFSIZE];
 	char reply[BUFSIZE];
 	fd_set	fd;
 	fd_set	fd;
 	socklen_t slen;
 	socklen_t slen;
-	//regex_t* regexp;
-	//regex_t* redexp;
 	regex_t redexp, proexp, okexp, tmhexp, errexp;
 	regex_t redexp, proexp, okexp, tmhexp, errexp;
 
 
+	/* initalize some local vars */
 	redirected = 1;
 	redirected = 1;
 	nretries = 5;
 	nretries = 5;
 	retryAfter = 5000;
 	retryAfter = 5000;
@@ -492,21 +533,25 @@ void shoot(char *buff)
 		lport=ntohs(sockname.sin_port);
 		lport=ntohs(sockname.sin_port);
 	}
 	}
 
 
-	/* set a regular expression according to the modus */
-	//regexp=(regex_t*)malloc(sizeof(regex_t));
-	regcomp(&proexp, "^SIP/[0-9]\\.[0-9] 1[0-9][0-9] ", REG_EXTENDED|REG_NOSUB|REG_ICASE); 
-	regcomp(&okexp, "^SIP/[0-9]\\.[0-9] 200 ", REG_EXTENDED|REG_NOSUB|REG_ICASE); 
-	regcomp(&redexp, "^SIP/[0-9]\\.[0-9] 3[0-9][0-9] ", REG_EXTENDED|REG_NOSUB|REG_ICASE);
-	regcomp(&errexp, "^SIP/[0-9]\\.[0-9] 4[0-9][0-9] ", REG_EXTENDED|REG_NOSUB|REG_ICASE); 
-	regcomp(&tmhexp, "^SIP/[0-9]\\.[0-9] 483 ", REG_EXTENDED|REG_NOSUB|REG_ICASE); 
-	/* catching redirects */
-	//redexp=(regex_t*)malloc(sizeof(regex_t));
+	/* set all regular expression to simplfy the result code indetification */
+	regcomp(&proexp, "^SIP/[0-9]\\.[0-9] 1[0-9][0-9] ", 
+		REG_EXTENDED|REG_NOSUB|REG_ICASE); 
+	regcomp(&okexp, "^SIP/[0-9]\\.[0-9] 200 ", 
+		REG_EXTENDED|REG_NOSUB|REG_ICASE); 
+	regcomp(&redexp, "^SIP/[0-9]\\.[0-9] 3[0-9][0-9] ", 
+		REG_EXTENDED|REG_NOSUB|REG_ICASE);
+	regcomp(&errexp, "^SIP/[0-9]\\.[0-9] 4[0-9][0-9] ", 
+		REG_EXTENDED|REG_NOSUB|REG_ICASE); 
+	regcomp(&tmhexp, "^SIP/[0-9]\\.[0-9] 483 ", 
+		REG_EXTENDED|REG_NOSUB|REG_ICASE); 
 
 
 	if (usrloc){
 	if (usrloc){
+		/* in usrloc every test consists of three steps */
 		nretries=3*(nameend-namebeg)+3;
 		nretries=3*(nameend-namebeg)+3;
 		create_msg(buff, REQ_REG);
 		create_msg(buff, REQ_REG);
 	}
 	}
 	else if (trace){
 	else if (trace){
+		/* for trace we need some spezial initis */
 		if (maxforw!=-1)
 		if (maxforw!=-1)
 			nretries=maxforw;
 			nretries=maxforw;
 		else
 		else
@@ -517,6 +562,7 @@ void shoot(char *buff)
 		add_via(buff);
 		add_via(buff);
 	}
 	}
 	else if (flood){
 	else if (flood){
+		/* this should be the max of an (32 bit) int without the sign */
 		if (namebeg==-1) namebeg=2147483647;
 		if (namebeg==-1) namebeg=2147483647;
 		nretries=namebeg;
 		nretries=namebeg;
 		namebeg=1;
 		namebeg=1;
@@ -531,12 +577,14 @@ void shoot(char *buff)
 			if (trashchar < nameend)
 			if (trashchar < nameend)
 				nameend=trashchar;
 				nameend=trashchar;
 			else
 			else
-				printf("warning: number of trashed chars to big. setting to request lenght\n");
+				printf("warning: number of trashed chars to big. setting to "
+					"request lenght\n");
 		}
 		}
 		nretries=nameend-1;
 		nretries=nameend-1;
 		trash_random(buff);
 		trash_random(buff);
 	}
 	}
 	else {
 	else {
+		/* for non of the modes we also need some inits */
 		if (!file_b) {
 		if (!file_b) {
 			namebeg=1;
 			namebeg=1;
 			create_msg(buff, REQ_OPT);
 			create_msg(buff, REQ_OPT);
@@ -551,26 +599,31 @@ void shoot(char *buff)
 	/* if we got a redirect this loop ensures sending to the 
 	/* if we got a redirect this loop ensures sending to the 
 	   redirected server*/
 	   redirected server*/
 	while (redirected) {
 	while (redirected) {
-
+		/* we don't want to send for ever */
 		redirected=0;
 		redirected=0;
 
 
+		/* destination socket init here because it could be changed in a 
+		   case of a redirect */
 		addr.sin_addr.s_addr = address;
 		addr.sin_addr.s_addr = address;
 		addr.sin_port = htons((short)rport);
 		addr.sin_port = htons((short)rport);
 		addr.sin_family = AF_INET;
 		addr.sin_family = AF_INET;
 	
 	
 		/* we connect as per the RFC 2543 recommendations
 		/* we connect as per the RFC 2543 recommendations
-		modified from sendto/recvfrom */
+		   modified from sendto/recvfrom */
 		ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
 		ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
 		if (ret==-1) {
 		if (ret==-1) {
 			perror("no connect");
 			perror("no connect");
 			exit(2);
 			exit(2);
 		}
 		}
 
 
+		/* here we go for the number of nretries which healily depends on the 
+		   mode */
 		for (i = 0; i <= nretries; i++)
 		for (i = 0; i <= nretries; i++)
 		{
 		{
 			if (trace) {
 			if (trace) {
 				set_maxforw(buff);
 				set_maxforw(buff);
 			}
 			}
+			/* some initial output */
 			else if (usrloc && verbose) {
 			else if (usrloc && verbose) {
 				switch (usrlocstep) {
 				switch (usrlocstep) {
 					case 0:
 					case 0:
@@ -597,6 +650,7 @@ void shoot(char *buff)
 				printf("** request **\n%s\n", buff);
 				printf("** request **\n%s\n", buff);
 			}
 			}
 
 
+			/* lets fire the request to the server and store when we did */
 			ret = send(sock, buff, strlen(buff), 0);
 			ret = send(sock, buff, strlen(buff), 0);
 			(void)gettimeofday(&sendtime, &tz);
 			(void)gettimeofday(&sendtime, &tz);
 			if (ret==-1) {
 			if (ret==-1) {
@@ -604,7 +658,9 @@ void shoot(char *buff)
 				exit( 1 );
 				exit( 1 );
 			}
 			}
 
 
+			/* in flood we are only interested in sending so skip the rest */
 			if (!flood) {
 			if (!flood) {
+				/* set the timeout and wait for a response */
 				tv.tv_sec = retryAfter/1000;
 				tv.tv_sec = retryAfter/1000;
 				tv.tv_usec = (retryAfter % 1000) * 1000;
 				tv.tv_usec = (retryAfter % 1000) * 1000;
 
 
@@ -615,6 +671,7 @@ void shoot(char *buff)
 				(void)gettimeofday(&recvtime, &tz);
 				(void)gettimeofday(&recvtime, &tz);
 				if (ret == 0)
 				if (ret == 0)
 				{
 				{
+					/* lets see if we at least received an icmp error */
 					sockerr.fd=sock;
 					sockerr.fd=sock;
 					sockerr.events=POLLERR;
 					sockerr.events=POLLERR;
 					if ((poll(&sockerr, 1, 10))==1) {
 					if ((poll(&sockerr, 1, 10))==1) {
@@ -622,21 +679,30 @@ void shoot(char *buff)
 							recv(sock, reply, strlen(reply), 0);
 							recv(sock, reply, strlen(reply), 0);
 							perror("send failure: ");
 							perror("send failure: ");
 							if (randtrash) 
 							if (randtrash) 
-								printf ("last message before send failure:\n%s\n", buff);
+								printf ("last message before send failure:"
+									"\n%s\n", buff);
 							exit(1);
 							exit(1);
 						}
 						}
 					}
 					}
-					if (trace) printf("%i: timeout after %i ms\n", i, retryAfter);
-					else if (verbose) printf("** timeout after %i ms**\n", retryAfter);
+					/* printout that we did not received anything */
+					if (trace) printf("%i: timeout after %i ms\n", i, 
+									retryAfter);
+					else if (verbose) printf("** timeout after %i ms**\n", 
+										retryAfter);
 					if (randtrash) {
 					if (randtrash) {
-						printf("did not get a response on this request:\n%s\n", buff);
+						printf("did not get a response on this request:"
+							"\n%s\n", buff);
 						if (i+1 < nameend) {
 						if (i+1 < nameend) {
 							if (randretrys == 2) {
 							if (randretrys == 2) {
-								printf("sended the following message three times without getting a response:\n%s\ngive up further retransmissions...\n", buff);
+								printf("sended the following message three "
+									"times without getting a response:\n%s\n"
+									"give up further retransmissions...\n", 
+									buff);
 								exit(1);
 								exit(1);
 							}
 							}
 							else {
 							else {
-								printf("resending it without additional random changes...\n\n");
+								printf("resending it without additional "
+									"random changes...\n\n");
 								randretrys++;
 								randretrys++;
 							}
 							}
 						}
 						}
@@ -644,26 +710,34 @@ void shoot(char *buff)
 					retryAfter = retryAfter * 2;
 					retryAfter = retryAfter * 2;
 					if (retryAfter > 5000)
 					if (retryAfter > 5000)
 						retryAfter = 5000;
 						retryAfter = 5000;
+					/* if we did not exit until here lets try another send */
 					continue;
 					continue;
-				} else if ( ret == -1 ) {
+				}
+				else if ( ret == -1 ) {
 					perror("select error");
 					perror("select error");
 					exit(2);
 					exit(2);
-				} /* no timeout, no error ... something has happened :-) */
+				}
 				else if (FD_ISSET(ssock, &fd)) {
 				else if (FD_ISSET(ssock, &fd)) {
+					/* no timeout, no error ... something has happened :-) */
 				 	if (!trace && !usrloc && !randtrash)
 				 	if (!trace && !usrloc && !randtrash)
 						printf ("\nmessage received\n");
 						printf ("\nmessage received\n");
-				} else {
-					puts("\nselect returned succesfuly, nothing received\n");
+				}
+				else {
+					printf("\nselect returned succesfuly, nothing received\n");
 					continue;
 					continue;
 				}
 				}
 
 
-				/* we are retrieving only the extend of a decent MSS = 1500 bytes */
+				/* we are retrieving only the extend of a decent 
+				   MSS = 1500 bytes */
 				len = sizeof(addr);
 				len = sizeof(addr);
 				ret = recv(ssock, reply, BUFSIZE, 0);
 				ret = recv(ssock, reply, BUFSIZE, 0);
 				if(ret > 0)
 				if(ret > 0)
 				{
 				{
 					reply[ret] = 0;
 					reply[ret] = 0;
-					if (i==0) memcpy(&firstsendt, &sendtime, sizeof(struct timeval));
+					/* store the time of our first send */
+					if (i==0)
+						memcpy(&firstsendt, &sendtime, sizeof(struct timeval));
+					/* lets see if received a redirect */
 					if (redirects && regexec(&redexp, reply, 0, 0, 0)==0) {
 					if (redirects && regexec(&redexp, reply, 0, 0, 0)==0) {
 						printf("** received redirect ");
 						printf("** received redirect ");
 						if (warning_ext) {
 						if (warning_ext) {
@@ -672,23 +746,27 @@ void shoot(char *buff)
 							printf("\n");
 							printf("\n");
 						}
 						}
 						else printf("\n");
 						else printf("\n");
-						/* we'll try to handle 301 and 302 here, other 3xx are to complex */
-						regcomp(&redexp, "^SIP/[0-9]\\.[0-9] 30[1-2] ", REG_EXTENDED|REG_NOSUB|REG_ICASE);
+						/* we'll try to handle 301 and 302 here, other 3xx 
+						   are to complex */
+						regcomp(&redexp, "^SIP/[0-9]\\.[0-9] 30[1-2] ", 
+							REG_EXTENDED|REG_NOSUB|REG_ICASE);
 						if (regexec(&redexp, reply, 0, 0, 0)==0) {
 						if (regexec(&redexp, reply, 0, 0, 0)==0) {
 							/* try to find the contact in the redirect */
 							/* try to find the contact in the redirect */
 							if ((foo=strstr(reply, "Contact"))==NULL) {
 							if ((foo=strstr(reply, "Contact"))==NULL) {
-								printf("error: cannot find Contact in this redirect:\n%s\n", reply);
+								printf("error: cannot find Contact in this "
+									"redirect:\n%s\n", reply);
 								exit(2);
 								exit(2);
 							}
 							}
 							crlf=strchr(foo, '\n');
 							crlf=strchr(foo, '\n');
-							if ((contact=strchr(foo, '\r'))!=NULL && contact<crlf)
+							if ((contact=strchr(foo, '\r'))!=NULL 
+							&& contact<crlf)
 								crlf=contact;
 								crlf=contact;
 							bar=malloc(crlf-foo+1);
 							bar=malloc(crlf-foo+1);
 							strncpy(bar, foo, crlf-foo);
 							strncpy(bar, foo, crlf-foo);
-							//sprintf(bar+(crlf-foo), "0");
 							*(bar+(crlf-foo))='\0';
 							*(bar+(crlf-foo))='\0';
 							if ((contact=strstr(bar, "sip"))==NULL) {
 							if ((contact=strstr(bar, "sip"))==NULL) {
-								printf("error: cannot find sip in the Contact of this redirect:\n%s\n", reply);
+								printf("error: cannot find sip in the Contact "
+									"of this redirect:\n%s\n", reply);
 								exit(2);
 								exit(2);
 							}
 							}
 							if ((foo=strchr(contact, ';'))!=NULL)
 							if ((foo=strchr(contact, ';'))!=NULL)
@@ -703,7 +781,9 @@ void shoot(char *buff)
 									foo++;
 									foo++;
 									rport = atoi(foo);
 									rport = atoi(foo);
 									if (!rport) {
 									if (!rport) {
-										printf("error: cannot handle the port in the uri in Contact:\n%s\n", reply);
+										printf("error: cannot handle the port "
+											"in the uri in Contact:\n%s\n", 
+											reply);
 										exit(2);
 										exit(2);
 									}
 									}
 								}
 								}
@@ -716,12 +796,15 @@ void shoot(char *buff)
 								/* get the new destination IP*/
 								/* get the new destination IP*/
 								address = getaddress(crlf);
 								address = getaddress(crlf);
 								if (!address){
 								if (!address){
-									printf("error: cannot determine host address from Contact of redirect:\%s\n", reply);
+									printf("error: cannot determine host "
+										"address from Contact of redirect:"
+										"\%s\n", reply);
 									exit(2);
 									exit(2);
 								}
 								}
 							}
 							}
 							else{
 							else{
-								printf("error: missing : in Contact of this redirect:\n%s\n", reply);
+								printf("error: missing : in Contact of this "
+									"redirect:\n%s\n", reply);
 								exit(2);
 								exit(2);
 							}
 							}
 							free(bar);
 							free(bar);
@@ -730,20 +813,24 @@ void shoot(char *buff)
 							i=nretries;
 							i=nretries;
 						}
 						}
 						else {
 						else {
-							printf("error: cannot handle this redirect:\n%s\n", reply);
+							printf("error: cannot handle this redirect:"
+								"\n%s\n", reply);
 							exit(2);
 							exit(2);
 						}
 						}
 					}
 					}
 					else if (trace) {
 					else if (trace) {
 						if (regexec(&tmhexp, reply, 0, 0, 0)==0) {
 						if (regexec(&tmhexp, reply, 0, 0, 0)==0) {
+							/* we received 483 to many hops */
 							printf("%i: ", i);
 							printf("%i: ", i);
 #ifdef DEBUG
 #ifdef DEBUG
-							printf("(%.3f ms)\n%s\n", deltaT(&sendtime, &recvtime), reply);
+							printf("(%.3f ms)\n%s\n", 
+								deltaT(&sendtime, &recvtime), reply);
 #else
 #else
 							warning_extract(reply);
 							warning_extract(reply);
 							crlf=strchr(reply, '\n');
 							crlf=strchr(reply, '\n');
 							*crlf='\0';
 							*crlf='\0';
-							printf("(%.3f ms) %s\n", deltaT(&sendtime, &recvtime), reply);
+							printf("(%.3f ms) %s\n", 
+								deltaT(&sendtime, &recvtime), reply);
 #endif
 #endif
 							namebeg++;
 							namebeg++;
 							maxforw++;
 							maxforw++;
@@ -752,18 +839,23 @@ void shoot(char *buff)
 							continue;
 							continue;
 						}
 						}
 						else if (regexec(&proexp, reply, 0, 0, 0)==0) {
 						else if (regexec(&proexp, reply, 0, 0, 0)==0) {
+							/* we received a provisional response */
 							printf("%i: ", i);
 							printf("%i: ", i);
 #ifdef DEBUG
 #ifdef DEBUG
-							printf("(%.3f ms)\n%s\n", deltaT(&sendtime, &recvtime), reply);
+							printf("(%.3f ms)\n%s\n", 
+								deltaT(&sendtime, &recvtime), reply);
 #else
 #else
 							warning_extract(reply);
 							warning_extract(reply);
 							crlf=strchr(reply, '\n');
 							crlf=strchr(reply, '\n');
 							*crlf='\0';
 							*crlf='\0';
-							printf("(%.3f ms) %s\n", deltaT(&sendtime, &recvtime), reply);
+							printf("(%.3f ms) %s\n", 
+								deltaT(&sendtime, &recvtime), reply);
 #endif
 #endif
 							continue;
 							continue;
 						}
 						}
 						else {
 						else {
+							/* anything else then 483 or provisional will
+							   be treated as final */
 							if (maxforw==i) printf("%i: ", i);
 							if (maxforw==i) printf("%i: ", i);
 							else printf("\t");
 							else printf("\t");
 							warning_extract(crlf);
 							warning_extract(crlf);
@@ -771,8 +863,8 @@ void shoot(char *buff)
 							*crlf='\0';
 							*crlf='\0';
 							crlf++;
 							crlf++;
 							contact=strstr(crlf, "Contact");
 							contact=strstr(crlf, "Contact");
-							//printf("received reply from ");
-							printf("(%.3f ms) %s\n", deltaT(&sendtime, &recvtime), reply);
+							printf("(%.3f ms) %s\n", 
+								deltaT(&sendtime, &recvtime), reply);
 							if (contact){
 							if (contact){
 								crlf=strchr(contact,'\n');
 								crlf=strchr(contact,'\n');
 								*crlf='\0';
 								*crlf='\0';
@@ -787,8 +879,8 @@ void shoot(char *buff)
 					else if (usrloc) {
 					else if (usrloc) {
 						switch (usrlocstep) {
 						switch (usrlocstep) {
 							case 0:
 							case 0:
-								/* at first we have sended a register a look at the 
-								   response now*/
+								/* at first we have sended a register and look 
+								   at the response now*/
 								if (regexec(&okexp, reply, 0, 0, 0)==0) {
 								if (regexec(&okexp, reply, 0, 0, 0)==0) {
 									if (verbose)
 									if (verbose)
 										printf ("  OK\n");
 										printf ("  OK\n");
@@ -801,18 +893,21 @@ void shoot(char *buff)
 								else {
 								else {
 									if (verbose)
 									if (verbose)
 										printf("received:\n%s\n", reply);
 										printf("received:\n%s\n", reply);
-									printf("error: didn't received '200 OK' on regsiter. aborting\n");
+									printf("error: didn't received '200 OK' "
+										"on regsiter. aborting\n");
 									exit(1);
 									exit(1);
 								}
 								}
 								break;
 								break;
 							case 1:
 							case 1:
 								/* now we sended the message and look if its 
 								/* now we sended the message and look if its 
 								   forwarded to us*/
 								   forwarded to us*/
-								if (!strncmp(reply, messusern, strlen(messusern))) {
+								if (!strncmp(reply, messusern, 
+								strlen(messusern))) {
 									if (verbose) {
 									if (verbose) {
 										crlf=strstr(reply, "\r\n\r\n");
 										crlf=strstr(reply, "\r\n\r\n");
 										crlf=crlf+4;
 										crlf=crlf+4;
-										printf("         received message\n  '%s'\n", crlf);
+										printf("         received message\n  "
+											"'%s'\n", crlf);
 									}
 									}
 #ifdef DEBUG
 #ifdef DEBUG
 									printf("\n%s\n", reply);
 									printf("\n%s\n", reply);
@@ -824,24 +919,29 @@ void shoot(char *buff)
 								else {
 								else {
 									if (verbose)
 									if (verbose)
 										printf("\nreceived:\n%s\n", reply);
 										printf("\nreceived:\n%s\n", reply);
-									printf("error: didn't received the 'MESSAGE' we sended. aborting\n");
+									printf("error: didn't received the "
+										"'MESSAGE' we sended. aborting\n");
 									exit(1);
 									exit(1);
 								}
 								}
 								break;
 								break;
 							case 2:
 							case 2:
-								/* finnaly we sended our reply on the message and 
-								   look if this is also forwarded to us*/
-								while (!strncmp(reply, messusern, strlen(messusern))){
-									printf("warning: received 'MESSAGE' retransmission!\n");
+								/* finnaly we sended our reply on the message 
+								   and look if this is also forwarded to us*/
+								while (!strncmp(reply, messusern, 
+								strlen(messusern))){
+									printf("warning: received 'MESSAGE' "
+										"retransmission!\n");
 									ret = recv(ssock, reply, BUFSIZE, 0);
 									ret = recv(ssock, reply, BUFSIZE, 0);
 								}
 								}
 								if (regexec(&okexp, reply, 0, 0, 0)==0) {
 								if (regexec(&okexp, reply, 0, 0, 0)==0) {
 									if (verbose)
 									if (verbose)
 										printf("   reply received\n\n");
 										printf("   reply received\n\n");
 									else
 									else
-										printf("USRLOC for %s%i completed successful\n", username, namebeg);
+										printf("USRLOC for %s%i completed "
+											"successful\n", username, namebeg);
 									if (namebeg==nameend) {
 									if (namebeg==nameend) {
-										printf("All USRLOC tests completed successful.\n");
+										printf("All USRLOC tests completed "
+											"successful.\n");
 										exit(0);
 										exit(0);
 									}
 									}
 									namebeg++;
 									namebeg++;
@@ -851,7 +951,9 @@ void shoot(char *buff)
 								else {
 								else {
 									if (verbose)
 									if (verbose)
 										printf("\nreceived:\n%s\n", reply);
 										printf("\nreceived:\n%s\n", reply);
-									printf("error: didn't received the '200 OK' that we sended as the reply on the message\n");
+									printf("error: didn't received the '200 "
+										"OK' that we sended as the reply on "
+										"the message\n");
 									exit(1);
 									exit(1);
 								}
 								}
 							break;
 							break;
@@ -859,7 +961,7 @@ void shoot(char *buff)
 					}
 					}
 					else if (randtrash) {
 					else if (randtrash) {
 						/* in randomzing trash we are expexting 4?? error codes
 						/* in randomzing trash we are expexting 4?? error codes
-						 * everything should not be normal */
+						   everything should not be normal */
 						if (regexec(&errexp, reply, 0, 0, 0)==0) {
 						if (regexec(&errexp, reply, 0, 0, 0)==0) {
 #ifdef DEBUG
 #ifdef DEBUG
 							printf("received:\n%s\n", reply);
 							printf("received:\n%s\n", reply);
@@ -874,14 +976,19 @@ void shoot(char *buff)
 						}
 						}
 						else {
 						else {
 							printf("warning: did not received 4xx\n");
 							printf("warning: did not received 4xx\n");
-							if (verbose) printf("sended:\n%s\nreceived:\n%s\n", buff, reply);
+							if (verbose) 
+								printf("sended:\n%s\nreceived:\n%s\n", buff, 
+									reply);
 						}
 						}
 						if (nameend==(i+1)) {
 						if (nameend==(i+1)) {
 							if (randretrys == 0) {
 							if (randretrys == 0) {
-								printf("random end reached. server survived :) respect!\n");
+								printf("random end reached. server survived "
+									":) respect!\n");
 							}
 							}
 							else {
 							else {
-								printf("maximum sendings reached but did not get a response on this request:\n%s\n", buff);
+								printf("maximum sendings reached but did not "
+									"get a response on this request:\n%s\n", 
+									buff);
 							}
 							}
 							exit(0);
 							exit(0);
 						}
 						}
@@ -891,8 +998,14 @@ void shoot(char *buff)
 						/* in the normal send and reply case anything other 
 						/* in the normal send and reply case anything other 
 						   then 1xx will be treated as final response*/
 						   then 1xx will be treated as final response*/
 						printf("** reply received ");
 						printf("** reply received ");
-						if (i==0) printf("after %.3f ms **\n", deltaT(&sendtime, &recvtime));
-						else printf("%.3f ms after first send\n   and %.3f ms after last send **\n", deltaT(&firstsendt, &recvtime), deltaT(&sendtime, &recvtime));
+						if (i==0) 
+							printf("after %.3f ms **\n", 
+								deltaT(&sendtime, &recvtime));
+						else 
+							printf("%.3f ms after first send\n   and %.3f ms "
+								"after last send **\n", 
+								deltaT(&firstsendt, &recvtime), 
+								deltaT(&sendtime, &recvtime));
 						if (verbose) printf("%s\n", reply);
 						if (verbose) printf("%s\n", reply);
 						else {
 						else {
 							crlf=strchr(reply, '\n');
 							crlf=strchr(reply, '\n');
@@ -900,7 +1013,8 @@ void shoot(char *buff)
 							printf("   %s\n", reply);
 							printf("   %s\n", reply);
 						}
 						}
 						if (regexec(&proexp, reply, 0, 0, 0)==0) {
 						if (regexec(&proexp, reply, 0, 0, 0)==0) {
-							printf("   provisional received; still waiting for a final response\n ");
+							printf("   provisional received; still waiting "
+								"for a final response\n ");
 							continue;
 							continue;
 						} else {
 						} else {
 							printf("   final received\n ");
 							printf("   final received\n ");
@@ -930,6 +1044,7 @@ void shoot(char *buff)
 	exit(1);
 	exit(1);
 }
 }
 
 
+/* prints out some usage help and exits */
 void print_help() {
 void print_help() {
 	printf("sipsak %s ", SIPSAK_VERSION);
 	printf("sipsak %s ", SIPSAK_VERSION);
 #ifdef DEBUG
 #ifdef DEBUG
@@ -941,23 +1056,29 @@ void print_help() {
 		" USRLOC: sipsak -U [-b number] -e number [-x number] -s sip:uri\n"
 		" USRLOC: sipsak -U [-b number] -e number [-x number] -s sip:uri\n"
 		" flood : sipsak -F [-c number] -s sip:uri\n"
 		" flood : sipsak -F [-c number] -s sip:uri\n"
 		" random: sipsak -R [-t number] -s sip:uri\n\n"
 		" random: sipsak -R [-t number] -s sip:uri\n\n"
-		" additional parameter in every modus:\n"
-		"                [-d] [-i] [-l port] [-m number] [-n] [-r port] [-v] [-w]\n"
+		" additional parameter in every mode:\n"
+		"                [-d] [-i] [-l port] [-m number] [-n] [-r port] [-v] "
+			"[-w]\n"
 		"   -h           displays this help message\n"
 		"   -h           displays this help message\n"
 		"   -V           prints version string only\n"
 		"   -V           prints version string only\n"
 		"   -f filename  the file which contains the SIP message to send\n"
 		"   -f filename  the file which contains the SIP message to send\n"
-		"   -s sip:uri   the destination server uri in form sip:[user@]servername[:port]\n"
-		"   -T           activates the traceroute modus\n"
-		"   -U           activates the USRLOC modus\n"
-		"   -b number    the starting number appendix to the user name in USRLOC modus\n"
+		"   -s sip:uri   the destination server uri in form "
+			"sip:[user@]servername[:port]\n"
+		"   -T           activates the traceroute mode\n"
+		"   -U           activates the USRLOC mode\n"
+		"   -b number    the starting number appendix to the user name in "
+			"USRLOC mode\n"
 		"                (default: 0)\n"
 		"                (default: 0)\n"
-		"   -e number    the ending numer of the appendix to the user name in USRLOC\n"
-		"                modus\n"
+		"   -e number    the ending numer of the appendix to the user name in "
+			"USRLOC\n"
+		"                mode\n"
 		"   -x number    the expires header field value (default: 15)\n"
 		"   -x number    the expires header field value (default: 15)\n"
-		"   -F           activates the flood modus\n"
-		"   -c number    the maximum CSeq number for flood modus (default: 2^31)\n"
+		"   -F           activates the flood mode\n"
+		"   -c number    the maximum CSeq number for flood mode "
+			"(default: 2^31)\n"
 		"   -R           activates the random modues (dangerous)\n"
 		"   -R           activates the random modues (dangerous)\n"
-		"   -t number    the maximum number of trashed character in random modus\n"
+		"   -t number    the maximum number of trashed character in random "
+			"mode\n"
 		"                (default: request length)\n"
 		"                (default: request length)\n"
 		"   -l port      the local port to use (default: any)\n"
 		"   -l port      the local port to use (default: any)\n"
 		"   -r port      the remote port to use (default: 5060)\n"
 		"   -r port      the remote port to use (default: 5060)\n"
@@ -967,7 +1088,8 @@ void print_help() {
 		"   -d           ignore redirects\n"
 		"   -d           ignore redirects\n"
 		"   -v           be more verbose\n"
 		"   -v           be more verbose\n"
 		"   -w           extract IP from the warning in reply\n\n"
 		"   -w           extract IP from the warning in reply\n\n"
-		"The manupulation function are only tested with nice RFC conform SIP-messages,\n"
+		"The manupulation function are only tested with nice RFC conform "
+			"SIP-messages,\n"
 		"so don't expect them to work with ugly or malformed messages.\n");
 		"so don't expect them to work with ugly or malformed messages.\n");
 	exit(0);
 	exit(0);
 };
 };
@@ -1000,9 +1122,9 @@ int main(int argc, char *argv[])
 	while ((c=getopt(argc,argv,"b:c:de:f:Fhil:m:nr:Rs:t:TUvVwx:")) != EOF){
 	while ((c=getopt(argc,argv,"b:c:de:f:Fhil:m:nr:Rs:t:TUvVwx:")) != EOF){
 		switch(c){
 		switch(c){
 			case 'b':
 			case 'b':
-				//namebeg=atoi(optarg);
 				if ((namebeg=atoi(optarg))==-1) {
 				if ((namebeg=atoi(optarg))==-1) {
-					printf("error: non-numerical appendix begin for the username\n");
+					printf("error: non-numerical appendix begin for the "
+						"username\n");
 					exit(2);
 					exit(2);
 				}
 				}
 				break;
 				break;
@@ -1016,9 +1138,9 @@ int main(int argc, char *argv[])
 				redirects=0;
 				redirects=0;
 				break;
 				break;
 			case 'e':
 			case 'e':
-				//nameend=atoi(optarg);
 				if ((nameend=atoi(optarg))==-1) {
 				if ((nameend=atoi(optarg))==-1) {
-					printf("error: non-numerical appendix end for the username\n");
+					printf("error: non-numerical appendix end for the "
+						"username\n");
 					exit(2);
 					exit(2);
 				}
 				}
 				break;
 				break;
@@ -1026,7 +1148,8 @@ int main(int argc, char *argv[])
 				flood=1;
 				flood=1;
 				break;
 				break;
 			case 'f':
 			case 'f':
-				/* file is opened in binary mode so that the cr-lf is preserved */
+				/* file is opened in binary mode so that the cr-lf is 
+				   preserved */
 				pf = fopen(optarg, "rb");
 				pf = fopen(optarg, "rb");
 				if (!pf){
 				if (!pf){
 					puts("unable to open the file.\n");
 					puts("unable to open the file.\n");
@@ -1034,8 +1157,10 @@ int main(int argc, char *argv[])
 				}
 				}
 				length  = fread(buff, 1, sizeof(buff), pf);
 				length  = fread(buff, 1, sizeof(buff), pf);
 				if (length >= sizeof(buff)){
 				if (length >= sizeof(buff)){
-					printf("error:the file is too big. try files of less than %i bytes.\n", BUFSIZE);
-					printf("      or recompile the program with bigger BUFSIZE defined.\n");
+					printf("error:the file is too big. try files of less "
+						"than %i bytes.\n", BUFSIZE);
+					printf("      or recompile the program with bigger "
+						"BUFSIZE defined.\n");
 					exit(2);
 					exit(2);
 				}
 				}
 				fclose(pf);
 				fclose(pf);
@@ -1076,6 +1201,7 @@ int main(int argc, char *argv[])
 				randtrash=1;
 				randtrash=1;
 				break;
 				break;
 			case 's':
 			case 's':
+				/* we try to extract as much informationas we can from the uri*/
 				if (!strncmp(optarg,"sip",3)){
 				if (!strncmp(optarg,"sip",3)){
 					if ((delim=strchr(optarg,':'))!=NULL){
 					if ((delim=strchr(optarg,':'))!=NULL){
 						delim++;
 						delim++;
@@ -1090,7 +1216,8 @@ int main(int argc, char *argv[])
 							delim2++;
 							delim2++;
 							rport = atoi(delim2);
 							rport = atoi(delim2);
 							if (!rport) {
 							if (!rport) {
-								printf("error: non-numerical remote port number\n");
+								printf("error: non-numerical remote port "
+									"number\n");
 								exit(2);
 								exit(2);
 							}
 							}
 						}
 						}
@@ -1098,7 +1225,8 @@ int main(int argc, char *argv[])
 						strncpy(domainname, delim, strlen(delim));
 						strncpy(domainname, delim, strlen(delim));
 						address = getaddress(delim);
 						address = getaddress(delim);
 						if (!address){
 						if (!address){
-							printf("error:unable to determine the remote host address\n");
+							printf("error:unable to determine the remote host "
+								"address\n");
 							exit(2);
 							exit(2);
 						}
 						}
 					}
 					}
@@ -1116,7 +1244,8 @@ int main(int argc, char *argv[])
 			case 't':
 			case 't':
 				trashchar=atoi(optarg);
 				trashchar=atoi(optarg);
 				if (!trashchar) {
 				if (!trashchar) {
-					printf("error: non-numerical number of trashed character\n");
+					printf("error: non-numerical number of trashed "
+						"character\n");
 					exit(2);
 					exit(2);
 				}
 				}
 				break;
 				break;
@@ -1153,18 +1282,20 @@ int main(int argc, char *argv[])
 	/* lots of conditions to check */
 	/* lots of conditions to check */
 	if (trace) {
 	if (trace) {
 		if (usrloc || flood || randtrash) {
 		if (usrloc || flood || randtrash) {
-			printf("error: trace can't be combined with usrloc, random or flood\n");
+			printf("error: trace can't be combined with usrloc, random or "
+				"flood\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (!uri_b) {
 		if (!uri_b) {
-			printf("error: for trace modus a sip:uri is realy needed\n");
+			printf("error: for trace mode a sip:uri is realy needed\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (file_b) {
 		if (file_b) {
 			printf("warning: file will be ignored for tracing.");
 			printf("warning: file will be ignored for tracing.");
 		}
 		}
 		if (!username) {
 		if (!username) {
-			printf("error: for trace modus without a file the sip:uir have to contain a username\n");
+			printf("error: for trace mode without a file the sip:uir have to "
+				"contain a username\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (!via_ins){
 		if (!via_ins){
@@ -1172,26 +1303,29 @@ int main(int argc, char *argv[])
 			via_ins=1;
 			via_ins=1;
 		}
 		}
 		if (!warning_ext) {
 		if (!warning_ext) {
-			printf("warning: IP extract from warning activated to be more informational\n");
+			printf("warning: IP extract from warning activated to be more "
+				"informational\n");
 			warning_ext=1;
 			warning_ext=1;
 		}
 		}
 		if (maxforw==-1) maxforw=255;
 		if (maxforw==-1) maxforw=255;
 	}
 	}
 	else if (usrloc) {
 	else if (usrloc) {
 		if (trace || flood || randtrash) {
 		if (trace || flood || randtrash) {
-			printf("error: usrloc can't be combined with trace, random or flood\n");
+			printf("error: usrloc can't be combined with trace, random or "
+				"flood\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (!username || !uri_b || nameend==-1) {
 		if (!username || !uri_b || nameend==-1) {
-			printf("error: for the USRLOC modus you have to give a sip:uri with a "
-					"username and the\n       username appendix end at least\n");
+			printf("error: for the USRLOC mode you have to give a sip:uri with "
+				"a username and the\n       username appendix end at least\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (via_ins) {
 		if (via_ins) {
 			via_ins=0;
 			via_ins=0;
 		}
 		}
 		if (redirects) {
 		if (redirects) {
-			printf("warning: redirects are not expected in USRLOC. Disableing\n");
+			printf("warning: redirects are not expected in USRLOC. "
+				"disableing\n");
 			redirects=0;
 			redirects=0;
 		}
 		}
 		if (namebeg==-1)
 		if (namebeg==-1)
@@ -1199,7 +1333,8 @@ int main(int argc, char *argv[])
 	}
 	}
 	else if (flood) {
 	else if (flood) {
 		if (trace || usrloc || randtrash) {
 		if (trace || usrloc || randtrash) {
-			printf("error: flood can't be combined with trace, random or usrloc\n");
+			printf("error: flood can't be combined with trace, random or "
+				"usrloc\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (!uri_b) {
 		if (!uri_b) {
@@ -1207,13 +1342,15 @@ int main(int argc, char *argv[])
 			exit(2);
 			exit(2);
 		}
 		}
 		if (redirects) {
 		if (redirects) {
-			printf("warning: redirects are not expected in flood. Disableing\n");
+			printf("warning: redirects are not expected in flood. "
+				"disableing\n");
 			redirects=0;
 			redirects=0;
 		}
 		}
 	}
 	}
 	else if (randtrash) {
 	else if (randtrash) {
 		if (trace || usrloc || flood) {
 		if (trace || usrloc || flood) {
-			printf("error: random can't be combined with trace, flood or usrloc\n");
+			printf("error: random can't be combined with trace, flood or "
+				"usrloc\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		if (!uri_b) {
 		if (!uri_b) {
@@ -1221,11 +1358,13 @@ int main(int argc, char *argv[])
 			exit(2);
 			exit(2);
 		}
 		}
 		if (redirects) {
 		if (redirects) {
-			printf("warning: redirects are not expected in random. Disableing\n");
+			printf("warning: redirects are not expected in random. "
+				"disableing\n");
 			redirects=0;
 			redirects=0;
 		}
 		}
 		if (verbose) {
 		if (verbose) {
-			printf("warning: random characters may destroy your terminal output\n");
+			printf("warning: random characters may destroy your terminal "
+				"output\n");
 		}
 		}
 	}
 	}
 	else {
 	else {
@@ -1234,7 +1373,8 @@ int main(int argc, char *argv[])
 			exit(2);
 			exit(2);
 		}
 		}
 		if (!(username || file_b)) {
 		if (!(username || file_b)) {
-			printf("error: ether a file or an username in the sip uri is required\n");
+			printf("error: ether a file or an username in the sip uri is "
+				"required\n");
 			exit(2);
 			exit(2);
 		}
 		}
 		
 		
@@ -1253,11 +1393,3 @@ int main(int argc, char *argv[])
 	return 0;
 	return 0;
 }
 }
 
 
-
-/*
-shoot will exercise the all types of sip servers.
-it is not to be used to measure round-trips and general connectivity.
-use ping for that. 
-written by farhan on 10th august, 2000.
-*/
-