Beispiel #1
0
int locator_parse(void *ptr, locator_t *loc)
{
    locator_hdr_t *hdr;
    uint8_t status = UP;
    int len;

    hdr = ptr;
    if (!LOC_REACHABLE(hdr) && LOC_LOCAL(hdr)) {
        status = DOWN;
    }
    if (!loc->addr) {
        loc->addr = lisp_addr_new();
    }

    len = lisp_addr_parse(LOC_ADDR(hdr), loc->addr);
    if (len <= 0) {
        return (BAD);
    }

    loc->state = status;
    loc->priority = LOC_PRIORITY(hdr);
    loc->weight = LOC_WEIGHT(hdr);
    loc->mpriority = LOC_MPRIORITY(hdr);
    loc->mweight = LOC_MWEIGHT(hdr);

    return (sizeof(locator_hdr_t) + len);
}
Beispiel #2
0
/* Given a message buffer 'msg', extracts the EID out of an EID prefix field
 * and stores it in 'eid'. */
int
lisp_msg_parse_eid_rec(lbuf_t *msg, lisp_addr_t *eid)
{
    eid_record_hdr_t *hdr = lbuf_data(msg);
    int len = lisp_addr_parse(EID_REC_ADDR(hdr), eid);
    lbuf_pull(msg, len);
    lisp_addr_set_plen(eid, EID_REC_MLEN(hdr));

    return(GOOD);
}
Beispiel #3
0
int
lisp_msg_parse_addr(lbuf_t *msg, lisp_addr_t *eid)
{
    int len = lisp_addr_parse(lbuf_data(msg), eid);
    if (len < 0) {
        return(BAD);
    }
    lbuf_pull(msg, len);
    return(GOOD);
}
Beispiel #4
0
int
lisp_msg_parse_mapping_record_split(lbuf_t *b, lisp_addr_t *eid,
        glist_t *loc_list, locator_t **probed_)
{
    void *mrec_hdr = NULL, *loc_hdr = NULL;
    locator_t *loc = NULL, *probed = NULL;
    int i = 0, len = 0;

    probed = NULL;
    mrec_hdr = lbuf_data(b);
    lbuf_pull(b, sizeof(mapping_record_hdr_t));

    len = lisp_addr_parse(lbuf_data(b), eid);
    if (len <= 0) {
        return(BAD);
    }
    lbuf_pull(b, len);
    lisp_addr_set_plen(eid, MAP_REC_EID_PLEN(mrec_hdr));

    OOR_LOG(LDBG_1, "  %s eid: %s", mapping_record_hdr_to_char(mrec_hdr),
            lisp_addr_to_char(eid));

    for (i = 0; i < MAP_REC_LOC_COUNT(mrec_hdr); i++) {
        loc_hdr = lbuf_data(b);

        loc = locator_new();
        if (lisp_msg_parse_loc(b, loc) != GOOD) {
            return(BAD);
        }
        glist_add(loc, loc_list);

        if (LOC_PROBED(loc_hdr)) {
            if (probed != NULL) {
                OOR_LOG(LDBG_1, "Multiple probed locators! Probing only the first one: %s",
                        lisp_addr_to_char(locator_addr(loc)));
            }else{
                probed = loc;
            }
        }
    }
    if (probed_ != NULL) {
        *probed_ = probed;
    }

    return(GOOD);
}