[asterisk-commits] branch oej/sipregister r8824 - in /team/oej/sipregister: ./ channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Jan 28 08:07:13 MST 2006


Author: oej
Date: Sat Jan 28 09:07:11 2006
New Revision: 8824

URL: http://svn.digium.com/view/asterisk?rev=8824&view=rev
Log:
Merged revisions 8809,8823 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r8809 | oej | 2006-01-28 14:54:25 +0100 (Sat, 28 Jan 2006) | 2 lines

Blocking revision 8808 from trunk. It's already fixed in trunk.

........
r8823 | oej | 2006-01-28 16:02:29 +0100 (Sat, 28 Jan 2006) | 2 lines

Simplify code for building Call ID's, create generic random string function

........

Modified:
    team/oej/sipregister/   (props changed)
    team/oej/sipregister/channels/chan_sip.c

Propchange: team/oej/sipregister/
------------------------------------------------------------------------------
--- svnmerge-blocked (original)
+++ svnmerge-blocked Sat Jan 28 09:07:11 2006
@@ -1,1 +1,1 @@
-/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8124,8134,8394,8412,8414,8418,8429,8433,8445,8562,8573,8600,8619,8666
+/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8124,8134,8394,8412,8414,8418,8429,8433,8445,8562,8573,8600,8619,8666,8808

Propchange: team/oej/sipregister/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Jan 28 09:07:11 2006
@@ -1,1 +1,1 @@
-/trunk:1-8807
+/trunk:1-8823

Modified: team/oej/sipregister/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/channels/chan_sip.c?rev=8824&r1=8823&r2=8824&view=diff
==============================================================================
--- team/oej/sipregister/channels/chan_sip.c (original)
+++ team/oej/sipregister/channels/chan_sip.c Sat Jan 28 09:07:11 2006
@@ -3080,46 +3080,41 @@
 	return fr;
 }
 
+
+/*! \brief Generate 32 byte random string for callid's etc */
+static char *generate_random_string(char *buf, size_t size)
+{
+	int val[4];
+	int x;
+
+	for (x=0; x<4; x++)
+		val[x] = thread_safe_rand();
+	snprintf(buf, size, "%08x%08x%08x%08x", val[0], val[1], val[2], val[3]);
+
+	return buf;
+}
+
 /*! \brief Build SIP Call-ID value for a non-REGISTER transaction */
 static void build_callid_pvt(struct sip_pvt *pvt)
 {
-	int val[4];
-	int x;
 	char iabuf[INET_ADDRSTRLEN];
-
-	for (x=0; x<4; x++)
-		val[x] = thread_safe_rand();
-
-	if (ast_strlen_zero(pvt->fromdomain))
-		/* It's not important that we really use our right IP here... */
-		ast_string_field_build(pvt, callid, "%08x%08x%08x%08x@%s",
-				       val[0], val[1], val[2], val[3],
-				       ast_inet_ntoa(iabuf, sizeof(iabuf), pvt->ourip));
-	else
-		ast_string_field_build(pvt, callid, "%08x%08x%08x%08x@%s",
-				       val[0], val[1], val[2], val[3],
-				       pvt->fromdomain);
+	char buf[33];
+
+	const char *host = ast_strlen_zero(pvt->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), pvt->ourip) : pvt->fromdomain;
+	
+	ast_string_field_build(pvt, callid, "%s@%s", generate_random_string(buf, sizeof(buf)), host);
+
 }
 
 /*! \brief Build SIP Call-ID value for a REGISTER transaction */
 static void build_callid_registry(struct sip_registry *reg, struct in_addr ourip, const char *fromdomain)
 {
-	int val[4];
-	int x;
 	char iabuf[INET_ADDRSTRLEN];
-
-	for (x=0; x<4; x++)
-		val[x] = thread_safe_rand();
-
-	if (ast_strlen_zero(fromdomain))
-		/* It's not important that we really use our right IP here... */
-		ast_string_field_build(reg, callid, "%08x%08x%08x%08x@%s",
-				       val[0], val[1], val[2], val[3],
-				       ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
-	else
-		ast_string_field_build(reg, callid, "%08x%08x%08x%08x@%s",
-				       val[0], val[1], val[2], val[3],
-				       fromdomain);
+	char buf[33];
+
+	const char *host = ast_strlen_zero(fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), ourip) : fromdomain;
+
+	ast_string_field_build(reg, callid, "%s@%s", generate_random_string(buf, sizeof(buf)), host);
 }
 
 /*! \brief Make our SIP dialog tag */



More information about the asterisk-commits mailing list