Hello Daniel,
I end up insert routes like this.  And right now on client side I see only public ip route and private side only private ip routes.

route[ROUTE_HDR_ORG] {
        # Getting record routes
        if(is_present_hf("Route")) {
                xlog("L_INFO", "[$rm], Inbound connection from <$si>\n");
                if(is_method("NOTIFY")) {
                        if(is_ip_rfc1918($si)) {
                              xlog("L_INFO", "[$rm], Present Route: $(route_uri{uri.host})\n");
                              remove_hf("Route");
                              insert_hf("Record-Route: <"sip" + $sel(cfg_get.kamailio.bindpublicip) + ":" $sel(cfg_get.kamailio.bindpublicport);transport=tcp;lr=on;ftag=$ft;nat=yes>\r\n");
                             $fs = "tcp" + ":" + $sel(cfg_get.kamailio.bindpublicip) + ":" + $sel(cfg_get.kamailio.bindpublicport);
                        } else {
                             xlog("L_INFO", "[$rm], Present Route: $(route_uri{uri.host})\n");
                             remove_hf("Route");
                             insert_hf("Record-Route: <"sip" + ":" $sel(cfg_get.kamailio.bindip)  + ":" + $sel(cfg_get.kamailio.bindport);lr=on;ftag=$ft;nat=yes>\r\n");
                             $fs = "udp" + ":" + $sel(cfg_get.kamailio.bindip) + ":" + $sel(cfg_get.kamailio.bindport);
                        }
                }
        }
}

And for initial SUBSCRIBE INVITE

        if (is_method("INVITE|SUBSCRIBE")) {
                remove_hf("Route");
                insert_hf("Record-Route: <"sip" + ":"  + $sel(cfg_get.kamailio.bindip)  + ":" + $sel(cfg_get.kamailio.bindport);lr=on;ftag=$ft;nat=yes>\r\n");
                #record_route();
        }


Slava.


From: "Daniel-Constantin Mierla" <miconda@gmail.com>
To: "Slava Bendersky" <volga629@networklab.ca>, "sr-users" <sr-users@lists.sip-router.org>
Sent: Wednesday, March 18, 2015 4:15:28 AM
Subject: Re: [SR-Users] remove_hf_value

Hello,

but the INVITE request goes out with 2 Record Route headers, if you get them in the 200ok.

Not sure how it is going to work overall, you will have to manually set local sockets for requests within dialog, because you are doing also trasport layer gatewaying (tcp-udp).

Anyhow, as a solution, maybe you should just not be using record_route() function and just add the header with insert_hf() for the invite, remove the Record-Route header for 200ok with remove_hf() and insert a new one again with insert_hf()

If you know the local address (IP/port/transport) you want to put in the Record-Route, you can build the header as:

insert_hf("Record-Route: <sip:_LOCAL_IP_:_LOCAL_PORT_;transport=_LOCAL_TRANSPORT_;lr=on;ftag=$ft;nat=yes>\r\n");

Requests within the dialog can be handled with loose_route(), but again, you have to do more in config for selecting the local socket to send to next hop.

Cheers,
Daniel

On 16/03/15 13:35, Slava Bendersky wrote:
Hello Daniel,
I want do clean up on routes from first SUBSCRIBE, that when traffic goes to public side of kamailio will be only public route and when traffic is internal the Record-Route will stay internal only.  In SDP I see like this.
I tired double routes set 0 in rr, but didn't clean enough.

<--- Transmitting (NAT) to 10.18.130.46:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.18.130.46;branch=z9hG4bKf852.e0223f39c2bbad8366fdf1b7cb22b336.0;i=8;received=10.18.130.46;rport=5060
Via: SIP/2.0/TCP 192.168.88.252:5062;received=client_pub_ipbranch=z9hG4bK0bbe1f7d27257bba9;rport=5062
Record-Route: <sip:10.18.130.46;r2=on;lr=on;ftag=a185d974ec;nat=yes> On public side remote this Record-Route
Record-Route: <sip:kamailio_pub_ip:5084;transport=tcp;r2=on;lr=on;ftag=a185d974ec;nat=yes> On private side remote this Record-Route
From: "Slava Bendersky" <sips:10101@networklab.ca>;tag=a185d974ec
To: <sips:10101@networklab.ca>;tag=as00757d3e
Call-ID: b08adb1ad1804a83
CSeq: 236711034 SUBSCRIBE
Server: FPBX-2.11.0(11.15.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Expires: 3600
Contact: <sip:10101@10.18.130.50:5060>;expires=3600
Content-Length: 0


Slava.


From: "Daniel-Constantin Mierla" <miconda@gmail.com>
To: "sr-users" <sr-users@lists.sip-router.org>
Sent: Monday, March 16, 2015 7:01:54 AM
Subject: Re: [SR-Users] remove_hf_value

Hello,

can you give an example of incoming header and how you want to be after modification?

It is not clear for me what end result you want/expect.

Cheers,
Daniel

On 14/03/15 06:41, Slava Bendersky wrote:
Hello Everyone,
Here updated version.  Trying remove Record-Route after the coma.
My log shows

Mar 14 01:25:21 canlvprx01 /usr/sbin/kamailio[751]: INFO: <script>: [SUBSCRIBE], Inbound connection from <Client Public IP>
Mar 14 01:25:21 canlvprx01 /usr/sbin/kamailio[751]: ERROR: <script>: <null>
Mar 14 01:25:21 canlvprx01 /usr/sbin/kamailio[751]: INFO: <script>: [SUBSCRIBE], Route for removal: '<null>'

route snippet.

route[ROUTE_HDR_ORG] {
        # Getting record routes
        if(is_present_hf("Route")) {
                xlog("L_INFO", "[$rm], Inbound connection from <$si>\n");
                if(is_method("SUBSCRIBE")) {
                        if(is_ip_rfc1918($si)) {
                                xlog("$sel(@hf_value.Record_Route[-1])");
                                xlog("L_INFO", "[$rm], Route for removal: '$sel(@hf_value.Record_Route[-1])'\n");
                                remove_hf_value("Record-Route[-1]");
                        } else {
                                xlog("$sel(@hf_value.Record_Route[1])");
                                xlog("L_INFO", "[$rm], Route for removal: '$sel(@hf_value.Record_Route[1])'\n");
                                remove_hf_value("Record-Route[1]");
                        }
                }
        }
        return;
}


Slava,

From: "Slava Bendersky" <volga629@networklab.ca>
To: "sr-users" <sr-users@lists.sip-router.org>
Sent: Friday, March 13, 2015 1:00:44 PM
Subject: [SR-Users] remove_hf_value

Hello Everyone,
I am trying adjust Record-Route, but can't match headers value

And I am call route(ROUTE_HDR_ORG); right after route(WITHINDLG);

route[ROUTE_HDR_ORG] {
        # Getting record routes
        if(is_present_hf("Record-Route")) {
                if(is_method("SUBSCRIBE")) {
                        xlog("$sel(@hf_value.Record_Route[1])");
                        xlog("L_INFO", "[$rm], Route for removal: '$sel(@hf_value.Record_Route[1])'\n");
                        remove_hf_value("Record-Route[1]");
                }
        }
        return;
}

Any help Thank you,
Slava.

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - http://www.kamailioworld.com

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - http://www.kamailioworld.com