local cancel
authorBogdan-Andrei Iancu <bogdan@voice-system.ro>
Wed, 27 Feb 2002 21:30:43 +0000 (21:30 +0000)
committerBogdan-Andrei Iancu <bogdan@voice-system.ro>
Wed, 27 Feb 2002 21:30:43 +0000 (21:30 +0000)
12 files changed:
Makefile.defs
forward.c
modules/tm/t_funcs.c
modules/tm/t_funcs.h
modules/tm/t_lookup.c
modules/tm/t_reply.c
modules/tm/timer.c
msg_parser.c
parse_hname2.c
receive.c
timer.c
udp_server.c

index 3a14eab..ffce5a6 100644 (file)
@@ -80,8 +80,8 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
         -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
         -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
         -DF_MALLOC  -DUSE_SYNONIM\
-        -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DSRL\
-        -DNO_DEBUG 
+        -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DSRL -DBOGDAN_TRIFLE \
+        #-DNO_DEBUG \
         #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
         #-DNOSMP \
         #-DEXTRA_DEBUG 
index e576ae4..4b6df57 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -153,6 +153,14 @@ int forward_reply(struct sip_msg* msg)
                }
        }
        
+       /* we have to forward the reply stateless, so we need second via -bogdan*/
+       if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK))
+       {
+               /* no second via => error */
+               LOG(L_ERR, "ERROR: forward_msg: no 2nd via found in reply\n");
+               goto error;
+       }
+
        to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
        if (to==0){
                LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
@@ -165,15 +173,6 @@ int forward_reply(struct sip_msg* msg)
                goto error;
        }
 
-        /* send it! */
-       /* moved to udp_send; -jiri
-
-       DBG("Sending: to %s:%d, \n%s.\n",
-                       msg->via2->host.s,
-                       (unsigned short)msg->via2->port,
-                       new_buf);
-       */
-
        if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;
 
        if (udp_send(new_buf,new_len, (struct sockaddr*) to,
@@ -181,13 +180,16 @@ int forward_reply(struct sip_msg* msg)
        {
                STATS_TX_DROPS;
                goto error;
-       }
-       else {
+       } else {
 #ifdef STATS
                int j = msg->first_line.u.reply.statuscode/100;
                STATS_TX_RESPONSE(  j );
 #endif
        }
+
+       DBG(" reply forwarded to %s:%d\n",msg->via2->host.s,
+               (unsigned short) msg->via2->port);
+
        free(new_buf);
        free(to);
 skip:
index 4b2f487..350edc2 100644 (file)
@@ -76,7 +76,6 @@ static inline void reset_retr_timers( struct s_table *h_table,
        int ijk;
        struct retrans_buff *rb;
 
-       DBG("DEBUG:stop_RETR_and_FR_timers : start \n");
        /* lock the first timer list of the FR group -- all other
           lists share the same lock*/
        lock(hash_table->timers[RT_T1_TO_1].mutex);
@@ -96,7 +95,7 @@ static inline void reset_retr_timers( struct s_table *h_table,
                        }
                }
        unlock(hash_table->timers[FR_TIMER_LIST].mutex);
-       DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
+       DBG("DEBUG:stop_RETR_and_FR_timers : timers stopped\n");
 }
 
 int tm_startup()
@@ -376,7 +375,7 @@ int t_put_on_wait(  struct cell  *Trans  )
        for( i=0 ; i<Trans->nr_of_outgoings ; i++ )
                if ( Trans->inbound_response[i] && 
                REPLY_CLASS(Trans->inbound_response[i])==1)
-               t_cancel_branch(i);
+                       t_cancel_branch(i);
 
 
        /* we don't need outbound requests anymore -- let's save
@@ -662,6 +661,7 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
                sizeof (struct sockaddr_in));
        srb->tolen = sizeof (struct sockaddr_in);
        srb->my_T = Trans;
+       srb->fr_timer.payload = srb->retr_timer.payload = srb;
        srb->branch = branch;
        srb->status = STATUS_LOCAL_CANCEL;
        srb->retr_buffer = (char *) srb + sizeof( struct retrans_buff );
@@ -837,7 +837,7 @@ void retransmission_handler( void *attr)
 {
        struct retrans_buff* r_buf ;
        enum lists id;
-
+       DBG("DEBUG: entering retransmisson with attr = %x\n",attr);
        r_buf = (struct retrans_buff*)attr;
 #ifdef EXTRA_DEBUG
        if (r_buf->my_T->damocles) {
@@ -886,18 +886,16 @@ void final_response_handler( void *attr)
        /* the transaction is already removed from FR_LIST by the timer */
        if (r_buf->status==STATUS_LOCAL_CANCEL)
        {
-               DBG("DEBUG: final_response_handler: stop retransmission for"
-                       "Local Cancel\n");
+               DBG("DEBUG: FR_handler: stop retransmission for Local Cancel\n");
                reset_timer( hash_table , &(r_buf->retr_timer) );
                return;
        }
        /* send a 408 */
        if ( r_buf->my_T->status<200)
        {
-               DBG("DEBUG: final_response_handler:stop retransmission and"
-                       " send 408 (t=%p)\n", r_buf->my_T);
+               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);
+               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
@@ -905,7 +903,7 @@ void final_response_handler( void *attr)
                and refcount++ JKU */
                T=r_buf->my_T;
                global_msg_id=T->inbound_request->id;
-
+               DBG("DEBUG: FR_handler: send 408 (%p)\n", r_buf->my_T);
                t_send_reply( r_buf->my_T->inbound_request,408,"Request Timeout" );
        }else{
                /* put it on WT_LIST - transaction is over */
index 0e8df87..09005ce 100644 (file)
@@ -106,8 +106,8 @@ extern struct s_table*  hash_table;
        ( { \
                DBG_REF("ref", (_T_cell));       \
                if (T_IS_REFED_BYSELF(_T_cell)) { \
-                       DBG("ERROR: refering already refered transaction %p from %s , %s : %d\n", \
-                               (_T_cell), __FUNCTION__, __FILE__, __LINE__ ); \
+                       DBG("ERROR: refering already refered transaction %p from %s,%s :"\
+                               " %d\n",(_T_cell), __FUNCTION__, __FILE__, __LINE__ ); \
                        abort(); \
                } \
                (_T_cell)->ref_bitmap |= process_bit; \
index 0e080e8..5835608 100644 (file)
@@ -169,8 +169,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 found:
        T=p_cell;
        T_REF( T );
-       DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_lookup_request: "
-               "transaction found ( T=%p , ref=%x)\n",T,T->ref_bitmap);
+       DBG("DEBUG: t_lookup_request: transaction found (T=%p , ref=%x)\n",
+               T,T->ref_bitmap);
        unlock(&(hash_table->entrys[p_msg->hash_index].mutex));
        return 1;
 }
@@ -326,7 +326,7 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
                && ((get_cseq(p_msg)->method.s[0] ==
                get_cseq(p_cell->inbound_request)->method.s[0] && (*local_cancel=0)==0)
                || (get_cseq(p_cell->inbound_request)->method.s[0]=='I' &&
-               get_cseq(p_msg)->method.s[0]=='C' 
+               get_cseq(p_msg)->method.s[0]=='C'
                && p_cell->outbound_cancel[branch_id]!=NO_CANCEL
                && p_cell->outbound_cancel[branch_id]!=EXTERNAL_CANCEL
                && (*local_cancel=1)==1))
@@ -345,8 +345,8 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
                                *p_branch = branch_id;
                                T_REF( T );
                                unlock(&(hash_table->entrys[hash_index].mutex));
-                               DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_reply_matching:"
-                                       " reply matched (T=%p,ref=%x)!\n",T,T->ref_bitmap);
+                               DBG("DEBUG: t_reply_matching: reply matched (T=%p,ref=%x)!\n",
+                                       T,T->ref_bitmap);
                                return 1;
                        }
                /* next cell */
@@ -378,7 +378,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
        int local_cancel;
 
        /* is T still up-to-date ? */
-       DBG("DEBUG: t_check : msg id=%d , global msg id=%d , T on entrance=%p\n", 
+       DBG("DEBUG: t_check: msg id=%d global id=%d T start=%p\n", 
                p_msg->id,global_msg_id,T);
        if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
        {
@@ -391,8 +391,8 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
                                return -1;
                        t_lookup_request( p_msg , 0 /* unlock before returning */ );
                } else {
-                       if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1
-                       || !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq )
+                       if ( parse_headers(p_msg, HDR_VIA1|HDR_TO|HDR_CSEQ )==-1
+                       || !p_msg->via1 || !p_msg->to || !p_msg->cseq )
                                return -1;
                        t_reply_matching( p_msg ,
                                ((param_branch!=0)?(param_branch):(&local_branch)),
@@ -406,7 +406,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
                        abort();
                }
 #endif
-               DBG("DEBUG: t_check : msg id=%d , global msg id=%d , T on finish=%p\n",
+               DBG("DEBUG: t_check: msg id=%d global id=%d T end=%p\n",
                        p_msg->id,global_msg_id,T);
        } else {
                if (T)
@@ -452,6 +452,9 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
 
 }
 
+
+
+
 /* atomic "add_if_new" construct; it returns:
        AIN_ERROR       if a fatal error (e.g, parsing) occured
        AIN_RETR        it's a retransmission
@@ -466,8 +469,8 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
        struct cell *new_cell;
 
        /* is T still up-to-date ? */
-       DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d , T on entrance=%p\n", 
-               p_msg->id,global_msg_id,T);
+       DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d ,"
+               " T on entrance=%p\n",p_msg->id,global_msg_id,T);
        if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
        {
                global_msg_id = p_msg->id;
@@ -484,12 +487,12 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
                                ret=AIN_NEWACK;
                        } else {
                                /* add new transaction */
-                               new_cell = build_cell( p_msg ) ;
-                               if  ( !new_cell ){
-                                               LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
+                               new_cell = build_cell( p_msg ) ;
+                               if  ( !new_cell ){
+                                       LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
                                        ret = AIN_ERROR;
-                               } else {
-                                       insert_into_hash_table_unsafe( hash_table , new_cell );
+                               } else {
+                                       insert_into_hash_table_unsafe( hash_table , new_cell );
                                        ret = AIN_NEW;
                                        T=new_cell;
                                        T_REF(T);
@@ -510,7 +513,6 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
                        "processing this message, T not found!\n");
                return AIN_ERROR;
        }
-
 }
 
 
index 4d475f8..a6996ea 100644 (file)
@@ -173,7 +173,7 @@ int t_retransmit_reply( /* struct sip_msg* p_msg    */ )
 
 
 /* Force a new response into inbound response buffer.
-  * returns 1 if everything was OK or -1 for erro
+  * returns 1 if everything was OK or -1 for error
   */
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 {
@@ -181,7 +181,8 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
        char * buf, *shbuf;
        struct retrans_buff *rb;
 
-       buf = build_res_buf_from_sip_req(code,text,0,0,T->inbound_request,&len);
+       buf = build_res_buf_from_sip_req(code,text,T->tag->s,T->tag->len,
+               T->inbound_request,&len);
        DBG("DEBUG: t_send_reply: buffer computed\n");
        if (!buf)
        {
@@ -422,7 +423,7 @@ int t_on_reply( struct sip_msg  *p_msg )
        unsigned int local_cancel;
        struct sip_msg *clone, *backup;
        int relay;
-       int start_fr;
+       int start_fr = 0;
        int is_invite;
        /* retransmission structure of outbound reply and request */
        struct retrans_buff *orq_rb, *orp_rb, *ack_rb;
@@ -434,7 +435,8 @@ int t_on_reply( struct sip_msg  *p_msg )
 
 
        /* make sure we know the assosociated tranaction ... */
-       if (t_check( p_msg  , &branch , &local_cancel)==-1) return 1;
+       if (t_check( p_msg  , &branch , &local_cancel)==-1)
+               return 1;
        /* ... if there is no such, tell the core router to forward statelessly */
        if ( T<=0 ) return 1;
 
@@ -443,23 +445,30 @@ int t_on_reply( struct sip_msg  *p_msg )
 
        backup = 0;
 
-       DBG("DEBUG: t_on_reply_received: Original status=%d (%d,%d)\n",
+       DBG("DEBUG: t_on_reply: Original status=%d (%d,%d)\n",
                T->status,branch,local_cancel);
 
        /* special cases (local cancel reply and another 100 reply!)*/
        if (p_msg->REPLY_STATUS==100 && T->status==100)
-               return 0;
+               goto error;
        if (local_cancel==1)
        {
                reset_timer( hash_table, &(T->outbound_cancel[branch]->retr_timer));
                if ( p_msg->REPLY_STATUS>=200 )
                        reset_timer( hash_table, &(T->outbound_cancel[branch]->fr_timer));
-               return 0;
+               goto error;
        }
 
-       /* it can take quite long -- better do it now than later 
-          inside a reply_lock */
-                                                                                                       /* CLONE alloc'ed */
+       /* do we have via2 ? - maybe we'll need it for forwarding -bogdan*/
+       if ((p_msg->via2==0) || (p_msg->via2->error!=VIA_PARSE_OK)){
+               /* no second via => error */
+               LOG(L_ERR, "ERROR: t_on_reply: no 2nd via found in reply\n");
+               goto error2;
+       }
+
+       /* it can take quite long - better do it now than later
+       inside a reply_lock */
+       /* CLONE alloc'ed */
        if (!(clone=sip_msg_cloner( p_msg ))) {
                goto error;
        }
@@ -472,10 +481,10 @@ int t_on_reply( struct sip_msg  *p_msg )
        sometimes it will result in useless CPU cycles
        but mostly the assumption holds and allows the
        work to be done out of criticial lock region */
-       if (msg_status==100) buf=0;
+       if (msg_status==100)
+               buf=0;
        else {
-                                                                                               /* buf maybe allo'ed*/
-
+               /* buf maybe allo'ed*/
                buf = build_res_buf_from_sip_res ( p_msg, &orp_len);
                if (!buf) {
                        LOG(L_ERR, "ERROR: t_on_reply_received: "
@@ -487,15 +496,13 @@ int t_on_reply( struct sip_msg  *p_msg )
        /* *** stop timers *** */
        orq_rb=T->outbound_request[branch];
        /* stop retransmission */
-                                                                                               /* timers reset */
-
        reset_timer( hash_table, &(orq_rb->retr_timer));
        /* stop final response timer only if I got a final response */
        if ( msg_class>1 )
                reset_timer( hash_table, &(orq_rb->fr_timer));
 
        LOCK_REPLIES( T );
-       /* if a got the first prov. response for an INVITE ->
+       /* if a got the first prov. response for an INVITE ->
           change FR_TIME_OUT to INV_FR_TIME_UT */
        start_fr = !T->inbound_response[branch] && msg_class==1 && is_invite;
 
@@ -508,14 +515,14 @@ int t_on_reply( struct sip_msg  *p_msg )
                if ( ! orp_rb->retr_buffer ) {
                        /*init retrans buffer*/
                        memset( orp_rb , 0 , sizeof (struct retrans_buff) );
-                       if (update_sock_struct_from_via(  &(orp_rb->to), p_msg->via2 )==-1) {
-                                       UNLOCK_REPLIES( T );
-                                       start_fr = 1;
-                                       LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: "
-                                               "cannot lookup reply dst: %s\n",
-                                               p_msg->via2->host.s );
-                                       save_clone = 0;
-                                       goto error2;
+                       if (update_sock_struct_from_via( &(orp_rb->to),p_msg->via2 )==-1) {
+                               UNLOCK_REPLIES( T );
+                               start_fr = 1;
+                               LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: "
+                                       "cannot lookup reply dst: %s\n",
+                               p_msg->via2->host.s );
+                               save_clone = 0;
+                               goto error2;
                        }
                        orp_rb->retr_timer.tg=TG_RT;
                        orp_rb->fr_timer.tg=TG_FR;
@@ -530,9 +537,10 @@ int t_on_reply( struct sip_msg  *p_msg )
                        alloc_len = orp_len + REPLY_OVERBUFFER_LEN ;
                } else {
                        alloc_len = orp_len;
-               };
+               }
 
-               if (! (orp_rb->retr_buffer = (char *) shm_resize( orp_rb->retr_buffer, alloc_len ))) {
+               if (! (orp_rb->retr_buffer = (char *)
+               shm_resize( orp_rb->retr_buffer, alloc_len ))) {
                        UNLOCK_REPLIES( T );
                        start_fr = 1;
                        save_clone = 0;
@@ -570,29 +578,30 @@ cleanup:
        }
 
        /* *** ACK handling *** */
-       if ( is_invite )
-       {
+       if ( is_invite ) {
                if ( T->outbound_ack[branch] )
                {   /*retransmit*/
                        /* I don't need any additional syncing here -- after ack
                           is introduced it's never changed */
                        SEND_BUFFER( T->outbound_ack[branch] );
-               } else if (msg_class>2 ) {   /*on a non-200 reply to INVITE*/
-                       DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE: send ACK\n");
-                               ack_rb = build_ack( p_msg, T, branch );
-                               if (ack_rb) {
-                                       SEND_BUFFER( ack_rb );
-                                       /* append to transaction structure */
-                                       attach_ack( T, branch, ack_rb );
-                               } else {
-                                       /* restart FR */
-                                       start_fr=1;
-                                       DBG("ERROR: t_on_reply: build_ack failed\n");
-                               }
+               } else if (msg_class>2 ) {
+                       /*on a non-200 reply to INVITE*/
+                       DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE:"
+                               "send ACK\n");
+                       ack_rb = build_ack( p_msg, T, branch );
+                       if (ack_rb) {
+                               SEND_BUFFER( ack_rb );
+                               /* append to transaction structure */
+                               attach_ack( T, branch, ack_rb );
+                       } else {
+                               /* restart FR */
+                               start_fr=1;
+                               DBG("ERROR: t_on_reply: build_ack failed\n");
+                       }
                }
        } /* is_invite */
 
-       /* restart retransmission if a provisional response came for 
+       /* restart retransmission if a provisional response came for 
           a non_INVITE -> retrasmit at RT_T2*/
        if ( msg_class==1 && !is_invite )
        {
@@ -601,7 +610,8 @@ cleanup:
        }
        if (backup) sip_msg_free( backup );
 error2:
-       if (start_fr) set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
+       if (start_fr) 
+               set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
        if (buf) free( buf );
 error1:
        if (!save_clone) sip_msg_free( clone );
index ff02edc..2333a41 100644 (file)
@@ -160,6 +160,9 @@ void timer_routine(unsigned int ticks , void * attr)
        struct timer_link  *tl, *tmp_tl;
        int                           id;
 
+#ifdef BOGDAN_TRIFLE
+       DBG(" %d \n",ticks);
+#endif
 
        for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
        {
index 794b7fc..7c567c1 100644 (file)
@@ -263,8 +263,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
                        }
                        hdr->parsed=to_b;
                        hdr->body.len=tmp-hdr->body.s;
-                       DBG("get_hdr_field: to <%s>: <%s>=[%d] <%c> [%d]\n",
-                               hdr->name.s, to_b->body.s,to_b->body.len,*tmp,hdr->body.len);
+                       DBG("get_hdr_field: <%s> [%d]; <%s>.len = %d \n",
+                               hdr->name.s, hdr->body.len, to_b->body.s,to_b->body.len);
                        break;
                case HDR_FROM:
                case HDR_CALLID:
@@ -353,7 +353,6 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
        m_end=eat_token_end(m, end);
        *t=0; /*null terminate it*/
        cb->number.len=t-cb->number.s;
-       DBG("parse_cseq: found number %s\n", cb->number.s);
 
        if (m_end>=end) goto error;
        if (m_end==m){
@@ -366,7 +365,6 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
        c=*t;
        *t=0; /*null terminate it*/
        cb->method.len=t-cb->method.s;
-       DBG("parse_cseq: found method %s\n", cb->method.s);
        t++;
        /*check if the header ends here*/
        if (c=='\n') goto check_continue;
@@ -714,7 +712,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
                        DBG(" version: <%s>\n",fl->u.reply.version.s);
                        DBG(" status:  <%s>\n",fl->u.reply.status.s);
                        DBG(" reason:  <%s>\n",fl->u.reply.reason.s);
-                       flags=HDR_VIA|HDR_VIA2;
+                       flags=HDR_VIA | HDR_VIA2;
                        break;
                default:
                        DBG("unknown type %d\n",fl->type);
index 4861904..a34fb83 100644 (file)
@@ -340,8 +340,6 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
        register char* p;
        register int val;
 
-       DBG("DEBUG: parse_hname2 entered\n");
-
        p = begin;
        val = READ(p);
        hdr->name.s = begin;
@@ -355,10 +353,10 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
        case Via1: Via1_CASE;
        case From: From_CASE;
        case To12: To12_CASE;
-       case CSeq: CSeq_CASE;                                                             
+       case CSeq: CSeq_CASE;
        case Call: Call_CASE;
-        case Cont: Cont_CASE;
-       case Rout: Rout_CASE;                                                             
+       case Cont: Cont_CASE;
+       case Rout: Rout_CASE;
        case Max_: Max_CASE;
        case Reco: Reco_CASE;
         case Via2: Via2_CASE;
index 4d5729c..bf7a294 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -57,7 +57,6 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
        }
        DBG("After parse_msg...\n");
        if (msg->first_line.type==SIP_REQUEST){
-               DBG("msg= request\n");
                /* sanity checks */
                if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
                        /* no via, send back error ? */
@@ -68,7 +67,8 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 
                /* loop checks */
                if (loop_checks) {
-                       DBG("WARNING: receive_msg: Placeholder for loop check. NOT implemented yet.\n");
+                       DBG("WARNING: receive_msg: Placeholder for loop check."
+                               " NOT implemented yet.\n");
                }
                
                /* exec routing script */
@@ -90,18 +90,18 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
                STATS_RX_REQUEST( msg->first_line.u.request.method_value );
 #endif
        }else if (msg->first_line.type==SIP_REPLY){
-               DBG("msg= reply\n");
                /* sanity checks */
                if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
                        /* no via, send back error ? */
                        LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
                        goto error;
                }
+               /*
                if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){
-                       /* no second via => error? */
+                       /* no second via => error? /
                        LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n");
                        goto error;
-               }
+               }*/
                /* check if via1 == us */
 
 #ifdef STATS
@@ -110,11 +110,8 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 #endif
                
                /* send the msg */
-               if (forward_reply(msg)==0){
-                       DBG(" reply forwarded to %s:%d\n", 
-                                               msg->via2->host.s,
-                                               (unsigned short) msg->via2->port);
-               }
+               forward_reply(msg);
+
 #ifdef STATS
                gettimeofday( & tve, &tz );
                diff = (tve.tv_sec-tvb.tv_sec)*1000000+(tve.tv_usec-tvb.tv_usec);
diff --git a/timer.c b/timer.c
index 20d2ddb..d9753e1 100644 (file)
--- a/timer.c
+++ b/timer.c
@@ -109,6 +109,5 @@ unsigned int get_ticks()
                        ", returning 0 (probably wrong)");
        return 0;
 #endif
-       DBG("- get_ticks:returning %d\n", *jiffies);
        return *jiffies;
 }
index c4ce606..8664909 100644 (file)
@@ -223,30 +223,27 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
        c=inet_ntoa(a->sin_addr);
        strncpy( ip_txt, c, MAX_IP_LENGTH - 1 );
        p=ntohs(a->sin_port);
-       DBG("DEBUG: udp_send: ");
 
        if (tolen < sizeof(struct sockaddr_in))
-               DBG("DEBUG: tolen small\n");
+               DBG("DEBUG: udp_send: tolen small\n");
        if (a->sin_family && a->sin_family != AF_INET)
-               DBG("DEBUG: to not INET\n");
+               DBG("DEBUG: udp_send: to not INET\n");
        if (a->sin_port == 0)
-               DBG("DEBUG: no port\n");
+               DBG("DEBUG: udp_send: no port\n");
 
 #ifdef EXTRA_DEBUG
-       if ( tolen < sizeof(struct sockaddr_in) || a->sin_family && a->sin_family != AF_INET
-               || a->sin_port == 0 )
+       if ( tolen < sizeof(struct sockaddr_in) ||
+       a->sin_family && a->sin_family != AF_INET || a->sin_port == 0 )
                abort();
        /* every message must be terminated by CRLF */
        if (memcmp(buf+len-CRLF_LEN, CRLF, CRLF_LEN)!=0) {
-               LOG(L_CRIT, "ERROR: this is ugly -- we are sending a packet not terminated by CRLF\n");
+               LOG(L_CRIT, "ERROR: this is ugly -- we are sending a packet"
+                       " not terminated by CRLF\n");
                abort();
        }
 #endif
 
-       DBG(" destination: IP=%s, port=%u; packet:\n", ip_txt, p);
-       DBG(" destination (hex): IP=%x, port=%x;\n", a->sin_addr.s_addr, a->sin_port );
-       /* DBG(" packet: {%.*s...}\n", 24, buf ); */
-       /* DBG("%.*s\n", len, buf ); */
+       DBG("DEBUG: udp_send destination: IP=%s, port=%u;\n", ip_txt, p);
 #endif
 /*
        memset(&a2, 0, sizeof(struct sockaddr_in));