Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
modules-new-design:lcr-module-design [2010/05/31 18:54] – 87.93.31.28 | modules-new-design:lcr-module-design [2010/06/09 08:41] (current) – 87.95.129.219 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== New LCR Module Design (proposal) ====== | ||
+ | A new design for Kamailio' | ||
+ | ===== Introduction ===== | ||
+ | |||
+ | Current LCR module lacks some useful features and it's hard to manage via an admin interface due to the complexity and not good relationship between its DB tables. | ||
+ | |||
+ | Some of the current design issues are: | ||
+ | * LCR rule definitions are mixed with rule steps/ | ||
+ | * In order to reuse some gateway in two different groups it's required to duplicate all the information for the given gateway (ip, port, flags, ping...). | ||
+ | * Summarizing, | ||
+ | |||
+ | Some desired features would be: | ||
+ | * There si no way to make a rule stop if it fails to handle the request and we don't want other matching rules to be loaded (i.e: "I want calls to 001 just to use gw3 and not to use default gateways, those belonging to rule with NULL prefix, if gw3 is down). | ||
+ | * Rules should be disabled without having to delete them. | ||
+ | |||
+ | In order to simplify implementation and use, gateway groups are no longer supported. | ||
+ | |||
+ | |||
+ | ===== New DB schema ===== | ||
+ | ==== lcr_rule ==== | ||
+ | |||
+ | ^ Column | ||
+ | | id | Primary key: identifier of this rule | Integer | | | ||
+ | | lcr_id | ||
+ | | prefix | ||
+ | | from_uri | ||
+ | | stopper | ||
+ | | enabled | ||
+ | |||
+ | Keys: | ||
+ | * PRIMARY KEY: //id// | ||
+ | * UNIQUE: //lcr_id// + //prefix// + // | ||
+ | ==== lcr_rule_target table ==== | ||
+ | |||
+ | ^ Column | ||
+ | | id | Primary key | Integer | | | ||
+ | | rule_id | ||
+ | | gw_id | Gateway for this rule target (points to //id// in //lcr_gw// table) | Integer | | | ||
+ | | priority | ||
+ | | weight | ||
+ | |||
+ | Keys: | ||
+ | * PRIMARY KEY: //id// | ||
+ | * UNIQUE: //rule_id// + //gw_id// | ||
+ | * INDEX: //rule_id// | ||
+ | ==== lcr_gw table ==== | ||
+ | |||
+ | ^ Column | ||
+ | | id | Primary key, identifier of the gateway | ||
+ | | lcr_id | ||
+ | | gw_name | ||
+ | | ip_addr | ||
+ | | port | Port of the gateway | ||
+ | | uri_scheme | ||
+ | | transport | ||
+ | | params | ||
+ | | hostname | ||
+ | | strip | Number of characters to be stripped from the front of Request URI user | NULL / Integer | NULL | | ||
+ | | tag | Prefix to be added to Request URI user part after removing //strip// characters | NULL / String | NULL | | ||
+ | | flags | Flags enabled when loading this gateway | ||
+ | | defunct | ||
+ | |||
+ | Keys: | ||
+ | * PRIMARY KEY: //id// | ||
+ | * UNIQUE: //lcr_id// + //ip_addr// + //port// + // | ||
+ | |||
+ | |||
+ | ===== New module parameters, functions and flags ===== | ||
+ | ==== flag(DONT_STRIP_OR_TAG) ==== | ||
+ | |||
+ | When calling // | ||
+ | |||
+ | This is an optional module parameter. If it's not defined then //strip// and //tag// are always applied for each gateway. | ||
+ | |||
+ | An use case in which this flag is useful: | ||
+ | |||
+ | * The PSTN gateway allows national format (NNNNNNNNN) and international format with " | ||
+ | * Kamailio is configured to normalize destination numbers to E.164 (+NNNNNNNNN) if the call is international, | ||
+ | * In this case it's required to replace " | ||
+ | * But it's also required not to modify the RURI user part if the number format is national. | ||
+ | |||
+ | The following configuration would do the job: | ||
+ | |||
+ | * //lcr_gw// entry for the PSTN gateway: | ||
+ | * **strip:** 1 | ||
+ | * **tag:** 00 | ||
+ | |||
+ | * Script configuration:< | ||
+ | # This route ensures that the dialed number is in the form +XXXXXX | ||
+ | # (international E164) or national (XXXXXXX without + or 00): | ||
+ | route(NORMALIZE_NUMBER); | ||
+ | |||
+ | # Load gateways as usual. | ||
+ | load_gws(...); | ||
+ | |||
+ | # If the dialed number is national then enable the flag(DONT_USE_STRIP_TAG) | ||
+ | # to avoid the RURI user part being striped and tagged with gw values. | ||
+ | if !(starts_with(" | ||
+ | setflag(DONT_STRIP_OR_TAG); | ||
+ | | ||
+ | next_gw(); | ||
+ | </ |