Browse code

kemix: exported functions to get socket string and name

Daniel-Constantin Mierla authored on 23/11/2020 07:15:34
Showing 1 changed files
... ...
@@ -486,6 +486,39 @@ static sr_kemi_xval_t* ki_kx_get_srcport(sip_msg_t *msg)
486 486
 	return &_sr_kemi_kx_xval;
487 487
 }
488 488
 
489
+/**
490
+ *
491
+ */
492
+static sr_kemi_xval_t* ki_kx_get_send_sock(sip_msg_t *msg)
493
+{
494
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
495
+	if (msg==NULL || msg->force_send_socket==0) {
496
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
497
+		return &_sr_kemi_kx_xval;
498
+	}
499
+
500
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
501
+	_sr_kemi_kx_xval.v.s = msg->force_send_socket->sock_str;
502
+	return &_sr_kemi_kx_xval;
503
+}
504
+
505
+/**
506
+ *
507
+ */
508
+static sr_kemi_xval_t* ki_kx_get_send_sock_name(sip_msg_t *msg)
509
+{
510
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
511
+	if (msg==NULL || msg->force_send_socket==0
512
+			|| msg->force_send_socket->sockname.s==0) {
513
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
514
+		return &_sr_kemi_kx_xval;
515
+	}
516
+
517
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
518
+	_sr_kemi_kx_xval.v.s = msg->force_send_socket->sockname;
519
+	return &_sr_kemi_kx_xval;
520
+}
521
+
489 522
 /**
490 523
  *
491 524
  */
... ...
@@ -520,6 +553,23 @@ static sr_kemi_xval_t* ki_kx_get_rcvport(sip_msg_t *msg)
520 553
 	return &_sr_kemi_kx_xval;
521 554
 }
522 555
 
556
+/**
557
+ *
558
+ */
559
+static sr_kemi_xval_t* ki_kx_get_rcv_sock_name(sip_msg_t *msg)
560
+{
561
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
562
+	if(msg==NULL || msg->rcv.bind_address==NULL
563
+			|| msg->rcv.bind_address->sockname.s==NULL) {
564
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
565
+		return &_sr_kemi_kx_xval;
566
+	}
567
+
568
+	_sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
569
+	_sr_kemi_kx_xval.v.s = msg->rcv.bind_address->sockname;
570
+	return &_sr_kemi_kx_xval;
571
+}
572
+
523 573
 /**
524 574
  *
525 575
  */
... ...
@@ -1107,11 +1157,26 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
1107 1157
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1108 1158
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1109 1159
 	},
1160
+	{ str_init("kx"), str_init("get_send_sock"),
1161
+		SR_KEMIP_XVAL, ki_kx_get_send_sock,
1162
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1163
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1164
+	},
1165
+	{ str_init("kx"), str_init("get_send_sock_name"),
1166
+		SR_KEMIP_XVAL, ki_kx_get_send_sock_name,
1167
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1168
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1169
+	},
1110 1170
 	{ str_init("kx"), str_init("get_rcvip"),
1111 1171
 		SR_KEMIP_XVAL, ki_kx_get_rcvip,
1112 1172
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1113 1173
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1114 1174
 	},
1175
+	{ str_init("kx"), str_init("get_rcv_sock_name"),
1176
+		SR_KEMIP_XVAL, ki_kx_get_rcv_sock_name,
1177
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1178
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1179
+	},
1115 1180
 	{ str_init("kx"), str_init("get_rcvport"),
1116 1181
 		SR_KEMIP_XVAL, ki_kx_get_rcvport,
1117 1182
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,