[asterisk-commits] rizzo: branch rizzo/astobj2 r47965 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 23 06:58:40 MST 2006


Author: rizzo
Date: Thu Nov 23 07:58:40 2006
New Revision: 47965

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47965
Log:
rename "peersecret" and "peermd5secret" fields in sip_pvt to
"secret" and "md5secret", respectively.
They don't always come from a peer so the name was misleading.

trunk candidate.

On passing: these and many other fields in the sip_pvt are
simply copied from the relevant data structure (sip_user,
sip_peer, sip_registry) when the dialog is created, and
then used once (or never).

It would make a lot more sense to either:

- just keep a reference from the sip_pvt to the source
  of this information (it is already there for sip_registry),
  so these strings can be grabbed from the source when necessary;

- if the source is dynamic, e.g. read from a database, make sure
  that the source itself has a compact representation of this info
  so we can just copy a blob of memory, and do simple lookups from there.

While this is not the worst offender in the sip_pvt size,
it does consume a significant amount of memory, and especially,
quite a bit of time (and code) to copy all the info at creation.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47965&r1=47964&r2=47965
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Thu Nov 23 07:58:40 2006
@@ -923,8 +923,8 @@
 		AST_STRING_FIELD(authname);	/*!< Who we use for authentication */
 		AST_STRING_FIELD(uri);		/*!< Original requested URI */
 		AST_STRING_FIELD(okcontacturi);	/*!< URI from the 200 OK on INVITE */
-		AST_STRING_FIELD(peersecret);	/*!< Password */
-		AST_STRING_FIELD(peermd5secret);
+		AST_STRING_FIELD(secret);	/*!< Password */
+		AST_STRING_FIELD(md5secret);
 		AST_STRING_FIELD(cid_num);	/*!< Caller*ID number */
 		AST_STRING_FIELD(cid_name);	/*!< Caller*ID name */
 		AST_STRING_FIELD(via);		/*!< Via: header */
@@ -2939,8 +2939,8 @@
 	ast_string_field_set(dialog, peername, peer->username);
 	ast_string_field_set(dialog, authname, peer->username);
 	ast_string_field_set(dialog, username, peer->username);
-	ast_string_field_set(dialog, peersecret, peer->secret);
-	ast_string_field_set(dialog, peermd5secret, peer->md5secret);
+	ast_string_field_set(dialog, secret, peer->secret);
+	ast_string_field_set(dialog, md5secret, peer->md5secret);
 	ast_string_field_set(dialog, tohost, peer->tohost);
 	ast_string_field_set(dialog, fullcontact, peer->fullcontact);
 	if (!dialog->initreq.headers && !ast_strlen_zero(peer->fromdomain)) {
@@ -7531,9 +7531,9 @@
 		r->register_pvt = pvt_ref(p);			/* Save pointer to SIP dialog */
 		p->registry = ASTOBJ_REF(r);	/* Add pointer to registry in dialog */
 		if (!ast_strlen_zero(r->secret))	/* Secret (password) */
-			ast_string_field_set(p, peersecret, r->secret);
+			ast_string_field_set(p, secret, r->secret);
 		if (!ast_strlen_zero(r->md5secret))
-			ast_string_field_set(p, peermd5secret, r->md5secret);
+			ast_string_field_set(p, md5secret, r->md5secret);
 		/* User name in this realm  
 		- if authuser is set, use that, otherwise use username */
 		if (!ast_strlen_zero(r->authuser)) {	
@@ -9399,8 +9399,8 @@
 			ast_string_field_set(p, cid_name, user->cid_name);
 		ast_string_field_set(p, username, user->name);
 		ast_string_field_set(p, peername, user->name);
-		ast_string_field_set(p, peersecret, user->secret);
-		ast_string_field_set(p, peermd5secret, user->md5secret);
+		ast_string_field_set(p, secret, user->secret);
+		ast_string_field_set(p, md5secret, user->md5secret);
 		ast_string_field_set(p, subscribecontext, user->subscribecontext);
 		ast_string_field_set(p, accountcode, user->accountcode);
 		ast_string_field_set(p, language, user->language);
@@ -9487,8 +9487,8 @@
 	replace_cid(p, rpid_num, calleridname);
 	do_setnat(p, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE));
 
-	ast_string_field_set(p, peersecret, peer->secret);
-	ast_string_field_set(p, peermd5secret, peer->md5secret);
+	ast_string_field_set(p, secret, peer->secret);
+	ast_string_field_set(p, md5secret, peer->md5secret);
 	ast_string_field_set(p, subscribecontext, peer->subscribecontext);
 	ast_string_field_set(p, mohinterpret, peer->mohinterpret);
 	ast_string_field_set(p, mohsuggest, peer->mohsuggest);
@@ -9498,10 +9498,10 @@
 		p->timer_t1 = peer->lastms;
 	if (ast_test_flag(&peer->flags[0], SIP_INSECURE_INVITE)) {
 		/* Pretend there is no required authentication */
-		ast_string_field_free(p, peersecret);
-		ast_string_field_free(p, peermd5secret);
-	}
-	if (!(res = check_auth(p, req, peer->name, p->peersecret, p->peermd5secret, sipmethod, uri2, reliable, req_ignore(req)))) {
+		ast_string_field_free(p, secret);
+		ast_string_field_free(p, md5secret);
+	}
+	if (!(res = check_auth(p, req, peer->name, p->secret, p->md5secret, sipmethod, uri2, reliable, req_ignore(req)))) {
 		ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_FLAGS_TO_COPY);
 		ast_copy_flags(&p->flags[1], &peer->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
 		/* If we have a call limit, set flag */
@@ -9533,8 +9533,8 @@
 		ast_string_field_set(p, fullcontact, peer->fullcontact);
 		if (!ast_strlen_zero(peer->context))
 			ast_string_field_set(p, context, peer->context);
-		ast_string_field_set(p, peersecret, peer->secret);
-		ast_string_field_set(p, peermd5secret, peer->md5secret);
+		ast_string_field_set(p, secret, peer->secret);
+		ast_string_field_set(p, md5secret, peer->md5secret);
 		ast_string_field_set(p, language, peer->language);
 		ast_string_field_set(p, accountcode, peer->accountcode);
 		p->amaflags = peer->amaflags;
@@ -11624,10 +11624,12 @@
 		if (sipdebug)
  			ast_log(LOG_DEBUG,"Using realm %s authentication for call %s\n", p->realm, p->callid);
  	} else {
- 		/* No authentication, use peer or register= config */
+ 		/* No authentication, use credentials in the dialog
+		 * (coming from user/peer/registration)
+		 */
  		username = p->authname;
- 		secret =  p->peersecret;
- 		md5secret = p->peermd5secret;
+ 		secret =  p->secret;
+ 		md5secret = p->md5secret;
  	}
 	if (ast_strlen_zero(username))	/* We have no authentication */
 		return -1;



More information about the asterisk-commits mailing list