[Freeswitch-svn] [commit] r7824 - freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport

Freeswitch SVN mikej at freeswitch.org
Fri Mar 7 12:46:28 EST 2008


Author: mikej
Date: Fri Mar  7 12:46:28 2008
New Revision: 7824

Modified:
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c

Log:
Fri Mar  7 11:47:06 EST 2008  Pekka.Pessi at nokia.com
  * tport: allow using TPTAG_LOG() and TPTAG_DUMP() with tport_set_params().



Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport.c	Fri Mar  7 12:46:28 2008
@@ -532,7 +532,6 @@
   ta_start(ta, tag, value);
 
   tport_set_params(mr->mr_master, ta_tags(ta));
-  tport_open_log(mr, ta_args(ta));
 
 #if HAVE_SOFIA_STUN
   tport_init_stun_server(mr, ta_args(ta));
@@ -1233,12 +1232,12 @@
 		     tag_type_t tag, tag_value_t value, ...)
 {
   ta_list ta;
-  int n;
+  int n, m = 0;
   tport_params_t tpp[1], *tpp0;
   
   usize_t mtu;
   int connect, sdwn_error, reusable, stun_server, pong2ping;
-  
+
   if (self == NULL)
     return su_seterrno(EINVAL);
 
@@ -1272,10 +1271,13 @@
 	      TPTAG_TOS_REF(tpp->tpp_tos),
 	      TAG_END());
 
+  if (self == (tport_t *)self->tp_master)
+    m = tport_open_log(self->tp_master, ta_args(ta));
+
   ta_end(ta);
 
   if (n == 0)
-    return 0;
+    return m;
 
   if (tpp->tpp_idle > 0 && tpp->tpp_idle < 100)
     tpp->tpp_idle = 100;
@@ -1314,7 +1316,7 @@
   if (tport_is_secondary(self))
     tport_set_secondary_timer(self);
 
-  return n;
+  return n + m;
 }
 
 extern tport_vtable_t const tport_udp_vtable;
@@ -4260,6 +4262,7 @@
     return NULL;
   else if (tport_is_master(self))
     return ((tport_master_t *)self)->mr_primaries->pri_primary;
+
   else if (tport_is_primary(self))
     return ((tport_primary_t *)self)->pri_next->pri_primary;
   else

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_internal.h	Fri Mar  7 12:46:28 2008
@@ -283,9 +283,9 @@
 
   /**< Timer reclaiming unused connections and compartment */
   su_timer_t         *mr_timer;		
-  /** File to dump received and sent data */
+  /** FILE to dump received and sent data */
   FILE               *mr_dump_file;	
-
+  char               *mr_dump;	/**< Filename for dumping received/sent data */
   tport_primary_t    *mr_primaries;        /**< List of primary contacts */
 
   tport_params_t      mr_params[1];
@@ -453,7 +453,7 @@
 void tport_error_report(tport_t *self, int errcode, 
 			su_sockaddr_t const *addr);
 
-void tport_open_log(tport_master_t *mr, tagi_t *tags);
+int tport_open_log(tport_master_t *mr, tagi_t *tags);
 void tport_log_msg(tport_t *tp, msg_t *msg, char const *what, 
 		   char const *via, su_time_t now);
 void tport_dump_iovec(tport_t const *self, msg_t *msg, 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c	Fri Mar  7 12:46:28 2008
@@ -94,30 +94,43 @@
 
 
 /** Initialize logging. */
-void tport_open_log(tport_master_t *mr, tagi_t *tags)
+int tport_open_log(tport_master_t *mr, tagi_t *tags)
 {
-  char const *log = NULL;
-  int log_msg = 0;
-
-  tl_gets(tags, TPTAG_LOG_REF(log_msg), TAG_END());
+  int log_msg = mr->mr_log != 0;
+  char const *dump = NULL;
+  int n;
+  
+  n = tl_gets(tags,
+	      TPTAG_LOG_REF(log_msg), 
+	      TPTAG_DUMP_REF(dump),
+	      TAG_END());
 
   if (getenv("MSG_STREAM_LOG") != NULL || getenv("TPORT_LOG") != NULL)
     log_msg = 1;
-
   mr->mr_log = log_msg ? MSG_DO_EXTRACT_COPY : 0;
 
-  tl_gets(tags, TPTAG_DUMP_REF(log), TAG_END());
-
   if (getenv("MSG_DUMP"))
-    log = getenv("MSG_DUMP");
+    dump = getenv("MSG_DUMP");
   if (getenv("TPORT_DUMP"))
-    log = getenv("TPORT_DUMP");
+    dump = getenv("TPORT_DUMP");
 
-  if (log) {
+  if (dump) {
     time_t now;
+    char *dumpname;
 
-    if (strcmp(log, "-")) 
-      mr->mr_dump_file = fopen(log, "ab"); /* XXX */
+    if (mr->mr_dump && strcmp(dump, mr->mr_dump) == 0)
+      return n;
+    dumpname = su_strdup(mr->mr_home, dump);
+    if (dumpname == NULL)
+      return n;
+    su_free(mr->mr_home, mr->mr_dump);
+    mr->mr_dump = dumpname;
+
+    if (mr->mr_dump_file && mr->mr_dump_file != stdout)
+      fclose(mr->mr_dump_file), mr->mr_dump_file = NULL;
+
+    if (strcmp(dumpname, "-")) 
+      mr->mr_dump_file = fopen(dumpname, "ab"); /* XXX */
     else
       mr->mr_dump_file = stdout;
 
@@ -126,6 +139,8 @@
       fprintf(mr->mr_dump_file, "dump started at %s\n\n", ctime(&now));
     }
   }
+
+  return n;
 }
 
 /** Create log stamp */



More information about the Freeswitch-svn mailing list