VoIP (english): Porovnání verzí

Z Freenetis Wiki
Přejít na: navigace, hledání
 
(Nejsou zobrazeny 2 mezilehlé verze od stejného uživatele.)
Řádek 1: Řádek 1:
 
[[cs:VoIP]]
 
[[cs:VoIP]]
[[ru: VoIP(русский))]]
+
[[ru: VoIP(русский)]]
  
 
FreenetIS allows to manage VoIP accounts. The system can be connected to Asterisk (or the [http://www.iptel.org/ser/ SER] and its derivatives) and then to the billing.
 
FreenetIS allows to manage VoIP accounts. The system can be connected to Asterisk (or the [http://www.iptel.org/ser/ SER] and its derivatives) and then to the billing.
  
 
== General Information ==
 
== General Information ==
In Фреенетис system each member can register only one number. If you need additional паймент it requires to register another user. User can can change information on VoIP account as the password and voicemail settings. If the billing module is active then it is possible to display an extract of calls or charging a credit.
+
In FreenetIS system each member can register only one number. If you need additional payment it requires to register another user. User can can change information on VoIP account as the password and voicemail settings. If the billing module is active then it is possible to display an extract of calls or charging a credit.
  
 
== Setting ==
 
== Setting ==
Řádek 112: Řádek 112:
 
At this point asterisk is integrated with FreentIS and after adding VoIP account in FreenetIS you should be able to login to the control panel by using software or hardware client. Status log can be viewed in FreenetIS in VoIP Account
 
At this point asterisk is integrated with FreentIS and after adding VoIP account in FreenetIS you should be able to login to the control panel by using software or hardware client. Status log can be viewed in FreenetIS in VoIP Account
  
Then, we set the Asterisk depends on the user requirements. Sample configuration for trunk from NFX s.z.p.o.:
+
Then, we set the Asterisk depends on the user requirements. Sample configuration for prunk from NFX s.z.p.o.:
  
 
[general]
 
[general]
Řádek 140: Řádek 140:
 
  exten => 158,1,Goto(emergency,${EXTEN},1)
 
  exten => 158,1,Goto(emergency,${EXTEN},1)
 
   
 
   
;converting long numbers to short - only for CR
 
exten => _00420XXXXXXXXX,1,Goto(internal,${EXTEN:5},1)
 
 
;calling to slfree, we examine the context slfree
 
exten => _951020XXX,1,Goto(slfree,${EXTEN},1)
 
 
;calling to CR, we examine the context outgoing-nfx
 
exten => _XXXXXXXXX,1,Goto(outgoing-nfx,00420${EXTEN},1)
 
 
;calling to the world, explore context-outgoing nfx
 
exten => _XXXXXXXXXXXXXX,1,Goto(outgoing-nfx,${EXTEN},1)
 
 
;otherwise unknown number
 
exten => _X.,1,Goto(default,s,1)
 
 
;everything goes into the central nfx
 
[outgoing-nfx]
 
exten => _XXXXXXXXXXXXXX,1,Set(CALLERID(num)=00420${CALLERID(num)})
 
exten => _XXXXXXXXXXXXXX,n,Dial(SIP/nfx/${EXTEN})
 
exten => _XXXXXXXXXXXXXX,n,Hangup
 
 
[incomming-nfx]
 
;converting long numbers to short
 
exten => _00420XXXXXXXXX,1,Goto(incomming-nfx,${EXTEN:5},1)
 
;calling to slfree, we examine the context [slfree]
 
exten => _951020XXX,1,Goto(slfree,${EXTEN},1)
 
 
;otherwise unknown number
 
exten => _X.,1,Goto(default,s,1)
 
 
[slfree]
 
;the context for the numbers of slfree, we take data from db
 
 
exten => _951020XXX,1,Macro(safedial,SIP/${EXTEN},30)
 
 
;Realtime integration is not yet implemented in FreenetISu!!
 
;switch => Realtime
 
 
Finally, set the trunk for outgoing calls.
 
 
[nfx]
 
type=peer
 
host=sip.nfx.czf
 
qualify=no
 
language=cz
 
insecure=port,invite
 
fromdomain=******
 
canreinvite=no
 
context=incomming-nfx
 
nat=no
 
 
To other trunks (eg trunk from Havel or 802.cz) need a custom solution …
 
  
 
==Billing API==
 
==Billing API==

Aktuální verze z 10. 12. 2013, 08:09


FreenetIS allows to manage VoIP accounts. The system can be connected to Asterisk (or the SER and its derivatives) and then to the billing.

General Information

In FreenetIS system each member can register only one number. If you need additional payment it requires to register another user. User can can change information on VoIP account as the password and voicemail settings. If the billing module is active then it is possible to display an extract of calls or charging a credit.

Setting

For proper functioning of VoIP it is important to set in FreenetIS the range of numbers that user can register. It is also possible to configure SIP proxy, which will be displayed in the User Account VoIP. If any of the range of numbers should not be offered for registration then it has to be defined in the omitted numbers.

Integration with Asterisk

Install the necessary packages (Debian and its derivatives).

 apt-get install mysql asterisk asterisk-mysql

For integration with Asterisk is to create a view to the table voip_sips:

First you need to create a database for Asterisk:

mysql> create database asterisk;

And then a view in the database FreenetIS:

 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `asterisk`.`sip` AS select `freenetis`.`voip_sips`.`id` AS `id`,
`freenetis`.`voip_sips`.`name` AS  `name`,
`freenetis`.`voip_sips`.`amaflags` AS `amaflags`,
`freenetis`.`voip_sips`.`accountcode` AS `accountcode`,
`freenetis`.`voip_sips`.`callgroup` AS `callgroup`,
`freenetis`.`voip_sips`.`callerid` AS `callerid`,
`freenetis`.`voip_sips`.`canreinvite` AS `canreinvite`,
`freenetis`.`voip_sips`.`context` AS `context`,
`freenetis`.`voip_sips`.`defaultip` AS `defaultip`,
`freenetis`.`voip_sips`.`dtmfmode` AS `dtmfmode`,
`freenetis`.`voip_sips`.`fromuser` AS `fromuser`,
`freenetis`.`voip_sips`.`fromdomain` AS `fromdomain`,
`freenetis`.`voip_sips`.`fullcontact` AS `fullcontact`,
`freenetis`.`voip_sips`.`host` AS `host`,
`freenetis`.`voip_sips`.`insecure` AS `insecure`,
`freenetis`.`voip_sips`.`language` AS `language`,
`freenetis`.`voip_sips`.`mailbox` AS `mailbox`,
`freenetis`.`voip_sips`.`md5secret` AS `md5secret`,
`freenetis`.`voip_sips`.`nat` AS `nat`,
`freenetis`.`voip_sips`.`deny` AS `deny`,
`freenetis`.`voip_sips`.`permit` AS `permit`,
`freenetis`.`voip_sips`.`mask` AS `mask`,
`freenetis`.`voip_sips`.`pickupgroup` AS `pickupgroup`,
`freenetis`.`voip_sips`.`port` AS `port`,
`freenetis`.`voip_sips`.`qualify` AS `qualify`,
`freenetis`.`voip_sips`.`restrictcid` AS `restrictcid`,
`freenetis`.`voip_sips`.`rtptimeout` AS `rtptimeout`,
`freenetis`.`voip_sips`.`rtpholdtimeout` AS `rtpholdtimeout`,
`freenetis`.`voip_sips`.`secret` AS `secret`,
`freenetis`.`voip_sips`.`type` AS `type`,
`freenetis`.`voip_sips`.`username` AS `username`,
`freenetis`.`voip_sips`.`disallow` AS `disallow`,
`freenetis`.`voip_sips`.`allow` AS `allow`,
`freenetis`.`voip_sips`.`musiconhold` AS `musiconhold`,
`freenetis`.`voip_sips`.`regseconds` AS `regseconds`,
`freenetis`.`voip_sips`.`ipaddr` AS `ipaddr`,
`freenetis`.`voip_sips`.`regexten` AS `regexten`,
`freenetis`.`voip_sips`.`cancallforward` AS `cancallforward`,
`freenetis`.`voip_sips`.`setvar` AS `setvar`,
`freenetis`.`voip_sips`.`auth` AS `auth` from `freenetis`.`voip_sips`;

Furthermore, we create a view for voicemail:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `asterisk`.`voicemail_users` AS select `freenetis`.`voip_voicemail_users`.`id` AS `uniqueid`,
`freenetis`.`voip_voicemail_users`.`customer_id` AS `customer_id`,
`freenetis`.`voip_voicemail_users`.`context` AS `context`,
`freenetis`.`voip_voicemail_users`.`mailbox` AS `mailbox`,
`freenetis`.`voip_voicemail_users`.`password` AS `password`,
`freenetis`.`voip_voicemail_users`.`fullname` AS `fullname`,
`freenetis`.`voip_voicemail_users`.`email` AS `email`,
`freenetis`.`voip_voicemail_users`.`pager` AS `pager`,
`freenetis`.`voip_voicemail_users`.`stamp` AS `stamp` from
`freenetis`.`voip_voicemail_users` where (`freenetis`.`voip_voicemail_users`.`active` = _utf8'1');
=== Configuring MySQL ===

Asterisk can directly access mysq.

In /etc/asterisk/res_mysql.conf add

[general]
dbhost = localhost
dbname = asterisk
dbuser = username
dbpass = password
dbport = 3306
dbsock = /var/run/mysqld/mysqld.sock
=== Configuring Asterisk ===

All files are in /etc/asterisk/ In extconfig.conf some things are read from DB - there should be

sippeers => mysql,asterisk,sip
voicemail => mysql,asterisk,voicemail_users
;extensions => mysql,asterisk, extensions - not yet implemented in FreentIS!!

To test the connection to the MySQL connect to the console

asterisk-rvvv

and run realtime mysql status

sip*CLI> realtime mysql status
Connected to asterisk@localhost, port 3306 with username asterisk for 4 seconds.

We have tested a connection functionality.

At this point asterisk is integrated with FreentIS and after adding VoIP account in FreenetIS you should be able to login to the control panel by using software or hardware client. Status log can be viewed in FreenetIS in VoIP Account

Then, we set the Asterisk depends on the user requirements. Sample configuration for prunk from NFX s.z.p.o.:

[general]

static=yes
writeprotect=no
userscontext=default

[default]
;the default context, this covers everything that is not in other contexts
exten => s,1,Answer()
exten => s,n,Wait(2)
exten => s,n,Playback(slfree-cal-no-there)
exten => s,n,Hangup()

[internal]
;the default context for our number
;If we call 11 then we will get into our own voicemail
exten => 11,1,Goto(mailbox,s,1)


;If you call the emergency line then we will get in the context of emergency
exten => 112,1,Goto(emergency,${EXTEN},1)
exten => 150,1,Goto(emergency,${EXTEN},1)
exten => 155,1,Goto(emergency,${EXTEN},1)
exten => 158,1,Goto(emergency,${EXTEN},1)

Billing API

Billing records a credit recharging , charging calls, etc. LBilling API was integrated into FreenetISu. LBilling API has been exhaustively developed for the needs of NFX s.z.p.o. Its specifications is available on internal pages NFX. The actual billing was designed to be universal and only change Billing driver .

Currently only Lbilling is implemented for driver API NFX . Other API can be programmed if it will be required.

Installing the synchronization script

The synchronization script provides charging and syncing credit VoIP users in FreenetIS.

Before installation, check if you have installed the SIP server perl.

1) Create a MySQL named lbilling DB on the same server as your FreenetIS database.

2 ) Create a view to FreenetIS database (if the database of FreenetIS has different name than freenetis , change all values `freenetis` in the name of your database , or even change the user that defines the view).

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `transfers` AS select `freenetis`.`transfers`.`id` AS `id`,`freenetis`.`transfers`.`origin_id` AS `origin_id`,`freenetis`.`transfers`.`destination_id` AS `destination_id`,`freenetis`.`transfers`.`previous_transfer_id` AS `previous_transfer_id`,`freenetis`.`transfers`.`member_id` AS `member_id`,`freenetis`.`transfers`.`user_id` AS `user_id`,`freenetis`.`transfers`.`type` AS `type`,`freenetis`.`transfers`.`datetime` AS `datetime`,`freenetis`.`transfers`.`creation_datetime` AS `creation_datetime`,`freenetis`.`transfers`.`text` AS `text`,`freenetis`.`transfers`.`amount` AS `amount` from `freenetis`.`transfers`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `voip_lbilling_accounts` AS select `voip_lbilling_accounts`.`id` AS `id`,`voip_lbilling_accounts`.`userid` AS `userid`,`voip_lbilling_accounts`.`cid` AS `cid`,`voip_lbilling_accounts`.`state` AS `state`,`voip_lbilling_accounts`.`limit` AS `limit`,`voip_lbilling_accounts`.`tarif` AS `tarif`,`voip_lbilling_accounts`.`descr` AS `descr` from `freenetis`.`voip_lbilling_accounts`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `voip_lbilling_payments` AS select `voip_lbilling_payments`.`id` AS `id`,`voip_lbilling_payments`.`userid` AS `userid`,`voip_lbilling_payments`.`date` AS `date`,`voip_lbilling_payments`.`value` AS `value`,`voip_lbilling_payments`.`state` AS `state`,`voip_lbilling_payments`.`descr` AS `descr` from `freenetis`.`voip_lbilling_payments`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `voip_lbilling_users` AS select `voip_lbilling_users`.`id` AS `id`,`voip_lbilling_users`.`type` AS `type`,`voip_lbilling_users`.`state` AS `state`,`voip_lbilling_users`.`limit` AS `limit`,`voip_lbilling_users`.`currency` AS `currency`,`voip_lbilling_users`.`descr` AS `descr` from `freenetis`.`voip_lbilling_users`;

2)The SIP server , place the following files lbilling-synchronization.pl and html.tt to the folder /usr/local/bin/lbilling/

3) Set the rights for the synchronization script:

chmod a+x /usr/local/bin/lbilling/lbilling-synchronization.pl

4 )Set the configuration to the variables in the script lbilling-synchronization.pl ( configuration section).

nano /usr/local/bin/lbilling/lbilling-synchronization.pl

5 ) Add the synchronization script ( following lines) to CRON (/etc/crontab):

#lBilling synchronization
30 22   * * * root perl /usr/local/bin/lbilling/lbilling-synchronization.pl -s
*/5 *  * * * root perl /usr/local/bin/lbilling/lbilling-synchronization.pl -p