Partial session manager implementation for opensips

This commit is contained in:
DanB
2015-05-09 19:56:45 +02:00
parent 6b3c5430a3
commit df65bebd6a
5 changed files with 145 additions and 60 deletions

View File

@@ -86,12 +86,14 @@ modparam("dialog", "db_mode", 0)
#### ACCounting module
loadmodule "acc.so"
modparam("acc", "cdr_flag", "CDR")
#modparam("acc", "cdr_flag", "CDR")
modparam("acc", "evi_flag", "CDR")
modparam("acc", "evi_missed_flag", "CDR")
modparam("acc", "evi_extra", "cgr_reqtype=$avp(cgr_reqtype);
cgr_account=$avp(cgr_account);
cgr_subject=$avp(cgr_subject);
cgr_destination=$avp(cgr_destination)")
cgr_destination=$avp(cgr_destination);
cgr_supplier=$avp(cgr_supplier);
dialog_id=$DLG_did")
#### CfgUtils module
loadmodule "cfgutils.so"
@@ -119,26 +121,10 @@ startup_route {
raise_event("E_OPENSIPS_START");
}
event_route[E_DLG_STATE_CHANGED] {
fetch_event_params("new_state=$var(new_state)");
if $var(new_state) == 3 {
$avp(dialog_start) = "cgr_reqtype";
$avp(dialog_start) = $avp(cgr_reqtype);
$avp(dialog_start) = "callid";
$avp(dialog_start) = $ci;
$avp(dialog_start) = "from_tag";
$avp(dialog_start) = $ft;
$avp(dialog_start) = "cgr_account";
$avp(dialog_start) = $avp(cgr_account);
$avp(dialog_start) = "cgr_subject";
$avp(dialog_start) = $avp(cgr_subject);
$avp(dialog_start) = "cgr_destination";
$avp(dialog_start) = $avp(cgr_destination);
$avp(dialog_start) = "created";
$avp(dialog_start) = $Ts;
$avp(dialog_start) = "dialog_id";
$avp(dialog_start) = $DLG_did;
raise_event("E_CGR_DIALOG_START", $avp(auth_keys), $avp(auth_vals));
local_route {
if (is_method("BYE") ) {
#setflag(CDR);
acc_evi_request("LOCAL_DISCONNECT"); #FixMe
}
}
@@ -157,7 +143,7 @@ route{
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
#setflag(CDR); # do accounting ...
setflag(CDR); # do accounting ...
} else if (is_method("INVITE")) {
# even if in most of the cases is useless, do RR for
# re-INVITEs alos, as some buggy clients do change route set
@@ -236,6 +222,10 @@ route{
send_reply("500","Internal Server Error");
exit;
}
$avp(cgr_reqtype)="*pseudoprepaid";
#$avp(cgr_account)=$fU;
$avp(cgr_destination)=$rU;
$avp(cgr_supplier)="supplier1";
setflag(CDR);
#route(CGR_AUTH_REQ);
}
@@ -274,10 +264,6 @@ route{
## Send AUTH request to CGRateS engine
route[CGR_AUTH_REQ] {
$avp(cgr_reqtype)="*pseudoprepaid";
$avp(cgr_account)=$fU;
$avp(cgr_destination)=$rU;
# Code to produce the json
$json(cgr_auth) := "{}";
$json(cgr_auth/id) = "1";
@@ -312,7 +298,6 @@ route[CGR_AUTH_REPLY] {
route[relay] {
# for INVITEs enable some additional helper routes
if (is_method("INVITE") && !has_totag()) {
t_on_reply("invite_reply");
t_on_failure("missed_call");
}
if (!t_relay()) {
@@ -330,12 +315,6 @@ route[location] {
}
}
onreply_route[invite_reply] {
xlog("incoming reply\n");
#acc_evi_request("DIALOG_START");
}
failure_route[missed_call] {
if (t_was_cancelled()) {
exit;