[SR-Users] Playing with dlg_bridge()

Roberto Fichera kernel at tekno-soft.it
Tue Jul 5 18:46:49 CEST 2011


Hi All in the list,

I want to implement a click and dial feature using the xhttp interface
but also keeping working the XCAP functionality. Than I added some
code about the dialog module (it's my first time I try it) so that the
URL look like http://localhost:5060/sip-bridge/<from>/<to>

#!ifdef WITH_XCAPSRV
#!define WITH_XHTTPAUTH
event_route[xhttp:request] {
  xdbg("===== xhttp: request [$rv] $rm => $hu\n");
 
  if($hu=~"^/xcap-root/")
  {
#!ifdef WITH_XHTTPAUTH
    if (!www_authorize("xcap", "subscriber"))
    {
      www_challenge("xcap", "0");
      exit;
    }
#!endif
    set_reply_close();
    set_reply_no_connect();
    # xcap ops
    $xcapuri(u=>data) = $hu;
    if($xcapuri(u=>xuid)=~"^sip:.+ at .+")
      $var(uri) = $xcapuri(u=>xuid);
    else if($xcapuri(u=>xuid)=~".+ at .+")
      $var(uri) = "sip:" + $xcapuri(u=>xuid);
    else
      $var(uri) = "sip:"+ $xcapuri(u=>xuid) + "@" + $Ri;
    xlog("===== xhttp: $xcapuri(u=>auid) : $xcapuri(u=>xuid)\n");
    if($xcapuri(u=>auid)=="xcap-caps")
    {
      $var(xbody) =
"<?xml version='1.0' encoding='UTF-8'?>
<xcap-caps xmlns='urn:ietf:params:xml:ns:xcap-caps'>
  <auids>
    <auid>rls-services</auid>
    <auid>pidf-manipulation</auid>
    <auid>xcap-caps</auid>
    <auid>resource-lists</auid>
    <auid>pres-rules</auid>
    <auid>org.openmobilealliance.pres-rules</auid>
  </auids>
  <extensions>
  </extensions>
  <namespaces>
    <namespace>urn:ietf:params:xml:ns:rls-services</namespace>
    <namespace>urn:ietf:params:xml:ns:pidf</namespace>
    <namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>
    <namespace>urn:ietf:params:xml:ns:resource-lists</namespace>
    <namespace>urn:ietf:params:xml:ns:pres-rules</namespace>
  </namespaces>
</xcap-caps>";
      xhttp_reply("200", "ok", "application/xcap-caps+xml",
          "$var(xbody)");
      exit;
    }
#!ifdef WITH_XHTTPAUTH
        # be sure auth user access only its documents
        if ($au!=$(var(uri){uri.user})) {
            xhttp_reply("403", "Forbidden", "text/html",
                    "<html><body>$si:$sp</body></html>");
            exit;
        }
 
#!endif
    switch($rm) {
      case "PUT":
        xcaps_put("$var(uri)", "$hu", "$rb");
        if($xcapuri(u=>auid)=~"pres-rules")
        {
          xlog("===== xhttp put: refreshing watchers for $var(uri)\n");
          pres_update_watchers("$var(uri)", "presence");
          pres_refresh_watchers("$var(uri)", "presence", 1);
        }
        exit;
      break;
      case "GET":
        xlog("===== xhttp: get $var(uri) => $hu\n");
        xcaps_get("$var(uri)", "$hu");
        exit;
      break;
      case "DELETE":
        xcaps_del("$var(uri)", "$hu");
        if($xcapuri(u=>auid)=~"pres-rules")
        {
          xlog("===== xhttp del: refreshing watchers for $var(uri)\n");
          pres_update_watchers("$var(uri)", "presence");
          pres_refresh_watchers("$var(uri)", "presence", 1);
        }
        exit;
      break;
    }
  }
  else if($hu=~"^/sip-bridge/")
  {
   
    if ( ! ( src_ip == 127.0.0.1 ) )
    {
      xhttp_reply( "403", "Forbidden", "text/html", "<html><body>Invalid Access</body></html>" );
      exit;
    }

    $var(uri) = $hu;
    $var(from) = $(var(uri){s.select,2,/});
    $var(to) = $(var(uri){s.select,3,/});

    xdbg( "=== GOT sip-bridge between $var(caller) => $var(callee) ===" );
   
   *dlg_bridge( $var(from), $var(to), "sip:192.168.2.92:5060" );*

  }

  # http ops
  xhttp_reply("200", "ok", "text/html",
          "<html><body>OK: $si:$sp</body></html>");
  exit;
}
#!endif

but I got the error below:

Not starting : invalid configuration file!

 0(22256) : <core> [cfg.y:3409]: parse error in config file //etc/kamailio/kamailio.cfg, line 986, column 17-26:
function dlg_bridge: parameter 1 is not constant

 0(22256) : <core> [cfg.y:3412]: parse error in config file //etc/kamailio/kamailio.cfg, line 986, column 63: bad command
ERROR: bad config file (2 errors)

so my question is how can I call the dlg_bridge() passing some parameters
coming from the http request?

Thanks in advance.
Roberto Fichera.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20110705/d060e703/attachment.htm>


More information about the sr-users mailing list