Prelocalization

From Kolmisoft Wiki
Jump to navigationJump to search

Prelocalization allows to do additional Localization before any other action in MOR. Prelocalization is applied to incoming calls (calls to DID numbers) too.



Purpose

Prelocalization allows to greatly reduce the number of Localization rules.

MNP routing and EU/NonEU discrimination need a lot of rules in order to work.
When calls come in from clients that can have one of the following formats (Greek example):

  • 210XXXXXXX (national format)
  • 30210XXXXXXX(E.164 format)
  • +30210XXXXXXX (International format)
  • 0030210XXXXXXX (international format)

If prelocalization does not exist, then each rule applied to localization must be repeated for every dialing type, thus increasing the overall amount of rules.
This is why prelocalization is needed, so we will avoid adding same rule multiple times in order to cover all dialing types from clients.

Example: In MNP environment prefixes are added to the destination numbers. These prefixes have to be removed using localization rules.
If prefix added is 569000 then we will need 4 rules in order to solve this although with prelocalization we would only need one rule

Without prelocalization rule:

Prelocalization example1.png

If prelocalization rules exist, then before MNP prefix is added, or before localization is hit, number would already be localized e.g. 302XXXXXXXXX so we would only need 1 rule instead 4 for one prefix.
Prelocalization greatly reduces amount of rules needed so if it exist we would only need following rule for the same case:

Prelocalization example2.png



How to enable it

Latest MOR X12 (or higher) version is required for this feature to work

!!! Please note that if your extensions_mor.conf contains _[A-Z0-9]! instead of _X. then all extensions described bellow should also be set to _[A-Z0-9]!


Modify /etc/asterisk/extensions_mor.conf to include MOR prelocalization AGI script (at around 40th line, just above exten => _X.,n,mor(${EXTEN}))

exten => _X.,1,NoOp(MOR starts)
exten => _X.,n,GotoIf($["${MOR_DIAL_LOCAL_IVR}" != ""]?mor_dial_local_ivr,s,1)
exten => _X.,n,Gosub(diversion_settings,${EXTEN},1)
exten => _X.,n,Gosub(proxy_settings,${EXTEN},1)
exten => _X.,n,Set(__MOR_SIP_TO=${SIP_HEADER(To)})
exten => _X.,n,Set(TIMEOUT(response)=20)
exten => _X.,n,AGI(mor_prelocalization)  ;<--------------------------------------- ADD THIS LINE HERE ----------- !!!!
exten => _X.,n,mor(${EXTEN})
exten => _X.,n,GotoIf($["${MOR_CARD_USED}" != ""]?mor_callingcard,s,1)
exten => _X.,n,GotoIf($["${MOR_ANIPIN_USED}" != ""]?mor_anipin,s,1)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?BUSY,1:HANGUP,1)

If you are using Mobile Number Portability Addon, then this line should go BEFORE MNP addon line and should look like this:

exten => _X.,1,AGI(mor_prelocalization)   ;<--------------------------------------- ADD THIS LINE HERE ----------- !!!!
exten => _X.,n,AGI(mor_mnp)
exten => _X.,n,GotoIf($["${MOR_DIAL_LOCAL_IVR}" != ""]?mor_dial_local_ivr,s,1)
exten => _X.,n,Gosub(diversion_settings,${EXTEN},1)
exten => _X.,n,Gosub(proxy_settings,${EXTEN},1)
exten => _X.,n,Set(__MOR_SIP_TO=${SIP_HEADER(To)})
exten => _X.,n,Set(TIMEOUT(response)=20)
exten => _X.,n,Set(TIMEOUT(digit)=10)
exten => _X.,n,mor(${EXTEN})
exten => _X.,n,GotoIf($["${MOR_CARD_USED}" != ""]?mor_callingcard,s,1)
exten => _X.,n,GotoIf($["${MOR_ANIPIN_USED}" != ""]?mor_anipin,s,1)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?BUSY,1:HANGUP,1)


If you are using system with Proxy solution, then this line should go AFTER proxy_settings and BEFORE MNP addon (if it is used):

exten => _X.,1,GotoIf($["${MOR_DIAL_LOCAL_IVR}" != ""]?mor_dial_local_ivr,s,1)
exten => _X.,n,Gosub(diversion_settings,${EXTEN},1)
exten => _X.,n,Gosub(proxy_settings,${EXTEN},1)
exten => _X.,n,AGI(mor_prelocalization)   ;<---------Prelocalization line should go after proxy and before mnp (if it is used)---------- !!!!
exten => _X.,n,AGI(mor_mnp)
exten => _X.,n,Set(__MOR_SIP_TO=${SIP_HEADER(To)})
exten => _X.,n,Set(TIMEOUT(response)=20)
exten => _X.,n,Set(TIMEOUT(digit)=10)
exten => _X.,n,mor(${EXTEN})
exten => _X.,n,GotoIf($["${MOR_CARD_USED}" != ""]?mor_callingcard,s,1)
exten => _X.,n,GotoIf($["${MOR_ANIPIN_USED}" != ""]?mor_anipin,s,1)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?BUSY,1:HANGUP,1)


Asterisk dialplan should be reloaded each time this file is changed:

asterisk -rx "dialplan reload"

Configuration

Configuration file /etc/mor/system.conf

prelocalization_location - which Location to use for prelocalization? Value should be Location ID.
prelocalization_global_rules - should we include global rules? Value is either 1 or 0 (default 0).

For example:

 prelocalization_location_id = 17
 prelocalization_global_rules = 1


Note: reload is not required when this file is changed.

Location rules

Prelocalization supports only Destination and Source rules. Combined rules are not supported.

Only Cut, Add, Min Len and Max Len are applied when doing prelocalization.

Script output

Prelocalization output is written to Asterisk verbose log at the beginning of the call:

mor_prelocalization: MOR prelocalization AGI script started                                                                                                                                                                                  
mor_prelocalization: Original destination number: 00370123456                                                                                                                                                                                
mor_prelocalization: Original source number: +390000000
mor_prelocalization: Original source name: test
mor_prelocalization: Localized dst number: 370123456 (cut: 00, add: )
mor_prelocalization: Localized src number: 390000000 (cut: +, add: )                                                                                                                                                                         
mor_prelocalization: MOR prelocalization AGI script stopped



See also