本文整理汇总了C++中ccn_name_from_uri函数的典型用法代码示例。如果您正苦于以下问题:C++ ccn_name_from_uri函数的具体用法?C++ ccn_name_from_uri怎么用?C++ ccn_name_from_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ccn_name_from_uri函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ccn_proxy_init
struct ccn_proxy *
ccn_proxy_init(const char *filter_uri,
const char *prefix_uri)
{
struct ccn_proxy *proxy = calloc(1, sizeof(struct ccn_proxy));
struct ccn_buf_decoder decoder;
struct ccn_buf_decoder *d = &decoder;
int res;
DEBUG_PRINT("IN %d %s\n", __LINE__, __func__);
/* Convert URI to name this proxy is responsible for */
proxy->prefix = ccn_charbuf_create();
res = ccn_name_from_uri(proxy->prefix, prefix_uri);
if (res < 0) {
DEBUG_PRINT("ABORT %d %s bad ccn URI: %s\n", __LINE__, __func__, prefix_uri);
abort();
}
d = ccn_buf_decoder_start(d, proxy->prefix->buf, proxy->prefix->length);
proxy->prefix_comps = ccn_indexbuf_create();
proxy->prefix_ncomps = ccn_parse_Name(d, proxy->prefix_comps);
proxy->filter = ccn_charbuf_create();
res = ccn_name_from_uri(proxy->filter, filter_uri);
if (res < 0) {
DEBUG_PRINT("ABORT %d %s bad ccn URI: %s\n", __LINE__, __func__, filter_uri);
abort();
}
/* Initialization should be done by ccn_proxy_connect() */
proxy->handle_name = ccn_charbuf_create();
ccn_charbuf_append_string(proxy->handle_name, "in/outb");
DEBUG_PRINT("OUT %d %s\n", __LINE__, __func__);
return(proxy);
}
开发者ID:chris-wood,项目名称:ANDANAv2,代码行数:48,代码来源:proxy.c
示例2: ccn_charbuf_create
void GroupManager::enumerate() {
ccn_charbuf *interest_path = NULL;
ccn_charbuf *templ = NULL;
interest_path = ccn_charbuf_create();
if (interest_path == NULL ) {
return;
}
ccn_name_from_uri(interest_path, BROADCAST_PREFIX);
ccn_name_append_str(interest_path, confName.toLocal8Bit().constData());
ccn_name_append_str(interest_path, "speaker-list");
// update exclusive filter according to recently known remote users
QHash<QString, RemoteUser *>::const_iterator it = (pGroupManager->qhRemoteUsers).constBegin();
QList<QString> toExclude;
while (it != (pGroupManager->qhRemoteUsers).constEnd())
{
RemoteUser *ru = it.value();
if (ru && !ru->needRefresh()) {
toExclude.append(ru->getName());
}
++it;
}
// TODO: do not exclude local user (when staleness comes to play)
// always exclude localuser by now
toExclude.append(userName);
expressEnumInterest(interest_path, toExclude);
}
开发者ID:FreshLeaf8865,项目名称:mumble,代码行数:29,代码来源:GroupManager.cpp
示例3: ccn_publish_client_mountpoint
static void
ccn_publish_client_mountpoint()
{
dropbear_log(LOG_WARNING,"Enter ccn_publish_client_mountpoint");
int result;
struct ccn_charbuf *mountpoint;
char client_id_str[6];
char *client_name_str = NULL;
mountpoint = ccn_charbuf_create();
if( mountpoint == NULL )
dropbear_exit("Failed to allocate client mountpoint charbuf");
client_name_str = strdup((const char*)cli_opts.ccnxdomain);
strcat(client_name_str,"/ssh/");
sprintf(client_id_str,"%6d",rand());
strcat(client_name_str,client_id_str);
cli_opts.ccnxdomain = client_name_str;
result = ccn_name_from_uri(mountpoint,cli_opts.ccnxdomain);
if( result < 0 )
dropbear_exit("Can't resolve client domain");
dropbear_log(LOG_WARNING,"Listening at");
print_ccnb_charbuf(mountpoint);
result = ccn_set_interest_filter(cli_opts.ssh_ccn,mountpoint,&newServerAction);
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:27,代码来源:cli-main.c
示例4: main
int main()
{
struct ccn *ccn = NULL;
struct ccn_charbuf *name = NULL;
int res;
struct ccn_closure *incoming = NULL;
ccn = ccn_create();
if (ccn_connect(ccn, NULL) == -1)
{
perror("Could not connect to ccnd");
exit(1);
}
incoming = calloc(1, sizeof(*incoming));
incoming->p = &incoming_content;
name = ccn_charbuf_create();
res = ccn_name_from_uri(name, "ccnx:/FOX/test");
//ccn_express_persistent_interest(ccn, name, incoming, NULL, 1);
ccn_express_interest(ccn, name, incoming, NULL);
printf("Interests send\n", res);
res = ccn_run(ccn, 10000);
return 0;
}
开发者ID:netharis,项目名称:ccnxaueb,代码行数:31,代码来源:ccnsender.c
示例5: ccns_slice_name
int
ccns_slice_name(struct ccn_charbuf *nm, struct ccns_slice *s)
{
struct ccn_charbuf *c;
struct ccn_digest *digest = NULL;
struct ccn_charbuf *hash = NULL;
int res = 0;
c = ccn_charbuf_create();
if (c == NULL)
return (-1);
res = append_slice(c, s);
if (res < 0)
goto Cleanup;
digest = ccn_digest_create(CCN_DIGEST_SHA256);
hash = ccn_charbuf_create_n(ccn_digest_size(digest));
if (hash == NULL)
goto Cleanup;
ccn_digest_init(digest);
res |= ccn_digest_update(digest, c->buf, c->length);
res |= ccn_digest_final(digest, hash->buf, hash->limit);
if (res < 0)
goto Cleanup;
hash->length = hash->limit;
if (ccn_name_from_uri(nm, "ccnx:/%C1.M.S.localhost/%C1.S.cs") < 0)
res = -1;
res |= ccn_name_append(nm, hash->buf, hash->length);
Cleanup:
ccn_charbuf_destroy(&c);
ccn_digest_destroy(&digest);
ccn_charbuf_destroy(&hash);
return (res);
}
开发者ID:IthacaDream,项目名称:ccnx,代码行数:35,代码来源:sync_api.c
示例6: ccnr_init_policy_link_cob
/**
* should probably return a new cob, rather than reusing one.
* should publish link as:
* CCNRID_POLICY_URI("ccnx:/%C1.M.S.localhost/%C1.M.SRV/repository/POLICY)/%C1.M.K--pubid--/--version--/%00
* should have key locator which is the key name of the repository
*/
PUBLIC struct ccn_charbuf *
ccnr_init_policy_link_cob(struct ccnr_handle *ccnr, struct ccn *h,
struct ccn_charbuf *targetname)
{
struct ccn_signing_params sp = CCN_SIGNING_PARAMS_INIT;
struct ccn_charbuf *name = ccn_charbuf_create();
struct ccn_charbuf *pubid = ccn_charbuf_create();
struct ccn_charbuf *pubkey = ccn_charbuf_create();
struct ccn_charbuf *keyid = ccn_charbuf_create();
struct ccn_charbuf *content = ccn_charbuf_create();
struct ccn_charbuf *cob = ccn_charbuf_create();
struct ccn_charbuf *answer = NULL;
int res;
res = ccn_get_public_key(h, NULL, pubid, pubkey);
if (res < 0)
goto Bail;
if (ccn_name_from_uri(name, CCNRID_POLICY_URI) < 0)
goto Bail;
res |= ccn_charbuf_append_value(keyid, CCN_MARKER_CONTROL, 1);
res |= ccn_charbuf_append_string(keyid, ".M.K");
res |= ccn_charbuf_append_value(keyid, 0, 1);
res |= ccn_charbuf_append_charbuf(keyid, pubid);
res |= ccn_name_append(name, keyid->buf, keyid->length);
res |= ccn_create_version(h, name, CCN_V_NOW, 0, 0);
if (ccn_name_from_uri(name, "%00") < 0)
goto Bail;
sp.sp_flags |= CCN_SP_FINAL_BLOCK;
sp.type = CCN_CONTENT_LINK;
res |= ccnb_append_Link(content, targetname, "Repository Policy", NULL);
if (res != 0)
goto Bail;
res |= ccn_sign_content(h, cob, name, &sp, content->buf, content->length);
if (res != 0)
goto Bail;
answer = cob;
cob = NULL;
Bail:
ccn_charbuf_destroy(&name);
ccn_charbuf_destroy(&pubid);
ccn_charbuf_destroy(&pubkey);
ccn_charbuf_destroy(&keyid);
ccn_charbuf_destroy(&content);
ccn_charbuf_destroy(&cob);
return (answer);
}
开发者ID:GabrielLiz,项目名称:ccnx,代码行数:53,代码来源:ccnr_init.c
示例7: ccnr_init_service_ccnb
static struct ccn_charbuf *
ccnr_init_service_ccnb(struct ccnr_handle *ccnr, struct ccn *h, const char *baseuri, int freshness)
{
struct ccn_signing_params sp = CCN_SIGNING_PARAMS_INIT;
struct ccn_charbuf *name = ccn_charbuf_create();
struct ccn_charbuf *pubid = ccn_charbuf_create();
struct ccn_charbuf *pubkey = ccn_charbuf_create();
struct ccn_charbuf *keyid = ccn_charbuf_create();
struct ccn_charbuf *cob = ccn_charbuf_create();
int res;
res = ccn_get_public_key(h, NULL, pubid, pubkey);
if (res < 0) abort();
ccn_name_from_uri(name, baseuri);
ccn_charbuf_append_value(keyid, CCN_MARKER_CONTROL, 1);
ccn_charbuf_append_string(keyid, ".M.K");
ccn_charbuf_append_value(keyid, 0, 1);
ccn_charbuf_append_charbuf(keyid, pubid);
ccn_name_append(name, keyid->buf, keyid->length);
ccn_create_version(h, name, 0, ccnr->starttime, ccnr->starttime_usec * 1000);
sp.template_ccnb = ccn_charbuf_create();
ccnb_element_begin(sp.template_ccnb, CCN_DTAG_SignedInfo);
ccnb_element_begin(sp.template_ccnb, CCN_DTAG_KeyLocator);
ccnb_element_begin(sp.template_ccnb, CCN_DTAG_KeyName);
ccn_charbuf_append_charbuf(sp.template_ccnb, name);
ccnb_element_end(sp.template_ccnb);
// ccn_charbuf_append_tt(sp.template_ccnb, CCN_DTAG_PublisherPublicKeyDigest,
// CCN_DTAG);
// ccn_charbuf_append_charbuf(sp.template_ccnb, pubid);
// ccnb_element_end(sp.template_ccnb);
ccnb_element_end(sp.template_ccnb);
ccnb_element_end(sp.template_ccnb);
sp.sp_flags |= CCN_SP_TEMPL_KEY_LOCATOR;
ccn_name_from_uri(name, "%00");
sp.sp_flags |= CCN_SP_FINAL_BLOCK;
sp.type = CCN_CONTENT_KEY;
sp.freshness = freshness;
res = ccn_sign_content(h, cob, name, &sp, pubkey->buf, pubkey->length);
if (res != 0) abort();
ccn_charbuf_destroy(&name);
ccn_charbuf_destroy(&pubid);
ccn_charbuf_destroy(&pubkey);
ccn_charbuf_destroy(&keyid);
ccn_charbuf_destroy(&sp.template_ccnb);
return(cob);
}
开发者ID:GabrielLiz,项目名称:ccnx,代码行数:46,代码来源:ccnr_internal_client.c
示例8: newServerHandler
/*
* newServerHandler
*
* Expecting a string containing the URI for the client
*/
static enum ccn_upcall_res
newServerHandler(struct ccn_closure *selfp,
enum ccn_upcall_kind kind,
struct ccn_upcall_info *info)
{
dropbear_log(LOG_WARNING,"Enter newServerHandler");
dropbear_log(LOG_WARNING,"Got interest matching %d components, kind = %d\n", info->matched_comps, kind);
int result;
const unsigned char *ccnb = NULL;
size_t ccnb_size;
void *data = NULL;
size_t data_size = 0;
switch (kind) {
case CCN_UPCALL_CONTENT:
break;
case CCN_UPCALL_INTEREST_TIMED_OUT:
return CCN_UPCALL_RESULT_REEXPRESS;
case CCN_UPCALL_CONTENT_UNVERIFIED:
// TODO: fix verification
break;
default:
return CCN_UPCALL_RESULT_ERR;
}
dropbear_log(LOG_WARNING,"Interest to");
print_ccnb_name(info);
ccnb = info->content_ccnb;
ccnb_size = info->pco->offset[CCN_PCO_E];
result = ccn_content_get_value(ccnb, ccnb_size, info->pco, (const unsigned char **)&data, &data_size);
if( result < 0 )
dropbear_exit("Could not parse reply message");
dropbear_log(LOG_WARNING,"newServerHandler: parsing contents");
if( strncmp((char *)data,"ccnx:/",6) == 0 ) {
cli_opts.remote_name_str = (char *)data;
dropbear_log(LOG_WARNING,"newServerHandler: matches: %s (%d)",data,data_size);
ses.remote_name = ccn_charbuf_create();
result = ccn_name_from_uri(ses.remote_name,cli_opts.remote_name_str);
if( result < 0 )
dropbear_exit("Did not find expected uri in server response");
// Start a new session
dropbear_log(LOG_WARNING,"Connected to server at");
print_ccnb_charbuf(ses.remote_name);
cli_session(cli_opts.ccnxdomain,cli_opts.remote_name_str);
return CCN_UPCALL_RESULT_OK;
} else {
dropbear_log(LOG_WARNING,"newServerHandler: doesn't match");
return CCN_UPCALL_RESULT_ERR;
}
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:63,代码来源:cli-main.c
示例9: add_delete_ccn_face
static int
add_delete_ccn_face(struct ccn *h, const char *uri, const char *address, const unsigned int p, int operation)
{
struct ccn_charbuf *prefix;
char port[6];
struct ccn_charbuf *local_scope_template = ccn_charbuf_create();
struct ccn_charbuf *no_name = ccn_charbuf_create();
unsigned char ccndid_storage[32] = {0};
unsigned char *ccndid = ccndid_storage;
size_t ccndid_size = 0;
struct ccn_face_instance *fi;
struct ccn_face_instance *nfi;
int res;
prefix = ccn_charbuf_create();
res = ccn_name_from_uri(prefix, uri);
ON_ERROR_CLEANUP(res);
memset(port, 0, 6);
sprintf(port, "%d", p);
init_data(local_scope_template, no_name);
ccndid_size = get_ccndid(h, local_scope_template, ccndid);
if (ccndid_size != sizeof(ccndid_storage))
{
fprintf(stderr, "Incorrect size for ccnd id in response\n");
ON_ERROR_CLEANUP(-1);
}
/* construct a face instance for new face request */
fi = construct_face(ccndid, ccndid_size, address, port);
ON_NULL_CLEANUP(fi);
/* send new face request to actually create a new face */
nfi = create_face(h, local_scope_template, no_name, fi);
ON_NULL_CLEANUP(nfi);
res = register_unregister_prefix(h, local_scope_template, no_name, prefix, nfi, operation);
ON_ERROR_CLEANUP(res);
ccn_charbuf_destroy(&local_scope_template);
ccn_charbuf_destroy(&no_name);
ccn_face_instance_destroy(&fi);
ccn_face_instance_destroy(&nfi);
ccn_charbuf_destroy(&prefix);
return 0;
cleanup:
ccn_charbuf_destroy(&prefix);
ccn_charbuf_destroy(&local_scope_template);
ccn_charbuf_destroy(&no_name);
ccn_face_instance_destroy(&fi);
ccn_face_instance_destroy(&nfi);
return -1;
}
开发者ID:akaash-nigam,项目名称:OSPFN2.0,代码行数:57,代码来源:ccn_fib.c
示例10: get_content_by_content_name
int
get_content_by_content_name(char *content_name, unsigned char **content_data,
char *orig_router)
{
int ret=-1;
struct ccn_charbuf *name = NULL;
struct ccn_charbuf *templ = NULL;
struct ccn_charbuf *resultbuf = NULL;
struct ccn_parsed_ContentObject pcobuf = { 0 };
int res;
int allow_stale = 1;
int content_only = 1;
int scope = -1;
const unsigned char *ptr,*ptr_in;
size_t length,length_in;
int resolve_version = CCN_V_HIGHEST;
int timeout_ms = 3000;
const unsigned lifetime_default = CCN_INTEREST_LIFETIME_SEC << 12;
unsigned lifetime_l12 = lifetime_default;
int get_flags = 0;
name = ccn_charbuf_create();
res = ccn_name_from_uri(name,content_name);
if (res < 0) {
fprintf(stderr, "Bad ccn URI: %s\n", content_name);
ccn_charbuf_destroy(&name);
return ret;
}
if (allow_stale || lifetime_l12 != lifetime_default || scope != -1) {
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> */
if (allow_stale) {
ccn_charbuf_append_tt(templ, CCN_DTAG_AnswerOriginKind, CCN_DTAG);
ccnb_append_number(templ,
CCN_AOK_DEFAULT | CCN_AOK_STALE);
ccn_charbuf_append_closer(templ); /* </AnswerOriginKind> */
}
if (scope != -1) {
ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope);
}
if (lifetime_l12 != lifetime_default) {
/*
* Choose the interest lifetime so there are at least 3
* expressions (in the unsatisfied case).
*/
unsigned char buf[3] = { 0 };
int i;
for (i = sizeof(buf) - 1; i >= 0; i--, lifetime_l12 >>= 8)
buf[i] = lifetime_l12 & 0xff;
ccnb_append_tagged_blob(templ, CCN_DTAG_InterestLifetime, buf,
sizeof(buf));
}
开发者ID:myownrhyme,项目名称:NLSR0.0,代码行数:56,代码来源:nlsr_sync.c
示例11: parse_ccn_forwarding_entry
struct ccn_forwarding_entry *
parse_ccn_forwarding_entry(struct ccndc_data *self,
const char *cmd_uri,
const char *cmd_flags,
int freshness)
{
int res = 0;
struct ccn_forwarding_entry *entry;
entry= calloc(1, sizeof(*entry));
if (entry == NULL) {
ccndc_warn(__LINE__, "Fatal error: memory allocation failed");
goto ExitOnError;
}
entry->name_prefix = ccn_charbuf_create();
if (entry->name_prefix == NULL) {
ccndc_warn(__LINE__, "Fatal error: memory allocation failed");
goto ExitOnError;
}
// copy static info
entry->ccnd_id = (const unsigned char *)self->ccnd_id;
entry->ccnd_id_size = self->ccnd_id_size;
/* we will be creating the face to either add/delete a prefix on it */
if (cmd_uri == NULL) {
ccndc_warn(__LINE__, "command erro, missing CCNx URI\n");
goto ExitOnError;
}
res = ccn_name_from_uri(entry->name_prefix, cmd_uri);
if (res < 0) {
ccndc_warn(__LINE__, "command error, bad CCNx URI '%s'\n", cmd_uri);
goto ExitOnError;
}
entry->flags = -1;
if (cmd_flags != NULL && cmd_flags[0] != 0) {
char *endptr;
entry->flags = strtol(cmd_flags, &endptr, 10);
if ((endptr != &cmd_flags[strlen(cmd_flags)]) ||
(entry->flags & ~CCN_FORW_PUBMASK) != 0) {
ccndc_warn(__LINE__, "command error, invalid flags %s\n", cmd_flags);
goto ExitOnError;
}
}
entry->lifetime = freshness;
return (entry);
ExitOnError:
ccn_forwarding_entry_destroy(&entry);
return (NULL);
}
开发者ID:IthacaDream,项目名称:ccnx,代码行数:55,代码来源:ccndc.c
示例12: get_orig_router_from_lsa_name
char *
get_orig_router_from_lsa_name(struct ccn_charbuf * content_name)
{
int start=0;
size_t comp_size;
const unsigned char *second_last_comp;
char *second_comp_type;
char *sep=".";
char *rem;
struct ccn_indexbuf *components=ccn_indexbuf_create();
struct ccn_charbuf *name=ccn_charbuf_create();
ccn_name_from_uri(name,nlsr->slice_prefix);
ccn_name_split (name, components);
start=components->n-2;
ccn_charbuf_destroy(&name);
ccn_indexbuf_destroy(&components);
struct ccn_indexbuf *comps=ccn_indexbuf_create();
ccn_name_split (content_name, comps);
ccn_name_comp_get( content_name->buf, comps,
comps->n-1-2, &second_last_comp, &comp_size);
second_comp_type=strtok_r((char *)second_last_comp, sep, &rem);
if ( strcmp( second_comp_type, "lsId" ) == 0 ){
ccn_name_chop(content_name,comps,-3);
}
else{
ccn_name_chop(content_name,comps,-2);
}
struct ccn_charbuf *temp=ccn_charbuf_create();
ccn_name_init(temp);
ccn_name_append_components( temp, content_name->buf,
comps->buf[start+1],
comps->buf[comps->n - 1]);
struct ccn_charbuf *temp1=ccn_charbuf_create();
ccn_uri_append(temp1, temp->buf, temp->length, 0);
char *orig_router=(char *)calloc(strlen(ccn_charbuf_as_string(temp1))+1,
sizeof(char));
memcpy(orig_router,ccn_charbuf_as_string(temp1),
strlen(ccn_charbuf_as_string(temp1)));
orig_router[strlen(orig_router)]='\0';
ccn_charbuf_destroy(&temp);
ccn_charbuf_destroy(&temp1);
ccn_indexbuf_destroy(&comps);
return orig_router;
}
开发者ID:akaash-nigam,项目名称:NLSR0.0,代码行数:55,代码来源:nlsr_km.c
示例13: ccn_ssh_connect
void
ccn_ssh_connect(char *remote_name_str)
{
dropbear_log(LOG_WARNING,"Enter ccn_ssh_connect");
int result;
struct ccn_charbuf *remote_name;
/*
struct ccn_pkey *server_pkey;
void *encrypted_local_name;
size_t encrypted_local_name_length;
*/
struct ccn_charbuf *connect_template;
remote_name = ccn_charbuf_create();
result = ccn_name_from_uri(remote_name,remote_name_str);
if( result < 0 )
dropbear_exit("Could not parse server uri");
ccn_name_append_str(remote_name,"ssh");
ccn_name_append_str(remote_name,"client");
/*
server_pkey = ssh_ccn_retrieve_public_key(
cli_opts.ssh_ccn,
cli_opts.remote_name_str,
cli_opts.ccn_cached_keystore);
if( server_pkey == NULL )
dropbear_exit("Could not get server public key");
result = ccn_pubkey_encrypt(server_pkey,
cli_opts.ccnxdomain,
strlen(cli_opts.ccnxdomain),
&encrypted_local_name,
&encrypted_local_name_length);
ccn_name_append(remote_name,encrypted_local_name);
*/
ccn_name_append(remote_name,cli_opts.ccnxdomain,strlen(cli_opts.ccnxdomain));
dropbear_log(LOG_WARNING,"Connecting to remote:");
print_ccnb_charbuf(remote_name);
connect_template = make_connect_template();
result = ccn_express_interest(cli_opts.ssh_ccn,
remote_name,
&newServerAction,
connect_template);
if( result < 0 )
dropbear_exit("Failed to express interest to server");
}
开发者ID:jchu,项目名称:dropbear-ccn,代码行数:53,代码来源:cli-main.c
示例14: join_dhcp_group
/*
* Create a face on the multicast address and port, bind the DHCP prefix to the face
*/
int join_dhcp_group(struct ccn *h)
{
int res;
struct ccn_charbuf *prefix = ccn_charbuf_create();
ccn_name_from_uri(prefix, CCN_DHCP_URI);
res = add_new_face(h, prefix, CCN_DHCP_ADDR, CCN_DHCP_PORT);
ccn_charbuf_destroy(&prefix);
return res;
}
开发者ID:NDN-Routing,项目名称:ccnx-dhcp,代码行数:15,代码来源:dhcp_helper.c
示例15: ccn_charbuf_create
/**
* Initiates a stream to download data
*
* @param id identifier of the ccn stream
* @param pname name of the object to download
* @param pipeline number of parallel requisitions for chunks
*/
bool CCNGet::initStream(string id, string pname, int pipeline)
{
name = ccn_charbuf_create();
name->length = 0;
ccn_name_from_uri(name, pname.c_str());
templ = make_template(0,-1);
ccn = ccn_create();
if (ccn_connect(ccn,NULL) == -1) return false;
fetch = ccn_fetch_new(ccn);
stream = ccn_fetch_open(fetch, name, id.c_str(), templ, pipeline, CCN_V_HIGHEST, ASSUMEFIXED);
if (stream == NULL) return false;
else return true;
}
开发者ID:rodolfo-s-antunes,项目名称:ccnx-relations-streaming-experiment-cpp,代码行数:20,代码来源:CCNComm.cpp
示例16: CcnCC_registerControlPrefix
void CcnCC_registerControlPrefix(CcnCC self) {
if (self->regControlPrefix) return;
struct ccn_charbuf* prefix = ccn_charbuf_create();
ccn_name_from_uri(prefix, "ccnx:/ccnx/ndnld");
ccn_name_append(prefix, self->ccndid, CCNDID_length);
ccn_name_append_str(prefix, "control");
struct ccn_closure* action = (struct ccn_closure*)calloc(1, sizeof(struct ccn_closure));
action->data = self;
action->p = &CcnCC_controlInterest;
ccn_set_interest_filter(self->ccnh, prefix, action);
ccn_charbuf_destroy(&prefix);
}
开发者ID:ltr120,项目名称:NDNFD,代码行数:14,代码来源:CcnClient.c
示例17: CcnLAC_fetchFaceid
void CcnLAC_fetchFaceid(CcnLAC self, CCNDID ccndid) {
struct ccn_charbuf* prefix = ccn_charbuf_create();
ccn_name_from_uri(prefix, "ccnx:/ccnx/ndnld");
ccn_name_append(prefix, ccndid, CCNDID_length);
ccn_name_append_str(prefix, "discover-faceid");
struct ccn_forwarding_entry* fe = CcnH_buildForwardingEntry(CcnPrefixOp_selfreg, ccndid, 0, prefix);
fe->flags = CCN_FORW_LAST | CCN_FORW_LOCAL;
fe->lifetime = 1;
CcnH_regForwardingEntry(self->ccnh, ccndid, fe, self, &CcnLAC_fetchFaceidCb);
ccn_charbuf_destroy(&prefix);
free(fe);
}
开发者ID:ltr120,项目名称:NDNFD,代码行数:14,代码来源:CcnClient.c
示例18: ccn_charbuf_create
int NdnMediaProcess::checkInterest()
{
int res = 0;
QHash<QString,UserDataBuf *>::iterator it;
ruMutex->lock();
for ( it = qhRemoteUser.begin(); it != qhRemoteUser.end(); ++it ) {
if (!it.value()->interested) {
/* Use a template to express our order preference for the first packet. */
struct ccn_charbuf *templ = ccn_charbuf_create();
struct ccn_charbuf *path = 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);
ccn_charbuf_append_tt(templ, CCN_DTAG_ChildSelector, CCN_DTAG);
ccn_charbuf_append_tt(templ, 1, CCN_UDATA);
ccn_charbuf_append(templ, "1", 1); /* low bit 1: rightmost */
ccn_charbuf_append_closer(templ); /*<ChildSelector>*/
ccn_charbuf_append_closer(templ);
ccn_name_from_uri(path, it.key().toLocal8Bit().constData());
ccn_name_append_str(path, "audio");
if (res >= 0) {
if (it.value()->data_buf.callback->p == NULL) {fprintf(stderr, "data_buf.callback is NULL!\n"); exit(1); }
/*
int c = 0;
while (pthread_mutex_trylock(&ccn_mutex) != 0) {
c++;
if (c > 10000000) {
fprintf(stderr, "cannot obtain lock! %s:%d\n", __FILE__, __LINE__);
std::exit(1);
}
}
*/
pthread_mutex_lock(&ccn_mutex);
res = ccn_express_interest(ndnState.ccn, path, it.value()->data_buf.callback, templ);
pthread_mutex_unlock(&ccn_mutex);
it.value()->interested = 1;
fprintf(stderr, "short interest sent\n");
}
if (res < 0) {
fprintf(stderr, "sending the first interest failed\n");
exit(1);
}
ccn_charbuf_destroy(&path);
ccn_charbuf_destroy(&templ);
}
}
ruMutex->unlock();
return res;
}
开发者ID:FreshLeaf8865,项目名称:mumble,代码行数:49,代码来源:media_pro.cpp
示例19: SyncNewBase
extern struct SyncBaseStruct *
SyncNewBase(struct ccnr_handle *ccnr,
struct ccn *ccn,
struct ccn_schedule *sched) {
sync_time now = SyncCurrentTime();
struct SyncBaseStruct *base = NEW_STRUCT(1, SyncBaseStruct);
base->ccnr = ccnr;
base->ccn = ccn;
base->sched = sched;
struct SyncPrivate *priv = NEW_STRUCT(1, SyncPrivate);
base->priv = priv;
priv->topoAccum = SyncAllocNameAccum(4);
priv->prefixAccum = SyncAllocNameAccum(4);
priv->sliceCmdPrefix = ccn_charbuf_create();
priv->localHostPrefix = ccn_charbuf_create();
priv->comps = ccn_indexbuf_create();
priv->stableTarget = CCNR_NULL_HWM;
priv->stableStored = CCNR_NULL_HWM;
priv->lastStable = now;
priv->lastCacheClean = now;
ccn_name_from_uri(priv->localHostPrefix, "/%C1.M.S.localhost");
ccn_name_from_uri(priv->sliceCmdPrefix, "/%C1.M.S.localhost/%C1.S.cs");
return base;
}
开发者ID:YichiLL,项目名称:ccnx,代码行数:24,代码来源:SyncBase.c
示例20: main
int
main(int argc, char *argv[])
{
int res;
struct ccn *ccn = NULL;
struct ccn_charbuf *name = NULL;
struct ccn_closure *incoming;
if (argc != 2)
usage(argv[0]);
name = ccn_charbuf_create();
res = ccn_name_from_uri(name, argv[1]);
if (res < 0) {
fprintf(stderr, "invalid ccn URI: %s\n", argv[1]);
usage(argv[0]);
}
ccn = ccn_create();
res = ccn_connect(ccn, NULL);
if (res < 0) {
fprintf(stderr, "can't connect to ccn: %d\n", res);
ccn_perror(ccn, "ccn_connect");
exit(1);
}
incoming = calloc(1, sizeof(*incoming));
incoming->p = incoming_handler;
g_working = true;
gettimeofday(&g_start, NULL);
res = ccn_express_interest(ccn, name, incoming, NULL);
while (g_working && res >= 0)
res = ccn_run(ccn, 100);
free(incoming);
if (res < 0) {
ccn_perror(ccn, "ccn_run");
exit(1);
}
ccn_charbuf_destroy(&name);
ccn_destroy(&ccn);
return 0;
}
开发者ID:remap,项目名称:ndn-status,代码行数:48,代码来源:ccnping.c
注:本文中的ccn_name_from_uri函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论