Browse code

kemix: functions to get status code for reply

Daniel-Constantin Mierla authored on 01/08/2019 09:15:26
Showing 1 changed files
... ...
@@ -584,6 +584,39 @@ static sr_kemi_xval_t* ki_kx_get_method(sip_msg_t *msg)
584 584
 	return &_sr_kemi_kx_xval;
585 585
 }
586 586
 
587
+/**
588
+ *
589
+ */
590
+static int ki_kx_get_status(sip_msg_t *msg)
591
+{
592
+	if(msg==NULL) {
593
+		return -1;
594
+	}
595
+	if(msg->first_line.type != SIP_REPLY) {
596
+		return -1;
597
+	}
598
+	return (int)msg->first_line.u.reply.statuscode;
599
+}
600
+
601
+/**
602
+ *
603
+ */
604
+static sr_kemi_xval_t* ki_kx_gets_status(sip_msg_t *msg)
605
+{
606
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
607
+	if(msg==NULL) {
608
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
609
+		return &_sr_kemi_kx_xval;
610
+	}
611
+	if(msg->first_line.type != SIP_REPLY) {
612
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
613
+		return &_sr_kemi_kx_xval;
614
+	}
615
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
616
+	_sr_kemi_kx_xval.v.s = msg->first_line.u.reply.status;
617
+	return &_sr_kemi_kx_xval;
618
+}
619
+
587 620
 /**
588 621
  *
589 622
  */
... ...
@@ -734,6 +767,16 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
734 767
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
735 768
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
736 769
 	},
770
+	{ str_init("kx"), str_init("get_status"),
771
+		SR_KEMIP_INT, ki_kx_get_status,
772
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
773
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
774
+	},
775
+	{ str_init("kx"), str_init("gets_status"),
776
+		SR_KEMIP_XVAL, ki_kx_gets_status,
777
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
778
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
779
+	},
737 780
 
738 781
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
739 782
 };