コード例 #1
0
ファイル: ccn_versioning.c プロジェクト: Emat12/ccnx
static struct ccn_charbuf *
resolve_templ(struct ccn_charbuf *templ, unsigned const char *vcomp, int size)
{
    if (templ == NULL)
        templ = ccn_charbuf_create();
    if (size < 3 || size > 16) {
        ccn_charbuf_destroy(&templ);
        return(NULL);
    }
    templ->length = 0;
    ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
    ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
    ccn_charbuf_append_closer(templ); /* </Name> */
    ccn_charbuf_append_tt(templ, CCN_DTAG_Exclude, CCN_DTAG);
    append_filter_all(templ);
    ccn_charbuf_append_tt(templ, CCN_DTAG_Component, CCN_DTAG);
    ccn_charbuf_append_tt(templ, size, CCN_BLOB);
    ccn_charbuf_append(templ, vcomp, size);
    ccn_charbuf_append_closer(templ); /* </Component> */
    append_future_vcomp(templ);
    append_filter_all(templ);
    ccn_charbuf_append_closer(templ); /* </Exclude> */
    answer_highest(templ);
    answer_passive(templ);
    ccn_charbuf_append_closer(templ); /* </Interest> */
    return(templ);
}
コード例 #2
0
ファイル: ccnslurp.c プロジェクト: GabrielLiz/ccnx
static struct ccn_charbuf *
create_passive_templ(void)
{
    struct ccn_charbuf *templ = ccn_charbuf_create();
    ccnb_element_begin(templ, CCN_DTAG_Interest);
    ccnb_element_begin(templ, CCN_DTAG_Name);
    ccnb_element_end(templ); /* </Name> */
    answer_passive(templ);
    ccnb_element_end(templ); /* </Interest> */
    return(templ);
}
コード例 #3
0
ファイル: ccnslurp.c プロジェクト: Emat12/ccnx
static struct ccn_charbuf *
create_passive_templ(void)
{
    struct ccn_charbuf *templ = ccn_charbuf_create();
    ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
    ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
    ccn_charbuf_append_closer(templ); /* </Name> */
    answer_passive(templ);
    ccn_charbuf_append_closer(templ); /* </Interest> */
    return(templ);
}
コード例 #4
0
ファイル: ccn_traverse.c プロジェクト: RazortoothRTC/ccnx
/*
 * Construct and send a new interest that uses the exclusion list.
 * Return -1 if not sent because of packet size, 0 for success.
 */
static int
express_my_interest(struct ccn *h,
                    struct ccn_closure *selfp,
                    struct ccn_charbuf *name)
{
    int ans;
    struct ccn_charbuf *templ = NULL;
    int i;
    struct ccn_traversal *data = get_my_data(selfp);

    templ = ccn_charbuf_create();
    ccnb_element_begin(templ, CCN_DTAG_Interest);
    ccnb_element_begin(templ, CCN_DTAG_Name);
    ccnb_element_end(templ); /* </Name> */
    if (data->n_excl != 0) {
        ccnb_element_begin(templ, CCN_DTAG_Exclude);
        if ((data->flags & EXCLUDE_LOW) != 0)
            append_Any_filter(templ);
        for (i = 0; i < data->n_excl; i++) {
            struct ccn_charbuf *comp = data->excl[i];
            if (comp->length < 4) abort();
            ccn_charbuf_append(templ, comp->buf + 1, comp->length - 2);
        }
        if ((data->flags & EXCLUDE_HIGH) != 0)
            append_Any_filter(templ);
        ccnb_element_end(templ); /* </Exclude> */
    }
    answer_passive(templ, (data->flags & ALLOW_STALE) != 0);
    if ((data->flags & LOCAL_SCOPE) != 0)
        local_scope(templ);
    ccnb_element_end(templ); /* </Interest> */
    if (templ->length + name->length > data->warn + 2) {
        fprintf(stderr, "*** Interest packet is %d bytes\n", (int)templ->length);
        data->warn = data->warn * 8 / 5;
    }
    if (templ->length + name->length > 1450 && data->n_excl > 3)
        ans = -1;
    else {
        ccn_express_interest(h, name, selfp, templ);
        ans = 0;
    }
    ccn_charbuf_destroy(&templ);
    return(ans);
}
コード例 #5
0
ファイル: ccnslurp.c プロジェクト: Emat12/ccnx
/*
 * Construct and send a new interest that uses the exclusion list.
 * Return -1 if not sent because of packet size, 0 for success.
 */
static int
express_my_interest(struct ccn *h,
                    struct ccn_closure *selfp,
                    struct ccn_charbuf *name)
{
    int ans;
    struct ccn_charbuf *templ = NULL;
    int i;
    struct upcalldata *data = get_my_data(selfp);

    templ = ccn_charbuf_create();
    ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
    ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
    ccn_charbuf_append_closer(templ); /* </Name> */
    ccn_charbuf_append_tt(templ, CCN_DTAG_Exclude, CCN_DTAG);
    if ((data->flags & EXCLUDE_LOW) != 0)
        append_bf_all(templ);
    for (i = 0; i < data->n_excl; i++) {
        struct ccn_charbuf *comp = data->excl[i];
        if (comp->length < 4) abort();
        ccn_charbuf_append(templ, comp->buf + 1, comp->length - 2);
    }
    if ((data->flags & EXCLUDE_HIGH) != 0)
        append_bf_all(templ);
    ccn_charbuf_append_closer(templ); /* </Exclude> */
    answer_passive(templ);
    ccn_charbuf_append_closer(templ); /* </Interest> */
    if (templ->length + name->length > data->warn + 2) {
        fprintf(stderr, "*** Interest packet is %d bytes\n", (int)templ->length);
        data->warn = data->warn * 8 / 5;
    }
    if (templ->length + name->length > 1450 && data->n_excl > 3)
        ans = -1;
    else {
        ccn_express_interest(h, name, selfp, templ);
        ans = 0;
    }
    ccn_charbuf_destroy(&templ);
    return(ans);
}
コード例 #6
0
ファイル: ndn_versioning.c プロジェクト: cawka/ndnx
static struct ndn_charbuf *
resolve_templ(struct ndn_charbuf *templ, unsigned const char *vcomp,
              int size, int lifetime, int versioning_flags)
{
    if (templ == NULL)
        templ = ndn_charbuf_create();
    if (size < 3 || size > 16) {
        ndn_charbuf_destroy(&templ);
        return(NULL);
    }
    templ->length = 0;
    ndn_charbuf_append_tt(templ, NDN_DTAG_Interest, NDN_DTAG);
    ndn_charbuf_append_tt(templ, NDN_DTAG_Name, NDN_DTAG);
    ndn_charbuf_append_closer(templ); /* </Name> */
    ndn_charbuf_append_tt(templ, NDN_DTAG_Exclude, NDN_DTAG);
    append_filter_all(templ);
    ndn_charbuf_append_tt(templ, NDN_DTAG_Component, NDN_DTAG);
    ndn_charbuf_append_tt(templ, size, NDN_BLOB);
    ndn_charbuf_append(templ, vcomp, size);
    ndn_charbuf_append_closer(templ); /* </Component> */
    append_future_vcomp(templ);
    append_filter_all(templ);
    ndn_charbuf_append_closer(templ); /* </Exclude> */
    answer_highest(templ);
    answer_passive(templ);
    if ((versioning_flags & NDN_V_SCOPE2) != 0)
        ndnb_tagged_putf(templ, NDN_DTAG_Scope, "%d", 2);
    else if ((versioning_flags & NDN_V_SCOPE1) != 0)
        ndnb_tagged_putf(templ, NDN_DTAG_Scope, "%d", 1);
    else if ((versioning_flags & NDN_V_SCOPE0) != 0)
        ndnb_tagged_putf(templ, NDN_DTAG_Scope, "%d", 0);
    if (lifetime > 0)
        ndnb_append_tagged_binary_number(templ, NDN_DTAG_InterestLifetime, lifetime);
    ndn_charbuf_append_closer(templ); /* </Interest> */
    return(templ);
}