Module: sip-router Branch: master Commit: 858146a9910ae2e434fb1de3840678cf8b684ce2 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=858146a9...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Apr 27 13:04:04 2009 +0200
core: pv - added wrapper to set function
- wrapper for PV set function that takes in consideration cases of altering the msg context
---
pvapi.c | 11 +++++++++++ pvar.h | 5 +++++ 2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/pvapi.c b/pvapi.c index ed6a239..87de64a 100644 --- a/pvapi.c +++ b/pvapi.c @@ -35,6 +35,7 @@ #include "ut.h" #include "dprint.h" #include "hashes.h" +#include "route.h" #include "pvar.h"
#define is_in_str(p, in) (p<in->s+in->len && *p) @@ -920,6 +921,16 @@ int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value) return ret; }
+int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op, + pv_value_t *value) +{ + if(sp==NULL || !pv_is_w(sp)) + return 0; /* no op */ + if(pv_alter_context(sp) && is_route_type(LOCAL_ROUTE)) + return 0; /* no op */ + return sp->setf(msg, &sp->pvp, op, value); +} + /** * */ diff --git a/pvar.h b/pvar.h index e1a51a5..bb98ef0 100644 --- a/pvar.h +++ b/pvar.h @@ -134,6 +134,9 @@ typedef int (*pv_parse_name_f)(pv_spec_p sp, str *in); typedef int (*pv_parse_index_f)(pv_spec_p sp, str *in); typedef int (*pv_init_param_f)(pv_spec_p sp, int param);
+#define pv_alter_context(pv) ((pv)->type==PVT_CONTEXT \ + || (pv)->type==PVT_BRANCH) + /*! \brief * PV spec format: * - $class_name @@ -166,6 +169,8 @@ typedef struct _pv_elem char* pv_parse_spec2(str *in, pv_spec_p sp, int silent); #define pv_parse_spec(in, sp) pv_parse_spec2((in), (sp), 0) int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value); +int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op, + pv_value_t *value); int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); int pv_elem_free_all(pv_elem_p log); void pv_value_destroy(pv_value_t *val);