THis is from an irc convo with brettnem, much thanks for his help.....
the lcr mod will lookup the ruri in the lcr table.. matching prefix and from_ruri
which gives a grp_id.. this grp_id is matched up to a grp_id in gw_grp (I think, I munged the functions)
the grp_id correlates to multiple possible gateways for that call
one table resolves prefixes (numbers) to route groups.. the other
resolves route groups to a list of gateways (or a feature server)
lcr will route based on NPANXX to certain provider, or route DIDs to
feature servers out of the box with like 2 lines of code in ser.cfg..
that's right
you really should have more than 2.. but you got the idea.. you need to check for load_gws failure (ie, no route 404)
example for:
sip:1234567890@test.com to sip:1234567890@test.org
tamp4x mysql> describe lcr;
tamp4x +----------+---------------------+------+-----+---------+-------+
tamp4x | Field |
Type
| Null | Key | Default | Extra |
tamp4x +----------+---------------------+------+-----+---------+-------+
tamp4x | prefix |
varchar(16)
| | MUL
|
| |
tamp4x | from_uri |
varchar(128)
| | MUL |
%
| |
tamp4x | grp_id | int(10) unsigned
| | MUL |
0
| |
tamp4x | priority | tinyint(3) unsigned |
| | 0
| |
tamp4x +----------+---------------------+------+-----+---------+-------+
tamp4x 4 rows in set (0.00 sec)
tamp4x mysql> describe gw;
tamp4x +------------+----------------------+------+-----+---------+-------+
tamp4x | Field |
Type
| Null | Key | Default | Extra |
tamp4x +------------+----------------------+------+-----+---------+-------+
tamp4x | gw_name |
varchar(128)
| | PRI
|
| |
tamp4x | ip_addr | int(10)
unsigned |
| | 0
| |
tamp4x | port | smallint(5)
unsigned | YES | | NULL
| |
tamp4x | uri_scheme | tinyint(3) unsigned | YES
| | NULL
| |
tamp4x | transport | tinyint(3) unsigned | YES
| | NULL
| |
tamp4x | grp_id | int(10)
unsigned | | MUL
| 0
| |
tamp4x +------------+----------------------+------+-----+---------+-------+
tamp4x mysql> describe gw_grp;
tamp4x +----------+------------------+------+-----+---------+----------------+
tamp4x | Field |
Type
| Null | Key | Default |
Extra |
tamp4x +----------+------------------+------+-----+---------+----------------+
tamp4x | grp_id | int(10) unsigned | | PRI | NULL | auto_increment |
tamp4x | grp_name | varchar(64)
| |
|
|
|
tamp4x +----------+------------------+------+-----+---------+----------------+
tamp4x 2 rows in set (0.02 sec)
tamp4x mysql> describe grp;
tamp4x +---------------+--------------+------+-----+---------------------+-------+
tamp4x | Field |
Type | Null | Key |
Default
| Extra |
tamp4x +---------------+--------------+------+-----+---------------------+-------+
tamp4x | username | varchar(64)
| | PRI
|
| |
tamp4x | domain |
varchar(128) | | PRI
|
| |
tamp4x |
grp |
varchar(50) | | PRI
|
| |
tamp4x | last_modified | datetime
| | | 0000-00-00
00:00:00 | |
tamp4x +---------------+--------------+------+-----+---------------------+-------+
that is the table structures
make sure your version table looks like this:
+-----------------------+---------------+
| table_name | table_version |
+-----------------------+---------------+
|
subscriber
|
5 |
|
reserved
|
1 |
|
phonebook
|
1 |
|
pending
|
4 |
| missed_calls
|
2 |
|
location
| 1001 |
|
aliases
| 1001 |
|
grp
|
2 |
|
event
|
1 |
| active_sessions
|
1 |
|
acc
|
2 |
|
config
|
1 |
|
silo
|
3 |
|
realm
|
1 |
|
domain
|
1 |
|
uri
|
1 |
| server_monitoring | 1 |
| server_monitoring_agg | 1 |
|
trusted
|
1 |
| usr_preferences
|
2 |
| usr_preferences_types | 1 |
| admin_privileges | 1 |
| calls_forwarding | 1 |
|
speed_dial
|
2 |
|
dbaliases
|
1 |
|
gw
|
3 |
|
gw_grp
|
1 |
|
lcr
|
1 |
+-----------------------+---------------+
insert into lcr values(1234567890,'%',100,50);
insert into gw values('my-nifty-gateway',122432324,5060,'','',100);
the ip address you have to reverse the octets and THEN convert to long giving 122432324 (test.org)
here is the script for IP conversion: (make sure you have Net::IP module installed)