[Freeswitch-svn] [commit] r4767 - in freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua: iptsec msg nta nua nua/sofia-sip sip/tests su/sofia-sip tport url

Freeswitch SVN mikej at freeswitch.org
Mon Mar 26 14:05:57 EDT 2007


Author: mikej
Date: Mon Mar 26 14:05:55 2007
New Revision: 4767

Added:
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt
Modified:
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
   freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c

Log:
upadte to sofia darcs

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c	Mon Mar 26 14:05:55 2007
@@ -178,9 +178,9 @@
     return -1;
 
   if (!ca->ca_credential_class)
-    stale = 1, ca->ca_credential_class = credential_class;
+    stale = 2, ca->ca_credential_class = credential_class;
 
-  return stale ? 2 : 1;
+  return stale > 1 ? 2 : 1;
 }
 
 /** Store authentication info to authenticators.
@@ -748,6 +748,10 @@
 };
 
 /** Store a digest authorization challenge.
+ *
+ * @retval 2 if credentials need to be (re)sent
+ * @retval 1 if challenge was updated
+ * @retval -1 upon an error
  */
 static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
 {
@@ -765,7 +769,7 @@
   if (ac->ac_qop && !ac->ac_auth && !ac->ac_auth_int)
     goto error;
 
-  stale = ac->ac_stale || str0cmp(ac->ac_nonce, cda->cda_ac->ac_nonce);
+  stale = ac->ac_stale || cda->cda_ac->ac_nonce == NULL;
 
   if (ac->ac_qop && (cda->cda_cnonce == NULL || ac->ac_stale)) {
     su_guid_t guid[1];

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c	Mon Mar 26 14:05:55 2007
@@ -1974,6 +1974,8 @@
     return NULL;
 
   msg = msg_create(mc, flags);
+  if (msg == NULL)
+    return NULL;
 
   su_home_preload(msg_home(msg), 1, len + 1024);
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c	Mon Mar 26 14:05:55 2007
@@ -663,6 +663,8 @@
 
 static int test_bad_messages(agent_t *ag)
 {
+  BEGIN();
+
 #if HAVE_DIRENT_H
   DIR *dir;
   struct dirent *d;
@@ -687,13 +689,10 @@
   if (dir == NULL) {
     fprintf(stderr, "test_nta: cannot find sip torture messages\n"); 
     fprintf(stderr, "test_nta: tried %s\n", name); 
-    return 0;
   }
 
   offset = strlen(name);
 
-  BEGIN();
-
   TEST_1(ag->ag_default_leg = nta_leg_tcreate(ag->ag_agent, 
 					      leg_callback_500,
 					      ag,
@@ -720,7 +719,7 @@
   sprintf(via, "v: SIP/2.0/UDP is.invalid:%u\r\n", ntohs(su->su_port));
   vlen = strlen(via);
 
-  for (d = readdir(dir); d; d = readdir(dir)) {
+  for (d = dir ? readdir(dir) : NULL; d; d = readdir(dir)) {
     size_t len = strlen(d->d_name);
     FILE *f;
     int blen, n;
@@ -752,6 +751,8 @@
     su_root_step(ag->ag_root, 1);
   }
 
+  TEST_SIZE(su_sendto(s, "", 0, 0, ai->ai_addr, ai->ai_addrlen), 0);
+
   su_close(s);
 
   for (i = 0; i < 20; i++)
@@ -759,12 +760,12 @@
 
   nta_leg_destroy(ag->ag_default_leg), ag->ag_default_leg = NULL;
 
-  closedir(dir);
+  if (dir)
+    closedir(dir);
 
-  END();
-#else
-  return 0;
 #endif /* HAVE_DIRENT_H */
+
+  END();
 }
 
 static unsigned char const code[] = 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile	Mon Mar 26 14:05:55 2007
@@ -30,6 +30,9 @@
 ALIASES		    += NUA_EVENT="@var nua_event_e::"
 ALIASES		    += END_NUA_EVENT="@par &nbsp;"
 
+ALIASES             += \
+  NUA_HPARAM_CALLS="nua_invite(), nua_respond(), nua_ack(), nua_prack(), nua_update(), nua_info(), nua_bye(), nua_options(), nua_message(), nua_register(), nua_publish(), nua_refer(),nua_subscribe(), nua_notify(), nua_refer(), nua_notifier()"
+
 VERBATIM_HEADERS     = NO
 
 @INCLUDE             = ../sip/sip.doxyaliases

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h	Mon Mar 26 14:05:55 2007
@@ -301,7 +301,8 @@
   unsigned cr_contactize:1;	/**< Request needs Contact */
 
   /* Current state */
-  unsigned cr_challenged:1;	/**< Request was challenged, pending auth */
+  unsigned cr_challenged:1;	/**< Request was challenged */
+  unsigned cr_wait_for_cred:1;	/**< Request is pending authentication */
   unsigned cr_restarting:1;	/**< Request is being restarted */
   unsigned cr_reporting:1;	/**< Reporting in progress */
   unsigned cr_terminating:1;	/**< Request terminates the usage */

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c	Mon Mar 26 14:05:55 2007
@@ -393,6 +393,7 @@
  *   NUTAG_ALLOW(), SIPTAG_ALLOW(), and SIPTAG_ALLOW_STR() \n
  *   NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and 
  *                         SIPTAG_ALLOW_EVENTS_STR() \n
+ *   NUTAG_AUTH_CACHE() \n
  *   NUTAG_AUTOACK() \n
  *   NUTAG_AUTOALERT() \n
  *   NUTAG_AUTOANSWER() \n
@@ -778,6 +779,11 @@
     else if (tag == nutag_path_enable) {
       NHP_SET(nhp, path_enable, value != 0);
     }
+    /* NUTAG_AUTH_CACHE(auth_cache) */
+    else if (tag == nutag_auth_cache) {
+      if (value >= 0 && value < (tag_value_t)_nua_auth_cache_invalid)
+	NHP_SET(nhp, auth_cache, (int)value);
+    }
     /* NUTAG_REFER_EXPIRES(refer_expires) */
     else if (tag == nutag_refer_expires) {
       NHP_SET(nhp, refer_expires, value);
@@ -1363,6 +1369,7 @@
  * @param sip    NULL
  * @param tags
  *   NUTAG_APPL_METHOD() \n
+ *   NUTAG_AUTH_CACHE() \n
  *   NUTAG_AUTOACK() \n
  *   NUTAG_AUTOALERT() \n
  *   NUTAG_AUTOANSWER() \n
@@ -1546,6 +1553,7 @@
      TIF(NUTAG_MEDIA_FEATURES, media_features),
      TIF(NUTAG_SERVICE_ROUTE_ENABLE, service_route_enable),
      TIF(NUTAG_PATH_ENABLE, path_enable),
+     TIF(NUTAG_AUTH_CACHE, auth_cache),
      TIF(NUTAG_REFER_EXPIRES, refer_expires),
      TIF(NUTAG_REFER_WITH_ID, refer_with_id),
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h	Mon Mar 26 14:05:55 2007
@@ -95,9 +95,11 @@
   unsigned         nhp_service_route_enable:1;
   /** Enable Path */
   unsigned         nhp_path_enable:1;
+  /** Authentication cache policy */
+  unsigned         nhp_auth_cache:1;
+
   /** Always include id with Event: refer */
   unsigned         nhp_refer_with_id:1;
-
   unsigned:0;
 
   /* Default lifetime for implicit subscriptions created by REFER */
@@ -157,6 +159,7 @@
     unsigned nhb_media_features:1;
     unsigned nhb_service_route_enable:1;
     unsigned nhb_path_enable:1;
+    unsigned nhb_auth_cache:1;
     unsigned nhb_refer_with_id:1;
     unsigned nhb_refer_expires:1;
     unsigned nhb_substate:1;

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c	Mon Mar 26 14:05:55 2007
@@ -1269,7 +1269,7 @@
       /* No INVITE template */
       cr == NULL || 
       /* INVITE is in progress or being authenticated */
-      cr->cr_orq || cr->cr_challenged)
+      cr->cr_orq || cr->cr_wait_for_cred)
     return;
 
   /* UPDATE in progress or being authenticated */
@@ -3533,10 +3533,13 @@
 			     nua_callstate_terminated);
 
     if (ss && !ss->ss_reporting) {
-      if (nua_client_is_queued(du->du_cr) && du->du_cr->cr_status < 200)
-	/* No final response to INVITE received yet */;
-      else
+      if (du->du_cr == NULL ||
+	  !nua_client_is_queued(du->du_cr) ||
+	  du->du_cr->cr_status >= 200) {
+	/* INVITE is completed, we can zap the session... */;
+	cr->cr_usage = NULL;
 	nua_session_usage_destroy(nh, ss);
+      }
     }
   }
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c	Mon Mar 26 14:05:55 2007
@@ -90,8 +90,6 @@
 static int nh_authorize(nua_handle_t *nh,
 			tag_type_t tag, tag_value_t value, ...);
 
-static int nh_challenge(nua_handle_t *nh, sip_t const *sip);
-
 static void nua_stack_timer(nua_t *nua, su_timer_t *t, su_timer_arg_t *a);
 
 /* ---------------------------------------------------------------------- */
@@ -939,33 +937,6 @@
   return retval;
 }
 
-/**@internal
- * Collect challenges from response.
- *
- * @return Number of updated challenges, 0 if no updates found.
- * @retval -1 upon error.
- */
-static
-int nh_challenge(nua_handle_t *nh, sip_t const *sip)
-{
-  int server = 0, proxy = 0;
-
-  if (sip->sip_www_authenticate)
-    server = auc_challenge(&nh->nh_auth, nh->nh_home,
-			   sip->sip_www_authenticate,
-			   sip_authorization_class);
-
-  if (sip->sip_proxy_authenticate)
-    proxy = auc_challenge(&nh->nh_auth, nh->nh_home,
-			  sip->sip_proxy_authenticate,
-			  sip_proxy_authorization_class);
-
-  if (server < 0 || proxy < 0)
-    return -1;
-
-  return server + proxy;
-}
-
 static inline
 int can_redirect(sip_contact_t const *m, sip_method_t method)
 {
@@ -1023,7 +994,7 @@
   if (status > 0) {
     nua_client_request_t *cr = nh->nh_ds->ds_cr;
 
-    if (cr && cr->cr_challenged) {
+    if (cr && cr->cr_wait_for_cred) {
       nua_client_restart_request(cr, cr->cr_terminating, tags);
     }
     else {
@@ -2043,6 +2014,8 @@
 
 /** Restart the request message.
  *
+ * A restarted request has not completed successfully.
+ *
  * @retval 0 if request is pending
  * @retval >=1 if error event has been sent
  */
@@ -2067,6 +2040,8 @@
 
 /** Resend the request message.
  *
+ * A resent request has completed once successfully - restarted has not.
+ *
  * @retval 0 if request is pending
  * @retval >=1 if error event has been sent
  */
@@ -2075,6 +2050,7 @@
 {
   if (cr) {
     cr->cr_retry_count = 0;
+    cr->cr_challenged = 0;
 
     if (nua_client_is_queued(cr)) {
       if (terminating)
@@ -2223,7 +2199,7 @@
       return -1;
   }
 
-  cr->cr_challenged = 0;
+  cr->cr_wait_for_cred = 0;
 
   if (cr->cr_methods->crm_send)
     return cr->cr_methods->crm_send(cr, msg, sip, NULL);
@@ -2264,8 +2240,13 @@
 {
   nua_handle_t *nh = cr->cr_owner;
 
-  if (nh->nh_auth && auc_authorize(&nh->nh_auth, msg, sip) < 0)
-    return nua_client_return(cr, 900, "Cannot add credentials", msg);
+  if (nh->nh_auth) {
+    if (cr->cr_challenged || 
+	NH_PGET(nh, auth_cache) == nua_auth_cache_dialog) {
+      if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
+	return nua_client_return(cr, 900, "Cannot add credentials", msg);
+    }
+  }
 
   cr->cr_seq = sip->sip_cseq->cs_seq; /* Save last sequence number */
 
@@ -2429,14 +2410,31 @@
 
   /* XXX - handle Retry-After */
 
-  if (status == 302) {
+  if (status == 302 || status == 305) {
+    sip_route_t r[1];
+
     if (!can_redirect(sip->sip_contact, cr->cr_method))
       return 0;
 
-    if (nua_client_set_target(cr, sip->sip_contact->m_url) >= 0)
-      return nua_client_restart(cr, 100, "Redirected");
+    switch (status) {
+    case 302:
+      if (nua_client_set_target(cr, sip->sip_contact->m_url) >= 0)
+	return nua_client_restart(cr, 100, "Redirected");
+      break;
+
+    case 305:
+      sip_route_init(r);
+      *r->r_url = *sip->sip_contact->m_url;
+      if (sip_add_dup(cr->cr_msg, cr->cr_sip, (sip_header_t *)r) >= 0)
+	return nua_client_restart(cr, 100, "Redirected via a proxy");
+      break;
+
+    default:
+      break;
+    }
   }
 
+
   if (status == 423) {
     unsigned my_expires = 0;
     
@@ -2456,20 +2454,40 @@
     }
   }
 
-  if (((status == 401 && sip->sip_www_authenticate) ||
-       (status == 407 && sip->sip_proxy_authenticate)) &&
-      nh_challenge(nh, sip) > 0) {
+  if ((status == 401 && sip->sip_www_authenticate) ||
+      (status == 407 && sip->sip_proxy_authenticate)) {
+    int server = 0, proxy = 0;
     nta_outgoing_t *orq;
-    if (auc_has_authorization(&nh->nh_auth)) 
-      return nua_client_restart(cr, 100, "Request Authorized by Cache");
 
-    orq = cr->cr_orq, cr->cr_orq = NULL;
-    cr->cr_challenged = 1;
-    cr->cr_retry_count++;
-    nua_client_report(cr, status, phrase, NULL, orq, NULL);
-    nta_outgoing_destroy(orq);
+    if (sip->sip_www_authenticate)
+      server = auc_challenge(&nh->nh_auth, nh->nh_home,
+			     sip->sip_www_authenticate,
+			     sip_authorization_class);
+
+    if (sip->sip_proxy_authenticate)
+      proxy = auc_challenge(&nh->nh_auth, nh->nh_home,
+			    sip->sip_proxy_authenticate,
+			    sip_proxy_authorization_class);
+
+    if (server >= 0 && proxy >= 0) {
+      int invalid = cr->cr_challenged && server + proxy == 0;
+
+      cr->cr_challenged = 1;
+
+      if (invalid)
+	/* Bad username/password */
+	auc_clear_credentials(&nh->nh_auth, NULL, NULL);
+      else if (auc_has_authorization(&nh->nh_auth)) 
+	return nua_client_restart(cr, 100, "Request Authorized by Cache");
+
+      orq = cr->cr_orq, cr->cr_orq = NULL;
+      cr->cr_wait_for_cred = 1;
+      cr->cr_retry_count++;
+      nua_client_report(cr, status, phrase, NULL, orq, NULL);
+      nta_outgoing_destroy(orq);
 
-    return 1;
+      return 1;
+    }
   }
 
   return 0;  /* This was a final response that cannot be restarted. */
@@ -2591,8 +2609,18 @@
 
   cr->cr_reporting = 1, nh->nh_ds->ds_reporting = 1;
 
-  if (status >= 200 && status < 300)
-    nh_challenge(nh, sip);  /* Collect nextnonce */
+  if (nh->nh_auth && sip &&
+      (sip->sip_authentication_info || sip->sip_proxy_authentication_info)) {
+    /* Collect nextnonce */
+    if (sip->sip_authentication_info)
+      auc_info(&nh->nh_auth,
+	       sip->sip_authentication_info,
+	       sip_authorization_class);
+    if (sip->sip_proxy_authentication_info) 
+      auc_info(&nh->nh_auth,
+	       sip->sip_proxy_authentication_info,
+	       sip_proxy_authorization_class);
+  }
 
   if ((method != sip_method_invite && status >= 200) || status >= 300)
     nua_client_request_remove(cr);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c	Mon Mar 26 14:05:55 2007
@@ -144,6 +144,7 @@
 tag_typedef_t nutag_path_enable = BOOLTAG_TYPEDEF(path_enable);
 tag_typedef_t nutag_service_route_enable = 
   BOOLTAG_TYPEDEF(service_route_enable);
+tag_typedef_t nutag_auth_cache = INTTAG_TYPEDEF(auth_cache);
 
 tag_typedef_t nutag_detect_network_updates = UINTTAG_TYPEDEF(detect_network_updates);
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h	Mon Mar 26 14:05:55 2007
@@ -451,8 +451,8 @@
  *
  * @par Used with
  *    nua_invite() \n
- *    nua_set_params() \n
- *    nua_get_params()
+ *    nua_set_params(), nua_set_hparams(),
+ *    nua_get_params(), nua_get_hparams()
  *
  * @par Parameter type
  *    int (enum nua_af)
@@ -1247,6 +1247,38 @@
 #define NUTAG_AUTH_REF(x)	    nutag_auth_ref, tag_str_vr(&(x))
 SOFIAPUBVAR tag_typedef_t nutag_auth_ref;
 
+/** Authentication caching policy
+ *
+ * @par Used with
+ *    nua_set_params(), nua_set_hparams() \n
+ *    nua_get_params(), nua_get_hparams() \n
+ *    @NUA_HPARAM_CALLS 
+ *
+ * @par Parameter type
+ *    enum nua_auth_cache
+ *
+ * @par Values
+ *    - nua_auth_cache_dialog (0) - include credentials within dialog
+ *    - nua_auth_cache_challenged (1) - include credentials only when 
+ *                                      challenged
+ *    
+ * Corresponding tag taking reference parameter is NUTAG_AUTH_CACHE_REF()
+ */
+#define NUTAG_AUTH_CACHE(x)   nutag_auth_cache, tag_int_v(x)
+SOFIAPUBVAR tag_typedef_t nutag_auth_cache;
+
+#define NUTAG_AUTH_CACHE_REF(x) nutag_auth_cache_ref, tag_int_vr(&(x))
+SOFIAPUBVAR tag_typedef_t nutag_auth_cache_ref;
+
+/** Authentication caching policy */
+enum nua_auth_cache {
+  /** Include credentials within dialog (default) */
+  nua_auth_cache_dialog = 0,
+  /** Include credentials only when challenged */
+  nua_auth_cache_challenged = 1,
+  _nua_auth_cache_invalid
+};
+
 /** Keepalive interval in milliseconds.
  *
  * This setting applies to OPTIONS/STUN keepalives. See documentation 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c	Mon Mar 26 14:05:55 2007
@@ -404,17 +404,21 @@
   TEST_1(is_answer_recv(e->data->e_tags));
   TEST_1(!is_offer_sent(e->data->e_tags));
 
-  if (md5 && !md5sess) {
-    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
-    TEST(e->data->e_status, 407);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
+
+  if (e->data->e_status != 200 && md5 && !md5sess) {
+    if (e->data->e_status != 100) {
+      TEST(e->data->e_status, 407);
+    }
 
     TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
     TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
     TEST_1(!is_answer_recv(e->data->e_tags));
     TEST_1(!is_offer_sent(e->data->e_tags));
+
+    TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
   }
 
-  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
   TEST(e->data->e_status, 200);
 
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c	Mon Mar 26 14:05:55 2007
@@ -261,7 +261,7 @@
 
 /* ------------------------------------------------------------------------ */
 
-int reject_302(CONDITION_PARAMS);
+int reject_302(CONDITION_PARAMS), reject_305(CONDITION_PARAMS);
 int reject_604(CONDITION_PARAMS);
 
 /*
@@ -281,6 +281,7 @@
  |<---604 Nowhere-----|
  |--------ACK-------->|
 */
+
 int reject_302(CONDITION_PARAMS)
 {
   if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
@@ -301,6 +302,33 @@
   case nua_callstate_terminated:
     if (call)
       nua_handle_destroy(call->nh), call->nh = NULL;
+    ep->next_condition = reject_305;
+    return 0;
+  default:
+    return 0;
+  }
+}
+
+int reject_305(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    {
+      sip_contact_t m[1];
+      *m = *ep->contact;
+      m->m_url->url_user = "305";
+      m->m_url->url_params = "lr=1";
+      RESPOND(ep, call, nh, SIP_305_USE_PROXY, SIPTAG_CONTACT(m), TAG_END());
+    }
+    return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
     ep->next_condition = reject_604;
     return 0;
   default:
@@ -308,6 +336,7 @@
   }
 }
 
+
 int reject_604(CONDITION_PARAMS)
 {
   if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
@@ -338,6 +367,7 @@
   struct endpoint *a = &ctx->a, *b = &ctx->b;
   struct call *a_call = a->call, *b_call = b->call;
   struct event *e;
+  sip_t const *sip;
 
   /* Make call reject-3 */
   if (print_headings)
@@ -388,6 +418,12 @@
   TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
   TEST_1(is_offer_sent(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(e->data->e_status, 100);
+  TEST(sip_object(e->data->e_msg)->sip_status->st_status, 305);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
   TEST(e->data->e_status, 180);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
@@ -415,6 +451,18 @@
   TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
   TEST_1(is_offer_recv(e->data->e_tags));
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+  TEST(e->data->e_status, 100);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST_1(sip->sip_request);
+  TEST_S(sip->sip_request->rq_url->url_user, "302");
+  TEST_1(sip->sip_route);
+  TEST_S(sip->sip_route->r_url->url_user, "305");
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
@@ -724,7 +772,7 @@
   sip_t const *sip;
 
   if (print_headings)
-    printf("TEST NUA-4.6: invalid challenge \n");
+    printf("TEST NUA-4.6.1: invalid challenge \n");
 
   a_call->sdp = "m=audio 5008 RTP/AVP 8";
   b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
@@ -773,7 +821,160 @@
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   if (print_headings)
-    printf("TEST NUA-4.6: PASSED\n");
+    printf("TEST NUA-4.6.1: PASSED\n");
+
+  END();
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/* Reject call with 401, twice */
+
+/*
+ A   reject-401-bad   B
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |<--------401--------|
+ |---------ACK------->|
+ |                    |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |<--------401--------|
+ |---------ACK------->|
+*/
+
+int reject_401_bad(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  switch (callstate(tags)) {
+  case nua_callstate_received:
+    RESPOND(ep, call, nh, SIP_401_UNAUTHORIZED,
+	    /* Send a challenge that we do not grok */
+	    SIPTAG_WWW_AUTHENTICATE_STR("Digest realm=\"No hope\", "
+					"nonce=\"goO541ftNrw327aWpu2\", "
+					"algorithm=MD5, "
+					"qop=\"auth\""),
+	    TAG_END());
+    return 0;
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    if (ep->flags.bit0)		/* Terminate 2 calls */
+      return 1;
+    ep->flags.bit0 = 1;
+    return 0;
+  default:
+    return 0;
+  }
+}
+
+int authenticate_once(CONDITION_PARAMS)
+{
+  if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+    return 0;
+
+  save_event_in_list(ctx, event, ep, call);
+
+  if (event == nua_r_invite && status == 401) {
+    if (ep->flags.bit0) {
+      nua_handle_destroy(nh); if (call) call->nh = NULL;
+      return 1;
+    }
+    ep->flags.bit0 = 1;
+    AUTHENTICATE(ep, call, nh, NUTAG_AUTH("Digest:\"No hope\":jaska:secret"),
+		 SIPTAG_SUBJECT_STR("Got 401"),
+		 TAG_END());
+    return 0;
+  }
+
+  switch (callstate(tags)) {
+  case nua_callstate_terminated:
+    if (call)
+      nua_handle_destroy(call->nh), call->nh = NULL;
+    return 1;
+  default:
+    return 0;
+  }
+}
+
+
+int test_reject_401_bad(struct context *ctx)
+{
+  BEGIN();
+
+  struct endpoint *a = &ctx->a, *b = &ctx->b;
+  struct call *a_call = a->call, *b_call = b->call;
+  struct event const *e;
+  sip_t const *sip;
+
+  if (print_headings)
+    printf("TEST NUA-4.6.2: bad username/password\n");
+
+  a_call->sdp = "m=audio 5008 RTP/AVP 8";
+
+  TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+  INVITE(a, a_call, a_call->nh,
+	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+	 SIPTAG_SUBJECT_STR("reject-401-bad"),
+	 SOATAG_USER_SDP_STR(a_call->sdp),
+	 TAG_END());
+
+  run_ab_until(ctx, -1, authenticate_once, -1, reject_401_bad);
+
+  /*
+   Client transitions
+   INIT -(C1)-> CALLING -(C6a)-> TERMINATED/INIT
+  */
+  TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(sip_object(e->data->e_msg)->sip_status->st_status, 401);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+  TEST_1(is_offer_sent(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+  TEST(sip_object(e->data->e_msg)->sip_status->st_status, 401);
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, a->events);
+
+  /*
+   Server transitions:
+   INIT -(S1)-> RECEIVED -(S6a)-> TERMINATED
+  */
+  TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+  TEST_1(sip = sip_object(e->data->e_msg));
+  TEST(e->data->e_status, 100);
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+  TEST_1(is_offer_recv(e->data->e_tags));
+  TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+  TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+  TEST_1(!e->next);
+
+  free_events_in_list(ctx, b->events);
+
+  nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+  nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+  if (print_headings)
+    printf("TEST NUA-4.6.2: PASSED\n");
 
   END();
 }
@@ -976,7 +1177,7 @@
   struct endpoint *a = &ctx->a, *b = &ctx->b;
   struct call *a_call = a->call, *b_call = b->call;
   struct event *e;
-  struct nat_filter *f;
+  struct nat_filter *f, *f2;
 
   if (print_headings)
     printf("TEST NUA-4.7: check for error and timeout handling\n");
@@ -993,6 +1194,8 @@
   TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
 
   TEST_1(f = test_nat_add_filter(ctx->nat, filter_200_OK, NULL, nat_inbound));
+  TEST_1(f2 = test_nat_add_filter(ctx->nat, filter_200_OK,
+				  NULL, nat_outbound));
   
   INVITE(a, a_call, a_call->nh,
 	 TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
@@ -1014,7 +1217,7 @@
  |   X-----200--------|
  |                    |
  |<--------BYE--------|
- |--------200 OK----->|
+ |--------200 OK---X  |
 
   */
 
@@ -1052,6 +1255,7 @@
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+  TEST(e->data->e_status, 408);
   TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
   TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
   TEST_1(!e->next);
@@ -1062,6 +1266,7 @@
   nua_handle_destroy(b_call->nh), b_call->nh = NULL;
 
   TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
+  TEST_1(test_nat_remove_filter(ctx->nat, f2) == 0);
 
   if (print_headings)
     printf("TEST NUA-4.7.1: PASSED\n");
@@ -1262,3 +1467,19 @@
 
   return event == nua_i_state && callstate(tags) == nua_callstate_terminated;
 }
+
+/* ---------------------------------------------------------------------- */
+
+int test_rejects(struct context *ctx)
+{
+  return
+    test_reject_401_bad(ctx) ||
+    test_reject_a(ctx) ||
+    test_reject_b(ctx) ||
+    test_reject_302(ctx) ||
+    test_reject_401(ctx) ||
+    test_mime_negotiation(ctx) ||
+    test_call_timeouts(ctx) ||
+    test_reject_401_aka(ctx) ||
+    0;
+}

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c	Mon Mar 26 14:05:55 2007
@@ -110,7 +110,8 @@
 			       AUTHTAG_OPAQUE("kuik"),
 			       AUTHTAG_DB(passwd_name),
 			       AUTHTAG_QOP("auth-int"),
-			       AUTHTAG_ALGORITHM("md5-sess"),
+			       AUTHTAG_ALGORITHM("md5"),
+			       AUTHTAG_NEXT_EXPIRES(60),
 			       TAG_IF(ctx->proxy_logging, TPTAG_LOG(1)),
 			       TAG_END());
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c	Mon Mar 26 14:05:55 2007
@@ -307,13 +307,7 @@
 
     while (retval == 0) {
       retval |= test_basic_call(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_a(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_b(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_302(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_401(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_mime_negotiation(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_call_timeouts(ctx); SINGLE_FAILURE_CHECK();
-      retval |= test_reject_401_aka(ctx); SINGLE_FAILURE_CHECK();
+      retval |= test_rejects(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_call_cancel(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_call_destroy(ctx); SINGLE_FAILURE_CHECK();
       retval |= test_offer_answer(ctx); SINGLE_FAILURE_CHECK();

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h	Mon Mar 26 14:05:55 2007
@@ -330,10 +330,7 @@
 
 int test_basic_call(struct context *ctx);
 int test_offer_answer(struct context *ctx);
-int test_reject_a(struct context *ctx);
-int test_reject_b(struct context *ctx);
-int test_reject_302(struct context *ctx);
-int test_reject_401(struct context *ctx);
+int test_rejects(struct context *ctx);
 int test_mime_negotiation(struct context *ctx);
 int test_call_timeouts(struct context *ctx);
 int test_reject_401_aka(struct context *ctx);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c	Mon Mar 26 14:05:55 2007
@@ -193,6 +193,7 @@
 		 NUTAG_MEDIA_FEATURES(1),
 		 NUTAG_SERVICE_ROUTE_ENABLE(0),
 		 NUTAG_PATH_ENABLE(0),
+		 NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
 		 NUTAG_REFER_EXPIRES(333),
 		 NUTAG_REFER_WITH_ID(0),
 		 NUTAG_SUBSTATE(nua_substate_pending),
@@ -268,6 +269,7 @@
     int media_features = -1;
     int service_route_enable = -1;
     int path_enable = -1;
+    int auth_cache = -1;
     unsigned refer_expires = (unsigned)-1;
     int refer_with_id = -1;
     int substate = -1;
@@ -331,6 +333,7 @@
 	       	NUTAG_MEDIA_FEATURES_REF(media_features),
 	       	NUTAG_SERVICE_ROUTE_ENABLE_REF(service_route_enable),
 	       	NUTAG_PATH_ENABLE_REF(path_enable),
+	       	NUTAG_AUTH_CACHE_REF(auth_cache),
 	       	NUTAG_REFER_EXPIRES_REF(refer_expires),
 	       	NUTAG_REFER_WITH_ID_REF(refer_with_id),
 	       	NUTAG_SUBSTATE_REF(substate),
@@ -361,7 +364,7 @@
 		NUTAG_INSTANCE_REF(instance),
 
 		TAG_END());
-    TEST(n, 47);
+    TEST(n, 48);
 
     TEST_S(sip_header_as_string(tmphome, (void *)from), Alice);
     TEST_S(from_str, Alice);
@@ -391,6 +394,7 @@
     TEST(media_features, 1);
     TEST(service_route_enable, 0);
     TEST(path_enable, 0);
+    TEST(auth_cache, nua_auth_cache_challenged);
     TEST(refer_expires, 333);
     TEST(refer_with_id, 0);
     TEST(substate, nua_substate_pending);
@@ -455,6 +459,7 @@
     int media_features = -1;
     int service_route_enable = -1;
     int path_enable = -1;
+    int auth_cache = -1;
     unsigned refer_expires = (unsigned)-1;
     int refer_with_id = -1;
     int substate = -1;
@@ -513,6 +518,7 @@
 	       	NUTAG_MEDIA_FEATURES_REF(media_features),
 	       	NUTAG_SERVICE_ROUTE_ENABLE_REF(service_route_enable),
 	       	NUTAG_PATH_ENABLE_REF(path_enable),
+		NUTAG_AUTH_CACHE_REF(auth_cache),
 	       	NUTAG_SUBSTATE_REF(substate),
 
 	       	SIPTAG_SUPPORTED_REF(supported),
@@ -565,6 +571,7 @@
     TEST(media_features, -1);
     TEST(service_route_enable, -1);
     TEST(path_enable, -1);
+    TEST(auth_cache, -1);
     TEST(refer_expires, (unsigned)-1);
     TEST(refer_with_id, -1);
     TEST(substate, -1);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c	Mon Mar 26 14:05:55 2007
@@ -55,6 +55,7 @@
   struct event *e;
   sip_t const *sip;
   sip_cseq_t cseq[1];
+  int seen_401;
 
   if (ctx->p)
     test_proxy_set_expiration(ctx->p, 5, 5, 10);
@@ -189,6 +190,8 @@
 
     REGISTER(b, b_reg, b_reg->nh, SIPTAG_TO(b->to), 
 	     SIPTAG_CONTACT(m),
+	     /* Do not include credentials unless challenged */
+	     NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
 	     TAG_END());
   }
   run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
@@ -213,7 +216,8 @@
   TEST_1(sip->sip_contact);
   TEST_S(sip->sip_contact->m_display, "B");
   TEST_S(sip->sip_contact->m_url->url_user, "b");
-
+  free_events_in_list(ctx, b->events);
+  
   if (print_headings)
     printf("TEST NUA-2.3.2: PASSED\n");
 
@@ -318,11 +322,21 @@
   TEST_1(!e->next);
   free_events_in_list(ctx, a->events);
 
+  seen_401 = 0;
+
   for (e = b->events->head; e; e = e->next) {
     TEST_E(e->data->e_event, nua_r_register);
-    TEST(e->data->e_status, 200);
     TEST_1(sip = sip_object(e->data->e_msg));
-    TEST_1(sip->sip_contact);
+
+    if (e->data->e_status == 200) {
+      TEST(e->data->e_status, 200);
+      TEST_1(seen_401);
+      TEST_1(sip->sip_contact);
+    }
+    else if (sip->sip_status && sip->sip_status->st_status == 401) {
+      seen_401 = 1;
+    }
+
     if (!e->next)
       break;
   }
@@ -680,6 +694,10 @@
     run_b_until(ctx, -1, save_until_final_response);
     TEST_1(e = b->events->head);
     TEST_E(e->data->e_event, nua_r_unregister);
+    if (e->data->e_status == 100) {
+      TEST_1(e = e->next);
+      TEST_E(e->data->e_event, nua_r_unregister);
+    }
     TEST(e->data->e_status, 200);
     TEST_1(sip = sip_object(e->data->e_msg));
     TEST_1(!sip->sip_contact);

Added: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt
==============================================================================
--- (empty file)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt	Mon Mar 26 14:05:55 2007
@@ -0,0 +1,20 @@
+INVITE sip:1234 at 10.50.71.28 SIP/2.0
+To: <sip:1234 at 10.50.71.28>
+From: "Displayname" <sip:1234 at testaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.example.local:5060>;tag=10052
+Via: SIP/2.0/UDP 10.50.71.29:5060;branch=z9hG4bK10052t1174659568681
+Call-ID: s0c00010052i0t1174659568681 at 10.50.71.29
+Contact: "999" <sip:999 at 10.50.71.29;transport=udp>
+Content-Length: 180
+Content-Type: application/sdp
+CSeq: 1 INVITE
+Max-Forwards: 70
+
+v=0
+o=999 1 1 IN IP4 10.50.71.29
+s=Codenomicon SIP UAS Test Tool 3.0.2 (http://www.codenomicon.com/)
+c=IN IP4 10.50.71.29
+t=0 0
+m=audio 49152 RTP/AVP 0
+a=rtpmap:0 PCMU/8000
\ No newline at end of file

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h	Mon Mar 26 14:05:55 2007
@@ -46,9 +46,7 @@
 #include "sofia-sip/su_time.h"
 #endif
 
-#if SU_HAVE_KQUEUE
-#include <sys/event.h>
-#elif SU_HAVE_POLL
+#if SU_HAVE_POLL
 #include <sys/poll.h>
 #endif
 

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c	Mon Mar 26 14:05:55 2007
@@ -252,6 +252,11 @@
 		su_strerror(err), err));
     return -1;
   }
+  if (N == 0) {
+    su_recv(self->tp_socket, sample, 1, 0);
+    SU_DEBUG_3(("tport(%p): zero length packet", (void *)self));
+    return 0;
+  }
 #endif
 
   veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, 1);

Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c	(original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c	Mon Mar 26 14:05:55 2007
@@ -403,6 +403,10 @@
   TEST_S(u->url_params, "isfocus");
   TEST_1(!url_have_transport(u));
 
+  u = url_hdup(home, (void *)"sip:%22foo%22 at 172.21.55.55:5060");
+  TEST_1(u);
+  TEST_S(u->url_user, "%22foo%22");
+
   a = url_hdup(home, (void *)"sip:172.21.55.55:5060");
   b = url_hdup(home, (void *)"sip:172.21.55.55");
   TEST_1(a); TEST_1(b);



More information about the Freeswitch-svn mailing list