ccnc.c File Reference

Go to the source code of this file.

Defines

#define USAGE
#define PIT_LIMIT   10
 Number of pending interests we will keep.
#define CS_LIMIT   3
 Number of generated data items we will hold.
#define VER_LIMIT   5
 Max number of received versions to track.
#define FATAL(res)   fatal(__LINE__, res)
#define DB(st, ccnb)   debug_logger(st, __LINE__, ccnb)

Functions

static enum ccn_upcall_res incoming_interest (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info)
 Interest handler.
static enum ccn_upcall_res incoming_content (struct ccn_closure *, enum ccn_upcall_kind, struct ccn_upcall_info *)
static void fatal (int lineno, int val)
 Print cryptic message and exit.
static void initialize (struct ccnxchat_state *st, struct ccn_charbuf *basename)
 Initialization at startup.
struct ccn_charbufadjust_regprefix (struct ccn_charbuf *name)
 Return a newly-allocated Name buffer with one Component chopped off.
static int namecompare (const void *a, const void *b)
 Comparison operator for sorting the excl list with qsort.
static void stampnow (struct ccn_charbuf *c)
 Append a numeric timestamp to a charbuf.
static void seed_random (void)
 Seed the pseudo-random numbers.
static void usage (void)
 Usage.
unsigned short wrappednow (void)
 Wrapped time - (normally) 16-bit unsigned; millisecond units.
static int wait_for_input_or_timeout (struct ccn *h, int fd)
 Wait until input on fd is ready or ccn_run needs to be called.
static void read_input (struct ccnxchat_state *st)
 Read a line of standard input into payload.
static void generate_new_data (struct ccnxchat_state *st)
 Collect some new data and when ready, place it in store.
static int matchbox (struct ccnxchat_state *st)
 Match PIT entries against the store.
static int send_matching_data (struct ccnxchat_state *st)
 Send data that has been matched.
static void toss_in_cs (struct ccnxchat_state *st, const unsigned char *p, size_t size)
 Insert a ccnb-encoded ContentObject into our content store.
static void toss_in_pit (struct ccnxchat_state *st, const unsigned char *p, struct ccn_parsed_interest *pi)
 Insert a ccnb-encoded Interest message into our pending interest table.
static void age_cs (struct ccnxchat_state *st)
 Remove already-sent entries from the content store.
static void age_pit (struct ccnxchat_state *st)
 Get rid of PIT entries that have timed out or been consumed.
static void debug_logger (struct ccnxchat_state *st, int lineno, struct ccn_charbuf *ccnb)
 Debugging aid.
static int append_interest_details (struct ccn_charbuf *c, const unsigned char *ccnb, size_t size)
static void generate_cob (struct ccnxchat_state *st)
 Generate a content object containing the current payload.
static void add_info_exclusion (struct ccnxchat_state *, struct ccn_upcall_info *)
static void add_uri_exclusion (struct ccnxchat_state *, const char *)
static void add_ver_exclusion (struct ccnxchat_state *, struct ccn_charbuf **)
static void display_the_content (struct ccnxchat_state *, struct ccn_upcall_info *)
static void express_interest (struct ccnxchat_state *)
static void init_ver_exclusion (struct ccnxchat_state *)
static void prune_oldest_exclusion (struct ccnxchat_state *)
static int append_full_user_name (struct ccn_charbuf *)
static int chat_main (int argc, char **argv)
 Main entry point for chat.
static void add_cob_exclusion (struct ccnxchat_state *st, struct ccn_charbuf *cob)
static void parseopts (int argc, char **argv)
static int robo_chat (int argc, char **argv)
 classic unix fork/exec to hook up an automatic responder
int main (int argc, char **argv)

Variables

static const char * progname
 Global progam name for messages.
struct {
   int   debug
   int   echo
   int   freshness
   int   robotname
   int   quiet
   int   verbose
   const char *   basename
   const char *   responder
option
 Global option info.

Define Documentation

#define CS_LIMIT   3

Number of generated data items we will hold.

Definition at line 58 of file ccnc.c.

Referenced by generate_new_data(), and toss_in_cs().

#define DB ( st,
ccnb   )     debug_logger(st, __LINE__, ccnb)
#define FATAL ( res   )     fatal(__LINE__, res)

Definition at line 136 of file ccnc.c.

Referenced by chat_main(), generate_cob(), send_matching_data(), toss_in_cs(), and toss_in_pit().

#define PIT_LIMIT   10

Number of pending interests we will keep.

Definition at line 49 of file ccnc.c.

Referenced by toss_in_pit().

#define USAGE
Value:
"[-hdi:nqr:vx:] ccnx:/chat/room - community text chat"               "\n" \
    " -h - help"                                                         "\n" \
    " -d - debug mode - no input editing"                                "\n" \
    " -i n - print n bytes of signer's public key digest in hex"         "\n" \
    " -n - no echo of own output"                                        "\n" \
    " -q - no automatic greeting or farwell"                             "\n" \
    " -r command - hook up to input and output of responder command"     "\n" \
    " -v - verbose trace of what is happening"                           "\n" \
    " -x sec - set freshness"

Definition at line 31 of file ccnc.c.

Referenced by usage().

#define VER_LIMIT   5

Max number of received versions to track.

Definition at line 60 of file ccnc.c.

Referenced by add_ver_exclusion().


Function Documentation

static void add_cob_exclusion ( struct ccnxchat_state *  st,
struct ccn_charbuf cob 
) [static]

Definition at line 401 of file ccnc.c.

Referenced by generate_new_data().

static void add_info_exclusion ( struct ccnxchat_state *  st,
struct ccn_upcall_info info 
) [static]

Definition at line 369 of file ccnc.c.

Referenced by incoming_content().

static void add_uri_exclusion ( struct ccnxchat_state *  st,
const char *  uri 
) [static]

Definition at line 391 of file ccnc.c.

Referenced by init_ver_exclusion().

static void add_ver_exclusion ( struct ccnxchat_state *  st,
struct ccn_charbuf **  c 
) [static]

Definition at line 324 of file ccnc.c.

Referenced by add_cob_exclusion(), add_info_exclusion(), and add_uri_exclusion().

struct ccn_charbuf * adjust_regprefix ( struct ccn_charbuf name  )  [read]

Return a newly-allocated Name buffer with one Component chopped off.

Definition at line 857 of file ccnc.c.

static void age_cs ( struct ccnxchat_state *  st  )  [static]

Remove already-sent entries from the content store.

Definition at line 699 of file ccnc.c.

Referenced by chat_main().

static void age_pit ( struct ccnxchat_state *  st  )  [static]

Get rid of PIT entries that have timed out or been consumed.

Definition at line 722 of file ccnc.c.

Referenced by chat_main(), and toss_in_pit().

static int append_full_user_name ( struct ccn_charbuf c  )  [static]

Definition at line 1013 of file ccnc.c.

Referenced by chat_main().

static int append_interest_details ( struct ccn_charbuf c,
const unsigned char *  ccnb,
size_t  size 
) [static]

Definition at line 950 of file ccnc.c.

Referenced by debug_logger().

static int chat_main ( int  argc,
char **  argv 
) [static]

Main entry point for chat.

Definition at line 145 of file ccnc.c.

Referenced by main(), and robo_chat().

static void debug_logger ( struct ccnxchat_state *  st,
int  lineno,
struct ccn_charbuf ccnb 
) [static]

Debugging aid.

Prints some internal state to stderr. If non-NULL, ccnb should be a ccnb-encoded Name, Interest, or ContentObject.

Definition at line 927 of file ccnc.c.

Referenced by chat_main().

static void display_the_content ( struct ccnxchat_state *  st,
struct ccn_upcall_info info 
) [static]

Definition at line 282 of file ccnc.c.

Referenced by incoming_content().

static void express_interest ( struct ccnxchat_state *  st  )  [static]

Definition at line 438 of file ccnc.c.

Referenced by chat_main().

static void fatal ( int  lineno,
int  val 
) [static]

Print cryptic message and exit.

Definition at line 870 of file ccnc.c.

static void generate_cob ( struct ccnxchat_state *  st  )  [static]

Generate a content object containing the current payload.

The standard versioning and segmentation profiles are used. It is assumed that the payload fits into one content object.

Definition at line 473 of file ccnc.c.

Referenced by generate_new_data().

static void generate_new_data ( struct ccnxchat_state *  st  )  [static]

Collect some new data and when ready, place it in store.

Definition at line 575 of file ccnc.c.

Referenced by chat_main(), and incoming_interest().

static enum ccn_upcall_res incoming_content ( struct ccn_closure selfp,
enum ccn_upcall_kind  kind,
struct ccn_upcall_info info 
) [static]

Definition at line 249 of file ccnc.c.

static enum ccn_upcall_res incoming_interest ( struct ccn_closure selfp,
enum ccn_upcall_kind  kind,
struct ccn_upcall_info info 
) [static]

Interest handler.

Definition at line 223 of file ccnc.c.

static void init_ver_exclusion ( struct ccnxchat_state *  st  )  [static]

Definition at line 431 of file ccnc.c.

Referenced by chat_main().

static void initialize ( struct ccnxchat_state *  st,
struct ccn_charbuf basename 
) [static]

Initialization at startup.

If there is a command line argument, it is interpreted as a URI relative to basename, and basename is updated accordingly.

basename is a Name in ccnb encoding.

Definition at line 840 of file ccnc.c.

Referenced by chat_main().

int main ( int  argc,
char **  argv 
)

Definition at line 1073 of file ccnc.c.

static int matchbox ( struct ccnxchat_state *  st  )  [static]

Match PIT entries against the store.

This implementation relies on both tables being relatively small, since it can look at all n x m combinations.

Returns:
number of new matches found

Definition at line 645 of file ccnc.c.

Referenced by chat_main(), and incoming_interest().

static int namecompare ( const void *  a,
const void *  b 
) [static]

Comparison operator for sorting the excl list with qsort.

For convenience, the items in the excl array are charbufs containing ccnb-encoded Names of one component each. (This is not the most efficient representation.)

Definition at line 760 of file ccnc.c.

Referenced by add_ver_exclusion().

static void parseopts ( int  argc,
char **  argv 
) [static]

Definition at line 785 of file ccnc.c.

Referenced by main().

static void prune_oldest_exclusion ( struct ccnxchat_state *  st  )  [static]

Definition at line 356 of file ccnc.c.

Referenced by incoming_content().

static void read_input ( struct ccnxchat_state *  st  )  [static]

Read a line of standard input into payload.

Definition at line 530 of file ccnc.c.

Referenced by chat_main().

static int robo_chat ( int  argc,
char **  argv 
) [static]

classic unix fork/exec to hook up an automatic responder

Definition at line 1031 of file ccnc.c.

Referenced by main().

static void seed_random ( void   )  [static]

Seed the pseudo-random numbers.

Definition at line 912 of file ccnc.c.

Referenced by initialize().

static int send_matching_data ( struct ccnxchat_state *  st  )  [static]

Send data that has been matched.

Definition at line 675 of file ccnc.c.

Referenced by chat_main().

static void stampnow ( struct ccn_charbuf c  )  [static]

Append a numeric timestamp to a charbuf.

Definition at line 886 of file ccnc.c.

Referenced by debug_logger().

static void toss_in_cs ( struct ccnxchat_state *  st,
const unsigned char *  p,
size_t  size 
) [static]

Insert a ccnb-encoded ContentObject into our content store.

Definition at line 591 of file ccnc.c.

Referenced by generate_new_data().

static void toss_in_pit ( struct ccnxchat_state *  st,
const unsigned char *  p,
struct ccn_parsed_interest pi 
) [static]

Insert a ccnb-encoded Interest message into our pending interest table.

Definition at line 606 of file ccnc.c.

Referenced by incoming_interest().

static void usage ( void   )  [static]

Usage.

Definition at line 878 of file ccnc.c.

static int wait_for_input_or_timeout ( struct ccn *  h,
int  fd 
) [static]

Wait until input on fd is ready or ccn_run needs to be called.

Returns:
1 if STDIN is ready to read, 0 if not, or -1 for error.

Definition at line 501 of file ccnc.c.

Referenced by chat_main().

unsigned short wrappednow ( void   ) 

Wrapped time - (normally) 16-bit unsigned; millisecond units.

Definition at line 900 of file ccnc.c.

Referenced by age_pit(), debug_logger(), and toss_in_pit().


Variable Documentation

const char* basename

Definition at line 780 of file ccnc.c.

Referenced by load_policy(), and process_file().

int debug
int echo

Definition at line 775 of file ccnc.c.

int freshness

Definition at line 776 of file ccnc.c.

struct { ... } option [static]

Global option info.

Referenced by initialize(), main(), parseopts(), and robo_chat().

const char* progname [static]

Global progam name for messages.

Definition at line 771 of file ccnc.c.

Referenced by fatal(), main(), parseopts(), and usage().

int quiet

Definition at line 778 of file ccnc.c.

const char* responder

Definition at line 781 of file ccnc.c.

int robotname

Definition at line 777 of file ccnc.c.

int verbose

Definition at line 779 of file ccnc.c.

Generated on Tue Aug 21 14:54:32 2012 for Content-Centric Networking in C by  doxygen 1.6.3