Go to the source code of this file.
Defines | |
#define | CCN_VERSION_TIMEOUT 8000 |
Streaming access for fetching segmented CCNx data. | |
#define | CCN_INTEREST_TIMEOUT_USECS 15000000 |
#define | MaxSuffixDefault 4 |
Typedefs | |
typedef intmax_t | seg_t |
typedef uint64_t | TimeMarker |
Functions | |
static TimeMarker | GetCurrentTimeUSecs (void) |
static intmax_t | DeltaTime (TimeMarker mt1, TimeMarker mt2) |
static enum ccn_upcall_res | CallMe (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info) |
static char * | newStringCopy (const char *src) |
static char * | freeString (char *s) |
static struct ccn_charbuf * | sequenced_name (struct ccn_charbuf *basename, seg_t seq) |
static struct ccn_charbuf * | make_data_template (int maxSuffix) |
static seg_t | GetNumberFromInfo (const unsigned char *ccnb, enum ccn_dtag tt, size_t start, size_t stop) |
static seg_t | GetFinalSegment (struct ccn_upcall_info *info) |
static struct localClosure * | AddSegRequest (struct ccn_fetch_stream *fs, seg_t seg) |
static struct localClosure * | RemSegRequest (struct ccn_fetch_stream *fs, struct localClosure *req) |
static struct ccn_fetch_buffer * | FindBufferForSeg (struct ccn_fetch_stream *fs, seg_t seg) |
static struct ccn_fetch_buffer * | FindBufferForPosition (struct ccn_fetch_stream *fs, intmax_t pos) |
static intmax_t | InferPosition (struct ccn_fetch_stream *fs, seg_t seg) |
static struct ccn_fetch_buffer * | NewBufferForSeg (struct ccn_fetch_stream *fs, seg_t seg, size_t len) |
static void | PruneSegments (struct ccn_fetch_stream *fs) |
static void | NeedSegment (struct ccn_fetch_stream *fs, seg_t seg) |
static void | NeedSegments (struct ccn_fetch_stream *fs) |
static void | ShowDelta (FILE *f, TimeMarker from) |
struct ccn_fetch * | ccn_fetch_new (struct ccn *h) |
Creates a new ccn_fetch object using the given ccn connection. | |
void | ccn_fetch_set_debug (struct ccn_fetch *f, FILE *debug, ccn_fetch_flags flags) |
Sets the destination for debug output. | |
struct ccn_fetch * | ccn_fetch_destroy (struct ccn_fetch *f) |
Destroys a ccn_fetch object. | |
int | ccn_fetch_poll (struct ccn_fetch *f) |
Polls the underlying streams and attempts to make progress. | |
struct ccn_fetch_stream * | ccn_fetch_next (struct ccn_fetch *f, struct ccn_fetch_stream *fs) |
Provides an iterator through the underlying streams. | |
struct ccn * | ccn_fetch_get_ccn (struct ccn_fetch *f) |
struct ccn_fetch_stream * | ccn_fetch_open (struct ccn_fetch *f, struct ccn_charbuf *name, const char *id, struct ccn_charbuf *interestTemplate, int maxBufs, int resolveVersion, int assumeFixed) |
Creates a stream for a named interest. | |
struct ccn_fetch_stream * | ccn_fetch_close (struct ccn_fetch_stream *fs) |
Closes the stream and reclaims any resources used by the stream. | |
intmax_t | ccn_fetch_avail (struct ccn_fetch_stream *fs) |
Tests for available bytes in the stream. | |
intmax_t | ccn_fetch_read (struct ccn_fetch_stream *fs, void *buf, intmax_t len) |
Reads bytes from a stream. | |
void | ccn_reset_timeout (struct ccn_fetch_stream *fs) |
Resets the timeout marker. | |
int | ccn_fetch_seek (struct ccn_fetch_stream *fs, intmax_t pos) |
Seeks to a position in a stream. | |
intmax_t | ccn_fetch_position (struct ccn_fetch_stream *fs) |
Variables | |
static char * | globalNullString = "" |
#define CCN_INTEREST_TIMEOUT_USECS 15000000 |
Definition at line 49 of file ccn_fetch.c.
Referenced by ccn_fetch_open().
#define CCN_VERSION_TIMEOUT 8000 |
Streaming access for fetching segmented CCNx data.
Supports multiple streams from a single connection and seeking to an arbitrary position within the associated file.
TBD: need to fix up the case where a segment cannot be fetched but we are not really at the end of the stream data. This case can occur if we express an interest for a segment and the interest times out. Current behavior is to treat this as an end-of-stream (prematurely and silently)
TBD: need to provide a more principled (or maybe just controlled) way to handle interest timeouts.
Definition at line 48 of file ccn_fetch.c.
Referenced by ccn_fetch_open().
#define MaxSuffixDefault 4 |
Definition at line 50 of file ccn_fetch.c.
Referenced by ccn_fetch_open().
typedef intmax_t seg_t |
Definition at line 52 of file ccn_fetch.c.
typedef uint64_t TimeMarker |
Definition at line 54 of file ccn_fetch.c.
static struct localClosure* AddSegRequest | ( | struct ccn_fetch_stream * | fs, | |
seg_t | seg | |||
) | [static, read] |
Definition at line 213 of file ccn_fetch.c.
Referenced by NeedSegment().
static enum ccn_upcall_res CallMe | ( | struct ccn_closure * | selfp, | |
enum ccn_upcall_kind | kind, | |||
struct ccn_upcall_info * | info | |||
) | [static] |
Definition at line 467 of file ccn_fetch.c.
Referenced by NeedSegment().
intmax_t ccn_fetch_avail | ( | struct ccn_fetch_stream * | fs | ) |
Tests for available bytes in the stream.
Determines how many bytes can be read on the given stream without waiting (via ccn_fetch_poll).
Definition at line 902 of file ccn_fetch.c.
Referenced by ccn_fetch_poll().
struct ccn_fetch_stream* ccn_fetch_close | ( | struct ccn_fetch_stream * | fs | ) | [read] |
Closes the stream and reclaims any resources used by the stream.
The stream object will be freed, so the client must not access it again.
Definition at line 842 of file ccn_fetch.c.
Referenced by ccn_fetch_destroy(), ElemDone(), and main().
struct ccn_fetch* ccn_fetch_destroy | ( | struct ccn_fetch * | f | ) | [read] |
Destroys a ccn_fetch object.
Only destroys the underlying ccn connection if it was automatically created. Forces all underlying streams to close immediately.
Definition at line 659 of file ccn_fetch.c.
Referenced by main().
struct ccn* ccn_fetch_get_ccn | ( | struct ccn_fetch * | f | ) | [read] |
Definition at line 735 of file ccn_fetch.c.
struct ccn_fetch* ccn_fetch_new | ( | struct ccn * | h | ) | [read] |
Creates a new ccn_fetch object using the given ccn connection.
If h == NULL, attempts to create a new connection automatically.
Definition at line 630 of file ccn_fetch.c.
Referenced by main().
struct ccn_fetch_stream* ccn_fetch_next | ( | struct ccn_fetch * | f, | |
struct ccn_fetch_stream * | fs | |||
) | [read] |
Provides an iterator through the underlying streams.
Use fs == NULL to start the iteration, and an existing stream to continue the iteration.
Definition at line 717 of file ccn_fetch.c.
struct ccn_fetch_stream* ccn_fetch_open | ( | struct ccn_fetch * | f, | |
struct ccn_charbuf * | name, | |||
const char * | id, | |||
struct ccn_charbuf * | interestTemplate, | |||
int | maxBufs, | |||
int | resolveVersion, | |||
int | assumeFixed | |||
) | [read] |
Creates a stream for a named interest.
The name should be a ccnb encoded interest. If resolveVersion, then we assume that the version is unresolved, and an attempt is made to determine the version number using the highest version. The number of buffers (nBufs) may be silently limited.
Definition at line 750 of file ccn_fetch.c.
int ccn_fetch_poll | ( | struct ccn_fetch * | f | ) |
Polls the underlying streams and attempts to make progress.
Scans the streams for those that have data already present, or are at the end of the stream. If the count is 0, perfoms a ccn_poll on the underlying ccn connection with a 0 timeout.
NOTE: periodic calls to ccn_fetch_poll should be performed to update the contents of the streams UNLESS the client is calling ccn_run for the underlying ccn connection.
Definition at line 693 of file ccn_fetch.c.
Referenced by runTest().
intmax_t ccn_fetch_position | ( | struct ccn_fetch_stream * | fs | ) |
Definition at line 1089 of file ccn_fetch.c.
intmax_t ccn_fetch_read | ( | struct ccn_fetch_stream * | fs, | |
void * | buf, | |||
intmax_t | len | |||
) |
Reads bytes from a stream.
Reads at most len bytes into buf from the given stream. Will not wait for bytes to arrive. Advances the read position on a successful read.
Definition at line 954 of file ccn_fetch.c.
int ccn_fetch_seek | ( | struct ccn_fetch_stream * | fs, | |
intmax_t | pos | |||
) |
Seeks to a position in a stream.
Sets the read position. It is strongly recommended that the seek is only done to a position that is either 0 or has resulted from a successful read. Otherwise end of stream indicators may be returned for a seek beyond the end.
Definition at line 1041 of file ccn_fetch.c.
void ccn_fetch_set_debug | ( | struct ccn_fetch * | f, | |
FILE * | debug, | |||
ccn_fetch_flags | flags | |||
) |
Sets the destination for debug output.
NULL disables debug output.
Definition at line 647 of file ccn_fetch.c.
Referenced by main().
void ccn_reset_timeout | ( | struct ccn_fetch_stream * | fs | ) |
Resets the timeout marker.
Resets the timeout indicator, which will cause pending interests to be retried.
Definition at line 1027 of file ccn_fetch.c.
static intmax_t DeltaTime | ( | TimeMarker | mt1, | |
TimeMarker | mt2 | |||
) | [static] |
Definition at line 65 of file ccn_fetch.c.
Referenced by CallMe(), and ShowDelta().
static struct ccn_fetch_buffer* FindBufferForPosition | ( | struct ccn_fetch_stream * | fs, | |
intmax_t | pos | |||
) | [static, read] |
Definition at line 290 of file ccn_fetch.c.
Referenced by ccn_fetch_seek().
static struct ccn_fetch_buffer* FindBufferForSeg | ( | struct ccn_fetch_stream * | fs, | |
seg_t | seg | |||
) | [static, read] |
Definition at line 278 of file ccn_fetch.c.
Referenced by CallMe(), ccn_fetch_avail(), ccn_fetch_read(), InferPosition(), NeedSegment(), and NewBufferForSeg().
static char* freeString | ( | char * | s | ) | [static] |
Definition at line 144 of file ccn_fetch.c.
Referenced by ccn_fetch_close(), and ccn_fetch_open().
static TimeMarker GetCurrentTimeUSecs | ( | void | ) | [static] |
Definition at line 57 of file ccn_fetch.c.
Referenced by AddSegRequest(), CallMe(), and ShowDelta().
static seg_t GetFinalSegment | ( | struct ccn_upcall_info * | info | ) | [static] |
Definition at line 200 of file ccn_fetch.c.
Referenced by CallMe().
static seg_t GetNumberFromInfo | ( | const unsigned char * | ccnb, | |
enum ccn_dtag | tt, | |||
size_t | start, | |||
size_t | stop | |||
) | [static] |
Definition at line 176 of file ccn_fetch.c.
Referenced by GetFinalSegment().
static intmax_t InferPosition | ( | struct ccn_fetch_stream * | fs, | |
seg_t | seg | |||
) | [static] |
Definition at line 303 of file ccn_fetch.c.
Referenced by CallMe(), and NewBufferForSeg().
static struct ccn_charbuf* make_data_template | ( | int | maxSuffix | ) | [static, read] |
Definition at line 161 of file ccn_fetch.c.
Referenced by ccn_fetch_open().
static void NeedSegment | ( | struct ccn_fetch_stream * | fs, | |
seg_t | seg | |||
) | [static] |
Definition at line 385 of file ccn_fetch.c.
Referenced by ccn_fetch_open(), ccn_fetch_seek(), and NeedSegments().
static void NeedSegments | ( | struct ccn_fetch_stream * | fs | ) | [static] |
Definition at line 444 of file ccn_fetch.c.
Referenced by ccn_fetch_read().
static struct ccn_fetch_buffer* NewBufferForSeg | ( | struct ccn_fetch_stream * | fs, | |
seg_t | seg, | |||
size_t | len | |||
) | [static, read] |
Definition at line 324 of file ccn_fetch.c.
Referenced by CallMe().
static char* newStringCopy | ( | const char * | src | ) | [static] |
Definition at line 135 of file ccn_fetch.c.
Referenced by ccn_fetch_open().
static void PruneSegments | ( | struct ccn_fetch_stream * | fs | ) | [static] |
Definition at line 359 of file ccn_fetch.c.
Referenced by ccn_fetch_close(), ccn_fetch_read(), and ccn_fetch_seek().
static struct localClosure* RemSegRequest | ( | struct ccn_fetch_stream * | fs, | |
struct localClosure * | req | |||
) | [static, read] |
Definition at line 241 of file ccn_fetch.c.
Referenced by CallMe(), and NeedSegment().
static struct ccn_charbuf* sequenced_name | ( | struct ccn_charbuf * | basename, | |
seg_t | seq | |||
) | [static, read] |
Definition at line 151 of file ccn_fetch.c.
Referenced by NeedSegment().
static void ShowDelta | ( | FILE * | f, | |
TimeMarker | from | |||
) | [static] |
Definition at line 460 of file ccn_fetch.c.
Referenced by CallMe().
char* globalNullString = "" [static] |
Definition at line 133 of file ccn_fetch.c.
Referenced by freeString(), and newStringCopy().