Exemplo n.º 1
0
struct acc_extra *parse_acc_leg(char *extra_str)
{
	struct acc_extra *legs;
	struct acc_extra *it;
	int n;

	legs = parse_acc_extra(extra_str, 1);
	if (legs==0) {
		LM_ERR("failed to parse extra leg\n");
		return 0;
	}

	/* check the type and len */
	for( it=legs,n=0 ; it ; it=it->next ) {
		if (it->spec.type!=PVT_AVP) {
			LM_ERR("only AVP are accepted as leg info\n");
			destroy_extras(legs);
			return 0;
		}
		n++;
		if (n>MAX_ACC_LEG) {
			LM_ERR("too many leg info; MAX=%d\n", MAX_ACC_LEG);
			destroy_extras(legs);
			return 0;
		}
	}

	return legs;
}
Exemplo n.º 2
0
static void destroy(void)
{
    if (caller_extra) destroy_extras(caller_extra);
    if (callee_extra) destroy_extras(callee_extra);
    if (group_extra) destroy_extras(group_extra);
    if (uri_extra) destroy_extras(group_extra);
}
Exemplo n.º 3
0
static void destroy(void)
{
	if (log_extra)
		destroy_extras( log_extra);
#ifdef SQL_ACC
	acc_db_close();
	if (db_extra)
		destroy_extras( db_extra);
#endif
#ifdef DIAM_ACC
	close_tcp_connection(sockfd);
	if (dia_extra)
		destroy_extras( dia_extra);
#endif
}
Exemplo n.º 4
0
/* convert the facility-name string into a id and store it */
void destroy_cdr_generation( void)
{
    if( !cdr_extra)
    {
        return;
    }

    destroy_extras( cdr_extra);
}
Exemplo n.º 5
0
static void destroy(void)
{
    if (log_extra_tags)
        destroy_extras( log_extra_tags);
    if (log_leg_tags)
        destroy_extras( log_leg_tags);
    acc_db_close();
    if (db_extra_tags)
        destroy_extras( db_extra_tags);
    if (db_leg_tags)
        destroy_extras( db_leg_tags);

    if (aaa_extra_tags)
        destroy_extras( aaa_extra_tags);
    if (aaa_leg_tags)
        destroy_extras( aaa_leg_tags);

    if (evi_extra_tags)
        destroy_extras( evi_extra_tags);
    if (evi_leg_tags)
        destroy_extras( evi_leg_tags);
}
Exemplo n.º 6
0
struct acc_extra *parse_acc_extra(char *extra_str, int allow_reply)
{
	struct acc_extra *head;
	struct acc_extra *tail;
	struct acc_extra *extra;
	char *foo;
	char *s;
	int  n;
	str stmp;

	n = 0;
	head = 0;
	extra = 0;
	tail = 0;
	s = extra_str;

	if (s==0) {
		LM_ERR("null string received\n");
		goto error;
	}

	while (*s) {
		/* skip white spaces */
		while (*s && isspace((int)*s))  s++;
		if (*s==0)
			goto parse_error;
		if (n==MAX_ACC_EXTRA) {
			LM_ERR("too many extras -> please increase the internal buffer\n");
			goto error;
		}
		extra = (struct acc_extra*)pkg_malloc(sizeof(struct acc_extra));
		if (extra==0) {
			LM_ERR("no more pkg mem 1\n");
			goto error;
		}
		memset( extra, 0, sizeof(struct acc_extra));

		/* link the new extra at the end */
		if (tail==0) {
			head = extra;
		} else {
			tail->next = extra;
		}
		tail = extra;
		n++;

		/* get name */
		foo = s;
		while (*s && !isspace((int)*s) && EQUAL!=*s)  s++;
		if (*s==0)
			goto parse_error;
		if (*s==EQUAL) {
			extra->name.len = (s++) - foo;
		} else {
			extra->name.len = (s++) - foo;
			/* skip spaces */
			while (*s && isspace((int)*s))  s++;
			if (*s!=EQUAL)
				goto parse_error;
			s++;
		}
		extra->name.s = foo;

		/* skip spaces */
		while (*s && isspace((int)*s))  s++;

		/* get value type */
		stmp.s = s; stmp.len = strlen(s);
		if ( (foo=pv_parse_spec(&stmp, &extra->spec))==0 )
			goto parse_error;
		s = foo;

		/* skip spaces */
		while (*s && isspace((int)*s))  s++;

		/* type of message - request or reply ? */
		if (allow_reply && *s=='/') {
			s++;
			while (*s && isspace((int)*s))  s++;
			if (*s==0)
				goto parse_error;
			foo = s;
			while (*s && isalpha((int)*s))  s++;
			if (s-foo==REPLY_STR_LEN &&
			strncasecmp(foo,REPLY_STR_S,REPLY_STR_LEN)==0 ) {
				extra->use_rpl =1;
			} else {
				LM_ERR("unsupported marker <%.*s>\n",(unsigned int)(s-foo),foo);
				goto error;
			}
		}

		/* skip spaces */
		while (*s && isspace((int)*s))  s++;
		if (*s && (*(s++)!=SEPARATOR || *s==0))
			goto parse_error;
	}

	/* go throught all extras and make the names null terminated */
	for( extra=head ; extra ; extra=extra->next)
		extra->name.s[extra->name.len] = 0;

	return head;
parse_error:
	LM_ERR("parse failed in <%s> "
		"around position %d\n",extra_str, (int)(long)(s-extra_str));
error:
	LM_ERR("error\n");
	destroy_extras(head);
	return 0;
}