THis is from an irc convo with brettnem, much thanks for his help.....<br>
the lcr mod will lookup the ruri in the lcr table.. matching prefix and from_ruri<br>
which gives a grp_id.. this grp_id is matched up to a grp_id in gw_grp (I think, I munged the functions)<br>
the grp_id correlates to multiple possible gateways for that call<br>
one table resolves prefixes (numbers) to route groups.. the other
resolves route groups to a list of gateways (or a feature server)<br>
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<br>
you really should have more than 2.. but you got the idea.. you need to check for load_gws failure (ie, no route 404)<br>
<br>
example for:<br>
<a href="mailto:sip:1234567890@test.com">sip:1234567890@test.com</a> to <a href="mailto:sip:1234567890@test.org">sip:1234567890@test.org</a><br>
<br>
tamp4x mysql> describe lcr;<br>
tamp4x +----------+---------------------+------+-----+---------+-------+<br>
tamp4x | Field |
Type
| Null | Key | Default | Extra |<br>
tamp4x +----------+---------------------+------+-----+---------+-------+<br>
tamp4x | prefix |
varchar(16)
| | MUL
|
| |<br>
tamp4x | from_uri |
varchar(128)
| | MUL |
%
| |<br>
tamp4x | grp_id | int(10) unsigned
| | MUL |
0
| |<br>
tamp4x | priority | tinyint(3) unsigned |
| | 0
| |<br>
tamp4x +----------+---------------------+------+-----+---------+-------+<br>
tamp4x 4 rows in set (0.00 sec)<br>
tamp4x mysql> describe gw;<br>
tamp4x +------------+----------------------+------+-----+---------+-------+<br>
tamp4x | Field |
Type
| Null | Key | Default | Extra |<br>
tamp4x +------------+----------------------+------+-----+---------+-------+<br>
tamp4x | gw_name |
varchar(128)
| | PRI
|
| |<br>
tamp4x | ip_addr | int(10)
unsigned |
| | 0
| |<br>
tamp4x | port | smallint(5)
unsigned | YES | | NULL
| |<br>
tamp4x | uri_scheme | tinyint(3) unsigned | YES
| | NULL
| |<br>
tamp4x | transport | tinyint(3) unsigned | YES
| | NULL
| |<br>
tamp4x | grp_id | int(10)
unsigned | | MUL
| 0
| |<br>
tamp4x +------------+----------------------+------+-----+---------+-------+<br>
tamp4x mysql> describe gw_grp;<br>
tamp4x +----------+------------------+------+-----+---------+----------------+<br>
tamp4x | Field |
Type
| Null | Key | Default |
Extra |<br>
tamp4x +----------+------------------+------+-----+---------+----------------+<br>
tamp4x | grp_id | int(10) unsigned | | PRI | NULL | auto_increment |<br>
tamp4x | grp_name | varchar(64)
| |
|
|
|<br>
tamp4x +----------+------------------+------+-----+---------+----------------+<br>
tamp4x 2 rows in set (0.02 sec)<br>
tamp4x mysql> describe grp;<br>
tamp4x +---------------+--------------+------+-----+---------------------+-------+<br>
tamp4x | Field |
Type | Null | Key |
Default
| Extra |<br>
tamp4x +---------------+--------------+------+-----+---------------------+-------+<br>
tamp4x | username | varchar(64)
| | PRI
|
| |<br>
tamp4x | domain |
varchar(128) | | PRI
|
| |<br>
tamp4x |
grp |
varchar(50) | | PRI
|
| |<br>
tamp4x | last_modified | datetime
| | | 0000-00-00
00:00:00 | |<br>
tamp4x +---------------+--------------+------+-----+---------------------+-------+<br>
that is the table structures<br>
<br>
make sure your version table looks like this:<br>
<br>
+-----------------------+---------------+<br>
| table_name | table_version |<br>
+-----------------------+---------------+<br>
|
subscriber
|
5 |<br>
|
reserved
|
1 |<br>
|
phonebook
|
1 |<br>
|
pending
|
4 |<br>
| missed_calls
|
2 |<br>
|
location
| 1001 |<br>
|
aliases
| 1001 |<br>
|
grp
|
2 |<br>
|
event
|
1 |<br>
| active_sessions
|
1 |<br>
|
acc
|
2 |<br>
|
config
|
1 |<br>
|
silo
|
3 |<br>
|
realm
|
1 |<br>
|
domain
|
1 |<br>
|
uri
|
1 |<br>
| server_monitoring | 1 |<br>
| server_monitoring_agg | 1 |<br>
|
trusted
|
1 |<br>
| usr_preferences
|
2 |<br>
| usr_preferences_types | 1 |<br>
| admin_privileges | 1 |<br>
| calls_forwarding | 1 |<br>
|
speed_dial
|
2 |<br>
|
dbaliases
|
1 |<br>
|
gw
|
3 |<br>
|
gw_grp
|
1 |<br>
|
lcr
|
1 |<br>
+-----------------------+---------------+<br>
<br>
<br>
<br>
<br>
insert into lcr values(1234567890,'%',100,50);<br>
insert into gw values('my-nifty-gateway',122432324,5060,'','',100);<br>
<br>
the ip address you have to reverse the octets and THEN convert to long giving 122432324 (<a href="http://test.org">test.org</a>)<br>
<br>
here is the script for IP conversion: (make sure you have Net::IP module installed)<br>
<br>
<div class="raw" id="source"><ol><li><div class="de1">#!/usr/bin/perl</div></li><li><div class="de1">use Net::IP;</div></li><li><div class="de1">my $ip = new Net::IP <span class="br0">(</span>$ARGV<span class="br0">[</span>
<span class="nu0">0</span><span class="br0">]</span><span class="br0">)</span> or die <span class="br0">(</span>Net::IP::Error<span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>;</div></li><li><div class="de1">
print "In Binary: " . $ip->binip . "\n";</div></li><li class="li2"><div class="de2">$decip= bin2dec<span class="br0">(</span>$ip->binip<span class="br0">)</span>;</div></li><li><div class="de1">print "DecIP:$decip\n";
</div></li><li><div class="de1">sub bin2dec <span class="br0">{</span></div></li><li><div class="de1"> return unpack<span class="br0">(</span>"N", pack<span class="br0">(</span>"B32", substr<span class="br0">
(</span>"<span class="nu0">0</span>" x <span class="nu0">32</span> . shift, -<span class="nu0">32</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span>;</div></li><li><div class="de1">
<span class="br0">}</span> </div></li></ol></div>
<br>
<br>
<br>
<br>
<br>
the 100 is the important data. it's the key that binds the first record in the lcr table to the ip record in the gw table<br>
that way, anything that routes to your nifty gateway, you just put it
into gw_grp 100 and it works.. just one entry in the gw table.
the ipaddr is what you want the destination host to be.<br>
<br>
<br>
now here is my ser.cfg<br>
<br>
# ----------- global configuration parameters ------------------------<br>
<br>
# debug=9 # debug level (cmd line: -dddddddddd)<br>
fork=yes<br>
log_stderror=yes# (cmd line: -E)<br>
check_via=no # (cmd. line: -v)<br>
dns=no # (cmd. line: -r)<br>
rev_dns=no # (cmd. line: -R)<br>
listen=<a href="http://64.201.13.52">64.201.13.52</a><br>
port=5060<br>
children=4<br>
# fifo="/tmp/ser_fifo"<br>
<br>
<br>
# ------------------ module loading ----------------------------------<br>
<br>
<br>
<br>
<br>
loadmodule "/usr/local/sip_router/modules/mysql/mysql.so"<br>
loadmodule "/usr/local/sip_router/modules/nathelper/nathelper.so"<br>
loadmodule "/usr/local/sip_router/modules/sl/sl.so"<br>
loadmodule "/usr/local/sip_router/modules/tm/tm.so"<br>
loadmodule "/usr/local/sip_router/modules/rr/rr.so"<br>
loadmodule "/usr/local/sip_router/modules/maxfwd/maxfwd.so"<br>
loadmodule "/usr/local/sip_router/modules/usrloc/usrloc.so"<br>
loadmodule "/usr/local/sip_router/modules/registrar/registrar.so"<br>
loadmodule "/usr/local/sip_router/modules/lcr/lcr.so"<br>
<br>
#!!!!!!!!!!you may need to use openser's table formatting!!!!!!!#<br>
#modparam("lcr","db_url", "mysql://root:password@localhost/openser")<br>
modparam("lcr","db_url", "mysql://root:password@localhost/ser")<br>
<br>
# main routing logic<br>
<br>
route{<br>
<br>
<br>
if (method=="REGISTER"){<br>
#record_route();<br>
forward(<a href="http://mysip.server.com">mysip.server.com</a>,5060);<br>
};<br>
<br>
#loose_route();<br>
<br>
if (method=="INVITE") {<br>
#record_route();<br>
force_rtp_proxy();<br>
if (!load_gws()) {<br>
sl_send_reply("500", "Server Internal Error - Cannot load gateways");<br>
break;<br>
};<br>
};<br>
<br>
# forward to current uri now<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
};<br>
}<br>
<br>
onreply_route[1] {<br>
if (status=~"[12][0-9][0-9]")<br>
force_rtp_proxy();<br>
<br>
}<br>
<br>
<br>
<br>
<br>
<br>
Ok hopefully this will work for someone out there , let me know<br>
<br>
because its not working perfectly for me... when i attempt to make a call i get memory errors...<br>
1(2850) ERROR: sip_msg_cloner: cannot allocate memory<br>
1(2850) ERROR: new_t: out of mem:<br>
1(2850) ERROR: t_newtran: new_t failed<br>
1(2850) ERROR: sl_reply_error used: I'm terribly sorry, server error occurred (1/SL)<br>
2(2852) ERROR: build_req_buf_from_sip_req: out of memory<br>
2(2852) ERROR: forward_request: building failed<br>
2(2852) Warning: sl_send_reply: I won't send a reply for ACK!!<br>
2(2852) ERROR: sl_reply_error used: I'm terribly sorry, server error occurred (2/SL)<br>
<br>
<br>
<br>