Support for ccn clients. More...
Go to the source code of this file.
Defines | |
#define | CCN_FORW_WAITING_CCNDID (1<<30) |
#define | NOTE_ERR(h, e) (h->err = (e), h->errline = __LINE__, ccn_note_err(h)) |
#define | NOTE_ERRNO(h) NOTE_ERR(h, errno) |
#define | THIS_CANNOT_HAPPEN(h) do { NOTE_ERR(h, -73); ccn_perror(h, "Can't happen");} while (0) |
#define | XXX do { NOTE_ERR(h, -76); ccn_perror(h, "Please write some more code here"); } while (0) |
#define | CCN_MAX_KEY_LINK_CHAIN 7 |
This is the maximum number of links in we are willing to traverse when resolving a key locator. | |
Functions | |
static void | ccn_refresh_interest (struct ccn *, struct expressed_interest *) |
static void | ccn_initiate_prefix_reg (struct ccn *, const void *, size_t, struct interest_filter *) |
static void | finalize_pkey (struct hashtb_enumerator *e) |
static void | finalize_keystore (struct hashtb_enumerator *e) |
static int | ccn_pushout (struct ccn *h) |
static void | update_ifilt_flags (struct ccn *h, struct interest_filter *f, int forw_flags) |
Change forwarding flags, triggering a refresh as needed. | |
static int | update_multifilt (struct ccn *h, struct interest_filter *f, struct ccn_closure *action, int forw_flags) |
Take care of the case of multiple filters registered on one prefix. | |
static int | tv_earlier (const struct timeval *a, const struct timeval *b) |
Compare two timvals. | |
void | ccn_perror (struct ccn *h, const char *s) |
Produce message on standard error output describing the last error encountered during a call using the given handle. | |
static int | ccn_note_err (struct ccn *h) |
int | ccn_seterror (struct ccn *h, int error_code) |
Set the error code in a ccn handle. | |
int | ccn_geterror (struct ccn *h) |
Recover last error code. | |
static struct ccn_indexbuf * | ccn_indexbuf_obtain (struct ccn *h) |
static void | ccn_indexbuf_release (struct ccn *h, struct ccn_indexbuf *c) |
static void | ccn_replace_handler (struct ccn *h, struct ccn_closure **dstp, struct ccn_closure *src) |
Do the refcount updating for closure instances on assignment. | |
struct ccn * | ccn_create (void) |
Create a client handle. | |
int | ccn_defer_verification (struct ccn *h, int defer) |
Tell the library to defer verification. | |
int | ccn_connect (struct ccn *h, const char *name) |
Connect to local ccnd. | |
int | ccn_get_connection_fd (struct ccn *h) |
void | ccn_set_connect_type (struct ccn *h, const char *name) |
const char * | ccn_get_connect_type (struct ccn *h) |
int | ccn_disconnect (struct ccn *h) |
static void | ccn_gripe (struct expressed_interest *i) |
static void | replace_interest_msg (struct expressed_interest *interest, struct ccn_charbuf *cb) |
static struct expressed_interest * | ccn_destroy_interest (struct ccn *h, struct expressed_interest *i) |
void | ccn_check_interests (struct expressed_interest *list) |
void | ccn_clean_interests_by_prefix (struct ccn *h, struct interests_by_prefix *entry) |
void | ccn_destroy (struct ccn **hp) |
static int | ccn_check_namebuf (struct ccn *h, struct ccn_charbuf *namebuf, int prefix_comps, int omit_possible_digest) |
static void | ccn_construct_interest (struct ccn *h, struct ccn_charbuf *name_prefix, struct ccn_charbuf *interest_template, struct expressed_interest *dest) |
int | ccn_express_interest (struct ccn *h, struct ccn_charbuf *namebuf, struct ccn_closure *action, struct ccn_charbuf *interest_template) |
static void | finalize_interest_filter (struct hashtb_enumerator *e) |
int | ccn_set_interest_filter_with_flags (struct ccn *h, struct ccn_charbuf *namebuf, struct ccn_closure *action, int forw_flags) |
Register to receive interests on a prefix, with forwarding flags. | |
int | ccn_set_interest_filter (struct ccn *h, struct ccn_charbuf *namebuf, struct ccn_closure *action) |
Register to receive interests on a prefix. | |
static enum ccn_upcall_res | handle_multifilt (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
Upcall to handle multifilt. | |
static int | build_multifilt_array (struct ccn *h, struct multifilt_item **ap, int n, struct ccn_closure *action, int forw_flags) |
Replace *ap with a copy, perhaps with one additional element. | |
static void | destroy_multifilt_array (struct ccn *h, struct multifilt_item **ap, int n) |
Destroy a multifilt_array. | |
int | ccn_put (struct ccn *h, const void *p, size_t length) |
int | ccn_output_is_pending (struct ccn *h) |
struct ccn_charbuf * | ccn_grab_buffered_output (struct ccn *h) |
static int | ccn_get_content_type (const unsigned char *ccnb, const struct ccn_parsed_ContentObject *pco) |
static void | ccn_digest_Content (const unsigned char *content_object, struct ccn_parsed_ContentObject *pc, unsigned char *digest, size_t digest_bytes) |
Compute the digest of just the Content portion of content_object. | |
static int | ccn_cache_key (struct ccn *h, const unsigned char *ccnb, size_t size, struct ccn_parsed_ContentObject *pco) |
static int | ccn_locate_key (struct ccn *h, const unsigned char *msg, struct ccn_parsed_ContentObject *pco, struct ccn_pkey **pubkey) |
Examine a ContentObject and try to find the public key needed to verify it. | |
static int | ccn_append_link_name (struct ccn_charbuf *name, const unsigned char *data, size_t data_size) |
Get the name out of a Link. | |
static enum ccn_upcall_res | handle_key (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
Called when we get an answer to a KeyLocator fetch issued by ccn_initiate_key_fetch. | |
static int | ccn_initiate_key_fetch (struct ccn *h, unsigned char *msg, struct ccn_parsed_ContentObject *pco, struct expressed_interest *trigger_interest) |
static void | ccn_check_pub_arrival (struct ccn *h, struct expressed_interest *interest) |
If we were waiting for a key and it has arrived, refresh the interest. | |
void | ccn_dispatch_message (struct ccn *h, unsigned char *msg, size_t size) |
Dispatch a message through the registered upcalls. | |
static int | ccn_process_input (struct ccn *h) |
static void | ccn_update_refresh_us (struct ccn *h, struct timeval *tv) |
static void | ccn_age_interest (struct ccn *h, struct expressed_interest *interest, const unsigned char *key, size_t keysize) |
static void | ccn_clean_all_interests (struct ccn *h) |
static void | ccn_notify_ccndid_changed (struct ccn *h) |
struct ccn_schedule * | ccn_get_schedule (struct ccn *h) |
Get the previously set event schedule from a ccn handle. | |
struct ccn_schedule * | ccn_set_schedule (struct ccn *h, struct ccn_schedule *schedule) |
Set the event schedule in a ccn handle. | |
int | ccn_process_scheduled_operations (struct ccn *h) |
Process any scheduled operations that are due. | |
int | ccn_set_run_timeout (struct ccn *h, int timeout) |
Modify ccn_run timeout. | |
int | ccn_run (struct ccn *h, int timeout) |
Run the ccn client event loop. | |
static enum ccn_upcall_res | handle_simple_incoming_content (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
Upcall for implementing ccn_get(). | |
int | ccn_get (struct ccn *h, struct ccn_charbuf *name, struct ccn_charbuf *interest_template, int timeout_ms, struct ccn_charbuf *resultbuf, struct ccn_parsed_ContentObject *pcobuf, struct ccn_indexbuf *compsbuf, int flags) |
Get a single matching ContentObject This is a convenience for getting a single matching ContentObject. | |
static enum ccn_upcall_res | handle_ccndid_response (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
Upcall to handle response to fetch a ccndid. | |
static void | ccn_initiate_ccndid_fetch (struct ccn *h) |
static enum ccn_upcall_res | handle_prefix_reg_reply (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
Handle reply to a prefix registration request. | |
int | ccn_verify_content (struct ccn *h, const unsigned char *msg, struct ccn_parsed_ContentObject *pco) |
Verify a ContentObject using the public key from either the object itself or our cache of keys. | |
int | ccn_load_private_key (struct ccn *h, const char *keystore_path, const char *keystore_passphrase, struct ccn_charbuf *pubid_out) |
Load a private key from a keystore file. | |
int | ccn_load_default_key (struct ccn *h, const char *keystore_path, const char *keystore_passphrase) |
Load the handle's default signing key from a keystore. | |
int | ccn_get_public_key (struct ccn *h, const struct ccn_signing_params *params, struct ccn_charbuf *digest_result, struct ccn_charbuf *result) |
Place the public key associated with the params into result buffer, and its digest into digest_result. | |
int | ccn_chk_signing_params (struct ccn *h, const struct ccn_signing_params *params, struct ccn_signing_params *result, struct ccn_charbuf **ptimestamp, struct ccn_charbuf **pfinalblockid, struct ccn_charbuf **pkeylocator) |
This is mostly for use within the library, but may be useful for some clients. | |
int | ccn_sign_content (struct ccn *h, struct ccn_charbuf *resultbuf, const struct ccn_charbuf *name_prefix, const struct ccn_signing_params *params, const void *data, size_t size) |
Create a signed ContentObject. | |
int | ccn_is_final_block (struct ccn_upcall_info *info) |
Check whether content described by info is final block. |
Support for ccn clients.
Part of the CCNx C Library.
Copyright (C) 2008-2012 Palo Alto Research Center, Inc.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Definition in file ccn_client.c.
#define CCN_FORW_WAITING_CCNDID (1<<30) |
Definition at line 113 of file ccn_client.c.
Referenced by ccn_initiate_prefix_reg(), and ccn_notify_ccndid_changed().
#define CCN_MAX_KEY_LINK_CHAIN 7 |
This is the maximum number of links in we are willing to traverse when resolving a key locator.
Definition at line 1476 of file ccn_client.c.
Referenced by ccn_initiate_key_fetch().
#define NOTE_ERR | ( | h, | |||
e | ) | (h->err = (e), h->errline = __LINE__, ccn_note_err(h)) |
Definition at line 122 of file ccn_client.c.
Referenced by ccn_chk_signing_params(), ccn_connect(), ccn_construct_interest(), ccn_get_public_key(), ccn_load_default_key(), ccn_locate_key(), ccn_put(), ccn_run(), ccn_sign_content(), handle_ccndid_response(), handle_key(), and handle_prefix_reg_reply().
#define NOTE_ERRNO | ( | h | ) | NOTE_ERR(h, errno) |
Definition at line 123 of file ccn_client.c.
Referenced by build_multifilt_array(), ccn_cache_key(), ccn_chk_signing_params(), ccn_connect(), ccn_create(), ccn_disconnect(), ccn_express_interest(), ccn_initiate_key_fetch(), ccn_initiate_prefix_reg(), ccn_load_private_key(), ccn_locate_key(), ccn_process_input(), ccn_pushout(), ccn_put(), ccn_run(), ccn_set_interest_filter_with_flags(), handle_ccndid_response(), and update_multifilt().
#define THIS_CANNOT_HAPPEN | ( | h | ) | do { NOTE_ERR(h, -73); ccn_perror(h, "Can't happen");} while (0) |
Definition at line 125 of file ccn_client.c.
Referenced by ccn_locate_key().
#define XXX do { NOTE_ERR(h, -76); ccn_perror(h, "Please write some more code here"); } while (0) |
Definition at line 128 of file ccn_client.c.
Referenced by ccn_locate_key(), and handle_prefix_reg_reply().
static int build_multifilt_array | ( | struct ccn * | h, | |
struct multifilt_item ** | ap, | |||
int | n, | |||
struct ccn_closure * | action, | |||
int | forw_flags | |||
) | [static] |
Replace *ap with a copy, perhaps with one additional element.
The old array is not modified. Empty slots are not copied.
Definition at line 960 of file ccn_client.c.
Referenced by handle_multifilt(), and update_multifilt().
static void ccn_age_interest | ( | struct ccn * | h, | |
struct expressed_interest * | interest, | |||
const unsigned char * | key, | |||
size_t | keysize | |||
) | [static] |
Definition at line 1763 of file ccn_client.c.
Referenced by ccn_process_scheduled_operations().
static int ccn_append_link_name | ( | struct ccn_charbuf * | name, | |
const unsigned char * | data, | |||
size_t | data_size | |||
) | [static] |
Get the name out of a Link.
XXX - this needs a better home.
Definition at line 1375 of file ccn_client.c.
Referenced by handle_key().
static int ccn_cache_key | ( | struct ccn * | h, | |
const unsigned char * | ccnb, | |||
size_t | size, | |||
struct ccn_parsed_ContentObject * | pco | |||
) | [static] |
Definition at line 1217 of file ccn_client.c.
Referenced by ccn_dispatch_message().
void ccn_check_interests | ( | struct expressed_interest * | list | ) |
Definition at line 511 of file ccn_client.c.
Referenced by ccn_clean_interests_by_prefix(), and ccn_process_scheduled_operations().
static int ccn_check_namebuf | ( | struct ccn * | h, | |
struct ccn_charbuf * | namebuf, | |||
int | prefix_comps, | |||
int | omit_possible_digest | |||
) | [static] |
Definition at line 593 of file ccn_client.c.
Referenced by ccn_express_interest(), and ccn_set_interest_filter_with_flags().
static void ccn_check_pub_arrival | ( | struct ccn * | h, | |
struct expressed_interest * | interest | |||
) | [static] |
If we were waiting for a key and it has arrived, refresh the interest.
Definition at line 1555 of file ccn_client.c.
Referenced by ccn_process_scheduled_operations().
int ccn_chk_signing_params | ( | struct ccn * | h, | |
const struct ccn_signing_params * | params, | |||
struct ccn_signing_params * | result, | |||
struct ccn_charbuf ** | ptimestamp, | |||
struct ccn_charbuf ** | pfinalblockid, | |||
struct ccn_charbuf ** | pkeylocator | |||
) |
This is mostly for use within the library, but may be useful for some clients.
Definition at line 2570 of file ccn_client.c.
Referenced by ccn_get_public_key(), ccn_sign_content(), ccnd_init_internal_keystore(), and ccnr_init_repo_keystore().
static void ccn_clean_all_interests | ( | struct ccn * | h | ) | [static] |
Definition at line 1833 of file ccn_client.c.
Referenced by ccn_process_scheduled_operations().
void ccn_clean_interests_by_prefix | ( | struct ccn * | h, | |
struct interests_by_prefix * | entry | |||
) |
Definition at line 523 of file ccn_client.c.
Referenced by ccn_clean_all_interests().
int ccn_connect | ( | struct ccn * | h, | |
const char * | name | |||
) |
Connect to local ccnd.
h | is a ccn library handle | |
name | is the name of the unix-domain socket to connect to, or the string "tcp[4|6][:port]" to indicate a TCP connection using either IPv4 (default) or IPv6 on the optional port; use NULL to get the default, which is affected by the environment variables CCN_LOCAL_TRANSPORT, interpreted as is name, and CCN_LOCAL_PORT if there is no port specified, or CCN_LOCAL_SOCKNAME and CCN_LOCAL_PORT. |
Definition at line 358 of file ccn_client.c.
Referenced by ccn_fetch_new(), ccn_get(), chat_main(), existingRootOp(), getFile(), main(), putFile(), putFileList(), r_init_create(), and sendSlice().
static void ccn_construct_interest | ( | struct ccn * | h, | |
struct ccn_charbuf * | name_prefix, | |||
struct ccn_charbuf * | interest_template, | |||
struct expressed_interest * | dest | |||
) | [static] |
Definition at line 629 of file ccn_client.c.
Referenced by ccn_express_interest().
struct ccn* ccn_create | ( | void | ) | [read] |
Create a client handle.
The new handle is not yet connected. On error, returns NULL and sets errno. Errors: ENOMEM
Definition at line 270 of file ccn_client.c.
Referenced by ccn_fetch_new(), ccn_get(), ccnd_internal_client_start(), ccnr_direct_client_start(), ccnr_internal_client_start(), chat_main(), existingRootOp(), getFile(), main(), putFile(), putFileList(), and sendSlice().
int ccn_defer_verification | ( | struct ccn * | h, | |
int | defer | |||
) |
Tell the library to defer verification.
For some specialized applications (performance testing being an example), the normal verification done within the library may be undesirable. Setting the "defer validation" flag will cause the library to pass content to the application without attempting to verify it. In this case, the CCN_UPCALL_CONTENT_RAW upcall kind will be passed instead of CCN_UPCALL_CONTENT, and CCN_UPCALL_CONTENT_KEYMISSING instead of CCN_UPCALL_CONTENT_UNVERIFIED. If the application wants do still do key fetches, it may use the CCN_UPCALL_RESULT_FETCHKEY response instead of CCN_UPCALL_RESULT_VERIFY.
Calling this while there are interests outstanding is not recommended.
This call is available beginning with CCN_API_VERSION 4004.
defer | is 0 to verify, 1 to defer, -1 to leave unchanged. |
Definition at line 333 of file ccn_client.c.
Referenced by getFile(), main(), r_init_create(), and SyncInit().
void ccn_destroy | ( | struct ccn ** | hp | ) |
Definition at line 544 of file ccn_client.c.
Referenced by ccn_fetch_destroy(), ccn_fetch_new(), ccn_get(), ccnd_internal_client_start(), ccnd_internal_client_stop(), ccnr_direct_client_start(), ccnr_direct_client_stop(), ccnr_internal_client_start(), ccnr_internal_client_stop(), existingRootOp(), getFile(), main(), putFile(), putFileList(), and sendSlice().
static struct expressed_interest* ccn_destroy_interest | ( | struct ccn * | h, | |
struct expressed_interest * | i | |||
) | [static, read] |
Definition at line 495 of file ccn_client.c.
Referenced by ccn_clean_interests_by_prefix(), and ccn_destroy().
static void ccn_digest_Content | ( | const unsigned char * | content_object, | |
struct ccn_parsed_ContentObject * | pc, | |||
unsigned char * | digest, | |||
size_t | digest_bytes | |||
) | [static] |
Compute the digest of just the Content portion of content_object.
Definition at line 1189 of file ccn_client.c.
Referenced by ccn_cache_key().
int ccn_disconnect | ( | struct ccn * | h | ) |
Definition at line 449 of file ccn_client.c.
Referenced by ccn_destroy(), ccn_fetch_destroy(), ccn_process_input(), ccn_run(), main(), r_init_create(), and r_io_shutdown_client_fd().
void ccn_dispatch_message | ( | struct ccn * | h, | |
unsigned char * | msg, | |||
size_t | size | |||
) |
Dispatch a message through the registered upcalls.
This is not used by normal ccn clients, but is made available for use when ccnd needs to communicate with its internal client.
h | is the ccn handle. | |
msg | is the ccnb-encoded Interest or ContentObject. | |
size | is its size in bytes. |
Definition at line 1576 of file ccn_client.c.
Referenced by ccn_process_input(), ccnd_send(), and r_io_send().
int ccn_express_interest | ( | struct ccn * | h, | |
struct ccn_charbuf * | namebuf, | |||
struct ccn_closure * | action, | |||
struct ccn_charbuf * | interest_template | |||
) |
Definition at line 671 of file ccn_client.c.
Referenced by ask_more(), ccn_get(), ccn_initiate_ccndid_fetch(), ccn_initiate_key_fetch(), ccn_initiate_prefix_reg(), ccns_send_root_advise_interest(), express_bulkdata_interest(), express_interest(), express_my_interest(), fill_holes(), handle_key(), incoming_content(), main(), me_too(), NeedSegment(), r_proto_expect_content(), r_proto_initiate_key_fetch(), r_proto_start_write(), SyncSendRootAdviseInterest(), SyncStartContentFetch(), and SyncStartNodeFetch().
int ccn_get | ( | struct ccn * | h, | |
struct ccn_charbuf * | name, | |||
struct ccn_charbuf * | interest_template, | |||
int | timeout_ms, | |||
struct ccn_charbuf * | resultbuf, | |||
struct ccn_parsed_ContentObject * | pcobuf, | |||
struct ccn_indexbuf * | compsbuf, | |||
int | flags | |||
) |
Get a single matching ContentObject This is a convenience for getting a single matching ContentObject.
Blocks until a matching ContentObject arrives or there is a timeout.
h | is the ccn handle. If NULL or ccn_get is called from inside an upcall, a new connection will be used and upcalls from other requests will not be processed while ccn_get is active. | |
name | holds a ccnb-encoded Name | |
interest_template | conveys other fields to be used in the interest (may be NULL). | |
timeout_ms | limits the time spent waiting for an answer (milliseconds). | |
resultbuf | is updated to contain the ccnb-encoded ContentObject. | |
pcobuf | may be supplied to save the client the work of re-parsing the ContentObject; may be NULL if this information is not actually needed. | |
compsbuf | works similarly. | |
flags | - CCN_GET_NOKEYWAIT means that it is permitted to return unverified data. |
Definition at line 2119 of file ccn_client.c.
Referenced by ccn_get_header(), ccn_resolve_version(), ccns_read_slice(), do_face_action(), existingRootOp(), get_ccndid(), getFile(), localStore(), main(), putFile(), putFileList(), register_unregister_prefix(), and write_slice().
const char* ccn_get_connect_type | ( | struct ccn * | h | ) |
Definition at line 441 of file ccn_client.c.
Referenced by ccn_get().
int ccn_get_connection_fd | ( | struct ccn * | h | ) |
Definition at line 423 of file ccn_client.c.
Referenced by ccnr_direct_client_refresh(), main(), r_dispatch_run(), r_init_create(), r_proto_answer_req(), r_proto_expect_content(), r_sync_upcall_store(), and wait_for_input_or_timeout().
static int ccn_get_content_type | ( | const unsigned char * | ccnb, | |
const struct ccn_parsed_ContentObject * | pco | |||
) | [static] |
Definition at line 1167 of file ccn_client.c.
Referenced by ccn_cache_key(), ccn_dispatch_message(), and handle_key().
int ccn_get_public_key | ( | struct ccn * | h, | |
const struct ccn_signing_params * | params, | |||
struct ccn_charbuf * | digest_result, | |||
struct ccn_charbuf * | result | |||
) |
Place the public key associated with the params into result buffer, and its digest into digest_result.
This is for one of our signing keys, not just any key. Result buffers may be NULL if the corresponding result is not wanted.
Definition at line 2518 of file ccn_client.c.
Referenced by ccnd_init_service_ccnb(), ccnr_init_policy_cob(), ccnr_init_policy_link_cob(), and ccnr_init_service_ccnb().
struct ccn_schedule* ccn_get_schedule | ( | struct ccn * | h | ) | [read] |
Get the previously set event schedule from a ccn handle.
h | is the ccn handle |
Definition at line 1872 of file ccn_client.c.
Referenced by ccns_open().
int ccn_geterror | ( | struct ccn * | h | ) |
Recover last error code.
h | is the ccn handle - may be NULL. |
Definition at line 212 of file ccn_client.c.
struct ccn_charbuf* ccn_grab_buffered_output | ( | struct ccn * | h | ) | [read] |
Definition at line 1137 of file ccn_client.c.
Referenced by process_internal_client_buffer(), and r_dispatch_process_internal_client_buffer().
static void ccn_gripe | ( | struct expressed_interest * | i | ) | [static] |
Definition at line 468 of file ccn_client.c.
Referenced by ccn_age_interest(), ccn_check_interests(), ccn_destroy_interest(), ccn_dispatch_message(), ccn_refresh_interest(), and replace_interest_msg().
static struct ccn_indexbuf* ccn_indexbuf_obtain | ( | struct ccn * | h | ) | [static, read] |
Definition at line 220 of file ccn_client.c.
Referenced by ccn_age_interest(), and ccn_dispatch_message().
static void ccn_indexbuf_release | ( | struct ccn * | h, | |
struct ccn_indexbuf * | c | |||
) | [static] |
Definition at line 231 of file ccn_client.c.
Referenced by ccn_age_interest(), and ccn_dispatch_message().
static void ccn_initiate_ccndid_fetch | ( | struct ccn * | h | ) | [static] |
Definition at line 2230 of file ccn_client.c.
Referenced by ccn_initiate_prefix_reg().
static int ccn_initiate_key_fetch | ( | struct ccn * | h, | |
unsigned char * | msg, | |||
struct ccn_parsed_ContentObject * | pco, | |||
struct expressed_interest * | trigger_interest | |||
) | [static] |
Definition at line 1480 of file ccn_client.c.
Referenced by ccn_dispatch_message().
static void ccn_initiate_prefix_reg | ( | struct ccn * | h, | |
const void * | prefix, | |||
size_t | prefix_size, | |||
struct interest_filter * | i | |||
) | [static] |
Definition at line 2309 of file ccn_client.c.
Referenced by ccn_process_scheduled_operations().
int ccn_is_final_block | ( | struct ccn_upcall_info * | info | ) |
Check whether content described by info is final block.
info | - the ccn_upcall_info describing the ContentObject |
Definition at line 2819 of file ccn_client.c.
Referenced by r_proto_expect_content().
int ccn_load_default_key | ( | struct ccn * | h, | |
const char * | keystore_path, | |||
const char * | keystore_passphrase | |||
) |
Load the handle's default signing key from a keystore.
This call is only required for applications that use something other than the user's default signing key as the handle's default. It should be called early and at most once.
h | is the ccn handle | |
keystore_path | is the pathname of the keystore file | |
keystore_passphrase | is the passphase needed to unlock the keystore |
Definition at line 2480 of file ccn_client.c.
Referenced by ccnd_init_internal_keystore(), and ccnr_init_repo_keystore().
int ccn_load_private_key | ( | struct ccn * | h, | |
const char * | keystore_path, | |||
const char * | keystore_passphrase, | |||
struct ccn_charbuf * | pubid_out | |||
) |
Load a private key from a keystore file.
This call is only required for applications that use something other than the user's default signing key.
h | is the ccn handle | |
keystore_path | is the pathname of the keystore file | |
keystore_passphrase | is the passphase needed to unlock the keystore | |
pubid_out,if | not NULL, is loaded with the digest of the public key |
Definition at line 2415 of file ccn_client.c.
Referenced by ccn_chk_signing_params(), and ccn_load_default_key().
static int ccn_locate_key | ( | struct ccn * | h, | |
const unsigned char * | msg, | |||
struct ccn_parsed_ContentObject * | pco, | |||
struct ccn_pkey ** | pubkey | |||
) | [static] |
Examine a ContentObject and try to find the public key needed to verify it.
It might be present in our cache of keys, or in the object itself; in either of these cases, we can satisfy the request right away. Or there may be an indirection (a KeyName), in which case return without the key. The final possibility is that there is no key locator we can make sense of.
Definition at line 1284 of file ccn_client.c.
Referenced by ccn_dispatch_message(), and ccn_verify_content().
static int ccn_note_err | ( | struct ccn * | h | ) | [static] |
Definition at line 181 of file ccn_client.c.
Referenced by ccn_seterror().
static void ccn_notify_ccndid_changed | ( | struct ccn * | h | ) | [static] |
Definition at line 1850 of file ccn_client.c.
Referenced by handle_ccndid_response().
int ccn_output_is_pending | ( | struct ccn * | h | ) |
Definition at line 1131 of file ccn_client.c.
Referenced by ccn_grab_buffered_output(), ccn_process_scheduled_operations(), ccn_run(), and r_io_prepare_poll_fds().
void ccn_perror | ( | struct ccn * | h, | |
const char * | s | |||
) |
Produce message on standard error output describing the last error encountered during a call using the given handle.
h | is the ccn handle - may not be NULL. | |
s | is a client-supplied message; if NULL a message will be supplied where available. |
Definition at line 166 of file ccn_client.c.
Referenced by ccn_create(), ccn_note_err(), ccn_resolve_version(), and main().
static int ccn_process_input | ( | struct ccn * | h | ) | [static] |
Definition at line 1699 of file ccn_client.c.
Referenced by ccn_run().
int ccn_process_scheduled_operations | ( | struct ccn * | h | ) |
Process any scheduled operations that are due.
This is not used by normal ccn clients, but is made available for use by ccnd to run its internal client.
h | is the ccn handle. |
Definition at line 1899 of file ccn_client.c.
Referenced by ccn_run(), ccnd_internal_client_refresh(), ccnr_direct_client_refresh(), ccnr_internal_client_refresh(), r_dispatch_run(), and wait_for_input_or_timeout().
static int ccn_pushout | ( | struct ccn * | h | ) | [static] |
Definition at line 1065 of file ccn_client.c.
Referenced by ccn_disconnect(), ccn_put(), and ccn_run().
int ccn_put | ( | struct ccn * | h, | |
const void * | p, | |||
size_t | length | |||
) |
Definition at line 1087 of file ccn_client.c.
Referenced by ccn_refresh_interest(), ccn_seqw_write(), ccnd_answer_req(), ccnr_answer_req(), incoming_interest(), interest_handler(), localStore(), main(), outgoing_content(), r_io_send(), r_proto_begin_enumeration(), r_proto_bulk_import(), r_proto_continue_enumeration(), r_proto_start_write(), r_proto_start_write_checked(), send_matching_data(), SendDeltasReply(), seqw_incoming_interest(), storeHandler(), SyncInterestArrived(), and write_interest_handler().
static void ccn_refresh_interest | ( | struct ccn * | h, | |
struct expressed_interest * | interest | |||
) | [static] |
Definition at line 1148 of file ccn_client.c.
Referenced by ccn_age_interest(), ccn_check_pub_arrival(), ccn_dispatch_message(), and ccn_express_interest().
static void ccn_replace_handler | ( | struct ccn * | h, | |
struct ccn_closure ** | dstp, | |||
struct ccn_closure * | src | |||
) | [static] |
Do the refcount updating for closure instances on assignment.
When the refcount drops to 0, the closure is told to finalize itself.
Definition at line 246 of file ccn_client.c.
Referenced by build_multifilt_array(), ccn_destroy(), ccn_destroy_interest(), ccn_dispatch_message(), ccn_express_interest(), ccn_process_scheduled_operations(), ccn_set_interest_filter_with_flags(), destroy_multifilt_array(), and update_multifilt().
int ccn_run | ( | struct ccn * | h, | |
int | timeout | |||
) |
Run the ccn client event loop.
This may serve as the main event loop for simple apps by passing a timeout value of -1.
h | is the ccn handle. | |
timeout | is in milliseconds. |
Definition at line 1977 of file ccn_client.c.
Referenced by ccn_dump_names(), ccn_fetch_poll(), ccn_get(), chat_main(), getFile(), main(), putFile(), putFileList(), r_dispatch_process_input(), r_link_do_deferred_write(), and write_slice().
void ccn_set_connect_type | ( | struct ccn * | h, | |
const char * | name | |||
) |
Definition at line 430 of file ccn_client.c.
Referenced by ccn_connect().
int ccn_set_interest_filter | ( | struct ccn * | h, | |
struct ccn_charbuf * | namebuf, | |||
struct ccn_closure * | action | |||
) |
Register to receive interests on a prefix.
The action will be called upon the arrival of an interest that has the given name as a prefix.
If action is NULL, any existing filter for the prefix is removed. Note that this may have undesirable effects in applications that share the same handle for independently operating subcomponents. See ccn_set_interest_filter_with_flags() for a way to deal with this.
The contents of namebuf are copied as needed.
The handler should return CCN_UPCALL_RESULT_INTEREST_CONSUMED as a promise that it has produced, or will soon produce, a matching content object.
The upcall kind passed to the handler will be CCN_UPCALL_INTEREST if no other handler has claimed to produce content, or else CCN_UPCALL_CONSUMED_INTEREST.
This call is equivalent to a call to ccn_set_interest_filter_with_flags, passing the forwarding flags (CCN_FORW_ACTIVE | CCN_FORW_CHILD_INHERIT).
Definition at line 818 of file ccn_client.c.
Referenced by ccn_seqw_close(), ccn_seqw_create(), ccnd_uri_listen(), ccnr_uri_listen(), chat_main(), main(), putFile(), r_proto_uri_listen(), SyncRegisterInterest(), SyncRegisterInterests(), and write_slice().
int ccn_set_interest_filter_with_flags | ( | struct ccn * | h, | |
struct ccn_charbuf * | namebuf, | |||
struct ccn_closure * | action, | |||
int | forw_flags | |||
) |
Register to receive interests on a prefix, with forwarding flags.
See ccn_set_interest_filter for a description of the basic operation.
The additional forw_flags argument offers finer control of which interests are forward to the application. Refer to doc/technical/Registration for details.
There may be multiple actions associated with the prefix. They will be called in an unspecified order. The flags passed to ccnd will be the inclusive-or of the flags associated with each action.
Passing a value of 0 for forw_flags will unregister just this specific action, leaving other actions untouched.
Definition at line 756 of file ccn_client.c.
Referenced by ccn_set_interest_filter(), and main().
int ccn_set_run_timeout | ( | struct ccn * | h, | |
int | timeout | |||
) |
Modify ccn_run timeout.
This may be called from an upcall to change the timeout value. Most often this will be used to set the timeout to zero so that ccn_run() will return control to the client.
h | is the ccn handle. | |
timeout | is in milliseconds. |
Definition at line 1961 of file ccn_client.c.
Referenced by CallMe(), handle_simple_incoming_content(), incoming_content(), incoming_interest(), and write_interest_handler().
struct ccn_schedule* ccn_set_schedule | ( | struct ccn * | h, | |
struct ccn_schedule * | schedule | |||
) | [read] |
Set the event schedule in a ccn handle.
h | is the ccn handle | |
schedule | is the new event schedule to be set in the handle |
Definition at line 1884 of file ccn_client.c.
Referenced by ccns_open().
int ccn_seterror | ( | struct ccn * | h, | |
int | error_code | |||
) |
Set the error code in a ccn handle.
h | is the ccn handle - may be NULL. | |
error_code | is the code to set. |
Definition at line 195 of file ccn_client.c.
Referenced by ccn_resolve_version(), and ccn_seqw_write().
int ccn_sign_content | ( | struct ccn * | h, | |
struct ccn_charbuf * | resultbuf, | |||
const struct ccn_charbuf * | name_prefix, | |||
const struct ccn_signing_params * | params, | |||
const void * | data, | |||
size_t | size | |||
) |
Create a signed ContentObject.
h | is the ccn handle | |
resultbuf | - result buffer to which the ContentObject will be appended | |
name_prefix | contains the ccnb-encoded name | |
params | describe the ancillary information needed | |
data | points to the raw content | |
size | is the size of the raw content, in bytes |
Definition at line 2729 of file ccn_client.c.
Referenced by ccn_initiate_prefix_reg(), ccnd_answer_req(), ccnd_init_service_ccnb(), ccnr_answer_req(), ccnr_init_policy_cob(), ccnr_init_policy_link_cob(), ccnr_init_service_ccnb(), do_face_action(), generate_cob(), localStore(), main(), r_proto_bulk_import(), r_proto_continue_enumeration(), r_proto_start_write(), r_proto_start_write_checked(), register_unregister_prefix(), seqw_next_cob(), storeHandler(), SyncSignBuf(), and write_slice().
static void ccn_update_refresh_us | ( | struct ccn * | h, | |
struct timeval * | tv | |||
) | [static] |
Definition at line 1747 of file ccn_client.c.
Referenced by ccn_process_scheduled_operations().
int ccn_verify_content | ( | struct ccn * | h, | |
const unsigned char * | msg, | |||
struct ccn_parsed_ContentObject * | pco | |||
) |
Verify a ContentObject using the public key from either the object itself or our cache of keys.
This routine does not attempt to fetch the public key if it is not at hand.
Definition at line 2386 of file ccn_client.c.
Referenced by ccnd_answer_req(), ccnr_answer_req(), handle_ccndid_response(), handle_prefix_reg_reply(), and SyncLocalRepoFetch().
static void destroy_multifilt_array | ( | struct ccn * | h, | |
struct multifilt_item ** | ap, | |||
int | n | |||
) | [static] |
Destroy a multifilt_array.
Definition at line 1004 of file ccn_client.c.
Referenced by handle_multifilt(), and update_multifilt().
static void finalize_interest_filter | ( | struct hashtb_enumerator * | e | ) | [static] |
Definition at line 728 of file ccn_client.c.
Referenced by ccn_set_interest_filter_with_flags().
static void finalize_keystore | ( | struct hashtb_enumerator * | e | ) | [static] |
Definition at line 2502 of file ccn_client.c.
Referenced by ccn_create().
static void finalize_pkey | ( | struct hashtb_enumerator * | e | ) | [static] |
Definition at line 1266 of file ccn_client.c.
Referenced by ccn_create().
static enum ccn_upcall_res handle_ccndid_response | ( | struct ccn_closure * | selfp, | |
enum ccn_upcall_kind | kind, | |||
struct ccn_upcall_info * | info | |||
) | [static] |
Upcall to handle response to fetch a ccndid.
Definition at line 2183 of file ccn_client.c.
Referenced by ccn_initiate_ccndid_fetch().
static enum ccn_upcall_res handle_key | ( | struct ccn_closure * | selfp, | |
enum ccn_upcall_kind | kind, | |||
struct ccn_upcall_info * | info | |||
) | [static] |
Called when we get an answer to a KeyLocator fetch issued by ccn_initiate_key_fetch.
This does not really have to do much, since the main content handling logic picks up the keys as they go by.
Definition at line 1404 of file ccn_client.c.
Referenced by ccn_initiate_key_fetch().
static enum ccn_upcall_res handle_multifilt | ( | struct ccn_closure * | selfp, | |
enum ccn_upcall_kind | kind, | |||
struct ccn_upcall_info * | info | |||
) | [static] |
Upcall to handle multifilt.
Definition at line 1022 of file ccn_client.c.
Referenced by update_multifilt().
static enum ccn_upcall_res handle_prefix_reg_reply | ( | struct ccn_closure * | selfp, | |
enum ccn_upcall_kind | kind, | |||
struct ccn_upcall_info * | info | |||
) | [static] |
Handle reply to a prefix registration request.
Definition at line 2247 of file ccn_client.c.
Referenced by ccn_initiate_prefix_reg().
static enum ccn_upcall_res handle_simple_incoming_content | ( | struct ccn_closure * | selfp, | |
enum ccn_upcall_kind | kind, | |||
struct ccn_upcall_info * | info | |||
) | [static] |
Upcall for implementing ccn_get().
Definition at line 2056 of file ccn_client.c.
Referenced by ccn_get().
static void replace_interest_msg | ( | struct expressed_interest * | interest, | |
struct ccn_charbuf * | cb | |||
) | [static] |
Definition at line 474 of file ccn_client.c.
Referenced by ccn_construct_interest(), ccn_destroy_interest(), ccn_dispatch_message(), and ccn_process_scheduled_operations().
static int tv_earlier | ( | const struct timeval * | a, | |
const struct timeval * | b | |||
) | [static] |
Compare two timvals.
Definition at line 149 of file ccn_client.c.
Referenced by ccn_process_scheduled_operations().
static void update_ifilt_flags | ( | struct ccn * | h, | |
struct interest_filter * | f, | |||
int | forw_flags | |||
) | [static] |
Change forwarding flags, triggering a refresh as needed.
Definition at line 829 of file ccn_client.c.
Referenced by ccn_set_interest_filter_with_flags(), and update_multifilt().
static int update_multifilt | ( | struct ccn * | h, | |
struct interest_filter * | f, | |||
struct ccn_closure * | action, | |||
int | forw_flags | |||
) | [static] |
Take care of the case of multiple filters registered on one prefix.
Avoid calling when either action or f->action is NULL.
Definition at line 878 of file ccn_client.c.
Referenced by ccn_set_interest_filter_with_flags().