ccnr_main.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <signal.h>
00024 #include <stddef.h>
00025 #include <stdarg.h>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028
00029 #include "ccnr_private.h"
00030
00031 #include "ccnr_init.h"
00032 #include "ccnr_dispatch.h"
00033 #include "ccnr_msg.h"
00034 #include "ccnr_stats.h"
00035
00036 static int
00037 stdiologger(void *loggerdata, const char *format, va_list ap)
00038 {
00039 FILE *fp = (FILE *)loggerdata;
00040 return(vfprintf(fp, format, ap));
00041 }
00042
00043 static struct ccnr_handle *global_h = NULL;
00044
00045 static void
00046 handle_signal(int sig)
00047 {
00048 if (global_h != NULL)
00049 global_h->running = 0;
00050 signal(sig, SIG_DFL);
00051 }
00052
00053
00054
00055 static const char *ccnr_usage_message =
00056 "ccnr - CCNx Repository Daemon\n"
00057 " options: none\n"
00058 " arguments: none\n"
00059 " configuration (via $CCNR_DIRECTORY/config or environment):\n"
00060 " CCNR_DEBUG=WARNING\n"
00061 " Debug logging level:\n"
00062 " NONE - no messages\n"
00063 " SEVERE - severe, probably fatal, errors\n"
00064 " ERROR - errors\n"
00065 " WARNING - warnings\n"
00066 " INFO - informational messages\n"
00067 " FINE, FINER, FINEST - debugging/tracing\n"
00068 " CCNR_DIRECTORY=.\n"
00069 " Directory where ccnr data is kept\n"
00070 " Defaults to current directory\n"
00071 " Ignored in config file\n"
00072 " CCNR_GLOBAL_PREFIX=ccnx:/parc.com/csl/ccn/Repos\n"
00073 " CCNx URI representing the prefix where data/policy.xml is stored.\n"
00074 " Only meaningful if no policy file exists at startup.\n"
00075 " CCNR_START_WRITE_SCOPE_LIMIT=3\n"
00076 " 0..3 (default 3) Process start-write(-checked) interests with a scope\n"
00077 " not exceeding the given value. 0 is effectively read-only. 3 indicates unlimited.\n"
00078 " CCNR_BTREE_MAX_FANOUT=1999\n"
00079 " 4..9999 (default 1999) Maximum number of entries within a node.\n"
00080 " CCNR_BTREE_MAX_LEAF_ENTRIES=1999\n"
00081 " 4..9999 (default 1999) Maximum number of entries within a node at level 0.\n"
00082 " CCNR_BTREE_MAX_NODE_BYTES=2097152\n"
00083 " 1024..8388608 (default 2097152) Maximum node size (bytes).\n"
00084 " CCNR_BTREE_NODE_POOL=512\n"
00085 " 16..2000000 (default 512) Maximum number of btree nodes in memory.\n"
00086 " CCNR_CONTENT_CACHE=4201\n"
00087 " 16..2000000 (default 4201) Maximum number of ContentObjects cached in memory.\n"
00088 " CCNR_MIN_SEND_BUFSIZE=16384\n"
00089 " Minimum in bytes for output socket buffering.\n"
00090 " CCNR_PROTO=unix\n"
00091 " Specify 'tcp' to connect to ccnd using tcp instead of unix ipc.\n"
00092 " CCNR_LISTEN_ON=\n"
00093 " List of ip addresses to listen on for status; defaults to localhost addresses.\n"
00094 " CCNR_STATUS_PORT=\n"
00095 " Port to use for status server; default is to not serve status.\n"
00096 " CCNS_DEBUG=WARNING\n"
00097 " Same values as for CCNR_DEBUG.\n"
00098 " CCNS_ENABLE=1\n"
00099 " Disable (0) or enable (1, default) Sync processing.\n"
00100 " CCNS_REPO_STORE=1\n"
00101 " Disable (0) or enable (1, default) storing Sync state in repository.\n"
00102 " CCNS_STABLE_ENABLED=1\n"
00103 " Disable (0) or enable (1, default) storing Sync stable-points to repository.\n"
00104 " CCNS_FAUX_ERROR=0\n"
00105 " Disable (0, default) or enable (1-99) percent simulated random packet loss.\n"
00106 " CCNS_HEARTBEAT_MICROS=200000\n"
00107 " 100000..10000000 (default 200000) microseconds between Sync heartbeats.\n"
00108 " CCNS_ROOT_ADVISE_FRESH=4\n"
00109 " 1..30 (default 4) freshness (seconds) for Sync root advise response.\n"
00110 " CCNS_ROOT_ADVISE_LIFETIME=20\n"
00111 " 1..30 (default 20) lifetime (seconds) for Sync root advise response.\n"
00112 " CCNS_NODE_FETCH_LIFETIME=4\n"
00113 " 1..30 (default 4) lifetime (seconds) for Sync node fetch response.\n"
00114 " CCNS_MAX_FETCH_BUSY=6\n"
00115 " 1..100 (default 6) maximum simultaneous node or content fetches per Sync root.\n"
00116 " CCNS_MAX_COMPARES_BUSY=4\n"
00117 " 1..100 (default 4) maximum simultaneous Sync roots in compare state.\n"
00118 " CCNS_NOTE_ERR=0\n"
00119 " Disable (0, default) or enable (1) exceptional Sync error reporting.\n"
00120 ;
00121
00122 int
00123 main(int argc, char **argv)
00124 {
00125 int s;
00126
00127 if (argc > 1) {
00128 fprintf(stderr, "%s", ccnr_usage_message);
00129 exit(1);
00130 }
00131 signal(SIGPIPE, SIG_IGN);
00132 global_h = r_init_create(argv[0], stdiologger, stderr);
00133 if (global_h == NULL)
00134 exit(1);
00135 signal(SIGINT, &handle_signal);
00136 signal(SIGTERM, &handle_signal);
00137 signal(SIGXFSZ, &handle_signal);
00138 r_dispatch_run(global_h);
00139 s = (global_h->running != 0);
00140 ccnr_msg(global_h, "exiting.");
00141 r_init_destroy(&global_h);
00142 exit(s);
00143 }