ccnd.c File Reference

Go to the source code of this file.

Defines

#define WTHZ   500U
 Frequency of wrapped timer.
#define CCN_SKIPLIST_MAX_DEPTH   30
 Limit for how deep our skiplists can be.

Typedefs

typedef void(* loggerproc )(void *, const char *,...)

Enumerations

enum  ccn_strategy_op {
  CCNST_NOP, CCNST_FIRST, CCNST_TIMER, CCNST_SATISFIED,
  CCNST_TIMEOUT
}
 

Main program of ccnd - the CCNx Daemon.

More...

Functions

static void cleanup_at_exit (void)
static void unlink_at_exit (const char *path)
 Record the name of the unix-domain listener.
static int create_local_listener (struct ccnd_handle *h, const char *sockname, int backlog)
 Create a listener on a unix-domain socket.
static struct facerecord_connection (struct ccnd_handle *h, int fd, struct sockaddr *who, socklen_t wholen, int setflags)
 Make a new face entered in the faces_by_fd table.
static void process_input_message (struct ccnd_handle *h, struct face *face, unsigned char *msg, size_t size, int pdu_ok)
 Process an incoming message.
static void process_input (struct ccnd_handle *h, int fd)
 Process the input from a socket.
static int ccn_stuff_interest (struct ccnd_handle *h, struct face *face, struct ccn_charbuf *c)
 Stuff a PDU with interest messages that will fit.
static void do_deferred_write (struct ccnd_handle *h, int fd)
 Do deferred sends.
static void clean_needed (struct ccnd_handle *h)
 Schedule clean_deamon, if it is not already scheduled.
static struct faceget_dgram_source (struct ccnd_handle *h, struct face *face, struct sockaddr *addr, socklen_t addrlen, int why)
 Get (or create) the face associated with a given sockaddr.
static void content_skiplist_insert (struct ccnd_handle *h, struct content_entry *content)
 Insert a new entry into the skiplist.
static void content_skiplist_remove (struct ccnd_handle *h, struct content_entry *content)
 Remove an entry from the skiplist.
static void mark_stale (struct ccnd_handle *h, struct content_entry *content)
 Mark content as stale.
static ccn_accession_t content_skiplist_next (struct ccnd_handle *h, struct content_entry *content)
 Advance to the next entry in the skiplist.
static void reap_needed (struct ccnd_handle *h, int init_delay_usec)
static void check_comm_file (struct ccnd_handle *h)
static int nameprefix_seek (struct ccnd_handle *h, struct hashtb_enumerator *e, const unsigned char *msg, struct ccn_indexbuf *comps, int ncomps)
 Creates a nameprefix entry if it does not already exist, together with all of its parents.
static void register_new_face (struct ccnd_handle *h, struct face *face)
 Called when a face is first created, and (perhaps) a second time in the case that a face transitions from the undecided state.
static void update_forward_to (struct ccnd_handle *h, struct nameprefix_entry *npe)
 Set up forward_to list for a name prefix entry.
static void stuff_and_send (struct ccnd_handle *h, struct face *face, const unsigned char *data1, size_t size1, const unsigned char *data2, size_t size2, const char *tag, int lineno)
 Send a message in a PDU, possibly stuffing other interest messages into it.
static void ccn_link_state_init (struct ccnd_handle *h, struct face *face)
 Set up to send one sequence number to see it the other side wants to play.
static void ccn_append_link_stuff (struct ccnd_handle *h, struct face *face, struct ccn_charbuf *c)
 Append a sequence number if appropriate.
static int process_incoming_link_message (struct ccnd_handle *h, struct face *face, enum ccn_dtag dtag, unsigned char *msg, size_t size)
 Process an incoming link message.
static void pfi_destroy (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *p)
 Remove the pit face item from the interest entry.
static struct pit_face_itempfi_set_nonce (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *p, const unsigned char *nonce, size_t noncesize)
 Set the nonce in a pit face item.
static int pfi_nonce_matches (struct pit_face_item *p, const unsigned char *nonce, size_t size)
 Return true iff the nonce in p matches the given one.
static struct pit_face_itempfi_copy_nonce (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *p, const struct pit_face_item *src)
 Copy a nonce from src into p.
static int pfi_unique_nonce (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *p)
 True iff the nonce in p does not occur in any of the other items of the entry.
static int wt_compare (ccn_wrappedtime a, ccn_wrappedtime b)
 Compare two wrapped time values.
static void update_npe_children (struct ccnd_handle *h, struct nameprefix_entry *npe, unsigned faceid)
 We have a FIB change - accelerate forwarding of existing interests.
static void pfi_set_expiry_from_lifetime (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *p, intmax_t lifetime)
 Set the expiry of the pit face item based upon an interest lifetime.
static void pfi_set_expiry_from_micros (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *p, unsigned micros)
 Set the expiry of the pit face item using a time in microseconds from present.
static struct pit_face_itempfi_seek (struct ccnd_handle *h, struct interest_entry *ie, unsigned faceid, unsigned pfi_flag)
 Find the pit face item with the given flag set, or create it if not present.
static void strategy_callout (struct ccnd_handle *h, struct interest_entry *ie, enum ccn_strategy_op op)
 This implements the default strategy.
static void handle_fatal_signal (int sig)
static int comm_file_ok (void)
 Check to see if the unix-domain listener has been unlinked.
static struct ccn_charbufcharbuf_obtain (struct ccnd_handle *h)
 Obtain a charbuf for short-term use.
static void charbuf_release (struct ccnd_handle *h, struct ccn_charbuf *c)
 Release a charbuf for reuse.
static struct ccn_indexbufindexbuf_obtain (struct ccnd_handle *h)
 Obtain an indexbuf for short-term use.
static void indexbuf_release (struct ccnd_handle *h, struct ccn_indexbuf *c)
 Release an indexbuf for reuse.
static struct faceface_from_faceid (struct ccnd_handle *h, unsigned faceid)
 Looks up a face based on its faceid (private).
struct faceccnd_face_from_faceid (struct ccnd_handle *h, unsigned faceid)
 Looks up a face based on its faceid.
static int enroll_face (struct ccnd_handle *h, struct face *face)
 Assigns the faceid for a nacent face, calls register_new_face() if successful.
static int choose_face_delay (struct ccnd_handle *h, struct face *face, enum cq_delay_class c)
 Decide how much to delay the content sent out on a face.
static struct content_queuecontent_queue_create (struct ccnd_handle *h, struct face *face, enum cq_delay_class c)
 Create a queue for sending content.
static void content_queue_destroy (struct ccnd_handle *h, struct content_queue **pq)
 Destroy a queue.
static void close_fd (int *pfd)
 Close an open file descriptor quietly.
static void ccnd_close_fd (struct ccnd_handle *h, unsigned faceid, int *pfd)
 Close an open file descriptor, and grumble about it.
static void finalize_face (struct hashtb_enumerator *e)
 Clean up when a face is being destroyed.
static struct content_entrycontent_from_accession (struct ccnd_handle *h, ccn_accession_t accession)
 Convert an accession to its associated content handle.
static void cleanout_stragglers (struct ccnd_handle *h)
 Sweep old entries out of the direct accession-to-content table.
static int cleanout_empties (struct ccnd_handle *h)
 Prevent the direct accession-to-content table from becoming too sparse.
static void enroll_content (struct ccnd_handle *h, struct content_entry *content)
 Assign an accession number to a content object.
static void finalize_content (struct hashtb_enumerator *content_enumerator)
static int content_skiplist_findbefore (struct ccnd_handle *h, const unsigned char *key, size_t keysize, struct content_entry *wanted_old, struct ccn_indexbuf **ans)
 Find the skiplist entries associated with the key.
static struct content_entryfind_first_match_candidate (struct ccnd_handle *h, const unsigned char *interest_msg, const struct ccn_parsed_interest *pi)
 Find the first candidate that might match the given interest.
static int content_matches_interest_prefix (struct ccnd_handle *h, struct content_entry *content, const unsigned char *interest_msg, struct ccn_indexbuf *comps, int prefix_comps)
 Check for a prefix match.
static void consume_interest (struct ccnd_handle *h, struct interest_entry *ie)
 Consume an interest.
static void finalize_nameprefix (struct hashtb_enumerator *e)
 Clean up a name prefix entry when it is removed from the hash table.
static void link_interest_entry_to_nameprefix (struct ccnd_handle *h, struct interest_entry *ie, struct nameprefix_entry *npe)
 Link an interest to its name prefix entry.
static void finalize_interest (struct hashtb_enumerator *e)
 Clean up an interest_entry when it is removed from its hash table.
static int establish_min_recv_bufsize (struct ccnd_handle *h, int fd, int minsize)
 Adjust socket buffer limit.
static void init_face_flags (struct ccnd_handle *h, struct face *face, int setflags)
 Initialize the face flags based upon the addr information and the provided explicit setflags.
static int accept_connection (struct ccnd_handle *h, int listener_fd)
 Accept an incoming SOCK_STREAM connection, creating a new face.
static struct facemake_connection (struct ccnd_handle *h, struct sockaddr *who, socklen_t wholen, int setflags)
 Make an outbound stream connection.
static int ccnd_getboundsocket (void *dat, struct sockaddr *who, socklen_t wholen)
 Get a bound datagram socket.
static unsigned faceid_from_fd (struct ccnd_handle *h, int fd)
 Get the faceid associated with a file descriptor.
static struct facesetup_multicast (struct ccnd_handle *h, struct ccn_face_instance *face_instance, struct sockaddr *who, socklen_t wholen)
 Set up a multicast face.
static void shutdown_client_fd (struct ccnd_handle *h, int fd)
 Close a socket, destroying the associated face.
static void send_content (struct ccnd_handle *h, struct face *face, struct content_entry *content)
 Send a ContentObject.
static enum cq_delay_class choose_content_delay_class (struct ccnd_handle *h, unsigned faceid, int content_flags)
 Select the output queue class for a piece of content.
static unsigned randomize_content_delay (struct ccnd_handle *h, struct content_queue *q)
 Pick a randomized delay for sending.
static int content_sender (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Scheduled event for sending from a queue.
static int face_send_queue_insert (struct ccnd_handle *h, struct face *face, struct content_entry *content)
 Queue a ContentObject to be sent on a face.
static int is_pending_on (struct ccnd_handle *h, struct interest_entry *ie, unsigned faceid)
 Return true iff the interest is pending on the given face.
static int consume_matching_interests (struct ccnd_handle *h, struct nameprefix_entry *npe, struct content_entry *content, struct ccn_parsed_ContentObject *pc, struct face *face)
 Consume matching interests given a nameprefix_entry and a piece of content.
static void adjust_npe_predicted_response (struct ccnd_handle *h, struct nameprefix_entry *npe, int up)
 Adjust the predicted response associated with a name prefix entry.
static void adjust_predicted_response (struct ccnd_handle *h, struct interest_entry *ie, int up)
 Adjust the predicted responses for an interest.
static void note_content_from (struct ccnd_handle *h, struct nameprefix_entry *npe, unsigned from_faceid, int prefix_comps)
 Keep a little history about where matching content comes from.
static int match_interests (struct ccnd_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pc, struct face *face, struct face *from_face)
 Find and consume interests that match given content.
static int stuff_link_check (struct ccnd_handle *h, struct face *face, struct ccn_charbuf *c)
 Append a link-check interest if appropriate.
static int check_dgram_faces (struct ccnd_handle *h)
 Checks for inactivity on datagram faces.
int ccnd_destroy_face (struct ccnd_handle *h, unsigned faceid)
 Destroys the face identified by faceid.
static void check_forward_to (struct ccnd_handle *h, struct ccn_indexbuf **ip)
 Remove expired faces from *ip.
static int check_nameprefix_entries (struct ccnd_handle *h)
 Ages src info and retires unused nameprefix entries.
static int reap (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Scheduled reap event for retiring expired structures.
static int remove_content (struct ccnd_handle *h, struct content_entry *content)
 Remove a content object from the store.
static int clean_deamon (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Periodic content cleaning.
static int age_forwarding (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Age out the old forwarding table entries.
static void age_forwarding_needed (struct ccnd_handle *h)
 Make sure a call to age_forwarding is scheduled.
static struct ccn_forwardingseek_forwarding (struct ccnd_handle *h, struct nameprefix_entry *npe, unsigned faceid)
 Look up a forwarding entry, creating it if it is not there.
static int ccnd_reg_prefix (struct ccnd_handle *h, const unsigned char *msg, struct ccn_indexbuf *comps, int ncomps, unsigned faceid, int flags, int expires)
 Register or update a prefix in the forwarding table (FIB).
int ccnd_reg_uri (struct ccnd_handle *h, const char *uri, unsigned faceid, int flags, int expires)
 Register a prefix, expressed in the form of a URI.
void ccnd_reg_uri_list (struct ccnd_handle *h, struct ccn_charbuf *uris, unsigned faceid, int flags, int expires)
 Register prefixes, expressed in the form of a list of URIs.
static int ccnd_nack (struct ccnd_handle *h, struct ccn_charbuf *reply_body, int errcode, const char *errtext)
 Replaces contents of reply_body with a ccnb-encoded StatusResponse.
static int check_ccndid (struct ccnd_handle *h, const void *p, size_t sz, struct ccn_charbuf *reply_body)
 Check that indicated ccndid matches ours.
static int check_face_instance_ccndid (struct ccnd_handle *h, struct ccn_face_instance *f, struct ccn_charbuf *reply_body)
 Check ccndid, given a face instance.
static int check_forwarding_entry_ccndid (struct ccnd_handle *h, struct ccn_forwarding_entry *f, struct ccn_charbuf *reply_body)
 Check ccndid, given a parsed ForwardingEntry.
int ccnd_req_newface (struct ccnd_handle *h, const unsigned char *msg, size_t size, struct ccn_charbuf *reply_body)
 Process a newface request for the ccnd internal client.
int ccnd_req_destroyface (struct ccnd_handle *h, const unsigned char *msg, size_t size, struct ccn_charbuf *reply_body)
 Process a destroyface request for the ccnd internal client.
static int ccnd_req_prefix_or_self_reg (struct ccnd_handle *h, const unsigned char *msg, size_t size, int selfreg, struct ccn_charbuf *reply_body)
 Worker bee for two very similar public functions.
int ccnd_req_prefixreg (struct ccnd_handle *h, const unsigned char *msg, size_t size, struct ccn_charbuf *reply_body)
 Process a prefixreg request for the ccnd internal client.
int ccnd_req_selfreg (struct ccnd_handle *h, const unsigned char *msg, size_t size, struct ccn_charbuf *reply_body)
 Process a selfreg request for the ccnd internal client.
int ccnd_req_unreg (struct ccnd_handle *h, const unsigned char *msg, size_t size, struct ccn_charbuf *reply_body)
 Process an unreg request for the ccnd internal client.
static struct ccn_indexbufget_outbound_faces (struct ccnd_handle *h, struct face *from, const unsigned char *msg, struct ccn_parsed_interest *pi, struct nameprefix_entry *npe)
 This is where we consult the interest forwarding table.
static int ie_next_usec (struct ccnd_handle *h, struct interest_entry *ie, ccn_wrappedtime *expiry)
 Compute the delay until the next timed action on an interest.
static int append_tagged_binary_number (struct ccn_charbuf *cb, enum ccn_dtag dtag, uintmax_t val)
static struct pit_face_itemsend_interest (struct ccnd_handle *h, struct interest_entry *ie, struct pit_face_item *x, struct pit_face_item *p)
 Forward an interest message.
struct nameprefix_entryget_fib_npe (struct ccnd_handle *h, struct interest_entry *ie)
 Find the entry for the longest name prefix that contains forwarding info.
static int strategy_timer (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Implementation detail for strategy_settimer.
static void strategy_settimer (struct ccnd_handle *h, struct interest_entry *ie, int usec, enum ccn_strategy_op op)
 Schedule a strategy wakeup.
static int do_propagate (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Execute the next timed action on a propagating interest.
static int ccnd_debug_nonce (struct ccnd_handle *h, struct face *face, unsigned char *s)
 Append an interest Nonce value that is useful for debugging.
static int ccnd_plain_nonce (struct ccnd_handle *h, struct face *face, unsigned char *s)
 Append a random interest Nonce value.
static struct pit_face_itempfi_create (struct ccnd_handle *h, unsigned faceid, unsigned flags, const unsigned char *nonce, size_t noncesize, struct pit_face_item **pp)
 Used in just one place; could go away.
static int propagate_interest (struct ccnd_handle *h, struct face *face, unsigned char *msg, struct ccn_parsed_interest *pi, struct nameprefix_entry *npe)
 Schedules the propagation of an Interest message.
static struct content_entrynext_child_at_level (struct ccnd_handle *h, struct content_entry *content, int level)
static int drop_nonlocal_interest (struct ccnd_handle *h, struct nameprefix_entry *npe, struct face *face, unsigned char *msg, size_t size)
 Check whether the interest should be dropped for local namespace reasons.
static void process_incoming_interest (struct ccnd_handle *h, struct face *face, unsigned char *msg, size_t size)
 Process an incoming interest message.
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 exported.
static void set_content_timer (struct ccnd_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco)
 Schedules content expiration based on its FreshnessSeconds, and the configured default and limit.
static void process_incoming_content (struct ccnd_handle *h, struct face *face, unsigned char *wire_msg, size_t wire_size)
 Process an arriving ContentObject.
static void ccnd_new_face_msg (struct ccnd_handle *h, struct face *face)
 Log a notification that a new datagram face has been created.
static struct sockaddr * scrub_sockaddr (struct sockaddr *addr, socklen_t addrlen, struct sockaddr_in6 *space)
 Since struct sockaddr_in6 may contain fields that should not participate in comparison / hash, ensure the undesired fields are zero.
static void process_input_buffer (struct ccnd_handle *h, struct face *face)
 Break up data in a face's input buffer buffer into individual messages, and call process_input_message on each one.
static void process_internal_client_buffer (struct ccnd_handle *h)
 Process messages from our internal client.
static int process_icb_action (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Scheduled event for deferred processing of internal client.
static void process_internal_client_buffer_needed (struct ccnd_handle *h)
 Schedule the processing of internal client results.
static int handle_send_error (struct ccnd_handle *h, int errnum, struct face *face, const void *data, size_t size)
 Handle errors after send() or sendto().
static int sending_fd (struct ccnd_handle *h, struct face *face)
 Determine what socket to use to send on a face.
void ccnd_send (struct ccnd_handle *h, struct face *face, const void *data, size_t size)
 Send data to the face.
static void prepare_poll_fds (struct ccnd_handle *h)
 Set up the array of fd descriptors for the poll(2) call.
void ccnd_run (struct ccnd_handle *h)
 Run the main loop of the ccnd.
static void ccnd_reseed (struct ccnd_handle *h)
 Reseed our pseudo-random number generator.
static char * ccnd_get_local_sockname (void)
 Get the name of our unix-domain socket listener.
static void ccnd_gettime (const struct ccn_gettime *self, struct ccn_timeval *result)
 Get the time.
void ccnd_setsockopt_v6only (struct ccnd_handle *h, int fd)
 Set IPV6_V6ONLY on a socket.
static const char * af_name (int family)
 Translate an address family constant to a string.
static int ccnd_listen_on_wildcards (struct ccnd_handle *h)
 Create the standard ipv4 and ipv6 bound ports.
static int ccnd_listen_on_address (struct ccnd_handle *h, const char *addr)
 Create a tcp listener and a bound udp socket on the given address.
static int ccnd_listen_on (struct ccnd_handle *h, const char *addrs)
 Create listeners or bound udp ports using the given addresses.
static struct ccn_charbufccnd_parse_uri_list (struct ccnd_handle *h, const char *what, const char *uris)
 Parse a list of ccnx URIs.
struct ccnd_handleccnd_create (const char *progname, ccnd_logger logger, void *loggerdata)
 Start a new ccnd instance.
static void ccnd_shutdown_listeners (struct ccnd_handle *h)
 Shutdown listeners and bound datagram sockets, leaving connected streams.
void ccnd_destroy (struct ccnd_handle **pccnd)
 Destroy the ccnd instance, releasing all associated resources.

Variables

static const char * unlink_this_at_exit = NULL
 Name of our unix-domain listener.

Define Documentation

#define CCN_SKIPLIST_MAX_DEPTH   30

Limit for how deep our skiplists can be.

Definition at line 697 of file ccnd.c.

Referenced by content_skiplist_insert(), content_skiplist_remove(), find_first_match_candidate(), and next_child_at_level().

#define WTHZ   500U

Frequency of wrapped timer.

This should divide 1000000 evenly. Making this too large reduces the maximum supported interest lifetime, and making it too small makes the timekeeping too coarse.

Definition at line 159 of file ccnd.c.

Referenced by ccnd_gettime(), do_propagate(), ie_next_usec(), pfi_set_expiry_from_lifetime(), pfi_set_expiry_from_micros(), send_interest(), and update_npe_children().


Typedef Documentation

typedef void(* loggerproc)(void *, const char *,...)

Definition at line 1236 of file ccnd.c.


Enumeration Type Documentation

Main program of ccnd - the CCNx Daemon.

Ops for strategy callout

Enumerator:
CCNST_NOP 
CCNST_FIRST 
CCNST_TIMER 
CCNST_SATISFIED 
CCNST_TIMEOUT 

Definition at line 65 of file ccnd.c.


Function Documentation

static int accept_connection ( struct ccnd_handle h,
int  listener_fd 
) [static]

Accept an incoming SOCK_STREAM connection, creating a new face.

This could be, for example, a unix-domain socket, or TCP.

Returns:
fd of new socket, or -1 for an error.

Definition at line 1094 of file ccnd.c.

Referenced by process_input().

static void adjust_npe_predicted_response ( struct ccnd_handle h,
struct nameprefix_entry npe,
int  up 
) [static]

Adjust the predicted response associated with a name prefix entry.

It is decreased by a small fraction if we get content within our previous predicted value, and increased by a larger fraction if not.

Definition at line 1608 of file ccnd.c.

Referenced by adjust_predicted_response(), and note_content_from().

static void adjust_predicted_response ( struct ccnd_handle h,
struct interest_entry ie,
int  up 
) [static]

Adjust the predicted responses for an interest.

We adjust two npes, so that the parents are informed about activity at the leaves.

Definition at line 1631 of file ccnd.c.

Referenced by strategy_callout().

static const char* af_name ( int  family  )  [static]

Translate an address family constant to a string.

Definition at line 5186 of file ccnd.c.

Referenced by ccnd_listen_on_address(), and ccnd_listen_on_wildcards().

static int age_forwarding ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Age out the old forwarding table entries.

Definition at line 2250 of file ccnd.c.

Referenced by age_forwarding_needed().

static void age_forwarding_needed ( struct ccnd_handle h  )  [static]

Make sure a call to age_forwarding is scheduled.

Definition at line 2307 of file ccnd.c.

Referenced by ccnd_create().

static int append_tagged_binary_number ( struct ccn_charbuf cb,
enum ccn_dtag  dtag,
uintmax_t  val 
) [static]

Definition at line 3164 of file ccnd.c.

Referenced by send_interest().

static void ccn_append_link_stuff ( struct ccnd_handle h,
struct face face,
struct ccn_charbuf c 
) [static]

Append a sequence number if appropriate.

Definition at line 1845 of file ccnd.c.

Referenced by stuff_and_send().

static void ccn_link_state_init ( struct ccnd_handle h,
struct face face 
) [static]

Set up to send one sequence number to see it the other side wants to play.

If we don't hear a number from the other side, we won't keep sending them.

Definition at line 1826 of file ccnd.c.

Referenced by register_new_face().

static int ccn_stuff_interest ( struct ccnd_handle h,
struct face face,
struct ccn_charbuf c 
) [static]

Stuff a PDU with interest messages that will fit.

Note by default stuffing does not happen due to the setting of h->mtu.

Returns:
the number of messages that were stuffed.

Definition at line 1811 of file ccnd.c.

Referenced by stuff_and_send().

static void ccnd_close_fd ( struct ccnd_handle h,
unsigned  faceid,
int *  pfd 
) [static]

Close an open file descriptor, and grumble about it.

Definition at line 428 of file ccnd.c.

Referenced by finalize_face().

struct ccnd_handle* ccnd_create ( const char *  progname,
ccnd_logger  logger,
void *  loggerdata 
) [read]

Start a new ccnd instance.

Parameters:
progname - name of program binary, used for locating helpers
logger - logger function
loggerdata - data to pass to logger function

Definition at line 5455 of file ccnd.c.

Referenced by main(), and start_ccnd().

static int ccnd_debug_nonce ( struct ccnd_handle h,
struct face face,
unsigned char *  s 
) [static]

Append an interest Nonce value that is useful for debugging.

This does leak some information about the origin of interests, but it also makes it easier to figure out what is happening.

The debug nonce is 12 bytes long. When converted to hexadecimal and broken into fields (big-endian style), it looks like

IIIIII-PPPP-FFFF-SSss-XXXXXX

where IIIIII - first 24 bits of the CCNDID. PPPP - pid of the ccnd. FFFF - 16 low-order bits of the faceid. SSss - local time modulo 256 seconds, with 8 bits of fraction XXXXXX - 24 random bits.

Definition at line 3504 of file ccnd.c.

Referenced by ccnd_create().

void ccnd_destroy ( struct ccnd_handle **  pccnd  ) 

Destroy the ccnd instance, releasing all associated resources.

Definition at line 5631 of file ccnd.c.

Referenced by main().

int ccnd_destroy_face ( struct ccnd_handle h,
unsigned  faceid 
)

Destroys the face identified by faceid.

Returns:
0 for success, -1 for failure.

Definition at line 1973 of file ccnd.c.

Referenced by ccnd_req_destroyface(), and ccnd_stats_handle_http_connection().

struct face* ccnd_face_from_faceid ( struct ccnd_handle h,
unsigned  faceid 
) [read]

Looks up a face based on its faceid.

Definition at line 296 of file ccnd.c.

Referenced by ccnd_collect_stats(), and post_face_notice().

static char* ccnd_get_local_sockname ( void   )  [static]

Get the name of our unix-domain socket listener.

Uses the library to generate the name, using the environment.

Returns:
a newly-allocated nul-terminated string.

Definition at line 5119 of file ccnd.c.

Referenced by ccnd_create().

static int ccnd_getboundsocket ( void *  dat,
struct sockaddr *  who,
socklen_t  wholen 
) [static]

Get a bound datagram socket.

This is handed to ccn_setup_socket() when setting up a multicast face.

Definition at line 1186 of file ccnd.c.

Referenced by setup_multicast().

static void ccnd_gettime ( const struct ccn_gettime self,
struct ccn_timeval result 
) [static]

Get the time.

This is used to supply the clock for our scheduled events.

Definition at line 5132 of file ccnd.c.

Referenced by ccnd_create().

static int ccnd_listen_on ( struct ccnd_handle h,
const char *  addrs 
) [static]

Create listeners or bound udp ports using the given addresses.

The addresses may be separated by whitespace, commas, or semicolons.

Definition at line 5366 of file ccnd.c.

Referenced by ccnd_create().

static int ccnd_listen_on_address ( struct ccnd_handle h,
const char *  addr 
) [static]

Create a tcp listener and a bound udp socket on the given address.

Definition at line 5283 of file ccnd.c.

Referenced by ccnd_listen_on().

static int ccnd_listen_on_wildcards ( struct ccnd_handle h  )  [static]

Create the standard ipv4 and ipv6 bound ports.

Definition at line 5202 of file ccnd.c.

Referenced by ccnd_listen_on().

static int ccnd_nack ( struct ccnd_handle h,
struct ccn_charbuf reply_body,
int  errcode,
const char *  errtext 
) [static]

Replaces contents of reply_body with a ccnb-encoded StatusResponse.

Returns:
CCN_CONTENT_NACK, or -1 in case of error.

Definition at line 2494 of file ccnd.c.

Referenced by ccnd_req_destroyface(), ccnd_req_newface(), ccnd_req_prefix_or_self_reg(), ccnd_req_unreg(), and check_ccndid().

static void ccnd_new_face_msg ( struct ccnd_handle h,
struct face face 
) [static]

Log a notification that a new datagram face has been created.

Definition at line 4536 of file ccnd.c.

Referenced by get_dgram_source().

static struct ccn_charbuf* ccnd_parse_uri_list ( struct ccnd_handle h,
const char *  what,
const char *  uris 
) [static, read]

Parse a list of ccnx URIs.

The URIs may be separated by whitespace, commas, or semicolons.

Errors are logged.

Returns:
a newly-allocated charbuf containing nul-terminated URIs; or NULL if no valid URIs are found.

Definition at line 5409 of file ccnd.c.

Referenced by ccnd_create().

static int ccnd_plain_nonce ( struct ccnd_handle h,
struct face face,
unsigned char *  s 
) [static]

Append a random interest Nonce value.

For production use, although this uses a simple PRNG.

Definition at line 3526 of file ccnd.c.

Referenced by ccnd_create().

static int ccnd_reg_prefix ( struct ccnd_handle h,
const unsigned char *  msg,
struct ccn_indexbuf comps,
int  ncomps,
unsigned  faceid,
int  flags,
int  expires 
) [static]

Register or update a prefix in the forwarding table (FIB).

Parameters:
h is the ccnd handle.
msg is a ccnb-encoded message containing the name prefix somewhere.
comps contains the delimiting offsets for the name components in msg.
ncomps is the number of relevant components.
faceid indicates which face to forward to.
flags are the forwarding entry flags (CCN_FORW_...), -1 for defaults.
expires tells the remaining lifetime, in seconds.
Returns:
-1 for error, or new flags upon success; the private flag CCN_FORW_REFRESHED indicates a previously existing entry.

Definition at line 2353 of file ccnd.c.

Referenced by ccnd_reg_uri(), and ccnd_req_prefix_or_self_reg().

int ccnd_reg_uri ( struct ccnd_handle h,
const char *  uri,
unsigned  faceid,
int  flags,
int  expires 
)

Register a prefix, expressed in the form of a URI.

Returns:
negative value for error, or new face flags for success.

Definition at line 2423 of file ccnd.c.

Referenced by ccnd_internal_client_start(), ccnd_reg_ccnx_ccndid(), ccnd_reg_uri_list(), and ccnd_uri_listen().

void ccnd_reg_uri_list ( struct ccnd_handle h,
struct ccn_charbuf uris,
unsigned  faceid,
int  flags,
int  expires 
)

Register prefixes, expressed in the form of a list of URIs.

The URIs in the charbuf are each terminated by nul.

Definition at line 2458 of file ccnd.c.

Referenced by register_new_face().

int ccnd_req_destroyface ( struct ccnd_handle h,
const unsigned char *  msg,
size_t  size,
struct ccn_charbuf reply_body 
)

Process a destroyface request for the ccnd internal client.

Parameters:
h is the ccnd handle
msg points to a ccnd-encoded ContentObject containing a FaceInstance in its Content.
size is its size in bytes
reply_body is a buffer to hold the Content of the reply, as a FaceInstance including faceid
Returns:
0 for success, negative for no response, or CCN_CONTENT_NACK to set the response type to NACK.

Is is an error if the face does not exist.

Definition at line 2705 of file ccnd.c.

Referenced by ccnd_answer_req().

int ccnd_req_newface ( struct ccnd_handle h,
const unsigned char *  msg,
size_t  size,
struct ccn_charbuf reply_body 
)

Process a newface request for the ccnd internal client.

Parameters:
h is the ccnd handle
msg points to a ccnd-encoded ContentObject containing a FaceInstance in its Content.
size is its size in bytes
reply_body is a buffer to hold the Content of the reply, as a FaceInstance including faceid
Returns:
0 for success, negative for no response, or CCN_CONTENT_NACK to set the response type to NACK.

Is is permitted for the face to already exist. A newly created face will have no registered prefixes, and so will not receive any traffic.

Definition at line 2558 of file ccnd.c.

Referenced by ccnd_answer_req().

static int ccnd_req_prefix_or_self_reg ( struct ccnd_handle h,
const unsigned char *  msg,
size_t  size,
int  selfreg,
struct ccn_charbuf reply_body 
) [static]

Worker bee for two very similar public functions.

Definition at line 2763 of file ccnd.c.

Referenced by ccnd_req_prefixreg(), and ccnd_req_selfreg().

int ccnd_req_prefixreg ( struct ccnd_handle h,
const unsigned char *  msg,
size_t  size,
struct ccn_charbuf reply_body 
)

Process a prefixreg request for the ccnd internal client.

Parameters:
h is the ccnd handle
msg points to a ccnd-encoded ContentObject containing a ForwardingEntry in its Content.
size is its size in bytes
reply_body is a buffer to hold the Content of the reply, as a FaceInstance including faceid
Returns:
0 for success, negative for no response, or CCN_CONTENT_NACK to set the response type to NACK.

Definition at line 2862 of file ccnd.c.

Referenced by ccnd_answer_req().

int ccnd_req_selfreg ( struct ccnd_handle h,
const unsigned char *  msg,
size_t  size,
struct ccn_charbuf reply_body 
)

Process a selfreg request for the ccnd internal client.

Parameters:
h is the ccnd handle
msg points to a ccnd-encoded ContentObject containing a ForwardingEntry in its Content.
size is its size in bytes
reply_body is a buffer to hold the Content of the reply, as a ccnb-encoded ForwardingEntry
Returns:
0 for success, negative for no response, or CCN_CONTENT_NACK to set the response type to NACK.

Definition at line 2882 of file ccnd.c.

Referenced by ccnd_answer_req().

int ccnd_req_unreg ( struct ccnd_handle h,
const unsigned char *  msg,
size_t  size,
struct ccn_charbuf reply_body 
)

Process an unreg request for the ccnd internal client.

Parameters:
h is the ccnd handle
msg points to a ccnd-encoded ContentObject containing a ForwardingEntry in its Content.
size is its size in bytes
reply_body is a buffer to hold the Content of the reply, as a ccnb-encoded ForwardingEntry
Returns:
0 for success, negative for no response, or CCN_CONTENT_NACK to set the response type to NACK.

Definition at line 2902 of file ccnd.c.

Referenced by ccnd_answer_req().

static void ccnd_reseed ( struct ccnd_handle h  )  [static]

Reseed our pseudo-random number generator.

Definition at line 5090 of file ccnd.c.

Referenced by ccnd_create().

void ccnd_run ( struct ccnd_handle h  ) 

Run the main loop of the ccnd.

Definition at line 5039 of file ccnd.c.

Referenced by main(), and start_ccnd().

void ccnd_send ( struct ccnd_handle h,
struct face face,
const void *  data,
size_t  size 
)

Send data to the face.

No direct error result is provided; the face state is updated as needed.

Definition at line 4903 of file ccnd.c.

Referenced by ccnd_stats_handle_http_connection(), send_http_response(), and stuff_and_send().

void ccnd_setsockopt_v6only ( struct ccnd_handle h,
int  fd 
)

Set IPV6_V6ONLY on a socket.

The handle is used for error reporting.

Definition at line 5170 of file ccnd.c.

Referenced by ccnd_listen_on_address(), and ccnd_listen_on_wildcards().

static void ccnd_shutdown_listeners ( struct ccnd_handle h  )  [static]

Shutdown listeners and bound datagram sockets, leaving connected streams.

Definition at line 5613 of file ccnd.c.

Referenced by ccnd_destroy().

static struct ccn_charbuf* charbuf_obtain ( struct ccnd_handle h  )  [static, read]

Obtain a charbuf for short-term use.

Definition at line 226 of file ccnd.c.

Referenced by process_incoming_content(), and stuff_and_send().

static void charbuf_release ( struct ccnd_handle h,
struct ccn_charbuf c 
) [static]

Release a charbuf for reuse.

Definition at line 240 of file ccnd.c.

Referenced by process_incoming_content(), and stuff_and_send().

static int check_ccndid ( struct ccnd_handle h,
const void *  p,
size_t  sz,
struct ccn_charbuf reply_body 
) [static]

Check that indicated ccndid matches ours.

Fills reply_body with a StatusResponse in case of no match.

Returns:
0 if OK, or CCN_CONTENT_NACK if not.

Definition at line 2513 of file ccnd.c.

Referenced by check_face_instance_ccndid(), and check_forwarding_entry_ccndid().

static void check_comm_file ( struct ccnd_handle h  )  [static]

Definition at line 2062 of file ccnd.c.

Referenced by process_input(), reap(), and shutdown_client_fd().

static int check_dgram_faces ( struct ccnd_handle h  )  [static]

Checks for inactivity on datagram faces.

Returns:
number of faces that have gone away.

Definition at line 1935 of file ccnd.c.

Referenced by reap().

static int check_face_instance_ccndid ( struct ccnd_handle h,
struct ccn_face_instance f,
struct ccn_charbuf reply_body 
) [static]

Check ccndid, given a face instance.

Definition at line 2525 of file ccnd.c.

Referenced by ccnd_req_destroyface(), and ccnd_req_newface().

static void check_forward_to ( struct ccnd_handle h,
struct ccn_indexbuf **  ip 
) [static]

Remove expired faces from *ip.

Definition at line 2003 of file ccnd.c.

Referenced by check_nameprefix_entries().

static int check_forwarding_entry_ccndid ( struct ccnd_handle h,
struct ccn_forwarding_entry f,
struct ccn_charbuf reply_body 
) [static]

Check ccndid, given a parsed ForwardingEntry.

Definition at line 2535 of file ccnd.c.

Referenced by ccnd_req_unreg().

static int check_nameprefix_entries ( struct ccnd_handle h  )  [static]

Ages src info and retires unused nameprefix entries.

Returns:
number that have gone away.

Definition at line 2027 of file ccnd.c.

Referenced by reap().

static enum cq_delay_class choose_content_delay_class ( struct ccnd_handle h,
unsigned  faceid,
int  content_flags 
) [static]

Select the output queue class for a piece of content.

Definition at line 1355 of file ccnd.c.

Referenced by face_send_queue_insert().

static int choose_face_delay ( struct ccnd_handle h,
struct face face,
enum cq_delay_class  c 
) [static]

Decide how much to delay the content sent out on a face.

Units are microseconds.

Definition at line 350 of file ccnd.c.

Referenced by content_queue_create().

static int clean_deamon ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Periodic content cleaning.

Definition at line 2131 of file ccnd.c.

Referenced by clean_needed().

static void clean_needed ( struct ccnd_handle h  )  [static]

Schedule clean_deamon, if it is not already scheduled.

Definition at line 2240 of file ccnd.c.

Referenced by ccnd_create().

static int cleanout_empties ( struct ccnd_handle h  )  [static]

Prevent the direct accession-to-content table from becoming too sparse.

Definition at line 558 of file ccnd.c.

Referenced by enroll_content().

static void cleanout_stragglers ( struct ccnd_handle h  )  [static]

Sweep old entries out of the direct accession-to-content table.

Definition at line 515 of file ccnd.c.

Referenced by cleanout_empties().

static void cleanup_at_exit ( void   )  [static]

Definition at line 170 of file ccnd.c.

Referenced by handle_fatal_signal(), and unlink_at_exit().

static void close_fd ( int *  pfd  )  [static]

Close an open file descriptor quietly.

Definition at line 416 of file ccnd.c.

Referenced by accept_connection().

static int comm_file_ok ( void   )  [static]

Check to see if the unix-domain listener has been unlinked.

Returns:
1 if the file is there, 0 if not.

Definition at line 210 of file ccnd.c.

Referenced by check_comm_file().

static void consume_interest ( struct ccnd_handle h,
struct interest_entry ie 
) [static]

Consume an interest.

Definition at line 859 of file ccnd.c.

Referenced by consume_matching_interests(), do_propagate(), and finalize_nameprefix().

static int consume_matching_interests ( struct ccnd_handle h,
struct nameprefix_entry npe,
struct content_entry content,
struct ccn_parsed_ContentObject pc,
struct face face 
) [static]

Consume matching interests given a nameprefix_entry and a piece of content.

If face is not NULL, pay attention only to interests from that face. It is allowed to pass NULL for pc, but if you have a (valid) one it will avoid a re-parse.

Returns:
number of matches found.

Definition at line 1560 of file ccnd.c.

Referenced by match_interests().

static struct content_entry* content_from_accession ( struct ccnd_handle h,
ccn_accession_t  accession 
) [static, read]

Convert an accession to its associated content handle.

Returns:
content handle, or NULL if it is no longer available.

Definition at line 493 of file ccnd.c.

Referenced by clean_deamon(), content_sender(), content_skiplist_findbefore(), expire_content(), find_first_match_candidate(), next_child_at_level(), process_incoming_content(), and process_incoming_interest().

static int content_matches_interest_prefix ( struct ccnd_handle h,
struct content_entry content,
const unsigned char *  interest_msg,
struct ccn_indexbuf comps,
int  prefix_comps 
) [static]

Check for a prefix match.

Definition at line 820 of file ccnd.c.

Referenced by process_incoming_interest().

static struct content_queue* content_queue_create ( struct ccnd_handle h,
struct face face,
enum cq_delay_class  c 
) [static, read]

Create a queue for sending content.

Definition at line 372 of file ccnd.c.

Referenced by face_send_queue_insert().

static void content_queue_destroy ( struct ccnd_handle h,
struct content_queue **  pq 
) [static]

Destroy a queue.

Definition at line 397 of file ccnd.c.

Referenced by finalize_face().

static int content_sender ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Scheduled event for sending from a queue.

Definition at line 1397 of file ccnd.c.

Referenced by face_send_queue_insert().

static int content_skiplist_findbefore ( struct ccnd_handle h,
const unsigned char *  key,
size_t  keysize,
struct content_entry wanted_old,
struct ccn_indexbuf **  ans 
) [static]

Find the skiplist entries associated with the key.

Returns:
the number of entries of ans that were filled in.

Definition at line 655 of file ccnd.c.

Referenced by content_skiplist_insert(), content_skiplist_remove(), find_first_match_candidate(), and next_child_at_level().

static void content_skiplist_insert ( struct ccnd_handle h,
struct content_entry content 
) [static]

Insert a new entry into the skiplist.

Definition at line 703 of file ccnd.c.

Referenced by process_incoming_content().

static ccn_accession_t content_skiplist_next ( struct ccnd_handle h,
struct content_entry content 
) [static]

Advance to the next entry in the skiplist.

Definition at line 846 of file ccnd.c.

Referenced by next_child_at_level(), and process_incoming_interest().

static void content_skiplist_remove ( struct ccnd_handle h,
struct content_entry content 
) [static]

Remove an entry from the skiplist.

Definition at line 733 of file ccnd.c.

Referenced by finalize_content().

static int create_local_listener ( struct ccnd_handle h,
const char *  sockname,
int  backlog 
) [static]

Create a listener on a unix-domain socket.

Definition at line 949 of file ccnd.c.

Referenced by ccnd_create().

static void do_deferred_write ( struct ccnd_handle h,
int  fd 
) [static]

Do deferred sends.

These can only happen on streams, after there has been a partial write.

Definition at line 4955 of file ccnd.c.

Referenced by ccnd_run().

static int do_propagate ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Execute the next timed action on a propagating interest.

Definition at line 3374 of file ccnd.c.

Referenced by propagate_interest(), and update_npe_children().

static int drop_nonlocal_interest ( struct ccnd_handle h,
struct nameprefix_entry npe,
struct face face,
unsigned char *  msg,
size_t  size 
) [static]

Check whether the interest should be dropped for local namespace reasons.

Definition at line 3999 of file ccnd.c.

Referenced by process_incoming_interest().

static void enroll_content ( struct ccnd_handle h,
struct content_entry content 
) [static]

Assign an accession number to a content object.

Definition at line 583 of file ccnd.c.

Referenced by process_incoming_content().

static int enroll_face ( struct ccnd_handle h,
struct face face 
) [static]

Assigns the faceid for a nacent face, calls register_new_face() if successful.

Definition at line 306 of file ccnd.c.

Referenced by ccnd_create(), get_dgram_source(), and record_connection().

static int establish_min_recv_bufsize ( struct ccnd_handle h,
int  fd,
int  minsize 
) [static]

Adjust socket buffer limit.

Definition at line 989 of file ccnd.c.

Referenced by setup_multicast().

static int expire_content ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Scheduled event that makes content stale when its FreshnessSeconds has exported.

May actually remove the content if we are over quota.

Definition at line 4216 of file ccnd.c.

Referenced by set_content_timer().

static struct face* face_from_faceid ( struct ccnd_handle h,
unsigned  faceid 
) [static, read]
static int face_send_queue_insert ( struct ccnd_handle h,
struct face face,
struct content_entry content 
) [static]

Queue a ContentObject to be sent on a face.

Definition at line 1493 of file ccnd.c.

Referenced by consume_matching_interests(), and process_incoming_interest().

static unsigned faceid_from_fd ( struct ccnd_handle h,
int  fd 
) [static]

Get the faceid associated with a file descriptor.

Returns:
the faceid, or CCN_NOFACEID.

Definition at line 1228 of file ccnd.c.

Referenced by setup_multicast().

static void finalize_content ( struct hashtb_enumerator content_enumerator  )  [static]

Definition at line 617 of file ccnd.c.

Referenced by ccnd_create().

static void finalize_face ( struct hashtb_enumerator e  )  [static]

Clean up when a face is being destroyed.

This is called when an entry is deleted from one of the hash tables that keep track of faces.

Definition at line 453 of file ccnd.c.

Referenced by ccnd_create().

static void finalize_interest ( struct hashtb_enumerator e  )  [static]

Clean up an interest_entry when it is removed from its hash table.

Definition at line 914 of file ccnd.c.

Referenced by ccnd_create().

static void finalize_nameprefix ( struct hashtb_enumerator e  )  [static]

Clean up a name prefix entry when it is removed from the hash table.

Definition at line 877 of file ccnd.c.

Referenced by ccnd_create().

static struct content_entry* find_first_match_candidate ( struct ccnd_handle h,
const unsigned char *  interest_msg,
const struct ccn_parsed_interest pi 
) [static, read]

Find the first candidate that might match the given interest.

Definition at line 758 of file ccnd.c.

Referenced by process_incoming_interest().

static struct face * get_dgram_source ( struct ccnd_handle h,
struct face face,
struct sockaddr *  addr,
socklen_t  addrlen,
int  why 
) [static, read]

Get (or create) the face associated with a given sockaddr.

Definition at line 4598 of file ccnd.c.

Referenced by ccnd_req_newface(), and process_input().

struct nameprefix_entry* get_fib_npe ( struct ccnd_handle h,
struct interest_entry ie 
) [read]

Find the entry for the longest name prefix that contains forwarding info.

Definition at line 3222 of file ccnd.c.

Referenced by strategy_callout().

static struct ccn_indexbuf* get_outbound_faces ( struct ccnd_handle h,
struct face from,
const unsigned char *  msg,
struct ccn_parsed_interest pi,
struct nameprefix_entry npe 
) [static, read]

This is where we consult the interest forwarding table.

Parameters:
h is the ccnd handle
from is the handle for the originating face (may be NULL).
msg points to the ccnb-encoded interest message
pi must be the parse information for msg
npe should be the result of the prefix lookup
Returns:
Newly allocated set of outgoing faceids (never NULL)

Definition at line 3069 of file ccnd.c.

Referenced by propagate_interest(), and update_npe_children().

static void handle_fatal_signal ( int  sig  )  [static]

Definition at line 179 of file ccnd.c.

Referenced by unlink_at_exit().

static int handle_send_error ( struct ccnd_handle h,
int  errnum,
struct face face,
const void *  data,
size_t  size 
) [static]

Handle errors after send() or sendto().

Returns:
-1 if error has been dealt with, or 0 to defer sending.

Definition at line 4837 of file ccnd.c.

Referenced by ccnd_send().

static int ie_next_usec ( struct ccnd_handle h,
struct interest_entry ie,
ccn_wrappedtime expiry 
) [static]

Compute the delay until the next timed action on an interest.

Definition at line 3116 of file ccnd.c.

Referenced by propagate_interest().

static struct ccn_indexbuf* indexbuf_obtain ( struct ccnd_handle h  )  [static, read]

Obtain an indexbuf for short-term use.

Definition at line 253 of file ccnd.c.

Referenced by process_incoming_content(), and process_incoming_interest().

static void indexbuf_release ( struct ccnd_handle h,
struct ccn_indexbuf c 
) [static]

Release an indexbuf for reuse.

Definition at line 267 of file ccnd.c.

Referenced by process_incoming_content(), and process_incoming_interest().

static void init_face_flags ( struct ccnd_handle h,
struct face face,
int  setflags 
) [static]

Initialize the face flags based upon the addr information and the provided explicit setflags.

Definition at line 1014 of file ccnd.c.

Referenced by get_dgram_source(), and record_connection().

static int is_pending_on ( struct ccnd_handle h,
struct interest_entry ie,
unsigned  faceid 
) [static]

Return true iff the interest is pending on the given face.

Definition at line 1537 of file ccnd.c.

Referenced by consume_matching_interests().

static void link_interest_entry_to_nameprefix ( struct ccnd_handle h,
struct interest_entry ie,
struct nameprefix_entry npe 
) [static]

Link an interest to its name prefix entry.

Definition at line 899 of file ccnd.c.

Referenced by propagate_interest().

static struct face* make_connection ( struct ccnd_handle h,
struct sockaddr *  who,
socklen_t  wholen,
int  setflags 
) [static, read]

Make an outbound stream connection.

Definition at line 1120 of file ccnd.c.

Referenced by ccnd_req_newface().

static void mark_stale ( struct ccnd_handle h,
struct content_entry content 
) [static]

Mark content as stale.

Definition at line 4193 of file ccnd.c.

Referenced by clean_deamon(), expire_content(), and process_incoming_interest().

static int match_interests ( struct ccnd_handle h,
struct content_entry content,
struct ccn_parsed_ContentObject pc,
struct face face,
struct face from_face 
) [static]

Find and consume interests that match given content.

Schedules the sending of the content. If face is not NULL, pay attention only to interests from that face. It is allowed to pass NULL for pc, but if you have a (valid) one it will avoid a re-parse. For new content, from_face is the source; for old content, from_face is NULL.

Returns:
number of matches, or -1 if the new content should be dropped.

Definition at line 1677 of file ccnd.c.

Referenced by process_incoming_content(), and process_incoming_interest().

static int nameprefix_seek ( struct ccnd_handle h,
struct hashtb_enumerator e,
const unsigned char *  msg,
struct ccn_indexbuf comps,
int  ncomps 
) [static]

Creates a nameprefix entry if it does not already exist, together with all of its parents.

Definition at line 3912 of file ccnd.c.

Referenced by ccnd_reg_prefix(), and process_incoming_interest().

static struct content_entry* next_child_at_level ( struct ccnd_handle h,
struct content_entry content,
int  level 
) [static, read]

Definition at line 3959 of file ccnd.c.

Referenced by process_incoming_interest().

static void note_content_from ( struct ccnd_handle h,
struct nameprefix_entry npe,
unsigned  from_faceid,
int  prefix_comps 
) [static]

Keep a little history about where matching content comes from.

Definition at line 1648 of file ccnd.c.

Referenced by match_interests().

static struct pit_face_item * pfi_copy_nonce ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item p,
const struct pit_face_item src 
) [static, read]

Copy a nonce from src into p.

Returns:
p (or its replacement)

Definition at line 3722 of file ccnd.c.

Referenced by send_interest().

static struct pit_face_item* pfi_create ( struct ccnd_handle h,
unsigned  faceid,
unsigned  flags,
const unsigned char *  nonce,
size_t  noncesize,
struct pit_face_item **  pp 
) [static, read]

Used in just one place; could go away.

Definition at line 3551 of file ccnd.c.

Referenced by pfi_set_nonce().

static void pfi_destroy ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item p 
) [static]

Remove the pit face item from the interest entry.

Definition at line 3578 of file ccnd.c.

Referenced by do_propagate(), and pfi_set_nonce().

static int pfi_nonce_matches ( struct pit_face_item p,
const unsigned char *  nonce,
size_t  size 
) [static]

Return true iff the nonce in p matches the given one.

Definition at line 3704 of file ccnd.c.

Referenced by pfi_unique_nonce().

static struct pit_face_item * pfi_seek ( struct ccnd_handle h,
struct interest_entry ie,
unsigned  faceid,
unsigned  pfi_flag 
) [static, read]

Find the pit face item with the given flag set, or create it if not present.

New items are appended to the end of the list

Definition at line 3603 of file ccnd.c.

Referenced by propagate_interest(), and update_npe_children().

static void pfi_set_expiry_from_lifetime ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item p,
intmax_t  lifetime 
) [static]

Set the expiry of the pit face item based upon an interest lifetime.

lifetime is in the units specified by the CCNx protocal - 1/4096 sec

Also sets the renewed timestamp to now.

Definition at line 3631 of file ccnd.c.

Referenced by propagate_interest().

static void pfi_set_expiry_from_micros ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item p,
unsigned  micros 
) [static]

Set the expiry of the pit face item using a time in microseconds from present.

Does not set the renewed timestamp.

Definition at line 3658 of file ccnd.c.

Referenced by strategy_callout().

static struct pit_face_item * pfi_set_nonce ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item p,
const unsigned char *  nonce,
size_t  noncesize 
) [static, read]

Set the nonce in a pit face item.

Returns:
the replacement value, which is p unless the nonce will not fit.

Definition at line 3673 of file ccnd.c.

Referenced by pfi_copy_nonce(), and propagate_interest().

static int pfi_unique_nonce ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item p 
) [static]

True iff the nonce in p does not occur in any of the other items of the entry.

Definition at line 3733 of file ccnd.c.

Referenced by propagate_interest().

static void prepare_poll_fds ( struct ccnd_handle h  )  [static]

Set up the array of fd descriptors for the poll(2) call.

Arrange the array so that multicast receivers are early, so that if the same packet arrives on both a multicast socket and a normal socket, we will count is as multicast.

Definition at line 5008 of file ccnd.c.

Referenced by ccnd_run().

static int process_icb_action ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Scheduled event for deferred processing of internal client.

Definition at line 4806 of file ccnd.c.

Referenced by process_internal_client_buffer_needed().

static void process_incoming_content ( struct ccnd_handle h,
struct face face,
unsigned char *  wire_msg,
size_t  wire_size 
) [static]

Process an arriving ContentObject.

Parse the ContentObject and discard if it is not well-formed.

Compute the digest.

Look it up in the content store. It it is already there, but is stale, make it fresh again. If it is not there, add it.

Find the matching pending interests in the PIT and consume them, queueing the ContentObject to be sent on the associated faces. If no matches were found and the content object was new, discard remove it from the store.

XXX - the change to staleness should also not happen if there was no matching PIT entry.

Definition at line 4301 of file ccnd.c.

Referenced by process_input_message(), r_init_map_and_process_file(), r_proto_expect_content(), r_sync_local_store(), and r_sync_upcall_store().

static void process_incoming_interest ( struct ccnd_handle h,
struct face face,
unsigned char *  msg,
size_t  size 
) [static]

Process an incoming interest message.

Parse the Interest and discard if it does not parse. Check for correct scope (a scope 0 or scope 1 interest should never arrive on an external face). Check for a duplicated Nonce, discard if it has been seen before. Look up the name prefix. Check for a local namespace and discard if an interest in a local namespace arrives from outside. Consult the content store. If a suitable matching ContentObject is found, prepare to send it, consuming this interest and any pending interests on that face that also match this object. Otherwise, initiate propagation of the interest.

Definition at line 4029 of file ccnd.c.

Referenced by process_input_message().

static int process_incoming_link_message ( struct ccnd_handle h,
struct face face,
enum ccn_dtag  dtag,
unsigned char *  msg,
size_t  size 
) [static]

Process an incoming link message.

Definition at line 1866 of file ccnd.c.

Referenced by process_input_message().

static void process_input ( struct ccnd_handle h,
int  fd 
) [static]

Process the input from a socket.

The socket has been found ready for input by the poll call. Decide what face it corresponds to, and after checking for exceptional cases, receive data, parse it into ccnb-encoded messages, and call process_input_message for each one.

Definition at line 4680 of file ccnd.c.

Referenced by ccnd_run().

static void process_input_buffer ( struct ccnd_handle h,
struct face face 
) [static]

Break up data in a face's input buffer buffer into individual messages, and call process_input_message on each one.

This is used to handle things originating from the internal client - its output is input for face 0.

Definition at line 4644 of file ccnd.c.

Referenced by process_internal_client_buffer().

static void process_input_message ( struct ccnd_handle h,
struct face face,
unsigned char *  msg,
size_t  size,
int  pdu_ok 
) [static]

Process an incoming message.

This is where we decide whether we have an Interest message, a ContentObject, or something else.

Definition at line 4468 of file ccnd.c.

Referenced by process_input(), and process_input_buffer().

static void process_internal_client_buffer ( struct ccnd_handle h  )  [static]

Process messages from our internal client.

The internal client's output is input to us.

Definition at line 4789 of file ccnd.c.

Referenced by ccnd_run(), and process_icb_action().

static void process_internal_client_buffer_needed ( struct ccnd_handle h  )  [static]

Schedule the processing of internal client results.

This little dance keeps us from destroying an interest entry while we are in the middle of processing it.

Definition at line 4827 of file ccnd.c.

Referenced by ccnd_send().

static int propagate_interest ( struct ccnd_handle h,
struct face face,
unsigned char *  msg,
struct ccn_parsed_interest pi,
struct nameprefix_entry npe 
) [static]

Schedules the propagation of an Interest message.

Definition at line 3753 of file ccnd.c.

Referenced by process_incoming_interest().

static unsigned randomize_content_delay ( struct ccnd_handle h,
struct content_queue q 
) [static]

Pick a randomized delay for sending.

This is primarily for multicast and similar broadcast situations, where we may see the content being sent by somebody else. If that is the case, we will avoid sending our copy as well.

Definition at line 1378 of file ccnd.c.

Referenced by content_sender(), and face_send_queue_insert().

static int reap ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Scheduled reap event for retiring expired structures.

Definition at line 2075 of file ccnd.c.

Referenced by reap_needed().

static void reap_needed ( struct ccnd_handle h,
int  init_delay_usec 
) [static]

Definition at line 2095 of file ccnd.c.

Referenced by ccnd_create().

static struct face * record_connection ( struct ccnd_handle h,
int  fd,
struct sockaddr *  who,
socklen_t  wholen,
int  setflags 
) [static, read]

Make a new face entered in the faces_by_fd table.

Definition at line 1053 of file ccnd.c.

Referenced by accept_connection(), ccnd_getboundsocket(), ccnd_listen_on_address(), ccnd_listen_on_wildcards(), create_local_listener(), make_connection(), and setup_multicast().

static void register_new_face ( struct ccnd_handle h,
struct face face 
) [static]

Called when a face is first created, and (perhaps) a second time in the case that a face transitions from the undecided state.

Definition at line 2476 of file ccnd.c.

Referenced by enroll_face(), and process_input_message().

static int remove_content ( struct ccnd_handle h,
struct content_entry content 
) [static]

Remove a content object from the store.

Definition at line 2105 of file ccnd.c.

Referenced by clean_deamon(), expire_content(), and process_incoming_content().

static struct sockaddr* scrub_sockaddr ( struct sockaddr *  addr,
socklen_t  addrlen,
struct sockaddr_in6 *  space 
) [static, read]

Since struct sockaddr_in6 may contain fields that should not participate in comparison / hash, ensure the undesired fields are zero.

Per RFC 3493, sin6_flowinfo is zeroed.

Parameters:
addr is the sockaddr (any family)
addrlen is its length
space points to a buffer that may be used for the result.
Returns:
either the original addr or a pointer to a scrubbed copy.

Definition at line 4575 of file ccnd.c.

Referenced by get_dgram_source().

static struct ccn_forwarding* seek_forwarding ( struct ccnd_handle h,
struct nameprefix_entry npe,
unsigned  faceid 
) [static, read]

Look up a forwarding entry, creating it if it is not there.

Definition at line 2320 of file ccnd.c.

Referenced by ccnd_reg_prefix().

static void send_content ( struct ccnd_handle h,
struct face face,
struct content_entry content 
) [static]

Send a ContentObject.

This is after it has worked its way through the queue; update the meters and stuff the packet as appropriate.

Definition at line 1328 of file ccnd.c.

Referenced by content_sender().

static struct pit_face_item* send_interest ( struct ccnd_handle h,
struct interest_entry ie,
struct pit_face_item x,
struct pit_face_item p 
) [static, read]

Forward an interest message.

x is downstream (the interest came x). p is upstream (the interest is to be forwarded to p).

Returns:
p (or its reallocated replacement).

Definition at line 3182 of file ccnd.c.

Referenced by do_propagate(), and strategy_callout().

static int sending_fd ( struct ccnd_handle h,
struct face face 
) [static]

Determine what socket to use to send on a face.

For streams, this just returns the associated fd.

For datagrams, one fd may be in use for many faces, so we need to find the right one to use.

This is not as smart as it should be for situations where CCND_LISTEN_ON has been specified.

Definition at line 4870 of file ccnd.c.

Referenced by ccnd_send().

static void set_content_timer ( struct ccnd_handle h,
struct content_entry content,
struct ccn_parsed_ContentObject pco 
) [static]

Schedules content expiration based on its FreshnessSeconds, and the configured default and limit.

Definition at line 4248 of file ccnd.c.

Referenced by process_incoming_content().

static struct face* setup_multicast ( struct ccnd_handle h,
struct ccn_face_instance face_instance,
struct sockaddr *  who,
socklen_t  wholen 
) [static, read]

Set up a multicast face.

Definition at line 1242 of file ccnd.c.

Referenced by ccnd_req_newface().

static void shutdown_client_fd ( struct ccnd_handle h,
int  fd 
) [static]

Close a socket, destroying the associated face.

Definition at line 1293 of file ccnd.c.

Referenced by ccnd_destroy_face(), ccnd_run(), do_deferred_write(), and process_input().

static void strategy_callout ( struct ccnd_handle h,
struct interest_entry ie,
enum ccn_strategy_op  op 
) [static]

This implements the default strategy.

Eventually there will be a way to have other strategies.

Definition at line 3275 of file ccnd.c.

Referenced by consume_matching_interests(), do_propagate(), propagate_interest(), and strategy_timer().

static void strategy_settimer ( struct ccnd_handle h,
struct interest_entry ie,
int  usec,
enum ccn_strategy_op  op 
) [static]

Schedule a strategy wakeup.

Any previously wakeup will be cancelled.

Definition at line 3257 of file ccnd.c.

Referenced by strategy_callout().

static int strategy_timer ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Implementation detail for strategy_settimer.

Definition at line 3234 of file ccnd.c.

Referenced by strategy_settimer().

static void stuff_and_send ( struct ccnd_handle h,
struct face face,
const unsigned char *  data1,
size_t  size1,
const unsigned char *  data2,
size_t  size2,
const char *  tag,
int  lineno 
) [static]

Send a message in a PDU, possibly stuffing other interest messages into it.

The message may be in two pieces.

Definition at line 1716 of file ccnd.c.

Referenced by send_content(), and send_interest().

static int stuff_link_check ( struct ccnd_handle h,
struct face face,
struct ccn_charbuf c 
) [static]

Append a link-check interest if appropriate.

Returns:
the number of messages that were stuffed.

Definition at line 1765 of file ccnd.c.

Referenced by ccn_stuff_interest().

static void unlink_at_exit ( const char *  path  )  [static]

Record the name of the unix-domain listener.

Sets up signal handlers in case we are stopping due to a signal.

Definition at line 191 of file ccnd.c.

Referenced by create_local_listener().

static void update_forward_to ( struct ccnd_handle h,
struct nameprefix_entry npe 
) [static]

Set up forward_to list for a name prefix entry.

Recomputes the contents of npe->forward_to and npe->flags from forwarding lists of npe and all of its ancestors.

Definition at line 3004 of file ccnd.c.

Referenced by drop_nonlocal_interest(), get_outbound_faces(), and match_interests().

static void update_npe_children ( struct ccnd_handle h,
struct nameprefix_entry npe,
unsigned  faceid 
) [static]

We have a FIB change - accelerate forwarding of existing interests.

Definition at line 3850 of file ccnd.c.

Referenced by ccnd_reg_prefix().

static int wt_compare ( ccn_wrappedtime  a,
ccn_wrappedtime  b 
) [static]

Compare two wrapped time values.

Returns:
negative if a < b, 0 if a == b, positive if a > b

Definition at line 3541 of file ccnd.c.

Referenced by do_propagate(), propagate_interest(), and update_npe_children().


Variable Documentation

const char* unlink_this_at_exit = NULL [static]

Name of our unix-domain listener.

This tiny bit of global state is needed so that the unix-domain listener can be removed at shutdown.

Definition at line 167 of file ccnd.c.

Referenced by check_comm_file(), cleanup_at_exit(), comm_file_ok(), and unlink_at_exit().

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