From df817340df65abd116e6f9d49a3a32b4d1c0d470 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 20 Jul 2018 17:59:36 +0200 Subject: [PATCH] pv: using * for header name matches any header for $hdr(name) - e.g., $hdr(*) is body of first header, $(hdr(*)[-1]) is body of last header --- src/modules/pv/pv_core.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c index 8957098895d..65e9491b936 100644 --- a/src/modules/pv/pv_core.c +++ b/src/modules/pv/pv_core.c @@ -1900,6 +1900,8 @@ int pv_get_hdr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) if (tv.ri==hf->type) break; } else { + if(tv.rs.len==1 && tv.rs.s[0]=='*') + break; if (cmp_hdrname_str(&hf->name, &tv.rs)==0) break; } @@ -1953,8 +1955,10 @@ int pv_get_hdr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) if (tv.ri==hf->type) break; } else { + if(tv.rs.len==1 && tv.rs.s[0]=='*') + break; if (cmp_hdrname_str(&hf->name, &tv.rs)==0) - break; + break; } } } while (hf); @@ -1976,8 +1980,11 @@ int pv_get_hdr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) if (tv.ri==hf0->type) n++; } else { - if (cmp_hdrname_str(&hf0->name, &tv.rs)==0) + if(tv.rs.len==1 && tv.rs.s[0]=='*') { n++; + } else if (cmp_hdrname_str(&hf0->name, &tv.rs)==0) { + n++; + } } } idx = -idx; @@ -2003,8 +2010,11 @@ int pv_get_hdr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) if (tv.ri==hf0->type) n++; } else { - if (cmp_hdrname_str(&hf0->name, &tv.rs)==0) + if(tv.rs.len==1 && tv.rs.s[0]=='*') { + n++; + } else if (cmp_hdrname_str(&hf0->name, &tv.rs)==0) { n++; + } } if(n==idx) break; @@ -3114,6 +3124,14 @@ int pv_parse_hdr_name(pv_spec_p sp, str *in) return 0; } + if(in->len==1 && in->s[0]=='*') { + /* match any header name */ + sp->pvp.pvn.type = PV_NAME_INTSTR; + sp->pvp.pvn.u.isname.type = AVP_NAME_STR; + sp->pvp.pvn.u.isname.name.s = *in; + return 0; + } + if(in->len>=pv_get_buffer_size()-1) { LM_ERR("name too long\n");