[sr-dev] git:master:e3774a8e: pv: add missing implementation for documented acc user pv (GH #2056)

Henning Westerholt hw at skalatan.de
Fri Sep 6 09:27:22 CEST 2019


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

Author: Henning Westerholt <hw at skalatan.de>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2019-09-06T09:19:59+02:00

pv: add missing implementation for documented acc user pv (GH #2056)

- add missing implementation for documented acc user pseudo-variable
- it was documented as $Au, but it works differently since a long time
- as discussed in issue GH #2056 add a new pv $AU that works like intended

---

Modified: src/modules/pv/pv.c
Modified: src/modules/pv/pv_core.c
Modified: src/modules/pv/pv_core.h

---

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

---

diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index e629d66d10..310acf53d0 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -141,6 +141,9 @@ static pv_export_t mod_pvs[] = {
 	{{"Au", (sizeof("Au")-1)}, /* */
 		PVT_OTHER, pv_get_acc_username, 0,
 		0, 0, pv_init_iname, 1},
+	{{"AU", (sizeof("AU")-1)}, /* */
+		PVT_OTHER, pv_get_acc_user, 0,
+		0, 0, pv_init_iname, 1},
 	{{"bf", (sizeof("bf")-1)}, /* */
 		PVT_CONTEXT, pv_get_bflags, pv_set_bflags,
 		0, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index c554ed0cde..18db915cfb 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -1572,6 +1572,37 @@ static inline str *cred_realm(struct sip_msg *rq)
 	return realm;
 }
 
+
+int pv_get_acc_user(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res)
+{
+	str* user;
+	struct sip_uri puri;
+	struct to_body* from;
+
+	/* try to take it from credentials */
+	user = cred_user(msg);
+	if (user) {
+		return pv_get_strval(msg, param, res, user);
+	}
+
+	/* from from uri */
+	if(parse_from_header(msg)<0)
+	{
+		LM_ERR("cannot parse FROM header\n");
+		return pv_get_null(msg, param, res);
+	}
+	if (msg->from && (from=get_from(msg)) && from->uri.len) {
+		if (parse_uri(from->uri.s, from->uri.len, &puri) < 0 ) {
+			LM_ERR("bad From URI\n");
+			return pv_get_null(msg, param, res);
+		}
+		return pv_get_strval(msg, param, res, &(puri.user));
+	}
+	return pv_get_null(msg, param, res);
+}
+
+
 int pv_get_acc_username(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res)
 {
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 86629e66e0..ee45b915cd 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -223,6 +223,9 @@ int pv_get_body_size(struct sip_msg *msg, pv_param_t *param,
 int pv_get_authattr(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 
+int pv_get_acc_user(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res);
+
 int pv_get_acc_username(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 




More information about the sr-dev mailing list