[Freeswitch-svn] [commit] r11796 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/iptsec

FreeSWITCH SVN mikej at freeswitch.org
Wed Feb 11 08:47:44 PST 2009


Author: mikej
Date: Wed Feb 11 10:47:44 2009
New Revision: 11796

Log:
Thu Jan  8 13:50:53 CST 2009  Pekka Pessi <first.last at nokia.com>
  * iptsec: using <sofia-sip/su_string.h> functions



Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Wed Feb 11 10:47:44 2009
@@ -1 +1 @@
-Wed Feb 11 10:47:06 CST 2009
+Wed Feb 11 10:47:34 CST 2009

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c	Wed Feb 11 10:47:44 2009
@@ -47,7 +47,7 @@
 
 #include <sofia-sip/base64.h>
 #include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
 
 #include <sofia-sip/su_debug.h>
 
@@ -166,9 +166,9 @@
   if (!ca || !ch)
     return -1;
 
-  if (strcasecmp(ca->ca_scheme, scheme))
+  if (!su_casematch(ca->ca_scheme, scheme))
     return 0;
-  if (strcmp(ca->ca_realm, realm))
+  if (!su_strmatch(ca->ca_realm, realm))
     return 0;
 
   if (ca->ca_credential_class &&
@@ -390,13 +390,13 @@
   if (!ca || !ca->ca_scheme || !ca->ca_realm)
     return -1;
 
-  if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
-      (realm != NULL && strcmp(realm, ca->ca_realm)))
+  if ((scheme != NULL && !su_casematch(scheme, ca->ca_scheme)) ||
+      (realm != NULL && !su_strmatch(realm, ca->ca_realm)))
     return 0;
 
   old_user = ca->ca_user, old_pass = ca->ca_pass;
 
-  if (str0cmp(user, old_user) == 0 && str0cmp(pass, old_pass) == 0)
+  if (su_strmatch(user, old_user) && su_strmatch(pass, old_pass))
     return 0;
 
   new_user = su_strdup(ca->ca_home, user);
@@ -440,14 +440,14 @@
 	continue;
       if (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear)
 	continue;
-      if (!ca->ca_scheme[0] || strcasecmp(ca->ca_scheme, d->ca_scheme))
+      if (!ca->ca_scheme[0] || !su_casematch(ca->ca_scheme, d->ca_scheme))
 	continue;
-      if (!ca->ca_realm[0] || strcmp(ca->ca_realm, d->ca_realm))
+      if (!ca->ca_realm || !su_strmatch(ca->ca_realm, d->ca_realm))
 	continue;
 
       if (!(AUTH_CLIENT_IS_EXTENDED(d) && d->ca_clear) &&
-	  d->ca_user && strcmp(d->ca_user, ca->ca_user) == 0 &&
-	  d->ca_pass && strcmp(d->ca_pass, ca->ca_pass) == 0) {
+	  su_strmatch(d->ca_user, ca->ca_user) &&
+	  su_strmatch(d->ca_pass, ca->ca_pass)) {
 	retval++;
 	break;
       }
@@ -497,8 +497,8 @@
     if (!AUTH_CLIENT_IS_EXTENDED(ca))
       continue;
 
-    if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
-	(realm != NULL && strcmp(realm, ca->ca_realm)))
+    if ((scheme != NULL && !su_casematch(scheme, ca->ca_scheme)) ||
+	(realm != NULL && !su_strmatch(realm, ca->ca_realm)))
       continue;
 
     match = ca->ca_auc->auc_clear(*auc_list);
@@ -990,7 +990,7 @@
 
   for (i = 0; i < MAX_AUC; i++) {
     if (ca_plugins[i] == NULL ||
-	strcmp(plugin->auc_name, ca_plugins[i]->auc_name) == 0) {
+	su_strmatch(plugin->auc_name, ca_plugins[i]->auc_name) == 0) {
       ca_plugins[i] = plugin;
       return 0;
     }
@@ -1018,7 +1018,7 @@
 
   for (i = 0; i < MAX_AUC; i++) {
     auc = ca_plugins[i];
-    if (!auc || strcasecmp(auc->auc_name, scheme) == 0)
+    if (!auc || su_casematch(auc->auc_name, scheme))
       break;
   }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c	Wed Feb 11 10:47:44 2009
@@ -44,7 +44,7 @@
 
 #include <sofia-sip/base64.h>
 #include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
 
 #include <sofia-sip/su_debug.h>
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c	Wed Feb 11 10:47:44 2009
@@ -36,16 +36,13 @@
 
 #include "sofia-sip/auth_common.h"
 #include "sofia-sip/msg_header.h"
+#include <sofia-sip/su_string.h>
 
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
 #include <assert.h>
 
-#if !HAVE_STRCASESTR
-char *strcasestr(char const *haystack, char const *needle);
-#endif
-
 su_inline int has_token(char const *qstring, char const *token);
 
 /**
@@ -92,12 +89,12 @@
 	 if expected is found in parameter value,
 	 return non-NULL pointer in *return_value */
       for (j = 0; (p = params[j++]);) {
-	if (strcasecmp(p, fmt) == 0) {
+	if (su_casematch(p, fmt)) {
 	  /* Matched the whole parameter with fmt name=expected */
 	  value = p;
 	  break;
 	}
-	else if (strncasecmp(p, fmt, namelen) ||
+	else if (!su_casenmatch(p, fmt, namelen) ||
 		 p[namelen] != '=')
 	  continue;
 
@@ -109,7 +106,7 @@
 	  value = p;
 	  break;
 	}
-	else if (strcasecmp(p, expected) == 0) {
+	else if (su_casematch(p, expected)) {
 	  /* Parameter value matches with extected value
 	   * e.g., qop=auth matches qop=auth */
 	  value = p;
@@ -120,7 +117,7 @@
     else {
       /* format is name= , return unquoted parameter value after = */
       for (j = 0; (p = params[j++]);) {
-	if (strncasecmp(p, fmt, len))
+	if (!su_casenmatch(p, fmt, len))
 	  continue;
 
 	if (p[len] == '"')
@@ -169,7 +166,8 @@
   size_t n = strlen(token);
   char const *q;
 
-  q = strcasestr(qstring, token);
+  q = su_strcasestr(qstring, token);
+
   return (q &&
 	  (q[n] == 0 || strchr("\", \t", q[n])) &&
 	  (q == qstring || strchr("\", \t", q[-1])));

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c	Wed Feb 11 10:47:44 2009
@@ -61,6 +61,7 @@
 
 #include <sofia-sip/su_wait.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 #include <sofia-sip/su_tagarg.h>
 
 #include <sofia-sip/base64.h>
@@ -181,7 +182,7 @@
   am->am_fake = fake;
   am->am_remote = url_hdup(am->am_home, (url_t *)remote);
   am->am_algorithm = algorithm ? su_strdup(am->am_home, algorithm) : "MD5";
-  am->am_nextnonce = !algorithm || strcasecmp(algorithm, "MD5") == 0;
+  am->am_nextnonce = !algorithm || su_casematch(algorithm, "MD5");
   if (next_expires == 0)
     am->am_nextnonce = 0;
   am->am_qop = su_strdup(am->am_home, qop);
@@ -694,11 +695,11 @@
       /* Check for qop */
       (ar->ar_qop &&
        ((ar->ar_auth &&
-	 strcasecmp(ar->ar_qop, "auth") &&
-	 strcasecmp(ar->ar_qop, "\"auth\"")) ||
+	 !su_casematch(ar->ar_qop, "auth") &&
+	 !su_casematch(ar->ar_qop, "\"auth\"")) ||
 	(ar->ar_auth_int &&
-	 strcasecmp(ar->ar_qop, "auth-int") &&
-	 strcasecmp(ar->ar_qop, "\"auth-int\"")))
+	 !su_casematch(ar->ar_qop, "auth-int") &&
+	 !su_casematch(ar->ar_qop, "\"auth-int\"")))
        && (phrase = PA "has invalid qop"))) {
     assert(phrase);
     SU_DEBUG_5(("auth_method_digest: 400 %s\n", phrase));
@@ -1249,7 +1250,7 @@
   char const *arealm;
 
   for (;auth; auth = auth->au_next) {
-    if (strcasecmp(auth->au_scheme, scheme))
+    if (!su_casematch(auth->au_scheme, scheme))
       continue;
 
     if (!realm)
@@ -1290,7 +1291,7 @@
   char const *arealm, *aopaque;
 
   for (;auth; auth = auth->au_next) {
-    if (strcasecmp(auth->au_scheme, "Digest"))
+    if (!su_casematch(auth->au_scheme, "Digest"))
       continue;
 
     if (realm) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c	Wed Feb 11 10:47:44 2009
@@ -91,7 +91,7 @@
   if (n < 0)
     return n;
 
-  if (ac->ac_stale && strcasecmp(ac->ac_stale, "true") != 0)
+  if (ac->ac_stale && !su_casematch(ac->ac_stale, "true"))
     ac->ac_stale = NULL;
 
   ac->ac_md5 = md5 != NULL || ac->ac_algorithm == NULL;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c	Wed Feb 11 10:47:44 2009
@@ -52,6 +52,7 @@
 
 #include <sofia-sip/su_wait.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 #include <sofia-sip/su_tagarg.h>
 
 #include "sofia-sip/auth_module.h"
@@ -130,16 +131,16 @@
 
     if (base == NULL)
       ;
-    else if (strcasecmp(base, "Basic") == 0)
+    else if (su_casematch(base, "Basic"))
       bscheme = auth_scheme_basic;
-    else if (strcasecmp(base, "Digest") == 0)
+    else if (su_casematch(base, "Digest"))
       bscheme = auth_scheme_digest;
 
     if (base == NULL || bscheme) {
       int i;
 
       for (i = 0; schemes[i] && i < N; i++) {
-	if (strncasecmp(schemes[i]->asch_method, method, len) == 0 &&
+	if (su_casenmatch(schemes[i]->asch_method, method, len) &&
 	    schemes[i]->asch_method[len] == 0) {
 	  am = auth_mod_alloc(schemes[i], ta_tags(ta));
 	  if (schemes[i]->asch_init(am, bscheme, root, ta_tags(ta)) == -1) {

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c	Wed Feb 11 10:47:44 2009
@@ -170,7 +170,7 @@
   char const *agssapidata, *atargetname;
 
   for (;auth; auth = auth_mod_credentials(auth->au_next)) {
-    if (strcasecmp(auth->au_scheme, "NTLM"))
+    if (!su_casematch(auth->au_scheme, "NTLM"))
       continue;
 
     if (gssapidata) {
@@ -224,11 +224,11 @@
       /* Check for qop */
       (ar->ar_qop &&
        ((ar->ar_auth &&
-	 strcasecmp(ar->ar_qop, "auth") &&
-	 strcasecmp(ar->ar_qop, "\"auth\"")) ||
+	 !su_casematch(ar->ar_qop, "auth") &&
+	 !su_casematch(ar->ar_qop, "\"auth\"")) ||
 	(ar->ar_auth_int &&
-	 strcasecmp(ar->ar_qop, "auth-int") &&
-	 strcasecmp(ar->ar_qop, "\"auth-int\"")))
+	 !su_casematch(ar->ar_qop, "auth-int") &&
+	 !su_casematch(ar->ar_qop, "\"auth-int\"")))
        && (phrase = PA "has invalid qop"))) {
     assert(phrase);
     SU_DEBUG_5(("auth_method_ntlm: 400 %s\n", phrase));

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c	Wed Feb 11 10:47:44 2009
@@ -73,6 +73,7 @@
 #include <sofia-sip/auth_client.h>
 #include <sofia-sip/msg_header.h>
 #include <sofia-sip/su_wait.h>
+#include <sofia-sip/su_string.h>
 
 int tstflags;
 char *argv0;
@@ -349,8 +350,11 @@
     TEST_SIZE(auth_digest_challenge_get(home, ac, pa->au_params), 6);
 
     TEST0(pz = sip_proxy_authorization_make(home, cred));
-    TEST_SIZE(auth_digest_response_get(home, ar, pz->au_params), 8);
 
+    {
+    size_t n = auth_digest_response_get(home, ar, pz->au_params);
+    TEST_SIZE(n, 8);
+    }
     ar->ar_md5 = ac->ac_md5 || ac->ac_algorithm == NULL;
 
     TEST(auth_digest_sessionkey(ar, sessionkey, "test1"), 0);
@@ -702,7 +706,7 @@
 
       if (au->au_params)
 	for (i = 0; au->au_params[i]; i++) {
-	  if (strncasecmp(au->au_params[i], "realm=", 6) == 0)
+	  if (su_casenmatch(au->au_params[i], "realm=", 6))
 	    continue;
 	  equal = strchr(au->au_params[i], '=');
 	  if (equal)



More information about the Freeswitch-svn mailing list