adding interoperability with TurboSIP
authorJiri Kuthan <jiri@iptel.org>
Sat, 12 Jan 2002 02:33:31 +0000 (02:33 +0000)
committerJiri Kuthan <jiri@iptel.org>
Sat, 12 Jan 2002 02:33:31 +0000 (02:33 +0000)
Makefile.defs
modules/tm/config.h
modules/tm/t_lookup.c
msg_translator.c
test/tx.cfg

index 4d632eb..8a36f91 100644 (file)
@@ -53,8 +53,9 @@ ARCH = $(shell uname -s)
 
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
         -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
-       -DEXTRA_DEBUG \
-       -DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
+       -DVQ_MALLOC -DBRUT_HACK
+       #-DEXTRA_DEBUG -DBRUT_HACK \
+       #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
          #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG
          #-DNO_DEBUG #-DDBG_QM_MALLOC
 #-DEXTRA_DEBUG
@@ -64,9 +65,9 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 #-DNO_DEBUG#-DSTATS -DNO_DEBUG 
 #-DNO_LOG
 
-PROFILE=  -pg #set this if you want profiling
-mode = debug
-#mode = release
+#PROFILE=  -pg #set this if you want profiling
+#mode = debug
+mode = release
 
 # platform dependent settings
 
index 182d259..a9792e1 100644 (file)
 */
 #define REPLY_OVERBUFFER_LEN 160
 
+/* character which separates individual parts of MPLS-ized branch */
+#ifdef BRUT_HACK
+#      define BRANCH_SEPARATOR 'X'
+#else
+#      define BRANCH_SEPARATOR '.'
+#endif
+
 #endif
index 228aef8..63c9741 100644 (file)
@@ -3,13 +3,14 @@
  *
  */
 
-#include "hash_func.h"
-#include "t_funcs.h"
 #include "../../dprint.h"
 #include "../../config.h"
 #include "../../parser_f.h"
 #include "../../ut.h"
 #include "../../timer.h"
+#include "hash_func.h"
+#include "t_funcs.h"
+#include "config.h"
 
 static int reverse_hex2int( char *c, int len )
 {
@@ -221,25 +222,25 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
    scan_space=p_msg->via1->branch->value.len;
 
    /* loop detection ... ignore */
-   n=eat_token2_end( p, p+scan_space, '.');
+   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR );
    scan_space-=n-p;
-   if (n==p || scan_space<2 || *n!='.') goto nomatch2;
+   if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
    p=n+1; scan_space--;
 
    /* hash_id */
-   n=eat_token2_end( p, p+scan_space, '.');
+   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
    hashl=n-p;
    scan_space-=hashl;
-   if (!hashl || scan_space<2 || *n!='.') goto nomatch2;
+   if (!hashl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
    hashi=p;
    p=n+1;scan_space--;
 
 
    /* sequence id */
-   n=eat_token2_end( p, p+scan_space, '.');
+   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
    synl=n-p;
    scan_space-=synl;
-   if (!synl || scan_space<2 || *n!='.') goto nomatch2;
+   if (!synl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
    syni=p;
    p=n+1;scan_space--;
 
@@ -377,11 +378,11 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
        begin=p_msg->add_to_branch_s+p_msg->add_to_branch_len;
        orig_size = size=MAX_BRANCH_PARAM_LEN - p_msg->add_to_branch_len;
 
-       if (size) { *begin='.'; begin++; size--; } else return -1;
+       if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
        if (int2reverse_hex( &begin, &size, trans->hash_index)==-1) return -1;
-       if (size) { *begin='.'; begin++; size--; } else return -1;
+       if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
        if (int2reverse_hex( &begin, &size, trans->label)==-1) return -1;
-       if (size) { *begin='.'; begin++; size--; } else return -1;
+       if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
        if (int2reverse_hex( &begin, &size, branch)==-1) return -1;
 
        p_msg->add_to_branch_len+=(orig_size-size);
index 5a25eef..cbf9a37 100644 (file)
@@ -540,6 +540,9 @@ char * build_res_buf_from_sip_req(  unsigned int code ,
        unsigned int       len,foo;
        struct hdr_field  *hdr;
        int                       i;
+#ifdef BRUT_HACK
+       struct hdr_field  *to, *from, *callid, *cseq, *via;
+#endif
 
        /* force parsing all headers -- we want to return all
        Via's in the reply and they may be scattered down to the
@@ -553,10 +556,22 @@ char * build_res_buf_from_sip_req(        unsigned int code ,
        len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ + strlen(text) + CRLF_LEN/*new line*/;
        /*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
        for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
+#ifdef BRUT_HACK
+       {
+               len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
+               if ( hdr->type==HDR_VIA ) via = hdr;
+               else if ( hdr->type==HDR_FROM) from = hdr;
+               else if (hdr->type==HDR_CALLID) callid = hdr;
+               else if ( hdr->type==HDR_TO) to = hdr;
+               else if ( hdr->type==HDR_CSEQ) cseq = hdr;
+               else len-=((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
+       }
+#else
                if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM ||
                                hdr->type==HDR_CALLID || hdr->type==HDR_TO ||
                                hdr->type==HDR_CSEQ )
                        len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
+#endif
        /* end of message */
        len += CRLF_LEN; /*new line*/
 
@@ -585,6 +600,20 @@ char * build_res_buf_from_sip_req( unsigned int code ,
        memcpy( p, CRLF, CRLF_LEN );
        p+=CRLF_LEN;
        /* headers*/
+#ifdef BRUT_HACK
+#define        COPY_HF(_hf) memcpy(p, msg->orig+(_hf->name.s-msg->buf), \
+                       ((_hf->body.s+_hf->body.len ) - \
+                       _hf->name.s )); \
+                       p+=((_hf->body.s+_hf->body.len)-_hf->name.s ) ; \
+                       memcpy( p, CRLF, CRLF_LEN ); \
+                       p+=CRLF_LEN;
+
+       COPY_HF(via);
+       COPY_HF(from);
+       COPY_HF(to);
+       COPY_HF(callid);
+       COPY_HF(cseq);
+#else
        for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
                if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM ||
                hdr->type==HDR_CALLID || hdr->type==HDR_TO || hdr->type==HDR_CSEQ )
@@ -596,6 +625,7 @@ char * build_res_buf_from_sip_req(  unsigned int code ,
                        memcpy( p, CRLF, CRLF_LEN );
                        p+=CRLF_LEN;
                }
+#endif
 
        memcpy( p, CRLF, CRLF_LEN );
        p+=CRLF_LEN;
index 94f7527..f5fd680 100644 (file)
@@ -4,21 +4,21 @@
 # $ID: $
 #
 
-debug=4          # debug level (cmd line: -dddddddddd)
+debug=1          # debug level (cmd line: -dddddddddd)
 fork=yes          # (cmd. line: -D)
 #fork=no
-log_stderror=yes # (cmd line: -E)
-#log_stderror=no       # (cmd line: -E)
+#log_stderror=yes # (cmd line: -E)
+log_stderror=no        # (cmd line: -E)
 
 
-children=2
+children=8
 check_via=yes     # (cmd. line: -v)
 dns=on           # (cmd. line: -r)
 rev_dns=yes      # (cmd. line: -R)
 port=5080
 #listen=127.0.0.1
 listen=195.37.77.101
-loop_checks=1
+loop_checks=0
 # for more info: sip_router -h
 
 #modules
@@ -74,7 +74,7 @@ route[0]{
                                };
                        } else {
                                log("SER: replying\n");
-                               if (! t_send_reply("100", "trying -- your call is important to us")
+                               if (! t_send_reply("100", "Trying")
                                        ){
                                        log("SER: ERROR: t_send_reply (100)\n");
                                } else log("SER: t_send_reply ok\n");
@@ -84,7 +84,7 @@ route[0]{
                                        log("SER:ERROR: t_forward (..., 5555)\n");
                                } else log("SER: t_forward ok\n");
                        } else if (method=="BYE") {
-                               if (! t_forward("bat.iptel.org", "5090")){
+                               if (! t_forward("bat.iptel.org", "5000")){
                                        log("SER:ERROR: t_forward (..., 5555)\n");
                                } else log("SER: t_forward ok\n");
                        } else log("SER: ERROR unknwon request\n");