ccn_btree_content.c File Reference

Go to the source code of this file.

Defines

#define MYFETCH(p, f)   ccn_btree_fetchval(&((p)->f[0]), sizeof((p)->f))
 B-tree for indexing ccnx content objects.
#define MYSTORE(p, f, v)   ccn_btree_storeval(&((p)->f[0]), sizeof((p)->f), (v))
#define MYFETCH64(p, f)   ccn_btree_fetchval64(&((p)->f[0]), sizeof((p)->f))
#define MYSTORE64(p, f, v)   ccn_btree_storeval64(&((p)->f[0]), sizeof((p)->f), (v))

Functions

static uint_least64_t ccn_btree_fetchval64 (const unsigned char *p, int size)
static void ccn_btree_storeval64 (unsigned char *p, int size, uint_least64_t v)
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.
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.
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_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_append_component (struct ccn_charbuf *dst, const unsigned char *comp, size_t size)
 Append one component to a flatname.
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_flatname_next_comp (const unsigned char *flatname, size_t size)
 Parse the component delimiter from the start of 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.


Define Documentation

#define MYFETCH ( p,
 )     ccn_btree_fetchval(&((p)->f[0]), sizeof((p)->f))

B-tree for indexing ccnx content objects.

Definition at line 29 of file ccn_btree_content.c.

#define MYFETCH64 ( p,
 )     ccn_btree_fetchval64(&((p)->f[0]), sizeof((p)->f))

Definition at line 37 of file ccn_btree_content.c.

Referenced by ccn_btree_content_cobid().

#define MYSTORE ( p,
f,
 )     ccn_btree_storeval(&((p)->f[0]), sizeof((p)->f), (v))

Definition at line 33 of file ccn_btree_content.c.

#define MYSTORE64 ( p,
f,
 )     ccn_btree_storeval64(&((p)->f[0]), sizeof((p)->f), (v))

Definition at line 51 of file ccn_btree_content.c.

Referenced by ccn_btree_content_set_cobid(), and ccn_btree_insert_content().


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().

static uint_least64_t ccn_btree_fetchval64 ( const unsigned char *  p,
int  size 
) [static]

Definition at line 40 of file ccn_btree_content.c.

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().

static void ccn_btree_storeval64 ( unsigned char *  p,
int  size,
uint_least64_t  v 
) [static]

Definition at line 54 of file ccn_btree_content.c.

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

Append one component to a flatname.

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:21 2012 for Content-Centric Networking in C by  doxygen 1.5.6