SER gurus:
    I am an newbie to SER usuage. At present a dynamic redirect issue happens to me. But it is very pity for SER not to support this case!!
 
Problem Description:
====================
    When configuring SER as only redirect server, config file regarding redirect routing section is partly writen as follows:
#-----------------------request routing logic-------------------------
#main routing logic
    if (method=="INVITE") {
    #rewrite current URI, which is always part of destination ser
        rewriteuri("sip:80000000@192.168.0.191:5060");
    #redirect now
        sl_send_reply("301", "Redirect");
        break;
    }
#---------------------------------------------------------------------
    where, redirecting destination URI is staticly configed into SER, but dynamic destination URI is what our IP-PBX product(RTCCP) want to hope.
    The following call flow diagram helps to understand above mentioned scenario.
 
         GrandStream HandyTone486              SER                       Our B2BUA IP PBX(RTCCP)
         IP: 192.168.0.253              IP: 192.168.0.252                  IP: 192.168.0.191
+++++++++++++++++++++++++++++++++++++ First Call+++++++++++++++++++++++++++++++++++++++++++++++++
         |-----------------F1(INVITE)---------->|
         |<-----------------F2(302)------------>|
         |-----------------F3(ACK)------------->|
         |------------------------------------F4(INVITE)------------------------>|
                           ( The subsequent call flow is omitted )
+++++++++++++++++++++++++++++++++++++ Second Call+++++++++++++++++++++++++++++++++++++++++++++++++
         |-----------------F5(INVITE)---------->|
         |<-----------------F6(302)------------>|
         |-----------------F7(ACK)------------->|
         |------------------------------------F8(INVITE)------------------------>|
                           ( The subsequent call flow is omitted )
F1:
INVITE sip:8000000@192.168.0.252;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.0.233;branch=z9hG4bKb537ec0f1387845f
From: "60000253" <sip:60000253@192.168.0.252;user=phone>;tag=c526ecce44ec6d75
To: <sip:8000000@192.168.0.252;user=phone>
Contact: <sip:60000253@192.168.0.233;user=phone>
Supported: replaces
Call-ID: d6169571fe4f59a2@192.168.0.233
CSeq: 50105 INVITE
User-Agent: Grandstream HT487 1.0.5.16
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE
Content-Type: application/sdp
Content-Length: 330
 
v=0
o=60000253 0 8000 IN IP4 192.168.0.233
s=SIP Call
c=IN IP4 192.168.0.233
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 2 15 99
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:15 G728/8000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=20
a=ptime:20
F2:
SIP/2.0 301 Redirect
Via: SIP/2.0/UDP 192.168.0.233;branch=z9hG4bKb537ec0f1387845f
From: "60000253" <sip:60000253@192.168.0.252;user=phone>;tag=c526ecce44ec6d75
To: <sip:8000000@192.168.0.252;user=phone>;tag=b27e1a1d33761e85846fc98f5f3a7e58.f9ed
Call-ID: d6169571fe4f59a2@192.168.0.233
CSeq: 50105 INVITE
Contact: sip:80000000@192.168.0.191:5060
Server: Sip EXpress router (0.8.12 (i386/linux))
Content-Length: 0
Warning: 392 192.168.0.252:5060 "Noisy feedback tells:  pid=6155 req_src_ip=192.168.0.233 req_src_port=5060 in_uri=sip:8000000@192.168.0.252;user=phone out_uri=sip:80000000@192.168.0.191:5060 via_cnt==1"
 
F4:
INVITE sip:80000000@192.168.0.191:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.233;branch=z9hG4bKc6905874d1906c58
From: "60000253" <sip:60000253@192.168.0.252;user=phone>;tag=1be4a5d7d169d8f1
To: <sip:80000000@192.168.0.191:5060>
Contact: <sip:60000253@192.168.0.233;user=phone>
Supported: replaces
Call-ID: 0d325b0e778321ee@192.168.0.233
CSeq: 17809 INVITE
User-Agent: Grandstream HT487 1.0.5.16
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE
Content-Type: application/sdp
Content-Length: 330
 
v=0
o=60000253 0 8000 IN IP4 192.168.0.233
s=SIP Call
c=IN IP4 192.168.0.233
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 2 15 99
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:15 G728/8000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=20
a=ptime:20
F5:
INVITE sip:80000002@192.168.0.252;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.0.233;branch=z9hG4bKe966424e91ceac8e
From: "60000253" <sip:60000253@192.168.0.252;user=phone>;tag=466d9b06b51ca7b4
To: <sip:80000002@192.168.0.252;user=phone>
Contact: <sip:60000253@192.168.0.233;user=phone>
Supported: replaces
Call-ID: c755c6b0908a8ce9@192.168.0.233
CSeq: 25248 INVITE
User-Agent: Grandstream HT487 1.0.5.16
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE
Content-Type: application/sdp
Content-Length: 330
 
v=0
o=60000253 0 8000 IN IP4 192.168.0.233
s=SIP Call
c=IN IP4 192.168.0.233
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 2 15 99
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:15 G728/8000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=20
a=ptime:20
F6:
SIP/2.0 301 Redirect
Via: SIP/2.0/UDP 192.168.0.233;branch=z9hG4bKe966424e91ceac8e
From: "60000253" <sip:60000253@192.168.0.252;user=phone>;tag=466d9b06b51ca7b4
To: <sip:80000002@192.168.0.252;user=phone>;tag=b27e1a1d33761e85846fc98f5f3a7e58.7906
Call-ID: c755c6b0908a8ce9@192.168.0.233
CSeq: 25248 INVITE
Contact: sip:80000000@192.168.0.191:5060
Server: Sip EXpress router (0.8.12 (i386/linux))
Content-Length: 0
Warning: 392 192.168.0.252:5060 "Noisy feedback tells:  pid=6151 req_src_ip=192.168.0.233 req_src_port=5060 in_uri=sip:80000002@192.168.0.252;user=phone out_uri=sip:80000000@192.168.0.191:5060 via_cnt==1"
 
F8:
INVITE sip:80000000@192.168.0.191:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.233;branch=z9hG4bK475fff37270b762d
From: "60000253" <sip:60000253@192.168.0.252;user=phone>;tag=58a90f4229e70a80
To: <sip:80000000@192.168.0.191:5060>
Contact: <sip:60000253@192.168.0.233;user=phone>
Supported: replaces
Call-ID: 2a79d9ac84e2f72e@192.168.0.233
CSeq: 62121 INVITE
User-Agent: Grandstream HT487 1.0.5.16
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE
Content-Type: application/sdp
Content-Length: 330
 
v=0
o=60000253 0 8000 IN IP4 192.168.0.233
s=SIP Call
c=IN IP4 192.168.0.233
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 2 15 99
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:15 G728/8000
a=rtpmap:99 iLBC/8000
a=fmtp:99 mode=20
a=ptime:20
    In fact, I think SER should retrieve user portion of header "to" URI of Invite message(for above example it should be 80000000 for first call,whereas 80000002 for second call) to construct userinfo of destination redirect uri for header contact of 3xx response(but hostinfo maybe get from SER config file). Meanwhile I study into sl_send_reply source code, but no progress to issue.
    So any suggestions or solutions are appreciated!!
 
Thanks in advance!!
 
 
                                                                          George Lee(ShenZhen, CHINA)