[SCCP MASQ] move pool base/max into config file

This commit is contained in:
Harald Welte 2011-02-06 22:33:08 +01:00
parent 0e1709cb65
commit 26f1cd50ab
2 changed files with 12 additions and 9 deletions

View File

@ -4,12 +4,16 @@
{modules, [mgw_nat_app, mgw_nat_sup, mgw_nat_usr, mgw_nat]},
{mod, {mgw_nat_app, []}},
{env, [
% SCCP rewrite
% SCCP static rewrite rules
{sccp_rewrite_tbl, [
{ 12340000, 98760000, "HLR" },
{ 12340001, 98760001, "VLR" }
]},
% SCCP source masquerading pool
{sccp_masq_gt_base, 12340000},
{sccp_masq_gt_max, 9999},
% ISUP rewrite
{msrn_pfx_msc, 35489099},
{msrn_pfx_stp, 6392994200},

View File

@ -31,22 +31,21 @@
last_access % timestamp of last usage
}).
-define(MASQ_GT_BASE, 12340000).
-define(MASQ_GT_MAX, 9999).
% alloc + insert a new masquerade state record in our tables
masq_alloc(DigitsOrig) ->
masq_try_alloc(DigitsOrig, 0).
masq_try_alloc(_DigitsOrig, Offset) when Offset > ?MASQ_GT_MAX ->
{ok, Base} = application:get_env(sccp_masq_gt_base),
{ok, Max} = application:get_env(sccp_masq_gt_max),
masq_try_alloc(DigitsOrig, Base, Max, 0).
masq_try_alloc(_DigitsOrig, _Base, Max, Offset) when Offset > Max ->
undef;
masq_try_alloc(DigitsOrig, Offset) ->
Try = ?MASQ_GT_BASE + Offset,
masq_try_alloc(DigitsOrig, Base, Max, Offset) ->
Try = Base + Offset,
EtsRet = ets:insert_new(get(sccp_masq_orig),
#sccp_masq_rec{digits_in = DigitsOrig,
digits_out = Try}),
case EtsRet of
false ->
masq_try_alloc(DigitsOrig, Offset+1);
masq_try_alloc(DigitsOrig, Base, Max, Offset+1);
_ ->
ets:insert(get(sccp_masq_rev),
#sccp_masq_rec{digits_in = Try,