[asterisk-commits] anthonyl: branch anthonyl/8291-iax2 r47680 - /team/anthonyl/8291-iax2/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Nov 15 11:14:59 MST 2006


Author: anthonyl
Date: Wed Nov 15 12:14:58 2006
New Revision: 47680

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47680
Log:
added some needed logging

Modified:
    team/anthonyl/8291-iax2/channels/chan_iax2.c

Modified: team/anthonyl/8291-iax2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/8291-iax2/channels/chan_iax2.c?view=diff&rev=47680&r1=47679&r2=47680
==============================================================================
--- team/anthonyl/8291-iax2/channels/chan_iax2.c (original)
+++ team/anthonyl/8291-iax2/channels/chan_iax2.c Wed Nov 15 12:14:58 2006
@@ -64,7 +64,7 @@
 #endif
 
 #include "asterisk/lock.h"
-#include "asterisk/frame.h" 
+#include "asterisk/frame.h"
 #include "asterisk/channel.h"
 #include "asterisk/logger.h"
 #include "asterisk/module.h"
@@ -143,7 +143,7 @@
 
 /*! \brief Maximum transimission unit for the UDP packet in the trunk not to be
     fragmented. This is based on 1516 - ethernet - ip - udp - iax minus one g711 frame = 1240 */
-#define MAX_TRUNK_MTU 1240 
+#define MAX_TRUNK_MTU 1240
 
 static int global_max_trunk_mtu; 	/*!< Maximum MTU, 0 if not used */
 static int trunk_timed, trunk_untimed, trunk_maxmtu, trunk_nmaxmtu ; 	/*!< Trunk MTU statistics */
@@ -191,7 +191,7 @@
 					 ~AST_FORMAT_SLINEAR &			\
 					 ~AST_FORMAT_ULAW &			\
 					 ~AST_FORMAT_ALAW &			\
-					 ~AST_FORMAT_G722) 
+					 ~AST_FORMAT_G722)
 /* A modem */
 #define IAX_CAPABILITY_LOWBANDWIDTH	(IAX_CAPABILITY_MEDBANDWIDTH & 		\
 					 ~AST_FORMAT_G726 &			\
@@ -270,8 +270,8 @@
 	IAX_CODEC_NOCAP = 	(1 << 16),	/*!< only consider requested format and ignore capabilities*/
 	IAX_RTCACHEFRIENDS = 	(1 << 17), 	/*!< let realtime stay till your reload */
 	IAX_RTUPDATE = 		(1 << 18), 	/*!< Send a realtime update */
-	IAX_RTAUTOCLEAR = 	(1 << 19), 	/*!< erase me on expire */ 
-	IAX_FORCEJITTERBUF =	(1 << 20),	/*!< Force jitterbuffer, even when bridged to a channel that can take jitter */ 
+	IAX_RTAUTOCLEAR = 	(1 << 19), 	/*!< erase me on expire */
+	IAX_FORCEJITTERBUF =	(1 << 20),	/*!< Force jitterbuffer, even when bridged to a channel that can take jitter */
 	IAX_RTIGNOREREGEXPIRE =	(1 << 21),	/*!< When using realtime, ignore registration expiration */
 	IAX_TRUNKTIMESTAMPS =	(1 << 22),	/*!< Send trunk timestamps */
 	IAX_TRANSFERMEDIA = 	(1 << 23),      /*!< When doing IAX2 transfers, transfer media only */
@@ -297,7 +297,7 @@
 		AST_STRING_FIELD(cid_num);
 		AST_STRING_FIELD(cid_name);
 	);
-	
+
 	int authmethods;
 	int encmethods;
 	int amaflags;
@@ -361,7 +361,7 @@
 	int pokefreqnotok;				/*!< How often to check when the host has been determined to be down */
 	int historicms;					/*!< How long recent average responses took */
 	int smoothing;					/*!< Sample over how many units to determine historic ms */
-	
+
 	struct ast_ha *ha;
 	AST_LIST_ENTRY(iax2_peer) entry;
 };
@@ -514,7 +514,7 @@
 	/*! The jitterbuffer */
         jitterbuf *jb;
 	/*! active jb read scheduler id */
-        int jbid;                       
+        int jbid;
 	/*! LAG */
 	int lag;
 	/*! Error, as discovered by the manager */
@@ -570,7 +570,7 @@
 		AST_STRING_FIELD(mohinterpret);
 		AST_STRING_FIELD(mohsuggest);
 	);
-	
+
 	/*! permitted authentication methods */
 	int authmethods;
 	/*! permitted encryption methods */
@@ -605,7 +605,7 @@
 
 	/*! Who we are bridged to */
 	unsigned short bridgecallno;
-	
+
 	int pingid;			/*!< Transmit PING request */
 	int lagid;			/*!< Retransmit lag request */
 	int autoid;			/*!< Auto hangup for Dialplan requestor */
@@ -696,12 +696,12 @@
 #endif
 #ifdef DEBUG_SCHED_MULTITHREAD
 	char curfunc[80];
-#endif	
+#endif
 	int actions;
 	pthread_t threadid;
 	int threadnum;
 	struct sockaddr_in iosin;
-	unsigned char buf[4096]; 
+	unsigned char buf[4096];
 	int iores;
 	int iofd;
 	time_t checktime;
@@ -894,7 +894,7 @@
 		return 0;
 	}
 	time(&t);
-	if (t != lasterror) 
+	if (t != lasterror)
 		ast_log(LOG_NOTICE, "Out of idle IAX2 threads for scheduling!\n");
 	lasterror = t;
 
@@ -915,7 +915,7 @@
 	if (iaxs[callno]) {
 #ifdef SCHED_MULTITHREADED
 		if (schedule_action(__send_ping, data))
-#endif		
+#endif
 			__send_ping(data);
 		return 1;
 	} else
@@ -948,7 +948,7 @@
 	if (iaxs[callno]) {
 #ifdef SCHED_MULTITHREADED
 		if (schedule_action(__send_lagrq, data))
-#endif		
+#endif
 			__send_lagrq(data);
 		return 1;
 	} else
@@ -990,7 +990,7 @@
 		return csub;
 }
 
-static struct iax2_peer *find_peer(const char *name, int realtime) 
+static struct iax2_peer *find_peer(const char *name, int realtime)
 {
 	struct iax2_peer *peer = NULL;
 
@@ -1052,7 +1052,7 @@
 		tmp = NULL;
 		return NULL;
 	}
-		
+
 	tmp->prefs = prefs;
 	tmp->callno = 0;
 	tmp->peercallno = 0;
@@ -1256,7 +1256,7 @@
 			iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
 			iaxs[x]->amaflags = amaflags;
 			ast_copy_flags(iaxs[x], (&globalflags), IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
-			
+
 			ast_string_field_set(iaxs[x], accountcode, accountcode);
 			ast_string_field_set(iaxs[x], mohinterpret, mohinterpret);
 			ast_string_field_set(iaxs[x], mohsuggest, mohsuggest);
@@ -1353,7 +1353,7 @@
 	}
 	/* Unlink our newly created file */
 	unlink(s2);
-	
+
 	/* Now copy the firmware into it */
 	len = stbuf.st_size;
 	while(len) {
@@ -1399,7 +1399,7 @@
 		close(fd);
 		return -1;
 	}
-	fwh = mmap(NULL, stbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 
+	fwh = mmap(NULL, stbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
 	if (!fwh) {
 		ast_log(LOG_WARNING, "mmap failed: %s\n", strerror(errno));
 		close(fd);
@@ -1428,12 +1428,12 @@
 			return 0;
 		}
 	}
-	
+
 	if (!cur && ((cur = ast_calloc(1, sizeof(*cur))))) {
 		cur->fd = -1;
 		AST_LIST_INSERT_TAIL(&firmwares, cur, list);
 	}
-	
+
 	if (cur) {
 		if (cur->fwh)
 			munmap(cur->fwh, cur->mmaplen);
@@ -1444,7 +1444,7 @@
 		cur->mmaplen = stbuf.st_size;
 		cur->dead = 0;
 	}
-	
+
 	return 0;
 }
 
@@ -1480,7 +1480,7 @@
 		return -1;
 
 	start *= bs;
-	
+
 	AST_LIST_LOCK(&firmwares);
 	AST_LIST_TRAVERSE(&firmwares, cur, list) {
 		if (strcmp((char *)dev, (char *)cur->fwh->devname))
@@ -1534,7 +1534,7 @@
 			}
 		}
 		closedir(fwd);
-	} else 
+	} else
 		ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", dir, strerror(errno));
 
 	/* Clean up leftovers */
@@ -1586,7 +1586,7 @@
 	else {
 		if (m.msg_controllen) {
 			sin = (struct sockaddr_in *)SO_EE_OFFENDER(&e);
-			if (sin) 
+			if (sin)
 				ast_log(LOG_WARNING, "Receive error from %s\n", ast_inet_ntoa(sin->sin_addr));
 			else
 				ast_log(LOG_WARNING, "No address detected??\n");
@@ -1620,7 +1620,7 @@
 	/* Don't send if there was an error, but return error instead */
 	if (!callno || !iaxs[callno] || iaxs[callno]->error)
 	    return -1;
-	
+
 	/* Called with iaxsl held */
 	if (option_debug > 2 && iaxdebug)
 		ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
@@ -1691,7 +1691,7 @@
 
 	if (!ast_test_flag(pvt, IAX_ALREADYGONE)) {
 		iax2_destroy_helper(pvt);
-		ast_set_flag(pvt, IAX_ALREADYGONE);	
+		ast_set_flag(pvt, IAX_ALREADYGONE);
 	}
 
 	if ((c = pvt->owner)) {
@@ -1713,7 +1713,7 @@
 retry:
 	pvt = iaxs[callno];
 	gettimeofday(&lastused[callno], NULL);
-	
+
 	owner = pvt ? pvt->owner : NULL;
 
 	if (owner) {
@@ -1733,7 +1733,7 @@
 		iax2_destroy_helper(pvt);
 
 		/* Already gone */
-		ast_set_flag(pvt, IAX_ALREADYGONE);	
+		ast_set_flag(pvt, IAX_ALREADYGONE);
 
 		if (owner) {
 			/* If there's an owner, prod it to give up */
@@ -1743,7 +1743,7 @@
 
 		AST_LIST_TRAVERSE(&iaxq.queue, cur, list) {
 			/* Cancel any pending transmissions */
-			if (cur->callno == pvt->callno) 
+			if (cur->callno == pvt->callno)
 				cur->retries = -1;
 		}
 		if (pvt->reg)
@@ -1791,7 +1791,7 @@
 	int freeme=0;
 	int callno = f->callno;
 	/* Make sure this call is still active */
-	if (callno) 
+	if (callno)
 		ast_mutex_lock(&iaxsl[callno]);
 	if (callno && iaxs[callno]) {
 		if ((f->retries < 0) /* Already ACK'd */ ||
@@ -1802,7 +1802,7 @@
 						/* Transfer timeout */
 						send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_TXREJ, 0, NULL, 0, -1);
 					} else if (f->final) {
-						if (f->final) 
+						if (f->final)
 							iax2_destroy(callno);
 					} else {
 						if (iaxs[callno]->owner)
@@ -1868,7 +1868,7 @@
 {
 #ifdef SCHED_MULTITHREADED
 	if (schedule_action(__attempt_transmit, data))
-#endif		
+#endif
 		__attempt_transmit(data);
 	return 0;
 }
@@ -1893,7 +1893,7 @@
 	} else {
 		ast_cli(fd, "SORRY peer %s was not found in the cache.\n", argv[3]);
 	}
-	
+
 	return RESULT_SUCCESS;
 }
 
@@ -1934,7 +1934,7 @@
 		return RESULT_SHOWUSAGE;
 
 	test_jit = atoi(argv[3]);
-	if (argc == 5) 
+	if (argc == 5)
 		test_jitpct = atoi(argv[4]);
 
 	return RESULT_SUCCESS;
@@ -1958,7 +1958,7 @@
 		} else {
 			ast_copy_string(status, "UNKNOWN", statuslen);
 		}
-	} else { 
+	} else {
 		ast_copy_string(status, "Unmonitored", statuslen);
 		res = -1;
 	}
@@ -2012,7 +2012,7 @@
 		ast_cli(fd, ")\n");
 
 		ast_cli(fd, "  Status       : ");
-		peer_status(peer, status, sizeof(status));	
+		peer_status(peer, status, sizeof(status));
 		ast_cli(fd, "%s\n",status);
 		ast_cli(fd, "  Qualify      : every %dms when OK, every %dms when UNREACHABLE (sample smoothing %s)\n", peer->pokefreqok, peer->pokefreqnotok, peer->smoothing ? "On" : "Off");
 		ast_cli(fd,"\n");
@@ -2072,7 +2072,7 @@
 	trunk_timed = trunk_untimed = 0;
 	if (trunk_maxmtu > trunk_nmaxmtu)
 		trunk_nmaxmtu = trunk_maxmtu;
-	
+
 	return RESULT_SUCCESS;
 }
 
@@ -2082,23 +2082,23 @@
 	int mtuv;
 
 	if (argc != 4)
-		return RESULT_SHOWUSAGE; 
-	if (strncasecmp(argv[3], "default", strlen(argv[3])) == 0) 
-		mtuv = MAX_TRUNK_MTU; 
-	else                                         
-		mtuv = atoi(argv[3]); 
+		return RESULT_SHOWUSAGE;
+	if (strncasecmp(argv[3], "default", strlen(argv[3])) == 0)
+		mtuv = MAX_TRUNK_MTU;
+	else
+		mtuv = atoi(argv[3]);
 
 	if (mtuv == 0) {
-		ast_cli(fd, "Trunk MTU control disabled (mtu was %d)\n", global_max_trunk_mtu); 
-		global_max_trunk_mtu = 0; 
-		return RESULT_SUCCESS; 
+		ast_cli(fd, "Trunk MTU control disabled (mtu was %d)\n", global_max_trunk_mtu);
+		global_max_trunk_mtu = 0;
+		return RESULT_SUCCESS;
 	}
 	if (mtuv < 172 || mtuv > 4000) {
-		ast_cli(fd, "Trunk MTU must be between 172 and 4000\n"); 
-		return RESULT_SHOWUSAGE; 
-	}
-	ast_cli(fd, "Trunk MTU changed from %d to %d\n", global_max_trunk_mtu, mtuv); 
-	global_max_trunk_mtu = mtuv; 
+		ast_cli(fd, "Trunk MTU must be between 172 and 4000\n");
+		return RESULT_SHOWUSAGE;
+	}
+	ast_cli(fd, "Trunk MTU changed from %d to %d\n", global_max_trunk_mtu, mtuv);
+	global_max_trunk_mtu = mtuv;
 	return RESULT_SUCCESS;
 }
 
@@ -2193,25 +2193,25 @@
 static void update_jbsched(struct chan_iax2_pvt *pvt)
 {
 	int when;
-	
+
 	when = ast_tvdiff_ms(ast_tvnow(), pvt->rxcore);
-	
+
 	when = jb_next(pvt->jb) - when;
-	
+
 	if(pvt->jbid > -1) ast_sched_del(sched, pvt->jbid);
-	
+
 	if(when <= 0) {
 		/* XXX should really just empty until when > 0.. */
 		when = 1;
 	}
-	
+
 	pvt->jbid = ast_sched_add(sched, when, get_from_jb, CALLNO_TO_PTR(pvt->callno));
-	
+
 	/* Signal scheduler thread */
 	signal_condition(&sched_lock, &sched_cond);
 }
 
-static void __get_from_jb(void *p) 
+static void __get_from_jb(void *p)
 {
 	int callno = PTR_TO_CALLNO(p);
 	struct chan_iax2_pvt *pvt = NULL;
@@ -2221,7 +2221,7 @@
 	long now;
 	long next;
 	struct timeval tv;
-	
+
 	/* Make sure we have a valid private structure before going on */
 	ast_mutex_lock(&iaxsl[callno]);
 	pvt = iaxs[callno];
@@ -2232,15 +2232,15 @@
 	}
 
 	pvt->jbid = -1;
-	
+
 	gettimeofday(&tv,NULL);
 	/* round up a millisecond since ast_sched_runq does; */
 	/* prevents us from spinning while waiting for our now */
 	/* to catch up with runq's now */
 	tv.tv_usec += 1000;
-	
+
 	now = ast_tvdiff_ms(tv, pvt->rxcore);
-	
+
 	if(now >= (next = jb_next(pvt->jb))) {
 		ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
 		switch(ret) {
@@ -2251,7 +2251,7 @@
 		case JB_INTERP:
 		{
 			struct ast_frame af;
-			
+
 			/* create an interpolation frame */
 			af.frametype = AST_FRAME_VOICE;
 			af.subclass = pvt->voiceformat;
@@ -2262,7 +2262,7 @@
 			af.data  = NULL;
 			af.delivery = ast_tvadd(pvt->rxcore, ast_samp2tv(next, 1000));
 			af.offset=AST_FRIENDLY_OFFSET;
-			
+
 			/* queue the frame:  For consistency, we would call __do_deliver here, but __do_deliver wants an iax_frame,
 			 * which we'd need to malloc, and then it would free it.  That seems like a drag */
 			if (!ast_test_flag(iaxs[callno], IAX_ALREADYGONE))
@@ -2289,7 +2289,7 @@
 {
 #ifdef SCHED_MULTITHREADED
 	if (schedule_action(__get_from_jb, data))
-#endif		
+#endif
 		__get_from_jb(data);
 	return 0;
 }
@@ -2302,7 +2302,7 @@
 
 	/* Attempt to recover wrapped timestamps */
 	unwrap_timestamp(fr);
-	
+
 
 	/* delivery time is sender's sent timestamp converted back into absolute time according to our clock */
 	if ( !fromtrunk && !ast_tvzero(iaxs[fr->callno]->rxcore))
@@ -2406,7 +2406,7 @@
 
 static int iax2_sendtext(struct ast_channel *c, const char *text)
 {
-	
+
 	return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_TEXT,
 		0, 0, (unsigned char *)text, strlen(text) + 1, -1);
 }
@@ -2459,7 +2459,7 @@
 		return NULL;
 
 	peer = build_peer(peername, var, NULL, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
-	
+
 	if (!peer)
 		return NULL;
 
@@ -2472,7 +2472,7 @@
 				destroy_peer(peer);
 				peer = NULL;
 				break;
-			} 
+			}
 		} else if (!strcasecmp(tmp->name, "regseconds")) {
 			ast_get_time_t(tmp->value, &regseconds, 0, NULL);
 		} else if (!strcasecmp(tmp->name, "ipaddr")) {
@@ -2502,7 +2502,7 @@
 		if (ast_test_flag(peer, IAX_DYNAMIC))
 			reg_source_db(peer);
 	} else {
-		ast_set_flag(peer, IAX_TEMPONLY);	
+		ast_set_flag(peer, IAX_TEMPONLY);
 	}
 
 	if (!ast_test_flag(&globalflags, IAX_RTIGNOREREGEXPIRE) && dynamic) {
@@ -2541,7 +2541,7 @@
 			if (strcasecmp(tmp->value, "friend") &&
 			    strcasecmp(tmp->value, "user")) {
 				return NULL;
-			} 
+			}
 		}
 		tmp = tmp->next;
 	}
@@ -2558,7 +2558,7 @@
 		AST_LIST_INSERT_HEAD(&users, user, entry);
 		AST_LIST_UNLOCK(&users);
 	} else {
-		ast_set_flag(user, IAX_TEMPONLY);	
+		ast_set_flag(user, IAX_TEMPONLY);
 	}
 
 	return user;
@@ -2568,11 +2568,11 @@
 {
 	char port[10];
 	char regseconds[20];
-	
+
 	snprintf(regseconds, sizeof(regseconds), "%d", (int)regtime);
 	snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
-	ast_update_realtime("iaxpeers", "name", peername, 
-		"ipaddr", ast_inet_ntoa(sin->sin_addr), "port", port, 
+	ast_update_realtime("iaxpeers", "name", peername,
+		"ipaddr", ast_inet_ntoa(sin->sin_addr), "port", port,
 		"regseconds", regseconds, NULL);
 }
 
@@ -2623,7 +2623,7 @@
 	}
 
 	cai->found = 1;
-	
+
 	/* if the peer has no address (current or default), return failure */
 	if (!(peer->addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr)) {
 		if (ast_test_flag(peer, IAX_TEMPONLY))
@@ -2701,7 +2701,7 @@
 {
 #ifdef SCHED_MULTITHREADED
 	if (schedule_action(__auto_congest, data))
-#endif		
+#endif
 		__auto_congest(data);
 	return 0;
 }
@@ -2841,7 +2841,7 @@
 	l = c->cid.cid_num;
 	n = c->cid.cid_name;
 
-	/* Now build request */	
+	/* Now build request */
 	memset(&ied, 0, sizeof(ied));
 
 	/* On new call, first IE MUST be IAX version of caller */
@@ -2899,7 +2899,7 @@
 	iaxs[callno]->encmethods = cai.encmethods;
 
 	iaxs[callno]->adsi = cai.adsi;
-	
+
 	ast_string_field_set(iaxs[callno], mohinterpret, cai.mohinterpret);
 	ast_string_field_set(iaxs[callno], mohsuggest, cai.mohsuggest);
 
@@ -2930,11 +2930,11 @@
 
 	ast_mutex_unlock(&iaxsl[callno]);
 	ast_setstate(c, AST_STATE_RINGING);
-	
+
 	return 0;
 }
 
-static int iax2_hangup(struct ast_channel *c) 
+static int iax2_hangup(struct ast_channel *c)
 {
 	unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
 	int alreadygone;
@@ -2947,7 +2947,7 @@
 		alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
 		/* Send the hangup unless we have had a transmission error or are already gone */
  		iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
-		if (!iaxs[callno]->error && !alreadygone) 
+		if (!iaxs[callno]->error && !alreadygone)
  			send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1);
 		/* Explicitly predestroy it */
 		iax2_predestroy(callno);
@@ -2959,7 +2959,7 @@
 		}
 	}
 	ast_mutex_unlock(&iaxsl[callno]);
-	if (option_verbose > 2) 
+	if (option_verbose > 2)
 		ast_verbose(VERBOSE_PREFIX_3 "Hungup '%s'\n", c->name);
 	return 0;
 }
@@ -2990,7 +2990,7 @@
 	}
 }
 
-static struct ast_frame *iax2_read(struct ast_channel *c) 
+static struct ast_frame *iax2_read(struct ast_channel *c)
 {
 	ast_log(LOG_NOTICE, "I should never be called!\n");
 	return &ast_null_frame;
@@ -3011,7 +3011,7 @@
 	iax_ie_append_addr(&ied1, IAX_IE_APPARENT_ADDR, &iaxs[callno0]->addr);
 	iax_ie_append_short(&ied1, IAX_IE_CALLNO, iaxs[callno0]->peercallno);
 	iax_ie_append_int(&ied1, IAX_IE_TRANSFERID, transferid);
-	
+
 	res = send_command(iaxs[callno0], AST_FRAME_IAX, IAX_COMMAND_TXREQ, 0, ied0.buf, ied0.pos, -1);
 	if (res)
 		return -1;
@@ -3151,7 +3151,7 @@
 		other = (who == c0) ? c1 : c0;  /* the 'other' channel */
 		if ((f->frametype == AST_FRAME_VOICE) ||
 		    (f->frametype == AST_FRAME_TEXT) ||
-		    (f->frametype == AST_FRAME_VIDEO) || 
+		    (f->frametype == AST_FRAME_VIDEO) ||
 		    (f->frametype == AST_FRAME_IMAGE) ||
 		    (f->frametype == AST_FRAME_DTMF)) {
 			/* monitored dtmf take out of the bridge.
@@ -3212,7 +3212,7 @@
 		return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1);
 	}
 }
-	
+
 static int iax2_transfer(struct ast_channel *c, const char *dest)
 {
 	unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
@@ -3232,7 +3232,7 @@
 		ast_log(LOG_DEBUG, "Transferring '%s' to '%s'\n", c->name, dest);
 	return send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1);
 }
-	
+
 static int iax2_getpeertrunk(struct sockaddr_in sin)
 {
 	struct iax2_peer *peer = NULL;
@@ -3332,14 +3332,14 @@
 	}
 	/* Update last transmit time now */
 	tpeer->lasttxtime = *tv;
-	
+
 	/* Calculate ms offset */
 	ms = ast_tvdiff_ms(*tv, tpeer->txtrunktime);
 	/* Predict from last value */
 	pred = tpeer->lastsent + sampms;
 	if (abs(ms - pred) < MAX_TIMESTAMP_SKEW)
 		ms = pred;
-	
+
 	/* We never send the same timestamp twice, so fudge a little if we must */
 	if (ms == tpeer->lastsent)
 		ms = tpeer->lastsent + 1;
@@ -3384,7 +3384,7 @@
 		} else if (f->frametype == AST_FRAME_IAX) {
 			genuine = 1;
 		} else if (f->frametype == AST_FRAME_CNG) {
-			p->notsilenttx = 0;	
+			p->notsilenttx = 0;
 		}
 	}
 	if (ast_tvzero(p->offset)) {
@@ -3412,7 +3412,7 @@
 				   When we send voice, we usually send "calculated" timestamps worked out
 			 	   on the basis of the number of samples sent. When we send other frames,
 				   we usually send timestamps worked out from the real clock.
-				   The problem is that they can tend to drift out of step because the 
+				   The problem is that they can tend to drift out of step because the
 			    	   source channel's clock and our clock may not be exactly at the same rate.
 				   We fix this by continuously "tweaking" p->offset.  p->offset is "time zero"
 				   for this call.  Moving it adjusts timestamps for non-voice frames.
@@ -3423,7 +3423,7 @@
 				   The use of a moving average avoids offset moving too radically.
 				   Generally, "adjust" roams back and forth around 0, with offset hardly
 				   changing at all.  But if a consistent different starts to develop it
-				   will be eliminated over the course of 10 frames (200-300msecs) 
+				   will be eliminated over the course of 10 frames (200-300msecs)
 				*/
 				adjust = (ms - p->nextpred);
 				if (adjust < 0)
@@ -3523,7 +3523,7 @@
 static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin, int fd)
 {
 	struct iax2_trunk_peer *tpeer = NULL;
-	
+
 	/* Finds and locks trunk peer */
 	AST_LIST_LOCK(&tpeers);
 
@@ -3562,7 +3562,7 @@
 	struct iax2_trunk_peer *tpeer;
 	void *tmp, *ptr;
 	struct timeval now;
-	int res; 
+	int res;
 	struct ast_iax2_meta_trunk_entry *met;
 	struct ast_iax2_meta_trunk_mini *mtm;
 
@@ -3576,7 +3576,7 @@
 					ast_mutex_unlock(&tpeer->lock);
 					return -1;
 				}
-				
+
 				tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
 				tpeer->trunkdata = tmp;
 				if (option_debug)
@@ -3613,14 +3613,14 @@
 		tpeer->calls++;
 
 		/* track the largest mtu we actually have sent */
-		if (tpeer->trunkdatalen + f->datalen + 4 > trunk_maxmtu) 
-			trunk_maxmtu = tpeer->trunkdatalen + f->datalen + 4 ; 
+		if (tpeer->trunkdatalen + f->datalen + 4 > trunk_maxmtu)
+			trunk_maxmtu = tpeer->trunkdatalen + f->datalen + 4 ;
 
 		/* if we have enough for a full MTU, ship it now without waiting */
 		if (global_max_trunk_mtu > 0 && tpeer->trunkdatalen + f->datalen + 4 >= global_max_trunk_mtu) {
 			gettimeofday(&now, NULL);
-			res = send_trunk(tpeer, &now); 
-			trunk_untimed ++; 
+			res = send_trunk(tpeer, &now);
+			trunk_untimed ++;
 		}
 
 		ast_mutex_unlock(&tpeer->lock);
@@ -3643,7 +3643,7 @@
 		ast_log(LOG_WARNING, "len should be multiple of 16, not %d!\n", len);
 	for (x=0;x<len;x++)
 		dst[x] = src[x] ^ 0xff;
-#else	
+#else
 	unsigned char lastblock[16] = { 0 };
 	int x;
 	while(len > 0) {
@@ -3674,7 +3674,7 @@
 		for (x=0;x<16;x++)
 			curblock[x] ^= src[x];
 		aes_encrypt(curblock, dst, ecx);
-		memcpy(curblock, dst, sizeof(curblock)); 
+		memcpy(curblock, dst, sizeof(curblock));
 		dst += 16;
 		src += 16;
 		len -= 16;
@@ -3776,7 +3776,7 @@
 		struct MD5Context md5;
 		unsigned char digest[16];
 		char *tmppw, *stringp;
-		
+
 		tmppw = ast_strdupa(iaxs[callno]->secret);
 		stringp = tmppw;
 		while ((tmppw = strsep(&stringp, ";"))) {
@@ -3791,7 +3791,7 @@
 				break;
 			}
 		}
-	} else 
+	} else
 		res = decode_frame(&iaxs[callno]->dcx, fh, f, datalen);
 	return res;
 }
@@ -3813,12 +3813,12 @@
 	int sendmini=0;
 	unsigned int lastsent;
 	unsigned int fts;
-		
+
 	if (!pvt) {
 		ast_log(LOG_WARNING, "No private structure for packet?\n");
 		return -1;
 	}
-	
+
 	lastsent = pvt->lastsent;
 
 	/* Calculate actual timestamp */
@@ -3831,20 +3831,20 @@
 	    return 0;
 
 
-	if ((ast_test_flag(pvt, IAX_TRUNK) || 
+	if ((ast_test_flag(pvt, IAX_TRUNK) ||
 			(((fts & 0xFFFF0000L) == (lastsent & 0xFFFF0000L)) ||
 			((fts & 0xFFFF0000L) == ((lastsent + 0x10000) & 0xFFFF0000L))))
 		/* High two bytes are the same on timestamp, or sending on a trunk */ &&
-	    (f->frametype == AST_FRAME_VOICE) 
+	    (f->frametype == AST_FRAME_VOICE)
 		/* is a voice frame */ &&
-		(f->subclass == pvt->svoiceformat) 
+		(f->subclass == pvt->svoiceformat)
 		/* is the same type */ ) {
 			/* Force immediate rather than delayed transmission */
 			now = 1;
 			/* Mark that mini-style frame is appropriate */
 			sendmini = 1;
 	}
-	if (((fts & 0xFFFF8000L) == (lastsent & 0xFFFF8000L)) && 
+	if (((fts & 0xFFFF8000L) == (lastsent & 0xFFFF8000L)) &&
 		(f->frametype == AST_FRAME_VIDEO) &&
 		((f->subclass & ~0x1) == pvt->svideoformat)) {
 			now = 1;
@@ -3922,7 +3922,7 @@
 			} else
 				ast_log(LOG_WARNING, "Supposed to send packet encrypted, but no key?\n");
 		}
-	
+
 		if (now) {
 			res = send_packet(fr);
 		} else
@@ -3942,7 +3942,7 @@
 			fr->datalen = fr->af.datalen + sizeof(struct ast_iax2_video_hdr);
 			fr->data = vh;
 			fr->retries = -1;
-			res = send_packet(fr);			
+			res = send_packet(fr);
 		} else {
 			/* Mini-frames have no sequence number */
 			fr->oseqno = -1;
@@ -3999,25 +3999,25 @@
 	AST_LIST_TRAVERSE(&users, user, entry) {
 		if (havepattern && regexec(&regexbuf, user->name, 0, NULL, 0))
 			continue;
-		
+
 		if (!ast_strlen_zero(user->secret)) {
   			ast_copy_string(auth,user->secret,sizeof(auth));
 		} else if (!ast_strlen_zero(user->inkeys)) {
   			snprintf(auth, sizeof(auth), "Key: %-15.15s ", user->inkeys);
  		} else
 			ast_copy_string(auth, "-no secret-", sizeof(auth));
-		
+
 		if(ast_test_flag(user,IAX_CODEC_NOCAP))
 			pstr = "REQ Only";
 		else if(ast_test_flag(user,IAX_CODEC_NOPREFS))
 			pstr = "Disabled";
 		else
 			pstr = ast_test_flag(user,IAX_CODEC_USER_FIRST) ? "Caller" : "Host";
-		
-		ast_cli(fd, FORMAT2, user->name, auth, user->authmethods, 
+
+		ast_cli(fd, FORMAT2, user->name, auth, user->authmethods,
 			user->contexts ? user->contexts->context : context,
 			user->ha ? "Yes" : "No", pstr);
-		
+
 	}
 	AST_LIST_UNLOCK(&users);
 
@@ -4101,7 +4101,7 @@
 			snprintf(name, sizeof(name), "%s/%s", peer->name, peer->username);
 		else
 			ast_copy_string(name, peer->name, sizeof(name));
-		
+
 		retstatus = peer_status(peer, status, sizeof(status));
 		if (retstatus > 0)
 			online_peers++;
@@ -4109,25 +4109,25 @@
 			offline_peers++;
 		else
 			unmonitored_peers++;
-		
+
 		ast_copy_string(nm, ast_inet_ntoa(peer->mask), sizeof(nm));
-		
-		snprintf(srch, sizeof(srch), FORMAT, name, 
+
+		snprintf(srch, sizeof(srch), FORMAT, name,
 			 peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
 			 ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
 			 nm,
 			 ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : "   ",
 			 peer->encmethods ? "(E)" : "   ", status, term);
-		
+
 		if (s)
-			astman_append(s, FORMAT, name, 
+			astman_append(s, FORMAT, name,
 				      peer->addr.sin_addr.s_addr ? ast_inet_ntoa( peer->addr.sin_addr) : "(Unspecified)",
 				      ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
 				      nm,
 				      ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : "   ",
 				      peer->encmethods ? "(E)" : "   ", status, term);
 		else
-			ast_cli(fd, FORMAT, name, 
+			ast_cli(fd, FORMAT, name,
 				peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
 				ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
 				nm,
@@ -4159,17 +4159,17 @@
 
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
-		
+
 	ast_cli(fd, "IAX2 Thread Information\n");
 	time(&t);
 	ast_cli(fd, "Idle Threads:\n");
 	AST_LIST_LOCK(&idle_list);
 	AST_LIST_TRAVERSE(&idle_list, thread, list) {
 #ifdef DEBUG_SCHED_MULTITHREAD
-		ast_cli(fd, "Thread %d: state=%d, update=%d, actions=%d, func ='%s'\n", 
+		ast_cli(fd, "Thread %d: state=%d, update=%d, actions=%d, func ='%s'\n",
 			thread->threadnum, thread->iostate, (int)(t - thread->checktime), thread->actions, thread->curfunc);
 #else
-		ast_cli(fd, "Thread %d: state=%d, update=%d, actions=%d\n", 
+		ast_cli(fd, "Thread %d: state=%d, update=%d, actions=%d\n",
 			thread->threadnum, thread->iostate, (int)(t - thread->checktime), thread->actions);
 #endif
 		threadcount++;
@@ -4183,10 +4183,10 @@
 		else
 			type = 'P';
 #ifdef DEBUG_SCHED_MULTITHREAD
-		ast_cli(fd, "Thread %c%d: state=%d, update=%d, actions=%d, func ='%s'\n", 
+		ast_cli(fd, "Thread %c%d: state=%d, update=%d, actions=%d, func ='%s'\n",
 			type, thread->threadnum, thread->iostate, (int)(t - thread->checktime), thread->actions, thread->curfunc);
 #else
-		ast_cli(fd, "Thread %c%d: state=%d, update=%d, actions=%d\n", 
+		ast_cli(fd, "Thread %c%d: state=%d, update=%d, actions=%d\n",
 			type, thread->threadnum, thread->iostate, (int)(t - thread->checktime), thread->actions);
 #endif
 		threadcount++;
@@ -4231,7 +4231,7 @@
 	AST_LIST_LOCK(&firmwares);
 	AST_LIST_TRAVERSE(&firmwares, cur, list) {
 		if ((argc == 3) || (!strcasecmp(argv[3], (char *)cur->fwh->devname)))  {
-			ast_cli(fd, "%-15.15s  %-15d %-15d\n", cur->fwh->devname, 
+			ast_cli(fd, "%-15.15s  %-15d %-15d\n", cur->fwh->devname,
 				ntohs(cur->fwh->version), (int)ntohl(cur->fwh->datalen));
 		}
 	}
@@ -4290,12 +4290,12 @@
 	ast_cli(fd, FORMAT2, "Host", "dnsmgr", "Username", "Perceived", "Refresh", "State");
 	for (reg = registrations;reg;reg = reg->next) {
 		snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
-		if (reg->us.sin_addr.s_addr) 
+		if (reg->us.sin_addr.s_addr)
 			snprintf(perceived, sizeof(perceived), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
 		else
 			ast_copy_string(perceived, "<Unregistered>", sizeof(perceived));
-		ast_cli(fd, FORMAT, host, 
-					(reg->dnsmgr) ? "Y" : "N", 
+		ast_cli(fd, FORMAT, host,
+					(reg->dnsmgr) ? "Y" : "N",
 					reg->username, perceived, reg->refresh, regstate2str(reg->regstate));
 	}
 	AST_LIST_UNLOCK(&peers);
@@ -4320,7 +4320,7 @@
 		if (iaxs[x]) {
 			int lag, jitter, localdelay;
 			jb_info jbinfo;
-			
+
 			if(ast_test_flag(iaxs[x], IAX_USEJITTERBUF)) {
 				jb_getinfo(iaxs[x]->jb, &jbinfo);
 				jitter = jbinfo.jitter;
@@ -4332,7 +4332,7 @@
 			lag = iaxs[x]->remote_rr.delay;
 			ast_cli(fd, FORMAT,
 				iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
-				ast_inet_ntoa(iaxs[x]->addr.sin_addr), 
+				ast_inet_ntoa(iaxs[x]->addr.sin_addr),
 				S_OR(iaxs[x]->username, "(None)"),
 				iaxs[x]->callno, iaxs[x]->peercallno,
 				iaxs[x]->oseqno, iaxs[x]->iseqno,
@@ -4361,7 +4361,7 @@
 			int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
 			char *fmt;
 			jb_info jbinfo;
-			
+
 			if(ast_test_flag(iaxs[x], IAX_USEJITTERBUF)) {
 				jb_getinfo(iaxs[x]->jb, &jbinfo);
 				localjitter = jbinfo.jitter;
@@ -4383,11 +4383,11 @@
 			else
 				fmt = "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n";
 			if (s)
-				
+
 				astman_append(s, fmt,
 					      iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
 					      iaxs[x]->pingtime,
-					      localjitter, 
+					      localjitter,
 					      localdelay,
 					      locallost,
 					      locallosspct,
@@ -4405,7 +4405,7 @@
 				ast_cli(fd, fmt,
 					iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
 					iaxs[x]->pingtime,
-					localjitter, 
+					localjitter,
 					localdelay,
 					locallost,
 					locallosspct,
@@ -4523,7 +4523,7 @@
 	return res;
 }
 
-static int __send_command(struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno, 
+static int __send_command(struct chan_iax2_pvt *i, char type, int command, unsigned int ts, const unsigned char *data, int datalen, int seqno,
 		int now, int transfer, int final)
 {
 	struct ast_frame f;
@@ -4625,7 +4625,7 @@
 	if (ies->capability) {
 		gotcapability = 1;
 		iaxs[callno]->peercapability = ies->capability;
-	} 
+	}
 	if (ies->version)
 		version = ies->version;
 
@@ -4635,10 +4635,10 @@
 		ast_codec_pref_convert(&iaxs[callno]->prefs, ies->codec_prefs, 32, 0);
 	}
 
-	if (!gotcapability) 
+	if (!gotcapability)
 		iaxs[callno]->peercapability = iaxs[callno]->peerformat;
 	if (version > IAX_PROTO_VERSION) {
-		ast_log(LOG_WARNING, "Peer '%s' has too new a protocol version (%d) for me\n", 
+		ast_log(LOG_WARNING, "Peer '%s' has too new a protocol version (%d) for me\n",
 			ast_inet_ntoa(sin->sin_addr), version);
 		return res;
 	}
@@ -4701,7 +4701,7 @@
 		/* copy vars */
 		for (v = user->vars ; v ; v = v->next) {
 			if((tmpvar = ast_variable_new(v->name, v->value))) {
-				tmpvar->next = iaxs[callno]->vars; 
+				tmpvar->next = iaxs[callno]->vars;
 				iaxs[callno]->vars = tmpvar;
 			}
 		}
@@ -4755,7 +4755,7 @@
 			iaxs[callno]->amaflags = user->amaflags;
 		if (!ast_strlen_zero(user->language))
 			ast_string_field_set(iaxs[callno], language, user->language);
-		ast_copy_flags(iaxs[callno], user, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);	
+		ast_copy_flags(iaxs[callno], user, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
 		/* Keep this check last */
 		if (!ast_strlen_zero(user->dbsecret)) {
 			char *family, *key=NULL;
@@ -4778,7 +4778,7 @@
 			ast_string_field_set(iaxs[callno], secret, user->secret);
 		res = 0;
 	}
-	ast_set2_flag(iaxs[callno], iax2_getpeertrunk(*sin), IAX_TRUNK);	
+	ast_set2_flag(iaxs[callno], iax2_getpeertrunk(*sin), IAX_TRUNK);
 	return res;
 }
 
@@ -4796,7 +4796,7 @@
 		 iax_showframe(NULL, &fh, 0, sin, 0);
 #if 0
 	if (option_debug)
-#endif	
+#endif
 		ast_log(LOG_DEBUG, "Raw Hangup %s:%d, src=%d, dst=%d\n",
 			ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
 	return sendto(sockfd, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
@@ -4872,7 +4872,7 @@
 	char md5secret[256] = "";
 	char secret[256] = "";
 	char rsasecret[256] = "";
-	int res = -1; 
+	int res = -1;
 	int x;
 	struct iax2_user *user = NULL;
 
@@ -4917,7 +4917,7 @@
 		struct MD5Context md5;
 		unsigned char digest[16];
 		char *tmppw, *stringp;
-		
+
 		tmppw = ast_strdupa(p->secret);
 		stringp = tmppw;
 		while((tmppw = strsep(&stringp, ";"))) {
@@ -5013,7 +5013,7 @@
 				if (key && !ast_check_signature(key, iaxs[callno]->challenge, rsasecret)) {
 					ast_set_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED);
 					break;
-				} else if (!key) 
+				} else if (!key)
 					ast_log(LOG_WARNING, "requested inkey '%s' does not exist\n", keyn);
 				keyn = strsep(&stringp, ":");
 			}
@@ -5035,7 +5035,7 @@
 		struct MD5Context md5;
 		unsigned char digest[16];
 		char *tmppw, *stringp;
-		
+
 		tmppw = ast_strdupa(p->secret);
 		stringp = tmppw;
 		while((tmppw = strsep(&stringp, ";"))) {
@@ -5045,7 +5045,7 @@
 			MD5Final(digest, &md5);
 			for (x=0;x<16;x++)
 				sprintf(requeststr + (x << 1), "%2.2x", digest[x]); /* safe */
-			if (!strcasecmp(requeststr, md5secret)) 
+			if (!strcasecmp(requeststr, md5secret))
 				break;
 		}
 		if (tmppw) {
@@ -5076,7 +5076,7 @@
 	}
 	ast_string_field_set(iaxs[callno], peer, peer);
 	/* Choose lowest expiry number */
-	if (expire && (expire < iaxs[callno]->expiry)) 
+	if (expire && (expire < iaxs[callno]->expiry))
 		iaxs[callno]->expiry = expire;
 
 	ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
@@ -5084,7 +5084,7 @@
 	if (ast_test_flag(p, IAX_TEMPONLY))
 		destroy_peer(p);
 	return 0;
-	
+
 }
 
 static int authenticate(const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct sockaddr_in *sin, aes_encrypt_ctx *ecx, aes_decrypt_ctx *dcx)
@@ -5093,7 +5093,7 @@
 	int x;
 	if (!ast_strlen_zero(keyn)) {
 		if (!(authmethods & IAX_AUTH_RSA)) {
-			if (ast_strlen_zero(secret)) 
+			if (ast_strlen_zero(secret))
 				ast_log(LOG_NOTICE, "Asked to authenticate to %s with an RSA key, but they don't allow RSA authentication\n", ast_inet_ntoa(sin->sin_addr));
 		} else if (ast_strlen_zero(challenge)) {
 			ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", ast_inet_ntoa(sin->sin_addr));
@@ -5113,7 +5113,7 @@
 				}
 			}
 		}
-	} 
+	}
 	/* Fall back */
 	if (res && !ast_strlen_zero(secret)) {
 		if ((authmethods & IAX_AUTH_MD5) && !ast_strlen_zero(challenge)) {
@@ -5147,9 +5147,9 @@
 	int res = -1;
 	int authmethods = 0;
 	struct iax_ie_data ied;
-	
+
 	memset(&ied, 0, sizeof(ied));
-	
+
 	if (ies->username)
 		ast_string_field_set(p, username, ies->username);
 	if (ies->challenge)
@@ -5168,7 +5168,7 @@
 	} else {
 		AST_LIST_LOCK(&peers);
 		AST_LIST_TRAVERSE(&peers, peer, entry) {
-			if ((ast_strlen_zero(p->peer) || !strcmp(p->peer, peer->name)) 
+			if ((ast_strlen_zero(p->peer) || !strcmp(p->peer, peer->name))
 			    /* No peer specified at our end, or this is the peer */
 			    && (ast_strlen_zero(peer->username) || (!strcmp(peer->username, p->username)))
 			    /* No username specified in peer rule, or this is the right username */
@@ -5177,12 +5177,12 @@
 				) {
 				res = authenticate(p->challenge, peer->secret, peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx);
 				if (!res)
-					break;	
+					break;
 			}
 		}
 		AST_LIST_UNLOCK(&peers);
 		if (!peer) {
-			/* We checked our list and didn't find one.  It's unlikely, but possible, 
+			/* We checked our list and didn't find one.  It's unlikely, but possible,
 			   that we're trying to authenticate *to* a realtime peer */
 			if ((peer = realtime_peer(p->peer, NULL))) {
 				res = authenticate(p->challenge, peer->secret,peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx);
@@ -5211,7 +5211,7 @@
 {
 #ifdef SCHED_MULTITHREADED
 	if (schedule_action(__iax2_do_register_s, data))
-#endif		
+#endif
 		__iax2_do_register_s(data);
 	return 0;
 }
@@ -5222,8 +5222,8 @@
 	char newip[256];
 	struct iax_ie_data ied;
 	struct sockaddr_in new;
-	
-	
+
+
 	memset(&ied, 0, sizeof(ied));
 	if (ies->apparent_addr)
 		bcopy(ies->apparent_addr, &new, sizeof(new));
@@ -5242,7 +5242,7 @@
 	if (ies->transferid)
 		iax_ie_append_int(&ied, IAX_IE_TRANSFERID, ies->transferid);
 	send_command_transfer(pvt, AST_FRAME_IAX, IAX_COMMAND_TXCNT, 0, ied.buf, ied.pos);
-	return 0; 
+	return 0;
 }
 
 static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
@@ -5250,10 +5250,10 @@
 	char exten[256] = "";
 	int status = CACHE_FLAG_UNKNOWN, expiry = iaxdefaultdpcache, x, matchmore = 0;
 	struct iax2_dpcache *dp = NULL;
-	
+
 	if (ies->called_number)
 		ast_copy_string(exten, ies->called_number, sizeof(exten));
-	
+
 	if (ies->dpstatus & IAX_DPSTATUS_EXISTS)
 		status = CACHE_FLAG_EXISTS;
 	else if (ies->dpstatus & IAX_DPSTATUS_CANEXIST)
@@ -5265,7 +5265,7 @@
 		expiry = ies->refresh;
 	if (ies->dpstatus & IAX_DPSTATUS_MATCHMORE)
 		matchmore = CACHE_FLAG_MATCHMORE;
-	
+
 	AST_LIST_LOCK(&dpcache);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&dpcache, dp, peer_list) {
 		if (strcmp(dp->exten, exten))
@@ -5333,11 +5333,11 @@
 		/* We must cancel any packets that would have been transmitted
 		   because now we're talking to someone new.  It's okay, they
 		   were transmitted to someone that didn't care anyway. */
-		if (callno == cur->callno) 
+		if (callno == cur->callno)
 			cur->retries = -1;
 	}
 	AST_LIST_UNLOCK(&iaxq.queue);
-	return 0; 
+	return 0;
 }
 
 /*! \brief Acknowledgment received for OUR registration */
@@ -5410,7 +5410,7 @@
 	char *username, *hostname, *secret;
 	char *porta;
 	char *stringp=NULL;
-	
+
 	if (!value)
 		return -1;
 	ast_copy_string(copy, value, sizeof(copy));
@@ -5427,7 +5427,7 @@
 	stringp=hostname;
 	hostname = strsep(&stringp, ":");
 	porta = strsep(&stringp, ":");
-	
+
 	if (porta && !atoi(porta)) {
 		ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
 		return -1;
@@ -5448,7 +5448,7 @@
 	reg->next = registrations;
 	reg->callno = 0;
 	registrations = reg;
-	
+
 	return 0;
 }
 
@@ -5517,7 +5517,7 @@
 {
 #ifdef SCHED_MULTITHREADED
 	if (schedule_action(__expire_registry, data))
-#endif		
+#endif
 		__expire_registry(data);
 	return 0;
 }
@@ -5540,7 +5540,7 @@
 					*d = '\0';
 					d++;
 					if (option_verbose > 2)
-						ast_verbose(VERBOSE_PREFIX_3 "Seeding '%s' at %s:%d for %d\n", p->name, 
+						ast_verbose(VERBOSE_PREFIX_3 "Seeding '%s' at %s:%d for %d\n", p->name,
 						ast_inet_ntoa(in), atoi(c), atoi(d));
 					iax2_poke_peer(p, 0);
 					p->expiry = atoi(d);
@@ -5555,8 +5555,8 @@
 					if (iax2_regfunk)
 						iax2_regfunk(p->name, 1);
 					register_peer_exten(p, 1);
-				}					
-					
+				}
+
 			}
 		}
 	}
@@ -5597,14 +5597,14 @@
 		if (!ast_test_flag(p, IAX_TEMPONLY) && sin->sin_addr.s_addr) {
 			ast_db_put("IAX/Registry", p->name, data);
 			if  (option_verbose > 2)
-				ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 '%s' (%s) at %s:%d\n", p->name, 
+				ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 '%s' (%s) at %s:%d\n", p->name,
 					    ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
 			manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Registered\r\n", p->name);
 			register_peer_exten(p, 1);
 			ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
 		} else if (!ast_test_flag(p, IAX_TEMPONLY)) {
 			if  (option_verbose > 2)
-				ast_verbose(VERBOSE_PREFIX_3 "Unregistered IAX2 '%s' (%s)\n", p->name, 
+				ast_verbose(VERBOSE_PREFIX_3 "Unregistered IAX2 '%s' (%s)\n", p->name,

[... 1380 lines stripped ...]


More information about the asterisk-commits mailing list