浏览代码

sst: exported functions to kemi interface

Daniel-Constantin Mierla 8 年之前
父节点
当前提交
a081a6ee5c
共有 3 个文件被更改,包括 63 次插入5 次删除
  1. 26 0
      src/modules/sst/sst.c
  2. 35 5
      src/modules/sst/sst_handlers.c
  3. 2 0
      src/modules/sst/sst_handlers.h

+ 26 - 0
src/modules/sst/sst.c

@@ -41,6 +41,8 @@
 #include <string.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdlib.h>
 
 
+#include "../../core/kemi.h"
+
 #include "../../modules/sl/sl.h"
 #include "../../modules/sl/sl.h"
 #include "sst_handlers.h" /* also includes sr_module.h needed by
 #include "sst_handlers.h" /* also includes sr_module.h needed by
                              handlers */
                              handlers */
@@ -211,3 +213,27 @@ static int mod_init(void)
 
 
 	return 0;
 	return 0;
 }
 }
+
+/**
+ *
+ */
+/* clang-format off */
+static sr_kemi_t sr_kemi_sst_exports[] = {
+	{ str_init("sst"), str_init("sst_check_min"),
+		SR_KEMIP_INT, ki_sst_check_min,
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+
+	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
+};
+/* clang-format on */
+
+/**
+ *
+ */
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
+{
+	sr_kemi_modules_add(sr_kemi_sst_exports);
+	return 0;
+}

+ 35 - 5
src/modules/sst/sst_handlers.c

@@ -590,7 +590,7 @@ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type,
 }
 }
 
 
 /**
 /**
- * The sstCheckMin() script command handler. Return 1 (true) if the
+ * The ki_sst_check_min() script command handler. Return 1 (true) if the
  * MIN-SE: of the message is too small compared to the sst_min_se
  * MIN-SE: of the message is too small compared to the sst_min_se
  * value. This will allow the script to reply to this INVITE with a
  * value. This will allow the script to reply to this INVITE with a
  * "422 Session Timer Too Small" response. if sst_min_se was never set
  * "422 Session Timer Too Small" response. if sst_min_se was never set
@@ -601,10 +601,9 @@ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type,
  * no reply is sent.
  * no reply is sent.
 
 
  * @param msg  - The sip message from the script (INVITE only)
  * @param msg  - The sip message from the script (INVITE only)
- * @param flag - Reply mode Flag. 0/NULL do not send reply, 1 send 422
+ * @param flag - Reply mode Flag. 0 do not send reply, 1 send 422
  *               reply if Session-Expires is to small with the MIN-SE
  *               reply if Session-Expires is to small with the MIN-SE
  *               header in the reply
  *               header in the reply
- * @param str2 - Not used.
  *
  *
  * @return 1 if the MIN-SE is too small, -1 if it is OK, or It could
  * @return 1 if the MIN-SE is too small, -1 if it is OK, or It could
  *         not be checked.
  *         not be checked.
@@ -612,7 +611,7 @@ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type,
  * NOTE: returning 0 == drop message, 1 == true, -1 == false in the
  * NOTE: returning 0 == drop message, 1 == true, -1 == false in the
  *       script.
  *       script.
  */
  */
-int sst_check_min(struct sip_msg *msg, char *flag, char *str2)
+int ki_sst_check_min(struct sip_msg *msg, int flag)
 {
 {
 	enum parse_sst_result result;
 	enum parse_sst_result result;
 	struct session_expires se = {0,0};
 	struct session_expires se = {0,0};
@@ -675,7 +674,7 @@ int sst_check_min(struct sip_msg *msg, char *flag, char *str2)
 			 * Too small. See if we need to send the 422 and are able
 			 * Too small. See if we need to send the 422 and are able
 			 * to send it.
 			 * to send it.
 			 */
 			 */
-			if (flag && *flag) {
+			if (flag) {
 				str msehdr;
 				str msehdr;
 				sst_build_minse_hdr(sst_min_se, &msehdr);
 				sst_build_minse_hdr(sst_min_se, &msehdr);
 				LM_DBG("Sending 422: %.*s\n", msehdr.len, msehdr.s);
 				LM_DBG("Sending 422: %.*s\n", msehdr.len, msehdr.s);
@@ -694,6 +693,37 @@ int sst_check_min(struct sip_msg *msg, char *flag, char *str2)
 	return -1; /* return false */
 	return -1; /* return false */
 }
 }
 
 
+/**
+ * The sstCheckMin() script command handler. Return 1 (true) if the
+ * MIN-SE: of the message is too small compared to the sst_min_se
+ * value. This will allow the script to reply to this INVITE with a
+ * "422 Session Timer Too Small" response. if sst_min_se was never set
+ * the recommended value of 1800 seconds will be used.
+ *
+ * If the flag (str1) is set to 1, the 422 reply will be sent with the
+ * sst MIN_SE value in the header. If the flag is not set or is NULL,
+ * no reply is sent.
+
+ * @param msg  - The sip message from the script (INVITE only)
+ * @param flag - Reply mode Flag. 0/NULL do not send reply, 1 send 422
+ *               reply if Session-Expires is to small with the MIN-SE
+ *               header in the reply
+ * @param str2 - Not used.
+ *
+ * @return 1 if the MIN-SE is too small, -1 if it is OK, or It could
+ *         not be checked.
+ *
+ * NOTE: returning 0 == drop message, 1 == true, -1 == false in the
+ *       script.
+ */
+int sst_check_min(struct sip_msg *msg, char *flag, char *str2)
+{
+	if (flag && *flag) {
+		return ki_sst_check_min(msg, 1);
+	}
+	return ki_sst_check_min(msg, 0);
+}
+
 /**
 /**
  * Send a reply (response) to the passed in SIP request messsage with
  * Send a reply (response) to the passed in SIP request messsage with
  * the code and reason. If the header is not NULL (and header_len !=
  * the code and reason. If the header is not NULL (and header_len !=

+ 2 - 0
src/modules/sst/sst_handlers.h

@@ -69,6 +69,8 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type,
  */
  */
 int sst_check_min(struct sip_msg *msg, char *str1, char *str2);
 int sst_check_min(struct sip_msg *msg, char *str1, char *str2);
 
 
+int ki_sst_check_min(struct sip_msg *msg, int flag);
+
 /** \brief
 /** \brief
  * The handlers initializer function
  * The handlers initializer function
  */
  */