Prechádzať zdrojové kódy

*** empty log message ***

Bogdan-Andrei Iancu 23 rokov pred
rodič
commit
0498ceb931
5 zmenil súbory, kde vykonal 54 pridanie a 25 odobranie
  1. 3 0
      modules/tm/sip_msg.c
  2. 12 1
      msg_parser.c
  3. 1 0
      msg_parser.h
  4. 13 2
      msg_translator.c
  5. 25 22
      test/th-uri.cfg

+ 3 - 0
modules/tm/sip_msg.c

@@ -97,6 +97,9 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
       lump_chain = lump_chain->next;
    }
 
+   /**/
+
+
    p=(char *)sh_malloc(len);foo=p;
    if (!p)
    {

+ 12 - 1
msg_parser.c

@@ -13,6 +13,7 @@
 #include "ut.h"
 #include "error.h"
 #include "dprint.h"
+#include "data_lump_rpl.h"
 #include "mem/mem.h"
 
 #ifdef DEBUG_DMALLOC
@@ -771,7 +772,16 @@ void free_uri(struct sip_uri* u)
 	}
 }
 
-
+void free_reply_lump( struct lump_rpl *lump)
+{
+	struct lump_rpl *foo, *bar;
+	for(foo=lump;foo;)
+	{
+		bar=foo->next;
+		free_lump_rpl(foo);
+		foo = bar;
+	}
+}
 
 void free_via_param_list(struct via_param* vp)
 {
@@ -855,6 +865,7 @@ void free_sip_msg(struct sip_msg* msg)
 	if (msg->headers)     free_hdr_field_lst(msg->headers);
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
 	if (msg->repl_add_rm) free_lump_list(msg->repl_add_rm);
+	if (msg->reply_lump)   free_reply_lump(msg->reply_lump);
 	pkg_free(msg->orig);
 	/* don't free anymore -- now a pointer to a static buffer */
 #	ifdef DYN_BUF

+ 1 - 0
msg_parser.h

@@ -199,6 +199,7 @@ struct sip_msg{
 
 	struct lump* add_rm;      /* used for all the forwarded messages */
 	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
+	struct lump_rpl *reply_lump;
 
 	/* str add_to_branch; */ /* whatever whoever want to append to branch comes here */
 	char add_to_branch_s[MAX_BRANCH_PARAM_LEN];

+ 13 - 2
msg_translator.c

@@ -10,6 +10,7 @@
 #include "dprint.h"
 #include "config.h"
 #include "md5utils.h"
+#include "data_lump_rpl.h"
 #include <netdb.h>
 
 
@@ -550,6 +551,7 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
 	char                    *buf, *p;
 	unsigned int       len,foo;
 	struct hdr_field  *hdr;
+	struct lump_rpl  *lump;
 	int                       i;
 	str                        *tag_str;
 
@@ -579,6 +581,9 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
 			case HDR_CSEQ:
 				len += ((hdr->body.s+hdr->body.len )-hdr->name.s )+CRLF_LEN;
 		}
+	/*lumps length*/
+	for(lump=msg->reply_lump;lump;lump=lump->next)
+		len += lump->text.len;
 	/*content length header*/
 	len +=CONTENT_LEN_LEN + CRLF_LEN;
 	/* end of message */
@@ -588,7 +593,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
 	buf = (char*) malloc( len+1 );
 	if (!buf)
 	{
-		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: out of memory\n");
+		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: out of memory "
+			" ; needs %d\n",len);
 		goto error;
 	}
 
@@ -640,7 +646,12 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
 					((hdr->body.s+hdr->body.len )-hdr->name.s ),msg);
 				append_str( p, CRLF,CRLF_LEN,msg);
 		}
-
+	/*lumps*/
+	for(lump=msg->reply_lump;lump;lump=lump->next)
+	{
+		memcpy(p,lump->text.s,lump->text.len);
+		p += lump->text.len;
+	}
 	/* content length header*/
 	memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN );
 	p+=CONTENT_LEN_LEN;

+ 25 - 22
test/th-uri.cfg

@@ -5,7 +5,7 @@
 #
 
 
-debug=3          # debug level (cmd line: -dddddddddd)
+debug=9          # debug level (cmd line: -dddddddddd)
 #fork=yes          # (cmd. line: -D)
 fork=no
 log_stderror=yes # (cmd line: -E)
@@ -18,19 +18,22 @@ dns=off           # (cmd. line: -r)
 rev_dns=off      # (cmd. line: -R)
 #port=5070
 #listen=10.0.0.179
-listen=192.168.57.33
+#listen=192.168.57.33
 loop_checks=0
 # for more info: sip_router -h
 
 #modules
 #loadmodule "modules/print/print.so"
+loadmodule "modules/textops/textops.so"
 loadmodule "modules/tm/tm.so"
 #loadmodule "modules/rr/rr.so"
 loadmodule "modules/maxfwd/maxfwd.so"
-#loadmodule "modules/sl/sl.so"
+loadmodule "modules/sl/sl.so"
+loadmodule "modules/cpl/cpl.so"
 
 
 route{
+             sl_filter_ACK();
 
              if ( mf_is_maxfwd_present() )
              {
@@ -48,25 +51,25 @@ route{
              };
 
 
-             #if (method=="INVITE")
-             #{
-                 #sl_send_reply("404","Not found");
-                 #drop();
-              #  log("SER : runing CPL!! :)\n");
-              #  if ( !cpl_run_script() )
-               # {
-               #    log("SER : Error during running CPL script!\n");
-               # }else{
-                #   if ( cpl_is_response_reject() )
-                  # {
-                    #   t_add_transaction();
-                      # t_send_reply("486","I am not available!");
-                       #drop();
-                 #  }else if ( cpl_is_response_redirect() ) {
-                   #      log("SER : redirect\n");
-                  # };
-               # };
-             #};
+             if (method=="INVITE")
+             {
+                log("SER : runing CPL!! :)\n");
+                if ( !cpl_run_script() )
+                {
+                   log("SER : Error during running CPL script!\n");
+                }else{
+                   if ( cpl_is_response_reject() )
+                   {
+                       sl_send_reply("603","I am not available!");
+                       drop();
+                   }else if ( cpl_is_response_redirect() ) {
+                       log("SER : redirect\n");
+                       cpl_update_contact();
+                       sl_send_reply("302","Moved temporarily");
+                       drop();
+                   };
+                };
+             };
 
            #  if ( !rewriteFromRoute() )
             # {