当前位置: 首页>>代码示例>>C++>>正文


C++ parse_rr函数代码示例

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


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

示例1: recordroute_diff

int recordroute_diff(struct sip_msg *req,struct sip_msg *resp)
{
   struct hdr_field *hf;
   rr_t *rr1;
   int i,j,k;
   i=j=k=0;
   /* count how many record-route bodies come in the response*/
   /* this does not work, I think because of siblings
   for(hf=resp->record_route;hf;hf=hf->sibling,j=0){
   */
   for(hf=resp->headers;hf;hf=hf->next,j=0){
      if(hf->type != HDR_RECORDROUTE_T)
	 continue;
      if(!hf->parsed){
	 if(0>parse_rr(hf))
	    goto error;
	 j=1;
      }
      for(rr1=hf->parsed;rr1;rr1=rr1->next){
	 i++;
      }
      if(j){
	 free_rr((rr_t**)(void*)&hf->parsed);
	 hf->parsed=NULL;
      }
   }
   /*
   for(hf=req->record_route;hf;hf=hf->sibling,j=0){
      */
   for(hf=req->headers;hf;hf=hf->next,j=0){
      if(hf->type != HDR_RECORDROUTE_T)
	 continue;
      if(!hf->parsed){
	 if(0>parse_rr(hf))
	    goto error;
	 j=1;
      }
      for(rr1=hf->parsed;rr1;rr1=rr1->next){
	 k++;
      }
      if(j){
	 free_rr((rr_t**)(void*)&hf->parsed);
	 hf->parsed=NULL;
      }
   }
   return i-k;
error:
   return -1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:49,代码来源:seas_action.c

示例2: cscf_get_first_p_associated_uri

/**
 * Returns the first entry of the P-Associated-URI header.
 * @param msg - the SIP message to look into
 * @param public_id - the public identity to be filled with the result
 * @returns 1 on success or 0 on failure
 */
int cscf_get_first_p_associated_uri(struct sip_msg *msg,str *public_id)
{
	struct hdr_field *h;
	rr_t *r;
	public_id->s=0;public_id->len=0;
	
	if (!msg) return 0;
	if (parse_headers(msg, HDR_EOH_F, 0)<0){
		LOG(L_ERR,"ERR:"M_NAME":cscf_get_p_associated_uri: error parsing headers\n");
		return 0;
	}
	h = msg->headers;
	while(h){
		if (h->name.len==16 && strncasecmp(h->name.s,"P-Associated-URI",16)==0)
			break;
		h = h->next;
	}
	if (!h){
		LOG(L_DBG,"DBG:"M_NAME":cscf_get_p_associated_uri: Header P-Associated-URI not found\n");
		return 0;
	}
	if (parse_rr(h)<0){
		LOG(L_ERR,"ERR:"M_NAME":cscf_get_p_associated_uri: Error parsing as Route header\n");
		return 0;
	}
	r = (rr_t*)h->parsed;
	h->type = HDR_ROUTE_T;
	
	if (r) {
		*public_id=r->nameaddr.uri;
		return 1;
	}
	else
		return 0;
}
开发者ID:Gaoithe,项目名称:openimscore_ims,代码行数:41,代码来源:sip.c

示例3: cscf_has_originating

/**
 * Finds if the message contains the orig parameter in the first Route header
 * @param msg - the SIP message
 * @param str1 - not used
 * @param str2 - not used
 * @returns #CSCF_RETURN_TRUE if yes, else #CSCF_RETURN_FALSE
 */
int cscf_has_originating(struct sip_msg *msg,char *str1,char *str2)
{
	//int ret=CSCF_RETURN_FALSE;
	struct hdr_field *h;
	str* uri;
	rr_t *r;

	if (parse_headers(msg, HDR_ROUTE_F, 0)<0){
		LM_DBG("I_originating: error parsing headers\n");
		return CSCF_RETURN_FALSE;
	}
	h = msg->route;
	if (!h){
		LM_DBG("I_originating: Header Route not found\n");
		return CSCF_RETURN_FALSE;
	}
	if (parse_rr(h)<0){
		LM_DBG("I_originating: Error parsing as Route header\n");
		return CSCF_RETURN_FALSE;
	}
	r = (rr_t*)h->parsed;

	uri = &r->nameaddr.uri;
	struct sip_uri puri;
	if (parse_uri(uri->s, uri->len, &puri) < 0) {
		LM_DBG( "I_originating: Error while parsing the first route URI\n");
		return -1;
	}
	if (puri.params.len < 4) return CSCF_RETURN_FALSE;
	int c = 0;
	int state = 0; 
	while (c < puri.params.len) {
		switch (puri.params.s[c]) {
		case 'o': if (state==0) state=1;
		break;
		case 'r': if (state==1) state=2;
		break;
		case 'i': if (state==2) state=3;
		break;
		case 'g': if (state==3) state=4;
		break;
		case ' ':
		case '\t':
		case '\r':
		case '\n':
		case ',':
		case ';':
			if (state==4) return CSCF_RETURN_TRUE;
			state=0;
			break;
		case '=': if (state==4) return CSCF_RETURN_TRUE;
		state=-1;
		break;
		default: state=-1;
		}
		c++;
	}

	return state==4 ? CSCF_RETURN_TRUE : CSCF_RETURN_FALSE;
}
开发者ID:AndreiPlesa,项目名称:kamailio,代码行数:67,代码来源:ims_getters.c

示例4: get_direction

static int get_direction(struct sip_msg* msg)
{
	int ret;
	if (parse_orig_ruri(msg) < 0) {
		return -1;
	}

	if (!msg->parsed_orig_ruri_ok) {
		ERR("Error while parsing original Request-URI\n");
		return -1;
	}

	ret = check_self(&msg->parsed_orig_ruri.host,
			 msg->parsed_orig_ruri.port_no ? msg->parsed_orig_ruri.port_no : SIP_PORT, 0);/* match all protos*/
	if (ret < 0) return -1;
	if (ret > 0) {
		     /* Route is in ruri */
		return check_ftag(msg, &msg->first_line.u.request.uri);
	} else {
		if (msg->route) {
			if (parse_rr(msg->route) < 0) {
				ERR("Error while parsing Route HF\n");
				return -1;
			}
		        ret = check_ftag(msg, &((rr_t*)msg->route->parsed)->nameaddr.uri);
			if (msg->route->parsed) free_rr((rr_t**)(void*)&msg->route->parsed);
			return ret;
		} else {
			DBG("No Route headers found\n");
			return -1;
		}
	}
}
开发者ID:SibghatullahSheikh,项目名称:kamailio,代码行数:33,代码来源:acc_radius.c

示例5: cscf_get_p_associated_uri

/**
 * Returns the content of the P-Associated-URI header
 * Public_id is pkg_alloced and should be later freed.
 * Inside values are not duplicated.
 * @param msg - the SIP message to look into
 * @param public_id - array to be allocated and filled with the result
 * @param public_id_cnt - the size of the public_id array
 * @param is_shm - msg from shared memory
 * @returns 1 on success or 0 on error
 */
int cscf_get_p_associated_uri(struct sip_msg *msg, str **public_id,
		int *public_id_cnt, int is_shm) {
	struct hdr_field *h;
	rr_t *r, *r2;
	*public_id = 0;
	*public_id_cnt = 0;

	if (!msg)
		return 0;
	if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
		LM_ERR("error parsing headers\n");
		return 0;
	}
	h = msg->headers;
	while (h) {
		if (h->name.len == 16
				&& strncasecmp(h->name.s, "P-Associated-URI", 16) == 0) {
			break;
		}
		h = h->next;
	}
	if (!h) {
		LM_DBG("Header P-Associated-URI not found\n");
		return 0;
	}
	if (parse_rr(h) < 0) {
		LM_DBG("Error parsing as Route header\n");
		return 0;
	}
	r = (rr_t*) h->parsed;
	h->type = HDR_ROUTE_T;
	*public_id_cnt = 0;
	r2 = r;
	while (r2) {
		(*public_id_cnt) = (*public_id_cnt) + 1;
		r2 = r2->next;
	}
	*public_id = pkg_malloc(sizeof(str)*(*public_id_cnt));
	if (!public_id) {
		LM_ERR("Error out of pkg memory");
		return 0;
	}
	r2 = r;
	*public_id_cnt = 0;
	while (r2) {
		(*public_id)[(*public_id_cnt)] = r2->nameaddr.uri;
		(*public_id_cnt) = (*public_id_cnt) + 1;
		r2 = r2->next;
	}

	if (is_shm) {
		r = (rr_t*) h->parsed;
		h->parsed = 0;
		free_rr(&r);
	}

	return 1;
}
开发者ID:AndreiPlesa,项目名称:kamailio,代码行数:68,代码来源:ims_getters.c

示例6: th_mask_record_route

int th_mask_record_route(sip_msg_t *msg)
{
	hdr_field_t *hdr;
	struct lump* l;
	int i;
	rr_t *rr;
	str out;

	if(msg->record_route==NULL)
	{
		LM_DBG("no record route header\n");
		return 0;
	}
	hdr = msg->record_route;
	i = 0;
	while(hdr!=NULL) 
	{
		if (parse_rr(hdr) < 0) 
		{
			LM_ERR("failed to parse RR\n");
			return -1;
		}

		rr =(rr_t*)hdr->parsed;
		while(rr)
		{
			i++;
			if(i!=1)
			{
				out.s = th_mask_encode(rr->nameaddr.uri.s, rr->nameaddr.uri.len,
						&th_uri_prefix, &out.len);
				if(out.s==NULL)
				{
					LM_ERR("cannot encode r-r %d\n", i);
					return -1;
				}
				l=del_lump(msg, rr->nameaddr.uri.s-msg->buf,
						rr->nameaddr.uri.len, 0);
				if (l==0)
				{
					LM_ERR("failed deleting r-r [%d]\n", i);
					pkg_free(out.s);
					return -1;
				}
				if (insert_new_lump_after(l, out.s, out.len, 0)==0){
					LM_ERR("could not insert new lump\n");
					pkg_free(out.s);
					return -1;
				}
			}
			rr = rr->next;
		}
		hdr = next_sibling_hdr(hdr);
	}

	return 0;
}
开发者ID:Jared-Prime,项目名称:kamailio,代码行数:57,代码来源:th_msg.c

示例7: cares_callback

static void cares_callback(void *arg, int status, unsigned char *abuf, int alen) {
	int i;
	unsigned int ancount, nscount, arcount;
	const unsigned char *aptr;

#ifdef DEBUG
	printf("cares_callback: status=%i, alen=%i\n", status, alen);
#endif
	if (status != ARES_SUCCESS) {
		if (verbose > 1)
			printf("ares failed: %s\n", ares_strerror(status));
		return;
	}

	ancount = DNS_HEADER_ANCOUNT(abuf);
	nscount = DNS_HEADER_NSCOUNT(abuf);
	arcount = DNS_HEADER_ARCOUNT(abuf);
	
#ifdef DEBUG
	printf("ancount: %i, nscount: %i, arcount: %i\n", ancount, nscount, arcount);
#endif

	/* safety check */
	if (alen < NS_HFIXEDSZ)
		return;
	aptr = abuf + NS_HFIXEDSZ;

	aptr = skip_query(aptr, abuf, alen);

	for (i = 0; i < ancount && caadr == 0; i++) {
		if (ca_tmpname == NULL)
			aptr = parse_rr(aptr, abuf, alen);
		else
			aptr = skip_rr(aptr, abuf, alen);
	}
	if (caadr == 0) {
		for (i = 0; i < nscount; i++) {
			aptr = skip_rr(aptr, abuf, alen);
		}
		for (i = 0; i < arcount && caadr == 0; i++) {
			aptr = parse_rr(aptr, abuf, alen);
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:sipsak-svn,代码行数:44,代码来源:helper.c

示例8: parse_rr_header

static int parse_rr_header(struct sip_msg *msg)
{
        if ( !msg->record_route && ( parse_headers(msg,HDR_RECORDROUTE_F,0) == -1)) {
                LM_ERR("bad msg or missing Record-Route header\n");
                return -1;
        }

	if (!msg->record_route) {
		LM_DBG("No Record-Route header field found\n");
		return -1;
	}

	return parse_rr(msg->record_route);
}
开发者ID:adubovikov,项目名称:kamailio,代码行数:14,代码来源:select_core.c

示例9: find_first_route

/*
 * Parse the message and find first occurrence of
 * Route header field. The function returns -1 or -2
 * on a parser error, 0 if there is a Route HF and
 * 1 if there is no Route HF.
 */
static inline int find_first_route(struct sip_msg* _m)
{
	if (parse_headers(_m, HDR_ROUTE_F, 0) == -1) {
		LOG(L_ERR, "find_first_route: Error while parsing headers\n");
		return -1;
	} else {
		if (_m->route) {
			if (parse_rr(_m->route) < 0) {
				LOG(L_ERR, "find_first_route: Error while parsing Route HF\n");
				return -2;
			}
			return 0;
		} else {
			DBG("find_first_route: No Route headers found\n");
			return 1;
		}
	}
}
开发者ID:Gaoithe,项目名称:openimscore_ims,代码行数:24,代码来源:loose.c

示例10: find_first_route

/*!
 * \brief Parse the message and find first occurrence of Route header field.
 * \param _m SIP message
 * \return -1 or -2 on a parser error, 0 if there is a Route HF and 1 if there is no Route HF
 */
static inline int find_first_route(struct sip_msg* _m)
{
    if (parse_headers(_m, HDR_ROUTE_F, 0) == -1) {
        LM_ERR("failed to parse headers\n");
        return -1;
    } else {
        if (_m->route) {
            if (parse_rr(_m->route) < 0) {
                LM_ERR("failed to parse Route HF\n");
                return -2;
            }
            return 0;
        } else {
            LM_DBG("No Route headers found\n");
            return 1;
        }
    }
}
开发者ID:Jared-Prime,项目名称:kamailio,代码行数:23,代码来源:loose.c

示例11: cscf_get_asserted_identity

/**
 * Looks for the P-Asserted-Identity header and extracts its content
 * @param msg - the sip message
 * @returns the asserted identity
 */
str cscf_get_asserted_identity(struct sip_msg *msg)
{
	name_addr_t id;
	struct hdr_field *h;
	rr_t *r;
	memset(&id,0,sizeof(name_addr_t));
	if (!msg) return id.uri;
	if (parse_headers(msg, HDR_EOH_F, 0)<0) {
		return id.uri;
	}
	h = msg->headers;
	while(h)
	{
		if (h->name.len == s_asserted_identity.len  &&
			strncasecmp(h->name.s,s_asserted_identity.s,s_asserted_identity.len)==0)
		{
			if (parse_rr(h)<0){
				//This might be an old client
				LOG(L_CRIT,"WARN:"M_NAME":cscf_get_asserted_identity: P-Asserted-Identity header must contain a Nameaddr!!! Fix the client!\n");
				id.name.s = h->body.s;
				id.name.len = 0;
				id.len = h->body.len;
				id.uri = h->body;
				while(id.uri.len && (id.uri.s[0]==' ' || id.uri.s[0]=='\t' || id.uri.s[0]=='<')){
					id.uri.s = id.uri.s+1;
					id.uri.len --;
				}
				while(id.uri.len && (id.uri.s[id.uri.len-1]==' ' || id.uri.s[id.uri.len-1]=='\t' || id.uri.s[id.uri.len-1]=='>')){
					id.uri.len--;
				}
				return id.uri;	
			}
			r = (rr_t*) h->parsed;
			id = r->nameaddr;			
			free_rr(&r);
			h->parsed=r;
			//LOG(L_RIT,"%.*s",id.uri.len,id.uri.s);
			return id.uri;
		}
		h = h->next;
	}
	return id.uri;
}
开发者ID:Gaoithe,项目名称:openimscore_ims,代码行数:48,代码来源:sip.c

示例12: tps_route_direction

int tps_route_direction(sip_msg_t *msg)
{
	rr_t *rr;
	struct sip_uri puri;
	str ftn = {"ftag", 4};
	str ftv = {0, 0};

	if(get_from(msg)->tag_value.len<=0)
	{
		LM_ERR("failed to get from header tag\n");
		return -1;
	}
	if(msg->route==NULL)
	{
		LM_DBG("no route header - downstream\n");
		return 0;
	}
	if (parse_rr(msg->route) < 0) 
	{
		LM_ERR("failed to parse route header\n");
		return -1;
	}

	rr =(rr_t*)msg->route->parsed;

	if (parse_uri(rr->nameaddr.uri.s, rr->nameaddr.uri.len, &puri) < 0) {
		LM_ERR("failed to parse the first route URI\n");
		return -1;
	}
	if(tps_get_param_value(&puri.params, &ftn, &ftv)!=0)
		return 0;

	if(get_from(msg)->tag_value.len!=ftv.len
			|| strncmp(get_from(msg)->tag_value.s, ftv.s, ftv.len)!=0)
	{
		LM_DBG("ftag mismatch\n");
		return 1;
	}
	LM_DBG("ftag match\n");
	return 0;
}
开发者ID:cloudvox,项目名称:kamailio,代码行数:41,代码来源:tps_msg.c

示例13: dump_rr

int 
dump_rr(struct iso_directory_record * idr){
	int len;
	char * pnt;

	len = idr->length[0] & 0xff;
	len -= (sizeof(struct iso_directory_record) - sizeof(idr->name));
	len -= idr->name_len[0];
	pnt = (char *) idr;
	pnt += (sizeof(struct iso_directory_record) - sizeof(idr->name));
	pnt += idr->name_len[0];

	if((idr->name_len[0] & 1) == 0){
		pnt++;
		len--;
	};

	rr_goof = 0;
	parse_rr(pnt, len, 0);
	return rr_goof;
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:21,代码来源:isovfy.c

示例14: get_route_set

/*
 * Create a copy of route set either in normal or reverse order
 */
static inline int get_route_set(struct sip_msg* _m, rr_t** _rs, unsigned char _order)
{
	struct hdr_field* ptr;
	rr_t* last, *p, *t;
	
	last = 0;

	ptr = _m->record_route;
	while(ptr) {
		if (ptr->type == HDR_RECORDROUTE_T) {
			if (parse_rr(ptr) < 0) {
				LOG(L_ERR, "get_route_set(): Error while parsing Record-Route body\n");
				goto error;
			}

			p = (rr_t*)ptr->parsed;
			if (shm_duplicate_rr(&t, p) < 0) {
				LOG(L_ERR, "get_route_set(): Error while duplicating rr_t\n");
				goto error;
			}
			if (!*_rs) *_rs = t;
			if (last) last->next = t;
			last = t;
			while (last->next) last = last->next; /* !!! there may be more routes in one hdr field !!! */

		}
		ptr = ptr->next;
	}
	if ((*_rs) && (_order != NORMAL_ORDER)) {
		/* better to revert the route outside of cycle above */
		*_rs = revert_route(*_rs);
	}
	
	return 0;

 error:
	shm_free_rr(_rs);
	return -1;
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:42,代码来源:dlg.c

示例15: isc_mark_get_from_msg

/**
 *	Retrieves the mark from message.
 *		- the marking should be in a header like described before
 *	@param msg - SIP mesage to mark
 *  @param mark - mark to load into
 *	@returns 1 if found, 0 if not
 */
int isc_mark_get_from_msg(struct sip_msg *msg, isc_mark *mark) {
	struct hdr_field *hdr;
	rr_t *rr;
	str x;
	LM_DBG("isc_mark_get_from_msg: Trying to get the mark from the message \n");

	memset(mark, 0, sizeof(isc_mark));

	parse_headers(msg, HDR_EOH_F, 0);
	hdr = msg->headers;
	while (hdr) {
		if (hdr->type == HDR_ROUTE_T) {
			if (!hdr->parsed) {
				if (parse_rr(hdr) < 0) {
					LM_ERR("isc_mark_get_from_msg: Error while parsing Route HF\n");
					hdr = hdr->next;
					continue;
				}
			}
			rr = (rr_t*) hdr->parsed;
			while (rr) {
				x = rr->nameaddr.uri;
				if (x.len >= ISC_MARK_USERNAME_LEN + 1 + isc_my_uri.len
						&& strncasecmp(x.s, ISC_MARK_USERNAME,
								ISC_MARK_USERNAME_LEN) == 0
						&& strncasecmp(x.s + ISC_MARK_USERNAME_LEN + 1,
								isc_my_uri.s, isc_my_uri.len) == 0) {
					LM_DBG("isc_mark_get_from_msg: Found <%.*s>\n",	x.len, x.s);
					isc_mark_get(x, mark);
					return 1;
				}
				rr = rr->next;
			}
		}
		hdr = hdr->next;
	}
	return 0;
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:45,代码来源:mark.c


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