Mobile Number Portability Addon

From Kolmisoft Wiki
Revision as of 09:36, 26 January 2012 by Admin (talk | contribs)
Jump to navigationJump to search

This addon is available starting from MOR 8

Mobile number portability (MNP) enables mobile telephone users to retain their mobile telephone numbers when changing from one mobile network operator to another.


MNP Addon for MOR allows system owner to check number if it belongs to other network and if so - route it through different providers or bill it with different price.

Current implementation allows to save numbers in MySQL database on any server (possible not on local server).

Before each call MOR MNP Addon checks dialed number and if number is found in database - some prefix is added in front of it.

By prefix MOR can set different routing(LCR) or billing(Tariff) for this number. Localization rules should be used to perform these actions.

Detailed technique is described here: LCR/Tariff change based on call prefix

MNP Addon for MOR is available from MOR v8

As Kolmisoft cannot make one unique database for all MNP services in all countries all over the world. MOR admin has to

manually enter numbers in MNP database (process described below) in order for this solution to work. mor_mnp database has

to contain only the necessary data (telephone numbers).



NOTE: It is important to take care of various number formats user can use to dial a number. As a solution to it is to insert MNP number into DB in several possible formats.



Installation

Do such steps:

  1. Upgrade MOR
  2. cd /usr/src/mor/sh_scripts
  3. ./install_mnp.sh 



Upgrade

After Upgrade MOR run /usr/src/mor/upgrade/9/mnp_reenable.sh



Database

Config to DB in: /usr/local/mor/mor_mnp.conf

It should be MySQL database mor_mnp:

DROP TABLE IF EXISTS `numbers`;
CREATE TABLE `numbers` (
 `number` varchar(50) NOT NULL,
 `prefix` varchar(20) NOT NULL,
 PRIMARY KEY  (`number`),
 UNIQUE KEY `number` (`number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




Make sure you have set correct MySQL permissions for mor_mnp database and also local or remote asterisk must have correct settings in /usr/local/mor/mor_mnp.conf . If your number is still not recognized, double check if you have it in your mor_mnp database!

An example how to set MySQL permissions:


GRANT REPLICATION SLAVE , REPLICATION CLIENT ON * . * TO 'mor'@'localhost' IDENTIFIED BY 'mor' WITH MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON `mor_mnp` . * TO 'mor'@'localhost' WITH GRANT OPTION ;



How to use MNP

You need to insert two values in mor_mnp database. These values are number and prefix.

To manage mor_mnp database you can use PhpMyAdmin:

http://<your server IP>/phpmyadmin

PhpMyAdmin login details can be found in file /root/phpMyAdminPassword

After login to PhpMyAdmin, MySQL login page will appear.

Use these details to login MySQL:

username: mor

password: mor

Now click "_mnp (1)" menu item on the left to select mor_mnp database.

"numbers" menu item will appear after that.

Click on "numbers" menu item to manage number table.

Now click on "Insert" tab at the top of page.

Fields number and prefix will appear.

Enter desired values and click "Go" to insert these values.

Done!

How to import numbers from CSV

There is no such option to import numbers from CSV in MOR GUI, but numbers can be imported directly to MNP database.

This procedure is described here:

1. You need to have CSV file on your server and file should look like:

...
37012312345;9991
37012312344;9991
37112312343;9992
37112354321;9992
...

2. Open MySQL CLI:

mysql mor_mnp

3. Create temporary table and import CSV file to it:

CREATE TABLE temp (col_1 VARCHAR(50) default NULL , col_2 VARCHAR(20) default NULL);
LOAD DATA LOCAL INFILE '/home/mnpnumbers.csv' IGNORE INTO TABLE temp FIELDS TERMINATED BY ';' ;

4. Copy data from temporary table to 'numbers' table:

INSERT INTO numbers (number,prefix) SELECT REPLACE(col_1, '\r', ), REPLACE(col_2, '\r', ) FROM temp
WHERE (REPLACE(col_1, '\r', ) REGEXP '^[0-9]+$' = 1) and (REPLACE(col_2, '\r', ) REGEXP '^[0-9]+$' = 1) ;

NOTE: this query skips values which contains non-numerical characters.

For example: row

...
+370123123456;9997
...

will not be imported to 'numbers' table.

5. Detele temporary table:

DROP TABLE temp;

Done. Numbers are imported to 'numbers' table.

How to configure external MNP database


Skip this step if your MOR billing installation is on one server.

locate mor_mnp.conf file

cd /usr/local/mor

edit the file with your favorite text editor, for example:

medit mor_mrnp.conf

You should see similar values:

host = localhost
db = mor_mnp
user = mor
secret = mor
port = 3306
server_id = 1
show_sql = 0
debug = 1

Change the values to the ones you need:

host - your database IP address server_id - your Asterisk server id, same as in /etc/asterisk/mor.conf

See also