本文整理汇总了C++中pv_get_spec_value函数的典型用法代码示例。如果您正苦于以下问题:C++ pv_get_spec_value函数的具体用法?C++ pv_get_spec_value怎么用?C++ pv_get_spec_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pv_get_spec_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strncmp
static inline struct uac_credential *get_avp_credential(struct sip_msg *msg, str *realm)
{
static struct uac_credential crd;
pv_value_t pv_val;
if(pv_get_spec_value( msg, &auth_realm_spec, &pv_val)!=0)
return 0;
if (pv_val.flags&PV_VAL_NULL || pv_val.rs.len<=0) {
/* if realm parameter is empty or NULL, match any realm asked for */
crd.realm = *realm;
} else {
crd.realm = pv_val.rs;
/* is it the domain we are looking for? */
if (realm->len!=crd.realm.len ||
strncmp( realm->s, crd.realm.s, realm->len)!=0 ) {
return 0;
}
}
/* get username and password */
if(pv_get_spec_value( msg, &auth_username_spec, &pv_val)!=0
|| pv_val.flags&PV_VAL_NULL || pv_val.rs.len<=0)
return 0;
crd.user = pv_val.rs;
if(pv_get_spec_value( msg, &auth_password_spec, &pv_val)!=0
|| pv_val.flags&PV_VAL_NULL || pv_val.rs.len<=0)
return 0;
crd.passwd = pv_val.rs;
return &crd;
}
示例2: lb_is_dst
/* Checks, if the IP PORT is a LB destination
*/
int lb_is_dst(struct lb_data *data, struct sip_msg *_m,
pv_spec_t *pv_ip, pv_spec_t *pv_port, int grp, int active)
{
pv_value_t val;
struct ip_addr *ip;
int port;
struct lb_dst *dst;
int k;
/* get the address to test */
if (pv_get_spec_value( _m, pv_ip, &val)!=0) {
LM_ERR("failed to get IP value from PV\n");
return -1;
}
if ( (val.flags&PV_VAL_STR)==0 ) {
LM_ERR("IP PV val is not string\n");
return -1;
}
if ( (ip=str2ip( &val.rs ))==NULL ) {
LM_ERR("IP val is not IP <%.*s>\n",val.rs.len,val.rs.s);
return -1;
}
/* get the port to test */
if (pv_port) {
if (pv_get_spec_value( _m, pv_port, &val)!=0) {
LM_ERR("failed to get PORT value from PV\n");
return -1;
}
if ( (val.flags&PV_VAL_INT)==0 ) {
LM_ERR("PORT PV val is not integer\n");
return -1;
}
port = val.ri;
} else {
port = 0;
}
/* and now search !*/
for( dst=data->dsts ; dst ; dst=dst->next) {
if ( ((grp==-1) || (dst->group==grp)) && /*group matches*/
( !active || (active && (dst->flags&LB_DST_STAT_DSBL_FLAG)==0 ) )
) {
/* check the IPs */
for(k=0 ; k<dst->ips_cnt ; k++ ) {
if ( (dst->ports[k]==0 || port==0 || port==dst->ports[k]) &&
ip_addr_cmp( ip, &dst->ips[k]) ) {
/* found */
return 1;
}
}
}
}
return -1;
}
示例3: auth_get_ha1
static inline int auth_get_ha1(struct sip_msg *msg, struct username* _username,
str* _domain, char* _ha1)
{
pv_value_t sval;
/* get username from PV */
memset(&sval, 0, sizeof(pv_value_t));
if(pv_get_spec_value(msg, &user_spec, &sval)==0)
{
if(sval.flags==PV_VAL_NONE || (sval.flags&PV_VAL_NULL)
|| (sval.flags&PV_VAL_EMPTY) || (!(sval.flags&PV_VAL_STR)))
{
pv_value_destroy(&sval);
return 1;
}
if(sval.rs.len!= _username->whole.len
|| strncasecmp(sval.rs.s, _username->whole.s, sval.rs.len))
{
LM_DBG("username mismatch [%.*s] [%.*s]\n",
_username->whole.len, _username->whole.s, sval.rs.len, sval.rs.s);
pv_value_destroy(&sval);
return 1;
}
} else {
return 1;
}
/* get password from PV */
memset(&sval, 0, sizeof(pv_value_t));
if(pv_get_spec_value(msg, &passwd_spec, &sval)==0)
{
if(sval.flags==PV_VAL_NONE || (sval.flags&PV_VAL_NULL)
|| (sval.flags&PV_VAL_EMPTY) || (!(sval.flags&PV_VAL_STR)))
{
pv_value_destroy(&sval);
return 1;
}
} else {
return 1;
}
if (auth_calc_ha1) {
/* Only plaintext passwords are stored in database,
* we have to calculate HA1 */
calc_HA1(HA_MD5, &_username->whole, _domain, &sval.rs, 0, 0, _ha1);
LM_DBG("HA1 string calculated: %s\n", _ha1);
} else {
memcpy(_ha1, sval.rs.s, sval.rs.len);
_ha1[sval.rs.len] = '\0';
}
return 0;
}
示例4: w_rl_check_forced
static int w_rl_check_forced(struct sip_msg* msg, char *p1, char *p2)
{
int pipe = -1;
pv_value_t pv_val;
if (p1 && (pv_get_spec_value(msg, (pv_spec_t *)p1, &pv_val) == 0)) {
if (pv_val.flags & PV_VAL_INT) {
pipe = pv_val.ri;
LM_DBG("pipe=%d\n", pipe);
} else if (pv_val.flags & PV_VAL_STR) {
if(str2int(&(pv_val.rs), (unsigned int*)&pipe) != 0) {
LM_ERR("Unable to get pipe from pv '%.*s'"
"=> defaulting to method type checking\n",
pv_val.rs.len, pv_val.rs.s);
pipe = -1;
}
} else {
LM_ERR("pv not a str or int => defaulting to method type checking\n");
pipe = -1;
}
} else {
LM_ERR("Unable to get pipe from pv:%p"
" => defaulting to method type checking\n", p1);
pipe = -1;
}
return rl_check(msg, pipe);
}
示例5: cmd_send_rpl
int cmd_send_rpl(struct sip_msg *msg, int *cluster_id, int *node_id,
str *gen_msg, pv_spec_t *param_tag)
{
pv_value_t tag_val;
int rc;
if (pv_get_spec_value(msg, param_tag, &tag_val) < 0) {
LM_ERR("Failed to fetch tag parameter\n");
return -1;
}
if (tag_val.flags & PV_VAL_NULL ||
(tag_val.flags & PV_VAL_STR && tag_val.rs.len == 0)) {
LM_ERR("Empty tag\n");
return -1;
}
rc = send_gen_msg(*cluster_id, *node_id, gen_msg, &tag_val.rs, 0);
switch (rc) {
case 0:
return 1;
case 1:
return -1;
case -1:
return -2;
case -2:
return -3;
default:
return -3;
}
}
示例6: pv_get_spec_name
int pv_get_spec_name(struct sip_msg* msg, pv_param_p ip, pv_value_t *name)
{
if(msg==NULL || ip==NULL || name==NULL)
return -1;
memset(name, 0, sizeof(pv_value_t));
if(ip->pvn.type==PV_NAME_INTSTR)
{
if(ip->pvn.u.isname.type&AVP_NAME_STR)
{
name->rs = ip->pvn.u.isname.name.s;
name->flags = PV_VAL_STR;
} else {
name->ri = ip->pvn.u.isname.name.n;
name->flags = PV_VAL_INT|PV_TYPE_INT;
}
return 0;
} else if(ip->pvn.type==PV_NAME_PVAR) {
/* pvar */
if(pv_get_spec_value(msg, (pv_spec_p)(ip->pvn.u.dname), name)!=0)
{
LM_ERR("cannot get name value\n");
return -1;
}
if(name->flags&PV_VAL_NULL || name->flags&PV_VAL_EMPTY)
{
LM_ERR("null or empty name\n");
return -1;
}
return 0;
}
LM_ERR("name type is PV_NAME_OTHER - cannot resolve\n");
return -1;
}
示例7: sca_set_called_line
int sca_set_called_line(struct sip_msg *msg, char *line_var)
{
pv_value_t value;
str line;
if (no_dialog_support) {
LM_ERR("dialog support is disabled, cannot use this function\n");
return -1;
}
if (msg->REQ_METHOD != METHOD_INVITE)
return 1;
/* get the name of line first */
if (line_var) {
/* take it from param */
if ( pv_get_spec_value( msg, (pv_spec_p)line_var, &value) < 0 ) {
LM_ERR("failed to evaluate parameter\n");
return -1;
}
if ( (value.flags&PV_VAL_STR)==0 ) {
LM_ERR("line value is not a string (flags are %d)\n",value.flags);
return -1;
}
line = value.rs;
} else {
/* take it from RURI msg */
line = *GET_RURI(msg);
}
return sca_set_line(msg, &line, 0/*called*/);
}
示例8: pv_set_count
static int pv_set_count(struct sip_msg* msg, pv_spec_t *pv_name, pv_spec_t *pv_result)
{
pv_value_t pv_val;
memset(&pv_val, 0, sizeof(pv_value_t));
pv_name->pvp.pvi.type = PV_IDX_INT;
pv_name->pvp.pvi.u.ival = 0;
while(pv_val.flags != PV_VAL_NULL)
{
if(pv_get_spec_value(msg, pv_name, &pv_val) < 0)
{
LM_ERR("PV get function failed\n");
return -1;
}
pv_name->pvp.pvi.u.ival++;
}
pv_val.flags = PV_TYPE_INT;
pv_val.ri = pv_name->pvp.pvi.u.ival-1;
if (pv_set_value( msg, pv_result, 0, &pv_val) != 0)
{
LM_ERR("SET output value failed.\n");
return -1;
}
LM_DBG("Set count = %d\n", pv_val.ri);
return 1;
}
示例9: lua_sr_pv_is_null
static int lua_sr_pv_is_null (lua_State *L)
{
str pvn;
pv_spec_t pvs;
pv_value_t val;
sr_lua_env_t *env_L;
env_L = sr_lua_env_get();
pvn.s = (char*)lua_tostring(L, -1);
if(pvn.s==NULL || env_L->msg==NULL)
return 0;
pvn.len = strlen(pvn.s);
LM_DBG("pv is null test: %s\n", pvn.s);
if(pv_parse_spec(&pvn, &pvs)<0)
{
LM_ERR("unable to parse pv [%s]\n", pvn.s);
return 0;
}
memset(&val, 0, sizeof(pv_value_t));
if(pv_get_spec_value(env_L->msg, &pvs, &val) != 0)
{
LM_ERR("unable to get pv value for [%s]\n", pvn.s);
return 0;
}
if(val.flags&PV_VAL_NULL)
{
lua_pushboolean(L, 1);
} else {
lua_pushboolean(L, 0);
}
return 1;
}
示例10: pv_get_spec_index
int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags)
{
pv_value_t tv;
if(ip==NULL || idx==NULL || flags==NULL)
return -1;
*idx = 0;
*flags = 0;
if(ip->pvi.type == PV_IDX_ALL) {
*flags = PV_IDX_ALL;
return 0;
}
if(ip->pvi.type == PV_IDX_INT)
{
*idx = ip->pvi.u.ival;
return 0;
}
/* pvar */
if(pv_get_spec_value(msg, (pv_spec_p)ip->pvi.u.dval, &tv)!=0)
{
LM_ERR("cannot get index value\n");
return -1;
}
if(!(tv.flags&PV_VAL_INT))
{
LM_ERR("invalid index value\n");
return -1;
}
*idx = tv.ri;
return 0;
}
示例11: is_uri_user_e164
/*
* Check if user part of URI in pseudo variable is an e164 number
*/
int is_uri_user_e164(struct sip_msg* _m, char* _sp, char* _s2)
{
pv_spec_t *sp;
pv_value_t pv_val;
struct sip_uri puri;
sp = (pv_spec_t *)_sp;
if (sp && (pv_get_spec_value(_m, sp, &pv_val) == 0)) {
if (pv_val.flags & PV_VAL_STR) {
if (pv_val.rs.len == 0 || pv_val.rs.s == NULL) {
LM_DBG("missing uri\n");
return -1;
}
if (parse_uri(pv_val.rs.s, pv_val.rs.len, &puri) < 0) {
LM_ERR("parsing URI failed\n");
return -1;
}
return e164_check(&(puri.user));
} else {
LM_ERR("pseudo variable value is not string\n");
return -1;
}
} else {
LM_ERR("failed to get pseudo variable value\n");
return -1;
}
}
示例12: set_timeout_avp
/**
* Set the dialog's AVP value so the dialog module will use this value
* and not the default when returning from the dialog callback.
*
* @param msg The current message to bind the AVP to.
* @param value The value you want to set the AVP to.
*
* @return 0 on success, -1 on an error.
*/
static int set_timeout_avp(struct sip_msg *msg, unsigned int value)
{
int rtn = -1; /* assume failure */
pv_value_t pv_val;
int result = 0;
/* Set the dialog timeout HERE */
if (timeout_avp) {
if ((result = pv_get_spec_value(msg, timeout_avp, &pv_val)) == 0) {
/* We now hold a reference to the AVP */
if (pv_val.flags & PV_VAL_INT && pv_val.ri == value) {
/* INT AVP with the same value */
LM_DBG("Current timeout value already set to %d\n",
value);
rtn = 0;
} else {
/* AVP not found or non-INT value -> add a new one*/
pv_val.flags = PV_VAL_INT|PV_TYPE_INT;
pv_val.ri = value;
if (timeout_avp->setf(msg,&timeout_avp->pvp,EQ_T,&pv_val)!=0) {
LM_ERR("failed to set new dialog timeout value\n");
} else {
rtn = 0;
}
}
}
else {
LM_ERR("SST not reset. get avp result is %d\n", result);
}
}
else {
LM_ERR("SST needs to know the name of the dialog timeout AVP!\n");
}
return(rtn);
}
示例13: xlog_3_helper
static int xlog_3_helper(struct sip_msg* msg, char* fac, char* lev, char* frm, int mode)
{
long level;
int facility;
xl_level_p xlp;
pv_value_t value;
xlp = (xl_level_p)lev;
if(xlp->type==1)
{
if(pv_get_spec_value(msg, &xlp->v.sp, &value)!=0
|| value.flags&PV_VAL_NULL || !(value.flags&PV_VAL_INT))
{
LM_ERR("invalid log level value [%d]\n", value.flags);
return -1;
}
level = (long)value.ri;
} else {
level = xlp->v.level;
}
facility = *(int*)fac;
if(!is_printable((int)level))
return 1;
return xlog_helper(msg, (xl_msg_t*)frm, (int)level, mode, facility);
}
示例14: w_is_domain_local
/*
* Check if domain given as value of pseudo variable parameter is local.
*/
int w_is_domain_local(struct sip_msg* _msg, char* _sp, char* _s2)
{
pv_spec_t *sp;
pv_value_t pv_val;
struct attr_list *attrs;
str did;
sp = (pv_spec_t *)_sp;
if (sp && (pv_get_spec_value(_msg, sp, &pv_val) == 0)) {
if (pv_val.flags & PV_VAL_STR) {
if (pv_val.rs.len == 0 || pv_val.rs.s == NULL) {
LM_DBG("missing domain name\n");
return -1;
}
return hash_table_lookup(&(pv_val.rs), &did, &attrs);
} else {
LM_DBG("domain pseudo variable value is not string\n");
return -1;
}
} else {
LM_DBG("cannot get domain pseudo variable value\n");
return -1;
}
}
示例15: make_send_message
int make_send_message(struct sip_msg* msg, int index, VALUE_PAIR **send) {
pv_value_t pt;
map_list *mp = sets[index]->parsed;
for (; mp; mp = mp->next) {
pv_get_spec_value(msg, mp->pv, &pt);
if (pt.flags & PV_VAL_INT) {
//LM_DBG("%.*s---->%d---->%d---->%d\n",mp->name.len, mp->name.s,
// pt.ri, mp->value, pt.flags);
if (!rc_avpair_add(rh, send, ATTRID(mp->value), &pt.ri, -1, VENDOR(mp->value)))
return -1;
}
else
if (pt.flags & PV_VAL_STR) {
//LM_DBG("%.*s----->%.*s---->%d---->%d---->%d\n",mp->name.len,
// mp->name.s, pt.rs.len, pt.rs.s, mp->value, pt.flags, pt.rs.len);
if (rc_dict_getattr(rh,mp->value)->type == PW_TYPE_IPADDR) {
uint32_t ipaddr=rc_get_ipaddr(pt.rs.s);
if (!rc_avpair_add(rh, send, ATTRID(mp->value), &ipaddr, -1, VENDOR(mp->value)))
return -1;
} else {
if (!rc_avpair_add(rh, send, ATTRID(mp->value), pt.rs.s, pt.rs.len, VENDOR(mp->value)))
return -1;
}
}
}
return 0;
}