[Freeswitch-svn] [commit] r7354 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua: nta nta/sofia-sip sip soa soa/sofia-sip sresolv sresolv/sofia-resolv su su/sofia-sip

Freeswitch SVN mikej at freeswitch.org
Fri Jan 25 12:42:24 EST 2008


Author: mikej
Date: Fri Jan 25 12:42:24 2008
New Revision: 7354

Modified:
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/sofia-sip/soa_session.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_cache.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_addrinfo.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_addrinfo.c

Log:
unpull a number of patches from the previous darcs merge to try to eliminate some causes of new segfaults in sofia-sip


Wed Jan 23 11:05:58 EST 2008  Pekka.Pessi at nokia.com
  * nta.c: asserting in proper place when handling queue tail
Shall I unpull this patch? (4/553)  [ynWvpxqadjk], or ? for help: y

Wed Jan 23 11:05:23 EST 2008  Pekka.Pessi at nokia.com
  * nta.c: ignore tags in nta_leg_by_dialog() if they are empty strings
Shall I unpull this patch? (5/553)  [ynWvpxqadjk], or ? for help: y

Tue Jan 22 13:59:44 EST 2008  Pekka.Pessi at nokia.com
  * nta.c: added NTATAG_GRAYLIST().

  Use NTATAG_GRAYLIST() as ttl value for sres_set_cached_srv_priority().
Shall I unpull this patch? (14/553)  [ynWvpxqadjk], or ? for help: y

Tue Jan 22 13:57:38 EST 2008  Pekka.Pessi at nokia.com
  * sres: added ttl parameter to sres_set_cached_srv_priority() and sres_cache_set_srv_priority().
Shall I unpull this patch? (15/553)  [ynWvpxqadjk], or ? for help: y

Tue Jan 22 11:15:04 EST 2008  Pekka.Pessi at nokia.com
  * sip_util.c: updated sip_response_terminates_dialog() as per RFC 5057.

  Changes handling of 423 in case of SUBSCRIBE.
Shall I unpull this patch? (22/553)  [ynWvpxqadjk], or ? for help: y

Mon Jan 21 14:06:35 EST 2008  Pekka.Pessi at nokia.com
  * soa.c: using session state in soa_set_activity()

  The media mode bits are set using (local) session description instead of
  remote offer/answer when O/A has been completed.
Shall I unpull this patch? (26/553)  [ynWvpxqadjk], or ? for help: y

Fri Jan 11 12:11:12 EST 2008  Pekka.Pessi at nokia.com
  * nta.c: NetModule hack re-prioritizing SRV records
  
  Original hack by Stefan Leuenberger <Stefan.Leuenberger at netmodule.com>.
  
  The hack reprioritizes the SRV records used with transaction in case a
  server refuses connection or it does not answer.
Shall I unpull this patch? (51/553)  [ynWvpxqadjk], or ? for help: y

Fri Jan 11 09:28:46 EST 2008  Pekka.Pessi at nokia.com
  * su_addrinfo.c: if su_getaddrinfo() service is NULL, try both with "0" and NULL
Shall I unpull this patch? (53/553)  [ynWvpxqadjk], or ? for help: y




Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c	Fri Jan 25 12:42:24 2008
@@ -338,7 +338,7 @@
  * NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(),
  * NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(),
  * NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(),
- * NTATAG_EXTRA_100(), NTATAG_GRAYLIST(),
+ * NTATAG_EXTRA_100(),
  * NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS()
  * NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(), 
  * NTATAG_REL100(), 
@@ -400,7 +400,6 @@
     agent->sa_t4              = NTA_SIP_T4;
     agent->sa_t1x64 	      = 64 * NTA_SIP_T1;
     agent->sa_timer_c         = 185 * 1000;
-    agent->sa_graylist        = 600;
     agent->sa_drop_prob       = 0;
     agent->sa_is_a_uas        = 0;
     agent->sa_progress        = 60 * 1000;
@@ -895,7 +894,7 @@
  * NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(),
  * NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(),
  * NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(),
- * NTATAG_EXTRA_100(), NTATAG_GRAYLIST(),
+ * NTATAG_EXTRA_100(),
  * NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS()
  * NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(), 
  * NTATAG_REL100(), 
@@ -945,7 +944,6 @@
   unsigned sip_t4     = agent->sa_t4;
   unsigned sip_t1x64  = agent->sa_t1x64;
   unsigned timer_c    = agent->sa_timer_c;
-  unsigned graylist   = agent->sa_graylist;
   unsigned blacklist  = agent->sa_blacklist;
   int ua              = agent->sa_is_a_uas;
   unsigned progress   = agent->sa_progress;
@@ -989,7 +987,6 @@
 	      NTATAG_DEBUG_DROP_PROB_REF(drop_prob),
 	      NTATAG_DEFAULT_PROXY_REF(proxy),
 	      NTATAG_EXTRA_100_REF(extra_100),
-	      NTATAG_GRAYLIST_REF(graylist),
 	      NTATAG_MAXSIZE_REF(maxsize),
 	      NTATAG_MAX_PROCEEDING_REF(max_proceeding),
 	      NTATAG_MAX_FORWARDS_REF(max_forwards),
@@ -1143,12 +1140,6 @@
     outgoing_queue_adjust(agent, agent->sa_out.inv_proceeding, timer_c);
   }
 
-  if (graylist > 24 * 60 * 60)
-    graylist = 24 * 60 * 60;
-  agent->sa_graylist = graylist;
-
-  if (blacklist > 24 * 60 * 60)
-    blacklist = 24 * 60 * 60;
   agent->sa_blacklist = blacklist;
 
   if (progress == 0)
@@ -1211,7 +1202,7 @@
  * NTATAG_CANCEL_2543_REF(), NTATAG_CANCEL_487_REF(),
  * NTATAG_CLIENT_RPORT_REF(), NTATAG_CONTACT_REF(), 
  * NTATAG_DEBUG_DROP_PROB_REF(), NTATAG_DEFAULT_PROXY_REF(),
- * NTATAG_EXTRA_100_REF(), NTATAG_GRAYLIST_REF(),
+ * NTATAG_EXTRA_100_REF(),
  * NTATAG_MAXSIZE_REF(), NTATAG_MAX_FORWARDS_REF(), NTATAG_MCLASS_REF(),
  * NTATAG_MERGE_482_REF(), NTATAG_MAX_PROCEEDING_REF(),
  * NTATAG_PASS_100_REF(), NTATAG_PASS_408_REF(), NTATAG_PRELOAD_REF(),
@@ -1260,7 +1251,6 @@
 	     NTATAG_DEBUG_DROP_PROB(agent->sa_drop_prob),
 	     NTATAG_DEFAULT_PROXY(agent->sa_default_proxy),
 	     NTATAG_EXTRA_100(agent->sa_extra_100),
-	     NTATAG_GRAYLIST(agent->sa_graylist),
 	     NTATAG_MAXSIZE(agent->sa_maxsize),
 		 NTATAG_MAX_PROCEEDING(agent->sa_max_proceeding),
 	     NTATAG_MAX_FORWARDS(agent->sa_max_forwards->mf_count),
@@ -4133,9 +4123,6 @@
  *                     it must math
  * @param local_uri    ignored
  *
- * @note
- * If @a remote_tag or @a local_tag is an empty string (""), the tag is
- * ignored when matching legs.
  */
 nta_leg_t *nta_leg_by_dialog(nta_agent_t const *agent,
 			     url_t const *request_uri,
@@ -4237,9 +4224,9 @@
     if (!remote_tag != !from_tag && !local_tag != !to_tag)
       continue;
 
-    if (local_tag && to_tag && strcasecmp(local_tag, to_tag) && to_tag[0])
+    if (local_tag && to_tag && strcasecmp(local_tag, to_tag))
       continue;
-    if (remote_tag && from_tag && strcasecmp(remote_tag, from_tag) && from_tag[0])
+    if (remote_tag && from_tag && strcasecmp(remote_tag, from_tag))
       continue;
 
     if (leg_url && request_uri && url_cmp(leg_url, request_uri))
@@ -7662,7 +7649,6 @@
   if (outgoing_is_queued(orq))
     outgoing_remove(orq);
 
-  assert(orq->orq_next == NULL);
   assert(*queue->q_tail == NULL);
 
   orq->orq_timeout = set_timeout(orq->orq_agent, queue->q_timeout);
@@ -7686,7 +7672,7 @@
   if ((*orq->orq_prev = orq->orq_next))
     orq->orq_next->orq_prev = orq->orq_prev;
   else
-    orq->orq_queue->q_tail = orq->orq_prev;
+    orq->orq_queue->q_tail = orq->orq_prev, assert(!*orq->orq_queue->q_tail);
 
   orq->orq_queue->q_length--;
   orq->orq_next = NULL;
@@ -8842,8 +8828,8 @@
   char const *sq_proto;
   char const *sq_domain;
   char     sq_port[6];		/* port number */
-  uint16_t sq_otype;		/* origin type of query data (0 means request) */
-  uint16_t sq_type;		/* query type */
+
+  uint16_t sq_type;
   uint16_t sq_priority;		/* priority or preference  */
   uint16_t sq_weight;		/* preference or weight */
 };
@@ -9074,65 +9060,6 @@
   outgoing_reset_timer(orq);
   outgoing_queue(orq->orq_agent->sa_out.resolving, orq);
 
-  if (orq->orq_status > 0)
-    /* PP: don't hack priority if a preliminary response has been received */
-    ;
-  else if (orq->orq_agent->sa_graylist == 0)
-    /* PP: priority hacking disabled */
-    ;
-  /* NetModule hack: 
-   * Move server that did not work to end of queue in sres cache
-   *
-   * the next request does not try to use the server that is currently down
-   *
-   * @TODO: fix cases with only A or AAAA answering, or all servers down.
-   */
-  else if (sr && sr->sr_target) {
-    struct sipdns_query *sq;
-
-    /* find latest A/AAAA record */
-    sq = sr->sr_head;
-    if (!sq || (sr->sr_a_aaaa1 != sr->sr_a_aaaa2 && sq->sq_type == sr->sr_a_aaaa1))
-	sq = sr->sr_done;	
-    
-    if (sq && sq->sq_otype == sres_type_srv) {
-      char const *target = sq->sq_domain, *proto = sq->sq_proto;
-      unsigned prio = sq->sq_priority, maxprio = prio;
-
-      SU_DEBUG_5(("nta: no response from %s:%s;transport=%s\n", target, sq->sq_port, proto));
-
-      for (sq = sr->sr_head; sq; sq = sq->sq_next) 
-	if (sq->sq_otype == sres_type_srv && sq->sq_priority > maxprio)
-	  maxprio = sq->sq_priority;
-
-      for (sq = sr->sr_done; sq; sq = sq->sq_next)
-	if (sq->sq_otype == sres_type_srv && sq->sq_priority > maxprio)
-	  maxprio = sq->sq_priority;
-
-      for (sq = sr->sr_done; sq; sq = sq->sq_next) {
-	int modified;
-
-	if (sq->sq_type != sres_type_srv || strcmp(proto, sq->sq_proto))
-	  continue;
-
-	/* modify the SRV record(s) corresponding to the latest A/AAAA record */
-	modified = sres_set_cached_srv_priority(
-	  orq->orq_agent->sa_resolver, 
-	  sq->sq_domain, 
-	  target,
-	  sq->sq_port[0] ? (uint16_t)strtoul(sq->sq_port, NULL, 10) : 0,
-	  orq->orq_agent->sa_graylist,
-	  maxprio + 1);
-
-	if (modified >= 0)
-	  SU_DEBUG_3(("nta: reduced priority of %d %s SRV records (increase value to %u)\n",
-		      modified, sq->sq_domain, maxprio + 1));
-	else
-	  SU_DEBUG_3(("nta: failed to reduce %s SRV priority\n", sq->sq_domain));
-      }
-    }
-  }
-
   return outgoing_resolve_next(orq);
 }
 
@@ -9411,7 +9338,6 @@
     sq = su_zalloc(home, (sizeof *sq) + rlen);
 
     *tail = sq, tail = &sq->sq_next;    
-    sq->sq_otype = sres_type_naptr;
     sq->sq_priority = na->na_prefer;
     sq->sq_weight = j;
     sq->sq_type = type;
@@ -9512,11 +9438,11 @@
     if (sq) {
       *tail = sq, tail = &sq->sq_next;
 
-      sq->sq_otype = sres_type_srv;
       sq->sq_type = sr->sr_a_aaaa1;
       sq->sq_proto = sq0->sq_proto;
       sq->sq_domain = memcpy(sq + 1, srv->srv_target, tlen);
       snprintf(sq->sq_port, sizeof(sq->sq_port), "%u", srv->srv_port);
+
       sq->sq_priority = srv->srv_priority;
       sq->sq_weight = srv->srv_weight;
     }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_internal.h	Fri Jan 25 12:42:24 2008
@@ -167,8 +167,6 @@
   /** SIP timer C - interval between provisional responses receivedxs */
   unsigned              sa_timer_c;
 
-  /** Graylisting period */
-  unsigned              sa_graylist;
   /** Blacklisting period */
   unsigned              sa_blacklist;
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta_tag.c	Fri Jan 25 12:42:24 2008
@@ -643,31 +643,6 @@
  */
 tag_typedef_t ntatag_timer_c = UINTTAG_TYPEDEF(timer_c);
 
-/**@def NTATAG_GRAYLIST(x)
- *
- * Avoid failed servers.
- *
- * The NTATAG_GRAYLIST() provides the time that the servers are avoided
- * after a request sent to them has been failed. Avoiding means that if a
- * domain provides multiple servers, the failed servers are tried last.
- *
- * @par Used with
- *    nua_create(), nua_set_params(),
- *    nta_agent_create(), nta_agent_set_params()
- *
- * @par Parameter type
- *     unsigned int
- *
- * @par Values
- *    - Number of seconds that server is kept in graylist, from 0 to 86400.
- *
- * @par Default Value
- *    - 600 (graylist server for 10 minutes)
- *
- * @sa NTATAG_BLACKLIST(), NTATAG_TIMEOUT_408()
- */
-tag_typedef_t ntatag_graylist = UINTTAG_TYPEDEF(graylist);
-
 /**@def NTATAG_BLACKLIST(x)
  *
  * Add Retry-After header to error responses returned to application.
@@ -685,7 +660,7 @@
  *     unsigned int
  *
  * @par Values
- *    - Value of @i delta-seconds in @RetryAfter header, from 0 to 86400
+ *    - Value of delta-seconds in @RetryAfter header
  *
  * @par Default Value
  *    - 0 (no Retry-After is included)

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/sofia-sip/nta_tag.h	Fri Jan 25 12:42:24 2008
@@ -203,12 +203,6 @@
 NTA_DLL extern tag_typedef_t ntatag_timer_c_ref;
 #define NTATAG_TIMER_C_REF(x) ntatag_timer_c_ref, tag_uint_vr(&(x))
 
-NTA_DLL extern tag_typedef_t ntatag_graylist;
-#define NTATAG_GRAYLIST(x)  ntatag_graylist, tag_uint_v((x))
-
-NTA_DLL extern tag_typedef_t ntatag_graylist_ref;
-#define NTATAG_GRAYLIST_REF(x) ntatag_graylist_ref, tag_uint_vr(&(x))
-
 NTA_DLL extern tag_typedef_t ntatag_blacklist;
 #define NTATAG_BLACKLIST(x)  ntatag_blacklist, tag_uint_v((x))
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c	Fri Jan 25 12:42:24 2008
@@ -883,7 +883,8 @@
  * decide whether to gracefully terminate or not, the
  * @a *return_graceful_terminate_usage is left unmodified.
  *
- * @RFC 5057
+ * @sa 
+ * http://www.ietf.org/internet-drafts/draft-ietf-sipping-dialogusage-02.txt
  */
 int sip_response_terminates_dialog(int response_code,
 				   sip_method_t method,
@@ -1059,6 +1060,8 @@
       usage in an existing dialog, no new usage is created and existing
       usages are unaffected.
     */
+    *return_graceful_terminate_usage = 0;
+    return 0;
 
   case 423: /** @par 423 Interval Too Brief 
 
@@ -1067,6 +1070,8 @@
       subscribe usage is not destroyed (or otherwise affected).  No
       other usages of the dialog are affected.
     */
+    *return_graceful_terminate_usage = 0;
+    return sip_method_subscribe == method ? terminate_usage : no_effect;
 
   case 428: /** @par 428 Use Identity Header
 
@@ -1074,6 +1079,8 @@
       the usage.  The usage is not affected.  The dialog is only
       affected by a change in its local @CSeq.  No other usages of the
       dialog are affected. */
+    *return_graceful_terminate_usage = 0;
+    return 0;
 
   case 429: /** @par 429 Provide Referrer Identity 
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c	Fri Jan 25 12:42:24 2008
@@ -70,6 +70,10 @@
 /* ======================================================================== */
 
 /* Internal prototypes */
+void soa_set_activity(soa_session_t *ss,
+		      sdp_media_t const *,
+		      int remote);
+
 su_inline int soa_media_is_ready(soa_session_t const *ss);
 
 enum soa_sdp_kind { 
@@ -1167,7 +1171,7 @@
   if (!new_version)
     return 0;
     
-  soa_set_activity(ss, sdp->sdp_media, soa_activity_remote);
+  soa_set_activity(ss, sdp->sdp_media, 1);
 
   ss->ss_remote_version++;
   
@@ -1450,7 +1454,7 @@
   if (!sdp)
     return -1;
 
-  soa_set_activity(ss, sdp->sdp_media, soa_activity_local); /* Wanted activity */
+  soa_set_activity(ss, sdp->sdp_media, 0);
 
   ss->ss_offer_sent = 1;
   ss->ss_answer_recv = 0;
@@ -1538,7 +1542,8 @@
     su_free(ss->ss_home, ss->ss_rsession);
   ss->ss_rsession = rsession;
 
-  soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
+  soa_set_activity(ss, l_sdp->sdp_media, 0);
+  soa_set_activity(ss, r_sdp->sdp_media, 1);
 
   ss->ss_offer_recv = 1;
   ss->ss_answer_sent = 1;
@@ -1619,7 +1624,8 @@
     su_free(ss->ss_home, ss->ss_rsession);
   ss->ss_rsession = rsession;
 
-  soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
+  soa_set_activity(ss, l_sdp->sdp_media, 0);
+  soa_set_activity(ss, r_sdp->sdp_media, 1);
 
   ss->ss_answer_recv = 1;
   ss->ss_complete = 1;
@@ -1686,7 +1692,7 @@
   if (!l_sdp)
     return -1;
 
-  soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
+  soa_set_activity(ss, l_sdp->sdp_media, 0);
 
   ss->ss_offer_sent = 0;
 
@@ -1777,7 +1783,8 @@
   ss->ss_oa_rounds = 0;
 
   soa_description_free(ss, ss->ss_remote);
-  soa_set_activity(ss, NULL, soa_activity_session);
+  soa_set_activity(ss, NULL, 0);
+  soa_set_activity(ss, NULL, 1);
 }
 
 /** Return true if the SDP Offer/Answer negotation is complete.
@@ -1882,75 +1889,56 @@
 
 void soa_set_activity(soa_session_t *ss,
 		      sdp_media_t const *m,
-		      enum soa_activity activity)
+		      int remote)
 {
   struct soa_media_activity *ma;
   sdp_connection_t const *c;
-  int mode, swap;
-  int l_audio = SOA_ACTIVE_DISABLED, r_audio = SOA_ACTIVE_DISABLED;
-  int l_video = SOA_ACTIVE_DISABLED, r_video = SOA_ACTIVE_DISABLED;
-  int l_chat = SOA_ACTIVE_DISABLED,  r_chat = SOA_ACTIVE_DISABLED;
-  int l_image = SOA_ACTIVE_DISABLED, r_image = SOA_ACTIVE_DISABLED;
+  int mode;
+  int ma_audio = SOA_ACTIVE_DISABLED;
+  int ma_video = SOA_ACTIVE_DISABLED;
+  int ma_chat = SOA_ACTIVE_DISABLED;
+  int ma_image = SOA_ACTIVE_DISABLED;
+  int *p;
+
+  remote = !!remote;
 
-  int *l, *r;
+  ma = remote ? ss->ss_remote_activity : ss->ss_local_activity;
 
   for (; m; m = m->m_next) {
     if (m->m_type == sdp_media_audio)
-      l = &l_audio, r = &r_audio;
+      p = &ma_audio;
     else if (m->m_type == sdp_media_video)
-      l = &l_video, r = &r_video;
+      p = &ma_video;
     else if (m->m_type == sdp_media_image)
-      l = &l_image, r = &r_image;
+      p = &ma_image;
     else if (strcasecmp(m->m_type_name, "message") == 0)
-      l = &l_chat, r = &r_chat;
+      p = &ma_chat;
     else
       continue;
 
     if (m->m_rejected) {
-      if (*l < 0) *l = SOA_ACTIVE_REJECTED;
-      if (*r < 0) *r = SOA_ACTIVE_REJECTED;
+      if (*p < 0)
+	*p = SOA_ACTIVE_REJECTED;
       continue;
     }
 
-    mode = m->m_mode, swap = ((mode << 1) & 2) | ((mode >> 1) & 1);
+    mode = m->m_mode;
 
     c = sdp_media_connections((sdp_media_t *)m);
 
-    switch (activity) {
-    case soa_activity_local:
-      *l &= SOA_ACTIVE_SENDRECV;
-      *l |= c && c->c_mcast ? swap : mode;
-      break;
-    case soa_activity_remote:
-      *r &= SOA_ACTIVE_SENDRECV;
-      *r = c && c->c_mcast ? mode : swap;
-      break;
-    case soa_activity_session:
-      *l &= SOA_ACTIVE_SENDRECV;
-      *l |= c && c->c_mcast ? swap : mode;
-      *r &= SOA_ACTIVE_SENDRECV;
-      *r = c && c->c_mcast ? swap : mode;
-      break;
-    }
-  }
+    if (remote != (c && c->c_mcast))
+      mode = ((mode << 1) & 2) | ((mode >> 1) & 1);
 
-  if (activity == soa_activity_local ||
-      activity == soa_activity_session) {
-    ma = ss->ss_local_activity;
-    ma->ma_audio = l_audio;
-    ma->ma_video = l_video;
-    ma->ma_image = l_image;
-    ma->ma_chat = l_chat;
-  }
-
-  if (activity == soa_activity_remote ||
-      activity == soa_activity_session) {
-    ma = ss->ss_remote_activity;
-    ma->ma_audio = r_audio;
-    ma->ma_video = r_video;
-    ma->ma_image = r_image;
-    ma->ma_chat = r_chat;
+    if (*p < 0)
+      *p = mode;
+    else
+      *p |= mode;
   }
+
+  ma->ma_audio = ma_audio;
+  ma->ma_video = ma_video;
+  ma->ma_image = ma_image;
+  ma->ma_chat = ma_chat;
 }
 
 /* ----------------------------------------------------------------------*/

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/sofia-sip/soa_session.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/sofia-sip/soa_session.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/sofia-sip/soa_session.h	Fri Jan 25 12:42:24 2008
@@ -238,11 +238,8 @@
 SOFIAPUBFUN int soa_set_status(soa_session_t *ss,
 			       int status, char const *phrase);
 
-enum soa_activity { soa_activity_local, soa_activity_remote, soa_activity_session };
-
 SOFIAPUBFUN void soa_set_activity(soa_session_t *ss, 
-				  sdp_media_t const *m, 
-				  enum soa_activity activity);
+				  sdp_media_t const *m, int remote);
 
 SOFIAPUBFUN int soa_description_set(soa_session_t *ss, 
 				    struct soa_description *ssd,

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/test_soa.c	Fri Jan 25 12:42:24 2008
@@ -1376,7 +1376,7 @@
 {
   BEGIN();
 
-#if 0				/* This has never been implemented */
+#if 0
   int n;
   
   char const *caps = NONE, *offer = NONE, *answer = NONE;

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres.h	Fri Jan 25 12:42:24 2008
@@ -218,13 +218,21 @@
                                              uint16_t type,
 					     struct sockaddr const *addr);
 
-/**Modify the priority of the specified SRV records. */
+/**Modify the priority of the specified SRV records.
+ * 
+ * @param res       pointer to resolver object
+ * @param service   domain name of the SRV records to search in cache
+ * @param target    target to lower the prio
+ * @param port      port number to lower the prio
+ * @param newprio   new priority value
+ *
+ * @return Number of modified records on success, -1 otherwise
+ */
 SRESPUBFUN
 int sres_set_cached_srv_priority(sres_resolver_t *res,
 				 char const *domain,
 				 char const *target,
 				 uint16_t port,
-				 uint32_t newttl,
 				 uint16_t newprio);
 
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_cache.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_cache.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_cache.h	Fri Jan 25 12:42:24 2008
@@ -107,8 +107,7 @@
 					   char const *domain,
 					   char const *target,
 					   uint16_t port,
-					   uint32_t newttl,
-					   uint16_t newprio);
+					   uint16_t prio);
 
 #ifdef __cplusplus
 }

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	Fri Jan 25 12:42:24 2008
@@ -1358,7 +1358,6 @@
  * @param target   SRV target of the SRV record(s) to modify
  * @param port     port number of SRV record(s) to modify 
  *                 (in host byte order) 
- * @param ttl      new ttl for SRV records of the domain
  * @param priority new priority value (0=highest, 65535=lowest)
  *
  * @sa sres_cache_set_srv_priority()
@@ -1369,7 +1368,6 @@
 				 char const *domain,
 				 char const *target,
 				 uint16_t port,
-				 uint32_t ttl,
 				 uint16_t priority)
 {
   char rooted_domain[SRES_MAXDNAME];
@@ -1383,8 +1381,7 @@
     return -1;
 
   return sres_cache_set_srv_priority(res->res_cache, 
-				     domain, target, port, 
-				     ttl, priority);
+				     domain, target, port, priority);
 }
 
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_cache.c	Fri Jan 25 12:42:24 2008
@@ -483,7 +483,6 @@
  * @param target   SRV target of the SRV record(s) to modify
  * @param port     port number of SRV record(s) to modify 
  *                 (in host byte order) 
- * @param ttl      new ttl
  * @param priority new priority value (0=highest, 65535=lowest)
  *
  * @sa sres_set_cached_srv_priority()
@@ -494,14 +493,12 @@
 				char const *domain,
 				char const *target,
 				uint16_t port,
-				uint32_t ttl,
 				uint16_t priority)
 {
   int ret = 0;
   unsigned hash;
   sres_rr_hash_entry_t **iter;
-  time_t expires;
-  
+
   if (cache == NULL || domain == NULL || target == NULL)
     return -1;
 
@@ -510,9 +507,6 @@
   if (!LOCK(cache))
     return -1;
 
-  time(&expires);
-  expires += ttl;
-
   for (iter = sres_htable_hash(cache->cache_hash, hash);
        iter && *iter;
        iter = sres_htable_next(cache->cache_hash, iter)) {
@@ -520,17 +514,13 @@
     
     if (rr && rr->sr_name &&
 	sres_type_srv == rr->sr_type &&
+	(port == 0 || rr->sr_srv->srv_port == port) &&
+	rr->sr_srv->srv_target &&
+	strcasecmp(rr->sr_srv->srv_target, target) == 0 &&
 	strcasecmp(rr->sr_name, domain) == 0) {
-
-      (*iter)->rr_expires = expires;
-      
-      if ((port == 0 || rr->sr_srv->srv_port == port) &&
-	  rr->sr_srv->srv_target &&
-	  strcasecmp(rr->sr_srv->srv_target, target) == 0) {
-	/* record found --> change priority of server */
-	rr->sr_srv->srv_priority = priority;
-	ret++;
-      }
+      /* record found --> change priority of server */
+      rr->sr_srv->srv_priority = priority;
+      ret++;
     }
   }
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_addrinfo.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_addrinfo.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_addrinfo.h	Fri Jan 25 12:42:24 2008
@@ -126,7 +126,7 @@
 #define	AI_MASK		(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
 #endif
 
-/** @RFC1576 address info structure. */
+/** RFC 1576 address info structure. */
 typedef struct addrinfo su_addrinfo_t;
 
 /** Translate address and service. */

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_addrinfo.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_addrinfo.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_addrinfo.c	Fri Jan 25 12:42:24 2008
@@ -893,7 +893,6 @@
 {
   int retval;
   su_addrinfo_t *ai;
-  char const *realservice = service;
 
   if (!service || service[0] == '\0')
     service = "0";
@@ -933,9 +932,6 @@
 
   retval = getaddrinfo(node, service, hints, res);
 
-  if (service != realservice && retval == EAI_SERVICE)
-    retval = getaddrinfo(node, realservice, hints, res);
-
   if (retval == 0) {
     for (ai = *res; ai; ai = ai->ai_next) {
       if (ai->ai_protocol)



More information about the Freeswitch-svn mailing list