Пример #1
0
int
handle_mapping_start(struct streamstate* stp)
{
    stp->curmap = new_mapping(stp, stp->curmap);
    if (! stp->curmap)
        return 1;

    struct keyvalue* kv = stp->curkv;
    if (kv) 
    {
        /*
         * this mapping is the value for the current keyvalue
         */
        kv->type      = KV_MAPPING;
        kv->map       = stp->curmap;
        kv->valuemark = stp->event.start_mark;
        stp->curkv = NULL;
    } 
    else 
    {
        /*
         * this mapping is the top level document.
         */
        if (! stp->document)
            stp->document = stp->curmap;
    }
    return 0;
}
Compartment_Report_Mapping_Ptr 
Compartment_Report_Binary_File_Reader::update_mapping
(const Cell_Target & new_cell_target)
{
    Compartment_Report_Mapping_Ptr new_mapping(new Compartment_Report_Mapping);
    _parser.cell_target(new_cell_target); 
    (*new_mapping) = _parser.mapping();
    return new_mapping;
}
Пример #3
0
void Faction::setDisposition(Faction* f, disposition d) {
	disposition disp_original = getDisposition(f);
	if (disp_by_fac.count(f)) {
		//previously mapped:
		disp_by_fac[f] = d;
		auto fac_l_o = fac_by_disp[disp_original];
		fac_l_o.erase(f);
	} else {
		//not previously mapped:
		std::pair<Faction*, disposition> new_mapping(f, d);
		disp_by_fac.insert(new_mapping);
		//update fac_by_disp:
	}
	auto fac_l_n = fac_by_disp[d];
	fac_l_n.insert(f);
}
Пример #4
0
/*
 * Generates a mapping with the local extended info
 */
lispd_mapping_elt *new_local_mapping(
        lisp_addr_t     eid_prefix,
        uint8_t         eid_prefix_length,
        int             iid)
{
    lispd_mapping_elt           *mapping        = NULL;

    if ((mapping = new_mapping (eid_prefix, eid_prefix_length, iid)) == NULL){
        return (NULL);
    }

    mapping->mapping_type = LOCAL_MAPPING;
    mapping->extended_info = (void *)new_lcl_mapping_extended_info();
    if (mapping->extended_info == NULL){
        free_mapping_elt(mapping);
        return (NULL);
    }
    return (mapping);
}
Пример #5
0
/*
 * Generates a clone of a lispd_mapping_elt. Parameters like timers or nonces are not cloned
 */
lispd_mapping_elt *copy_mapping_elt(lispd_mapping_elt *elt)
{
    lispd_mapping_elt *mapping = NULL;
    mapping = new_mapping(elt->eid_prefix,elt->eid_prefix_length,elt->iid);
    if (mapping == NULL){
        return (NULL);
    }
    mapping->locator_count = elt->locator_count;
    if (elt->head_v4_locators_list != NULL){
        mapping->head_v4_locators_list = copy_locators_list(elt->head_v4_locators_list);
        if (mapping->head_v4_locators_list == NULL){
            free_mapping_elt(mapping);
            return (NULL);
        }
    }
    if(elt->head_v6_locators_list != NULL){
        mapping->head_v6_locators_list = copy_locators_list(elt->head_v6_locators_list);
        if (mapping->head_v6_locators_list == NULL){
            free_mapping_elt(mapping);
            return(NULL);
        }
    }
    if (elt->extended_info != NULL){
        if (mapping->mapping_type == LOCAL_MAPPING){
            mapping->extended_info = (void *)copy_lcl_mapping_extended_info((lcl_mapping_extended_info *)elt->extended_info);
            if (mapping->extended_info == NULL){
                free_mapping_elt(mapping);
                return(NULL);
            }
            calculate_balancing_vectors (mapping,&(((lcl_mapping_extended_info *)mapping->extended_info)->outgoing_balancing_locators_vecs));
        }else{
            mapping->extended_info = (void *)copy_rmt_mapping_extended_info((rmt_mapping_extended_info *)elt->extended_info);
            if (mapping->extended_info == NULL){
                free_mapping_elt(mapping);
                return(NULL);
            }
            calculate_balancing_vectors (mapping,&(((rmt_mapping_extended_info *)mapping->extended_info)->rmt_balancing_locators_vecs));
        }
    }

    return (mapping);
}
Пример #6
0
int process_map_referral_record(
        uint8_t **offset,
        uint64_t nonce)
{
    uint8_t                                 *cur_ptr                    = NULL;
    lispd_pkt_referral_mapping_record_t     *record                     = NULL;
    lispd_referral_cache_entry              *referral_entry             = NULL;
    lispd_referral_cache_entry              *previous_referral_entry    = NULL;
    lispd_mapping_elt                       *referral_mapping           = NULL;
    lispd_pending_referral_cache_entry      *pending_referral_entry     = NULL;
    lispd_map_cache_entry                   *map_cache_entry            = NULL;
    lisp_addr_t                             ddt_node_locator_addr       = {.afi=AF_UNSPEC};
    lisp_addr_t                             aux_eid_prefix;
    int                                     aux_eid_prefix_length       = 0;
    int                                     aux_iid                     = 0;
    int                                     ctr                         = 0;
    int                                     result                      = GOOD;
    int                                     detected_loop               = FALSE;

    cur_ptr = *offset;

    record = (lispd_pkt_referral_mapping_record_t *)(cur_ptr);


    pending_referral_entry = lookup_pending_referral_cache_entry_by_nonce (nonce);

    if (pending_referral_entry == NULL){
        lispd_log_msg(LISP_LOG_DEBUG_2,"process_map_referral_record:  The nonce of the Map-Referral doesn't match the nonce of any generated Map-Request. Discarding message ...");
        free_mapping_elt(referral_mapping);
        return (BAD);
    }else {
        if (pending_referral_entry->previous_referral->act_entry_type == MS_NOT_REGISTERED){
            previous_referral_entry = pending_referral_entry->previous_referral->parent_node;
            ddt_node_locator_addr = get_ddt_locator_addr_at_position(pending_referral_entry->previous_referral->parent_node,
                    ctrl_supported_afi, pending_referral_entry->tried_locators);
        }else{
            previous_referral_entry = pending_referral_entry->previous_referral;
            ddt_node_locator_addr = get_ddt_locator_addr_at_position(pending_referral_entry->previous_referral,
                    ctrl_supported_afi, pending_referral_entry->tried_locators);
        }
    }

    free(pending_referral_entry->nonces);
    pending_referral_entry->nonces = NULL;

    /* Stop the timer to not retry to send the map request */
    stop_timer(pending_referral_entry->ddt_request_retry_timer);
    pending_referral_entry->ddt_request_retry_timer = NULL;


    /* Fill a auxiliar mapping with the information of the packet */
    referral_mapping = new_mapping(aux_eid_prefix,aux_eid_prefix_length,aux_iid);
    if (referral_mapping == NULL){
        return (BAD);
    }
    cur_ptr = (uint8_t *)&(record->eid_prefix_afi);
    if (pkt_process_eid_afi(&cur_ptr,referral_mapping) != GOOD){
        lispd_log_msg(LISP_LOG_DEBUG_2,"process_map_referral_record:  Error processing the EID of the map reply record");
        free_mapping_elt(referral_mapping);
        return (BAD);
    }
    referral_mapping->eid_prefix_length = record->eid_prefix_length;

    /* Check that the requested EID belongs to the returned prefix in the referral */
    if (is_prefix_b_part_of_a (
            referral_mapping->eid_prefix,
            referral_mapping->eid_prefix_length,
            pending_referral_entry->map_cache_entry->mapping->eid_prefix,
            pending_referral_entry->map_cache_entry->mapping->eid_prefix_length) == FALSE){
        lispd_log_msg(LISP_LOG_DEBUG_1,"process_map_referral_record: The requested EID doesn't belong to the prefix received "
                            "in the map referral: EID: %s  -   received prefix: %s/%d",
                            get_char_from_lisp_addr_t(pending_referral_entry->map_cache_entry->mapping->eid_prefix),
                            get_char_from_lisp_addr_t(referral_mapping->eid_prefix),referral_mapping->eid_prefix_length);
        err = try_next_referral_node_or_go_through_root (pending_referral_entry);
        if (err != GOOD){
            if (err == ERR_DST_ADDR){
                err = activate_negative_map_cache (pending_referral_entry->map_cache_entry,
                        pending_referral_entry->map_cache_entry->mapping->eid_prefix,
                        pending_referral_entry->map_cache_entry->mapping->eid_prefix_length,
                        1,MAPPING_ACT_NO_ACTION);
                if (err != GOOD){
                    del_map_cache_entry_from_db(pending_referral_entry->map_cache_entry->mapping->eid_prefix,
                            pending_referral_entry->map_cache_entry->mapping->eid_prefix_length);
                }
            }
            remove_pending_referral_cache_entry_from_list(pending_referral_entry);
        }
        free_mapping_elt(referral_mapping);

        return (BAD);
    }


    /*
     * Avoid loops:
     *   - Check that the returned referral has a more specific prefix than the previous referral
     *   - If received referral is: MS_REFERRAL or NODE_REFERRAL, Check that its prefix is diferent from the previous one.
     */

    if (is_prefix_b_part_of_a (
            previous_referral_entry->mapping->eid_prefix,
            previous_referral_entry->mapping->eid_prefix_length,
            referral_mapping->eid_prefix,
            referral_mapping->eid_prefix_length) == FALSE){
        lispd_log_msg(LISP_LOG_DEBUG_1,"process_map_referral_record: Loop detected in the ddt process-> "
                "received prefix: %s/%d  -   previous prefix: %s/%d. Trying next ddt node",
                get_char_from_lisp_addr_t(referral_mapping->eid_prefix),referral_mapping->eid_prefix_length,
                get_char_from_lisp_addr_t(previous_referral_entry->mapping->eid_prefix),
                previous_referral_entry->mapping->eid_prefix_length);
        detected_loop = TRUE;
    }else if ((previous_referral_entry->mapping->eid_prefix_length == referral_mapping->eid_prefix_length) &&
            (record->action == NODE_REFERRAL || record->action == MS_REFERRAL)){
        lispd_log_msg(LISP_LOG_DEBUG_1,"process_map_referral_record: Loop detected in the ddt process-> "
                "%s message contains same prefix as last referral iteration : %s/%d",
                (record->action == NODE_REFERRAL ? "Node referral" : "MS referral"),
                get_char_from_lisp_addr_t(referral_mapping->eid_prefix),
                referral_mapping->eid_prefix_length);
        detected_loop = TRUE;
    }

    if ( detected_loop == TRUE){
        /* Try with the next ddt node*/
        err = try_next_referral_node_or_go_through_root (pending_referral_entry);
        if (err != GOOD){
            if (err == ERR_DST_ADDR){
                lispd_log_msg(LISP_LOG_DEBUG_1,"process_map_referral_record: Loop detected in the ddt process-> "
                        "error in the ddt tree");
                err = activate_negative_map_cache (pending_referral_entry->map_cache_entry,
                        previous_referral_entry->mapping->eid_prefix,
                        previous_referral_entry->mapping->eid_prefix_length,
                        1,MAPPING_ACT_NO_ACTION);
                if (err != GOOD){
                    del_map_cache_entry_from_db(pending_referral_entry->map_cache_entry->mapping->eid_prefix,
                            pending_referral_entry->map_cache_entry->mapping->eid_prefix_length);
                }
            }
            remove_pending_referral_cache_entry_from_list(pending_referral_entry);
        }

        free_mapping_elt(referral_mapping);
        return (BAD);
    }

    map_cache_entry = pending_referral_entry->map_cache_entry;

    if (map_cache_entry->mapping->iid != referral_mapping->iid){
        lispd_log_msg(LISP_LOG_DEBUG_2,"process_map_referral_record:  Instance ID of the map referral doesn't match with the pending referral cache entry");
        free_mapping_elt(referral_mapping);
        remove_pending_referral_cache_entry_from_list(pending_referral_entry);
        return (BAD);
    }
    /* Create the referral cache entry */
    referral_entry = new_referral_cache_entry(referral_mapping, record->action, ntohl(record->ttl));
    referral_entry->src_inf_ddt_node_locator_addr = ddt_node_locator_addr;

    /* Get the locators list */
    for (ctr=0 ; ctr < record->locator_count ; ctr++){
        if ((process_map_referral_locator (&cur_ptr, referral_entry->mapping)) != GOOD){
            return(BAD);
        }
    }

    lispd_log_msg(LISP_LOG_DEBUG_2,"process_map_referral_record:Answer from %s : Authoritative: %d , Incomplete: %d",
            get_char_from_lisp_addr_t(referral_entry->src_inf_ddt_node_locator_addr),record->authoritative,record->incomplete);

    dump_referral_cache_entry(referral_entry,LISP_LOG_DEBUG_2);

    switch (referral_entry->act_entry_type){
        case NODE_REFERRAL:
            result = process_node_referral_reply(referral_entry,pending_referral_entry);
            break;
        case MS_REFERRAL:
            result = process_ms_referral_reply(referral_entry,pending_referral_entry);
            break;
        case MS_ACK:
            result = process_ms_ack_reply(referral_entry,pending_referral_entry);
            break;
        case MS_NOT_REGISTERED:
            result = process_ms_not_registered_reply(referral_entry,pending_referral_entry);
            break;
        case DELEGATION_HOLE:
            result = process_delegation_hole_reply(referral_entry,pending_referral_entry);
            break;
        case NOT_AUTHORITATIVE:
            result = process_not_authoritative_reply(referral_entry,pending_referral_entry);
            break;
        default:
            lispd_log_msg(LISP_LOG_DEBUG_2,"process_map_referral_record: Referral record %s/%d  with not supported action: %d",
                    get_char_from_lisp_addr_t(referral_mapping->eid_prefix),referral_mapping->eid_prefix_length,referral_entry->act_entry_type);
            result = BAD;
            break;
    }

    return (result);
}