Browse code

kemix: exported function get_rcvadvip() and get_rcvadvport()

- return advertised address and port of the receiving socket

Daniel-Constantin Mierla authored on 20/11/2020 07:12:18
Showing 1 changed files
... ...
@@ -520,6 +520,38 @@ static sr_kemi_xval_t* ki_kx_get_rcvport(sip_msg_t *msg)
520 520
 	return &_sr_kemi_kx_xval;
521 521
 }
522 522
 
523
+/**
524
+ *
525
+ */
526
+static sr_kemi_xval_t* ki_kx_get_rcvadvip(sip_msg_t *msg)
527
+{
528
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
529
+	if(msg->rcv.bind_address!=NULL
530
+			&& msg->rcv.bind_address->useinfo.address_str.len > 0) {
531
+		_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
532
+		_sr_kemi_kx_xval.v.s = msg->rcv.bind_address->useinfo.address_str;
533
+		return &_sr_kemi_kx_xval;
534
+	}
535
+
536
+	return ki_kx_get_rcvip(msg);
537
+}
538
+
539
+/**
540
+ *
541
+ */
542
+static sr_kemi_xval_t* ki_kx_get_rcvadvport(sip_msg_t *msg)
543
+{
544
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
545
+	if(msg->rcv.bind_address!=NULL
546
+			&& msg->rcv.bind_address->useinfo.port_no_str.len > 0) {
547
+		_sr_kemi_kx_xval.vtype = SR_KEMIP_INT;
548
+		_sr_kemi_kx_xval.v.n = (int)msg->rcv.bind_address->useinfo.port_no;
549
+		return &_sr_kemi_kx_xval;
550
+	}
551
+
552
+	return ki_kx_get_rcvport(msg);
553
+}
554
+
523 555
 /**
524 556
  *
525 557
  */
... ...
@@ -1085,6 +1117,16 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
1085 1117
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1086 1118
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1087 1119
 	},
1120
+	{ str_init("kx"), str_init("get_rcvadvip"),
1121
+		SR_KEMIP_XVAL, ki_kx_get_rcvadvip,
1122
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1123
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1124
+	},
1125
+	{ str_init("kx"), str_init("get_rcvadvport"),
1126
+		SR_KEMIP_XVAL, ki_kx_get_rcvadvport,
1127
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1128
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1129
+	},
1088 1130
 	{ str_init("kx"), str_init("get_proto"),
1089 1131
 		SR_KEMIP_XVAL, ki_kx_get_proto,
1090 1132
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,