[svn-commits] rmudgett: branch group/issue8824 r163589 - in /team/group/issue8824: ./ chann...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 12 11:17:31 CST 2008


Author: rmudgett
Date: Fri Dec 12 11:17:30 2008
New Revision: 163589

URL: http://svn.digium.com/view/asterisk?view=rev&rev=163589
Log:
Resolved conflict and restarted automerge.

Merged revisions 163449,163512,163516,163579 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r163449 | russell | 2008-12-12 07:55:30 -0600 (Fri, 12 Dec 2008) | 34 lines
  
  Merged revisions 163448 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r163448 | russell | 2008-12-12 07:44:08 -0600 (Fri, 12 Dec 2008) | 26 lines
  
  Resolve issues that could cause DTMF to be processed out of order.
  
  These changes come from team/russell/issue_12658
  
  1) Change autoservice to put digits on the head of the channel's frame readq 
     instead of the tail.  If there were frames on the readq that autoservice 
     had not yet read, the previous code would have resulted in out of order 
     processing.  This required a new API call to queue a frame to the head 
     of the queue instead of the tail.
  
  2) Change up the processing of DTMF in ast_read().  Some of the problems 
     were the result of having two sources of pending DTMF frames.  There 
     was the dtmfq and the more generic readq.  Both were used for pending 
     DTMF in various scenarios.  Simplifying things to only use the frame 
     readq avoids some of the problems.
  
  3) Fix a bug where a DTMF END frame could get passed through when it 
     shouldn't have.  If code set END_DTMF_ONLY in the middle of digit emulation,
     and a digit arrived before emulation was complete, digits would get 
     processed out of order.
  
  (closes issue #12658)
  Reported by: dimas
  Tested by: russell, file
  Review: http://reviewboard.digium.com/r/85/
  
  ........
................
  r163512 | russell | 2008-12-12 08:44:06 -0600 (Fri, 12 Dec 2008) | 13 lines
  
  Merged revisions 163511 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r163511 | russell | 2008-12-12 08:40:31 -0600 (Fri, 12 Dec 2008) | 5 lines
  
  Specify uint32_t for variables storing a CRC32 so that it is actually 32 bits
  on 64-bit machines, as well.
  
  (inspired by issue #13879)
  
  ........
................
  r163516 | dbailey | 2008-12-12 09:10:25 -0600 (Fri, 12 Dec 2008) | 2 lines
  
  Add internationalization to sample configuration file
................
  r163579 | file | 2008-12-12 10:55:15 -0600 (Fri, 12 Dec 2008) | 4 lines
  
  Since chan_sip is callback devicestate driven do not pass in actual states, pass in unknown so we get asked. Additionally do not pass in an actual device state value in ast_setstate since the channel may be callback driven.
  (closes issue #13525)
  Reported by: pj
................

Modified:
    team/group/issue8824/   (props changed)
    team/group/issue8824/channels/chan_sip.c
    team/group/issue8824/configs/phoneprov.conf.sample
    team/group/issue8824/include/asterisk/channel.h
    team/group/issue8824/main/autoservice.c
    team/group/issue8824/main/channel.c
    team/group/issue8824/pbx/pbx_dundi.c

Propchange: team/group/issue8824/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/issue8824/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/issue8824/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Dec 12 11:17:30 2008
@@ -1,1 +1,1 @@
-/trunk:1-163394
+/trunk:1-163581

Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=163589&r1=163588&r2=163589
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Fri Dec 12 11:17:30 2008
@@ -11031,7 +11031,7 @@
 	
 	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", peer->name);
 	register_peer_exten(peer, FALSE);	/* Remove regexten */
-	ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 
 	/* Do we need to release this peer from memory? 
 		Only for realtime peers and autocreated peers
@@ -11720,7 +11720,7 @@
 	ast_atomic_fetchadd_int(&peer->onHold, (hold ? +1 : -1));
 
 	/* Request device state update */
-	ast_devstate_changed(hold ? AST_DEVICE_ONHOLD : AST_DEVICE_INUSE, "SIP/%s", peer->name);
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 	unref_peer(peer, "sip_peer_hold: from find_peer operation");
 	
 	return;
@@ -17224,7 +17224,7 @@
 
 		ast_log(LOG_NOTICE, "Peer '%s' is now %s. (%dms / %dms)\n",
 			peer->name, s, pingtime, peer->maxms);
-		ast_devstate_changed(is_reachable ? AST_DEVICE_NOT_INUSE : AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 		manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
 			"ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: %s\r\nTime: %d\r\n",
 			peer->name, s, pingtime);
@@ -21592,7 +21592,7 @@
 	}
 	
 	peer->lastms = -1;
-	ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 
 	/* Try again quickly */
 	AST_SCHED_REPLACE_UNREF(peer->pokeexpire, sched, 

Modified: team/group/issue8824/configs/phoneprov.conf.sample
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/configs/phoneprov.conf.sample?view=diff&rev=163589&r1=163588&r2=163589
==============================================================================
--- team/group/issue8824/configs/phoneprov.conf.sample (original)
+++ team/group/issue8824/configs/phoneprov.conf.sample Fri Dec 12 11:17:30 2008
@@ -92,6 +92,23 @@
 static_file => 3111-15600-001.sip.ld,application/octet-stream
 static_file => 3111-40000-001.bootrom.ld,application/octet-stream
 static_file => 3111-40000-001.sip.ld,application/octet-stream
+static_file => SoundPointIPWelcome.wav,application/octet-stream
+static_file => SoundPointIPLocalization/Japanese_Japan/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Norwegian_Norway/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Spanish_Spain/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Portuguese_Portugal/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/English_United_Kingdom/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/English_United_States/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Russian_Russia/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Italian_Italy/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Chinese_China/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Swedish_Sweden/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/English_Canada/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/German_Germany/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/French_France/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Danish_Denmark/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Dutch_Netherlands/SoundPointIP-dictionary.xml
+static_file => SoundPointIPLocalization/Korean_Korea/SoundPointIP-dictionary.xml
 
 ${MAC}.cfg => 000000000000.cfg               ; Dynamically generated files.
 ${MAC}-phone.cfg => 000000000000-phone.cfg   ; (relative to AST_DATA_DIR/phoneprov)

Modified: team/group/issue8824/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/include/asterisk/channel.h?view=diff&rev=163589&r1=163588&r2=163589
==============================================================================
--- team/group/issue8824/include/asterisk/channel.h (original)
+++ team/group/issue8824/include/asterisk/channel.h Fri Dec 12 11:17:30 2008
@@ -639,7 +639,7 @@
 
 	unsigned short transfercapability;		/*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
 
-	char dtmfq[AST_MAX_EXTENSION];			/*!< Any/all queued DTMF characters */
+	char unused_old_dtmfq[AST_MAX_EXTENSION];			/*!< (deprecated, use readq instead) Any/all queued DTMF characters */
 	char context[AST_MAX_CONTEXT];			/*!< Dialplan: Current extension context */
 	char exten[AST_MAX_EXTENSION];			/*!< Dialplan: Current extension number */
 	char macrocontext[AST_MAX_CONTEXT];		/*!< Macro: Current non-macro context. See app_macro.c */
@@ -854,6 +854,20 @@
 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
 
 /*!
+ * \brief Queue an outgoing frame to the head of the frame queue
+ *
+ * \param chan the channel to queue the frame on
+ * \param f the frame to queue.  Note that this frame will be duplicated by
+ *        this function.  It is the responsibility of the caller to handle
+ *        freeing the memory associated with the frame being passed if
+ *        necessary.
+ *
+ * \retval 0 success
+ * \retval non-zero failure
+ */
+int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);
+
+/*!
  * \brief Queue a hangup frame
  *
  * \note The channel does not need to be locked before calling this function.

Modified: team/group/issue8824/main/autoservice.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/main/autoservice.c?view=diff&rev=163589&r1=163588&r2=163589
==============================================================================
--- team/group/issue8824/main/autoservice.c (original)
+++ team/group/issue8824/main/autoservice.c Fri Dec 12 11:17:30 2008
@@ -56,6 +56,9 @@
 	 *  it gets stopped for the last time. */
 	unsigned int use_count;
 	unsigned int orig_end_dtmf_flag:1;
+	/*! Frames go on at the head of deferred_frames, so we have the frames
+	 *  from newest to oldest.  As we put them at the head of the readq, we'll
+	 *  end up with them in the right order for the channel's readq. */
 	AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames;
 	AST_LIST_ENTRY(asent) list;
 };
@@ -161,7 +164,7 @@
 				}
 				
 				if ((dup_f = ast_frdup(defer_frame))) {
-					AST_LIST_INSERT_TAIL(&ents[i]->deferred_frames, dup_f, frame_list);
+					AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
 				}
 				
 				break;
@@ -292,10 +295,12 @@
 		ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
 	}
 
+	ast_channel_lock(chan);
 	while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) {
-		ast_queue_frame(chan, f);
+		ast_queue_frame_head(chan, f);
 		ast_frfree(f);
 	}
+	ast_channel_unlock(chan);
 
 	free(as);
 

Modified: team/group/issue8824/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/main/channel.c?view=diff&rev=163589&r1=163588&r2=163589
==============================================================================
--- team/group/issue8824/main/channel.c (original)
+++ team/group/issue8824/main/channel.c Fri Dec 12 11:17:30 2008
@@ -953,7 +953,7 @@
 }
 
 /*! \brief Queue an outgoing media frame */
-int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
+static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head)
 {
 	struct ast_frame *f;
 	struct ast_frame *cur;
@@ -962,9 +962,9 @@
 
 	/* Build us a copy and free the original one */
 	if (!(f = ast_frdup(fin))) {
-		ast_log(LOG_WARNING, "Unable to duplicate frame\n");
 		return -1;
 	}
+
 	ast_channel_lock(chan);
 
 	/* See if the last frame on the queue is a hangup, if so don't queue anything */
@@ -991,18 +991,37 @@
 			return 0;
 		}
 	}
-	AST_LIST_INSERT_TAIL(&chan->readq, f, frame_list);
+
+	if (head) {
+		AST_LIST_INSERT_HEAD(&chan->readq, f, frame_list);
+	} else {
+		AST_LIST_INSERT_TAIL(&chan->readq, f, frame_list);
+	}
+
 	if (chan->alertpipe[1] > -1) {
-		if (write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah))
+		if (write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah)) {
 			ast_log(LOG_WARNING, "Unable to write to alert pipe on %s, frametype/subclass %d/%d (qlen = %d): %s!\n",
 				chan->name, f->frametype, f->subclass, qlen, strerror(errno));
+		}
 	} else if (chan->timingfd > -1) {
 		ast_timer_enable_continuous(chan->timingfd);
 	} else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
 		pthread_kill(chan->blocker, SIGURG);
 	}
+
 	ast_channel_unlock(chan);
+
 	return 0;
+}
+
+int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
+{
+	return __ast_queue_frame(chan, fin, 0);
+}
+
+int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
+{
+	return __ast_queue_frame(chan, fin, 1);
 }
 
 /*! \brief Queue a hangup frame for channel */
@@ -2805,6 +2824,42 @@
 	}
 }
 
+static inline void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame *f)
+{
+	struct ast_frame *fr = &chan->dtmff;
+
+	fr->frametype = AST_FRAME_DTMF_END;
+	fr->subclass = f->subclass;
+	fr->len = f->len;
+
+	/* The only time this function will be called is for a frame that just came
+	 * out of the channel driver.  So, we want to stick it on the tail of the
+	 * readq. */
+
+	ast_queue_frame(chan, fr);
+}
+
+/*!
+ * \brief Determine whether or not we should ignore DTMF in the readq
+ */
+static inline int should_skip_dtmf(struct ast_channel *chan)
+{
+	if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) {
+		/* We're in the middle of emulating a digit, or DTMF has been
+		 * explicitly deferred.  Skip this digit, then. */
+		return 1;
+	}
+			
+	if (!ast_tvzero(chan->dtmf_tv) && 
+			ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) {
+		/* We're not in the middle of a digit, but it hasn't been long enough
+		 * since the last digit, so we'll have to skip DTMF for now. */
+		return 1;
+	}
+
+	return 0;
+}
+
 static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
 {
 	struct ast_frame *f = NULL;	/* the return value */
@@ -2838,28 +2893,6 @@
 	}
 	prestate = chan->_state;
 
-	if (!ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF | AST_FLAG_IN_DTMF) && 
-	    !ast_strlen_zero(chan->dtmfq) && 
-		(ast_tvzero(chan->dtmf_tv) || ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) > AST_MIN_DTMF_GAP) ) {
-		/* We have DTMF that has been deferred.  Return it now */
-		chan->dtmff.subclass = chan->dtmfq[0];
-		/* Drop first digit from the buffer */
-		memmove(chan->dtmfq, chan->dtmfq + 1, sizeof(chan->dtmfq) - 1);
-		f = &chan->dtmff;
-		if (ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
-			ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
-			chan->dtmff.frametype = AST_FRAME_DTMF_END;
-		} else {
-			ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %d queued on %s\n", f->subclass, AST_DEFAULT_EMULATE_DTMF_DURATION, chan->name);
-			chan->dtmff.frametype = AST_FRAME_DTMF_BEGIN;
-			ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
-			chan->emulate_dtmf_digit = f->subclass;
-			chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
-		}
-		chan->dtmf_tv = ast_tvnow();
-		goto done;
-	}
-	
 	/* Read and ignore anything on the alertpipe, but read only
 	   one sizeof(blah) per frame that we send from it */
 	if (chan->alertpipe[0] > -1) {
@@ -2927,7 +2960,35 @@
 
 	/* Check for pending read queue */
 	if (!AST_LIST_EMPTY(&chan->readq)) {
-		f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list);
+		int skip_dtmf = should_skip_dtmf(chan);
+
+		AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, f, frame_list) {
+			/* We have to be picky about which frame we pull off of the readq because
+			 * there are cases where we want to leave DTMF frames on the queue until
+			 * some later time. */
+
+			if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) {
+				continue;
+			}
+
+			AST_LIST_REMOVE_CURRENT(frame_list);
+			break;
+		}
+		AST_LIST_TRAVERSE_SAFE_END
+		
+		if (!f) {
+			/* There were no acceptable frames on the readq. */
+			f = &ast_null_frame;
+			if (chan->alertpipe[0] > -1) {
+				int poke = 0;
+				/* Restore the state of the alertpipe since we aren't ready for any
+				 * of the frames in the readq. */
+				if (write(chan->alertpipe[1], &poke, sizeof(poke)) != sizeof(poke)) {
+					ast_log(LOG_ERROR, "Failed to write to alertpipe: %s\n", strerror(errno));
+				}
+			}
+		}
+
 		/* Interpret hangup and return NULL */
 		/* XXX why not the same for frames from the channel ? */
 		if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
@@ -2984,26 +3045,16 @@
 		case AST_FRAME_DTMF_END:
 			send_dtmf_event(chan, "Received", f->subclass, "No", "Yes");
 			ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass, chan->name, f->len);
-			/* Queue it up if DTMF is deffered, or if DTMF emulation is forced.
-			 * However, only let emulation be forced if the other end cares about BEGIN frames */
-			if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF) ||
-				(ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) ) {
-				if (strlen(chan->dtmfq) < sizeof(chan->dtmfq) - 2) {
-					ast_log(LOG_DTMF, "DTMF end '%c' put into dtmf queue on %s\n", f->subclass, chan->name);
-					chan->dtmfq[strlen(chan->dtmfq)] = f->subclass;
-				} else
-					ast_log(LOG_WARNING, "Dropping deferred DTMF digits on %s\n", chan->name);
+			/* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
+			if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
+				queue_dtmf_readq(chan, f);
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else if (!ast_test_flag(chan, AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) {
 				if (!ast_tvzero(chan->dtmf_tv) && 
 				    ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) {
 					/* If it hasn't been long enough, defer this digit */
-					if (strlen(chan->dtmfq) < sizeof(chan->dtmfq) - 2) {
-						ast_log(LOG_DTMF, "DTMF end '%c' put into dtmf queue on %s\n", f->subclass, chan->name);
-						chan->dtmfq[strlen(chan->dtmfq)] = f->subclass;
-					} else
-						ast_log(LOG_WARNING, "Dropping deferred DTMF digits on %s\n", chan->name);
+					queue_dtmf_readq(chan, f);
 					ast_frfree(f);
 					f = &ast_null_frame;
 				} else {
@@ -4609,7 +4660,12 @@
 	}
 
 	chan->_state = state;
-	ast_devstate_changed_literal(ast_state_chan2dev(state), name);
+
+	/* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
+	 * for this channel is using the callback method for device state. If we pass in an actual state here
+	 * we override what they are saying the state is and things go amuck. */
+	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name);
+
 	/* setstate used to conditionally report Newchannel; this is no more */
 	manager_event(EVENT_FLAG_CALL,
 		      "Newstate",

Modified: team/group/issue8824/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/pbx/pbx_dundi.c?view=diff&rev=163589&r1=163588&r2=163589
==============================================================================
--- team/group/issue8824/pbx/pbx_dundi.c (original)
+++ team/group/issue8824/pbx/pbx_dundi.c Fri Dec 12 11:17:30 2008
@@ -197,7 +197,7 @@
 	int expiration;
 	int cbypass;
 	int pfds[2];
-	unsigned long crc32;                              /*!< CRC-32 of all but root EID's in avoid list */
+	uint32_t crc32;                              /*!< CRC-32 of all but root EID's in avoid list */
 	AST_LIST_HEAD_NOLOCK(, dundi_transaction) trans;  /*!< Transactions */
 	AST_LIST_ENTRY(dundi_request) list;
 };
@@ -229,10 +229,10 @@
 	int order;
 	unsigned char txenckey[256];           /*!< Transmitted encrypted key + sig */
 	unsigned char rxenckey[256];           /*!< Cache received encrypted key + sig */
-	unsigned long us_keycrc32;             /*!< CRC-32 of our key */
+	uint32_t us_keycrc32;                  /*!< CRC-32 of our key */
 	ast_aes_encrypt_key us_ecx;            /*!< Cached AES 128 Encryption context */
 	ast_aes_decrypt_key us_dcx;            /*!< Cached AES 128 Decryption context */
-	unsigned long them_keycrc32;           /*!< CRC-32 of our key */
+	uint32_t them_keycrc32;                /*!< CRC-32 of our key */
 	ast_aes_encrypt_key them_ecx;          /*!< Cached AES 128 Encryption context */
 	ast_aes_decrypt_key them_dcx;          /*!< Cached AES 128 Decryption context */
 	time_t keyexpire;                      /*!< When to expire/recreate key */
@@ -783,7 +783,7 @@
 
 	dundi_eid_to_str_short(eidpeer_str, sizeof(eidpeer_str), eidpeer);
 	dundi_eid_to_str_short(eidroot_str, sizeof(eidroot_str), &req->root_eid);
-	snprintf(key1, sizeof(key1), "hint/%s/%s/%s/e%08lx", eidpeer_str, hint->data, req->dcontext, unaffected ? 0 : req->crc32);
+	snprintf(key1, sizeof(key1), "hint/%s/%s/%s/e%08x", eidpeer_str, hint->data, req->dcontext, unaffected ? 0 : req->crc32);
 	snprintf(key2, sizeof(key2), "hint/%s/%s/%s/r%s", eidpeer_str, hint->data, req->dcontext, eidroot_str);
 
 	time(&timeout);
@@ -819,7 +819,7 @@
 		expiration = 1;
 	dundi_eid_to_str_short(eidpeer_str, sizeof(eidpeer_str), eidpeer);
 	dundi_eid_to_str_short(eidroot_str, sizeof(eidroot_str), &req->root_eid);
-	snprintf(key1, sizeof(key1), "%s/%s/%s/e%08lx", eidpeer_str, req->number, req->dcontext, unaffected ? 0 : req->crc32);
+	snprintf(key1, sizeof(key1), "%s/%s/%s/e%08x", eidpeer_str, req->number, req->dcontext, unaffected ? 0 : req->crc32);
 	snprintf(key2, sizeof(key2), "%s/%s/%s/r%s", eidpeer_str, req->number, req->dcontext, eidroot_str);
 	/* Build request string */
 	time(&timeout);
@@ -1140,7 +1140,7 @@
 	return 0;
 }
 
-static int cache_lookup(struct dundi_request *req, dundi_eid *peer_eid, unsigned long checksum, int *lowexpiration)
+static int cache_lookup(struct dundi_request *req, dundi_eid *peer_eid, uint32_t crc32, int *lowexpiration)
 {
 	char key[256];
 	char eid_str[20];
@@ -1156,9 +1156,9 @@
 	dundi_eid_to_str_short(eid_str, sizeof(eid_str), peer_eid);
 	dundi_eid_to_str_short(eidroot_str, sizeof(eidroot_str), &req->root_eid);
 	ast_eid_to_str(eid_str_full, sizeof(eid_str_full), peer_eid);
-	snprintf(key, sizeof(key), "%s/%s/%s/e%08lx", eid_str, req->number, req->dcontext, checksum);
+	snprintf(key, sizeof(key), "%s/%s/%s/e%08x", eid_str, req->number, req->dcontext, crc32);
 	res |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
-	snprintf(key, sizeof(key), "%s/%s/%s/e%08lx", eid_str, req->number, req->dcontext, 0L);
+	snprintf(key, sizeof(key), "%s/%s/%s/e%08x", eid_str, req->number, req->dcontext, 0);
 	res |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
 	snprintf(key, sizeof(key), "%s/%s/%s/r%s", eid_str, req->number, req->dcontext, eidroot_str);
 	res |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
@@ -1171,9 +1171,9 @@
 				break;
 			x++;
 			/* Check for hints */
-			snprintf(key, sizeof(key), "hint/%s/%s/%s/e%08lx", eid_str, tmp, req->dcontext, checksum);
+			snprintf(key, sizeof(key), "hint/%s/%s/%s/e%08x", eid_str, tmp, req->dcontext, crc32);
 			res2 |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
-			snprintf(key, sizeof(key), "hint/%s/%s/%s/e%08lx", eid_str, tmp, req->dcontext, 0L);
+			snprintf(key, sizeof(key), "hint/%s/%s/%s/e%08x", eid_str, tmp, req->dcontext, 0);
 			res2 |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
 			snprintf(key, sizeof(key), "hint/%s/%s/%s/r%s", eid_str, tmp, req->dcontext, eidroot_str);
 			res2 |= cache_lookup_internal(now, req, key, eid_str_full, lowexpiration);
@@ -1391,13 +1391,13 @@
 	return -1;
 }
 
-static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned char *newsig, unsigned long keycrc32)
+static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned char *newsig, uint32_t keycrc32)
 {
 	unsigned char dst[128];
 	int res;
 	struct ast_key *key, *skey;
 	char eid_str[20];
-	ast_debug(1, "Expected '%08lx' got '%08lx'\n", peer->them_keycrc32, keycrc32);
+	ast_debug(1, "Expected '%08x' got '%08x'\n", peer->them_keycrc32, keycrc32);
 	if (peer->them_keycrc32 && (peer->them_keycrc32 == keycrc32)) {
 		/* A match */
 		return 1;
@@ -3441,7 +3441,7 @@
 		if (!strcasecmp(cur->dcontext, dr->dcontext) &&
 		    !strcasecmp(cur->number, dr->number) &&
 		    (!ast_eid_cmp(&cur->root_eid, &dr->root_eid) || (cur->crc32 == dr->crc32))) {
-			ast_debug(1, "Found existing query for '%s@%s' for '%s' crc '%08lx'\n", 
+			ast_debug(1, "Found existing query for '%s@%s' for '%s' crc '%08x'\n", 
 				cur->dcontext, cur->number, ast_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
 			*pending = cur;
 			res = 1;
@@ -3449,7 +3449,7 @@
 		}
 	}
 	if (!res) {
-		ast_debug(1, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n", 
+		ast_debug(1, "Registering request for '%s@%s' on behalf of '%s' crc '%08x'\n", 
 				dr->number, dr->dcontext, ast_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
 		/* Go ahead and link us in since nobody else is searching for this */
 		AST_LIST_INSERT_HEAD(&requests, dr, list);
@@ -3484,7 +3484,7 @@
 {
 	/* Idea is that we're calculating a checksum which is independent of
 	   the order that the EID's are listed in */
-	unsigned long acrc32 = 0;
+	uint32_t acrc32 = 0;
 	int x;
 	for (x=0;avoid[x];x++) {
 		/* Order doesn't matter */




More information about the svn-commits mailing list