... | ... |
@@ -60,14 +60,11 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ ) |
60 | 60 |
DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ |
61 | 61 |
-DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\ |
62 | 62 |
-DDNS_IP_HACK -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP \ |
63 |
- -DUSE_SYNONIM \ |
|
64 |
- -DF_MALLOC |
|
65 |
- # -DVQ_MALLOC |
|
66 |
- #-DBRUT_HACK #-DEXTRA_DEBUG |
|
67 |
- #-DEXTRA_DEBUG -DBRUT_HACK \ |
|
68 |
- #-DVQ_MALLOC -DDBG_LOCK #-DSTATS |
|
69 |
- #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG |
|
70 |
- #-DNO_DEBUG #-DDBG_QM_MALLOC |
|
63 |
+ -DUSE_SYNONIM -DVQ_MALLOC \ |
|
64 |
+ #-DFAST_LOCK -Di386 |
|
65 |
+ #-DEXTRA_DEBUG #-DSTATIC_TM |
|
66 |
+ #-DVQ_MALLOC -DDBG_LOCK #-DSTATS |
|
67 |
+ #-DDBG_QM_MALLOC #-DNO_DEBUG |
|
71 | 68 |
#-DEXTRA_DEBUG |
72 | 69 |
# -DUSE_SHM_MEM |
73 | 70 |
#-DNO_DEBUG |
... | ... |
@@ -658,7 +658,7 @@ int t_send_reply( struct sip_msg* p_msg , unsigned int code , char * text ) |
658 | 658 |
} |
659 | 659 |
*/ |
660 | 660 |
|
661 |
- buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len ); |
|
661 |
+ buf = build_res_buf_from_sip_req(code,text,0,0,T->inbound_request,&len); |
|
662 | 662 |
DBG("DEBUG: t_send_reply: buffer computed\n"); |
663 | 663 |
if (!buf) |
664 | 664 |
{ |
... | ... |
@@ -676,7 +676,7 @@ int t_send_reply( struct sip_msg* p_msg , unsigned int code , char * text ) |
676 | 676 |
{ |
677 | 677 |
LOG(L_ERR, "ERROR: t_send_reply: cannot lookup reply dst: %s\n", |
678 | 678 |
p_msg->via1->host.s ); |
679 |
- goto error; |
|
679 |
+ goto error2; |
|
680 | 680 |
} |
681 | 681 |
|
682 | 682 |
rb->retr_timer.tg=TG_RT; |
... | ... |
@@ -134,13 +134,9 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked ) |
134 | 134 |
&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len |
135 | 135 |
&& /*from length*/ EQ_LEN(from) |
136 | 136 |
&& /*to body*/get_to(t_msg)->body.len==get_to(p_msg)->body.len |
137 |
- && printf("------>0.4 %d (%d,%d)\n",p_cell->status,p_cell->tag->len,get_to(p_msg)->tag_value.len) |
|
138 | 137 |
&& /*to tag*/p_cell->tag->len==get_to(p_msg)->tag_value.len |
139 |
- && printf("------>0.5 %d\n",p_cell->status) |
|
140 | 138 |
&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_LEN ) |
141 |
- && printf("------>0.6 %d\n",p_cell->status) |
|
142 |
- && /*VIA*/(p_cell->status==200 || EQ_VIA_LEN(via1)) |
|
143 |
- && printf("------>2 %d\n",p_cell->status) ) |
|
139 |
+ && /*VIA*/(p_cell->status==200 || EQ_VIA_LEN(via1)) ) |
|
144 | 140 |
/* so far the lengths are the same |
145 | 141 |
-> let's check the contents */ |
146 | 142 |
if (/*callid*/!memcmp( t_msg->callid->body.s, |
... | ... |
@@ -152,10 +148,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked ) |
152 | 148 |
get_to(p_msg)->body.s,get_to(t_msg)->body.len) |
153 | 149 |
&& /*to tag*/!memcmp(p_cell->tag->s, |
154 | 150 |
get_to(p_msg)->tag_value.s,p_cell->tag->len) |
155 |
- && /*req URI*/(p_cell->status==200 || EQ_REQ_URI_STR|| |
|
156 |
- printf("------>1 %d\n",p_cell->status) ) |
|
157 |
- && /*VAI*/(p_cell->status==200 ||EQ_VIA_STR(via1) || |
|
158 |
- printf("------>2 %d\n",p_cell->status) ) ) |
|
151 |
+ && /*req URI*/(p_cell->status==200 || EQ_REQ_URI_STR) |
|
152 |
+ && /*VAI*/(p_cell->status==200 ||EQ_VIA_STR(via1)) ) |
|
159 | 153 |
{ /* WE FOUND THE GOLDEN EGG !!!! */ |
160 | 154 |
goto found; |
161 | 155 |
} |
... | ... |
@@ -18,6 +18,18 @@ |
18 | 18 |
#define MAX_RECEIVED_SIZE 57 |
19 | 19 |
|
20 | 20 |
|
21 |
+#define append_str(_dest,_src,_len,_msg) \ |
|
22 |
+ do{\ |
|
23 |
+ memcpy( (_dest) , (_src) , (_len) );\ |
|
24 |
+ (_dest) += (_len) ;\ |
|
25 |
+ }while(0); |
|
26 |
+ |
|
27 |
+#define append_str_trans(_dest,_src,_len,_msg) \ |
|
28 |
+ do{\ |
|
29 |
+ memcpy( (_dest) , (_msg)->orig+((_src)-(_msg)->buf) , (_len) );\ |
|
30 |
+ (_dest) += (_len) ;\ |
|
31 |
+ }while(0); |
|
32 |
+ |
|
21 | 33 |
|
22 | 34 |
|
23 | 35 |
/* faster than inet_ntoa */ |
... | ... |
@@ -532,15 +544,14 @@ error: |
532 | 544 |
|
533 | 545 |
|
534 | 546 |
char * build_res_buf_from_sip_req( unsigned int code , |
535 |
- char *text , struct sip_msg* msg, unsigned int *returned_len) |
|
547 |
+ char *text, char *new_tag, unsigned int new_tag_len, |
|
548 |
+ struct sip_msg* msg, unsigned int *returned_len) |
|
536 | 549 |
{ |
537 | 550 |
char *buf, *p; |
538 | 551 |
unsigned int len,foo; |
539 | 552 |
struct hdr_field *hdr; |
540 | 553 |
int i; |
541 |
-#ifdef BRUT_HACK |
|
542 |
- struct hdr_field *to, *from, *callid, *cseq, *via; |
|
543 |
-#endif |
|
554 |
+ str *tag_str; |
|
544 | 555 |
|
545 | 556 |
/* force parsing all headers -- we want to return all |
546 | 557 |
Via's in the reply and they may be scattered down to the |
... | ... |
@@ -554,27 +565,24 @@ char * build_res_buf_from_sip_req( unsigned int code , |
554 | 565 |
len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ + strlen(text) + CRLF_LEN/*new line*/; |
555 | 566 |
/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/ |
556 | 567 |
for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) |
557 |
-#ifdef BRUT_HACK |
|
558 |
- { |
|
559 |
- len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN; |
|
560 |
- if ( hdr->type==HDR_VIA ) via = hdr; |
|
561 |
- else if ( hdr->type==HDR_FROM) from = hdr; |
|
562 |
- else if (hdr->type==HDR_CALLID) callid = hdr; |
|
563 |
- else if ( hdr->type==HDR_TO) to = hdr; |
|
564 |
- else if ( hdr->type==HDR_CSEQ) cseq = hdr; |
|
565 |
- else len-=((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN; |
|
566 |
- } |
|
567 |
-#else |
|
568 |
- if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM || |
|
569 |
- hdr->type==HDR_CALLID || hdr->type==HDR_TO || |
|
570 |
- hdr->type==HDR_CSEQ ) |
|
571 |
- len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN; |
|
572 |
-#endif |
|
568 |
+ switch (hdr->type) |
|
569 |
+ { |
|
570 |
+ case HDR_TO: |
|
571 |
+ if (new_tag) |
|
572 |
+ if (get_to(msg)->tag_value.s ) |
|
573 |
+ len+=new_tag_len-get_to(msg)->tag_value.len; |
|
574 |
+ else |
|
575 |
+ len+=new_tag_len+5/*";tag="*/; |
|
576 |
+ case HDR_VIA: |
|
577 |
+ case HDR_FROM: |
|
578 |
+ case HDR_CALLID: |
|
579 |
+ case HDR_CSEQ: |
|
580 |
+ len += ((hdr->body.s+hdr->body.len )-hdr->name.s )+CRLF_LEN; |
|
581 |
+ } |
|
573 | 582 |
/*content length header*/ |
574 | 583 |
len +=CONTENT_LEN_LEN + CRLF_LEN; |
575 | 584 |
/* end of message */ |
576 | 585 |
len += CRLF_LEN; /*new line*/ |
577 |
- |
|
578 | 586 |
/*allocating mem*/ |
579 | 587 |
buf = 0; |
580 | 588 |
buf = (char*) malloc( len+1 ); |
... | ... |
@@ -600,32 +608,38 @@ char * build_res_buf_from_sip_req( unsigned int code , |
600 | 608 |
memcpy( p, CRLF, CRLF_LEN ); |
601 | 609 |
p+=CRLF_LEN; |
602 | 610 |
/* headers*/ |
603 |
-#ifdef BRUT_HACK |
|
604 |
-#define COPY_HF(_hf) memcpy(p, msg->orig+(_hf->name.s-msg->buf), \ |
|
605 |
- ((_hf->body.s+_hf->body.len ) - \ |
|
606 |
- _hf->name.s )); \ |
|
607 |
- p+=((_hf->body.s+_hf->body.len)-_hf->name.s ) ; \ |
|
608 |
- memcpy( p, CRLF, CRLF_LEN ); \ |
|
609 |
- p+=CRLF_LEN; |
|
610 |
- |
|
611 |
- COPY_HF(via); |
|
612 |
- COPY_HF(from); |
|
613 |
- COPY_HF(to); |
|
614 |
- COPY_HF(callid); |
|
615 |
- COPY_HF(cseq); |
|
616 |
-#else |
|
617 | 611 |
for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) |
618 |
- if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM || |
|
619 |
- hdr->type==HDR_CALLID || hdr->type==HDR_TO || hdr->type==HDR_CSEQ ) |
|
612 |
+ switch (hdr->type) |
|
620 | 613 |
{ |
621 |
- memcpy( p , msg->orig+(hdr->name.s-msg->buf) , |
|
622 |
- ((hdr->body.s+hdr->body.len ) - |
|
623 |
- hdr->name.s ) ); |
|
624 |
- p += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) ; |
|
625 |
- memcpy( p, CRLF, CRLF_LEN ); |
|
626 |
- p+=CRLF_LEN; |
|
614 |
+ case HDR_TO: |
|
615 |
+ if (new_tag){ |
|
616 |
+ if (get_to(msg)->tag_value.s ) { |
|
617 |
+ tag_str =&(get_to(msg)->tag_value); |
|
618 |
+ append_str_trans( p, hdr->name.s , |
|
619 |
+ tag_str->s-hdr->name.s,msg); |
|
620 |
+ append_str( p, new_tag,new_tag_len,msg); |
|
621 |
+ append_str_trans( p,tag_str->s+tag_str->len, |
|
622 |
+ ((hdr->body.s+hdr->body.len )- |
|
623 |
+ (tag_str->s+tag_str->len)),msg); |
|
624 |
+ append_str( p, CRLF,CRLF_LEN,msg); |
|
625 |
+ }else{ |
|
626 |
+ append_str_trans( p, hdr->name.s , |
|
627 |
+ ((hdr->body.s+hdr->body.len )-hdr->name.s ), |
|
628 |
+ msg); |
|
629 |
+ append_str( p, ";tag=",5,msg); |
|
630 |
+ append_str( p, new_tag,new_tag_len,msg); |
|
631 |
+ append_str( p, CRLF,CRLF_LEN,msg); |
|
632 |
+ } |
|
633 |
+ break; |
|
634 |
+ } |
|
635 |
+ case HDR_VIA: |
|
636 |
+ case HDR_FROM: |
|
637 |
+ case HDR_CALLID: |
|
638 |
+ case HDR_CSEQ: |
|
639 |
+ append_str_trans( p, hdr->name.s , |
|
640 |
+ ((hdr->body.s+hdr->body.len )-hdr->name.s ),msg); |
|
641 |
+ append_str( p, CRLF,CRLF_LEN,msg); |
|
627 | 642 |
} |
628 |
-#endif |
|
629 | 643 |
|
630 | 644 |
/* content length header*/ |
631 | 645 |
memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN ); |
... | ... |
@@ -16,8 +16,10 @@ char * build_req_buf_from_sip_req ( struct sip_msg* msg, |
16 | 16 |
char * build_res_buf_from_sip_res( struct sip_msg* msg, |
17 | 17 |
unsigned int *returned_len); |
18 | 18 |
|
19 |
-char * build_res_buf_from_sip_req( unsigned int code , |
|
19 |
+char * build_res_buf_from_sip_req( unsigned int code , |
|
20 | 20 |
char *text , |
21 |
+ char *new_tag , |
|
22 |
+ unsigned int new_tag_len , |
|
21 | 23 |
struct sip_msg* msg, |
22 | 24 |
unsigned int *returned_len); |
23 | 25 |
char* via_builder( struct sip_msg *msg , |
... | ... |
@@ -27,9 +27,14 @@ loop_checks=0 |
27 | 27 |
loadmodule "modules/tm/tm.so" |
28 | 28 |
#loadmodule "modules/rr/rr.so" |
29 | 29 |
loadmodule "modules/maxfwd/maxfwd.so" |
30 |
+loadmodule "modules/sl/sl.so" |
|
30 | 31 |
|
31 | 32 |
|
32 | 33 |
route{ |
34 |
+ if ( !sl_filter_ACK() ){ |
|
35 |
+ log("SER : error in sl_filter_ACK!\n"); |
|
36 |
+ }; |
|
37 |
+ |
|
33 | 38 |
if ( mf_is_maxfwd_present() ) |
34 | 39 |
{ |
35 | 40 |
if ( !mf_decrement_maxfwd() ) |
... | ... |
@@ -39,14 +44,18 @@ route{ |
39 | 44 |
if ( mf_is_maxfwd_zero() ) |
40 | 45 |
{ |
41 | 46 |
log("SER: MAX FORWARD header is zero\n"); |
47 |
+ sl_send_reply("483","Too Many Hops"); |
|
42 | 48 |
drop(); |
43 | 49 |
}; |
44 | 50 |
}else{ |
45 | 51 |
mf_add_maxfwd_header( "10" ); |
46 | 52 |
}; |
47 | 53 |
|
54 |
+ |
|
48 | 55 |
#if (method=="INVITE") |
49 | 56 |
#{ |
57 |
+ #sl_send_reply("404","Not found"); |
|
58 |
+ #drop(); |
|
50 | 59 |
# log("SER : runing CPL!! :)\n"); |
51 | 60 |
# if ( !cpl_run_script() ) |
52 | 61 |
# { |
... | ... |
@@ -63,19 +72,19 @@ route{ |
63 | 72 |
# }; |
64 | 73 |
#}; |
65 | 74 |
|
66 |
- if ( !rewriteFromRoute() ) |
|
67 |
- { |
|
68 |
- log( " SER : no route found!\n"); |
|
69 |
- if ( method=="INVITE" ) |
|
70 |
- { |
|
71 |
- log ("SER : INVITE found - > adding RecordRoute!\n"); |
|
72 |
- addRecordRoute(); |
|
73 |
- }; |
|
74 |
- } |
|
75 |
- else |
|
76 |
- { |
|
77 |
- log( "SER : ROUTE found! \n"); |
|
78 |
- }; |
|
75 |
+ # if ( !rewriteFromRoute() ) |
|
76 |
+ # { |
|
77 |
+ #log( " SER : no route found!\n"); |
|
78 |
+ #if ( method=="INVITE" ) |
|
79 |
+ #{ |
|
80 |
+ # log ("SER : INVITE found - > adding RecordRoute!\n"); |
|
81 |
+ #addRecordRoute(); |
|
82 |
+ #}; |
|
83 |
+ #} |
|
84 |
+ #else |
|
85 |
+ #{ |
|
86 |
+ #log( "SER : ROUTE found! \n"); |
|
87 |
+ #}; |
|
79 | 88 |
|
80 | 89 |
t_relay(); |
81 | 90 |
} |