Răsfoiți Sursa

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

Carsten Bock 10 ani în urmă
părinte
comite
80fbeff64f

+ 16 - 0
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;
+}

+ 15 - 0
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
  */

+ 5 - 0
modules/ims_registrar_pcscf/service_routes.h

@@ -46,6 +46,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
  */