示例#1
0
static void new_verifier(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
    AvahiLLMNREntryVerify *ev;

    assert(s);
    assert(i);
    assert(e);
    assert(!e->dead);
    assert(e->type == AVAHI_ENTRY_LLMNR);

    if( !avahi_interface_match (i, e->interface, e->protocol) ||
        !i->llmnr.verifying ||
        !avahi_entry_is_commited(e) )
    /* start verifying rr's only when group has been commited */
        return;

    if(get_verifier(s, i, e))
        return;

    if(!(ev = avahi_new(AvahiLLMNREntryVerify, 1)))
        return;

    ev->s= s;
    ev->interface = i;
    ev->e = e;
    ev->lq = NULL;

    AVAHI_LLIST_PREPEND(AvahiLLMNREntryVerify, by_interface, i->llmnr.verifiers, ev);
    AVAHI_LLIST_PREPEND(AvahiLLMNREntryVerify, by_entry, e->proto.llmnr.verifiers, ev);

    set_state(ev);
}
示例#2
0
/**
 * @brief Use given API key to get the permanent key pair as the 
 * initialization step of plurk
 *
 * @param req the address of API key pair
 * @param permanent the address of permanent key pair
 *
 * @return error on 1
 */
int plurk_init(key_pair* req, key_pair* permanent){

    // prepare for response key
    key_pair* tmp = malloc(sizeof(key_pair));
    tmp->key = NULL;
    tmp->secret = NULL;

    // prepare for authorize verified code
    char* verifier_code = malloc(sizeof(char) * 8);

    // OAuth prcess procedure
    // 1. get response key
    // 2. get the verifier code
    // 3. get the permanent access key
    get_response_token(req->key, req->secret, &(tmp->key), &(tmp->secret));
    get_verifier(req->key, req->secret, tmp->key, tmp->secret, &verifier_code);
    get_access_token(req->key, req->secret, &(tmp->key), &(tmp->secret),
                     verifier_code);

    // store the permanent key/secret 
    permanent->key = tmp->key;
    permanent->secret = tmp->secret;

    // free the dynamic allocated space
    free(verifier_code);

    //free(tmp->key);      // << save for outer, no free
    //free(tmp->secret);   // << save for outer, no free
    return 0;
}
示例#3
0
static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
    AvahiEntry *e = userdata;
    AvahiLLMNREntryVerify *ev;

    assert(m);
    assert(i);
    assert(e);
    assert((!e->dead) && (e->type == AVAHI_ENTRY_LLMNR));

    if (!(ev = get_verifier(m->server, i, e)))
        return;

    avahi_reverify(ev);
}
示例#4
0
int avahi_llmnr_entry_is_verifying(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
    AvahiLLMNREntryVerify *ev;

    assert(s);
    assert(e);
    assert(i);
    assert((!e->dead) && (e->type == AVAHI_ENTRY_LLMNR));

    if( !(ev = get_verifier(s, i, e)) ||
         (ev->state == AVAHI_CONFLICT))
        return -1;

    if (ev->state == AVAHI_VERIFYING)
        return 1;

    assert(ev->state == AVAHI_VERIFIED);
    return 0;
}
示例#5
0
void avahi_llmnr_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
    AvahiLLMNREntryVerify *ev;

    assert(s);
    assert(e);
    assert(i);
    assert((!e->dead) && (e->type == AVAHI_ENTRY_LLMNR));

    if (!(ev = get_verifier(s, i, e)))
        return;

    if (ev->state == AVAHI_VERIFYING)
        if (ev->e->group) {

            avahi_llmnr_query_destroy(ev->lq);
            ev->lq = NULL;

            assert(ev->e->group->type == AVAHI_GROUP_LLMNR);
            ev->e->group->proto.llmnr.n_verifying--;
        }

    set_state(ev);
}