fetch.h File Reference

Streaming access for fetching segmented CCNx data. More...

Go to the source code of this file.

Defines

#define CCN_FETCH_READ_ZERO   (-3)
#define CCN_FETCH_READ_TIMEOUT   (-2)
#define CCN_FETCH_READ_NONE   (-1)
#define CCN_FETCH_READ_END   (0)

Enumerations

enum  ccn_fetch_flags {
  ccn_fetch_flags_None = 0, ccn_fetch_flags_NoteGlitch = 1, ccn_fetch_flags_NoteAddRem = 2, ccn_fetch_flags_NoteNeed = 4,
  ccn_fetch_flags_NoteFill = 8, ccn_fetch_flags_NoteFinal = 16, ccn_fetch_flags_NoteTimeout = 32, ccn_fetch_flags_NoteOpenClose = 64,
  ccn_fetch_flags_NoteAll = 0xffff
}

Functions

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 indicator, which will cause pending interests to be retried.
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)

Detailed Description

Streaming access for fetching segmented CCNx data.

Supports multiple streams from a single connection and seeking to an arbitrary position within the associated file.

Definition in file fetch.h.


Define Documentation

#define CCN_FETCH_READ_END   (0)

Definition at line 59 of file fetch.h.

Referenced by ccn_fetch_avail(), ccn_fetch_read(), main(), and runTest().

#define CCN_FETCH_READ_NONE   (-1)

Definition at line 58 of file fetch.h.

Referenced by ccn_fetch_avail(), ccn_fetch_read(), main(), and runTest().

#define CCN_FETCH_READ_TIMEOUT   (-2)

Definition at line 57 of file fetch.h.

Referenced by ccn_fetch_avail(), ccn_fetch_read(), main(), and runTest().

#define CCN_FETCH_READ_ZERO   (-3)

Definition at line 56 of file fetch.h.

Referenced by ccn_fetch_avail(), and ccn_fetch_read().


Enumeration Type Documentation

Enumerator:
ccn_fetch_flags_None 
ccn_fetch_flags_NoteGlitch 
ccn_fetch_flags_NoteAddRem 
ccn_fetch_flags_NoteNeed 
ccn_fetch_flags_NoteFill 
ccn_fetch_flags_NoteFinal 
ccn_fetch_flags_NoteTimeout 
ccn_fetch_flags_NoteOpenClose 
ccn_fetch_flags_NoteAll 

Definition at line 44 of file fetch.h.


Function Documentation

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

Returns:
CCN_FETCH_READ_TIMEOUT if a timeout occured, CCN_FETCH_READ_ZERO if a zero-length segment was found CCN_FETCH_READ_NONE if no bytes are immediately available CCN_FETCH_READ_END if the stream is at the end, and N > 0 if N bytes can be read without performing a 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.

Returns:
NULL in all cases.

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.

Returns:
NULL in all cases.

Definition at line 659 of file ccn_fetch.c.

Referenced by main().

struct ccn* ccn_fetch_get_ccn ( struct ccn_fetch *  f  )  [read]
Returns:
the underlying ccn connection.

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.

Returns:
NULL if the creation was not successful (only can happen for the h == NULL case).

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.

Returns:
the next stream in the iteration, or NULL at the end. Note that providing a stale (closed) stream handle will return NULL.

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. If interestTemplate == NULL then a suitable default is used. The max number of buffers (maxBufs) is a hint, and may be clamped to an implementation minimum or maximum. If assumeFixed, then assume that the segment size is given by the first segment fetched, otherwise segments may be of variable size.

Returns:
NULL if the stream creation failed, otherwise returns the new stream.

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.

Returns:
NULL if the stream creation failed, otherwise returns the new stream.

Definition at line 750 of file ccn_fetch.c.

Referenced by main(), and NewElem().

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.

Returns:
the count of streams that have pending data or have ended.

Definition at line 693 of file ccn_fetch.c.

Referenced by runTest().

intmax_t ccn_fetch_position ( struct ccn_fetch_stream *  fs  ) 
Returns:
the current read position (initially 0)
the current read position.

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.

Returns:
CCN_FETCH_READ_TIMEOUT if a timeout occured, CCN_FETCH_READ_ZERO if a zero-length segment was found CCN_FETCH_READ_NONE if no bytes are immediately available CCN_FETCH_READ_END if the stream is at the end, and N > 0 if N bytes were read.

Definition at line 954 of file ccn_fetch.c.

Referenced by main(), and runTest().

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.

Returns:
-1 if the seek is to a bad position or if the segment size is variable, otherwise returns 0.

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.

Returns:
-1 if the seek is to a bad position, otherwise returns 0.

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 indicator, which will cause pending interests to be retried.

The client determines conditions for a timeout to be considered an unrecoverable error.

Definition at line 1027 of file ccn_fetch.c.

Referenced by main(), and runTest().

Generated on Fri May 13 16:27:17 2011 for Content-Centric Networking in C by  doxygen 1.6.3