Beispiel #1
0
/**
 * limit checking with creation of pipe if it doesn't exist
 */
static int pl_check_limit(sip_msg_t* msg, str *pipeid, str *alg, int limit)
{
	pl_pipe_t *pipe = NULL;

	pipe = pl_pipe_get(pipeid, 1);
	if(pipe==NULL) {
		LM_DBG("pipe not found [%.*s] - trying to add it\n",
				pipeid->len, pipeid->s);
		if(pl_pipe_add(pipeid, alg, limit)<0) {
			LM_ERR("failed to add pipe [%.*s]\n",
				pipeid->len, pipeid->s);
			return -2;
		}
		pipe = pl_pipe_get(pipeid, 0);
		if(pipe==NULL) {
			LM_ERR("failed to retrieve pipe [%.*s]\n",
				pipeid->len, pipeid->s);
			return -2;
		}
	} else {
		if(limit>0) pipe->limit = limit;
		pl_pipe_release(&pipe->name);
	}

	return pl_check(msg, pipeid);
}
Beispiel #2
0
/**
 * limit checking with creation of pipe if it doesn't exist
 */
static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg,
		char *p3limit)
{
	int limit;
	str pipeid = {0, 0};
	str alg = {0, 0};
	pl_pipe_t *pipe = NULL;

	if(msg==NULL)
		return -1;

	if(fixup_get_ivalue(msg, (gparam_t*)p3limit, &limit)!=0 || limit<0)
	{
		LM_ERR("invalid limit value: %d\n", limit);
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_t*)p1pipe, &pipeid)!=0
			|| pipeid.s == 0)
	{
		LM_ERR("invalid pipeid parameter");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_t*)p2alg, &alg)!=0
			|| alg.s == 0)
	{
		LM_ERR("invalid algoritm parameter");
		return -1;
	}

	pipe = pl_pipe_get(&pipeid, 1);
	if(pipe==NULL)
	{
		LM_DBG("pipe not found [%.*s] - trying to add it\n",
				pipeid.len, pipeid.s);
		if(pl_pipe_add(&pipeid, &alg, limit)<0)
		{
			LM_ERR("failed to add pipe [%.*s]\n",
				pipeid.len, pipeid.s);
			return -2;
		}
		pipe = pl_pipe_get(&pipeid, 0);
		if(pipe==NULL)
		{
			LM_ERR("failed to retrieve pipe [%.*s]\n",
				pipeid.len, pipeid.s);
			return -2;
		}
	} else {
		if(limit>0) pipe->limit = limit;
		pl_pipe_release(&pipe->name);
	}

	return pl_check(msg, &pipeid);
}