various small fixes
authorJiri Kuthan <jiri@iptel.org>
Mon, 10 Jun 2002 19:00:19 +0000 (19:00 +0000)
committerJiri Kuthan <jiri@iptel.org>
Mon, 10 Jun 2002 19:00:19 +0000 (19:00 +0000)
Makefile
Makefile.defs
modules/tm/sip_msg.c
modules/tm/t_msgbuilder.c
modules/tm/t_thandlers.c
receive.c
test/bye00.sip

index 0939c82..358ca63 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,9 +10,9 @@ auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
 #include  source related defs
 include Makefile.sources
 
-exclude_modules=CVS mysql 
+exclude_modules=CVS 
 #mysql auth rr
-static_modules=
+static_modules=tm
 static_modules_path=$(addprefix modules/, $(static_modules))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
 extra_objs=$(extra_sources:.c=.o)
index 1f1a2f0..747501c 100644 (file)
@@ -1,4 +1,8 @@
+<<<<<<< Makefile.defs
 # $Id$
+=======
+# $Id$
+>>>>>>> 1.99
 #
 # makefile defs (CC, LD,a.s.o)
 #
@@ -7,7 +11,7 @@
 #version number
 VERSION = 0
 PATCHLEVEL = 8
-SUBLEVEL = 8
+SUBLEVEL = 7
 EXTRAVERSION = -3-ipv6
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
@@ -74,22 +78,21 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
 # -DNEW_HNAME
 #              32-bit header name parsing; turn off for lower speed ;-) or debugging;
 #              to become non-optional if fast and stable
-# -DSILENT_FR
+# -SILENT_FR
 #              if defined, when FR timer hits (in tm) cancel is sent only if forking
 #              if used; otherwise, just delete the transaction without doing anything
-# -DUSE_IPV6
-#              compiles ipv6 support
 
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
         -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
-        -DDNS_IP_HACK  -DPKG_MALLOC \
+        -DPKG_MALLOC \
         -DF_MALLOC \
         -DSHM_MEM  -DSHM_MMAP \
         -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
         -DWAIT -DNEW_HNAME \
+        -DSILENT_FR \
         -DUSE_IPV6 \
-        -DVERY_NOISY_REPLIES\
-        #-DSILENT_FR \
+        -DNOISY_REPLIES -DVERY_NOISY_REPLIES\
+        #-DUSE_SYNONIM\
         #-DNO_DEBUG \
         #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
         #-DNOSMP \
@@ -230,7 +233,7 @@ ifeq        ($(ARCH), sparc64)
 ifeq           ($(CC_NAME), gcc)
                                #common stuff
                                CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
-                                       -Wall #-Wmissing-prototypes \
+                                       #-Wmissing-prototypes \
                                #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
                                        #use 32bit for now
@@ -318,7 +321,7 @@ endif
        # -andrei
 else   #mode,release
 ifeq   ($(CC_NAME), gcc)
-               CFLAGS=-g -Wcast-align -Winline $(PROFILE) -Wall
+               CFLAGS=-g -Wcast-align -Winline $(PROFILE)
                LDFLAGS+=-g -Wl,-E $(PROFILE)
 endif
 ifeq   ($(CC_NAME), icc)
@@ -375,8 +378,7 @@ ifeq  ($(OS), SunOS)
 ifeq ($(CC_NAME), suncc)
        LIBS=-lfast
 endif
-       LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lresolv -lnsl \
-               -lsocket -lrt
+       LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lxnet -lrt
        # -lrt needed for sched_yield
 endif
 
index a5137c0..f6a4463 100644 (file)
@@ -123,8 +123,8 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
 
        /*computing the length of entire sip_msg structure*/
        len = ROUND4(sizeof( struct sip_msg ));
-       /*we will keep only the original msg*/
-       len += ROUND4(org_msg->len);
+       /*we will keep only the original msg +ZT */
+       len += ROUND4(org_msg->len + 1);
        /*the new uri (if any)*/
        if (org_msg->new_uri.s && org_msg->new_uri.len)
                len+= ROUND4(org_msg->new_uri.len);
@@ -206,8 +206,10 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
        }
        /* message buffers(org and scratch pad) */
        memcpy( p , org_msg->orig , org_msg->len);
+       /* ZT to be safer */
+       *(p+org_msg->len)=0;
        new_msg->orig = new_msg->buf = p;
-       p += ROUND4(new_msg->len);
+       p += ROUND4(new_msg->len+1);
        /* unparsed and eoh pointer */
        new_msg->unparsed = translate_pointer(new_msg->buf ,org_msg->buf,
                org_msg->unparsed );
index 95c2d22..e929777 100644 (file)
@@ -48,13 +48,15 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
        via = 0;
        p_msg = Trans->uas.request;
 
-       len = 0;
-       /*first line's len - CANCEL and INVITE has the same lenght */
-       len += ( REQ_LINE(p_msg).version.s+REQ_LINE(p_msg).version.len)-
-               REQ_LINE(p_msg).method.s+CRLF_LEN;
-       /*check if the REQ URI was override */
+       /* method, separators, version */
+       len=SIP_VERSION_LEN + CANCEL_LEN + 2 /* spaces */ + CRLF_LEN;
+       /* if URL was overridden .... */
        if (Trans->uac[branch].uri.s)
-               len += Trans->uac[branch].uri.len - REQ_LINE(p_msg).uri.len;
+               len+=Trans->uac[branch].uri.len;
+       else
+       /* ... otherwise use the inbound URL */
+               len+=REQ_LINE(p_msg).uri.len;
+
        /*via*/
        if ( add_branch_label(Trans,p_msg,branch)==-1 )
                goto error;
@@ -67,16 +69,18 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
        }
        len+= via_len;
        /*headers*/
-       for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next )
-               if (hdr->type==HDR_FROM || hdr->type==HDR_CALLID || 
-                       hdr->type==HDR_CSEQ || hdr->type==HDR_TO )
+       for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next ) {
+               if (hdr->type==HDR_FROM || hdr->type==HDR_CALLID 
+                       || hdr->type==HDR_TO )
                        len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN ;
-       /* User Agent header*/
-       len += USER_AGENT_LEN + CRLF_LEN;
-       /* Content Lenght heder*/
-       len += CONTENT_LEN_LEN + CRLF_LEN;
-       /* end of message */
-       len += CRLF_LEN;
+               else if (hdr->type==HDR_CSEQ)
+                       len += hdr->name.len + 2 + ((struct cseq_body*)hdr->parsed)->number.len +
+                               1+CANCEL_LEN+CRLF_LEN;
+       }
+       /* User Agent, Conteny Length, EoM */
+       len += USER_AGENT_LEN + CRLF_LEN +
+               CONTENT_LEN_LEN + CRLF_LEN +
+               CRLF_LEN;
 
        cancel_buf=sh_malloc( len+1 );
        if (!cancel_buf)
@@ -86,24 +90,16 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
        }
        p = cancel_buf;
 
-       /* first line -> do we have a new URI? */
-       if (Trans->uac[branch].uri.s)
-       {
-               append_mem_block(p,REQ_LINE(p_msg).method.s,
-                       REQ_LINE(p_msg).uri.s-REQ_LINE(p_msg).method.s);
-               append_mem_block(p,Trans->uac[branch].uri.s,
+       append_mem_block( p, CANCEL " ", CANCEL_LEN +1 );
+       if (Trans->uac[branch].uri.s) {
+               append_mem_block( p, Trans->uac[branch].uri.s, 
                        Trans->uac[branch].uri.len);
-               append_mem_block(p,REQ_LINE(p_msg).uri.s+REQ_LINE(p_msg).uri.len,
-                       REQ_LINE(p_msg).version.s+REQ_LINE(p_msg).version.len-
-                       (REQ_LINE(p_msg).uri.s+REQ_LINE(p_msg).uri.len))
-       }else{
-               append_mem_block(p,REQ_LINE(p_msg).method.s,
-                       REQ_LINE(p_msg).version.s+REQ_LINE(p_msg).version.len-
-                       REQ_LINE(p_msg).method.s);
+       } else {
+               append_mem_block(p,REQ_LINE(p_msg).uri.s,
+                       REQ_LINE(p_msg).uri.len );
        }
-       /* changhing method name*/
-       memcpy(cancel_buf, CANCEL , CANCEL_LEN );
-       append_mem_block(p,CRLF,CRLF_LEN);
+       append_mem_block( p, " " SIP_VERSION CRLF, 1+SIP_VERSION_LEN+CRLF_LEN );
+
        /* insert our via */
        append_mem_block(p,via,via_len);
 
@@ -115,22 +111,19 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
                        append_mem_block(p,hdr->name.s,
                                ((hdr->body.s+hdr->body.len)-hdr->name.s) );
                        append_mem_block(p, CRLF, CRLF_LEN );
-               }else if ( hdr->type==HDR_CSEQ )
+               } else if ( hdr->type==HDR_CSEQ )
                {
-                       append_mem_block(p,hdr->name.s,
-                               ((((struct cseq_body*)hdr->parsed)->method.s)-hdr->name.s));
-                       append_mem_block(p, CANCEL CRLF, CANCEL_LEN +CRLF_LEN );
+                       append_mem_block(p,hdr->name.s, hdr->name.len );
+                       append_mem_block(p,": ", 2 );
+                       append_mem_block(p, ((struct cseq_body*)hdr->parsed)->number.s,
+                               ((struct cseq_body*)hdr->parsed)->number.len );
+                       append_mem_block(p, " " CANCEL CRLF, 1+CANCEL_LEN+CRLF_LEN);
                }
-}
+       }
 
-       /* User Agent header */
-       append_mem_block(p,USER_AGENT,USER_AGENT_LEN);
-       append_mem_block(p,CRLF,CRLF_LEN);
-       /* Content Lenght header*/
-       append_mem_block(p,CONTENT_LEN,CONTENT_LEN_LEN);
-       append_mem_block(p,CRLF,CRLF_LEN);
-       /* end of message */
-       append_mem_block(p,CRLF,CRLF_LEN);
+       /* User Agent header, Content Length, EoM */
+       append_mem_block(p,USER_AGENT CRLF CONTENT_LEN CRLF CRLF ,
+               USER_AGENT_LEN + CRLF_LEN + CONTENT_LEN_LEN + CRLF_LEN + CRLF_LEN);
        *p=0;
 
        if (Trans->uac[branch].request.cancel) {
index 7e226a1..b4f73dc 100644 (file)
@@ -93,7 +93,12 @@ inline void final_response_handler( void *attr)
        {
                DBG("DEBUG: FR_handler:stop retr. and send CANCEL (%p)\n",r_buf->my_T);
                reset_timer( hash_table, &(r_buf->retr_timer) );
-               t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
+               /* BUG -- we want CANCELs actually ONLY for INVITE; BTW, the
+                  CANCEL construction method results for non-INVITEs in
+                  bizzar messages such as "CANCELS" for OPTIONS; -Jiri
+               */
+               if (r_buf->my_T->uas.request->first_line.u.request.method_value==METHOD_INVITE)
+                       t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
                /* dirty hack:t_send_reply would increase ref_count which would indeed
                result in refcount++ which would not -- until timer processe's
                T changes again; currently only on next call to t_send_reply from
index e1fff4b..b55b59f 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -42,6 +42,9 @@ int receive_msg(char* buf, unsigned int len, union sockaddr_union* src_su)
        /* fill in msg */
        msg->buf=buf;
        msg->len=len;
+       /* zero termination (termination of orig message bellow not that
+          useful as most of the work is done with scrath-pad; -jiri  */
+       buf[len]=0;
        su2ip_addr(&msg->src_ip, src_su);
        msg->dst_ip=bind_address->address; /* won't work if listening on 0.0.0.0 */
        msg->id=msg_no;
index a76905c..7e044ac 100644 (file)
@@ -1,6 +1,6 @@
 BYE sip:jiri@bat.iptel.org SIP/2.0
 Max-Forwards: 0
-Via: SIP/2.0/UDP 195.37.77.101;branch=df6250bb14ccda4a69dc0502173d02b2.e0e.0
+Via: SIP/2.0/UDP 195.37.77.100;branch=df6250bb14ccda4a69dc0502173d02b2.e0e.0
 Via: SIP/2.0/UDP 213.20.228.21:13671
 From: "jiri" <sip:jiri@iptel.org>;tag=9c77afe9-71ec-4c52-a009-f2869fba848b
 To: <sip:jiri@bat.iptel.org>;tag=9c77afe9-71ec-4c52-a009-f2869fba848b