Can you log the output you receive in "route..." In evapi message received?
суббота, 29 августа 2015 г. пользователь Admin написал:
Thank you for responding to my post. Here it is.
include_file "kamailio-cgrates.cfg"
request_route {
...
switch ($fU) {
case 1001:
case 1006:
$dlg_var(cgrReqType) = "*prepaid";
break;
case 1002:
$dlg_var(cgrReqType) = "*postpaid";
break;
case 1003:
$dlg_var(cgrReqType) = "*pseudoprepaid";
break;
default:
$dlg_var(cgrReqType) = "*rated";
}
$dlg_var(cgrTenant) = "cgrates.org";
$dlg_var(cgrAccount) = $fU;
$dlg_var(cgrDestination) = $rU;
route(CGRATES_AUTH_REQUEST); # Will be answered in
CGRATES_AUTH_REPLY
#route(CGRATES_LCR_REQUEST);
exit;
}
# Here will land requests after processing them with CGRateS.
# Call RELAY or other routes following this route
route[CGRATES_AUTH_REPLY] {
if $var(CgrError) != "" {
xlog("CGR_AUTH_ERROR: $var(CgrError)");
sl_send_reply("503","CGR_ERROR");
exit;
}
if $var(CgrMaxSessionTime) != -1 {
if $var(CgrMaxSessionTime) == 0 { // Not enough balance,
do not allow
the call to go through
sl_send_reply("403","Insufficient credit");
exit;
} else if !dlg_set_timeout("$var(CgrMaxSessionTime)") {
sl_send_reply("503","CGR_MAX_SESSION_TIME_ERROR");
exit;
}
}
if $var(CgrSuppliers) != "" { # Enforce the supplier variable to
the
first one received from CGRateS
$dlg_var(cgrSupplier) = $(var(CgrSuppliers){s.select,0,,});
}
route(RELAY);
}
====================================================================
# kamailio-cgrates.cfg
# Kamailio-CGRateS related route blocks
# Called on new connection over evapi, should normally be the case of
CGRateS engine
event_route[evapi:connection-new] {
$sht(cgrconn=>cgr) = $evapi(srcaddr) + ":" + $evapi(srcport); #
Detect presence of at least one connection
}
# Called when the connection with CGRateS closes
event_route[evapi:connection-closed] {
$var(connClosed) = $evapi(srcaddr) + ":" + $evapi(srcport);
if $sht(cgrconn=>cgr) == $var(connClosed) {
$sht(cgrconn=>cgr) = $null;
}
}
# Message received from CGRateS, dispatch it to own route
event_route[evapi:message-received] {
json_get_field("$evapi(msg)", "Event",
"$var(Event)");
route($(var(Event){s.rm,"})); # String characters are kept by
json_get_field, remove them here
}
# Called by Kamailio on new dialog
event_route[dialog:start] {
route(CGR_CALL_START);
}
# Called by Kamailio on dialog end
event_route[dialog:end] {
route(CGR_CALL_END);
}
# Called by Kamailio on local disconnect
event_route[tm:local-request] {
route(CGR_CALL_END);
}
# Send AUTH_REQUEST to CGRateS
route[CGRATES_AUTH_REQUEST] {
# Auth INVITEs with CGRateS
if $sht(cgrconn=>cgr) == $null {
sl_send_reply("503","Charging controller
unreachable");
exit;
}
evapi_async_relay("{\"event\":\"CGR_AUTH_REQUEST\",
\"tr_index\":\"$T(id_index)\",
\"tr_label\":\"$T(id_label)\",
\"cgr_reqtype\":\"$dlg_var(cgrReqType)\",
\"cgr_tenant\":\"$dlg_var(cgrTenant)\",
\"cgr_account\":\"$dlg_var(cgrAccount)\",
\"cgr_destination\":\"$dlg_var(cgrDestination)\",
\"cgr_setuptime\":\"$TS\",
\"cgr_computelcr\":\"true\"}");
}
# Process AUTH_REPLY from CGRateS
route[CGR_AUTH_REPLY] {
json_get_field("$evapi(msg)", "TransactionIndex",
"$var(TransactionIndex)");
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)");
$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(CgrError) = $(var(Error){s.rm,"});
t_continue("$var(id_index)", "$var(id_label)",
"CGRATES_AUTH_REPLY"); #
Unpark the transaction
}
# Send AUTH_REQUEST to CGRateS
route[CGRATES_LCR_REQUEST] {
# Auth INVITEs with CGRateS
if $sht(cgrconn=>cgr) == $null {
sl_send_reply("503","Charging controller
unreachable");
exit;
}
evapi_async_relay("{\"event\":\"CGR_LCR_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_LCR_REPLY] {
json_get_field("$evapi(msg)", "TransactionIndex",
"$var(TransactionIndex)");
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)");
$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(CgrError) = $(var(Error){s.rm,"});
t_continue("$var(id_index)", "$var(id_label)",
"CGRATES_AUTH_REPLY"); #
Unpark the transaction
}
# CGRateS request for session disconnect
route[CGR_SESSION_DISCONNECT] {
json_get_field("$evapi(msg)", "HashEntry",
"$var(HashEntry)");
json_get_field("$evapi(msg)", "HashId",
"$var(HashId)");
json_get_field("$evapi(msg)", "Reason",
"$var(Reason)");
jsonrpc_exec('{"jsonrpc":"2.0","id":1,
"method":"dlg.end_dlg","params":[$(var(HashEntry){s.rm,"}),
$(var(HashId){s.rm,"})]}');
#$jsonrpl($var(reply));
}
# Inform CGRateS about CALL_START (start prepaid sessions loops)
route[CGR_CALL_START] {
if $sht(cgrconn=>cgr) == $null {
xlog("Charging controller unreachable");
exit;
}
evapi_async_relay("{\"event\":\"CGR_CALL_START\",
\"callid\":\"$dlg(callid)\",
\"from_tag\":\"$dlg(from_tag)\",
\"h_entry\":\"$dlg(h_entry)\",
\"h_id\":\"$dlg(h_id)\",
\"cgr_reqtype\":\"$dlg_var(cgrReqType)\",
\"cgr_tenant\":\"$dlg_var(cgrTenant)\",
\"cgr_account\":\"$dlg_var(cgrAccount)\",
\"cgr_destination\":\"$dlg_var(cgrDestination)\",
\"cgr_answertime\":\"$TS\",
\"cgr_supplier\":\"$dlg_var(cgrSupplier)\"}");
}
# Inform CGRateS about CALL_END (stop debit loops, perform accounting if
desired in this way)
route[CGR_CALL_END] {
if $sht(cgrconn=>cgr) == $null {
xlog("Charging controller unreachable");
exit;
}
$var(callDur) = $TS - $dlg(start_ts);
evapi_async_relay("{\"event\":\"CGR_CALL_END\",
\"callid\":\"$dlg(callid)\",
\"from_tag\":\"$dlg(from_tag)\",
\"cgr_reqtype\":\"$dlg_var(cgrReqType)\",
\"cgr_tenant\":\"$dlg_var(cgrTenant)\",
\"cgr_account\":\"$dlg_var(cgrAccount)\",
\"cgr_destination\":\"$dlg_var(cgrDestination)\",
\"cgr_answertime\":\"$dlg(start_ts)\",
\"cgr_duration\":\"$var(callDur)\",
\"cgr_supplier\":\"$dlg_var(cgrSupplier)\",
\"cgr_disconnectcause\":\"$T_reply_code\"}");
}
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org <javascript:;>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Alexandru Covalschi
ABRISS-Solutions
VoIP engineer and system administrator
phone: +37367398493
web: