• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ add_avp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中add_avp函数的典型用法代码示例。如果您正苦于以下问题:C++ add_avp函数的具体用法?C++ add_avp怎么用?C++ add_avp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_avp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: push_ds_2_avps

static inline int push_ds_2_avps( ds_dest_t *ds )
{
	char buf[2+16+1]; /* a hexa string */
	int_str avp_val;

	avp_val.s.len = 1 + sprintf( buf, "%p", ds->sock );
	avp_val.s.s = buf;
	if(add_avp(AVP_VAL_STR|sock_avp_type, sock_avp_name, avp_val)!=0) {
		LM_ERR("failed to add SOCK avp\n");
		return -1;
	}

	avp_val.s = ds->uri;
	if(add_avp(AVP_VAL_STR|dst_avp_type, dst_avp_name, avp_val)!=0) {
		LM_ERR("failed to add DST avp\n");
		return -1;
	}

	if (attrs_avp_name >= 0) {
		avp_val.s = ds->attrs;
		if(add_avp(AVP_VAL_STR|attrs_avp_type,attrs_avp_name,avp_val)!=0) {
			LM_ERR("failed to add ATTR avp\n");
			return -1;
		}
	}
	return 0;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:27,代码来源:dispatch.c


示例2: ospSetIdentity

/*
 * Set Identity header
 * param trans Transaction handle
 * return 0 success, -1 failure
 */
static int ospSetIdentity(
    OSPTTRANHANDLE trans)
{
    char encoded[OSP_SIGNBUF_SIZE];
    unsigned encodedsize = sizeof(encoded);
    unsigned char sign[OSP_SIGNBUF_SIZE];
    unsigned signsize = sizeof(sign);
    char alg[OSP_ALGBUF_SIZE];
    char info[OSP_STRBUF_SIZE];
    char type[OSP_STRBUF_SIZE];
    unsigned char canon[OSP_STRBUF_SIZE];
    unsigned canonsize = sizeof(canon);
    str value;
    int result = -1;

    if (OSPPTransactionGetIdentity(trans, &signsize, sign, sizeof(alg), alg, sizeof(info), info, sizeof(type), type, &canonsize, canon) == OSPC_ERR_NO_ERROR) {
        if (signsize != 0) {
            if (OSPPBase64Encode(sign, signsize, (unsigned char*)encoded, &encodedsize) == OSPC_ERR_NO_ERROR) {
                value.s = encoded;
                value.len = encodedsize;
                add_avp(_osp_idsign_avptype | AVP_VAL_STR, _osp_idsign_avpid, (int_str)value);
            }
        }

        if (alg[0] != '\0') {
            value.s = alg;
            value.len = strlen(alg);
            add_avp(_osp_idalg_avptype | AVP_VAL_STR, _osp_idalg_avpid, (int_str)value);
        }

        if (info[0] != '\0') {
            value.s = info;
            value.len = strlen(info);
            add_avp(_osp_idinfo_avptype | AVP_VAL_STR, _osp_idinfo_avpid, (int_str)value);
        }

        if (type[0] != '\0') {
            value.s = type;
            value.len = strlen(type);
            add_avp(_osp_idtype_avptype | AVP_VAL_STR, _osp_idtype_avpid, (int_str)value);
        }

        if (canonsize != 0) {
            if (OSPPBase64Encode(canon, canonsize, (unsigned char*)encoded, &encodedsize) == OSPC_ERR_NO_ERROR) {
                value.s = encoded;
                value.len = encodedsize;
                add_avp(_osp_idcanon_avptype | AVP_VAL_STR, _osp_idcanon_avpid, (int_str)value);
            }
        }

        result = 0;
    } 

    return result;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:60,代码来源:orig_transaction.c


示例3: mt_add_tvalues

int mt_add_tvalues(struct sip_msg *msg, m_tree_t *pt, str *tomatch)
{
	int l;
	mt_node_t *itn;
	int_str val, values_avp_name;
	unsigned short values_name_type;
	mt_is_t *tvalues;

	if (pt == NULL || tomatch == NULL || tomatch->s == NULL) {
		LM_ERR("bad parameters\n");
		return -1;
	}

	if (pv_get_avp_name(msg, &pv_values.pvp, &values_avp_name,
				&values_name_type) < 0) {
		LM_ERR("cannot get values avp name\n");
		return -1;
	}

	l = 0;
	itn = pt->head;

	while (itn != NULL && l < tomatch->len && l < MT_MAX_DEPTH) {
		/* check validity */
		if(_mt_char_table[(unsigned int)tomatch->s[l]]==255) {
			LM_ERR("invalid char at %d in [%.*s]\n",
					l, tomatch->len, tomatch->s);
			return -1;
		}
		tvalues = itn[_mt_char_table[(unsigned int)tomatch->s[l]]].tvalues;
		while (tvalues != NULL) {
			if (pt->type == MT_TREE_IVAL) {
				val.n = tvalues->tvalue.n;
				LM_DBG("adding avp <%.*s> with value <i:%d>\n",
						values_avp_name.s.len, values_avp_name.s.s, val.n);
				add_avp(values_name_type, values_avp_name, val);
			} else {  /* pt->type == MT_TREE_SVAL */
				val.s = tvalues->tvalue.s;
				LM_DBG("adding avp <%.*s> with value <s:%.*s>\n",
						values_avp_name.s.len, values_avp_name.s.s, val.s.len,
						val.s.s);
				add_avp(values_name_type|AVP_VAL_STR, values_avp_name, val);
			}
			tvalues = tvalues->next;
		}

		itn = itn[_mt_char_table[(unsigned int)tomatch->s[l]]].child;
		l++;	
	}

	return 0;
}
开发者ID:tsudot,项目名称:kamailio,代码行数:52,代码来源:mtree.c


示例4: stack_to_avp

static void stack_to_avp(struct avp_stack *stack) {
	int j;
	int  avp_att;
	int_str  avp_val;

	for(j=0; j< stack->i; j++) {
		/* AVP names can be integer or string based */
		LM_DBG("process AVP: name='%s' value='%s'\n", 
					stack->avp[j].att, stack->avp[j].val);

		/* we will only use string avps
		 * so all names are strings */
		avp_val.s.s = stack->avp[j].att;
		avp_val.s.len = strlen(avp_val.s.s);

		avp_att = get_avp_id(&avp_val.s);
		if (avp_att < 0) {
			LM_ERR("cannot find %s avp\n", avp_val.s.s);
			continue;
		}
		LM_DBG("create string named AVP <s:%.*s>\n", 
				avp_val.s.len, ZSW(avp_val.s.s));

		avp_val.s.s = stack->avp[j].val; 
		avp_val.s.len = strlen(avp_val.s.s);

		/* string type explicitely forced with s: */
		if(add_avp(AVP_VAL_STR, avp_att, avp_val))
			LM_ERR("cannot add avp\n");
	}
}
开发者ID:UIKit0,项目名称:OpenSIPS,代码行数:31,代码来源:domainpolicy.c


示例5: match_hash_table

/* 
 * Check if an entry exists in hash table that has given src_ip and protocol
 * value and pattern that matches to From URI.  If an entry exists and tag_avp
 * has been defined, tag of the entry is added as a value to tag_avp.
 * Returns number of matches or -1 if none matched.
 */
int match_hash_table(struct trusted_list** table, struct sip_msg* msg,
		char *src_ip_c_str, int proto)
{
	str uri;
	char uri_string[MAX_URI_SIZE + 1];
	regex_t preg;
	struct trusted_list *np;
	str src_ip;
	int_str val;
	int count = 0;

	src_ip.s = src_ip_c_str;
	src_ip.len = strlen(src_ip.s);

	if (IS_SIP(msg))
	{
		if (parse_from_header(msg) < 0) return -1;
		uri = get_from(msg)->uri;
		if (uri.len > MAX_URI_SIZE) {
			LM_ERR("from URI too large\n");
			return -1;
		}
		memcpy(uri_string, uri.s, uri.len);
		uri_string[uri.len] = (char)0;
	}

	for (np = table[perm_hash(src_ip)]; np != NULL; np = np->next) {
	    if ((np->src_ip.len == src_ip.len) && 
		(strncmp(np->src_ip.s, src_ip.s, src_ip.len) == 0) &&
		((np->proto == PROTO_NONE) || (proto == PROTO_NONE) ||
		 (np->proto == proto))) {
		if (np->pattern && IS_SIP(msg)) {
		    if (regcomp(&preg, np->pattern, REG_NOSUB)) {
			LM_ERR("invalid regular expression\n");
			continue;
		    }
		    if (regexec(&preg, uri_string, 0, (regmatch_t *)0, 0)) {
			regfree(&preg);
			continue;
		    }
		    regfree(&preg);
		}
		/* Found a match */
		if (tag_avp.n && np->tag.s) {
		    val.s = np->tag;
		    if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
			LM_ERR("setting of tag_avp failed\n");
			return -1;
		    }
		}
		if (!peer_tag_mode)
		    return 1;
		count++;
	    }
	}
	if (!count)
	    return -1;
	else 
	    return count;
}
开发者ID:mattvv,项目名称:kamailio,代码行数:66,代码来源:hash.c


示例6: set_next_domain_on_rule

/**
 * writes the next_domain avp using the rule list of route_tree
 *
 * @param failure_tree the current failure routing tree node
 * @param host last tried host
 * @param reply_code the last reply code
 * @param flags flags for the failure route rule
 * @param dstavp the name of the AVP where to store the next domain
 *
 * @return 0 on success, -1 on failure
 */
static int set_next_domain_on_rule(const struct failure_route_tree_item *failure_tree,
		const str *host, const str *reply_code, const flag_t flags,
		const struct multiparam_t *dstavp) {
	struct failure_route_rule * rr;
	int_str avp_val;
	
	assert(failure_tree != NULL);
	
	LM_DBG("searching for matching routing rules");
	for (rr = failure_tree->rule_list; rr != NULL; rr = rr->next) {
		/*
		LM_DBG("rr.flags=%d rr.mask=%d flags=%d\n", rr->flags, rr->mask, flags);
		LM_DBG("rr.host.len=%d host.len=%d\n", rr->host.len, host->len);
		LM_DBG("rr.host.s='%.*s' host.s='%.*s'\n", rr->host.len, rr->host.s, host->len, host->s);
		LM_DBG("rr.reply_code.len=%d reply_code.len=%d\n", rr->reply_code.len, reply_code->len);
		LM_DBG("rr.reply_code.s='%.*s' reply_code.s='%.*s'\n", rr->reply_code.len, rr->reply_code.s, reply_code->len, reply_code->s);
		*/
		if (((rr->mask & flags) == rr->flags) &&
				((rr->host.len == 0) || (str_strcmp(host, &rr->host)==0)) &&
				(reply_code_matcher(&(rr->reply_code), reply_code)==0)) {
			avp_val.n = rr->next_domain;
			if (add_avp(dstavp->u.a.flags, dstavp->u.a.name, avp_val)<0) {
				LM_ERR("set AVP failed\n");
				return -1;
			}
			
			LM_INFO("next_domain is %d.\n", rr->next_domain);
			return 0;
		}
	}
	
	return -1;
}
开发者ID:UIKit0,项目名称:OpenSIPS,代码行数:44,代码来源:route_func.c


示例7: match_domain_name_table

/*
 * Check if an entry exists in hash table that has given group, domain_name, and
 * port.  Port 0 in hash table matches any port.
 */
int match_domain_name_table(struct domain_name_list** table, unsigned int group,
		str *domain_name, unsigned int port)
{
	struct domain_name_list *np;
	avp_value_t val;

	for (np = table[perm_hash(*domain_name)]; np != NULL; np = np->next) {
		if ( (np->grp == group)
				&& ((np->port == 0) || (np->port == port))
				&& np->domain.len == domain_name->len
				&& strncmp(np->domain.s, domain_name->s, domain_name->len)==0 ) {

			if (tag_avp.n && np->tag.s) {
				val.s = np->tag;
				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
					LM_ERR("setting of tag_avp failed\n");
					return -1;
				}
			}

			return 1;
		}
	}

	return -1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:30,代码来源:hash.c


示例8: cr_load_user_carrier

/**
 * Loads user carrier from subscriber table and stores it in an AVP.
 *
 * @param _msg the current SIP message
 * @param _user the user to determine the carrier data
 * @param _domain the domain to determine the domain data
 * @param _dstavp the name of the AVP where to store the carrier id
 *
 * @return 1 on success, -1 on failure
 */
int cr_load_user_carrier(struct sip_msg * _msg, gparam_t *_user, gparam_t *_domain, gparam_t *_dstavp) {
	str user, domain;
	int_str avp_val;
	
	if (fixup_get_svalue(_msg, _user, &user)<0) {
		LM_ERR("cannot print the user\n");
		return -1;
	}

	if (fixup_get_svalue(_msg, _domain, &domain)<0) {
		LM_ERR("cannot print the domain\n");
		return -1;
	}
	/* get carrier id */
	if ((avp_val.n = load_user_carrier(&user, &domain)) < 0) {
		LM_ERR("error in load user carrier");
		return -1;
	} else {
		/* set avp */
		if (add_avp(_dstavp->v.pve->spec->pvp.pvn.u.isname.type,
					_dstavp->v.pve->spec->pvp.pvn.u.isname.name, avp_val)<0) {
			LM_ERR("add AVP failed\n");
			return -1;
		}
	}
	return 1;
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:37,代码来源:cr_func.c


示例9: find_group_in_addr_hash_table

/*
 * Check if an ip_addr/port entry exists in hash table in any group.
 * Returns first group in which ip_addr/port is found.
 * Port 0 in hash table matches any port.
 */
int find_group_in_addr_hash_table(struct addr_list** table,
		ip_addr_t *addr, unsigned int port)
{
	struct addr_list *np;
	str addr_str;
	avp_value_t val;

	addr_str.s = (char*)addr->u.addr;
	addr_str.len = 4;

	for (np = table[perm_hash(addr_str)]; np != NULL; np = np->next) {
		if (((np->port == 0) || (np->port == port))
				&& ip_addr_cmp(&np->addr, addr)) {

			if (tag_avp.n && np->tag.s) {
				val.s = np->tag;
				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
					LM_ERR("setting of tag_avp failed\n");
					return -1;
				}
			}

			return np->grp;
		}
	}

	return -1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:33,代码来源:hash.c


示例10: w_get_profile_size

static int w_get_profile_size(struct sip_msg *msg, char *profile, 
													char *value, char *result)
{
	pv_elem_t *pve;
	str val_s;
	pv_spec_t *sp_dest;
	unsigned int size;
	int_str res;
	int avp_name;
	unsigned short avp_type;
	script_var_t * sc_var;

	pve = (pv_elem_t *)value;
	sp_dest = (pv_spec_t *)result;

	if ( pve!=NULL && ((struct dlg_profile_table*)profile)->has_value) {
		if ( pv_printf_s(msg, pve, &val_s)!=0 || 
		val_s.len == 0 || val_s.s == NULL) {
			LM_WARN("cannot get string for value\n");
			return -1;
		}
		size = get_profile_size( (struct dlg_profile_table*)profile ,&val_s );
	} else {
		size = get_profile_size( (struct dlg_profile_table*)profile, NULL );
	}

	switch (sp_dest->type) {
		case PVT_AVP:
			if (pv_get_avp_name( msg, &(sp_dest->pvp), &avp_name,
			&avp_type)!=0){
				LM_CRIT("BUG in getting AVP name\n");
				return -1;
			}
			res.n = size;
			if (add_avp(avp_type, avp_name, res)<0){
				LM_ERR("cannot add AVP\n");
				return -1;
			}
			break;

		case PVT_SCRIPTVAR:
			if(sp_dest->pvp.pvn.u.dname == 0){
				LM_ERR("cannot find svar name\n");
				return -1;
			}
			res.n = size;
			sc_var = (script_var_t *)sp_dest->pvp.pvn.u.dname;
			if(!set_var_value(sc_var, &res, 0)){
				LM_ERR("cannot set svar\n");
				return -1;
			}
			break;

		default:
			LM_CRIT("BUG: invalid pvar type\n");
			return -1;
	}

	return 1;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:60,代码来源:dialog.c


示例11: cr_load_user_carrier

/**
 * Loads user carrier from subscriber table and stores it in an AVP.
 *
 * @param _msg the current SIP message
 * @param _user the user to determine the route tree
 * @param _domain the domain to determine the route tree
 * @param _dstavp the name of the AVP where to store the carrier tree id
 *
 * @return 1 on success, -1 on failure
 */
int cr_load_user_carrier(struct sip_msg * _msg, pv_elem_t *_user, pv_elem_t *_domain, struct multiparam_t *_dstavp) {
	str user;
	str domain;
	int_str avp_val;
	
	if (pv_printf_s(_msg, _user, &user)<0)	{
		LM_ERR("cannot print the user\n");
		return -1;
	}

	if (pv_printf_s(_msg, _domain, &domain)<0)	{
		LM_ERR("cannot print the domain\n");
		return -1;
	}
	
	/* get carrier id */
	if ((avp_val.n = load_user_carrier(&user, &domain)) < 0) {
		LM_ERR("error in load user carrier");
		return -1;
	}
	else {
		/* set avp ! */
		if (add_avp(_dstavp->u.a.flags, _dstavp->u.a.name, avp_val)<0) {
			LM_ERR("add AVP failed\n");
			return -1;
		}
	}
	return 1;
}
开发者ID:UIKit0,项目名称:OpenSIPS,代码行数:39,代码来源:route_func.c


示例12: generate_avps

/*
 * Generate AVPs from the database result
 */
static int generate_avps(VALUE_PAIR* received)
{
	str name_str, val_str;
	int_str name, val;
	VALUE_PAIR *vp;

	vp = received;

	while ((vp = rc_avpair_get(vp, attrs[A_SIP_AVP].v, 0))) {
		attr_name_value(vp, &name_str, &val_str);
		
		name.s = name_str;
		val.s = val_str;
		if (add_avp(AVP_NAME_STR | AVP_VAL_STR, name, val) < 0) {
			LM_ERR("failed to create a new AVP\n");
		} else {
			LM_DBG("AVP '%.*s'='%.*s' has been added\n",
			    name_str.len, ZSW(name_str.s), 
			    val_str.len, ZSW(val_str.s));
		}
		vp = vp->next;
	}
	
	return 0;
}
开发者ID:Drooids,项目名称:openser-xmlrpc,代码行数:28,代码来源:checks.c


示例13: l_siplua_AVP_set

static int l_siplua_AVP_set(lua_State *L)
{
  int name;
  int_str val;
  str s;
  int retval;
  int flags = 0;

  luaL_checkany(L, 1);
  luaL_checkany(L, 2);
  s.s = (char *) lua_tostring(L, 1);
  s.len = strlen(s.s);
  name = get_avp_id(&s);
  if (lua_type(L, 2) == LUA_TNUMBER)
    val.n = luaL_checkinteger(L, 2);
  else
    {
      val.s.s = (char *)luaL_checkstring(L, 2);
      val.s.len = strlen(val.s.s);
      flags |= AVP_VAL_STR;
    }
  retval = add_avp(flags, name, val);
  if (!retval)
    lua_pushboolean(L, 1);
  else
    lua_pushnil(L);
  return 1;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:28,代码来源:sipapi.c


示例14: generate_avps

/*
 * Generate AVPs from the database result
 */
static int generate_avps(VALUE_PAIR* received)
{
	int_str name, val;
	unsigned short flags;
	VALUE_PAIR *vp;

	LM_DBG("getting AVPs from RADIUS Reply\n");
	vp = received;
	if ( ! ar_radius_avps_mode )
		vp=rc_avpair_get(vp,attrs[A_SIP_AVP].v,0);
	for( ; vp; vp=((ar_radius_avps_mode)?vp->next:rc_avpair_get(vp->next,attrs[A_SIP_AVP].v,0)) ) {
		flags = 0;
		if (!extract_avp( vp, &flags, &name, &val)){
			LM_ERR("error while extracting AVP '%.*s'\n",(int)strlen(vp->name),vp->name);
			continue;
		}
		if (add_avp( flags, name, val) < 0) {
			LM_ERR("unable to create a new AVP\n");
		} else {
			LM_DBG("AVP '%.*s'/%d='%.*s'/%d has been added\n",
				(flags&AVP_NAME_STR)?name.s.len:4,
				(flags&AVP_NAME_STR)?name.s.s:"null",
				(flags&AVP_NAME_STR)?0:name.n,
				(flags&AVP_VAL_STR)?val.s.len:4,
				(flags&AVP_VAL_STR)?val.s.s:"null",
				(flags&AVP_VAL_STR)?0:val.n );
		}
	}

	return 0;
}
开发者ID:AndreiPlesa,项目名称:kamailio,代码行数:34,代码来源:sterman.c


示例15: generate_avps

/* Generate AVPs from Radius reply items */
static void generate_avps(struct attr *attrs, VALUE_PAIR* received)
{
    int_str name, val;
    unsigned short flags;
    VALUE_PAIR *vp;

    vp = received;

    for( ; (vp=rc_avpair_get(vp,attrs[SA_SIP_AVP].v,0)) ; vp=vp->next) {
	flags = 0;
	if (extract_avp( vp, &flags, &name, &val)!=0 )
	    continue;
	if (add_avp( flags, name, val) < 0) {
	    LM_ERR("unable to create a new AVP\n");
	} else {
	    LM_DBG("AVP '%.*s'/%d='%.*s'/%d has been added\n",
		   (flags&AVP_NAME_STR)?name.s.len:4,
		   (flags&AVP_NAME_STR)?name.s.s:"null",
		   (flags&AVP_NAME_STR)?0:name.n,
		   (flags&AVP_VAL_STR)?val.s.len:4,
		   (flags&AVP_VAL_STR)?val.s.s:"null",
		   (flags&AVP_VAL_STR)?0:val.n );
	}
    }
    
    return;
}
开发者ID:halan,项目名称:kamailio,代码行数:28,代码来源:functions.c


示例16: set_next_domain_on_rule

/**
 * writes the next_domain avp using the rule list of failure_tree
 *
 * @param frr_head the head of the failure route rule list
 * @param host last tried host
 * @param reply_code the last reply code
 * @param flags flags for the failure route rule
 * @param dstavp the name of the AVP where to store the next domain
 *
 * @return 0 on success, -1 on failure
 */
static int set_next_domain_on_rule(struct failure_route_rule *frr_head,
		const str *host, const str *reply_code, const flag_t flags,
		const gparam_t *dstavp) {
	struct failure_route_rule * rr;
	int_str avp_val;
	
	assert(frr_head != NULL);
	
	LM_DBG("searching for matching routing rules");
	for (rr = frr_head; rr != NULL; rr = rr->next) {
		/*
		LM_DBG("rr.flags=%d rr.mask=%d flags=%d\n", rr->flags, rr->mask, flags);
		LM_DBG("rr.host.len=%d host.len=%d\n", rr->host.len, host->len);
		LM_DBG("rr.host.s='%.*s' host.s='%.*s'\n", rr->host.len, rr->host.s, host->len, host->s);
		LM_DBG("rr.reply_code.len=%d reply_code.len=%d\n", rr->reply_code.len, reply_code->len);
		LM_DBG("rr.reply_code.s='%.*s' reply_code.s='%.*s'\n", rr->reply_code.len, rr->reply_code.s, reply_code->len, reply_code->s);
		*/
		if (((rr->mask & flags) == rr->flags) &&
				((rr->host.len == 0) || (str_strcmp(host, &rr->host)==0)) &&
				(reply_code_matcher(&(rr->reply_code), reply_code)==0)) {
			avp_val.n = rr->next_domain;
			if (add_avp(dstavp->v.pve->spec->pvp.pvn.u.isname.type,
					dstavp->v.pve->spec->pvp.pvn.u.isname.name, avp_val)<0) {
				LM_ERR("set AVP failed\n");
				return -1;
			}
			
			LM_INFO("next_domain is %d\n", rr->next_domain);
			return 0;
		}
	}
	
	LM_INFO("no matching rule for (flags=%d, host='%.*s', reply_code='%.*s') found\n", flags, host->len, host->s, reply_code->len, reply_code->s);
	return -1;
}
开发者ID:TheGrandWazoo,项目名称:kamailio,代码行数:46,代码来源:cr_func.c


示例17: find_group_in_subnet_table

/*
 * Check if an entry exists in subnet table that matches given ip_addr,
 * and port.  Port 0 in subnet table matches any port.  Return group of
 * first match or -1 if no match is found.
 */
int find_group_in_subnet_table(struct subnet* table,
		ip_addr_t *addr, unsigned int port)
{
	unsigned int count, i;
	avp_value_t val;

	count = table[PERM_MAX_SUBNETS].grp;

	i = 0;
	while (i < count) {
		if ( ((table[i].port == port) || (table[i].port == 0))
				&& (ip_addr_match_net(addr, &table[i].subnet, table[i].mask)==0))
		{
			if (tag_avp.n && table[i].tag.s) {
				val.s = table[i].tag;
				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
					LM_ERR("setting of tag_avp failed\n");
					return -1;
				}
			}
			return table[i].grp;
		}
		i++;
	}

	return -1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:32,代码来源:hash.c


示例18: ops_write_avp

int ops_write_avp(struct sip_msg* msg, struct fis_param *src,
													struct fis_param *ap)
{
	struct sip_uri uri;
	int_str avp_val;
	unsigned short flags;
	str s_ip;

	if (src->flags&AVPOPS_VAL_NONE)
	{
		if (src->flags&AVPOPS_USE_SRC_IP)
		{
			/* get data from src_ip */
			if ( (s_ip.s=ip_addr2a( &msg->rcv.src_ip ))==0)
			{
				LOG(L_ERR,"ERROR:avpops:write_avp: cannot get src_ip\n");
				goto error;
			}
			s_ip.len = strlen(s_ip.s);
			avp_val.s = &s_ip;
		} else {
			/* get data from uri (from,to,ruri) */
			if (src->flags&(AVPOPS_FLAG_USER|AVPOPS_FLAG_DOMAIN))
			{
				if (parse_source_uri( msg, src->flags, &uri)!=0 )
				{
					LOG(L_ERR,"ERROR:avpops:write_avp: cannot parse uri\n");
					goto error;
				}
				if (src->flags&AVPOPS_FLAG_DOMAIN)
					avp_val.s = &uri.host;
				else
					avp_val.s = &uri.user;
			} else {
				/* get whole uri */
				if ( (avp_val.s=get_source_uri(msg,src->flags))==0 )
				{
					LOG(L_ERR,"ERROR:avpops:write_avp: cannot get uri\n");
					goto error;
				}
			}
		}
		flags = AVP_VAL_STR;
	} else {
		avp_val = src->val;
		flags = (src->flags&AVPOPS_VAL_INT)?0:AVP_VAL_STR;
	}

	/* set the proper flag */
	flags |=  (ap->flags&AVPOPS_VAL_INT)?0:AVP_NAME_STR;

	/* added the avp */
	if (add_avp( flags, ap->val, avp_val)<0)
		goto error;

	return 1;
error:
	return -1;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:59,代码来源:avpops_impl.c


示例19: exec_getenv

int exec_getenv(struct sip_msg *msg, char *cmd, pvname_list_p avpl)
{
	int_str avp_val;
	int_str avp_name;
	unsigned short avp_type;
	int ret;
	str res;
	pvname_list_t* crt;

	/* pessimist: assume error by default */
	ret=-1;

	res.s=getenv(cmd);
	if (res.s==NULL)
	{
		goto error;
	}
	res.len=strlen(res.s);

	crt = avpl;

	avp_type = 0;
	if(crt==NULL)
	{
		avp_name.s.s = int2str(1, &avp_name.s.len);
		if (!avp_name.s.s) {
			LM_ERR("cannot convert 1 to string\n");
			goto error;
		}
		avp_name.n = get_avp_id(&avp_name.s);
		if (avp_name.n < 0) {
			LM_ERR("cannot get avp id\n");
			goto error;
		}
	} else {
		if(pv_get_avp_name(msg, &(crt->sname.pvp), &avp_name.n, &avp_type)!=0)
		{
			LM_ERR("can't get item name\n");
			goto error;
		}
	}

	avp_type |= AVP_VAL_STR;
	avp_val.s = res;

	if(add_avp(avp_type, avp_name.n, avp_val)!=0)
	{
		LM_ERR("unable to add avp\n");
		goto error;
	}

	/* success */
	ret=1;

error:
	return ret;
}
开发者ID:nikbyte,项目名称:opensips,代码行数:57,代码来源:exec.c


示例20: ospSetCalling

/*
 * Set calling number if translated
 * param msg SIP message
 * param dest Destination structure
 * return 0 success, 1 calling number same or not support calling number translation, -1 failure
 */
static int ospSetCalling(
    struct sip_msg* msg,
    osp_dest* dest)
{
    str rpid;
    int_str val;
    char calling[OSP_STRBUF_SIZE];
    char buffer[OSP_STRBUF_SIZE];
    int result;

    if (ospGetFromUserpart(msg, calling, sizeof(calling)) != 0) {
        LM_ERR("failed to extract calling number\n");
        result = -1;
    } else if (strcmp(calling, dest->calling) == 0) {
        LM_DBG("calling number does not been translated\n");
        result = 1;
    } else if (osp_auth.rpid_avp < 0) {
        LM_WARN("rpid_avp is not found, cannot set rpid avp\n");
        result = -1;
    } else {
        snprintf(buffer,
            sizeof(buffer),
            "\"%s\" <sip:%[email protected]%s>",
            dest->calling,
            dest->calling,
            dest->source);
        buffer[sizeof(buffer) - 1] = '\0';

        rpid.s = buffer;
        rpid.len = strlen(buffer);
        add_avp(osp_auth.rpid_avp_type | AVP_VAL_STR, osp_auth.rpid_avp, (int_str)rpid);

        result = 0;
    }

    if (result == 0) {
        val.n = 1;
    } else {
        val.n = 0;
    }
    add_avp(0, _osp_calling_avpid, val);

    return result;
}
开发者ID:ryzhov,项目名称:ATS0,代码行数:50,代码来源:orig_transaction.c



注:本文中的add_avp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ alcDestroyContext函数代码示例发布时间:2022-05-30
下一篇:
C++ __mempcpy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap