[sr-dev] git:master:80fbeff6: Add Pseude-Variable to get username of Contact, that was used during registration.

Carsten Bock carsten at ng-voice.com
Thu Jan 22 11:56:36 CET 2015


Module: kamailio
Branch: master
Commit: 80fbeff64fe752a8998a774263fd00c9cddd65b5
URL: https://github.com/kamailio/kamailio/commit/80fbeff64fe752a8998a774263fd00c9cddd65b5

Author: Carsten Bock <carsten at ng-voice.com>
Committer: Carsten Bock <carsten at ng-voice.com>
Date: 2015-01-22T12:56:23+02:00

Add Pseude-Variable to get username of Contact, that was used during registration.

---

Modified: modules/ims_registrar_pcscf/reg_mod.c
Modified: modules/ims_registrar_pcscf/service_routes.c
Modified: modules/ims_registrar_pcscf/service_routes.h

---

Diff:  https://github.com/kamailio/kamailio/commit/80fbeff64fe752a8998a774263fd00c9cddd65b5.diff
Patch: https://github.com/kamailio/kamailio/commit/80fbeff64fe752a8998a774263fd00c9cddd65b5.patch

---

diff --git a/modules/ims_registrar_pcscf/reg_mod.c b/modules/ims_registrar_pcscf/reg_mod.c
index 0e27bb9..9d50862 100644
--- a/modules/ims_registrar_pcscf/reg_mod.c
+++ b/modules/ims_registrar_pcscf/reg_mod.c
@@ -127,6 +127,7 @@ static int assert_identity_fixup(void ** param, int param_no);
 
 /* Pseudo-Variables */
 static int pv_get_asserted_identity_f(struct sip_msg *, pv_param_t *, pv_value_t *);
+static int pv_get_registration_contact_f(struct sip_msg *, pv_param_t *, pv_value_t *);
 
 /**
  * Update the time.
@@ -183,6 +184,8 @@ stat_export_t mod_stats[] = {
 static pv_export_t mod_pvs[] = {
     {{"pcscf_asserted_identity", (sizeof("pcscf_asserted_identity")-1)}, /* The first identity of the contact. */
      PVT_OTHER, pv_get_asserted_identity_f, 0, 0, 0, 0, 0},
+    {{"pcscf_registration_contact", (sizeof("pcscf_registration_contact")-1)}, /* The contact used during REGISTER */
+     PVT_OTHER, pv_get_registration_contact_f, 0, 0, 0, 0, 0},
     {{0, 0}, 0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -479,3 +482,16 @@ pv_get_asserted_identity_f(struct sip_msg *msg, pv_param_t *param,
 	if (ret_val != NULL) return pv_get_strval(msg, param, res, ret_val);
 	else return -1;
 }
+
+
+/*
+ * Get the asserted Identity for the current user
+ */
+static int
+pv_get_registration_contact_f(struct sip_msg *msg, pv_param_t *param,
+		  pv_value_t *res)
+{
+	str * ret_val = get_registration_contact(msg);
+	if (ret_val != NULL) return pv_get_strval(msg, param, res, ret_val);
+	else return -1;
+}
diff --git a/modules/ims_registrar_pcscf/service_routes.c b/modules/ims_registrar_pcscf/service_routes.c
index 69a0046..ca253ef 100644
--- a/modules/ims_registrar_pcscf/service_routes.c
+++ b/modules/ims_registrar_pcscf/service_routes.c
@@ -38,6 +38,7 @@ static pcontact_t * c = NULL;
 extern usrloc_api_t ul;
 extern int ignore_contact_rxport_check;
 static str * asserted_identity;
+static str * registration_contact;
 
 /*!
  * \brief Parse the message and find first occurrence of Route header field.
@@ -222,7 +223,9 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
 		}
 	}
 	asserted_identity = NULL;
+	registration_contact = NULL;
 	if (c) {
+		registration_contact = &c->contact_user;
 		p = c->head;
 		while (p) {
 			if (p->is_default == 1)
@@ -495,6 +498,18 @@ str * get_asserted_identity(struct sip_msg* _m) {
 	} else return asserted_identity;
 }
 
+
+/**
+ * Get the contact used during registration of this user
+ */
+str * get_registration_contact(struct sip_msg* _m) {
+	if (_m->id != current_msg_id) {
+		LM_ERR("Unable to get contact used during registration: Please call is_registered first!\n");
+		return NULL;
+	} else return registration_contact;
+}
+
+
 /**
  * checked if passed identity is an asserted identity
  */
diff --git a/modules/ims_registrar_pcscf/service_routes.h b/modules/ims_registrar_pcscf/service_routes.h
index c7daf8f..c7887f5 100644
--- a/modules/ims_registrar_pcscf/service_routes.h
+++ b/modules/ims_registrar_pcscf/service_routes.h
@@ -47,6 +47,11 @@ int is_registered(struct sip_msg* _m, udomain_t* _d);
 str * get_asserted_identity(struct sip_msg* _m);
 
 /**
+ * Get the contact used during registration of this user
+ */
+str * get_registration_contact(struct sip_msg* _m);
+
+/**
  * Assert a given identity of a user
  */
 int assert_identity(struct sip_msg* _m, udomain_t* _d, str identity);




More information about the sr-dev mailing list