ccn_buf_encoder.c File Reference

Support for constructing various ccnb-encoded objects. More...

Go to the source code of this file.

Functions

int ccn_signed_info_create (struct ccn_charbuf *c, const void *publisher_key_id, size_t publisher_key_id_size, const struct ccn_charbuf *timestamp, enum ccn_content_type type, int freshness, const struct ccn_charbuf *finalblockid, const struct ccn_charbuf *key_locator)
 Create SignedInfo.
static int ccn_encode_Signature (struct ccn_charbuf *buf, const char *digest_algorithm, const void *witness, size_t witness_size, const struct ccn_signature *signature, size_t signature_size)
int ccn_encode_ContentObject (struct ccn_charbuf *buf, const struct ccn_charbuf *Name, const struct ccn_charbuf *SignedInfo, const void *data, size_t size, const char *digest_algorithm, const struct ccn_pkey *private_key)
 Encode and sign a ContentObject.
int ccn_encode_StatusResponse (struct ccn_charbuf *buf, int errcode, const char *errtext)
int ccn_charbuf_append_tt (struct ccn_charbuf *c, size_t val, enum ccn_tt tt)
 Append a ccnb start marker.
int ccn_charbuf_append_closer (struct ccn_charbuf *c)
 Append a CCN_CLOSE.
int ccnb_append_number (struct ccn_charbuf *c, int nni)
 Append a non-negative integer as a UDATA.
int ccnb_append_timestamp_blob (struct ccn_charbuf *c, enum ccn_marker marker, intmax_t secs, int nsecs)
 Append a binary timestamp as a BLOB using the ccn binary Timestamp representation (12-bit fraction).
int ccnb_append_now_blob (struct ccn_charbuf *c, enum ccn_marker marker)
 Append a binary timestamp, using the current time.
int ccnb_element_begin (struct ccn_charbuf *c, enum ccn_dtag dtag)
 Append a start-of-element marker.
int ccnb_element_end (struct ccn_charbuf *c)
 Append an end-of-element marker.
int ccnb_append_tagged_blob (struct ccn_charbuf *c, enum ccn_dtag dtag, const void *data, size_t size)
 Append a tagged BLOB.
int ccnb_tagged_putf (struct ccn_charbuf *c, enum ccn_dtag dtag, const char *fmt,...)
 Append a tagged UDATA string, with printf-style formatting.
int ccnb_append_Link (struct ccn_charbuf *buf, const struct ccn_charbuf *name, const char *label, const struct ccn_charbuf *linkAuthenticator)
 Append a representation of a Link to a charbuf.


Detailed Description

Support for constructing various ccnb-encoded objects.

Part of the CCNx C Library.

Copyright (C) 2008, 2009, 2011 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_buf_encoder.c.


Function Documentation

int ccn_charbuf_append_closer ( struct ccn_charbuf c  ) 

int ccn_charbuf_append_tt ( struct ccn_charbuf c,
size_t  val,
enum ccn_tt  tt 
)

int ccn_encode_ContentObject ( struct ccn_charbuf buf,
const struct ccn_charbuf Name,
const struct ccn_charbuf SignedInfo,
const void *  data,
size_t  size,
const char *  digest_algorithm,
const struct ccn_pkey *  private_key 
)

Encode and sign a ContentObject.

Parameters:
buf is the output buffer where encoded object is written.
Name is the ccnb-encoded name from ccn_name_init and friends.
SignedInfo is the ccnb-encoded info from ccn_signed_info_create.
data pintes to the raw data to be encoded.
size is the size, in bytes, of the raw data to be encoded.
digest_algorithm may be NULL for default.
private_key is the private key to use for signing.
Returns:
0 for success or -1 for error.

Definition at line 160 of file ccn_buf_encoder.c.

Referenced by ccn_sign_content(), encode_message(), and main().

static int ccn_encode_Signature ( struct ccn_charbuf buf,
const char *  digest_algorithm,
const void *  witness,
size_t  witness_size,
const struct ccn_signature *  signature,
size_t  signature_size 
) [static]

Definition at line 110 of file ccn_buf_encoder.c.

Referenced by ccn_encode_ContentObject().

int ccn_encode_StatusResponse ( struct ccn_charbuf buf,
int  errcode,
const char *  errtext 
)

Definition at line 231 of file ccn_buf_encoder.c.

Referenced by ccnd_nack().

int ccn_signed_info_create ( struct ccn_charbuf c,
const void *  publisher_key_id,
size_t  publisher_key_id_size,
const struct ccn_charbuf timestamp,
enum ccn_content_type  type,
int  freshness,
const struct ccn_charbuf finalblockid,
const struct ccn_charbuf key_locator 
)

Create SignedInfo.

Parameters:
c is used to hold the result.
publisher_key_id points to the digest of the publisher key id.
publisher_key_id_size is the size in bytes(32) of the pub key digest
timestamp holds the timestamp, as a ccnb-encoded blob, or is NULL to use the current time.
type indicates the Type of the ContentObject.
freshness is the FreshnessSeconds value, or -1 to omit.
finalblockid holds the FinalBlockID, as a ccnb-encoded blob, or is NULL to omit.
key_locator is the ccnb-encoded KeyLocator element, or NULL to omit.
Returns:
0 for success or -1 for error.

Definition at line 48 of file ccn_buf_encoder.c.

Referenced by ccn_sign_content(), and main().

int ccnb_append_Link ( struct ccn_charbuf buf,
const struct ccn_charbuf name,
const char *  label,
const struct ccn_charbuf linkAuthenticator 
)

Append a representation of a Link to a charbuf.

Parameters:
buf is the output buffer where encoded link is written.
name is the ccnb-encoded name from ccn_name_init and friends.
label is a UTF-8 string in a ccn_charbuf.
linkAuthenticator is the ccnb-encoded LinkAuthenticator.
Returns:
0 for success or -1 for error.

Definition at line 473 of file ccn_buf_encoder.c.

Referenced by ccnr_init_policy_link_cob(), and main().

int ccnb_append_now_blob ( struct ccn_charbuf c,
enum ccn_marker  marker 
)

Append a binary timestamp, using the current time.

Like ccnb_append_timestamp_blob() but uses current time

Parameters:
c is the buffer to append to.
marker - see ccnb_append_timestamp_blob()
Returns:
0 for success or -1 for error.

Definition at line 355 of file ccn_buf_encoder.c.

Referenced by ccn_create_version(), and ccn_signed_info_create().

int ccnb_append_number ( struct ccn_charbuf c,
int  nni 
)

Append a non-negative integer as a UDATA.

Parameters:
c is the buffer to append to.
nni is a non-negative value.
Returns:
0 for success or -1 for error.

Definition at line 288 of file ccn_buf_encoder.c.

Referenced by main(), make_data_template(), and make_template().

int ccnb_append_tagged_blob ( struct ccn_charbuf c,
enum ccn_dtag  dtag,
const void *  data,
size_t  size 
)

Append a tagged BLOB.

This is a ccnb-encoded element with containing the BLOB as content

Parameters:
c is the buffer to append to.
dtag is the element's dtab
data points to the binary data
size is the size of the data, in bytes
Returns:
0 for success or -1 for error.

Definition at line 395 of file ccn_buf_encoder.c.

Referenced by appendExclusions(), appendLifetime(), ccn_encode_ContentObject(), ccnb_append_face_instance(), ccnb_append_forwarding_entry(), ccnb_append_header(), ccnd_append_debug_nonce(), main(), storeStablePoint(), SyncAppendElementInner(), and SyncNodeAppendLongHash().

int ccnb_append_timestamp_blob ( struct ccn_charbuf c,
enum ccn_marker  marker,
intmax_t  secs,
int  nsecs 
)

Append a binary timestamp as a BLOB using the ccn binary Timestamp representation (12-bit fraction).

Parameters:
c is the buffer to append to.
marker If marker >= 0, the low-order byte is used as a marker byte, useful for some content naming conventions (versioning, in particular).
secs - seconds since epoch
nsecs - nanoseconds
Returns:
0 for success or -1 for error.

Definition at line 316 of file ccn_buf_encoder.c.

Referenced by ccn_create_version(), and ccnb_append_now_blob().

int ccnb_element_begin ( struct ccn_charbuf c,
enum ccn_dtag  dtag 
)

int ccnb_element_end ( struct ccn_charbuf c  ) 

int ccnb_tagged_putf ( struct ccn_charbuf c,
enum ccn_dtag  dtag,
const char *  fmt,
  ... 
)

Append a tagged UDATA string, with printf-style formatting.

This is a ccnb-encoded element with containing UDATA as content.

Parameters:
c is the buffer to append to.
dtag is the element's dtab.
fmt is a printf-style format string, followed by its values
Returns:
0 for success or -1 for error.

Definition at line 421 of file ccn_buf_encoder.c.

Referenced by answer_highest(), answer_passive(), ccn_encode_StatusResponse(), ccn_initiate_key_fetch(), ccn_signed_info_create(), ccnb_append_face_instance(), ccnb_append_forwarding_entry(), ccnb_append_header(), handle_key(), incoming_content(), initialize_global_data(), local_scope_rm_template(), main(), make_template(), r_proto_append_repo_info(), r_proto_initiate_key_fetch(), r_proto_mktemplate(), r_proto_policy_append_basic(), r_proto_policy_append_namespace(), stuff_link_check(), SyncAppendTaggedNumber(), SyncGenInterest(), and SyncSignBuf().


Generated on Thu Feb 16 00:44:22 2012 for Content-Centric Networking in C by  doxygen 1.5.6