Ver Fonte

(hopefuly successful) merger of Uli's CANCEL/FIFO (thanks!), jiri's hash
calculation for UAC transactions and current development branch

Jiri Kuthan há 21 anos atrás
pai
commit
c2ea965c63

+ 61 - 57
modules/tm/h_table.c

@@ -36,6 +36,7 @@
  * 2003-09-12  timer_link->tg will be set only if EXTRA_DEBUG (andrei)
  * 2003-12-04  global callbacks replaceed with callbacks per transaction;
  *             completion callback merged into them as LOCAL_COMPETED (bogdan)
+ * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 #include "defs.h"
@@ -158,17 +159,63 @@ void free_cell( struct cell* dead_cell )
 
 
 
-struct cell*  build_cell( struct sip_msg* p_msg )
+static inline void init_synonym_id( struct cell *t )
 {
-	struct cell* new_cell;
-	unsigned int i;
-	unsigned int myrand;
+	struct sip_msg *p_msg;
 	int size;
 	char *c;
+	unsigned int myrand;
+
+	if (!syn_branch) {
+		p_msg=t->uas.request;
+		if (p_msg) {
+			/* char value of a proxied transaction is
+			   calculated out of header-fileds forming
+			   transaction key
+			*/
+			char_msg_val( p_msg, t->md5 );
+		} else {
+			/* char value for a UAC transaction is created
+			   randomly -- UAC is an originating stateful element 
+			   which cannot be refreshed, so the value can be
+			   anything
+			*/
+			/* HACK : not long enough */
+			myrand=rand();
+			c=t->md5;
+			size=MD5_LEN;
+			memset(c, '0', size );
+			int2reverse_hex( &c, &size, myrand );
+		}
+	}
+}
+
+static void inline init_branches(struct cell *t)
+{
+	unsigned int i;
 	struct ua_client *uac;
 
-	/* avoid 'unitialized var use' warning */
-	myrand=0;
+	for(i=0;i<MAX_BRANCHES;i++)
+	{
+		uac=&t->uac[i];
+		uac->request.my_T = t;
+		uac->request.branch = i;
+#ifdef EXTRA_DEBUG
+		uac->request.fr_timer.tg = TG_FR;
+		uac->request.retr_timer.tg = TG_RT;
+#endif
+		uac->request.retr_timer.payload = 
+			uac->request.fr_timer.payload = 
+			&uac->request;
+		uac->local_cancel=uac->request;
+	}
+}
+
+
+struct cell*  build_cell( struct sip_msg* p_msg )
+{
+	struct cell* new_cell;
+
 
 	/* allocs a new cell */
 	new_cell = (struct cell*)shm_malloc( sizeof( struct cell ) );
@@ -200,34 +247,9 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 			goto error;
 	}
 
-	/* new_cell->uas.to_tag = &( get_to(new_cell->uas.request)->tag_value ); */
-	new_cell->uas.response.my_T = new_cell;
-
 	/* UAC */
-	for(i=0;i<MAX_BRANCHES;i++)
-	{
-		uac=&new_cell->uac[i];
-		uac->request.my_T = new_cell;
-		uac->request.branch = i;
-#ifdef EXTRA_DEBUG
-		uac->request.fr_timer.tg = TG_FR;
-		uac->request.retr_timer.tg = TG_RT;
-#endif
-		uac->request.retr_timer.payload = 
-		uac->request.fr_timer.payload = &uac->request;
-		uac->local_cancel=uac->request;
-	}
+	init_branches(new_cell);
 
-	/* global data for transaction */
-	if (p_msg) {
-		new_cell->hash_index = p_msg->hash_index;
-	} else {
-		/* 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;
 	new_cell->relaied_reply_branch   = -1;
@@ -237,27 +259,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
 	new_cell->dele_tl.tg=TG_DEL;
 #endif
 
-	if (!syn_branch) {
-		if (p_msg) {
-			/* char value of a proxied transaction is
-			   calculated out of header-fileds forming
-			   transaction key
-			*/
-			char_msg_val( p_msg, new_cell->md5 );
-		} else {
-			/* char value for a UAC transaction is created
-			   randomly -- UAC is an originating stateful element 
-			   which cannot be refreshed, so the value can be
-			   anything
-			*/
-			/* HACK : not long enough */
-			c=new_cell->md5;
-			size=MD5_LEN;
-			memset(c, '0', size );
-			int2reverse_hex( &c, &size, myrand );
-		}
-	}
-
+	init_synonym_id(new_cell);
 	init_cell_lock(  new_cell );
 	return new_cell;
 
@@ -268,7 +270,6 @@ error:
 
 
 
-
 /* Release all the data contained by the hash table. All the aux. structures
  *  as sems, lists, etc, are also released */
 void free_hash_table(  )
@@ -337,12 +338,14 @@ error0:
 
 /*  Takes an already created cell and links it into hash table on the
  *  appropiate entry. */
-void insert_into_hash_table_unsafe( struct cell * p_cell )
+void insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash )
 {
 	struct entry* p_entry;
 
+	p_cell->hash_index=_hash;
+
 	/* locates the apropiate entry */
-	p_entry = &tm_table->entrys[ p_cell->hash_index ];
+	p_entry = &tm_table->entrys[ _hash ];
 
 	p_cell->label = p_entry->next_label++;
 	if ( p_entry->last_cell )
@@ -361,13 +364,14 @@ void insert_into_hash_table_unsafe( struct cell * p_cell )
 
 
 
-
+#ifdef _OBSOLETED
 void insert_into_hash_table( struct cell * p_cell)
 {
 	LOCK_HASH(p_cell->hash_index);
 	insert_into_hash_table_unsafe(  p_cell );
 	UNLOCK_HASH(p_cell->hash_index);
 }
+#endif
 
 
 

+ 5 - 2
modules/tm/h_table.h

@@ -31,6 +31,7 @@
  * 2003-03-01  kr set through a function now (jiri)
  * 2003-12-04  callbacks per transaction added; completion callback
  *             merge into them as LOCAL_COMPETED (bogdan)
+ * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 #include "defs.h"
@@ -280,8 +281,10 @@ void   free_hash_table( );
 void   free_cell( struct cell* dead_cell );
 struct cell*  build_cell( struct sip_msg* p_msg );
 void   remove_from_hash_table_unsafe( struct cell * p_cell);
-void   insert_into_hash_table( struct cell * p_cell);
-void   insert_into_hash_table_unsafe( struct cell * p_cell );
+#ifdef OBSOLETED
+void   insert_into_hash_table( struct cell * p_cell, unsigned int _hash);
+#endif
+void   insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash );
 
 unsigned int transaction_count( void );
 

+ 64 - 0
modules/tm/t_cancel.c

@@ -29,9 +29,11 @@
  * ----------
  * 2003-04-14  checking if a reply sent before cancel is initiated
  *             moved here (jiri)
+ * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  *
  */
 
+#include <stdio.h> /* for FILE* in fifo_uac_cancel */
 
 #include "defs.h"
 
@@ -42,6 +44,8 @@
 #include "t_reply.h"
 #include "t_cancel.h"
 #include "t_msgbuilder.h"
+#include "t_lookup.h" /* for t_lookup_callid in fifo_uac_cancel */
+#include "../../fifo_server.h" /* for read_line() and fifo_reply() */
 
 
 /* determine which branches should be cancelled; do it
@@ -127,3 +131,63 @@ char *build_cancel(struct cell *Trans,unsigned int branch,
 		CANCEL, CANCEL_LEN, &Trans->to );
 }
 
+/* fifo command to cancel a pending call (Uli)
+  Syntax:
+
+  ":uac_cancel:[response file]\n
+  callid\n
+ cseq\n
+  \n"
+ */
+
+int fifo_uac_cancel( FILE* stream, char *response_file )
+{
+	struct cell *trans;
+
+	char cseq[128];
+	char callid[128];
+
+	str cseq_s;   /* cseq */
+	str callid_s; /* callid */
+
+	cseq_s.s=cseq;
+	callid_s.s=callid;
+
+	DBG("DEBUG: fifo_uac_cancel: ############### begin ##############\n");
+
+	/* first param callid read */
+	if (!read_line(callid_s.s, 128, stream, &callid_s.len)||callid_s.len==0) {
+		LOG(L_ERR, "ERROR: fifo_uac_cancel: callid expected\n");
+		fifo_reply(response_file, "400 fifo_uac_cancel: callid expected");
+		return -1;
+	}
+	callid_s.s[callid_s.len]='\0';
+	DBG("DEBUG: fifo_uac_cancel: callid=\"%.*s\"\n",callid_s.len, callid_s.s);
+
+	/* second param cseq read */
+	if (!read_line(cseq_s.s, 128, stream, &cseq_s.len)||cseq_s.len==0) {
+		LOG(L_ERR, "ERROR: fifo_uac_cancel: cseq expected\n");
+		fifo_reply(response_file, "400 fifo_uac_cancel: cseq expected");
+		return -1;
+	}
+	cseq_s.s[cseq_s.len]='\0';
+	DBG("DEBUG: fifo_uac_cancel: cseq=\"%.*s\"\n",cseq_s.len, cseq_s.s);
+
+	if( t_lookup_callid(&trans, callid_s, cseq_s) < 0 ) {
+		LOG(L_ERR,"ERROR: fifo_uac_cancel: lookup failed\n");
+		fifo_reply(response_file, "481 fifo_uac_cancel: no such transaction");
+		return -1;
+	}
+	/* tell tm to cancel the call */
+	DBG("DEBUG: fifo_uac_cancel: now calling cancel_uacs\n");
+	(*cancel_uacs)(trans,~0);
+
+	/* t_lookup_callid REF`d the transaction for us, we must UNREF here! */
+	UNREF(trans);
+
+	fifo_reply(response_file, "200 fifo_uac_cancel succeeded\n");
+	DBG("DEBUG: fifo_uac_cancel: ################ end ##############\n");
+	return 1;
+}
+
+

+ 7 - 0
modules/tm/t_cancel.h

@@ -24,12 +24,17 @@
  * You should have received a copy of the GNU General Public License 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * ---------
+ *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 
 #ifndef _CANCEL_H
 #define _CANCEL_H
 
+#include <stdio.h> /* just for FILE* for fifo_uac_cancel */
 #include "defs.h"
 
 
@@ -49,6 +54,8 @@ void which_cancel( struct cell *t, branch_bm_t *cancel_bm );
 void cancel_uacs( struct cell *t, branch_bm_t cancel_bm );
 void cancel_branch( struct cell *t, int branch );
 
+int fifo_uac_cancel( FILE* stream, char *response_file );
+
 char *build_cancel(struct cell *Trans,unsigned int branch,
 	unsigned int *len );
 

+ 71 - 2
modules/tm/t_lookup.c

@@ -74,9 +74,9 @@
  *             thanks Ed (jiri)
  * 2003-12-04  global TM callbacks switched to per transaction callbacks
  *             (bogdan)
+ * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
-
 #include "defs.h"
 
 
@@ -96,6 +96,8 @@
 #include "sip_msg.h"
 #include "t_hooks.h"
 #include "t_lookup.h"
+#include "dlg.h" /* for t_lookup_callid */
+#include "t_msgbuilder.h" /* for t_lookup_callid */
 
 #define EQ_VIA_LEN(_via)\
 	( (p_msg->via1->bsize-(p_msg->_via->name.s-(p_msg->_via->hdr.s+p_msg->_via->hdr.len)))==\
@@ -975,7 +977,7 @@ static inline int new_t(struct sip_msg *p_msg)
 		return E_OUT_OF_MEM;
 	} 
 
-	insert_into_hash_table_unsafe( new_cell );
+	insert_into_hash_table_unsafe( new_cell, p_msg->hash_index );
 	set_t(new_cell);
 	INIT_REF_UNSAFE(T);
 	/* init pointers to headers needed to construct local
@@ -1203,3 +1205,70 @@ int t_is_local(struct sip_msg* p_msg)
     
     return t->local;
 }
+
+/* lookup a transaction by callid and cseq, parameters are pure
+ * header field content only, e.g. "[email protected]" and "11"
+ */
+int t_lookup_callid(struct cell ** trans, str callid, str cseq) {
+	struct cell* p_cell;
+	unsigned hash_index;
+
+	/* I use MAX_HEADER, not shure if this is a good choice... */
+	char callid_header[MAX_HEADER];
+	char cseq_header[MAX_HEADER];
+	/* save return value of print_* functions here */
+	char* endpos;
+
+	/* need method, which is always INVITE in our case */
+	/* CANCEL is only useful after INVITE */
+	str invite_method;
+	char* invite_string = INVITE;
+	
+	invite_method.s = invite_string;
+	invite_method.len = INVITE_LEN;
+	
+	/* lookup the hash index where the transaction is stored */
+	hash_index=hash(callid, cseq);
+
+	if(hash_index >= TABLE_ENTRIES){
+		LOG(L_ERR,"ERROR: t_lookup_callid: invalid hash_index=%u\n",hash_index);
+		return -1;
+	}
+
+	/* create header fields the same way tm does itself, then compare headers */
+	endpos = print_callid_mini(callid_header, callid);
+	DBG("created comparable call_id header field: >%.*s<\n", endpos - callid_header, callid_header); 
+
+	endpos = print_cseq_mini(cseq_header, &cseq, &invite_method);
+	DBG("created comparable cseq header field: >%.*s<\n", endpos - cseq_header, cseq_header); 
+
+	LOCK_HASH(hash_index);
+	DBG("just locked hash index %u, looking for transactions there:\n", hash_index);
+
+	/* all the transactions from the entry are compared */
+	for ( p_cell = get_tm_table()->entrys[hash_index].first_cell;
+	  p_cell; p_cell = p_cell->next_cell ) {
+		
+		/* compare complete header fields, casecmp to make shure invite=INVITE */
+		if ( (strncmp(callid_header, p_cell->callid.s, p_cell->callid.len) == 0)
+			&& (strncasecmp(cseq_header, p_cell->cseq_n.s, p_cell->cseq_n.len) == 0) ) {
+			DBG("we have a match: callid=>>%.*s<< cseq=>>%.*s<<\n", p_cell->callid.len, 
+				p_cell->callid.s, p_cell->cseq_n.len, p_cell->cseq_n.s);
+			REF_UNSAFE(p_cell);
+			UNLOCK_HASH(hash_index);
+			set_t(p_cell);
+			*trans=p_cell;
+			DBG("DEBUG: t_lookup_callid: transaction found.\n");
+			return 1;
+		}
+		DBG("NO match: callid=%.*s cseq=%.*s\n", p_cell->callid.len, 
+			p_cell->callid.s, p_cell->cseq_n.len, p_cell->cseq_n.s);
+			
+	}
+
+	UNLOCK_HASH(hash_index);
+	DBG("DEBUG: t_lookup_callid: transaction not found.\n");
+    
+	return -1;
+}
+

+ 3 - 0
modules/tm/t_lookup.h

@@ -29,6 +29,7 @@
  * --------
  *  2003-02-24  s/T_NULL/T_NULL_CELL/ to avoid redefinition conflict w/
  *               nameser_compat.h (andrei)
+ *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 
@@ -90,6 +91,8 @@ typedef int (*tlookup_ident_f)(struct cell**, unsigned int, unsigned int);
 int t_is_local(struct sip_msg*);
 int t_get_trans_ident(struct sip_msg* p_msg, unsigned int* hash_index, unsigned int* label);
 int t_lookup_ident(struct cell** trans, unsigned int hash_index, unsigned int label);
+/* lookup a transaction by callid and cseq */
+int t_lookup_callid(struct cell** trans, str callid, str cseq);
 
 #endif
 

+ 24 - 10
modules/tm/t_msgbuilder.c

@@ -36,6 +36,7 @@
  *             is now called before reply status is updated to
  *             avoid late ACK sending (jiri)
  * 2003-10-02  added via_builder set host/port support (andrei)
+ * 2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 #include "defs.h"
@@ -331,31 +332,44 @@ static inline char* print_from(char* w, dlg_t* dialog, struct cell* t)
 /*
  * Print CSeq header field
  */
+char* print_cseq_mini(char* target, str* cseq, str* method) {
+	memapp(target, CSEQ, CSEQ_LEN);
+	memapp(target, cseq->s, cseq->len);
+	memapp(target, " ", 1);
+	memapp(target, method->s, method->len);
+	return target;
+}
+
 static inline char* print_cseq(char* w, str* cseq, str* method, struct cell* t)
 {
 	t->cseq_n.s = w; 
 	/* don't include method name and CRLF -- subsequent
 	 * local reuqests ACK/CANCEl will add their own */
 	t->cseq_n.len = CSEQ_LEN + cseq->len; 
-
-	memapp(w, CSEQ, CSEQ_LEN);
-	memapp(w, cseq->s, cseq->len);
-	memapp(w, " ", 1);
-	memapp(w, method->s, method->len);
+	w = print_cseq_mini(w, cseq, method);
 	return w;
 }
 
-
 /*
  * Print Call-ID header field
+ * created an extra function for pure header field creation, that is used by t_cancel for 
+ * t_uac_cancel FIFO function.
  */
+char* print_callid_mini(char* target, str callid) {
+	memapp(target, CALLID, CALLID_LEN);
+	memapp(target, callid.s, callid.len);
+	memapp(target, CRLF, CRLF_LEN);
+	return target;
+}
+
 static inline char* print_callid(char* w, dlg_t* dialog, struct cell* t)
 {
-	t->callid.s = w + CRLF_LEN; 
-	t->callid.len = CALLID_LEN + dialog->id.call_id.len + CRLF_LEN;
-	memapp(w, CRLF CALLID, CRLF_LEN + CALLID_LEN);
-	memapp(w, dialog->id.call_id.s, dialog->id.call_id.len);
+	/* begins with CRLF, not included in t->callid, don`t know why...?!? */
 	memapp(w, CRLF, CRLF_LEN);
+	t->callid.s = w;
+	t->callid.len = CALLID_LEN + dialog->id.call_id.len + CRLF_LEN;
+
+	w = print_callid_mini(w, dialog->id.call_id);
 	return w;
 }
 

+ 7 - 0
modules/tm/t_msgbuilder.h

@@ -24,6 +24,10 @@
  * You should have received a copy of the GNU General Public License 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * --------
+ *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 
@@ -81,5 +85,8 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t* dialog, int bra
 int t_calc_branch(struct cell *t,
 	int b, char *branch, int *branch_len);
 
+/* exported minimum functions for use in t_cancel */
+char* print_callid_mini(char* target, str callid);
+char* print_cseq_mini(char* target, str* cseq, str* method);
 
 #endif

+ 4 - 4
modules/tm/t_reply.c

@@ -55,6 +55,9 @@
  *  2003-12-04  global TM callbacks switched to per transaction callbacks
  *              (bogdan)
  *  2004-02-06: support for user pref. added - destroy_avps (bogdan)
+ *  2003-11-05  flag context updated from failure/reply handlers back
+ *              to transaction context (jiri)
+ *  2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
  */
 
 
@@ -494,7 +497,6 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 			return 0;
 		}
 	}
-
 	/* same for the body lumps */
 	if (shmem_msg->body_lumps) {
 		fake_req.body_lumps=dup_lump_list(shmem_msg->body_lumps);
@@ -505,7 +507,6 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 			return 0;
 		}
 	}
-
 	/* fake also the env. conforming to the fake msg */
 	faked_env( t, &fake_req);
 	/* DONE with faking ;-) -> run the failure handlers */
@@ -539,7 +540,6 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 	del_nonshm_lump_rpl( &(fake_req.reply_lump) );
 	/* if failure handler changed flag, update transaction context */
 	shmem_msg->flags = fake_req.flags;
-
 	return 1;
 }
 
@@ -1245,7 +1245,7 @@ int t_reply_with_body( struct cell *trans, unsigned int code,
 
 	rpl.s = build_res_buf_from_sip_req(
 			code, text, &s_to_tag,
-			trans->uas.request, &rpl.len, &bm);
+			trans->uas.request, (unsigned int*)&rpl.len, &bm);
 
 	/* since the msg (trans->uas.request) is a clone into shm memory, to avoid
 	 * memory leak or crashing (lumps are create in private memory) I will

+ 1 - 0
modules/tm/test.c

@@ -34,6 +34,7 @@
 #include "../../dprint.h"
 #include "../../config.h"
 #include "../../parser/parser_f.h"
+#include "../../data_lump.h"
 #include "../../ut.h"
 #include "../../timer.h"
 #include "../../data_lump.h"

+ 8 - 3
modules/tm/tm.c

@@ -69,6 +69,7 @@
  *              removed t_relay_{udp,tcp,tls} (andrei)
  *  2003-09-26  added t_forward_nonack_uri() - same as t_forward_nonack() but
  *              takes no parameters -> forwards to uri (bogdan)
+ *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 
@@ -101,6 +102,7 @@
 #include "t_lookup.h"
 #include "t_stats.h"
 #include "callid.h"
+#include "t_cancel.h"
 
 MODULE_VERSION
 
@@ -167,8 +169,6 @@ inline static int t_flush_flags(struct sip_msg* msg, char *dir, char *foo);
 static int t_attr_to_uri(struct sip_msg* msg, char *s, char *foo);
 
 
-
-
 static cmd_export_t cmds[]={
 	{"t_newtran",          w_t_newtran,             0, 0,
 			REQUEST_ROUTE},
@@ -471,6 +471,11 @@ static int mod_init(void)
 		return -1;
 	}
 
+	if (register_fifo_cmd(fifo_uac_cancel, "t_uac_cancel", 0) < 0) {
+		LOG(L_CRIT, "cannot register fifo t_uac_cancel\n");
+		return -1;
+	}
+
 	if (register_fifo_cmd(fifo_hash, "t_hash", 0)<0) {
 		LOG(L_CRIT, "cannot register hash\n");
 		return -1;
@@ -566,7 +571,6 @@ static int t_attr_to_uri(struct sip_msg* msg, char *s, char *foo)
 	msg->new_uri.s = uri;
 	msg->new_uri.len = avp->val.str_val.len;
 	msg->parsed_uri_ok=0;
-
 	return 1;
 }
 
@@ -803,6 +807,7 @@ inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo )
 }
 
 
+
 inline static int _w_t_relay_to( struct sip_msg  *p_msg , 
 	struct proxy_l *proxy )
 {

+ 12 - 2
modules/tm/uac.c

@@ -47,6 +47,7 @@
  *  2003-10-24  updated to the new socket_info lists (andrei)
  *  2003-12-03  completion filed removed from transaction and uac callbacks
  *              merged in transaction callbacks as LOCAL_COMPLETED (bogdan)
+ *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  */
 
 #include <string.h>
@@ -146,6 +147,16 @@ static inline int check_params(str* method, str* to, str* from, dlg_t** dialog)
 	return 0;
 }
 
+static inline unsigned int dlg2hash( dlg_t* dlg )
+{
+	str cseq_nr;
+	unsigned int hashid;
+
+	cseq_nr.s=int2str(dlg->loc_seq.value, &cseq_nr.len);
+	hashid=hash(dlg->id.call_id, cseq_nr);
+	DBG("DEBUG: dlg2hash: %d\n", hashid);
+	return hashid;
+}
 
 /*
  * Send a request using data from the dialog structure
@@ -201,9 +212,8 @@ int t_uac(str* method, str* headers, str* body, dlg_t* dialog,
 	request->dst.proto = send_sock->proto;
 	request->dst.proto_reserved1 = 0;
 
-	/* need to put in table to calculate label which is needed for printing */
 	LOCK_HASH(new_cell->hash_index);
-	insert_into_hash_table_unsafe(new_cell);
+	insert_into_hash_table_unsafe(new_cell, dlg2hash(dialog));
 	UNLOCK_HASH(new_cell->hash_index);
 
 	buf = build_uac_req(method, headers, body, dialog, 0, new_cell,

+ 3 - 0
modules/tm/uac_fifo.h

@@ -1,5 +1,8 @@
 /*
  * UAC FIFO interface
+ *
+ * $Id$
+ *
  */
 
 #ifndef UAC_FIFO_H