|
@@ -0,0 +1,84 @@
|
|
|
|
+/**
|
|
|
|
+ * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
|
|
|
|
+ *
|
|
|
|
+ * This file is part of Kamailio, a free SIP server.
|
|
|
|
+ *
|
|
|
|
+ * Kamailio is free software; you can redistribute it and/or modify
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ * (at your option) any later version
|
|
|
|
+ *
|
|
|
|
+ * Kamailio is distributed in the hope that it will be useful,
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ * GNU General Public License for more details.
|
|
|
|
+ *
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
|
|
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+
|
|
|
|
+#include "../../dprint.h"
|
|
|
|
+#include "../../route.h"
|
|
|
|
+
|
|
|
|
+#include "python_exec.h"
|
|
|
|
+#include "apy_kemi.h"
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+int sr_kemi_config_engine_python(sip_msg_t *msg, int rtype, str *rname)
|
|
|
|
+{
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ ret = -1;
|
|
|
|
+ if(rtype==REQUEST_ROUTE) {
|
|
|
|
+ ret = apy_exec(msg, "ksr_request_route", NULL, 1);
|
|
|
|
+ } else if(rtype==CORE_ONREPLY_ROUTE) {
|
|
|
|
+ ret = apy_exec(msg, "ksr_reply_route", NULL, 0);
|
|
|
|
+ } else if(rtype==BRANCH_ROUTE) {
|
|
|
|
+ if(rname!=NULL && rname->s!=NULL) {
|
|
|
|
+ ret = apy_exec(msg, rname->s, NULL, 0);
|
|
|
|
+ }
|
|
|
|
+ } else if(rtype==FAILURE_ROUTE) {
|
|
|
|
+ if(rname!=NULL && rname->s!=NULL) {
|
|
|
|
+ ret = apy_exec(msg, rname->s, NULL, 0);
|
|
|
|
+ }
|
|
|
|
+ } else if(rtype==BRANCH_FAILURE_ROUTE) {
|
|
|
|
+ if(rname!=NULL && rname->s!=NULL) {
|
|
|
|
+ ret = apy_exec(msg, rname->s, NULL, 0);
|
|
|
|
+ }
|
|
|
|
+ } else if(rtype==TM_ONREPLY_ROUTE) {
|
|
|
|
+ if(rname!=NULL && rname->s!=NULL) {
|
|
|
|
+ ret = apy_exec(msg, rname->s, NULL, 0);
|
|
|
|
+ }
|
|
|
|
+ } else if(rtype==ONSEND_ROUTE) {
|
|
|
|
+ ret = apy_exec(msg, "ksr_onsend_route", NULL, 0);
|
|
|
|
+ } else if(rtype==EVENT_ROUTE) {
|
|
|
|
+ if(rname!=NULL && rname->s!=NULL) {
|
|
|
|
+ ret = apy_exec(msg, rname->s, NULL, 0);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if(rname!=NULL) {
|
|
|
|
+ LM_ERR("route type %d with name [%.*s] not implemented\n",
|
|
|
|
+ rtype, rname->len, rname->s);
|
|
|
|
+ } else {
|
|
|
|
+ LM_ERR("route type %d with no name not implemented\n",
|
|
|
|
+ rtype);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(rname!=NULL) {
|
|
|
|
+ LM_DBG("execution of route type %d with name [%.*s] returned %d\n",
|
|
|
|
+ rtype, rname->len, rname->s, ret);
|
|
|
|
+ } else {
|
|
|
|
+ LM_DBG("execution of route type %d with no name returned %d\n",
|
|
|
|
+ rtype, ret);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
|
|
+}
|