... | ... |
@@ -703,6 +703,59 @@ static int ki_evapi_async_relay(sip_msg_t *msg, str *sdata) |
703 | 703 |
return 1; |
704 | 704 |
} |
705 | 705 |
|
706 |
+static int ki_evapi_async_unicast(sip_msg_t *msg, str *sdata, str *stag) |
|
707 |
+{ |
|
708 |
+ unsigned int tindex; |
|
709 |
+ unsigned int tlabel; |
|
710 |
+ tm_cell_t *t = 0; |
|
711 |
+ |
|
712 |
+ if(tmb.t_suspend==NULL) { |
|
713 |
+ LM_ERR("evapi async relay is disabled - tm module not loaded\n"); |
|
714 |
+ return -1; |
|
715 |
+ } |
|
716 |
+ |
|
717 |
+ t = tmb.t_gett(); |
|
718 |
+ if (t==NULL || t==T_UNDEFINED) |
|
719 |
+ { |
|
720 |
+ if(tmb.t_newtran(msg)<0) |
|
721 |
+ { |
|
722 |
+ LM_ERR("cannot create the transaction\n"); |
|
723 |
+ return -1; |
|
724 |
+ } |
|
725 |
+ t = tmb.t_gett(); |
|
726 |
+ if (t==NULL || t==T_UNDEFINED) |
|
727 |
+ { |
|
728 |
+ LM_ERR("cannot lookup the transaction\n"); |
|
729 |
+ return -1; |
|
730 |
+ } |
|
731 |
+ } |
|
732 |
+ if(tmb.t_suspend(msg, &tindex, &tlabel)<0) |
|
733 |
+ { |
|
734 |
+ LM_ERR("failed to suspend request processing\n"); |
|
735 |
+ return -1; |
|
736 |
+ } |
|
737 |
+ |
|
738 |
+ LM_DBG("transaction suspended [%u:%u]\n", tindex, tlabel); |
|
739 |
+ |
|
740 |
+ |
|
741 |
+ if(sdata->s==NULL || sdata->len == 0) { |
|
742 |
+ LM_ERR("invalid data parameter\n"); |
|
743 |
+ return -1; |
|
744 |
+ } |
|
745 |
+ |
|
746 |
+ if(stag->s==NULL || stag->len == 0) { |
|
747 |
+ LM_ERR("invalid tag parameter\n"); |
|
748 |
+ return -1; |
|
749 |
+ } |
|
750 |
+ |
|
751 |
+ if(evapi_relay_unicast(sdata, stag)<0) { |
|
752 |
+ LM_ERR("failed to relay event: [[%.*s]] to [%.*s] \n", |
|
753 |
+ sdata->len, sdata->s, stag->len, stag->s); |
|
754 |
+ return -2; |
|
755 |
+ } |
|
756 |
+ return 1; |
|
757 |
+} |
|
758 |
+ |
|
706 | 759 |
/** |
707 | 760 |
* |
708 | 761 |
*/ |
... | ... |
@@ -766,6 +819,11 @@ static sr_kemi_t sr_kemi_evapi_exports[] = { |
766 | 819 |
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, |
767 | 820 |
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
768 | 821 |
}, |
822 |
+ { str_init("evapi"), str_init("async_unicast"), |
|
823 |
+ SR_KEMIP_INT, ki_evapi_async_unicast, |
|
824 |
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, |
|
825 |
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
|
826 |
+ }, |
|
769 | 827 |
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } |
770 | 828 |
}; |
771 | 829 |
/* clang-format on */ |