inserting < and > bracket around URI

Stefan
2012-04-05
2013-05-09
  • Stefan
    Stefan
    2012-04-05

    Hi Bogdan,
    I am trying to create a CONTACT reply header that contains a semicolon ";"
    this is the goal
    <sip:user@domain;maddr=nexthop>

    by constructing like with construct_uri(proto,user,domain,port,extra,result_avp) or filling $avp(anything)="blabla"

    constructing/filling works fine but the "<" and the ">" are missing and are required according to RFC3261

    so the results is (according to wireshark)
    sip:user@domain;maddr=nexthop (observe the absence of < and >)

    So how can I insert these brackets in OPENSIPS?

    RFC3261
    "The Contact, From, and To header fields contain a URI.  If the URI
       contains a comma, question mark or semicolon, the URI MUST be
       enclosed in angle brackets (< and >).  Any URI parameters are
       contained within these brackets.  If the URI is not enclosed in angle
       brackets, any semicolon-delimited parameters are header-parameters,
       not URI parameters."

     
  • Hi Stefan,

    A SIP URI does not contain the angle brackets, so the construct_uri() is correct. As per RFC, the  brackets are required to enclose the URI in a name-addr header, only if the URI has paramters - just to separate the URI params from the hdr param.

    Some name-addr headers are : From, To, RPID, Contact, RR, Route.

    So, you need to add the brackets only when pushing the SIP URI into the contact hdr - but this depends on how do you push the URI.

    Regards,
    Bogdan

     
  • Stefan
    Stefan
    2012-04-06

    Hi Bogdan, thanks for the quick reply

    Snippet below shows my attempt to push into the $ru and send 302 Redirect reply (I am constructing redirect server, we spoke before about that)

    but opensips says: 475 BAD URI and shows the following log

    LOG SAYS:
    2012-04-06T13:51:01.956916+02:00 pmnlapp01 /usr/sbin/opensips: ERROR:core:parse_uri: bad uri,  state 0 parsed: <<sip> (4) / <<sip:+31621265968@alternativedomain;maddr=nexthop>> (53)
    2012-04-06T13:51:01.956929+02:00 pmnlapp01 /usr/sbin/opensips: ERROR:core:parse_sip_msg_uri: bad uri <<sip:+31621265968@alternativedomain;maddr=nexthop>>
    2012-04-06T13:51:01.956941+02:00 pmnlapp01 /usr/sbin/opensips: DBG:core:set_err_info: ec: 1, el: 3, ei: 'error parsing r-uri'
    2012-04-06T13:51:01.956953+02:00 pmnlapp01 /usr/sbin/opensips: ERROR:tm:new_t: uri invalid
    2012-04-06T13:51:01.956965+02:00 pmnlapp01 /usr/sbin/opensips: ERROR:tm:t_newtran: new_t failed

    You must have the answer with a snap of your fingers..
    regards
    Stefan

    SNIPPET:

    route{
    ……….
    construct_uri("sip","$avp(origcdn)","alternativedomain","","maddr=nexthop",$avp(contact)); OR # ALSO WORKS

    $avp(contact)="sip:"+$avp(origcdn)+"@alternativedomain;maddr=nexthop";

    $ru="<"+$avp(contact)+">";      # PUSH NEW DESTINATION INTO REQUEST URI

    }

    route {

            if (t_newtran()) {
                    t_reply("$avp(causevalue)","$avp(cause)"); # $avp(causevalue) USUALLY CONTAINS 302, BECAUSE THIS IS A REDIRECT SERVER
            } else sl_reply_error();

            exit;
    }

     
  • Stefan,

    Investigating more, it seems to be a bug in the way that Contact hdr is built for 3xx replies. Please drop me an email and I will send you a patch for testing.

    Regards,
    Bogdan

     
  • Stefan
    Stefan
    2012-04-06

    Hi Bogdan, please find it in your mailbox
    Stefan