Browse code

kemix: added functions to get proto string and id

Daniel-Constantin Mierla authored on 08/07/2019 15:28:46
Showing 1 changed files
... ...
@@ -453,6 +453,38 @@ static sr_kemi_xval_t* ki_kx_get_rcvport(sip_msg_t *msg)
453 453
 /**
454 454
  *
455 455
  */
456
+static sr_kemi_xval_t* ki_kx_get_proto(sip_msg_t *msg)
457
+{
458
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
459
+	if(msg==NULL) {
460
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
461
+		return &_sr_kemi_kx_xval;
462
+	}
463
+
464
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
465
+	if(get_valid_proto_string(msg->rcv.proto, 0, 0, &_sr_kemi_kx_xval.v.s)<0) {
466
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
467
+	}
468
+
469
+	return &_sr_kemi_kx_xval;
470
+}
471
+
472
+/**
473
+ *
474
+ */
475
+static int ki_kx_get_protoid(sip_msg_t *msg)
476
+{
477
+	if(msg==NULL) {
478
+		return -1;
479
+	}
480
+
481
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
482
+	return (int)msg->rcv.proto;
483
+}
484
+
485
+/**
486
+ *
487
+ */
456 488
 /* clang-format off */
457 489
 static sr_kemi_t sr_kemi_kx_exports[] = {
458 490
 	{ str_init("kx"), str_init("get_ruri"),
... ...
@@ -570,6 +602,16 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
570 570
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
571 571
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
572 572
 	},
573
+	{ str_init("kx"), str_init("get_proto"),
574
+		SR_KEMIP_XVAL, ki_kx_get_proto,
575
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
576
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
577
+	},
578
+	{ str_init("kx"), str_init("get_protoid"),
579
+		SR_KEMIP_INT, ki_kx_get_protoid,
580
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
581
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
582
+	},
573 583
 
574 584
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
575 585
 };