Browse code

kemix: exported functions to get to-uri user and host

Daniel-Constantin Mierla authored on 06/02/2020 19:49:36
Showing 1 changed files
... ...
@@ -341,6 +341,71 @@ static sr_kemi_xval_t* ki_kx_gete_fhost(sip_msg_t *msg)
341 341
 	return ki_kx_get_furi_attr(msg, 2, SR_KEMI_XVAL_NULL_EMPTY);
342 342
 }
343 343
 
344
+/**
345
+ *
346
+ */
347
+static sr_kemi_xval_t* ki_kx_get_turi_attr(sip_msg_t *msg, int iattr, int xmode)
348
+{
349
+	sip_uri_t *uri;
350
+
351
+	memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
352
+	uri=parse_to_uri(msg);
353
+	if(uri==NULL) {
354
+		sr_kemi_xval_null(&_sr_kemi_kx_xval, xmode);
355
+		return &_sr_kemi_kx_xval;
356
+	}
357
+
358
+	return ki_kx_get_xuri_attr(msg, uri, iattr, xmode);
359
+}
360
+
361
+/**
362
+ *
363
+ */
364
+static sr_kemi_xval_t* ki_kx_get_tuser(sip_msg_t *msg)
365
+{
366
+	return ki_kx_get_turi_attr(msg, 1, SR_KEMI_XVAL_NULL_NONE);
367
+}
368
+
369
+/**
370
+ *
371
+ */
372
+static sr_kemi_xval_t* ki_kx_getw_tuser(sip_msg_t *msg)
373
+{
374
+	return ki_kx_get_turi_attr(msg, 1, SR_KEMI_XVAL_NULL_PRINT);
375
+}
376
+
377
+/**
378
+ *
379
+ */
380
+static sr_kemi_xval_t* ki_kx_gete_tuser(sip_msg_t *msg)
381
+{
382
+	return ki_kx_get_turi_attr(msg, 1, SR_KEMI_XVAL_NULL_EMPTY);
383
+}
384
+
385
+/**
386
+ *
387
+ */
388
+static sr_kemi_xval_t* ki_kx_get_thost(sip_msg_t *msg)
389
+{
390
+	return ki_kx_get_turi_attr(msg, 2, SR_KEMI_XVAL_NULL_NONE);
391
+}
392
+
393
+/**
394
+ *
395
+ */
396
+static sr_kemi_xval_t* ki_kx_getw_thost(sip_msg_t *msg)
397
+{
398
+	return ki_kx_get_turi_attr(msg, 2, SR_KEMI_XVAL_NULL_PRINT);
399
+}
400
+
401
+/**
402
+ *
403
+ */
404
+static sr_kemi_xval_t* ki_kx_gete_thost(sip_msg_t *msg)
405
+{
406
+	return ki_kx_get_turi_attr(msg, 2, SR_KEMI_XVAL_NULL_EMPTY);
407
+}
408
+
344 409
 /**
345 410
  *
346 411
  */
... ...
@@ -828,6 +893,36 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
828 893
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
829 894
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
830 895
 	},
896
+	{ str_init("kx"), str_init("get_tuser"),
897
+		SR_KEMIP_XVAL, ki_kx_get_tuser,
898
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
899
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
900
+	},
901
+	{ str_init("kx"), str_init("gete_tuser"),
902
+		SR_KEMIP_XVAL, ki_kx_gete_tuser,
903
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
904
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
905
+	},
906
+	{ str_init("kx"), str_init("getw_tuser"),
907
+		SR_KEMIP_XVAL, ki_kx_getw_tuser,
908
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
909
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
910
+	},
911
+	{ str_init("kx"), str_init("get_thost"),
912
+		SR_KEMIP_XVAL, ki_kx_get_thost,
913
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
914
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
915
+	},
916
+	{ str_init("kx"), str_init("gete_thost"),
917
+		SR_KEMIP_XVAL, ki_kx_gete_thost,
918
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
919
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
920
+	},
921
+	{ str_init("kx"), str_init("getw_thost"),
922
+		SR_KEMIP_XVAL, ki_kx_getw_thost,
923
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
924
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
925
+	},
831 926
 	{ str_init("kx"), str_init("get_duri"),
832 927
 		SR_KEMIP_XVAL, ki_kx_get_duri,
833 928
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,