mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 06:38:45 +05:00
Kamailio SM with RL support
This commit is contained in:
@@ -59,16 +59,18 @@ route[CGR_AUTH_REPLY] {
|
||||
json_get_field("$evapi(msg)", "TransactionLabel", "$var(TransactionLabel)");
|
||||
json_get_field("$evapi(msg)", "MaxSessionTime", "$var(MaxSessionTime)");
|
||||
json_get_field("$evapi(msg)", "Suppliers", "$var(Suppliers)");
|
||||
json_get_field("$evapi(msg)", "Error", "$var(Error)");
|
||||
json_get_field("$evapi(msg)", "ResourceAllowed", "$var(CGRResourceAllowed)");
|
||||
json_get_field("$evapi(msg)", "Error", "$var(CgrError)");
|
||||
$var(id_index) = $(var(TransactionIndex){s.int});
|
||||
$var(id_label) = $(var(TransactionLabel){s.int});
|
||||
$var(CgrMaxSessionTime) = $(var(MaxSessionTime){s.int});
|
||||
$var(CgrSuppliers) = $(var(Suppliers){s.rm,"});
|
||||
$var(CGRResourceAllowed) = $(var(CGRResourceAllowed){s.rm,"});
|
||||
$var(CgrError) = $(var(Error){s.rm,"});
|
||||
t_continue("$var(id_index)", "$var(id_label)", "CGRATES_AUTH_REPLY"); # Unpark the transaction
|
||||
}
|
||||
|
||||
# Send AUTH_REQUEST to CGRateS
|
||||
# Send LCR_REQUEST to CGRateS
|
||||
route[CGRATES_LCR_REQUEST] {
|
||||
# Auth INVITEs with CGRateS
|
||||
if $sht(cgrconn=>cgr) == $null {
|
||||
@@ -99,6 +101,33 @@ route[CGR_LCR_REPLY] {
|
||||
t_continue("$var(id_index)", "$var(id_label)", "CGRATES_AUTH_REPLY"); # Unpark the transaction
|
||||
}
|
||||
|
||||
|
||||
# Send ResourceAllocation request to CGRateS
|
||||
route[CGRATES_RL_REQUEST] {
|
||||
if $sht(cgrconn=>cgr) == $null {
|
||||
sl_send_reply("503","Charging controller unreachable");
|
||||
exit;
|
||||
}
|
||||
evapi_async_relay("{\"event\":\"CGR_RL_REQUEST\",
|
||||
\"tr_index\":\"$T(id_index)\",
|
||||
\"tr_label\":\"$T(id_label)\",
|
||||
\"cgr_tenant\":\"$dlg_var(cgrTenant)\",
|
||||
\"cgr_account\":\"$dlg_var(cgrAccount)\",
|
||||
\"cgr_destination\":\"$dlg_var(cgrDestination)\",
|
||||
\"cgr_setuptime\":\"$TS\"}");
|
||||
}
|
||||
|
||||
# Process LCR_REPLY from CGRateS
|
||||
route[CGR_RL_REPLY] {
|
||||
json_get_field("$evapi(msg)", "ResourceAllowed", "$var(CGRResourceAllowed)");
|
||||
json_get_field("$evapi(msg)", "Error", "$var(CgrError)");
|
||||
$var(id_index) = $(var(TransactionIndex){s.int});
|
||||
$var(id_label) = $(var(TransactionLabel){s.int});
|
||||
$var(CGRResourceAllowed) = $(var(CGRResourceAllowed){s.rm,"});
|
||||
$var(CgrError) = $(var(CgrError){s.rm,"});
|
||||
t_continue("$var(id_index)", "$var(id_label)", "CGRATES_RL_REPLY"); # Unpark the transaction
|
||||
}
|
||||
|
||||
# CGRateS request for session disconnect
|
||||
route[CGR_SESSION_DISCONNECT] {
|
||||
json_get_field("$evapi(msg)", "HashEntry", "$var(HashEntry)");
|
||||
|
||||
@@ -207,6 +207,23 @@ route[CGRATES_AUTH_REPLY] {
|
||||
if $var(CgrSuppliers) != "" { # Enforce the supplier variable to the first one received from CGRateS, more for testing purposes
|
||||
$dlg_var(cgrSupplier) = $(var(CgrSuppliers){s.select,0,,});
|
||||
}
|
||||
if $var(CGRResourceAllowed) == "false" {
|
||||
sl_send_reply("403","Resource not allowed");
|
||||
exit;
|
||||
}
|
||||
route(RELAY);
|
||||
}
|
||||
|
||||
route[CGRATES_RL_REPLY] {
|
||||
if $var(CgrError) != "" {
|
||||
xlog("CGR_RL_ERROR: $var(CgrError)");
|
||||
sl_send_reply("503","CGR_ERROR");
|
||||
exit;
|
||||
}
|
||||
if $var(CGRResourceAllowed) == "false" {
|
||||
sl_send_reply("403","Resource not allowed");
|
||||
exit;
|
||||
}
|
||||
route(RELAY);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user