...
|
...
|
@@ -84,8 +84,8 @@
|
84
|
84
|
|
85
|
85
|
int tm_unix_tx_timeout = 2; /* Default is 2 seconds */
|
86
|
86
|
|
87
|
|
-#define TWRITE_PARAMS 21
|
88
|
|
-#define TWRITE_VERSION_S "0.2"
|
|
87
|
+#define TWRITE_PARAMS 20
|
|
88
|
+#define TWRITE_VERSION_S "0.3"
|
89
|
89
|
#define TWRITE_VERSION_LEN (sizeof(TWRITE_VERSION_S)-1)
|
90
|
90
|
#define eol_line(_i_) ( lines_eol[2*(_i_)] )
|
91
|
91
|
|
...
|
...
|
@@ -354,7 +354,7 @@ int parse_tw_append( modparam_t type, void* val)
|
354
|
354
|
}
|
355
|
355
|
foo.s[foo.len] = bar;
|
356
|
356
|
ha->ival = hdr.type;
|
357
|
|
- if (hdr.type==HDR_OTHER_T || ha->title.s==0) {
|
|
357
|
+ if (hdr.type==HDR_OTHER || ha->title.s==0) {
|
358
|
358
|
/* duplicate hdr name */
|
359
|
359
|
ha->sval.s = (char*)pkg_malloc(foo.len+1);
|
360
|
360
|
if (ha->sval.s==0) {
|
...
|
...
|
@@ -559,7 +559,7 @@ error:
|
559
|
559
|
|
560
|
560
|
|
561
|
561
|
static inline char* add2buf(char *buf, char *end, char *title, int title_len,
|
562
|
|
- char *value , int value_len)
|
|
562
|
+ char *value , int value_len)
|
563
|
563
|
{
|
564
|
564
|
if (buf+title_len+value_len+2+1>=end)
|
565
|
565
|
return 0;
|
...
|
...
|
@@ -575,7 +575,7 @@ static inline char* add2buf(char *buf, char *end, char *title, int title_len,
|
575
|
575
|
|
576
|
576
|
|
577
|
577
|
static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
578
|
|
- struct hdr_avp *ha)
|
|
578
|
+ struct hdr_avp *ha)
|
579
|
579
|
{
|
580
|
580
|
struct hdr_field *hdr;
|
581
|
581
|
struct usr_avp *avp;
|
...
|
...
|
@@ -594,9 +594,11 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
594
|
594
|
if (ha->sval.s) {
|
595
|
595
|
avp_name.s=&ha->sval;
|
596
|
596
|
avp = search_first_avp( AVP_NAME_STR, avp_name, &avp_val);
|
|
597
|
+ DBG("AVP <%.*s>: %x\n",avp_name.s->len,avp_name.s->s,(unsigned int)avp);
|
597
|
598
|
} else {
|
598
|
599
|
avp_name.n=ha->ival;
|
599
|
600
|
avp = search_first_avp( 0, avp_name, &avp_val);
|
|
601
|
+ DBG("AVP <%i>: %x\n",avp_name.n,(unsigned int)avp);
|
600
|
602
|
}
|
601
|
603
|
if (avp) {
|
602
|
604
|
if (avp->flags&AVP_VAL_STR) {
|
...
|
...
|
@@ -615,14 +617,14 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
|
615
|
617
|
} else if (ha->type==ELEM_IS_HDR) {
|
616
|
618
|
/* parse the HDRs */
|
617
|
619
|
if (!msg_parsed) {
|
618
|
|
- if (parse_headers( req, HDR_EOH_F, 0)!=0) {
|
|
620
|
+ if (parse_headers( req, HDR_EOH, 0)!=0) {
|
619
|
621
|
LOG(L_ERR,"ERROR:tm:append2buf: parsing hdrs failed\n");
|
620
|
622
|
goto error;
|
621
|
623
|
}
|
622
|
624
|
msg_parsed = 1;
|
623
|
625
|
}
|
624
|
626
|
/* search the HDR */
|
625
|
|
- if (ha->ival==HDR_OTHER_T) {
|
|
627
|
+ if (ha->ival==HDR_OTHER) {
|
626
|
628
|
for(hdr=req->headers;hdr;hdr=hdr->next)
|
627
|
629
|
if (ha->sval.len==hdr->name.len &&
|
628
|
630
|
strncasecmp( ha->sval.s, hdr->name.s, hdr->name.len)==0)
|
...
|
...
|
@@ -681,7 +683,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
681
|
683
|
}
|
682
|
684
|
|
683
|
685
|
/* parse all -- we will need every header field for a UAS */
|
684
|
|
- if ( parse_headers(msg, HDR_EOH_F, 0)==-1) {
|
|
686
|
+ if ( parse_headers(msg, HDR_EOH, 0)==-1) {
|
685
|
687
|
LOG(L_ERR,"assemble_msg: parse_headers failed\n");
|
686
|
688
|
goto error;
|
687
|
689
|
}
|
...
|
...
|
@@ -771,7 +773,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
771
|
773
|
}
|
772
|
774
|
for(p_hdr = p_hdr->next;p_hdr;p_hdr = p_hdr->next) {
|
773
|
775
|
/* filter out non-RR hdr and empty hdrs */
|
774
|
|
- if( (p_hdr->type!=HDR_RECORDROUTE_T) || p_hdr->body.len==0)
|
|
776
|
+ if( (p_hdr->type!=HDR_RECORDROUTE) || p_hdr->body.len==0)
|
775
|
777
|
continue;
|
776
|
778
|
|
777
|
779
|
if(p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ){
|
...
|
...
|
@@ -816,13 +818,19 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
816
|
818
|
|
817
|
819
|
/* additional headers */
|
818
|
820
|
append.s = s = append_buf;
|
819
|
|
- if (sizeof(flag_t)+12+1 >= APPEND_BUFFER_MAX) {
|
|
821
|
+ if (sizeof(flag_t)*2+12+1 >= APPEND_BUFFER_MAX) {
|
820
|
822
|
LOG(L_ERR,"assemble_msg: buffer overflow "
|
821
|
823
|
"while copying optional header\n");
|
822
|
824
|
goto error;
|
823
|
825
|
}
|
824
|
826
|
append_str(s,"P-MsgFlags: ",12);
|
825
|
|
- int2reverse_hex(&s, &l, (int)msg->msg_flags);
|
|
827
|
+ l = APPEND_BUFFER_MAX - (12+1); /* include trailing `\n'*/
|
|
828
|
+
|
|
829
|
+ if (int2reverse_hex(&s, &l, (int)msg->msg_flags) == -1) {
|
|
830
|
+ LOG(L_ERR,"assemble_msg: buffer overflow "
|
|
831
|
+ "while copying optional header\n");
|
|
832
|
+ goto error;
|
|
833
|
+ }
|
826
|
834
|
append_chr(s,'\n');
|
827
|
835
|
|
828
|
836
|
if ( twi->append && ((s=append2buf( s, APPEND_BUFFER_MAX-(s-append.s), msg,
|
...
|
...
|
@@ -845,28 +853,27 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
845
|
853
|
|
846
|
854
|
eol_line(2)=REQ_LINE(msg).method; /* method type */
|
847
|
855
|
eol_line(3)=msg->parsed_uri.user; /* user from r-uri */
|
848
|
|
- eol_line(4)=empty_param; /* email - TODO -remove it */
|
849
|
|
- eol_line(5)=msg->parsed_uri.host; /* domain */
|
|
856
|
+ eol_line(4)=msg->parsed_uri.host; /* domain */
|
850
|
857
|
|
851
|
|
- eol_line(6)=msg->rcv.bind_address->address_str; /* dst ip */
|
|
858
|
+ eol_line(5)=msg->rcv.bind_address->address_str; /* dst ip */
|
852
|
859
|
|
853
|
|
- eol_line(7)=msg->rcv.dst_port==SIP_PORT ?
|
|
860
|
+ eol_line(6)=msg->rcv.dst_port==SIP_PORT ?
|
854
|
861
|
empty_param : msg->rcv.bind_address->port_no_str; /* port */
|
855
|
862
|
|
856
|
863
|
/* r_uri ('Contact:' for next requests) */
|
857
|
|
- eol_line(8)=msg->first_line.u.request.uri;
|
|
864
|
+ eol_line(7)=msg->first_line.u.request.uri;
|
858
|
865
|
|
859
|
866
|
/* r_uri for subsequent requests */
|
860
|
|
- eol_line(9)=str_uri.len?str_uri:empty_param;
|
|
867
|
+ eol_line(8)=str_uri.len?str_uri:empty_param;
|
861
|
868
|
|
862
|
|
- eol_line(10)=get_from(msg)->body; /* from */
|
863
|
|
- eol_line(11)=msg->to->body; /* to */
|
864
|
|
- eol_line(12)=msg->callid->body; /* callid */
|
865
|
|
- eol_line(13)=get_from(msg)->tag_value; /* from tag */
|
866
|
|
- eol_line(14)=get_to(msg)->tag_value; /* to tag */
|
867
|
|
- eol_line(15)=get_cseq(msg)->number; /* cseq number */
|
|
869
|
+ eol_line(9)=get_from(msg)->body; /* from */
|
|
870
|
+ eol_line(10)=msg->to->body; /* to */
|
|
871
|
+ eol_line(11)=msg->callid->body; /* callid */
|
|
872
|
+ eol_line(12)=get_from(msg)->tag_value; /* from tag */
|
|
873
|
+ eol_line(13)=get_to(msg)->tag_value; /* to tag */
|
|
874
|
+ eol_line(14)=get_cseq(msg)->number; /* cseq number */
|
868
|
875
|
|
869
|
|
- eol_line(16).s=id_buf; /* hash:label */
|
|
876
|
+ eol_line(15).s=id_buf; /* hash:label */
|
870
|
877
|
s = int2str(hash_index, &l);
|
871
|
878
|
if (l+1>=IDBUF_LEN) {
|
872
|
879
|
LOG(L_ERR, "assemble_msg: too big hash\n");
|
...
|
...
|
@@ -874,19 +881,19 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
|
874
|
881
|
}
|
875
|
882
|
memcpy(id_buf, s, l);
|
876
|
883
|
id_buf[l]=':';
|
877
|
|
- eol_line(16).len=l+1;
|
|
884
|
+ eol_line(15).len=l+1;
|
878
|
885
|
s = int2str(label, &l);
|
879
|
|
- if (l+1+eol_line(16).len>=IDBUF_LEN) {
|
|
886
|
+ if (l+1+eol_line(15).len>=IDBUF_LEN) {
|
880
|
887
|
LOG(L_ERR, "assemble_msg: too big label\n");
|
881
|
888
|
goto error;
|
882
|
889
|
}
|
883
|
|
- memcpy(id_buf+eol_line(16).len, s, l);
|
884
|
|
- eol_line(16).len+=l;
|
|
890
|
+ memcpy(id_buf+eol_line(15).len, s, l);
|
|
891
|
+ eol_line(15).len+=l;
|
885
|
892
|
|
886
|
|
- eol_line(17) = route.len ? route : empty_param;
|
887
|
|
- eol_line(18) = next_hop;
|
888
|
|
- eol_line(19) = append;
|
889
|
|
- eol_line(20) = body;
|
|
893
|
+ eol_line(16) = route.len ? route : empty_param;
|
|
894
|
+ eol_line(17) = next_hop;
|
|
895
|
+ eol_line(18) = append;
|
|
896
|
+ eol_line(19) = body;
|
890
|
897
|
|
891
|
898
|
/* success */
|
892
|
899
|
return 1;
|