Accfile

From Yate Documentation
Revision as of 10:02, 15 May 2013 by Dana (Talk | contribs)

Jump to: navigation, search

The Accfile module is used to register Yate to outside gateways to terminate calls. The accounts that are defined in accfile can use different protocols like SIP, H323, Jabber or IAX.

This module defines a connection with authentication between Yate and a server(gateway). Yate will be the client for that server. The connection information will be configured in a file: accfile.conf. A basic connection is defined by setting: protocol, username, password and the server ip.

When you want to route the accounts defined in accfile module you have to use a routing module, like regexroute or make the routing from an external script using the external module.

Yate register to gateway.png

Contents

Main actions

Module Accfile emits a login/logout for the accounts(gateways) configured in accfile.conf.

An account is valid if it has parameter enabled set to true or if parameter enabled is missing but the parameter username is set.

Commands using rmanager

From telnet, in a terminal run command to reload, login or logout a specific account or all accounts if parameter [account] is not specified:

accounts [reload|{login|logout|...} [account]]

Routing from an account/line

To route the calls to the an account:

1. configure account in accfile.conf:

[my_line]
enabled=yes
protocol=sip
username=routecalls
password=mysecret
server=192.168.168.156

2. configure routing in regexroute.conf:

Routing all calls through the gateway/account:

^.*$=line/\0;line=my_line
  • the line parameter is fixed.
  • \0 will catch whatever is on left side of =. In this case, the phone number.
  • line=my_line will tell Yate on which gateway/account to route the call.

Configuration parameters

General parameters

  • protocol: The protocol to register on (sip, iax, h323, jabber ...)
  • username: Account username
  • password: Account password
  • interval: Registration interval (in seconds) to request from server (ignored for jabber)
  • enabled:
Sections with enabled=no are always ignored.
If the enabled parameter is missing, sections without username are ignored.
If enabled=yes the accounts are logged in even without an username.

Specific parameters

SIP
  • description: Caller name to set on outgoing calls on this account if none specified when routing
  • registrar: Registrar address. A port can be specified here (e.g. 1.2.3.4:7999)
  • authname: Authentication name to use instead of username when authenticating
  • domain: Authentication domain if any
  • outbound: Optional outbound proxy server if different from registrar.
A port can be specified here (e.g. 1.2.3.4:7999)
  • ip_transport: Optional SIP transport to use (udp, tcp, tls).
Defaults to udp
  • ip_transport_remoteip: IP address to connect to register the account.
Defaults to outbound or registrar address
  • ip_transport_remoteport: IP port to connect to register the account
  • ip_transport_localip: UDP: This parameter is used in conjuction ip_transport_localport
to identify the transport to use
TCP/TLS: Optional local ip to use when connecting
  • ip_transport_localport: Local port.
UDP only: This parameter is used to identify the transport to use
  • localaddress: Local address to set in sent messages
Set it to 'yes' to detect NAT and re-register with public ip when NAT is detected
Set it to 'no' or ipaddress (e.g. 1.2.3.4 or 1.2.3.4:5060) to disable NAT detection
  • keepalive: Optional interval for NAT keep alive.
Defaults to 0 if NAT detection is disabled
NOTE
Default port is 5060 for udp/tcp and 5061 for tls
Jabber
  • domain: Authentication domain
  • port: Server port. Defaults to 5222
  • server: Optional jabber server ip address to connect to.
If set the jabber stream will try first to connect to this address
  • localip: Optional local ip address to use when connecting.
Connect will fail if the address is invalid
  • resource: Optional resource to request from server
  • priority: Optional resource priority to set in initial presence
  • options: Comma separated list of stream flags
- allowplainauth: Allow plain password authentication
- tlsrequired: Stream encryption is required
- noautorestart: Don't restart the stream when disconnected (NOT RECOMMENDED)
  • nocompression: Boolean. Set it to 'yes' to disable stream compression
IAX
  • server: Registrar address or domain. A port can be specified here (e.g. 1.2.3.4:7999)
  • port: Registrar port if not specified in 'server' parameter
If not set the port defaults to 4569
H323
  • server: Registrar IP address
  • addr: Local address for H323 listener (leave it empty to listen on all interfaces)
  • port: Local port for H323 listener

Configuration examples

Example how to define a line

Suppose we have a SIP line and we want to route all calls through the gateway (line).

In accfile.conf:

[line_1]
enabled=yes
protocol=sip
username=line-1
password=pwd1
domain=10.0.0.1
registrar=10.0.0.1

How to route calls from regexroute through the line

In regexroute.conf set:

;This rule will match every call and will routed through the gateway
;\0 will catch whatever is on left side of =. In this case, all phone numbers.
^.*$=line/\0;line=line-1

How to route calls using fork

You can use fork with distributed parameters (Yate> 3.3.3 ) to route to multiple lines registered in accfile.conf.

In accfile.conf

[line_1]
enabled=yes
protocol=sip
username=line-1
password=pwd1
domain=10.0.0.1
registrar=10.0.0.1

[line_2]
enabled=yes
protocol=sip
username=line-2
password=pwd2
domain=10.0.0.1
registrar=10.0.0.1

This will try to send the call to both gateways at the same time:

In regexroute.conf

^.*$=fork;callto.1=line/\0;callto.1.line=line-1;callto.2=line/\0;callto.2.line=line-2

How to route calls using external module

This next example shows you how to route calls from an external module. We are going to use the lines defined above in accfile.conf.

To route to a gateway from a PHP script, take a look at route.php from share/scripts directory in Yate sources and replace:

      if ($ev->getValue("called") == "321") {
           $ev->retval = "tone/dial";
           $ev->handled = true;
       }

with:

       if ($ev->getValue("called")=="100") {
           $ev->retval = "line/".$ev->getValue("called");
           $ev->params["line"] = "line-1";
           $ev->handed = true;
       }

If you wish to use fork from the PHP script:

          $ev->retval = "fork";
          $ev->params["callto.1"] = "line/".$ev->getValue("called");
          $ev->params["callto.1.line"]  = "line-1";
          $ev->params["callto.2"] =  "line/".$ev->getValue("called");
          $ev->params["callto.2.line"]  = "line-2";
          $ev->handed = true;

Above is the equivalent of the following line from regexroute.conf:

^.*$=fork;callto.1=line/\0;callto.1.line=line-1;callto.2=line/\0;callto.2.line=line-2


See also

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers