<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Dear all,<br>
    <br>
    I have an on-reply route that needs to change the SDP version for
    the reply coming in. The use case is that I have a mobile originated
    call and there is some Ericsson switch that doesn't like it when the
    SDP version is updated (in this case by asterisk) although nothing
    has changed to the actual SDP (183 session progress and then OK.) 
    Funny thing is that Asterisk will actually drop a call if it
    receives a re-INVITE with same version... That's why they invented
    ignoresdpversion, but now it's the other way around.... :)<br>
    <br>
    Mobile phone -> Ericsson MSC -> ACME packet ->
    (18X.4X.XXX.XX) Kamailio (10.41.0.21) -> Asterisk<br>
    <br>
    The issue is that the asterisk sends a reply 200 OK, with an updated
    version because it already sent SDP for 183 session progress. This
    can be patched in asterisk, but in my scenario I can unfortunately
    not do that. Thus trying to fix this on Kamailio.<br>
    <br>
    I am able to 'fix' this currently by performing a subst on the sdp
    owner variable:<br>
    <br>
    onreply_route[WITHSDP] {<br>
            if (has_body("application/sdp")) {<br>
                    if(ds_is_from_list()) {<br>
                            rtpproxy_answer("wrei"); <br>
                          <b> if(subst("/^o=someowner ([0-9]+) ([0-9]+)
      IN IP4 (.*)$/o=someowner \1 \1 IN IP4 \3/")) {</b><br>
                                   xlog("L_INFO", "Fixed Asterisk
    incorrect version number in SDP");<br>
                           }<br>
                           # tried the answer here as well, but that
    corrupts it even more<br>
                    }<br>
                    else {<br>
                            rtpproxy_answer("wrie");<br>
                    }<br>
            }<br>
            exit; <br>
    }<br>
    <br>
    However this corrupts the SDP:<br>
    <br>
    v=0<br>
    o=tismi 652858233 652858233 IN IP4 10.41.0.21<b>18X.4X.XXX.XX</b><br>
    s=Some server<br>
    c=IN IP4 18X.4X.XXX.XX<br>
    t=0 0<br>
    m=audio 57644 RTP/AVP 8 0 18 3 101<br>
    a=rtpmap:8 PCMA/8000<br>
    a=rtpmap:0 PCMU/8000<br>
    a=rtpmap:18 G729/8000<br>
    a=fmtp:18 annexb=no<br>
    a=rtpmap:3 GSM/8000<br>
    a=rtpmap:101 telephone-event/8000<br>
    a=fmtp:101 0-16<br>
    a=silenceSupp:off - - - -<br>
    a=ptime:20<br>
    a=sendrecv<br>
    a=nortpproxy:yes<br>
    <br>
    When I do not substitute the SDP looks perfectly fine and the
    external address shows as the IN IP4. But of course the version is
    incremented:<br>
    <br>
    v=0<br>
    o=tismi 1606876535 <b>1606876536</b> IN IP4 <b>18X.4X.XXX.XX</b><br>
    s=Some server<br>
    c=IN IP4 18X.4X.XXX.XX<br>
    t=0 0<br>
    m=audio 55410 RTP/AVP 8 0 18 101<br>
    a=rtpmap:8 PCMA/8000<br>
    a=rtpmap:0 PCMU/8000<br>
    a=rtpmap:18 G729/8000<br>
    a=fmtp:18 annexb=no<br>
    a=rtpmap:101 telephone-event/8000<br>
    a=fmtp:101 0-16<br>
    a=silenceSupp:off - - - -<br>
    a=ptime:20<br>
    a=sendrecv<br>
    a=sdpmangled:yes<br>
    <br>
    <br>
    The ericsson is now accepting this (although it's corrupt, I
    know.... probably the ACME doing something funky with it), but it
    causes issues with another unknown piece of equipment that fails on
    parsing the session owner. I hope there is something wrong with my
    subst, but I'm afraid I can not do this from the on_reply route
    because SDP is only updated once it finishes?<br>
    <br>
    I know it's dangerous to alter the session version like this, so I
    made sure the Asterisk will never send a re-INVITE. Now I need a way
    to not corrupt the o=<br>
    <br>
    Kind regards,<br>
    <br>
    Matthias van der Vlies<br>
    <br>
    <br>
  </body>
</html>