Esempio n. 1
0
static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
{
	int val;
	str mf_value;

	val=is_maxfwd_present(msg, &mf_value);
	switch (val) {
		case -1:
			add_maxfwd_header( msg, (unsigned int)(unsigned long)str1 );
			break;
		case -2:
			break;
		case 0:
			return -1;
		default:
			if (max_limit && val>max_limit){
				DBG("DBG:maxfwd:process_maxfwd_header: "
					"value %d decreased to %d\n", val, max_limit);
				val = max_limit+1;
			}
			if ( decrement_maxfwd(msg, val, &mf_value)!=1 )
				LOG( L_ERR,"ERROR:maxfwd:process_maxfwd_header: "
					"decrement failed!\n");
	}
	return 1;
}
Esempio n. 2
0
static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
{
	int val;
	str mf_value;

	val=is_maxfwd_present(msg, &mf_value);
	switch (val) {
		/* header not found */
		case -1:
			if (add_maxfwd_header( msg, (unsigned int)(unsigned long)str1)!=0)
				goto error;
			return 2;
		/* error */
		case -2:
			goto error;
		/* found */
		case 0:
			return -1;
		default:
			if (val>max_limit){
				LM_DBG("value %d decreased to %d\n", val, max_limit);
				val = max_limit+1;
			}
			if ( decrement_maxfwd(msg, val, &mf_value)!=0 ) {
				LM_ERR("decrement failed!\n");
				goto error;
			}
	}

	return 1;
error:
	return -2;
}
Esempio n. 3
0
/* check if the current Max Forwards value is below a certain threshold */
static int w_process_maxfwd_lowlimit(struct sip_msg* msg, char* str1,char* str2)
{
	int val, lowlimit;
	str mf_value;

	val=is_maxfwd_present(msg, &mf_value);
	lowlimit = (unsigned int) (unsigned long) str1;

	DBG("maxfwd: lowlimit=%d current=%d\n", lowlimit, val);

	if ((val >= 0) && (val < lowlimit))
		return -1;	/* limit reached */
	else
		return 1;
}
Esempio n. 4
0
static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
{
	str mf_value;
	int limit;
	int val;

	limit = (int)(long)slimit;
	val = is_maxfwd_present( msg, &mf_value);
	LM_DBG("value = %d \n",val);

	if ( val<0 ) {
		/* error or not found */
		return val-1;
	} else if ( val>=limit ) {
		/* greater or equal than/to limit */
		return -1;
	}

	return 1;
}