Kaynağa Gözat

bugfix: Call-ID generation repaired, from_tags introduced,
stats allocation bug (process_cnt-related) fixed

Jiri Kuthan 23 yıl önce
ebeveyn
işleme
8280274342

+ 2 - 2
config.h

@@ -58,8 +58,8 @@
 #define MY_VIA "Via: SIP/2.0/UDP "
 #define MY_VIA_LEN 17
 
-#define CONTENT_LEN "Content-Length: 0"
-#define CONTENT_LEN_LEN 17
+#define CONTENT_LENGTH "Content-Length: "
+#define CONTENT_LENGTH_LEN (sizeof(CONTENT_LENGTH)-1)
 
 #define USER_AGENT "User-Agent: Sip EXpress router"\
 		"(" VERSION " (" ARCH "/" OS"))"

+ 9 - 6
modules/tm/h_table.c

@@ -25,7 +25,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-
+#include <stdlib.h>
 #include "../../mem/shm_mem.h"
 #include "../../hash_func.h"
 #include "h_table.h"
@@ -136,13 +136,13 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 {
 	struct cell* new_cell;
 	unsigned int i;
-	unsigned int rand;
+	unsigned int myrand;
 	int size;
 	char *c;
 	struct ua_client *uac;
 
 	/* avoid 'unitialized var use' warning */
-	rand=0;
+	myrand=0;
 
 	/* allocs a new cell */
 	new_cell = (struct cell*)shm_malloc( sizeof( struct cell ) );
@@ -192,8 +192,11 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 	if (p_msg) {
 		new_cell->hash_index = p_msg->hash_index;
 	} else {
-		rand = random();
-		new_cell->hash_index = rand % TABLE_ENTRIES ;
+		/* note: unsatisfactory if 
+		   RAND_MAX < TABLE_ENTRIES
+		*/
+		myrand = rand();
+		new_cell->hash_index = myrand % TABLE_ENTRIES ;
 	}
 	new_cell->wait_tl.payload = new_cell;
 	new_cell->dele_tl.payload = new_cell;
@@ -219,7 +222,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 			c=new_cell->md5;
 			size=MD5_LEN;
 			memset(c, '0', size );
-			int2reverse_hex( &c, &size, rand );
+			int2reverse_hex( &c, &size, myrand );
 		}
 	}
 

+ 46 - 19
modules/tm/t_msgbuilder.c

@@ -109,7 +109,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 		*len += USER_AGENT_LEN + CRLF_LEN;
 	}
 	/* Content Length, EoM */
-	*len+=CONTENT_LEN_LEN + CRLF_LEN + CRLF_LEN;
+	*len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN + CRLF_LEN;
 
 	cancel_buf=shm_malloc( *len+1 );
 	if (!cancel_buf)
@@ -153,8 +153,8 @@ char *build_local(struct cell *Trans,unsigned int branch,
 		append_mem_block(p,USER_AGENT CRLF, USER_AGENT_LEN+CRLF_LEN );
 	}
 	/* Content Length, EoM */
-	append_mem_block(p, CONTENT_LEN CRLF CRLF ,
-		CONTENT_LEN_LEN + CRLF_LEN + CRLF_LEN);
+	append_mem_block(p, CONTENT_LENGTH "0" CRLF CRLF ,
+		CONTENT_LENGTH_LEN+1 + CRLF_LEN + CRLF_LEN);
 	*p=0;
 
 	pkg_free(via);
@@ -168,16 +168,21 @@ error:
 
 
 char *build_uac_request(  str msg_type, str dst, str from,
-    	str headers, str body, int branch, 
-		struct cell *t, unsigned int *len)
+	str fromtag, int cseq, str callid, str headers, 
+	str body, int branch, 
+	struct cell *t, unsigned int *len)
 {
 	char *via;
 	unsigned int via_len;
 	char content_len[10];
 	int content_len_len;
+	char cseq_str[10];
+	int cseq_str_len;
 	char *buf;
 	char *w;
+#ifdef _OBSOLETED
 	int dummy;
+#endif
 
 	char branch_buf[MAX_BRANCH_PARAM_LEN];
 	int branch_len;
@@ -187,6 +192,23 @@ char *build_uac_request(  str msg_type, str dst, str from,
 
 	buf=0;
 
+	/* print content length */
+	content_len_len=snprintf(
+		content_len, sizeof(content_len), 
+		"%d", body.len );
+	if (content_len_len==-1) {
+		LOG(L_ERR, "ERROR: uac: content_len too big\n");
+		return 0;
+	}
+	/* print cseq */
+	cseq_str_len=snprintf( 
+		cseq_str, sizeof(cseq_str),
+		"%d", cseq );
+	if (cseq_str_len==-1) {
+		LOG(L_ERR, "ERROR: uac: cseq too big\n");
+		return 0;
+	}
+
 	if (from.len) {
 		from_len=from.len;
 		from_str=from.s;
@@ -210,9 +232,6 @@ char *build_uac_request(  str msg_type, str dst, str from,
 		goto error;
 	}
 	*len+=via_len;
-	/* content length */
-	content_len_len=snprintf(
-		content_len, sizeof(content_len), "%d", body.len );
 	/* header names and separators */
 	*len+=
 		+CSEQ_LEN+CRLF_LEN
@@ -223,10 +242,10 @@ char *build_uac_request(  str msg_type, str dst, str from,
 		+FROM_LEN+CRLF_LEN
 		+CRLF_LEN; /* EoM */
 	/* header field value and body length */
-	*len+= msg_type.len+1+UAC_CSEQNR_LEN /* CSeq: method, delimitor, number  */
+	*len+= msg_type.len+1+cseq_str_len /* CSeq: method, delimitor, number  */
 		+ dst.len /* To */
-		+ RAND_DIGITS+1+MAX_PID_LEN+1+MAX_SEQ_LEN /* call-id */
-		+ from_len+FROMTAG_LEN+MD5_LEN+
+		+ callid.len /* call-id */
+		+ from_len+FROMTAG_LEN+fromtag.len
 		+ content_len_len
 		+ headers.len
 		+ body.len;
@@ -243,17 +262,22 @@ char *build_uac_request(  str msg_type, str dst, str from,
 	memapp( w, dst.s, dst.len ); 
 	memapp( w, " " SIP_VERSION CRLF, 1+SIP_VERSION_LEN+CRLF_LEN );
 	memapp( w, via, via_len );
-	t->cseq_n.s=w; t->cseq_n.len=CSEQ_LEN+UAC_CSEQNR_LEN;
-	memapp( w, CSEQ UAC_CSEQNR " ", CSEQ_LEN + UAC_CSEQNR_LEN+ 1 );
+
+	/* CSeq */
+	t->cseq_n.s=w; 
+	t->cseq_n.len=CSEQ_LEN+cseq_str_len;
+	memapp(w, CSEQ, CSEQ_LEN );
+	memapp(w, cseq_str, cseq_str_len );
+	memapp(w, " ", 1 );
+
 	memapp( w, msg_type.s, msg_type.len );
 	t->to.s=w+CRLF_LEN; t->to.len=TO_LEN+dst.len;
 	memapp( w, CRLF TO, CRLF_LEN + TO_LEN  );
 	memapp( w, dst.s, dst.len );
-	t->callid.s=w+CRLF_LEN; t->callid.len=CALLID_LEN+RAND_DIGITS+1+
-		MAX_PID_LEN+1+MAX_SEQ_LEN;
+	t->callid.s=w+CRLF_LEN; t->callid.len=callid.len;
 	memapp( w, CRLF CALLID, CRLF_LEN + CALLID_LEN  );
-	memapp( w, call_id, RAND_DIGITS+1+MAX_PID_LEN+1+MAX_SEQ_LEN );
-	memapp( w, CRLF CONTENT_LEN, CRLF_LEN + CONTENT_LEN_LEN);
+	memapp( w, callid.s, callid.len );
+	memapp( w, CRLF CONTENT_LENGTH, CRLF_LEN + CONTENT_LENGTH_LEN);
 	memapp( w, content_len, content_len_len );
 	if (server_signature) {
 		memapp( w, CRLF USER_AGENT CRLF FROM, 
@@ -262,10 +286,11 @@ char *build_uac_request(  str msg_type, str dst, str from,
 		memapp( w, CRLF  FROM, 
 			CRLF_LEN+FROM_LEN);
 	}
-	t->from.s=w-FROM_LEN; t->from.len=FROM_LEN+from_len+FROMTAG_LEN+MD5_LEN;
+	t->from.s=w-FROM_LEN; 
+	t->from.len=FROM_LEN+from_len+FROMTAG_LEN+fromtag.len;
 	memapp( w, from_str, from_len );
 	memapp( w, FROMTAG, FROMTAG_LEN );
-	memapp( w, from_tag, MD5_LEN );
+	memapp( w, fromtag.s, fromtag.len );
 	memapp( w, CRLF, CRLF_LEN );
 
 	memapp( w, headers.s, headers.len );
@@ -274,9 +299,11 @@ char *build_uac_request(  str msg_type, str dst, str from,
 	if ( body.s ) {
 		memapp( w, body.s, body.len );
 	}
+#ifdef _OBSOLETED
 	/* ugly HACK -- debugging has shown len shorter by one */
 	dummy=*len+1;
 	*len=dummy;
+#endif
 #	ifdef EXTRA_DEBUG
 	if (w-buf != *len ) abort();
 #	endif

+ 11 - 10
modules/tm/t_msgbuilder.h

@@ -31,23 +31,23 @@
 #define _MSGBUILDER_H
 
 #define CSEQ "CSeq: "
-#define CSEQ_LEN 6
+#define CSEQ_LEN (sizeof(CSEQ)-1)
 #define TO "To: "
-#define TO_LEN 4
+#define TO_LEN (sizeof(TO)-1)
 #define CALLID "Call-ID: "
-#define CALLID_LEN 9
-#define CONTENT_LENGTH "Content-Length: "
-#define CONTENT_LENGTH_LEN 16
+#define CALLID_LEN (sizeof(CALLID)-1)
 #define FROM "From: "
-#define FROM_LEN 6
+#define FROM_LEN (sizeof(FROM)-1)
 #define FROMTAG ";tag="
-#define FROMTAG_LEN 5
+#define FROMTAG_LEN (sizeof(FROMTAG)-1)
 
+#ifdef _OBSOLETED
 #define UAC_CSEQNR "1"
 #define UAC_CSEQNR_LEN 1
+#define CONTENT_LENGTH "Content-Length: "
+#define CONTENT_LENGTH_LEN (sizeof(CONTENT_LENGTH)-1)
+#endif
 
-#define UAC_CSEQNR "1"
-#define UAC_CSEQNR_LEN 1
 
 /* convenience macros */
 #define memapp(_d,_s,_len) \
@@ -74,7 +74,8 @@ char *build_local(struct cell *Trans, unsigned int branch,
 	unsigned int *len, char *method, int method_len, str *to);
 
 char *build_uac_request(  str msg_type, str dst, str from,
-	str headers, str body, int branch,
+	str fromtag, int cseq, str callid, str headers, 
+	str body, int branch,
 	struct cell *t, unsigned int *len);
 
 int t_calc_branch(struct cell *t,

+ 1 - 1
modules/tm/t_stats.c

@@ -114,7 +114,7 @@ int init_tm_stats(void)
 	}
 	memset(tm_stats, 0, sizeof(struct t_stats) );
 
-	size=sizeof(int)*process_count();
+	size=sizeof(stat_counter)*process_count();
 	tm_stats->s_waiting=shm_malloc(size);
 	if (tm_stats->s_waiting==0) {
 		LOG(L_ERR, "ERROR: init_stats: no mem for stats\n");

+ 7 - 6
modules/tm/t_stats.h

@@ -35,19 +35,20 @@
 
 
 extern struct t_stats *tm_stats;
+typedef unsigned long stat_counter;
 
 struct t_stats {
 	/* number of transactions in wait state */
-	unsigned long *s_waiting;
+	stat_counter *s_waiting;
 	/* number of server transactions */
-	unsigned long *s_transactions;
+	stat_counter *s_transactions;
 	/* number of UAC transactions (part of transactions) */
-	unsigned long *s_client_transactions;
+	stat_counter *s_client_transactions;
 	/* number of transactions which completed with this status */
-	unsigned long completed_3xx, completed_4xx, completed_5xx, 
+	stat_counter completed_3xx, completed_4xx, completed_5xx, 
 		completed_6xx, completed_2xx;
-	unsigned long replied_localy;
-	unsigned long deleted;
+	stat_counter replied_localy;
+	stat_counter deleted;
 };
 
 inline void static t_stats_new(int local)

+ 36 - 16
modules/tm/tm.c

@@ -281,6 +281,8 @@ static int mod_init(void)
 			MAX_BRANCHES );
 		return -1;
 	}
+
+
 	if (register_fifo_cmd(fifo_uac, "t_uac", 0)<0) {
 		LOG(L_CRIT, "cannot register fifo uac\n");
 		return -1;
@@ -293,39 +295,57 @@ static int mod_init(void)
 		LOG(L_CRIT, "cannot register hash\n");
 		return -1;
 	}
-	
-	if (init_tm_stats()<0) {
-		LOG(L_CRIT, "ERROR: mod_init: failed to init stats\n");
-		return -1;
-	}
 
-	/* building the hash table*/
 	if (!init_hash_table()) {
 		LOG(L_ERR, "ERROR: mod_init: initializing hash_table failed\n");
 		return -1;
 	}
 
+
+	/* init static hidden values */
+	init_t();
+
 	if (!tm_init_timers()) {
 		LOG(L_ERR, "ERROR: mod_init: timer init failed\n");
 		return -1;
 	}
+	/* register the timer function */
+	register_timer( timer_routine , 0 /* empty attr */, 1 );
+
+	/* init_tm_stats calls process_count, which should
+	 * NOT be called from mod_init, because one does not
+	 * now, if a timer is used and thus how many processes
+	 * will be started; however we started already our
+	 * timers, so we know and process_count should not
+	 * change any more
+	 */	
+	if (init_tm_stats()<0) {
+		LOG(L_CRIT, "ERROR: mod_init: failed to init stats\n");
+		return -1;
+	}
 
-	/* init static hidden values */
-	init_t();
+	/* building the hash table*/
 
-	uac_init();
-	register_tmcb( TMCB_ON_NEGATIVE, on_negative_reply, 0 /* empty param */);
-    /* register the timer function */
-    register_timer( timer_routine , 0 /* empty attr */, 1 );
-    /* register post-script clean-up function */
-    register_script_cb( w_t_unref, POST_SCRIPT_CB, 0 /* empty param */ );
-    register_script_cb( script_init, PRE_SCRIPT_CB , 0 /* empty param */ );
+	if (uac_init()==-1) {
+		LOG(L_ERR, "ERROR: mod_init: uac_init failed\n");
+		return -1;
+	}
+	register_tmcb( TMCB_ON_NEGATIVE, on_negative_reply, 
+			0 /* empty param */);
+	/* register post-script clean-up function */
+	register_script_cb( w_t_unref, POST_SCRIPT_CB, 
+			0 /* empty param */ );
+	register_script_cb( script_init, PRE_SCRIPT_CB , 
+			0 /* empty param */ );
 
 	return 0;
 }
 
 static int child_init(int rank) {
-	uac_child_init(rank);
+	if (uac_child_init(rank)==-1) {
+		LOG(L_ERR, "ERROR: child_init: uac_child_init error\n");
+		return -1;
+	}
 	return 1;
 }
 

+ 123 - 56
modules/tm/uac.c

@@ -41,6 +41,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <limits.h>
 #include "../../dprint.h"
 #include "../../ut.h"
 #include "../../hash_func.h"
@@ -48,6 +49,8 @@
 #include "../../mem/mem.h"
 #include "../../fifo_server.h"
 #include "../../error.h"
+#include "../../pt.h"
+#include "../../crc.h"
 #include "t_funcs.h"
 #include "config.h"
 #include "sip_msg.h"
@@ -55,77 +58,118 @@
 #include "t_msgbuilder.h"
 #include "uac.h"
 
-/* Call-ID has the following form: call_id_rand-pid-seq */
+/* Call-ID has the following form: <callid_nr>-<pid>@<ip>
+ * callid_nr is initialized as a random number and continually
+ * increases; -<pid>@<ip> is kept in callid_suffix
+ */
+
+#define CALLID_SUFFIX_LEN (1 /* - */ + 5 /* pid */ \
+	+ 42 /* embedded v4inv6 address can be looong '128.' */ \
+	+ 2 /* parenthessis [] */ + 1 /* ZT 0 */ \
+	+ 16 /* one never knows ;-) */ )
+#define CALLID_NR_LEN 20
+
+/* the character which separates random from constant part */
+#define CID_SEP	'-'
+
+/* length of FROM tags */
+#define FROM_TAG_LEN (MD5_LEN +1 /* - */ + CRC16_LEN)
 
-char call_id[RAND_DIGITS+1+MAX_PID_LEN+1+MAX_SEQ_LEN+1];
-static unsigned long callid_seq;
+static unsigned long callid_nr;
+static char *callid_suffix;
+static int callid_suffix_len;
+static int rand_len;	/* number of chars to display max rand */
+static char callid[CALLID_NR_LEN+CALLID_SUFFIX_LEN];
 
 char *uac_from="\"UAC Account\" <sip:[email protected]:9>";
 
-char from_tag[ MD5_LEN +1];
+static char from_tag[ FROM_TAG_LEN+1 ];
 
-void uac_init() {
-	unsigned long init_nr;
-	char *c;
-	int len;
 
+
+int uac_init() {
+
+	int i; 
+	unsigned long uli;
+	int rand_len_bits;
+	int rand_cnt; /* number of rands() to be long enough */
+	int rand_bits; /* length of rands() in bits */
 	str src[3];
 
-	init_nr=random() % (1<<(RAND_DIGITS*4));
-	c=call_id;
-	len=RAND_DIGITS;
-	int2reverse_hex( &c, &len, init_nr );
-	while (len) { *c='z'; len--; c++; }
-	*c='-';
+	if (RAND_MAX<TABLE_ENTRIES) {
+		LOG(L_WARN, "Warning: uac does not spread "
+			"accross the whole hash table\n");
+	}
+
+	/* calculate the initial call-id */
+
+	/* how many bits and chars do we need to display the 
+	 * whole ULONG number */
+	for (rand_len_bits=0,uli=ULONG_MAX;uli;
+			uli>>=1, rand_len_bits++ );
+	rand_len=rand_len_bits/4;
+	if (rand_len>CALLID_NR_LEN) {
+		LOG(L_ERR, "ERROR: Too small callid buffer\n");
+		return -1;
+	}
+
+	/* how long are the rand()s ? */
+	for (rand_bits=0,i=RAND_MAX;i;i>>=1,rand_bits++);
+	/* how many rands() fit in the ULONG ? */
+	rand_cnt=rand_len_bits / rand_bits;
+
+	/* now fill in the callid with as many random
+	 * numbers as you can + 1 */
+	callid_nr=rand(); /* this is the + 1 */
+	while(rand_cnt) {
+		rand_cnt--;
+		callid_nr<<=rand_bits;
+		callid_nr|=rand();
+	}
+	callid_suffix=callid+rand_len;
+	DBG("CALLID initialization: %lx (len=%d)\n", 
+			callid_nr, rand_len );
+	DBG("CALLID0=%0*lx\n", rand_len, callid_nr );
+
+
+	/* calculate the initial From tag */
 
 	src[0].s="Long live SER server";
 	src[0].len=strlen(src[0].s);
-	src[1].s=sock_info[0].address_str.s;
+	src[1].s=sock_info[bind_idx].address_str.s;
 	src[1].len=strlen(src[1].s);
-	src[2].s=sock_info[0].port_no_str.s;
+	src[2].s=sock_info[bind_idx].port_no_str.s;
 	src[2].len=strlen(src[2].s);
 
 	MDStringArray( from_tag, src, 3 );
-	from_tag[MD5_LEN]=0;
-}
-
-
-void uac_child_init( int rank ) {
-	int pid_nr;
-	char *c;
-	int len;
-
-	pid_nr=getpid() % (1<<(MAX_PID_LEN*4));
-	c=call_id+RAND_DIGITS+1;
-	len=MAX_PID_LEN;
-	int2reverse_hex( &c, &len, pid_nr );
-	while (len) { *c='z'; len--; c++; }
-	*c='-';
-
-	callid_seq=random() % TABLE_ENTRIES;
+	from_tag[MD5_LEN]=CID_SEP;
 
+	return 1;
 }
 
-void generate_callid() {
-	char *c;
-	int len;
 
-	/* HACK: not long enough */
-	callid_seq = (callid_seq+1) % TABLE_ENTRIES;
-	c=call_id+RAND_DIGITS+1+MAX_PID_LEN+1;
-	len=MAX_SEQ_LEN;
-	int2reverse_hex( &c, &len, callid_seq );
-	while (len) { *c='z'; len--; c++; }
+int uac_child_init( int rank ) 
+{
+	callid_suffix_len=snprintf(callid_suffix,CALLID_SUFFIX_LEN,
+			"%c%d@%*s", CID_SEP, my_pid(), 
+			sock_info[bind_idx].address_str.len,
+			sock_info[bind_idx].address_str.s );
+	if (callid_suffix_len==-1) {
+		LOG(L_ERR, "ERROR: uac_child_init: 
+			buffer too small\n");
+		return -1;
+	}
+	DBG("DEBUG: callid_suffix: %s\n", callid_suffix );
+	return 1;
 }
 
-
-
 int t_uac( str *msg_type, str *dst, 
 	str *headers, str *body, str *from, 
 	transaction_cb completion_cb, void *cbp, 
 	dlg_t dlg)
 {
 
+	int r;
 	struct cell *new_cell;
 	struct proxy_l *proxy;
 	int branch;
@@ -136,6 +180,11 @@ int t_uac( str *msg_type, str *dst,
 	struct socket_info* send_sock;
 	struct retr_buf *request;
 	str dummy_from;
+	str callid_s;
+	str fromtag;
+
+	/* make -Wall shut up */
+	ret=0;
 
 	proxy=uri2proxy( dst );
 	if (proxy==0) {
@@ -155,7 +204,20 @@ int t_uac( str *msg_type, str *dst,
 		ret=E_NO_SOCKET;
 		goto error00;
 	}
-	generate_callid();
+
+	/* update callid */
+	/* generate_callid(); */
+	callid_nr++;
+	r=snprintf(callid, rand_len+1, "%0*lx", rand_len, callid_nr );
+	if (r==-1) {
+		LOG(L_CRIT, "BUG: SORRY, callid calculation failed\n");
+		goto error00;
+	}
+	/* fix the ZT 0 */
+	callid[rand_len]=CID_SEP;
+	callid_s.s=callid;
+	callid_s.len=rand_len+callid_suffix_len;
+	DBG("DEBUG: NEW CALLID:%*s\n", callid_s.len, callid_s.s );
 
 	new_cell = build_cell( NULL ) ; 
 	if (!new_cell) {
@@ -183,17 +245,22 @@ int t_uac( str *msg_type, str *dst,
 	UNLOCK_HASH(new_cell->hash_index);
 
 	if (from) dummy_from=*from; else { dummy_from.s=0; dummy_from.len=0; }
-	buf=build_uac_request(  *msg_type, *dst, dummy_from, *headers, *body,
-							branch,
-							new_cell, /* t carries hash_index, label, md5,
-										uac[].send_sock and other pieces of
-										information needed to print a message*/
-							 &req_len );
-    if (!buf) {
-        ret=E_OUT_OF_MEM;
-        LOG(L_ERR, "ERROR: t_uac: short of req shmem\n");
-        goto error01;
-    }      
+	/* calculate from tag from callid */
+	crcitt_string_array(&from_tag[MD5_LEN+1], &callid_s, 1 );
+	fromtag.s=from_tag; fromtag.len=FROM_TAG_LEN;
+	buf=build_uac_request(  *msg_type, *dst, 
+			dummy_from, fromtag,
+			DEFAULT_CSEQ, callid_s, 
+			*headers, *body, branch,
+			new_cell, /* t carries hash_index, label, md5,
+				uac[].send_sock and other pieces of
+				information needed to print a message*/
+		&req_len );
+	if (!buf) {
+		ret=E_OUT_OF_MEM;
+		LOG(L_ERR, "ERROR: t_uac: short of req shmem\n");
+		goto error01;
+	}      
 	new_cell->method.s=buf;new_cell->method.len=msg_type->len;
 
 

+ 10 - 7
modules/tm/uac.h

@@ -34,23 +34,26 @@
 #include "config.h"
 #include "t_dlg.h"
 
+#ifdef _DEPRECATED
 /* number of random digits in beginning of a string --
    please multiples of 2 */
 #define RAND_DIGITS	6
-/* maximum size of pid in hex characters */
-#define MAX_PID_LEN	4
 /* maximum seq size in hex chars */
 #define MAX_SEQ_LEN (T_TABLE_POWER*2)
+/* maximum size of pid in hex characters */
+#define MAX_PID_LEN	4
+extern char call_id[RAND_DIGITS+1+MAX_PID_LEN+1+MAX_SEQ_LEN+1];
+void generate_callid();
+#endif
+
+#define DEFAULT_CSEQ	10
 
 extern char *uac_from;
 extern char *fifo;
 extern int fifo_mode;
-extern char call_id[RAND_DIGITS+1+MAX_PID_LEN+1+MAX_SEQ_LEN+1];
-extern char from_tag[ MD5_LEN +1];
 
-void uac_init();
-void uac_child_init( int rank );
-void generate_callid();
+int uac_init();
+int uac_child_init( int rank );
 
 typedef int (*tuac_f)(str *msg_type, str *dst, str *headers,str *body,
 	str *from, transaction_cb completion_cb, void *cbp,

+ 3 - 3
msg_translator.c

@@ -655,7 +655,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text,
 		/*server header*/
 		len += SERVER_HDR_LEN + CRLF_LEN;
 		/*content length header*/
-		len +=CONTENT_LEN_LEN + CRLF_LEN;
+		len +=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
 	}
 	if (sip_warning) {
 		warning = warning_builder(msg,&warning_len);
@@ -743,8 +743,8 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text,
 		memcpy( p, CRLF, CRLF_LEN );
 		p+=CRLF_LEN;
 		/* content length header*/
-		memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN );
-		p+=CONTENT_LEN_LEN;
+		memcpy( p, CONTENT_LENGTH "0" , CONTENT_LENGTH_LEN+1 );
+		p+=CONTENT_LENGTH_LEN+1;
 		memcpy( p, CRLF, CRLF_LEN );
 		p+=CRLF_LEN;
 	}