Exemplo n.º 1
0
void
free_acl(void)
{
    ipset_done(&black_list_ipv4);
    ipset_done(&black_list_ipv6);
    ipset_done(&white_list_ipv4);
    ipset_done(&white_list_ipv6);

    free_rules(&black_list_rules);
    free_rules(&white_list_rules);
}
Exemplo n.º 2
0
void pp_knowledge_close(pp_knowledge *k)
{
  /* clear the memory taken up by k */
  xfree((void*)k->starting_link_lookup_table,
	((1+k->nStartingLinks)*sizeof(StartingLinkAndDomain)));
  free_link_sets(k);
  free_rules(k);
  pp_linkset_close(k->set_of_links_starting_bounded_domain);
  string_set_delete(k->string_set);
  pp_lexer_close(k->lt);
  xfree((void*)k, sizeof(pp_knowledge));
}
Exemplo n.º 3
0
void pp_knowledge_close(pp_knowledge *k)
{
  if (!k) return;
  /* clear the memory taken up by k */
  free(k->starting_link_lookup_table);
  free_link_sets(k);
  free_rules(k);
  pp_linkset_close(k->set_of_links_starting_bounded_domain);
  string_set_delete(k->string_set);
  if (NULL != k->lt) pp_lexer_close(k->lt);
  free(k);
}
Exemplo n.º 4
0
xmlNodePtr get_rule_node(subs_t* subs, xmlDocPtr xcap_tree)
{
	int action_value = -1, max_action_value = -1;
	char* sub_handling = NULL;
        xmlNodePtr node = NULL, actions_node = NULL, sub_handling_node = NULL;
        xcap_rule_t *rules = NULL, *rule_ptr = NULL;

        if (pres_rules_doc_id == OMA_PRES_RULES)
            oma_get_rules(subs, xcap_tree, &rules);
        else
            ietf_get_rules(subs, xcap_tree, &rules);
        if (rules == NULL)
                return NULL;

        for (rule_ptr = rules; rule_ptr; rule_ptr = rule_ptr->next)
        {
            actions_node = xmlNodeGetChildByName(rule_ptr->node, "actions");
            if(actions_node == NULL)
            {
                    LM_DBG("actions_node NULL\n");
                    continue;
            }

            sub_handling_node = xmlNodeGetChildByName(actions_node, "sub-handling");
            if(sub_handling_node == NULL)
            {
                    LM_DBG("sub_handling_node NULL\n");
		    xmlFree(sub_handling);
                    continue;
            }
            sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
            if(sub_handling == NULL)
            {
                    LM_ERR("Couldn't get sub-handling content\n");
                    continue;
            }
            LM_DBG("sub_handling_node->content= %s\n", sub_handling);

            action_value = get_action_value((char*)sub_handling);
            if (action_value > max_action_value)
            {
                    max_action_value = action_value;
                    node = rule_ptr->node;
            }
	    xmlFree(sub_handling);
        }

        free_rules(rules);
        return node;
}
Exemplo n.º 5
0
static void
rule_dealloc(ruleobject *xp)
{
	free_rules(xp->rule);
	PyObject_DEL(xp);
}
Exemplo n.º 6
0
static void oma_get_rules(subs_t* subs, xmlDocPtr xcap_tree, xcap_rule_t **rules)
{
	int apply_rule = 0, current_node_type = -1;
	str w_uri = {0, 0};
	xmlNodePtr ruleset_node = NULL, cond_node = NULL;
	xmlNodePtr node1 = NULL, node2 = NULL, current_node = NULL;
	xcap_rule_t *tmp_rule = NULL;
	xcap_rule_t *identity_rules = NULL, *external_rules = NULL, *anonymous_rules = NULL, *other_identity_rules = NULL;
	xcap_rule_t *identity_tail = NULL, *external_tail = NULL, *anonymous_tail = NULL, *other_identity_tail = NULL;

        *rules = NULL;

	uandd_to_uri(subs->from_user, subs->from_domain, &w_uri);
	if(w_uri.s == NULL)
	{
		LM_ERR("while creating uri\n");
		return;
	}

	ruleset_node = xmlDocGetNodeByName(xcap_tree, "ruleset", NULL);
	if(ruleset_node == NULL)
	{
		LM_ERR("ruleset_node not found\n");
		pkg_free(w_uri.s);
	        return;
	}

	for(node1 = ruleset_node->children; node1; node1 = node1->next)
	{
		if(xmlStrcasecmp(node1->name, (unsigned char*)"text")==0)
		        continue;

		cond_node = xmlNodeGetChildByName(node1, "conditions");
		if(cond_node == NULL)
		{
			LM_WARN("condition node not found\n");
			continue;
		}

                apply_rule = 0;
                current_node = node1;
                current_node_type = -1;

                for(node2 = cond_node->children; node2; node2 = node2->next)
                {
                        if(xmlStrcasecmp(node2->name, (unsigned char*)"identity") == 0)
                        {
                                current_node_type = IDENTITY_RULE;
                                apply_rule = oma_match_identity_condition(node2, subs, &w_uri);
                                break;
                        }
                        else if(xmlStrcasecmp(node2->name, (unsigned char*)"external-list") == 0)
                        {
                                current_node_type = EXTERNAL_LIST_RULE;
                                apply_rule = oma_match_external_list_condition(node2, subs, &w_uri);
                                break;
                        }
                        else if(xmlStrcasecmp(node2->name, (unsigned char*)"anonymous-request") == 0)
                        {
                                current_node_type = ANONYMOUS_REQUEST_RULE;
                                apply_rule = oma_match_anonymous_condition(node2, subs, &w_uri);
                                break;
                        }
                        else if(xmlStrcasecmp(node2->name, (unsigned char*)"other-identity") == 0)
                        {
                                current_node_type = OTHER_IDENTITY_RULE;
                                apply_rule = 1;
                                break;
                        }
                        else
                        {
                                /* unknown condition */
                                continue;
                        }

                }

                /* finished scanning all conditions for a given rule */
                if (apply_rule)
                {
                        tmp_rule = (xcap_rule_t *)pkg_malloc(sizeof(*tmp_rule));
                        if (tmp_rule == NULL)
                        {
                                LM_ERR("pkg mem\n");
                                goto error;
                        }
                        tmp_rule->node = current_node;
                        tmp_rule->next = NULL;
                        switch (current_node_type)
                        {
                                case IDENTITY_RULE:
                                        if(identity_rules == NULL)
                                                identity_rules = tmp_rule;
                                        else
                                                identity_tail->next = tmp_rule;
                                        identity_tail = tmp_rule;
                                        break;
                                case EXTERNAL_LIST_RULE:
                                        if(external_rules == NULL)
                                                external_rules = tmp_rule;
                                        else
                                                external_tail->next = tmp_rule;
                                        external_tail = tmp_rule;
                                        break;
                                case ANONYMOUS_REQUEST_RULE:
                                        if(anonymous_rules == NULL)
                                                anonymous_rules = tmp_rule;
                                        else
                                                anonymous_tail->next = tmp_rule;
                                        anonymous_tail = tmp_rule;
                                        break;
                                case OTHER_IDENTITY_RULE:
                                        if(other_identity_rules == NULL)
                                                other_identity_rules = tmp_rule;
                                        else
                                                other_identity_tail->next = tmp_rule;
                                        other_identity_tail = tmp_rule;
                                        break;
                                default:
                                        /* this will never happen */
                                        break;
                        }
                }
	}

        if (anonymous_rules)
        {
                *rules = anonymous_rules;
                free_rules(identity_rules);
                free_rules(external_rules);
                free_rules(other_identity_rules);
        }
        else if (identity_rules)
        {
                *rules = identity_rules;
                free_rules(external_rules);
                free_rules(anonymous_rules);
                free_rules(other_identity_rules);
        }
        else if (external_rules)
        {
                *rules = external_rules;
                free_rules(identity_rules);
                free_rules(anonymous_rules);
                free_rules(other_identity_rules);
        }
        else if (other_identity_rules)
        {
                *rules = other_identity_rules;
                free_rules(identity_rules);
                free_rules(external_rules);
                free_rules(anonymous_rules);
        }
        else
        {
                *rules = NULL;
                LM_DBG("no matching rules found\n");
        }

        pkg_free(w_uri.s);
        return;

error:
        if (w_uri.s)
                pkg_free(w_uri.s);
        free_rules(identity_rules);
        free_rules(external_rules);
        free_rules(anonymous_rules);
        free_rules(other_identity_rules);
}