Esempio n. 1
0
/*
 * Creates and initialize a new iface_locator
 * @param iface_name Name of the interface
 * @return iface_locators element
 */
iface_locators *
iface_locators_new(char *iface_name)
{
    iface_locators *if_loct;

    if_loct = xzalloc(sizeof(iface_locators));
    if_loct->iface_name = xstrdup(iface_name);
    if_loct->map_loc_entries = glist_new();
    if_loct->ipv4_locators = glist_new();
    if_loct->ipv6_locators = glist_new();
    if_loct->status_changed = TRUE;

    return(if_loct);
}
Esempio n. 2
0
glist_t *int_htable_values(int_htable *ht)
{
    glist_t *list;
    khiter_t k;

    list = glist_new();
    for (k = kh_begin(sh->htable); k != kh_end(ht->htable); ++k) {
        if (kh_exist(ht->htable, k)) {
            glist_add(kh_value(ht->htable,k), list);
        }
    }

    return (list);
}
Esempio n. 3
0
int
htable_ptrs_timers_add(htable_ptrs_t *ptr_ht, void *key, oor_timer_t *timer)
{
    glist_t *timer_lst;

    timer_lst = htable_ptrs_lookup(ptr_ht, key);
    if (!timer_lst){
        timer_lst = glist_new();
        if (!timer_lst){
            return (BAD);
        }
        htable_ptrs_insert(ptr_ht, key, timer_lst);
    }
    return (glist_add(timer, timer_lst));
}
Esempio n. 4
0
/* Return the list the timers of the requested type associated with the object */
glist_t *
htable_ptrs_timers_get_timers_of_type(htable_ptrs_t *ptr_ht, void *key,
        timer_type type)
{
    oor_timer_t *timer;
    glist_t *set_timers_lst;
    glist_t *timer_lst;
    glist_entry_t *timer_it, *timer_it_aux;

    timer_lst = htable_ptrs_lookup(ptr_ht, key);
    if (!timer_lst){
        return (NULL);
    }

    set_timers_lst = glist_new();
    glist_for_each_entry_safe(timer_it,timer_it_aux,timer_lst){
        timer = (oor_timer_t*)glist_entry_data(timer_it);
        if (type == oor_timer_type(timer)){
            glist_add(timer, set_timers_lst);
        }
    }
Esempio n. 5
0
/* extracts a mapping record out of lbuf 'b' and stores it into 'm'. 'm' must
 * be preallocated. If a locator is probed, a pointer to it is stored in
 * 'probed'. */
int
lisp_msg_parse_mapping_record(lbuf_t *b, mapping_t *m, locator_t **probed)
{
    glist_t *loc_list;
    glist_entry_t *lit;
    locator_t *loc;
    int ret;
    void *hdr;

    if (!m) {
        return(BAD);
    }

    hdr = lbuf_data(b);
    mapping_set_ttl(m, ntohl(MAP_REC_TTL(hdr)));
    mapping_set_action(m, MAP_REC_ACTION(hdr));
    mapping_set_auth(m, MAP_REC_AUTH(hdr));

    /* no free is called when destroyed*/
    loc_list = glist_new();

    ret = lisp_msg_parse_mapping_record_split(b, mapping_eid(m), loc_list,
                                              probed);
    if (ret != GOOD) {
        goto err;
    }

    glist_for_each_entry(lit, loc_list) {
        loc = glist_entry_data(lit);
        if ((ret = mapping_add_locator(m, loc)) != GOOD) {
            locator_del(loc);
            if (ret != ERR_EXIST){
                goto err;
            }
        }
    }
Esempio n. 6
0
int main(void)
{
    struct gnode *n1;
    struct glist *l1, *l2, *l3, *l4;
    int i;

    /* contruct a list of ints */
    
    l1 = glist_new();

    for (i = 0; i < 10; i++) {
        n1 = gnode_new();
        gnode_set_int(n1, i);
        glist_add(l1, n1);
    }
    
    glist_print(l1);
    printf("\n");

    /* construct a list of doubles */

    l2 = glist_new();
    
    for (i = 0; i < 10; i++) {
        n1 = gnode_new();
        gnode_set_double(n1, (double) i * 2);
        glist_add(l2, n1);
    }
    
    glist_print(l2);
    printf("\n");

    /* construct a list of strings */

    l3 = glist_new();
    
    for (i = 0; i < 10; i++) {
        char *numstr[] = {"zero", "one", "two", "three", "four", "five", "six", "seven",
            "eight", "nine"};
        n1 = gnode_new();
        gnode_set_str(n1, numstr[i]);
        glist_add(l3, n1);
    }
    
    glist_print(l3);
    printf("\n");

    /* construct a list of lists */

    l4 = glist_new();
    
    for (i = 0; i < 3; i++) {
        struct glist *lists[] = {l1, l2, l3};
        n1 = gnode_new();
        gnode_set_list(n1, lists[i]);
        glist_add(l4, n1);
    }

    glist_print(l4);
    printf("\n");

    return 0;
}