Module: kamailio Branch: master Commit: df817340df65abd116e6f9d49a3a32b4d1c0d470 URL: https://github.com/kamailio/kamailio/commit/df817340df65abd116e6f9d49a3a32b4...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-07-20T17:59:36+02:00
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
---
Modified: src/modules/pv/pv_core.c
---
Diff: https://github.com/kamailio/kamailio/commit/df817340df65abd116e6f9d49a3a32b4... Patch: https://github.com/kamailio/kamailio/commit/df817340df65abd116e6f9d49a3a32b4...
---
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c index 8957098895..65e9491b93 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");