btree_content.h File Reference

Storage of a content index in a btree. More...

Go to the source code of this file.

Data Structures

struct  ccn_btree_content_payload
 Structure of the entry payload within a leaf node. More...
struct  ccn_btree_content_entry
 Logical structure of the entry within a leaf node. More...

Defines

#define CCN_BT_CONTENT_MAGIC   0xC0
#define CCN_RCFLAG_LASTBLOCK   0x80
#define CCN_RCFLAG_STALE   0x01
#define CCNFLATDELIMSZ(rnc)   ((rnc) & 3)
 Get delimiter size from return value of ccn_flatname_next_comp.
#define CCNFLATDATASZ(rnc)   ((rnc) >> 2)
 Get data size from return value of ccn_flatname_next_comp.
#define CCNFLATSKIP(rnc)   (CCNFLATDELIMSZ(rnc) + CCNFLATDATASZ(rnc))
 Get total delimited size from return value of ccn_flatname_next_comp.

Functions

int ccn_btree_match_interest (struct ccn_btree_node *node, int ndx, const unsigned char *interest_msg, const struct ccn_parsed_interest *pi, struct ccn_charbuf *scratch)
 Test for a match between the ContentObject described by a btree index entry and an Interest, assuming that it is already known that there is a prefix match.
int ccn_btree_insert_content (struct ccn_btree_node *node, int ndx, uint_least64_t cobid, const unsigned char *content_object, struct ccn_parsed_ContentObject *pc, struct ccn_charbuf *flatname)
 Insert a ContentObject into a btree node.
uint_least64_t ccn_btree_content_cobid (struct ccn_btree_node *node, int ndx)
 Get cobid from btree entry.
int ccn_btree_content_set_cobid (struct ccn_btree_node *node, int ndx, uint_least64_t cobid)
 Set cobid in a btree entry.
int ccn_btree_content_cobsz (struct ccn_btree_node *node, int ndx)
 Get ContentObject size from btree entry.
int ccn_flatname_append_component (struct ccn_charbuf *dst, const unsigned char *comp, size_t size)
 Flat name representation.
int ccn_flatname_append_from_ccnb (struct ccn_charbuf *dst, const unsigned char *ccnb, size_t size, int skip, int count)
 Append Components from a ccnb-encoded Name to a flatname.
int ccn_flatname_from_ccnb (struct ccn_charbuf *dst, const unsigned char *ccnb, size_t size)
 Convert a ccnb-encoded Name to a flatname.
int ccn_name_append_flatname (struct ccn_charbuf *dst, const unsigned char *flatname, size_t size, int skip, int count)
 Append Components from a flatname to a ccnb-encoded Name.
int ccn_uri_append_flatname (struct ccn_charbuf *uri, const unsigned char *flatname, size_t size, int includescheme)
 Like ccn_uri_append(), but accepts a flatname instead of ccnb.
int ccn_flatname_ncomps (const unsigned char *flatname, size_t size)
 Get flatname component count.
int ccn_flatname_charbuf_compare (struct ccn_charbuf *a, struct ccn_charbuf *b)
 Compare flatnames a and b.
int ccn_flatname_compare (const unsigned char *a, size_t al, const unsigned char *b, size_t bl)
 Compare flatnames a and b (raw version).
int ccn_flatname_next_comp (const unsigned char *flatname, size_t size)
 Parse the component delimiter from the start of a flatname.


Detailed Description

Storage of a content index in a btree.

Definition in file btree_content.h.


Define Documentation

#define CCN_BT_CONTENT_MAGIC   0xC0

Definition at line 47 of file btree_content.h.

Referenced by ccn_btree_insert_content(), and ccn_btree_match_interest().

#define CCN_RCFLAG_LASTBLOCK   0x80

Definition at line 48 of file btree_content.h.

#define CCN_RCFLAG_STALE   0x01

Definition at line 49 of file btree_content.h.

#define CCNFLATDATASZ ( rnc   )     ((rnc) >> 2)

Get data size from return value of ccn_flatname_next_comp.

Definition at line 139 of file btree_content.h.

Referenced by ccn_btree_match_interest(), and ccn_name_append_flatname().

#define CCNFLATDELIMSZ ( rnc   )     ((rnc) & 3)

Get delimiter size from return value of ccn_flatname_next_comp.

Definition at line 137 of file btree_content.h.

Referenced by ccn_btree_match_interest(), and ccn_name_append_flatname().

#define CCNFLATSKIP ( rnc   )     (CCNFLATDELIMSZ(rnc) + CCNFLATDATASZ(rnc))

Get total delimited size from return value of ccn_flatname_next_comp.

Definition at line 141 of file btree_content.h.

Referenced by ccn_btree_match_interest(), ccn_flatname_ncomps(), and ccn_name_append_flatname().


Function Documentation

uint_least64_t ccn_btree_content_cobid ( struct ccn_btree_node node,
int  ndx 
)

Get cobid from btree entry.

Returns:
the cobid field of the indexed entry of node, or 0 if error.

Definition at line 291 of file ccn_btree_content.c.

Referenced by r_store_content_btree_insert(), and r_store_look().

int ccn_btree_content_cobsz ( struct ccn_btree_node node,
int  ndx 
)

Get ContentObject size from btree entry.

Returns:
the cobsz field of the indexed entry of node, or -1 if error.

Definition at line 330 of file ccn_btree_content.c.

Referenced by r_store_look().

int ccn_btree_content_set_cobid ( struct ccn_btree_node node,
int  ndx,
uint_least64_t  cobid 
)

Set cobid in a btree entry.

Returns:
0 for success, -1 for failure

Definition at line 308 of file ccn_btree_content.c.

Referenced by r_store_set_accession_from_offset().

int ccn_btree_insert_content ( struct ccn_btree_node node,
int  ndx,
uint_least64_t  cobid,
const unsigned char *  content_object,
struct ccn_parsed_ContentObject pc,
struct ccn_charbuf flatname 
)

Insert a ContentObject into a btree node.

The caller has presumably already done a lookup and found that the object is not there.

The caller is responsible for provinding a valid content parse (pc).

The flatname buffer should hold the correct full name, including the digest.

Returns:
the new entry count or, -1 for error.

Definition at line 76 of file ccn_btree_content.c.

Referenced by r_store_content_btree_insert(), and test_insert_content().

int ccn_btree_match_interest ( struct ccn_btree_node node,
int  ndx,
const unsigned char *  interest_msg,
const struct ccn_parsed_interest pi,
struct ccn_charbuf scratch 
)

Test for a match between the ContentObject described by a btree index entry and an Interest, assuming that it is already known that there is a prefix match.

This does not need access to the actual ContentObject, since the index entry contains everything that we know to know to do the match.

Parameters:
node leaf node
ndx index of entry within leaf node
interest_msg ccnb-encoded Interest
pi corresponding parsed interest
scratch for scratch use
Returns:
1 for match, 0 for no match, -1 for error.

Definition at line 143 of file ccn_btree_content.c.

Referenced by r_store_lookup(), r_sync_enumerate_action(), and testhelp_count_matches().

int ccn_flatname_append_component ( struct ccn_charbuf dst,
const unsigned char *  comp,
size_t  size 
)

Flat name representation.

Within the btree-based index, the name is stored in a representation different than the ccnb encoding that is used on the wire. This encoding is designed so that simple lexical ordering on flatname byte arrays corresponds precisely with ccn's CanonicalOrdering of Names.

In the flatname representation, the bytes that constitute each Component are prepended by a length indicator that occupies one or more bytes. The high-order bit is used to mark the end of the length indicator, with 0 marking the last byte. The low order 7 bits of each of these bytes are concatenated together, in big endian order, to form the length.

For example: 0x00 => the zero-length component 0x01 0x41 => the component "A" 0x7F 0xC1 ... => a component 127 bytes long that starts with "%C1" 0x81 0x00 0x39 ... => a component 128 bytes long that starts with "9" 0xff 0x3F 0x30 ... => a component 16383 bytes long that starts with "0"

Length indicators larger than this are possible in theory, but unlikely to come up in practice. Nontheless, we do allow 3-byte length indicators.

Flat name representation.

Returns:
0, or -1 if there is an error.

Definition at line 379 of file ccn_btree_content.c.

Referenced by ccn_flatname_append_from_ccnb(), r_store_set_flatname(), and test_insert_content().

int ccn_flatname_append_from_ccnb ( struct ccn_charbuf dst,
const unsigned char *  ccnb,
size_t  size,
int  skip,
int  count 
)

Append Components from a ccnb-encoded Name to a flatname.

The ccnb encoded input may be a ContentObject, Interest, Prefix, or Component instead of simply a Name.

Parameters:
dst is the destination, which should hold a ccnb-encoded Name
ccnb points to first byte of Name
size is the number of bytes in ccnb
skip is the number of components at the front of flatname to skip
count is the maximum number of componebts to append, or -1 for all
Returns:
number of appended components, or -1 if there is an error.

Definition at line 414 of file ccn_btree_content.c.

Referenced by ccn_flatname_from_ccnb(), r_store_find_first_match_candidate(), and test_flatname().

int ccn_flatname_charbuf_compare ( struct ccn_charbuf a,
struct ccn_charbuf b 
)

Compare flatnames a and b.

Returns:
negative, 0, or positive if a < b, a == b, a > b, respectively. The special return value -9999 means a < b and a is also a prefix of b. Similarly 9999 means b is a strict prefix of a. XXX should have defines for these values.

Definition at line 348 of file ccn_btree_content.c.

Referenced by r_store_content_matches_interest_prefix(), and r_store_lookup_ccnb().

int ccn_flatname_compare ( const unsigned char *  a,
size_t  al,
const unsigned char *  b,
size_t  bl 
)

Compare flatnames a and b (raw version).

Definition at line 357 of file ccn_btree_content.c.

Referenced by ccn_flatname_charbuf_compare().

int ccn_flatname_from_ccnb ( struct ccn_charbuf dst,
const unsigned char *  ccnb,
size_t  size 
)

Convert a ccnb-encoded Name to a flatname.

Returns:
number of components, or -1 if there is an error.

Definition at line 470 of file ccn_btree_content.c.

Referenced by r_store_content_matches_interest_prefix(), r_store_find_first_match_candidate(), r_store_lookup_ccnb(), r_store_next_child_at_level(), r_store_set_flatname(), test_flatname(), test_insert_content(), and testhelp_count_matches().

int ccn_flatname_ncomps ( const unsigned char *  flatname,
size_t  size 
)

Get flatname component count.

Returns:
the number of name components in the flatname, or -1 if the flatname is not well-formed

Definition at line 580 of file ccn_btree_content.c.

Referenced by ccn_btree_insert_content(), and test_flatname().

int ccn_flatname_next_comp ( const unsigned char *  flatname,
size_t  size 
)

Parse the component delimiter from the start of a flatname.

The delimiter size is limited to 3 bytes.

Returns:
-1 for error, 0 nothing left, or compsize * 4 + delimsize

Definition at line 484 of file ccn_btree_content.c.

Referenced by ccn_btree_match_interest(), ccn_flatname_ncomps(), and ccn_name_append_flatname().

int ccn_name_append_flatname ( struct ccn_charbuf dst,
const unsigned char *  flatname,
size_t  size,
int  skip,
int  count 
)

Append Components from a flatname to a ccnb-encoded Name.

Parameters:
dst is the destination, which should hold a ccnb-encoded Name
flatname points to first byte of flatname
size is the number of bytes in flatname
skip is the number of components at the front of flatname to skip
count is the maximum number of components to append, or -1 for all
Returns:
number of appended components, or -1 if there is an error.

Definition at line 513 of file ccn_btree_content.c.

Referenced by ccn_uri_append_flatname(), r_store_name_append_components(), r_store_next_child_at_level(), and test_flatname().

int ccn_uri_append_flatname ( struct ccn_charbuf uri,
const unsigned char *  flatname,
size_t  size,
int  includescheme 
)

Like ccn_uri_append(), but accepts a flatname instead of ccnb.

Definition at line 552 of file ccn_btree_content.c.

Referenced by ccnr_debug_content(), test_flatname(), and test_insert_content().


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