Beispiel #1
0
int th_unmask_ruri(sip_msg_t *msg)
{
	str eval;
	struct lump* l;
	str out;

	if(th_get_uri_param_value(&REQ_LINE(msg).uri, &th_uparam_name, &eval)<0
			|| eval.len<=0)
		return -1;
	
	out.s = th_mask_decode(eval.s, eval.len,
				&th_uparam_prefix, 0, &out.len);
	if(out.s==NULL)
	{
		LM_ERR("cannot decode r-uri\n");
		return -1;
	}
					
	LM_DBG("+decoded: %d: [%.*s]\n", out.len, out.len, out.s);
	l=del_lump(msg, REQ_LINE(msg).uri.s-msg->buf, REQ_LINE(msg).uri.len, 0);
	if (l==0)
	{
		LM_ERR("failed deleting r-uri\n");
		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;
	}

	return 0;
}
Beispiel #2
0
int th_unmask_refer_to(sip_msg_t *msg)
{
	str eval;
	str *uri;
	int ulen;
	struct lump* l;
	str out;

	if(!((get_cseq(msg)->method_id)&(METHOD_REFER)))
		return 0;

	if(parse_refer_to_header(msg)==-1)
	{
		LM_DBG("no Refer-To header\n");
		return 0;
	}
	if(msg->refer_to==NULL || get_refer_to(msg)==NULL)
	{
		LM_DBG("Refer-To header not found\n");
		return 0;
	}

	uri = &(get_refer_to(msg)->uri);
	if(th_get_uri_param_value(uri, &th_uparam_name, &eval)<0
			|| eval.len<=0)
		return -1;

	out.s = th_mask_decode(eval.s, eval.len,
				&th_uparam_prefix, 0, &out.len);
	if(out.s==NULL)
	{
		LM_ERR("cannot decode r-uri\n");
		return -1;
	}

	LM_DBG("+decoded: %d: [%.*s]\n", out.len, out.len, out.s);
	for(ulen=0; ulen<uri->len; ulen++)
	{
		if(uri->s[ulen]=='?')
			break;
	}

	l=del_lump(msg, uri->s-msg->buf, ulen, 0);
	if (l==0)
	{
		LM_ERR("failed deleting r-uri\n");
		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;
	}

	return 0;
}
Beispiel #3
0
int th_unmask_ruri(sip_msg_t *msg)
{
	str eval;
	struct lump* l;
	str out;

	/* Do nothing if ruri is not encoded */
	if (th_uri_prefix_checks && ((REQ_LINE(msg).uri.len<th_uri_prefix.len) ||
			(strncasecmp(REQ_LINE(msg).uri.s, th_uri_prefix.s,
						th_uri_prefix.len)!=0)))
	{
		LM_DBG("ruri [%.*s] is not encoded",REQ_LINE(msg).uri.len,REQ_LINE(msg).uri.s);
		return 0;
	}

	if(th_get_uri_param_value(&REQ_LINE(msg).uri, &th_uparam_name, &eval)<0
			|| eval.len<=0) {
		LM_DBG("no uri param [%.*s] in [%.*s]\n",
				th_uparam_name.len, th_uparam_name.s,
				REQ_LINE(msg).uri.len,REQ_LINE(msg).uri.s);
		return -1;
	}

	out.s = th_mask_decode(eval.s, eval.len,
				&th_uparam_prefix, 0, &out.len);
	if(out.s==NULL)
	{
		LM_ERR("cannot decode r-uri [%.*s]\n",
				REQ_LINE(msg).uri.len,REQ_LINE(msg).uri.s);
		return -1;
	}

	LM_DBG("+decoded: %d: [%.*s]\n", out.len, out.len, out.s);
	l=del_lump(msg, REQ_LINE(msg).uri.s-msg->buf, REQ_LINE(msg).uri.len, 0);
	if (l==0)
	{
		LM_ERR("failed deleting r-uri\n");
		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;
	}

	return 0;
}
Beispiel #4
0
int th_unmask_route(sip_msg_t *msg)
{
	hdr_field_t *hdr;
	struct lump* l;
	int i;
	rr_t *rr;
	str out;
	str eval;

	if(msg->route==NULL)
	{
		LM_DBG("no record route header\n");
		return 0;
	}
	hdr = msg->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)
			{
				if(th_get_uri_param_value(&rr->nameaddr.uri, &th_uparam_name,
							&eval)<0 || eval.len<=0)
					return -1;
	
				out.s = th_mask_decode(eval.s, eval.len,
							&th_uparam_prefix, 0, &out.len);

				if(out.s==NULL)
				{
					LM_ERR("cannot decode 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 [%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;
}