CCNx-Android-Services/jni/csrc/ccnr/ccnr_store.c File Reference

Part of ccnr - CCNx Repository Daemon. More...

#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <netdb.h>
#include <poll.h>
#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <ccn/bloom.h>
#include <ccn/btree_content.h>
#include <ccn/ccn.h>
#include <ccn/ccn_private.h>
#include <ccn/charbuf.h>
#include <ccn/face_mgmt.h>
#include <ccn/hashtb.h>
#include <ccn/indexbuf.h>
#include <ccn/schedule.h>
#include <ccn/reg_mgmt.h>
#include <ccn/uri.h>
#include "ccnr_private.h"
#include "ccnr_stats.h"
#include "ccnr_store.h"
#include "ccnr_init.h"
#include "ccnr_link.h"
#include "ccnr_util.h"
#include "ccnr_proto.h"
#include "ccnr_msg.h"
#include "ccnr_sync.h"
#include "ccnr_match.h"
#include "ccnr_sendq.h"
#include "ccnr_io.h"

Classes

struct  content_entry

Defines

#define FAILIF(cond)   do {} while ((cond) && r_store_fatal(h, __func__, __LINE__))
#define CHKSYS(res)   FAILIF((res) == -1)
#define CHKRES(res)   FAILIF((res) < 0)
#define CHKPTR(p)   FAILIF((p) == NULL)
#define CCN_BT_CLEAN_BATCH   3
 Number of btree index writes to do in a batch.
#define CCN_BT_CLEAN_TICK_MICROS   65536
 Approximate delay between batches of btree index writes.

Functions

static int r_store_set_flatname (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco)
 Parses content object and sets content->flatname.
static int r_store_content_btree_insert (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco, ccnr_accession *accp)
static int r_store_fatal (struct ccnr_handle *h, const char *fn, int lineno)
PUBLIC ccnr_accession r_store_content_accession (struct ccnr_handle *h, struct content_entry *content)
PUBLIC ccnr_cookie r_store_content_cookie (struct ccnr_handle *h, struct content_entry *content)
PUBLIC size_t r_store_content_size (struct ccnr_handle *h, struct content_entry *content)
static off_t r_store_offset_from_accession (struct ccnr_handle *h, ccnr_accession a)
static unsigned r_store_repofile_from_accession (struct ccnr_handle *h, ccnr_accession a)
static const unsigned char * r_store_content_mapped (struct ccnr_handle *h, struct content_entry *content)
static const unsigned char * r_store_content_read (struct ccnr_handle *h, struct content_entry *content)
PUBLIC int r_store_content_trim (struct ccnr_handle *h, struct content_entry *content)
 If the content appears to be safely stored in the repository, removes any buffered copy.
PUBLIC void r_store_trim (struct ccnr_handle *h, unsigned long limit)
 Evict recoverable content from in-memory buffers.
PUBLIC const unsigned char * r_store_content_base (struct ccnr_handle *h, struct content_entry *content)
 Get the base address of the content object.
PUBLIC int r_store_name_append_components (struct ccn_charbuf *dst, struct ccnr_handle *h, struct content_entry *content, int skip, int count)
PUBLIC int r_store_content_flags (struct content_entry *content)
PUBLIC int r_store_content_change_flags (struct content_entry *content, int set, int clear)
static int r_store_write_stable_point (struct ccnr_handle *h)
 Write a file named index/stable that contains the size of repoFile1 when the repository is shut down.
static void r_store_read_stable_point (struct ccnr_handle *h)
 Read the former size of repoFile1 from index/stable, and remove the latter.
static int r_store_reindexing (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Log a bit if we are taking a while to re-index.
static unsigned choose_limit (unsigned l, unsigned m)
 Select power of 2 between l and m + 1 (if possible).
PUBLIC void r_store_init (struct ccnr_handle *h)
PUBLIC int r_store_final (struct ccnr_handle *h, int stable)
PUBLIC struct content_entry * r_store_content_from_accession (struct ccnr_handle *h, ccnr_accession accession)
PUBLIC struct content_entry * r_store_content_from_cookie (struct ccnr_handle *h, ccnr_cookie cookie)
PUBLIC ccnr_cookie r_store_enroll_content (struct ccnr_handle *h, struct content_entry *content)
 This makes a cookie for content, and, if it has an accession number already, enters it into the content_by_accession_tab.
PUBLIC void r_store_forget_content (struct ccnr_handle *h, struct content_entry **pentry)
 Remove internal representation of a content object.
static struct content_entry * r_store_look (struct ccnr_handle *h, const unsigned char *key, size_t size)
 Get a handle on the content object that matches key, or if there is no match, the one that would come just after it.
PUBLIC struct content_entry * r_store_find_first_match_candidate (struct ccnr_handle *h, const unsigned char *interest_msg, const struct ccn_parsed_interest *pi)
PUBLIC int r_store_content_matches_interest_prefix (struct ccnr_handle *h, struct content_entry *content, const unsigned char *interest_msg, size_t interest_size)
PUBLIC struct content_entry * r_store_content_next (struct ccnr_handle *h, struct content_entry *content)
PUBLIC struct content_entry * r_store_next_child_at_level (struct ccnr_handle *h, struct content_entry *content, int level)
PUBLIC struct content_entry * r_store_lookup (struct ccnr_handle *h, const unsigned char *msg, const struct ccn_parsed_interest *pi, struct ccn_indexbuf *comps)
PUBLIC struct content_entry * r_store_lookup_ccnb (struct ccnr_handle *h, const unsigned char *namish, size_t size)
 Find the first content handle that matches the prefix given by the namish, which may be a Name, Interest, ContentObject, .
PUBLIC void r_store_mark_stale (struct ccnr_handle *h, struct content_entry *content)
 Mark content as stale.
static int expire_content (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Scheduled event that makes content stale when its FreshnessSeconds has expired.
PUBLIC void r_store_set_content_timer (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco)
 Schedules content expiration based on its FreshnessSeconds.
PUBLIC struct ccn_charbuf * r_store_content_flatname (struct ccnr_handle *h, struct content_entry *content)
 Get the flatname associated with content.
PUBLIC struct content_entry * process_incoming_content (struct ccnr_handle *h, struct fdholder *fdholder, unsigned char *msg, size_t size)
PUBLIC int r_store_content_field_access (struct ccnr_handle *h, struct content_entry *content, enum ccn_dtag dtag, const unsigned char **bufp, size_t *sizep)
PUBLIC int r_store_set_accession_from_offset (struct ccnr_handle *h, struct content_entry *content, struct fdholder *fdholder, off_t offset)
PUBLIC void r_store_send_content (struct ccnr_handle *h, struct fdholder *fdholder, struct content_entry *content)
PUBLIC int r_store_commit_content (struct ccnr_handle *h, struct content_entry *content)
PUBLIC void ccnr_debug_content (struct ccnr_handle *h, int lineno, const char *msg, struct fdholder *fdholder, struct content_entry *content)
static int r_store_index_cleaner (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
PUBLIC void r_store_index_needs_cleaning (struct ccnr_handle *h)

Variables

static const unsigned char * bogon = NULL
const ccnr_accession r_store_mark_repoFile1 = ((ccnr_accession)1) << 48


Detailed Description

Part of ccnr - CCNx Repository Daemon.


Function Documentation

PUBLIC const unsigned char* r_store_content_base ( struct ccnr_handle *  h,
struct content_entry *  content 
)

Get the base address of the content object.

This may involve reading the object in. Caller should not assume that the address will stay valid after it relinquishes control, either by returning or by calling routines that might invalidate objects.

static int r_store_content_btree_insert ( struct ccnr_handle *  h,
struct content_entry *  content,
struct ccn_parsed_ContentObject *  pco,
ccnr_accession *  accp 
) [static]

Returns:
2 if content was added to index, 1 if it was there but had no accession, 0 if it was already there, -1 for error

PUBLIC struct ccn_charbuf* r_store_content_flatname ( struct ccnr_handle *  h,
struct content_entry *  content 
) [read]

Get the flatname associated with content.

Returns:
flatname in a charbuf, which should be treated as read-only.

PUBLIC int r_store_content_trim ( struct ccnr_handle *  h,
struct content_entry *  content 
)

If the content appears to be safely stored in the repository, removes any buffered copy.

Returns:
0 if buffer was removed, -1 if not.

PUBLIC ccnr_cookie r_store_enroll_content ( struct ccnr_handle *  h,
struct content_entry *  content 
)

This makes a cookie for content, and, if it has an accession number already, enters it into the content_by_accession_tab.

Does not index by name.

static struct content_entry* r_store_look ( struct ccnr_handle *  h,
const unsigned char *  key,
size_t  size 
) [static, read]

Get a handle on the content object that matches key, or if there is no match, the one that would come just after it.

The key is in flatname format.

PUBLIC struct content_entry* r_store_lookup_ccnb ( struct ccnr_handle *  h,
const unsigned char *  namish,
size_t  size 
) [read]

Find the first content handle that matches the prefix given by the namish, which may be a Name, Interest, ContentObject, .

..

Does not check the other parts of namish, in particular, does not generate the digest component of a ContentObject.


Generated on Thu Feb 16 00:45:13 2012 for CCNx for Android by  doxygen 1.5.6