<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 09/10/14 13:19, Errol Samuels wrote:<br>
    </div>
    <blockquote
cite="mid:CAJvCycftGwPotGW=XYmifqX-Nj94=a+i9FM4h_QWXaQn9ppMYA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>HI Daniel,<br>
                <br>
                Thanks for that.<br>
                <br>
              </div>
              In my case I would need to use something like:<br>
              <br>
              user_agent_header = "X-Proxy: $ua"<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    The only purpose of the above line is that Kamailio doesn't add an
    User-Agent header by itself, but this X-Proxy (which you can change
    as well).<br>
    <br>
    Then you still add User-Agent in $uac_req(hdrs), but you don't end
    up with two User-Agent headers anymore.<br>
    <br>
    Hope is more clear now the purpose of X-Proxy header.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <blockquote
cite="mid:CAJvCycftGwPotGW=XYmifqX-Nj94=a+i9FM4h_QWXaQn9ppMYA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div><br>
            </div>
            since we don't what to hardcode a specific value which would
            affect every device that is registering but rather $ua which
            would set the real UA of the device that is registering at
            that time.<br>
            <br>
          </div>
          Does that make sense?<br>
          <br>
        </div>
        regards,<br>
        <br>
        Errol<br>
        <br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Oct 9, 2014 at 12:09 PM,
          Daniel-Constantin Mierla <span dir="ltr"><<a
              moz-do-not-send="true" href="mailto:miconda@gmail.com"
              target="_blank">miconda@gmail.com</a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>
                <div class="h5"> <br>
                  <div>On 08/10/14 19:25, Errol Samuels wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div>I followed Daniel's instructions and made
                        some progress but not 100% there yet.<br>
                        <br>
                        -------[Global section]----------<br>
                                   <br>
                        user_agent_header=""<br>
                             <br>
                        -------[Main Routing Logic]-------<br>
                        <br>
                        # handle registrations<br>
                                if (is_method("REGISTER"))<br>
                                {  <br>
                                $avp(new_user_agent) = $ua;<br>
                                }<br>
                                route(REGISTRAR);<br>
                        .<br>
                        .<br>
                        <br>
                        # Forward REGISTER to Freeswitch<br>
                        route[REGFWD] {<br>
                        <br>
                                if(!is_method("REGISTER"))<br>
                                {<br>
                                        return;<br>
                                }<br>
                                route(DISPATCH);<br>
                                $uac_req(method)="REGISTER";<br>
                                $uac_req(ruri)=$du;<br>
                                $uac_req(furi)=$fn + "<sip:" + $au +
                        "@" + $ar + ">";<br>
                                $uac_req(turi)=$tn + "<sip:" + $au +
                        "@" + $ar + ">";<br>
                                $uac_req(hdrs)="Contact: <sip:" + $au
                        + "@"<br>
                                                        + $ar<br>
                                                        +
                        ";fs_path=sip:"<br>
                                                        +
                        $sel(cfg_get.kamailio.bindip)<br>
                                                        + ":" +
                        $sel(cfg_get.kamailio.bindport)<br>
                                                        + ">"<br>
                                                        + "\r\n";<br>
                                if($sel(contact.expires) != $null)<br>
                                        $uac_req(hdrs)= $uac_req(hdrs) +
                        "Expires: " + $sel(contact.expires) + "\r\n";<br>
                                else<br>
                                        $uac_req(hdrs)= $uac_req(hdrs) +
                        "Expires: " + $hdr(Expires) + "\r\n";<br>
                                $uac_req(hdrs)= $uac_req(hdrs) +
                        "User-Agent: " + $avp(new_user_agent) + "\r\n";<br>
                                uac_req_send();<br>
                                exit;<br>
                        }<br>
                        #!endif<br>
                        <br>
                        ------------<br>
                        <br>
                        Now the correct User-Agent appears in the
                        REGISTER message but in Freeswitch it shows as
                        unknown.<br>
                        <br>
                        U 184.xx.xx.208:5060 -> 184.xx.xx.198:6060<br>
                        REGISTER <a moz-do-not-send="true">sip:184.x.x.198:6060</a>
                        SIP/2.0.<br>
                        Via: SIP/2.0/UDP
                        184.xx.xx.208;branch=z9hG4bKa764.668d6dc7.0.<br>
                        To: <<a moz-do-not-send="true"
                          href="mailto:sip%3A1001@pbx.mydomain.com"
                          target="_blank">sip:1001@pbx.mydomain.com</a>>.<br>
                        From: <<a moz-do-not-send="true"
                          href="mailto:sip%3A1001@pbx.mydomain.com"
                          target="_blank">sip:1001@pbx.mydomain.com</a>>;tag=6f72f76f3402bf7cf11f6917529ca761-2ceb.<br>
                        CSeq: 10 REGISTER.<br>
                        Call-ID: <a moz-do-not-send="true"
                          href="mailto:4570a277563cdffc-61869@184.xx.xx.208"
                          target="_blank">4570a277563cdffc-61869@184.xx.xx.208</a>.<br>
                        Max-Forwards: 70.<br>
                        Content-Length: 0.<br>
                        .<br>
                        Contact: <<a moz-do-not-send="true"
                          href="mailto:sip%3A1001@pbx.mydomain.com"
                          target="_blank">sip:1001@pbx.mydomain.com</a>;fs_path=<a
                          moz-do-not-send="true">sip:184.xx.xx.208:5060</a>>.<br>
                        Expires: 120.<br>
                        User-Agent: Yealink SIP-T46G 28.72.0.26.<br>
                        .<br>
                        ----------------<br>
                        <br>
                        Got some extra dots in there but not sure why
                        they are there and how they got there.<br>
                        Any ideas? Anything I missed?<br>
                      </div>
                    </div>
                  </blockquote>
                  <br>
                </div>
              </div>
              Apparently by setting an empty user-agent header value in
              kamailio config file results in an empty line in headers,
              which means end of headers. So it kind of breaks the
              headers -- I will fix that in kamailio.<br>
              <br>
              A solution for now will be to use:<br>
              <br>
              user_agent_header = "X-Proxy: abc"<br>
              <br>
              Or, in other words, set the value of the parameter to
              something that doesn't include User-Agent: as header name.<br>
              <br>
              Cheers,<br>
              Daniel<span class=""><br>
                 <br>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div><br>
                      BR<br>
                      <br>
                    </div>
                    Errol<br>
                    <br>
                    <div><br>
                      <div class="gmail_extra"><br>
                        <div class="gmail_quote">On Wed, Oct 8, 2014 at
                          12:34 PM, Daniel-Constantin Mierla <span
                            dir="ltr"><<a moz-do-not-send="true"
                              href="mailto:miconda@gmail.com"
                              target="_blank">miconda@gmail.com</a>></span>
                          wrote:<br>
                          <blockquote class="gmail_quote"
                            style="margin:0px 0px 0px
                            0.8ex;border-left:1px solid
                            rgb(204,204,204);padding-left:1ex">
                            <div bgcolor="#FFFFFF" text="#000000">
                              Perhaps you can get it with adding
                              User-Agent header to $uac_req(hdrs):<br>
                              <br>
                              $uac_req(hdrs)= $uac_req(hdrs) +
                              "User-Agent: " + $ua + "\r\n";<br>
                              <br>
                              And sent the global parameter:<br>
                              <br>
                              user_agent_header=""<br>
                              <br>
                              But then no local generated request has
                              user agent, which probably is ok for you.<br>
                              <br>
                              There are still ways to use
                              event_route[tm:local-request] to set a
                              custom user agent header, but would
                              require something like:<br>
                              - add $us in $uac_req(hdrs) as X-UA header<br>
                              - in event_route[tm:local-request], remove
                              User-Agent and X-UA headers and add again
                              User-Agent taking the value from X-UA<br>
                              <br>
                              Cheers,<br>
                              Daniel
                              <div>
                                <div><br>
                                  <br>
                                  <br>
                                </div>
                              </div>
                            </div>
                            <br>
                          </blockquote>
                        </div>
                        <br>
                      </div>
                    </div>
                  </div>
                </blockquote>
                <br>
              </span><span class="">
                <pre cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
              </span></div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
  </body>
</html>