Table of Contents

New LCR Module Design (proposal)

A new design for Kamailio's LCR module making it simpler, more powerful, and easier to manage via an admin interface.

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:

Some desired features would be:

In order to simplify implementation and use, gateway groups are no longer supported. Instead, gateways are directly specified as rule targets, where each rule target has a priority and weight.

New DB schema

lcr_rule

Column Description Possible values Default value
id Primary key: identifier of this rule Integer
lcr_id Identifier of LCR instance Integer
prefix Prefix of Request URI user part NULL / String NULL
from_uri Regular expression to match the From URI (or given pseudo-variable) NULL / String (regular expression) NULL
stopper If it's 1 no other rules would be inspected after finding this one Integer (1=on / 0=off) 0
enabled Is it this rule active so it can be loaded? Integer (1=on / 0=off) 1

Keys:

lcr_rule_target table

Column Description Possible values Default value
id Primary key Integer
rule_id Integer pointing to the id of an entry in lcr_rule table Integer
gw_id Gateway for this rule target (points to id in lcr_gw table) Integer
priority Priority of this rule target within all targets for the same rule Integer (0-255)
weight Weight of this rule target within all equal priority targets for the same rule Integer (1-254)

Keys:

lcr_gw table

Column Description Possible values Default value
id Primary key, identifier of the gateway Integer
lcr_id Identifier of LCR instance Integer
gw_name Name of the gateway (only for documentation) String NULL
ip_addr IP of the gateway NULL / String NULL
port Port of the gateway NULL (no port is added) / Integer (5060=sip / 5061=sips) NULL
uri_scheme Scheme of the Request URI NULL / Integer (NULL and 1 = sip / 2=sips) NULL
transport Transport used for this gateway NULL (no transport is added) / Integer (0=udp / 1=tcp / 2=tls / 3=sctp) NULL
params URI params to be added to Request URI NULL / String NULL
hostname Hostname to set in Request URI host part NULL / String NULL
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 Integer 0
defunct Gateway is defunct until this Linux timestamp time NULL (= 0) / Integer NULL

Keys:

New module parameters, functions and flags

flag(DONT_STRIP_OR_TAG)

When calling next_gw() function the value of flag(DONT_STRIP_OR_TAG) is inspected. If it is set then strip and tag values of the selected gateway are ignored so the Request URI user part is not modified.

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 following configuration would do the job: