Browse code

DSM:mod_dlg: dlg.refer action

Stefan Sayer authored on 10/11/2013 17:26:27
Showing 3 changed files
... ...
@@ -54,6 +54,9 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
54 54
 
55 55
   DEF_CMD("dlg.getOtherId", DLGGetOtherIdAction)
56 56
   DEF_CMD("dlg.getRtpRelayMode", DLGGetRtpRelayModeAction)
57
+
58
+  DEF_CMD("dlg.refer", DLGReferAction);
59
+
57 60
 } MOD_ACTIONEXPORT_END;
58 61
 
59 62
 //MOD_CONDITIONEXPORT_NONE(MOD_CLS_NAME);
... ...
@@ -455,3 +458,37 @@ EXEC_ACTION_START(DLGGetRtpRelayModeAction) {
455 458
 
456 459
   DBG("get RTP relay mode: %s='%s'\n", varname.c_str(), sc_sess->var[varname].c_str());
457 460
 } EXEC_ACTION_END;
461
+
462
+
463
+CONST_ACTION_2P(DLGReferAction, ',', true);
464
+EXEC_ACTION_START(DLGReferAction) {
465
+
466
+  AmSession* b2b_sess = dynamic_cast<AmSession*>(sess);
467
+  if (NULL == b2b_sess) {
468
+    throw DSMException("sbc", "type", "param", "cause",
469
+		       "dlg.refer used on non-session");
470
+  }
471
+
472
+  string refer_to = resolveVars(par1, sess, sc_sess, event_params);
473
+  string expires_s = resolveVars(par2, sess, sc_sess, event_params);
474
+
475
+  int expires = -1;
476
+  if (!expires_s.empty()) {
477
+    if (!str2int(expires_s, expires)) {
478
+      throw DSMException("sbc", "type", "param", "cause",
479
+			 "expires "+expires_s+" not valid");
480
+    }
481
+  }
482
+
483
+  if (NULL == b2b_sess->dlg) {
484
+      throw DSMException("sbc", "type", "param", "cause",
485
+			 "call doesn't have SIP dialog (OOPS!)");
486
+  }
487
+
488
+  if (b2b_sess->dlg->refer(refer_to, expires)) {
489
+    sc_sess->SET_ERRNO(DSM_ERRNO_DLG);
490
+    sc_sess->SET_STRERROR("sending REFER failed");
491
+  } else {
492
+    sc_sess->CLR_ERRNO;
493
+  }
494
+} EXEC_ACTION_END;
... ...
@@ -50,4 +50,7 @@ DEF_ACTION_2P(DLGGetReplyBodyAction);
50 50
 
51 51
 DEF_ACTION_1P(DLGGetOtherIdAction);
52 52
 DEF_ACTION_1P(DLGGetRtpRelayModeAction);
53
+
54
+DEF_ACTION_2P(DLGReferAction);
55
+
53 56
 #endif
... ...
@@ -76,6 +76,9 @@ dlg.getOtherId(varname)
76 76
 dlg.getRtpRelayMode(varname)
77 77
    get RTP relay mode (RTP_Direct, RTP_Relay, RTP_Transcoding) in $varname
78 78
 
79
+dlg.refer(string refer_to [, int expires=0])
80
+   refer to refer_to, optionally with expires
81
+
79 82
 Request/Reply Body handling in sipRequest/sipReply events:
80 83
 ----------------------------------------------------------
81 84
 actions (applicable only in sipRequest/sipReply event handling blocks):