Browse code

kemix: exported function to get call-id

Daniel-Constantin Mierla authored on 05/02/2020 08:38:43
Showing 1 changed files
... ...
@@ -35,6 +35,7 @@
35 35
 
36 36
 MODULE_VERSION
37 37
 
38
+/* clang-format off */
38 39
 struct module_exports exports = {
39 40
 	"kemix",         /* module name */
40 41
 	DEFAULT_DLFLAGS, /* dlopen flags */
... ...
@@ -47,6 +48,7 @@ struct module_exports exports = {
47 48
 	0,               /* per-child init function */
48 49
 	0                /* module destroy function */
49 50
 };
51
+/* clang-format on */
50 52
 
51 53
 
52 54
 /**
... ...
@@ -719,6 +721,28 @@ static int ki_kx_get_timestamp(sip_msg_t *msg)
719 721
 	return (int)time(NULL);
720 722
 }
721 723
 
724
+/**
725
+ *
726
+ */
727
+static sr_kemi_xval_t* ki_kx_get_callid(sip_msg_t *msg)
728
+{
729
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
730
+	if(msg==NULL) {
731
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
732
+		return &_sr_kemi_kx_xval;
733
+	}
734
+	if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID_F, 0)==-1)
735
+			|| (msg->callid==NULL))) {
736
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
737
+		return &_sr_kemi_kx_xval;
738
+	}
739
+
740
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
741
+	_sr_kemi_kx_xval.v.s = msg->callid->body;
742
+	return &_sr_kemi_kx_xval;
743
+}
744
+
745
+
722 746
 /**
723 747
  *
724 748
  */
... ...
@@ -915,6 +939,11 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
915 939
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
916 940
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
917 941
 	},
942
+	{ str_init("kx"), str_init("get_callid"),
943
+		SR_KEMIP_XVAL, ki_kx_get_callid,
944
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
945
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
946
+	},
918 947
 
919 948
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
920 949
 };