Browse code

kemix: exported KSR.kx.get_method() - return sip method string

Daniel-Constantin Mierla authored on 01/08/2019 09:08:38
Showing 1 changed files
... ...
@@ -556,6 +556,34 @@ static sr_kemi_xval_t* ki_kx_gete_au(sip_msg_t *msg)
556 556
 	return ki_kx_get_auth_attr(msg, 1, SR_KEMI_XVAL_NULL_EMPTY);
557 557
 }
558 558
 
559
+/**
560
+ *
561
+ */
562
+static sr_kemi_xval_t* ki_kx_get_method(sip_msg_t *msg)
563
+{
564
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
565
+	if(msg==NULL) {
566
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
567
+		return &_sr_kemi_kx_xval;
568
+	}
569
+
570
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
571
+	if(msg->first_line.type == SIP_REQUEST) {
572
+		_sr_kemi_kx_xval.v.s = msg->first_line.u.request.method;
573
+		return &_sr_kemi_kx_xval;
574
+	}
575
+
576
+	if(msg->cseq==NULL && ((parse_headers(msg, HDR_CSEQ_F, 0)==-1) ||
577
+				(msg->cseq==NULL))) {
578
+		LM_ERR("no CSEQ header\n");
579
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
580
+		return &_sr_kemi_kx_xval;
581
+	}
582
+
583
+	_sr_kemi_kx_xval.v.s = get_cseq(msg)->method;
584
+	return &_sr_kemi_kx_xval;
585
+}
586
+
559 587
 /**
560 588
  *
561 589
  */
... ...
@@ -701,6 +729,11 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
701 729
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
702 730
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
703 731
 	},
732
+	{ str_init("kx"), str_init("get_method"),
733
+		SR_KEMIP_XVAL, ki_kx_get_method,
734
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
735
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
736
+	},
704 737
 
705 738
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
706 739
 };