00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <stdio.h>
00024 #include <sys/time.h>
00025 #include <stdarg.h>
00026 #include <time.h>
00027 #include <unistd.h>
00028
00029 #include <ccn/ccn.h>
00030 #include <ccn/ccnd.h>
00031 #include <ccn/charbuf.h>
00032 #include <ccn/uri.h>
00033
00034 #include "ccnd_private.h"
00035
00036 #include <android/log.h>
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 void
00047 ccnd_msg(struct ccnd_handle *h, const char *fmt, ...)
00048 {
00049 struct timeval t;
00050 va_list ap;
00051 struct ccn_charbuf *b;
00052
00053 if (h != NULL && h->debug == 0)
00054 return;
00055
00056 b = ccn_charbuf_create();
00057
00058 gettimeofday(&t, NULL);
00059 ccn_charbuf_putf(b, "%ld.%06u ccnd[%d]: %s\n",
00060 (long)t.tv_sec, (unsigned)t.tv_usec, (int)getpid(), fmt);
00061 va_start(ap, fmt);
00062
00063 __android_log_vprint(ANDROID_LOG_INFO, "CCND", (const char *)b->buf, ap);
00064 va_end(ap);
00065 ccn_charbuf_destroy(&b);
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 void
00079 ccnd_debug_ccnb(struct ccnd_handle *h,
00080 int lineno,
00081 const char *msg,
00082 struct face *face,
00083 const unsigned char *ccnb,
00084 size_t ccnb_size)
00085 {
00086 struct ccn_charbuf *c;
00087 struct ccn_parsed_interest pi;
00088 const unsigned char *nonce = NULL;
00089 size_t nonce_size = 0;
00090 size_t i;
00091
00092 if (h != NULL && h->debug == 0)
00093 return;
00094 c = ccn_charbuf_create();
00095 ccn_charbuf_putf(c, "debug.%d %s ", lineno, msg);
00096 if (face != NULL)
00097 ccn_charbuf_putf(c, "%u ", face->faceid);
00098 ccn_uri_append(c, ccnb, ccnb_size, 1);
00099 ccn_charbuf_putf(c, " (%u bytes)", (unsigned)ccnb_size);
00100 if (ccn_parse_interest(ccnb, ccnb_size, &pi, NULL) >= 0) {
00101 ccn_ref_tagged_BLOB(CCN_DTAG_Nonce, ccnb,
00102 pi.offset[CCN_PI_B_Nonce],
00103 pi.offset[CCN_PI_E_Nonce],
00104 &nonce,
00105 &nonce_size);
00106 if (nonce_size > 0) {
00107 ccn_charbuf_putf(c, " ");
00108 for (i = 0; i < nonce_size; i++)
00109 ccn_charbuf_putf(c, "%02X", nonce[i]);
00110 }
00111 }
00112 ccnd_msg(h, "%s", ccn_charbuf_as_string(c));
00113 ccn_charbuf_destroy(&c);
00114 }
00115
00116
00117
00118
00119
00120
00121 void
00122 ccnd_usage(void)
00123 {
00124 static const char ccnd_usage_message[] =
00125 "ccnd - CCNx Daemon\n"
00126 " options: none\n"
00127 " arguments: none\n"
00128 " environment variables:\n"
00129 " CCND_DEBUG=\n"
00130 " 0 - no stderr messages\n"
00131 " 1 - default stderr messages (any non-zero value gets these)\n"
00132 " 2 - interest messages\n"
00133 " 4 - content messages\n"
00134 " 8 - matching details\n"
00135 " 16 - interest details\n"
00136 " 32 - gory interest details\n"
00137 " 64 - log occasional human-readable timestamps\n"
00138 " 128 - face registration debugging\n"
00139 " bitwise OR these together for combinations; -1 gets everything\n"
00140 " CCN_LOCAL_PORT=\n"
00141 " UDP port for unicast clients (default %s).\n"
00142 " Also listens on this TCP port for stream connections.\n"
00143 " Also affects name of unix-domain socket.\n"
00144 " CCND_CAP=\n"
00145 " Capacity limit, in count of ContentObjects.\n"
00146 " Not an absolute limit.\n"
00147 " CCND_MTU=\n"
00148 " Packet size in bytes.\n"
00149 " If set, interest stuffing is allowed within this budget.\n"
00150 " Single items larger than this are not precluded.\n"
00151 " CCND_DATA_PAUSE_MICROSEC=\n"
00152 " Adjusts content-send delay time for multicast and udplink faces\n";
00153 fprintf(stderr, ccnd_usage_message, CCN_DEFAULT_UNICAST_PORT);
00154 }
00155