Browse Source

- updated to the new management interface (not complete yet)

Jan Janak 20 năm trước cách đây
mục cha
commit
6cc8e8c1e8

+ 0 - 49
modules/tm/h_table.c

@@ -53,8 +53,6 @@
 #include "../../ut.h"
 #include "../../globals.h"
 #include "../../error.h"
-#include "../../fifo_server.h"
-#include "../../unixsock_server.h"
 #include "defs.h"
 #include "t_reply.h"
 #include "t_cancel.h"
@@ -405,50 +403,3 @@ void remove_from_hash_table_unsafe( struct cell * p_cell)
 	/* unlock( &(p_entry->mutex) ); */
 }
 
-/* print accumulated distribution of the hash table */
-int fifo_hash( FILE *stream, char *response_file )
-{
-	FILE *reply_file;
-	unsigned int i;
-
-	reply_file=open_reply_pipe(response_file);
-	if (reply_file==0) {
-		LOG(L_ERR, "ERROR: fifo_hash: file '%s' not opened\n", 
-			response_file);
-		return -1;
-	}
-	fputs( "200 ok\n\tcurrent\ttotal\n", reply_file);
-	for (i=0; i<TABLE_ENTRIES; i++) {
-		fprintf(reply_file, "%d.\t%lu\t%lu\n", 
-			i, tm_table->entrys[i].cur_entries ,
-			tm_table->entrys[i].acc_entries );
-	}
-	fclose(reply_file);
-	return 1;
-}
-
-
-int unixsock_hash(str* msg)
-{
-	unsigned int i, ret;
-
-	ret = 0;
-	unixsock_reply_asciiz( "200 OK\n\tcurrent\ttotal\n");
-
-	for (i = 0; i < TABLE_ENTRIES; i++) {
-		if (unixsock_reply_printf("%d.\t%lu\t%lu\n", 
-					  i, tm_table->entrys[i].cur_entries,
-					  tm_table->entrys[i].acc_entries
-					  ) < 0) {
-			unixsock_reply_reset();
-			unixsock_reply_asciiz("500 Error while creating reply\n");
-			ret = -1;
-			break;
-		}
-	}
-
-	if (unixsock_reply_send() < 0) {
-		ret = -1;
-	}
-	return ret;
-}

+ 0 - 5
modules/tm/h_table.h

@@ -330,11 +330,6 @@ void   insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash )
 
 unsigned int transaction_count( void );
 
-int fifo_hash( FILE *stream, char *response_file );
-
-/* Unix socket variant */
-int unixsock_hash(str* msg);
-		    
 #endif
 
 

+ 20 - 75
modules/tm/t_cancel.c

@@ -45,8 +45,6 @@
 #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() */
-#include "../../unixsock_server.h"
 
 
 /* determine which branches should be canceled; do it
@@ -126,16 +124,20 @@ void cancel_branch( struct cell *t, int branch )
 }
 
 
-/* fifo command to cancel a pending call (Uli)
-  Syntax:
+const char* rpc_cancel_doc[2] = {
+	"Cancel a pending transaction",
+	0
+};
 
-  ":uac_cancel:[response file]\n
-  callid\n
- cseq\n
-  \n"
- */
 
-int fifo_uac_cancel( FILE* stream, char *response_file )
+/* fifo command to cancel a pending call (Uli)
+ * Syntax:
+ *
+ * ":uac_cancel:[response file]\n
+ * callid\n
+ * cseq\n
+ */
+void rpc_cancel(rpc_t* rpc, void* c)
 {
 	struct cell *trans;
 	static char cseq[128], callid[128];
@@ -146,77 +148,20 @@ int fifo_uac_cancel( FILE* stream, char *response_file )
 	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;
+	if (rpc->scan(rpc, "SS", &callid_s, &cseq_s) < 2) {
+		rpc->fault(c, 400, "Callid and CSeq expected as parameters");
+		return;
 	}
-	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;
-}
-
-
-int unixsock_uac_cancel(str* msg)
-{
-	struct cell *trans;
-	str cseq, callid;
-
-	     /* first param callid read */
-	if (unixsock_read_line(&callid, msg) != 0) {
-		unixsock_reply_asciiz("400 Call-ID Expected\n");
-		unixsock_reply_send();
-		return -1;
-	}
-
-	     /* second param cseq read */
-	if (unixsock_read_line(&cseq, msg) != 0) {
-		unixsock_reply_asciiz("400 CSeq Expected\n");
-		unixsock_reply_send();
-		return -1;
-	}
-
-	if (t_lookup_callid(&trans, callid, cseq) < 0) {
-		LOG(L_ERR, "unixsock_uac_cancel: Lookup failed\n");
-		unixsock_reply_asciiz("481 uac_cancel: No such transaction\n");
-		unixsock_reply_send();
-		return 1;
+		DBG("Lookup failed\n");
+		rpc->fault(c, 400, "Transaction not found");
+		return;
 	}
-
 	     /* tell tm to cancel the call */
+	DBG("Now calling cancel_uacs\n");
 	(*cancel_uacs)(trans, ~0);
-
+	
 	     /* t_lookup_callid REF`d the transaction for us, we must UNREF here! */
 	UNREF(trans);
-
-	unixsock_reply_asciiz("200 uac_cancel succeeded\n");
-	unixsock_reply_send();
-	return 0;
 }

+ 3 - 4
modules/tm/t_cancel.h

@@ -35,6 +35,7 @@
 #define _CANCEL_H
 
 #include <stdio.h> /* just for FILE* for fifo_uac_cancel */
+#include "../../rpc.h"
 #include "defs.h"
 
 
@@ -54,10 +55,6 @@ 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 );
-
-int unixsock_uac_cancel(str* msg);
-
 inline short static should_cancel_branch( struct cell *t, int b )
 {
 	int last_received;
@@ -74,5 +71,7 @@ inline short static should_cancel_branch( struct cell *t, int b )
 	return should;
 }
 
+const char* rpc_cancel_doc[2];
+void rpc_cancel(rpc_t* rpc, void* c);
 
 #endif

+ 52 - 220
modules/tm/t_reply.c

@@ -85,8 +85,6 @@
 #include "../../data_lump.h"
 #include "../../data_lump_rpl.h"
 #include "../../usr_avp.h"
-#include "../../fifo_server.h"
-#include "../../unixsock_server.h"
 
 #include "defs.h"
 #include "h_table.h"
@@ -1495,163 +1493,6 @@ error:
 	return -1;
 }
 
-
-
-/*
-  Syntax:
-
-  ":vm_reply:[response file]\n
-  code\n
-  reason\n
-  trans_id\n
-  to_tag\n
-  [new headers]\n
-  \n
-  [Body]\n
-  .\n
-  \n"
- */
-int fifo_t_reply( FILE *stream, char *response_file )
-{
-	int ret;
-	struct cell *trans;
-	char code[16];
-	char reason[128];
-	char trans_id[128];
-	char new_headers[MAX_HEADER];
-	char body[MAX_BODY];
-	char to_tag[128];
-	str sc;       /*  code */
-	str sr;       /*  reason */
-	str sti;      /*  trans_id */
-	str snh;      /*  new_headers */
-	str sb;       /*  body */
-	str sttag;    /*  to-tag */
-	unsigned int hash_index,label,icode;
-
-	sc.s=code;
-	sr.s=reason;
-	sti.s=trans_id;
-	snh.s=new_headers; sb.s=body;
-	sttag.s=to_tag; sttag.len=0;
-
-
-	/*  get the infos from FIFO server */
-
-	DBG("DEBUG: fifo_t_reply: ############### begin ##############\n");
-
-	if (!read_line(sc.s, 16, stream, &sc.len)||sc.len==0) {
-		LOG(L_ERR, "ERROR: fifo_t_reply: code expected\n");
-		fifo_reply(response_file, "400 fifo_t_reply: code expected");
-		return -1;
-	}
-
-	icode = str2s(sc.s,sc.len,&ret);
-	if(ret){
-		LOG(L_ERR, "ERROR: fifo_t_reply: code(int) has wrong format\n");
-		fifo_reply(response_file, "400 fifo_t_reply: code(int) has"
-			" wrong format");
-		return -1;
-	}
-
-	if(!read_line(sr.s, 128, stream, &sr.len)||sr.len==0){
-		LOG(L_ERR, "ERROR: fifo_t_reply: reason expected\n");
-		fifo_reply(response_file, "400 fifo_t_reply: reason expected");
-		return -1;
-	}
-	sr.s[sr.len]='\0';
-
-	if (!read_line(sti.s, 128, stream, &sti.len)||sti.len==0) {
-		LOG(L_ERR, "ERROR: fifo_t_reply: trans_id expected\n");
-		fifo_reply(response_file, "400 fifo_t_reply: trans_id expected");
-		return -1;
-	}
-	sti.s[sti.len]='\0';
-	DBG("DEBUG: fifo_t_reply: trans_id=%.*s\n",sti.len,sti.s);
-
-	if(sscanf(sti.s,"%u:%u", &hash_index, &label) != 2){
-		LOG(L_ERR, "ERROR: fifo_t_reply: invalid trans_id (%s)\n",sti.s);
-		fifo_reply(response_file, "400 fifo_t_reply: invalid trans_id");
-		return -1;
-	}
-	DBG("DEBUG: fifo_t_reply: hash_index=%u label=%u\n",hash_index,label);
-
-	if( !read_line(sttag.s,64,stream,&sttag.len) || sttag.len==0 ){
-		LOG(L_ERR, "ERROR: fifo_t_reply: to-tag expected\n");
-		fifo_reply(response_file, "400 fifo_t_reply: to-ta expected");
-		return -1;
-	}
-	sttag.s[sttag.len]='\0';
-	DBG("DEBUG: fifo_t_reply: to-tag: %.*s\n",sttag.len,sttag.s);
-
-	/* read the new headers */
-	if (!read_line_set(snh.s, MAX_HEADER, stream, &snh.len)) {
-		LOG(L_ERR, "ERROR: fifo_t_reply: while reading new headers\n");
-		fifo_reply(response_file, "400 fifo_t_reply: while reading "
-			"new headers");
-		return -1;
-	}
-	snh.s[snh.len]='\0';
-	DBG("DEBUG: fifo_t_reply: new headers: %.*s\n", snh.len, snh.s);
-
-	/*  body can be empty ... */
-	read_body(sb.s, MAX_BODY, stream, &sb.len);
-	sb.s[sb.len]='\0';
-	DBG("DEBUG: fifo_t_reply: body: <%.*s>\n", sb.len, sb.s);
-
-	if( t_lookup_ident(&trans,hash_index,label)<0 ) {
-		LOG(L_ERR,"ERROR: fifo_t_reply: lookup failed\n");
-		fifo_reply(response_file, "481 fifo_t_reply: no such transaction");
-		return -1;
-	}
-
-	/* it's refcounted now, t_reply_with body unrefs for me -- I can
-	 * continue but may not use T anymore  */
-	ret = t_reply_with_body(trans,icode,reason,body,new_headers,to_tag);
-
-	if (ret<0) {
-		LOG(L_ERR, "ERROR: fifo_t_reply: reply failed\n");
-		fifo_reply(response_file, "500 fifo_t_reply: reply failed");
-		return -1;
-	}
-
-	fifo_reply(response_file, "200 fifo_t_reply succeeded\n");
-	DBG("DEBUG: fifo_t_reply: ################ end ##############\n");
-	return 1;
-}
-
-
-static int parse_transid(str* s, unsigned int* index, unsigned int* label)
-{
-	char* buf;
-
-	if (!s || !index || !label) {
-		LOG(L_ERR, "parse_transid: Invalid parameter value\n");
-		return -1;
-	}
-
-	buf = (char*)pkg_malloc(s->len + 1);
-	if (!buf) {
-		LOG(L_ERR, "parse_transid: No memory left\n");
-		return -1;
-	}
-
-	memcpy(buf, s->s, s->len + 1);
-	buf[s->len] = '\0';
-
-	if (sscanf(buf, "%u:%u", index, label) != 2) {
-		LOG(L_ERR, "parse_transid: Invalid trans_id (%s)\n", buf);
-		pkg_free(buf);
-		return -1;
-	}
-
-	DBG("parse_transid: hash_index=%u label=%u\n", *index, *label);
-	pkg_free(buf);
-	return 0;
-}
-
-
-
 static int send_reply(struct cell *trans, unsigned int code, str* text, str* body, str* headers, str* to_tag)
 {
 	struct lump_rpl *hdr_lump, *body_lump;
@@ -1724,86 +1565,77 @@ static int send_reply(struct cell *trans, unsigned int code, str* text, str* bod
 }
 
 
+const char* rpc_reply_doc[2] = {
+	"Reply transaction",
+	0
+};
+
+/*
+  Syntax:
 
-int unixsock_t_reply(str* msg)
+  ":tm.reply:[response file]\n
+  code\n
+  reason\n
+  trans_id\n
+  to_tag\n
+  [new headers]\n
+  \n
+  [Body]\n
+  .\n
+  \n"
+ */
+void rpc_reply(rpc_t* rpc, void* c)
 {
 	int ret;
 	struct cell *trans;
-	static char new_headers[MAX_HEADER];
-	str code, reason, transid, headers, body, to_tag;
-	unsigned int hash_index, label, icode;
-
-	headers.s = new_headers;
-	headers.len = MAX_HEADER;
-
-	if (unixsock_read_line(&code, msg) != 0) {
-		unixsock_reply_asciiz("400 Reason code expected\n");
-		goto err;
-	}
+	unsigned int hash_index, label, code;
+	str ti;
+	char* reason, *body, *headers, *tag;
 
-	icode = str2s(code.s, code.len, &ret);
-	if (ret) {
-		unixsock_reply_printf("400 Reason code has wrong format\n");
-		goto err;
+	if (rpc->scan(c, "d", &code) < 1) {
+		rpc->fault(c, 400, "Reply code expected");
+		return;
 	}
 
-	if (unixsock_read_line(&reason, msg) != 0) {
-		unixsock_reply_asciiz("400 Reason phrase expected\n");
-		goto err;
+	if (rpc->scan(c, "s", &reason) < 1) {
+		rpc->fault(c, 400, "Reason phrase expected");
+		return;
 	}
 
-	if (unixsock_read_line(&transid, msg) != 0) {
-		unixsock_reply_asciiz("400 Transaction ID expected\n");
-		goto err;
+	if (rpc->scan(c, "s", &ti.s) < 1) {
+		rpc->fault(c, 400, "Transaction ID expected");
+		return;
 	}
+	ti.len = strlen(ti.s);
 
-	if (parse_transid(&transid, &hash_index, &label) < 0) {
-		unixsock_reply_asciiz("400 Error while parsing transaction ID\n");
-		goto err;
+	if (rpc->scan(c, "s", &tag) < 1) {
+		rpc->fault(c, 400, "To tag expected");
+		return;
 	}
 
-	if (unixsock_read_line(&to_tag, msg) != 0) {
-		unixsock_reply_asciiz("400 To tag expected\n");
-		goto err;
-	}
+	if (rpc->scan(c, "s", &headers) < 0) return;
+	if (rpc->scan(c, "s", &body) < 0) return;
 
-	     /* read the new headers */
-	if (unixsock_read_lineset(&headers, msg) < 0) {
-		unixsock_reply_asciiz("400 Error while reading new headers\n");
-		goto err;
+	if(sscanf(ti.s,"%u:%u", &hash_index, &label) != 2) {
+		ERR("Invalid trans_id (%s)\n", ti.s);
+		rpc->fault(c, 400, "Invalid transaction ID");
+		return;
 	}
+	DBG("hash_index=%u label=%u\n", hash_index, label);
 
-	DBG("lineset: %.*s\n", headers.len, headers.s);
-
-	/*  body can be empty ... */
-	if (unixsock_read_body(&body, msg) < 0) {
-		unixsock_reply_asciiz("400 Error while reading body\n");
-		goto err;
+	if( t_lookup_ident(&trans, hash_index, label) < 0 ) {
+		ERR("Lookup failed\n");
+		rpc->fault(c, 481, "No such transaction");
+		return;
 	}
 
-	DBG("body: %.*s\n", body.len, body.s);
-
-	if (t_lookup_ident(&trans, hash_index, label) < 0) {
-		LOG(L_ERR,"unixsock_t_reply: lookup failed\n");
-		unixsock_reply_asciiz("481 No such transaction\n");
-		goto err;
-	}
+	/* it's refcounted now, t_reply_with body unrefs for me -- I can
+	 * continue but may not use T anymore  */
+	ret = t_reply_with_body(trans, code, reason, body, headers, tag);
 
-	     /* it's refcounted now, t_reply_with body unrefs for me -- I can
-	      * continue but may not use T anymore
-	      */
-	ret = send_reply(trans, icode, &reason, &body, &headers, &to_tag);
 	if (ret < 0) {
-		LOG(L_ERR, "unixsock_t_reply: reply failed\n");
-		unixsock_reply_asciiz("500 Reply failed\n");
-		goto err;
+		ERR("Reply failed\n");
+		rpc->fault(c, 500, "Reply failed");
+		return;
 	}
-
-	unixsock_reply_asciiz("200 Succeeded\n");
-	unixsock_reply_send();
-	return 1;
-
- err:
-	unixsock_reply_send();
-	return -1;
 }

+ 3 - 3
modules/tm/t_reply.h

@@ -31,6 +31,7 @@
 #define _T_REPLY_H
 
 #include "defs.h"
+#include "../../rpc.h"
 #include "../../tags.h"
 
 #include "h_table.h"
@@ -139,8 +140,7 @@ void tm_init_tags();
 /* selects the branch for fwd-ing the reply */
 int t_pick_branch(int inc_branch, int inc_code, struct cell *t, int *res_code);
 
-int fifo_t_reply( FILE *stream, char *response_file );
-
-int unixsock_t_reply(str* msg);
+extern const char* rpc_reply_doc[2];
+void rpc_reply(rpc_t* rpc, void* c);
 
 #endif

+ 39 - 123
modules/tm/t_stats.c

@@ -41,121 +41,11 @@
 #include "../../mem/shm_mem.h"
 #include "../../dprint.h"
 #include "../../config.h"
-#include "../../fifo_server.h"
-#include "../../unixsock_server.h"
 #include "../../pt.h"
 
 struct t_stats *tm_stats=0;
 
 
-/* we don't worry about locking data during reads (unlike
-   setting values which always happens from some locks) */
-  
-int print_stats(  FILE *f )
-{
-	unsigned long total, current, waiting, total_local;
-	int i;
-	int pno;
-
-	pno=process_count;
-	for(i=0, total=0, waiting=0, total_local=0; i<pno;i++) {
-		total+=tm_stats->s_transactions[i];
-		waiting+=tm_stats->s_waiting[i];
-		total_local+=tm_stats->s_client_transactions[i];
-	}
-	current=total-tm_stats->deleted;
-	waiting-=tm_stats->deleted;
-
-	
-
-	fprintf(f, "Current: %lu (%lu waiting) "
-		"Total: %lu (%lu local) " CLEANUP_EOL,
-		current, waiting, total, total_local);
-
-	fprintf(f, "Replied localy: %lu" CLEANUP_EOL ,
-		tm_stats->replied_localy );
-	fprintf(f, "Completion status 6xx: %lu,",
-		tm_stats->completed_6xx );
-	fprintf(f, " 5xx: %lu,",
-		tm_stats->completed_5xx );
-	fprintf(f, " 4xx: %lu,",
-		tm_stats->completed_4xx );
-	fprintf(f, " 3xx: %lu,",
-		tm_stats->completed_3xx );
-	fprintf(f, "2xx: %lu" CLEANUP_EOL ,
-		tm_stats->completed_2xx );
-	
-	return 1;
-}
-
-int static fifo_stats( FILE *pipe, char *response_file )
-{
-	FILE *file;
-
-	if (response_file==0 || *response_file==0 ) {
-		LOG(L_ERR, "ERROR: fifo_stats: null file\n");
-		return -1;
-	}
-
-	file=open_reply_pipe(response_file );
-	if (file==NULL) {
-		LOG(L_ERR, "ERROR: fifo_stats: file %s bad: %s\n",
-			response_file, strerror(errno) );
-		return -1;
-	}
-	fputs( "200 ok\n", file);
-	print_stats( file );
-	fclose(file);
-	
-	return 1;
-
-}
-
-int static unixsock_stats(str* cmd)
-{
-	unsigned long total, current, waiting, total_local;
-	int i;
-	int pno;
-
-	unixsock_reply_asciiz( "200 OK\n");
-
-	pno = process_count;
-	for(i = 0, total = 0, waiting = 0, total_local = 0; i < pno; i++) {
-		total += tm_stats->s_transactions[i];
-		waiting += tm_stats->s_waiting[i];
-		total_local += tm_stats->s_client_transactions[i];
-	}
-	current = total - tm_stats->deleted;
-	waiting -= tm_stats->deleted;
-
-	if (unixsock_reply_printf("Current: %lu (%lu waiting) "
-				  "Total: %lu (%lu local) " CLEANUP_EOL,
-				  current, waiting, total, total_local) < 0) goto err;
-
-	if (unixsock_reply_printf("Replied localy: %lu" CLEANUP_EOL ,
-				  tm_stats->replied_localy ) < 0) goto err;
-	if (unixsock_reply_printf("Completion status 6xx: %lu,",
-				  tm_stats->completed_6xx ) < 0) goto err;
-	if (unixsock_reply_printf(" 5xx: %lu,",
-				  tm_stats->completed_5xx ) < 0) goto err;
-	if (unixsock_reply_printf(" 4xx: %lu,",
-				  tm_stats->completed_4xx ) < 0) goto err;
-	if (unixsock_reply_printf(" 3xx: %lu,",
-				  tm_stats->completed_3xx ) < 0) goto err;
-	if (unixsock_reply_printf("2xx: %lu" CLEANUP_EOL ,
-				  tm_stats->completed_2xx ) < 0) goto err;
-	
-	unixsock_reply_send();
-	return 0;
-
- err:
-	unixsock_reply_reset();
-	unixsock_reply_asciiz("500 Buffer too small\n");
-	unixsock_reply_send();
-	return -1;
-}
-
-
 int init_tm_stats(void)
 {
 	int size;
@@ -189,21 +79,8 @@ int init_tm_stats(void)
 	}
 	memset(tm_stats->s_client_transactions, 0, size );
 		 
-	if (register_fifo_cmd(fifo_stats, "t_stats", 0)<0) {
-		LOG(L_CRIT, "cannot register fifo stats\n");
-		goto error4;
-	}
-
-	if (unixsock_register_cmd("t_stats", unixsock_stats) < 0) {
-		LOG(L_CRIT, "cannot register fifo stats\n");
-		goto error4;
-	}
-
 	return 1;
 
-error4:
-	shm_free(tm_stats->s_client_transactions);
-	tm_stats->s_client_transactions=0;
 error3:
 	shm_free(tm_stats->s_transactions);
 	tm_stats->s_transactions=0;
@@ -228,3 +105,42 @@ void free_tm_stats()
 		shm_free(tm_stats);
 	}
 }
+
+
+const char* tm_rpc_stats_doc[2] = {
+	"Print transaction statistics.",
+	0
+};
+
+/* we don't worry about locking data during reads (unlike
+ * setting values which always happens from some locks) 
+ */
+void tm_rpc_stats(rpc_t* rpc, void* c)
+{
+	void* st;
+	unsigned long total, current, waiting, total_local;
+	int i, pno;
+
+	pno = process_count;
+	for(i = 0, total = 0, waiting = 0, total_local = 0; i < pno; i++) {
+		total += tm_stats->s_transactions[i];
+		waiting += tm_stats->s_waiting[i];
+		total_local += tm_stats->s_client_transactions[i];
+	}
+	current = total - tm_stats->deleted;
+	waiting -= tm_stats->deleted;
+
+	if (rpc->add(c, "{", &st) < 0) return;
+
+	rpc->struct_add(st, "dd", "current", current, "waiting", waiting);
+	rpc->struct_add(st, "dd", "waiting", waiting, "total", total);
+	rpc->struct_add(st, "d", "total_local", total_local);
+	rpc->struct_add(st, "d", "replied_localy", tm_stats->replied_localy);
+	rpc->struct_add(st, "ddddd", 
+			"6xx", tm_stats->completed_6xx,
+			"5xx", tm_stats->completed_5xx,
+			"4xx", tm_stats->completed_4xx,
+			"3xx", tm_stats->completed_3xx,
+			"2xx", tm_stats->completed_2xx);
+	rpc->fault(c, 100, "Trying");
+}

+ 4 - 1
modules/tm/t_stats.h

@@ -33,7 +33,7 @@
 
 #include "defs.h"
 
-
+#include "../../rpc.h"
 #include "../../pt.h"
 
 
@@ -91,4 +91,7 @@ inline static void update_reply_stats( int code ) {
 int init_tm_stats(void);
 void free_tm_stats();
 
+extern const char* tm_rpc_stats_doc[2];
+void tm_rpc_stats(rpc_t* rpc, void* c);
+
 #endif

+ 9 - 45
modules/tm/tm.c

@@ -91,10 +91,8 @@
 #include "../../error.h"
 #include "../../ut.h"
 #include "../../script_cb.h"
-#include "../../fifo_server.h"
 #include "../../usr_avp.h"
 #include "../../mem/mem.h"
-#include "../../unixsock_server.h"
 #include "../../route_struct.h"
 
 #include "sip_msg.h"
@@ -104,8 +102,6 @@
 #include "ut.h"
 #include "t_reply.h"
 #include "uac.h"
-#include "uac_fifo.h"
-#include "uac_unixsock.h"
 #include "t_fwd.h"
 #include "t_lookup.h"
 #include "t_stats.h"
@@ -179,6 +175,7 @@ static int t_set_fr_all(struct sip_msg* msg, char* fr_inv, char* fr);
 static char *fr_timer_param = FR_TIMER_AVP;
 static char *fr_inv_timer_param = FR_INV_TIMER_AVP;
 
+static rpc_export_t tm_rpc[];
 
 static cmd_export_t cmds[]={
 	{"t_newtran",          w_t_newtran,             0, 0,
@@ -298,7 +295,7 @@ struct module_exports exports= {
 	"tm",
 	/* -------- exported functions ----------- */
 	cmds,
-	0,    /* RPC methods */
+	tm_rpc,    /* RPC methods */
 	/* ------------ exported variables ---------- */
 	params,
 	
@@ -394,46 +391,6 @@ static int mod_init(void)
 		return -1;
 	}
 
-	if (register_fifo_cmd(fifo_uac, "t_uac_dlg", 0) < 0) {
-		LOG(L_CRIT, "cannot register fifo t_uac\n");
-		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;
-	}
-
-	if (register_fifo_cmd(fifo_t_reply, "t_reply", 0)<0) {
-		LOG(L_CRIT, "cannot register t_reply\n");
-		return -1;
-	}
-
-	if (unixsock_register_cmd("t_uac_dlg", unixsock_uac) < 0) {
-		LOG(L_CRIT, "cannot register t_uac with the unix server\n");
-		return -1;
-	}
-
-	if (unixsock_register_cmd("t_uac_cancel", unixsock_uac_cancel) < 0) {
-		LOG(L_CRIT, "cannot register t_uac_cancel with the unix server\n");
-		return -1;
-	}
-
-	if (unixsock_register_cmd("t_hash", unixsock_hash) < 0) {
-		LOG(L_CRIT, "cannot register t_hash with the unix server\n");
-		return -1;
-	}
-
-	if (unixsock_register_cmd("t_reply", unixsock_t_reply) < 0) {
-		LOG(L_CRIT, "cannot register t_reply with the unix server\n");
-		return -1;
-	}
-
 	/* building the hash table*/
 	if (!init_hash_table()) {
 		LOG(L_ERR, "ERROR: mod_init: initializing hash_table failed\n");
@@ -852,3 +809,10 @@ static int t_set_fr_inv(struct sip_msg* msg, char* fr_inv, char* foo)
 	return t_set_fr_all(msg, fr_inv, (char*)0);
 }
 
+
+static rpc_export_t tm_rpc[] = {
+	{"tm.cancel", rpc_cancel,   rpc_cancel_doc,   0},
+	{"tm.reply",  rpc_reply,    rpc_reply_doc,    0},
+	{"tm.stats",  tm_rpc_stats, tm_rpc_stats_doc, 0},
+	{0, 0, 0, 0}
+};

+ 0 - 675
modules/tm/uac_fifo.c

@@ -1,675 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2001-2003 FhG Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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:
- * --------
- *  2003-12-03 : fifo_callback() updated for changes in tm callbacks (bogdan)
- *  2004-02-11: fix: TM callback writes to fifo changed to non-blocking (jiri)
- */
-
-#include <string.h>
-#include "../../mem/shm_mem.h"
-#include "../../mem/mem.h"
-#include "../../dprint.h"
-#include "../../fifo_server.h"
-#include "../../str.h"
-#include "../../parser/msg_parser.h"
-#include "../../parser/parse_from.h"
-#include "../../parser/parse_uri.h"
-#include "../../ip_addr.h"
-#include "config.h"
-#include "ut.h"
-#include "uac.h"
-#include "dlg.h"
-#include "callid.h"
-#include "h_table.h"
-#include "uac_fifo.h"
-
-
-/*
- * Callback data structure
- */
-struct cb_data {
-	dlg_t* dialog;
-	char filename[1];
-};
-
-
-struct str_list {
-	str s;
-	struct str_list *next;
-};
-
-
-#define skip_hf(_hf) (             \
-    ((_hf)->type == HDR_FROM_T)   || \
-    ((_hf)->type == HDR_TO_T)     || \
-    ((_hf)->type == HDR_CALLID_T) || \
-    ((_hf)->type == HDR_CSEQ_T)      \
-)
-
-
-/*
- * Report an error to syslog and FIFO output file
- */
-static inline void fifo_uac_error(char *reply_fifo, int code, char *msg)
-{
-	LOG(L_ERR, "ERROR: fifo_uac_error: %s\n", msg ); 
-	fifo_reply(reply_fifo, "%d fifo_uac_error: %s", code, msg);
-}
-
-
-/*
- * Get the Request URI from the FIFO stream and parse it
- */
-static inline int fifo_get_ruri(FILE* stream, char* response_file, str* ruri, struct sip_uri* puri)
-{
-	static char ruri_buf[MAX_URI_SIZE];
-
-	if (!read_line(ruri_buf, MAX_URI_SIZE, stream, &ruri->len) || !ruri->len) {
-		fifo_uac_error(response_file, 400, "ruri expected");
-		return -1;
-	}
-	
-	if (parse_uri(ruri_buf, ruri->len, puri) < 0 ) {
-		fifo_uac_error(response_file, 400, "ruri invalid\n");
-		return -2;
-	}
-	ruri->s = ruri_buf;
-	DBG("DEBUG: fifo_get_ruri: '%.*s'\n", ruri->len, ruri->s);
-	return 0;
-}
-
-
-/*
- * Get and parse next hop URI
- */
-static inline int fifo_get_nexthop(FILE* stream, char* response_file, str* nexthop, struct sip_uri* pnexthop)
-{
-	static char nexthop_buf[MAX_URI_SIZE];
-
-	if (!read_line(nexthop_buf, MAX_URI_SIZE, stream, &nexthop->len) || !nexthop->len) {
-		fifo_uac_error(response_file, 400, "next hop address expected\n");
-		return -1;
-	}
-
-	if (nexthop->len == 1 && nexthop_buf[0] == '.' ) {
-		DBG("DEBUG: fifo_get_nexthop: next hop empty\n");
-		nexthop->s = 0; 
-		nexthop->len = 0;
-	} else if (parse_uri(nexthop_buf, nexthop->len, pnexthop) < 0 ) {
-		fifo_uac_error(response_file, 400, "next hop uri invalid\n");
-		return -2;
-	} else {
-		nexthop->s = nexthop_buf;
-		DBG("DEBUG: fifo_get_nexthop: hop: '%.*s'\n", nexthop->len, nexthop->s);
-	}
-
-	return 0;
-}
-
-
-/*
- * Get method name from FIFO stream
- */
-static inline int fifo_get_method(FILE* stream, char* response_file, str* method)
-{
-	static char method_buf[MAX_METHOD];
-
-	if (!read_line(method_buf, MAX_METHOD, stream, &method->len) || !method->len) {
-		     /* line breaking must have failed -- consume the rest
-			and proceed to a new request
-		     */
-		fifo_uac_error(response_file, 400, "method expected");
-		return -1;
-	}
-	method->s = method_buf;
-	DBG("fifo_get_method: method: '%.*s'\n", method->len, method->s);
-	return 0;
-}
-
-
-/*
- * Get message body from FIFO stream
- */
-static inline int fifo_get_body(FILE* stream, char* response_file, str* body)
-{
-	static char body_buf[MAX_BODY];
-
-	if (!read_body(body_buf, MAX_BODY, stream, &body->len)) {
-		fifo_uac_error(response_file, 400, "body expected");
-		return -1;
-	}
-	body->s = body_buf;
-	DBG("fifo_get_body: body: %.*s\n", body->len,  body->s);
-	return 0;
-}
-
-
-/*
- * Get message headers from FIFO stream
- */
-static inline int fifo_get_headers(FILE* stream, char* response_file, str* headers)
-{
-	static char headers_buf[MAX_HEADER];
-
-	     /* now read and parse header fields */
-	if (!read_line_set(headers_buf, MAX_HEADER, stream, &headers->len) || !headers->len) {
-		fifo_uac_error(response_file, 400, "HFs expected");
-		return -1;
-	}
-	headers->s = headers_buf;
-	DBG("fifo_get_headers: headers: %.*s\n", headers->len, headers->s);
-	return 0;
-}
-
-
-/*
- * Create shm_copy of filename
- */
-static inline int fifo_cbp(char** shm_file, char* response_file)
-{
-	int fn_len;
-
-	if (response_file) {
-		fn_len = strlen(response_file) + 1;
-		*shm_file = shm_malloc(fn_len);
-		if (!*shm_file) {
-			fifo_uac_error(response_file, 500, "no shmem");
-			return -1;
-		}
-		memcpy(*shm_file, response_file, fn_len);
-	} else {
-		*shm_file = 0;
-	}
-	return 0;
-}
-
-
-static inline struct str_list *new_str(char *s, int len, struct str_list **last, int *total)
-{
-	struct str_list *new;
-	new=pkg_malloc(sizeof(struct str_list));
-	if (!new) {
-		LOG(L_ERR, "ERROR: new_str: not enough mem\n");
-		return 0;
-	}
-	new->s.s=s;
-	new->s.len=len;
-	new->next=0;
-
-	(*last)->next=new;
-	*last=new;
-	*total+=len;
-
-	return new;
-}
-
-
-static char *get_hfblock(str *uri, struct hdr_field *hf, int *l, int proto) 
-{
-	struct str_list sl, *last, *new, *i, *foo;
-	int hf_avail, frag_len, total_len;
-	char *begin, *needle, *dst, *ret, *d;
-	str *sock_name, *portname;
-	union sockaddr_union to_su;
-	struct socket_info* send_sock;
-
-	ret=0; /* pessimist: assume failure */
-	total_len=0;
-	last=&sl;
-	last->next=0;
-	portname=sock_name=0;
-
-	for (; hf; hf=hf->next) {
-		if (skip_hf(hf)) continue;
-
-		begin=needle=hf->name.s; 
-		hf_avail=hf->len;
-
-		/* substitution loop */
-		while(hf_avail) {
-			d=memchr(needle, SUBST_CHAR, hf_avail);
-			if (!d || d+1>=needle+hf_avail) { /* nothing to substitute */
-				new=new_str(begin, hf_avail, &last, &total_len); 
-				if (!new) goto error;
-				break;
-			} else {
-				frag_len=d-begin;
-				d++; /* d not at the second substitution char */
-				switch(*d) {
-					case SUBST_CHAR:	/* double SUBST_CHAR: IP */
-						/* string before substitute */
-						new=new_str(begin, frag_len, &last, &total_len); 
-						if (!new) goto error;
-						/* substitute */
-						if (!sock_name) {
-							send_sock=uri2sock(0, uri, &to_su, proto );
-							if (!send_sock) {
-								LOG(L_ERR, "ERROR: get_hfblock: send_sock failed\n");
-								goto error;
-							}
-							sock_name=&send_sock->address_str;
-							portname=&send_sock->port_no_str;
-						}
-						new=new_str(sock_name->s, sock_name->len,
-								&last, &total_len );
-						if (!new) goto error;
-						/* inefficient - FIXME --andrei*/
-						new=new_str(":", 1, &last, &total_len);
-						if (!new) goto error;
-						new=new_str(portname->s, portname->len,
-								&last, &total_len );
-						if (!new) goto error;
-						/* keep going ... */
-						begin=needle=d+1;hf_avail-=frag_len+2;
-						continue;
-					default:
-						/* no valid substitution char -- keep going */
-						hf_avail-=frag_len+1;
-						needle=d;
-				}
-			} /* possible substitute */
-		} /* substitution loop */
-		/* proceed to next header */
-		/* new=new_str(CRLF, CRLF_LEN, &last, &total_len );
-		if (!new) goto error; */
-		DBG("DEBUG: get_hfblock: one more hf processed\n");
-	} /* header loop */
-
-
-	/* construct a single header block now */
-	ret=pkg_malloc(total_len);
-	if (!ret) {
-		LOG(L_ERR, "ERROR: get_hfblock no pkg mem for hf block\n");
-		goto error;
-	}
-	i=sl.next;
-	dst=ret;
-	while(i) {
-		foo=i;
-		i=i->next;
-		memcpy(dst, foo->s.s, foo->s.len);
-		dst+=foo->s.len;
-		pkg_free(foo);
-	}
-	*l=total_len;
-	return ret;
-
-error:
-	i=sl.next;
-	while(i) {
-		foo=i;
-		i=i->next;
-		pkg_free(foo);
-	}
-	*l=0;
-	return 0;
-}
-
-
-/* syntax:
-
-	:t_uac:[file] EOL
-	method EOL
-	r-uri EOL 
-	dst EOL 				// ("." if no outbound server used)
-							// must be used with dialogs/lr
-	<EOL separated HFs>+	// From and To must be present at least;
-							// dialog-apps must include tag in From
- 							// (an ephemeral is appended otherwise)
-							// and supply CSeq/CallId
-	.[EOL]
-	[body] 
-	.EOL
-
-
-	there is also the possibility to have server placed its
-    hostname:portnumber in header fields -- just put double
-	exclamation mark in any of the optional header fields
-	(i.e., any but From/To/CallID,CSeq), they will be 
-	substituted hn:pn
-
-Example:
-
-sc fifo t_uac_dlg MESSAGE sip:[email protected] \
-	. \ # no outbound proxy
-	'From:[email protected];tagd=123'  \ # no to-tag -> ephemeral
-	'To:[email protected]' \
-	'Foo: sip:user@!! '  \ # expansion here
-	'CSEQ: 11 MESSAGE   ' \
-	. \ # EoH
-	.	# empty body
----
-U 192.168.2.16:5060 -> 192.168.2.1:5060
-MESSAGE sip:[email protected] SIP/2.0..
-Via: SIP/2.0/UDP 192.168.2.16;branch=z9hG4bK760c.922ea6a1.0..
-To: [email protected]..
-From: [email protected];tagd=123;tag=5405e669bc2980663aed2624dc31396f-fa77..
-CSeq: 11 MESSAGE..
-Call-ID: [email protected]..
-Content-Length: 0..
-User-Agent: Sip EXpress router (0.8.11pre4-tcp1-locking (i386/linux))..
-Foo: sip:[email protected]:5060..
-..
-
-
-*/
-
-
-/*
- * Make sure that the FIFO user created the message
- * correctly
- */
-static inline int fifo_check_msg(struct sip_msg* msg, str* method, char* resp, str* body, 
-				 int* fromtag, int *cseq_is, int* cseq, str* callid)
-{
-	struct to_body* parsed_from;
-	struct cseq_body *parsed_cseq;
-	int i;
-	char c;
-
-	if (body->len && !msg->content_type) {
-		fifo_uac_error(resp, 400, "Content-Type missing");
-		return -1;
-	}
-
-	if (body->len && msg->content_length) {
-		fifo_uac_error(resp, 400, "Content-Length disallowed");
-		return -2;
-	}
-
-	if (!msg->to) {
-		fifo_uac_error(resp, 400, "To missing");
-		return -3;
-	}
-
-	if (!msg->from) {
-		fifo_uac_error(resp, 400, "From missing");
-		return -4;
-	}
-
-	     /* we also need to know if there is from-tag and add it otherwise */
-	if (parse_from_header(msg) < 0) {
-		fifo_uac_error(resp, 400, "Error in From");
-		return -5;
-	}
-
-	parsed_from = (struct to_body*)msg->from->parsed;
-	*fromtag = parsed_from->tag_value.s && parsed_from->tag_value.len;
-
-	*cseq = 0;
-	if (msg->cseq && (parsed_cseq = get_cseq(msg))) {
-		*cseq_is = 1;
-		for (i = 0; i < parsed_cseq->number.len; i++) {
-			c = parsed_cseq->number.s[i];
-			if (c >= '0' && c <= '9' ) *cseq = (*cseq) * 10 + c - '0';
-			else {
-			        DBG("found non-numerical in CSeq: <%i>='%c'\n",(unsigned int)c,c);
-				fifo_uac_error(resp, 400, "non-numerical CSeq");
-				return -6;
-			}
-		}
-		
-		if (parsed_cseq->method.len != method->len 
-		    || memcmp(parsed_cseq->method.s, method->s, method->len) !=0 ) {
-			fifo_uac_error(resp, 400, "CSeq method mismatch");
-			return -7;
-		}
-	} else {
-		*cseq_is = 0;
-	}
-
-	if (msg->callid) {
-		callid->s = msg->callid->body.s;
-		callid->len = msg->callid->body.len;
-	} else {
-		callid->s = 0;
-		callid->len = 0;
-	}
-
-	return 0;
-}
-
-
-#define FIFO_ROUTE_PREFIX "Route: "
-#define FIFO_ROUTE_SEPARATOR ", "
-
-static inline void print_routes(FILE* out, dlg_t* _d)
-{
-	rr_t* ptr;
-
-	ptr = _d->hooks.first_route;
-
-	if (ptr) {
-		fprintf(out, FIFO_ROUTE_PREFIX);
-	} else {
-		fprintf(out, ".\n");
-		return;
-	}
-
-	while(ptr) {
-		fprintf(out, "%.*s", ptr->len, ptr->nameaddr.name.s);
-
-		ptr = ptr->next;
-		if (ptr) {
-			fprintf(out, FIFO_ROUTE_SEPARATOR);
-		}
-	} 
-
-	if (_d->hooks.last_route) {
-		fprintf(out, FIFO_ROUTE_SEPARATOR "<");
-		fprintf(out, "%.*s", _d->hooks.last_route->len, _d->hooks.last_route->s);
-		fprintf(out, ">");
-	}
-
-	if (_d->hooks.first_route) {
-		fprintf(out, CRLF);
-	}
-}
-
-
-static inline int print_uris(FILE* out, struct sip_msg* reply)
-{
-	dlg_t* dlg;
-	
-	dlg = (dlg_t*)shm_malloc(sizeof(dlg_t));
-	if (!dlg) {
-		LOG(L_ERR, "print_uris(): No memory left\n");
-		return -1;
-	}
-
-	memset(dlg, 0, sizeof(dlg_t));
-	if (dlg_response_uac(dlg, reply) < 0) {
-		LOG(L_ERR, "print_uris(): Error while creating dialog structure\n");
-		free_dlg(dlg);
-		return -2;
-	}
-
-	if (dlg->state != DLG_CONFIRMED) {
-		fprintf(out, ".\n.\n.\n");
-		free_dlg(dlg);
-		return 0;
-	}
-
-	if (dlg->hooks.request_uri->s) {	
-		fprintf(out, "%.*s\n", dlg->hooks.request_uri->len, dlg->hooks.request_uri->s);
-	} else {
-		fprintf(out, ".\n");
-	}
-	if (dlg->hooks.next_hop->s) {
-		fprintf(out, "%.*s\n", dlg->hooks.next_hop->len, dlg->hooks.next_hop->s);
-	} else {
-		fprintf(out, ".\n");
-	}
-	print_routes(out, dlg);
-	free_dlg(dlg);
-	return 0;
-}
-
-
-static void fifo_callback( struct cell *t, int type, struct tmcb_params *ps )
-{
-	
-	char *filename;
-	FILE* f;
-	str text;
-
-	DBG("DEBUG: fifo UAC completed with status %d\n", ps->code);
-	if (!*ps->param) {
-		LOG(L_INFO, "INFO: fifo UAC completed with status %d\n", ps->code);
-		return;
-	}
-
-	filename=(char *)(*ps->param);
-	if (ps->rpl==FAKED_REPLY) {
-		get_reply_status( &text, ps->rpl, ps->code);
-		if (text.s==0) {
-			LOG(L_ERR, "ERROR: fifo_callback: get_reply_status failed\n");
-			fifo_reply( filename,
-				"500 fifo_callback: get_reply_status failed\n");
-			goto done;
-		}
-		fifo_reply(filename, "%.*s\n", text.len, text.s );
-		pkg_free(text.s);
-	} else {
-		text.s = ps->rpl->first_line.u.reply.reason.s;
-		text.len = ps->rpl->first_line.u.reply.reason.len;
-
-		f = open_reply_pipe(filename);
-		if (!f) return;
-		fprintf(f, "%d %.*s\n", ps->rpl->first_line.u.reply.statuscode, text.len, text.s);
-		print_uris(f, ps->rpl);
-		fprintf(f, "%s\n", ps->rpl->headers->name.s);
-		fclose(f);
-	}
-	DBG("DEBUG: fifo_callback successfully completed\n");
-done:
-        if (ps->code >= 200) {
-	        /* Do not free if we received provisional reply */
-                shm_free(filename);
-        }
-}
-
-
-int fifo_uac(FILE *stream, char *response_file)
-{
-	str method, ruri, nexthop, headers, body, hfb, callid;
-	struct sip_uri puri, pnexthop;
-	struct sip_msg faked_msg;
-	int ret, sip_error, err_ret;
-	int fromtag, cseq_is, cseq;
-	struct cb_data;
-	char err_buf[MAX_REASON_LEN];
-	char* shm_file;
-	dlg_t dlg;
-
-	if (fifo_get_method(stream, response_file, &method) < 0) return 1;
-	if (fifo_get_ruri(stream, response_file, &ruri, &puri) < 0) return 1;
-	if (fifo_get_nexthop(stream, response_file, &nexthop, &pnexthop) < 0) return 1;
-	if (fifo_get_headers(stream, response_file, &headers) < 0) return 1;
-
-	/* use SIP parser to look at what is in the FIFO request */
-	memset(&faked_msg, 0, sizeof(struct sip_msg));
-	faked_msg.len = headers.len; 
-	faked_msg.buf = faked_msg.unparsed = headers.s;
-	if (parse_headers(&faked_msg, HDR_EOH_F, 0) == -1 ) {
-		DBG("DEBUG: fifo_uac: parse_headers failed\n");
-		fifo_uac_error(response_file, 400, "HFs unparseable");
-		goto error;
-	}
-	DBG("DEBUG: fifo_uac: parse_headers succeeded\n");
-
-	if (fifo_get_body(stream, response_file, &body) < 0) goto error;
-	
-	     /* at this moment, we collected all the things we got, let's
-	      * verify user has not forgotten something */
-	if (fifo_check_msg(&faked_msg, &method, response_file, &body, &fromtag, 
-			   &cseq_is, &cseq, &callid) < 0) goto error;
-
-	hfb.s = get_hfblock(nexthop.len ? &nexthop : &ruri, 
-			    faked_msg.headers, &hfb.len, PROTO_UDP);
-	if (!hfb.s) {
-		fifo_uac_error(response_file, 500, "no mem for hf block");
-		goto error;
-	}
-
-	DBG("DEBUG: fifo_uac: EoL -- proceeding to transaction creation\n");
-
-	memset(&dlg, 0, sizeof(dlg_t));
-	     /* Fill in Call-ID, use given Call-ID if
-	      * present and generate it if not present
-	      */
-	if (callid.s && callid.len) dlg.id.call_id = callid;
-	else generate_callid(&dlg.id.call_id);
-	
-	     /* We will not fill in dlg->id.rem_tag because
-	      * if present it will be printed within To HF
-	      */
-	
-	     /* Generate fromtag if not present */
-	if (!fromtag) {
-		generate_fromtag(&dlg.id.loc_tag, &dlg.id.call_id);
-	}
-
-	     /* Fill in CSeq */
-	if (cseq_is) dlg.loc_seq.value = cseq;
-	else dlg.loc_seq.value = DEFAULT_CSEQ;
-	dlg.loc_seq.is_set = 1;
-
-	dlg.loc_uri = faked_msg.from->body;
-	dlg.rem_uri = faked_msg.to->body;
-	dlg.hooks.request_uri = &ruri;
-	dlg.hooks.next_hop = (nexthop.len ? &nexthop : &ruri);
-
-#ifdef XL_DEBUG
-	print_dlg(stderr, &dlg);
-#endif
-
-	/* we got it all, initiate transaction now! */
-	if (fifo_cbp(&shm_file, response_file) < 0) goto error01;
-
-	ret = t_uac(&method, &hfb, &body, &dlg, fifo_callback, shm_file);
-
-	if (ret <= 0) {
-		err_ret = err2reason_phrase(ret, &sip_error, err_buf,
-			sizeof(err_buf), "FIFO/UAC") ;
-		if (err_ret > 0 )
-		{
-			fifo_uac_error(response_file, sip_error, err_buf);
-		} else {
-			fifo_uac_error(response_file, 500, "FIFO/UAC error");
-		}
-	}
-	
- error01:
-	pkg_free(hfb.s);
-	
- error:
-	     /* free_sip_msg(&faked_msg); */
-	if (faked_msg.headers) free_hdr_field_lst(faked_msg.headers);
-	return 1;
-}

+ 0 - 43
modules/tm/uac_fifo.h

@@ -1,43 +0,0 @@
-/*
- * UAC FIFO interface
- *
- * $Id$
- *
- * Copyright (C) 2001-2003 FhG Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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
- *
- */
-
-#ifndef UAC_FIFO_H
-#define UAC_FIFO_H
-
-#include <stdio.h>
-
-
-/*
- * FIFO function for sending messages
- */
-int fifo_uac(FILE *stream, char *response_file);
-
-
-#endif /* UAC_FIFO_H */

+ 0 - 664
modules/tm/uac_unixsock.c

@@ -1,664 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2001-2004 FhG Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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
- */
-
-#include <string.h>
-#include "../../mem/mem.h"
-#include "../../mem/shm_mem.h"
-#include "../../parser/hf.h"
-#include "../../dprint.h"
-#include "../../parser/parse_uri.h"
-#include "../../unixsock_server.h"
-#include "../../parser/msg_parser.h"
-#include "../../parser/parse_to.h"
-#include "../../parser/parse_cseq.h"
-#include "../../parser/parse_from.h"
-#include "../../ut.h"
-#include "uac_unixsock.h"
-#include "config.h"
-#include "ut.h"
-#include "t_hooks.h"
-#include "callid.h"
-#include "uac.h"
-#include "dlg.h"
-
-struct str_list {
-	str s;
-	struct str_list *next;
-};
-
-struct uac_cb_param {
-    
-    str from;
-    str callid;
-    str cseq;
-    struct sockaddr_un addr;
-};
-
-#define skip_hf(_hf) (             \
-    ((_hf)->type == HDR_FROM_T)   || \
-    ((_hf)->type == HDR_TO_T)     || \
-    ((_hf)->type == HDR_CALLID_T) || \
-    ((_hf)->type == HDR_CSEQ_T)      \
-)
-
-
-/*
- * Read the method from the request
- */
-static int get_method(str* method, str* msg)
-{
-	if (unixsock_read_line(method, msg) != 0) {
-		unixsock_reply_asciiz("400 Method expected");
-		unixsock_reply_send();
-		return -1;
-	}
-	DBG("get_method: method: '%.*s'\n", method->len, ZSW(method->s));
-	return 0;
-}
-
-
-/*
- * Read the Request-URI and parse it
- */
-static int get_ruri(str* ruri, struct sip_uri* puri, str* msg)
-{
-	if (unixsock_read_line(ruri, msg) != 0) {
-		unixsock_reply_asciiz("400 Request-URI expected");
-		unixsock_reply_send();
-		return -1;
-	}
-	
-	if (parse_uri(ruri->s, ruri->len, puri) < 0 ) {
-		unixsock_reply_asciiz("400 Request-URI is invalid\n");
-		unixsock_reply_send();
-		return -1;
-	}
-	DBG("get_ruri: '%.*s'\n", ruri->len, ZSW(ruri->s));
-	return 0;
-}
-
-
-/*
- * Read and parse the next hop
- */
-static int get_nexthop(str* nexthop, struct sip_uri* pnexthop, str* msg)
-{
-	if (unixsock_read_line(nexthop, msg) != 0) {
-		unixsock_reply_asciiz("400 Next-hop URI expected\n");
-		unixsock_reply_send();
-		return -1;
-	}
-
-	if (nexthop->len == 1 && nexthop->s[0] == '.' ) {
-		DBG("get_nexthop: next hop empty\n");
-		nexthop->s = 0; 
-		nexthop->len = 0;
-	} else if (parse_uri(nexthop->s, nexthop->len, pnexthop) < 0 ) {
-		unixsock_reply_asciiz("400 Next-hop URI is invalid\n");
-		unixsock_reply_send();
-		return -1;
-	} else {
-		DBG("get_nexthop: '%.*s'\n", nexthop->len, ZSW(nexthop->s));
-	}
-	return 0;
-}
-
-
-/*
- * Read header into a static buffer (it is necessary because
- * the unixsock_read_lineset performs CRLF recovery and thus
- * the result may be longer than the original
- */
-static int get_headers(str* headers, str* msg)
-{
-	static char headers_buf[MAX_HEADER];
-
-	headers->s = headers_buf;
-	headers->len = MAX_HEADER;
-
-	     /* now read and parse header fields */
-	if (unixsock_read_lineset(headers, msg) < 0) {
-		unixsock_reply_asciiz("400 Header fields expected\n");
-		unixsock_reply_send();
-		return -1;
-	}
-
-	DBG("get_headers: %.*s\n", headers->len, ZSW(headers->s));
-	return 0;
-}
-
-
-/*
- * Read the message body
- */
-static int get_body_lines(str* body, str* msg)
-{
-	if (unixsock_read_body(body, msg) < 0) {
-		unixsock_reply_asciiz("400 Body expected\n");
-		unixsock_reply_send();
-		return -1;
-	}
-	DBG("get_body_lines: %.*s\n", body->len,  ZSW(body->s));
-	return 0;
-}
-
-
-/*
- * Make sure that the FIFO user created the message
- * correctly
- */
-static int check_msg(struct sip_msg* msg, str* method, str* body, 
-		     int* fromtag, int *cseq_is, int* cseq, str* callid)
-{
-	struct to_body* parsed_from;
-	struct cseq_body *parsed_cseq;
-	int i;
-	char c;
-
-	if (body->len && !msg->content_type) {
-		unixsock_reply_asciiz("400 Content-Type missing");
-		goto err;
-	}
-
-	if (body->len && msg->content_length) {
-		unixsock_reply_asciiz("400 Content-Length disallowed");
-		goto err;
-	}
-
-	if (!msg->to) {
-		unixsock_reply_asciiz("400 To missing");
-		goto err;
-	}
-
-	if (!msg->from) {
-		unixsock_reply_asciiz("400 From missing");
-		goto err;
-	}
-
-	     /* we also need to know if there is from-tag and add it otherwise */
-	if (parse_from_header(msg) < 0) {
-		unixsock_reply_asciiz("400 Error in From");
-		goto err;
-	}
-
-	parsed_from = (struct to_body*)msg->from->parsed;
-	*fromtag = parsed_from->tag_value.s && parsed_from->tag_value.len;
-
-	*cseq = 0;
-	if (msg->cseq && (parsed_cseq = get_cseq(msg))) {
-		*cseq_is = 1;
-		for (i = 0; i < parsed_cseq->number.len; i++) {
-			c = parsed_cseq->number.s[i];
-			if (c >= '0' && c <= '9' ) {
-				*cseq = (*cseq) * 10 + c - '0';
-			} else {
-			        DBG("check_msg: Found non-numerical in CSeq: <%i>='%c'\n", (unsigned int)c, c);
-				unixsock_reply_asciiz("400 Non-numerical CSeq");
-				goto err;
-			}
-		}
-		
-		if (parsed_cseq->method.len != method->len 
-		    || memcmp(parsed_cseq->method.s, method->s, method->len) !=0 ) {
-			unixsock_reply_asciiz("400 CSeq method mismatch");
-			goto err;
-		}
-	} else {
-		*cseq_is = 0;
-	}
-
-	if (msg->callid) {
-		callid->s = msg->callid->body.s;
-		callid->len = msg->callid->body.len;
-	} else {
-		callid->s = 0;
-		callid->len = 0;
-	}
-	return 0;
-
- err:
-	unixsock_reply_send();
-	return -1;
-}
-
-
-static inline struct str_list *new_str(char *s, int len, struct str_list **last, int *total)
-{
-	struct str_list *new;
-	new = pkg_malloc(sizeof(struct str_list));
-	if (!new) {
-		LOG(L_ERR, "new_str: Not enough mem\n");
-		return 0;
-	}
-	new->s.s = s;
-	new->s.len = len;
-	new->next = 0;
-
-	(*last)->next = new;
-	*last = new;
-	*total += len;
-	return new;
-}
-
-
-static char *get_hfblock(str *uri, struct hdr_field *hf, int *l, int proto) 
-{
-	struct str_list sl, *last, *i, *foo;
-	int p, frag_len, total_len;
-	char *begin, *needle, *dst, *ret, *d;
-	str *sock_name, *portname;
-	union sockaddr_union to_su;
-	struct socket_info* send_sock;
-
-	ret = 0; /* pessimist: assume failure */
-	total_len = 0;
-	last = &sl;
-	last->next = 0;
-	portname = sock_name = 0;
-
-	for (; hf; hf = hf->next) {
-		if (skip_hf(hf)) continue;
-
-		begin = needle = hf->name.s; 
-		p = hf->len;
-
-		     /* substitution loop */
-		while(p) {
-			d = q_memchr(needle, SUBST_CHAR, p);
-			if (!d || d + 1 >= needle + p) { /* nothing to substitute */
-				if (!new_str(begin, p, &last, &total_len)) goto error;
-				break;
-			} else {
-				frag_len = d - begin;
-				d++; /* d not at the second substitution char */
-				switch(*d) {
-				case SUBST_CHAR: /* double SUBST_CHAR: IP */
-					     /* string before substitute */
-					if (!new_str(begin, frag_len, &last, &total_len)) goto error;
-					     /* substitute */
-					if (!sock_name) {
-						send_sock = uri2sock(0, uri, &to_su, proto);
-						if (!send_sock) {
-							LOG(L_ERR, "ERROR: get_hfblock: send_sock failed\n");
-							goto error;
-						}
-						sock_name = &send_sock->address_str;
-						portname = &send_sock->port_no_str;
-					}
-					if (!new_str(sock_name->s, sock_name->len, &last, &total_len)) goto error;
-					     /* inefficient - FIXME --andrei*/
-					if (!new_str(":", 1, &last, &total_len)) goto error;
-					if (!new_str(portname->s, portname->len, &last, &total_len)) goto error;
-					     /* keep going ... */
-					begin = needle = d + 1;
-					p -= frag_len + 2;
-					continue;
-				default:
-					     /* no valid substitution char -- keep going */
-					p -= frag_len + 1;
-					needle = d;
-				}
-			} /* possible substitute */
-		} /* substitution loop */
-		DBG("get_hfblock: one more hf processed\n");
-	} /* header loop */
-	
-	     /* construct a single header block now */
-	ret = pkg_malloc(total_len);
-	if (!ret) {
-		LOG(L_ERR, "get_hfblock: no pkg mem for hf block\n");
-		goto error;
-	}
-	i = sl.next;
-	dst = ret;
-	while(i) {
-		foo = i;
-		i = i->next;
-		memcpy(dst, foo->s.s, foo->s.len);
-		dst += foo->s.len;
-		pkg_free(foo);
-	}
-	*l = total_len;
-	return ret;
-	
- error:
-	i = sl.next;
-	while(i) {
-		foo = i;
-		i = i->next;
-		pkg_free(foo);
-	}
-	*l = 0;
-	return 0;
-}
-
-
-#define FIFO_ROUTE_PREFIX "Route: "
-#define FIFO_ROUTE_SEPARATOR ", "
-
-static void print_routes(dlg_t* _d)
-{
-	rr_t* ptr;
-
-	ptr = _d->hooks.first_route;
-
-	if (ptr) {
-		unixsock_reply_asciiz(FIFO_ROUTE_PREFIX);
-	} else {
-		unixsock_reply_asciiz(".\n");
-		return;
-	}
-
-	while(ptr) {
-		unixsock_reply_printf("%.*s", ptr->len, ptr->nameaddr.name.s);
-
-		ptr = ptr->next;
-		if (ptr) {
-			unixsock_reply_asciiz(FIFO_ROUTE_SEPARATOR);
-		}
-	} 
-
-	if (_d->hooks.last_route) {
-		unixsock_reply_asciiz(FIFO_ROUTE_SEPARATOR "<");
-		unixsock_reply_printf("%.*s", _d->hooks.last_route->len, _d->hooks.last_route->s);
-		unixsock_reply_asciiz(">");
-	}
-
-	if (_d->hooks.first_route) {
-		unixsock_reply_asciiz(CRLF);
-	}
-}
-
-
-
-static int print_uris(struct sip_msg* reply)
-{
-	dlg_t* dlg;
-	
-	dlg = (dlg_t*)shm_malloc(sizeof(dlg_t));
-	if (!dlg) {
-		LOG(L_ERR, "print_uris: No memory left\n");
-		return -1;
-	}
-
-	memset(dlg, 0, sizeof(dlg_t));
-	if (dlg_response_uac(dlg, reply) < 0) {
-		LOG(L_ERR, "print_uris: Error while creating dialog structure\n");
-		free_dlg(dlg);
-		return -2;
-	}
-
-	if (dlg->state != DLG_CONFIRMED) {
-		unixsock_reply_asciiz(".\n.\n.\n");
-		free_dlg(dlg);
-		return 0;
-	}
-
-	if (dlg->hooks.request_uri->s) {	
-		unixsock_reply_printf("%.*s\n", dlg->hooks.request_uri->len, dlg->hooks.request_uri->s);
-	} else {
-		unixsock_reply_asciiz(".\n");
-	}
-	if (dlg->hooks.next_hop->s) {
-		unixsock_reply_printf("%.*s\n", dlg->hooks.next_hop->len, dlg->hooks.next_hop->s);
-	} else {
-		unixsock_reply_asciiz(".\n");
-	}
-	print_routes(dlg);
-	free_dlg(dlg);
-	return 0;
-}
-
-static int new_uac_cb_param(struct uac_cb_param** param,
-			    struct sip_msg* msg, 
-			    struct sockaddr_un* addr)
-{
-    int len=0;
-    struct uac_cb_param* p_param=0;
-
-    if(msg && addr) {
-
-	*param = shm_malloc(sizeof(struct uac_cb_param));
-	if (!*param) {
-	    unixsock_reply_asciiz("500 No shared memory");
-	    return -1;
-	}
-	
-	p_param = *param;
-
-	len += msg->from->len;
-	len += msg->callid->len;
-	len += msg->cseq->len;
-
-	p_param->from.s = shm_malloc(len);
-	if(!p_param->from.s){
-
-	    shm_free(p_param);
-	    *param = 0;
-
-	    unixsock_reply_asciiz("500 No shared memory");
-	    return -1;
-	}
-
-	memcpy(p_param->from.s,msg->from->name.s,msg->from->len);
-	p_param->from.len = msg->from->len;
-
-	p_param->callid.s = p_param->from.s + p_param->from.len;
-	memcpy(p_param->callid.s,msg->callid->name.s,msg->callid->len);
-	p_param->callid.len = msg->callid->len;
-
-	p_param->cseq.s = p_param->callid.s + p_param->callid.len;
-	memcpy(p_param->cseq.s,msg->cseq->name.s,msg->cseq->len);
-	p_param->cseq.len = msg->cseq->len;
-
-	memcpy(&(p_param->addr), addr, sizeof(struct sockaddr_un));
-
-    } else {
-	*param = 0;
-    }
-    return 0;
-}
-
-static void free_uac_cb_param(struct uac_cb_param* param)
-{
-    shm_free(param->from.s);
-    shm_free(param);
-}
-
-static void callback(struct cell *t, int type, struct tmcb_params *ps)
-{
-	struct sockaddr_un*  to;
-	struct uac_cb_param* param=0;
-
-	str text;
-
-	if (!*ps->param) {
-		LOG(L_INFO, "INFO: fifo UAC completed with status %d\n", ps->code);
-		return;
-	}
-	
-	param = (struct uac_cb_param*)(*ps->param);
-	to = &param->addr;
-	unixsock_reply_reset();
-
-	if (ps->rpl == FAKED_REPLY) {
-		get_reply_status(&text, ps->rpl, ps->code);
-		if (text.s == 0) {
-			LOG(L_ERR, "callback: get_reply_status failed\n");
-			unixsock_reply_asciiz("500 callback: get_reply_status failed\n");
-			goto done;
-		}
-
-		unixsock_reply_printf("%.*s\n.\n.\n.\n", text.len, text.s);
-
-		unixsock_reply_printf("%.*s", param->from.len, param->from.s);
-		unixsock_reply_printf("%.*s", param->callid.len, param->callid.s);
-		unixsock_reply_printf("%.*s\n", param->cseq.len, param->cseq.s);
-
-		pkg_free(text.s);
-
-	} else {
-		text.s = ps->rpl->first_line.u.reply.reason.s;
-		text.len = ps->rpl->first_line.u.reply.reason.len;
-
-		     /* FIXME: check for return values here */
-		unixsock_reply_printf("%d %.*s\n", ps->rpl->first_line.u.reply.statuscode, text.len, text.s);
-		print_uris(ps->rpl);
-		unixsock_reply_printf("%s\n", ps->rpl->headers->name.s);
-	}
-done:
-	unixsock_reply_sendto(to);
-
-        if (ps->code >= 200) {
-
-	    free_uac_cb_param(param);
-	    *ps->param=0; /* 0 it so the callback won't do 
-			     anything if called for a retransmission */
-	}
-}
-
-
-#if 0
-/*
- * Create shm_copy of filename
- */
-static int duplicate_addr(struct sockaddr_un** dest, struct sockaddr_un* addr)
-{
-	if (addr) {
-		*dest = shm_malloc(sizeof(*addr));
-		if (!*dest) {
-			unixsock_reply_asciiz("500 No shared memory");
-			return -1;
-		}
-		memcpy(*dest, addr, sizeof(*addr));
-	} else {
-		*dest = 0;
-	}
-	return 0;
-}
-#endif
-
-
-int unixsock_uac(str* msg)
-{
-	str method, ruri, nexthop, headers, body, hfb, callid;
-	struct sip_uri puri, pnexthop;
-	struct sip_msg faked_msg;
-	int ret, sip_error, err_ret, fromtag, cseq_is, cseq;
-	char err_buf[MAX_REASON_LEN];
-	struct uac_cb_param* shm_param;
-	dlg_t dlg;
-
-	if (get_method(&method, msg) < 0) return -1;
-	if (get_ruri(&ruri, &puri, msg) < 0) return -1;
-	if (get_nexthop(&nexthop, &pnexthop, msg) < 0) return -1;
-	if (get_headers(&headers, msg) < 0) return -1;
-
-	     /* use SIP parser to look at what is in the FIFO request */
-	memset(&faked_msg, 0, sizeof(struct sip_msg));
-	faked_msg.len = headers.len; 
-	faked_msg.buf = faked_msg.unparsed = headers.s;
-	if (parse_headers(&faked_msg, HDR_EOH_F, 0) == -1 ) {
-		unixsock_reply_asciiz("400 HFs unparsable\n");
-		unixsock_reply_send();
-		goto error;
-	}
-
-	if (get_body_lines(&body, msg) < 0) goto error;
-	
-	     /* at this moment, we collected all the things we got, let's
-	      * verify user has not forgotten something */
-	if (check_msg(&faked_msg, &method, &body, &fromtag, 
-		      &cseq_is, &cseq, &callid) < 0) goto error;
-
-	hfb.s = get_hfblock(nexthop.len ? &nexthop : &ruri, 
-			    faked_msg.headers, &hfb.len, PROTO_UDP);
-	if (!hfb.s) {
-		unixsock_reply_asciiz("500 No memory for HF block");
-		unixsock_reply_send();
-		goto error;
-	}
-
-	memset(&dlg, 0, sizeof(dlg_t));
-	     /* Fill in Call-ID, use given Call-ID if
-	      * present and generate it if not present
-	      */
-	if (callid.s && callid.len) dlg.id.call_id = callid;
-	else generate_callid(&dlg.id.call_id);
-	
-	     /* We will not fill in dlg->id.rem_tag because
-	      * if present it will be printed within To HF
-	      */
-	
-	     /* Generate fromtag if not present */
-	if (!fromtag) {
-		generate_fromtag(&dlg.id.loc_tag, &dlg.id.call_id);
-	}
-	
-	     /* Fill in CSeq */
-	if (cseq_is) dlg.loc_seq.value = cseq;
-	else dlg.loc_seq.value = DEFAULT_CSEQ;
-	dlg.loc_seq.is_set = 1;
-
-	dlg.loc_uri = faked_msg.from->body;
-	dlg.rem_uri = faked_msg.to->body;
-	dlg.hooks.request_uri = &ruri;
-	dlg.hooks.next_hop = (nexthop.len ? &nexthop : &ruri);
-	
-	if (new_uac_cb_param(&shm_param,&faked_msg,unixsock_sender_addr()) < 0) {
-	    
-	    unixsock_reply_send();
-	    goto error01;
-	}
-
-	     /* we got it all, initiate transaction now! */
-	ret = t_uac(&method, &hfb, &body, &dlg, callback, shm_param);
-	if (ret <= 0) {
-		err_ret = err2reason_phrase(ret, &sip_error, err_buf, sizeof(err_buf), "FIFO/UAC");
-		if (err_ret > 0) {
-			unixsock_reply_printf("%d %s", sip_error, err_buf);
-		} else {
-			unixsock_reply_asciiz("500 UNIXSOCK/UAC error");
-		}
-		unixsock_reply_send();
-		free_uac_cb_param(shm_param);
-		goto error01;
-	}
-
-	     /* Do not free shm_sockaddr here, it will be used
-	      * by the callback
-	      */
-	pkg_free(hfb.s);
-	if (faked_msg.headers) free_hdr_field_lst(faked_msg.headers);
-	return 0;
-	
- error01:
-	pkg_free(hfb.s);
- error:
-	if (faked_msg.headers) free_hdr_field_lst(faked_msg.headers);
-	return -1;
-}

+ 0 - 35
modules/tm/uac_unixsock.h

@@ -1,35 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2001-2004 FhG Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * 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
- */
-
-#ifndef _UAC_UNIXSOCK_H
-#define _UAC_UNIXSOCK_H
-
-#include "../../str.h"
-
-int unixsock_uac(str* msg);
-
-#endif /* _UAC_UNIXSOCK_H */