static void ccnd_stats_http_set_debug(struct ccnd_handle *h, struct face *face, int level) { struct ccn_charbuf *response = ccn_charbuf_create(); h->debug = 1; ccnd_msg(h, "CCND_DEBUG=%d", level); h->debug = level; ccn_charbuf_putf(response, "<title>CCND_DEBUG=%d</title><tt>CCND_DEBUG=%d</tt>" CRLF, level, level); send_http_response(h, face, "text/html", response); ccn_charbuf_destroy(&response); }
int main(int argc, char **argv) { struct ccnd_handle *h; if (argc > 1) { fprintf(stderr, "%s", ccnd_usage_message); exit(1); } signal(SIGPIPE, SIG_IGN); h = ccnd_create(argv[0], stdiologger, stderr); if (h == NULL) exit(1); ccnd_run(h); ccnd_msg(h, "exiting."); ccnd_destroy(&h); ERR_remove_state(0); EVP_cleanup(); exit(0); }
/** * Produce a ccnd debug trace entry. * Output is produced by calling ccnd_msg. * @param h the ccnd handle * @param lineno caller's source line number (usually __LINE__) * @param msg a short text tag to identify the entry * @param face handle of associated face; may be NULL * @param ccnb points to ccnb-encoded Interest or ContentObject * @param ccnb_size is in bytes */ void ccnd_debug_ccnb(struct ccnd_handle *h, int lineno, const char *msg, struct face *face, const unsigned char *ccnb, size_t ccnb_size) { struct ccn_charbuf *c; struct ccn_parsed_interest pi; const unsigned char *nonce = NULL; size_t nonce_size = 0; size_t i; if (h != NULL && h->debug == 0) return; c = ccn_charbuf_create(); ccn_charbuf_putf(c, "debug.%d %s ", lineno, msg); if (face != NULL) ccn_charbuf_putf(c, "%u ", face->faceid); ccn_uri_append(c, ccnb, ccnb_size, 1); ccn_charbuf_putf(c, " (%u bytes)", (unsigned)ccnb_size); if (ccn_parse_interest(ccnb, ccnb_size, &pi, NULL) >= 0) { const char *p = ""; ccn_ref_tagged_BLOB(CCN_DTAG_Nonce, ccnb, pi.offset[CCN_PI_B_Nonce], pi.offset[CCN_PI_E_Nonce], &nonce, &nonce_size); if (nonce_size > 0) { ccn_charbuf_putf(c, " "); if (nonce_size == 12) p = "CCC-P-F-T-NN"; for (i = 0; i < nonce_size; i++) ccn_charbuf_putf(c, "%s%02X", (*p) && (*p++)=='-' ? "-" : "", nonce[i]); } } ccnd_msg(h, "%s", ccn_charbuf_as_string(c)); ccn_charbuf_destroy(&c); }
int ccnd_stats_handle_http_connection(struct ccnd_handle *h, struct face *face) { struct ccn_charbuf *response = NULL; char rbuf[16]; int i; int nspace; int n; ccnd_msg(h, "========== in ccnd_stats_handle_http_connection, face = %d", face); if (face->inbuf->length < 4) return(-1); if ((face->flags & CCN_FACE_NOSEND) != 0) { ccnd_destroy_face(h, face->faceid); return(-1); } ccnd_msg(h, "============ before n = sizeof(rbuf) - 1;"); n = sizeof(rbuf) - 1; if (face->inbuf->length < n) n = face->inbuf->length; for (i = 0, nspace = 0; i < n && nspace < 2; i++) { rbuf[i] = face->inbuf->buf[i]; if (rbuf[i] == ' ') nspace++; } ccnd_msg(h, "============= before rbuf[i] = 0;"); rbuf[i] = 0; if (nspace < 2 && i < sizeof(rbuf) - 1) return(-1); if (0 == strcmp(rbuf, "GET / ") || 0 == strcmp(rbuf, "GET /? ")) { ccnd_msg(h, "============== in 1 if"); response = collect_stats_html(h); ccnd_msg(h, "============== before send_http_response"); send_http_response(h, face, "text/html", response); } else if (0 == strcmp(rbuf, "GET /?l=none ")) { ccnd_msg(h, "============== in 2 else if"); ccnd_stats_http_set_debug(h, face, 0); } else if (0 == strcmp(rbuf, "GET /?l=low ")) { ccnd_msg(h, "============= in 3 else if"); ccnd_stats_http_set_debug(h, face, 1); } else if (0 == strcmp(rbuf, "GET /?l=co ")) { ccnd_msg(h, "============= in 4 else if"); ccnd_stats_http_set_debug(h, face, 4); } else if (0 == strcmp(rbuf, "GET /?l=med ")) { ccnd_msg(h, "============= in 5 else if"); ccnd_stats_http_set_debug(h, face, 71); } else if (0 == strcmp(rbuf, "GET /?l=high ")) { ccnd_msg(h, "============= in 6 else if"); ccnd_stats_http_set_debug(h, face, -1); } else if (0 == strcmp(rbuf, "GET /?f=xml ")) { ccnd_msg(h, "============= in 7 else if"); response = collect_stats_xml(h); send_http_response(h, face, "text/xml", response); } else if (0 == strcmp(rbuf, "GET ")){ ccnd_msg(h, "============= in 8 else if"); ccnd_send(h, face, resp404, strlen(resp404)); } else{ ccnd_msg(h, "============= in 9 else"); ccnd_send(h, face, resp405, strlen(resp405)); } face->flags |= (CCN_FACE_NOSEND | CCN_FACE_CLOSING); ccnd_msg(h, "=========== before ccn_charbuf_destroy(&response);"); ccn_charbuf_destroy(&response); return(0); }
static int ccnd_collect_stats(struct ccnd_handle *h, struct ccnd_stats *ans) { struct hashtb_enumerator ee; struct hashtb_enumerator *e = ⅇ long sum; unsigned i; for (sum = 0, hashtb_start(h->nameprefix_tab, e); e->data != NULL; hashtb_next(e)) { struct nameprefix_entry *npe = e->data; struct ielinks *head = &npe->ie_head; struct ielinks *ll; ccnd_msg(h, "================= before inner for: head = %d, npt = %d, head->next = %d", head, npe, head->next); for (ll = head->next; ll != head; ll = ll->next) { //Shen Li: as ll is the first element in interest_entry, so &ll == &ie struct interest_entry *ie = (struct interest_entry *)ll; struct pit_face_item *p; ccnd_msg(h, "=============== before inner inner for: ie->pfl = %d", ie->pfl); for (p = ie->pfl; p != NULL; p = p->next){ ccnd_msg(h, "============ p = %d", p); ccnd_msg(h, "============ ie->interest_msg = %d, ie->size = %d", ie->interest_msg, ie->size); print_msg(ie->interest_msg, ie->size, 200); ccnd_msg(h, "========== p->pfi_flags = %d, p->faceid = %d, p->next = %d", p->pfi_flags, p->faceid, p->next); if ((p->pfi_flags & CCND_PFI_PENDING) != 0){ ccnd_msg(h, "============= in first if"); if (ccnd_face_from_faceid(h, p->faceid) != NULL){ ccnd_msg(h, "=============== in second if"); sum += 1; } } ccnd_msg(h, "========== p->pfi_flags, p->faceid, p->next", p->pfi_flags, p->faceid, p->next); } ccnd_msg(h, "=============== after inner inner for: ie->pfl = %d", ie->pfl); } ccnd_msg(h, "================= after inner for: head = %d, npt = %d, head->next = %d", head, npe, head->next); } ans->total_interest_counts = sum; hashtb_end(e); ans->total_flood_control = 0; /* N/A */ /* Do a consistency check on pending interest counts */ for (sum = 0, i = 0; i < h->face_limit; i++) { struct face *face = h->faces_by_faceid[i]; if (face != NULL) sum += face->pending_interests; } if (sum != ans->total_interest_counts) ccnd_msg(h, "ccnd_collect_stats found inconsistency %ld != %ld\n", (long)sum, (long)ans->total_interest_counts); ans->total_interest_counts = sum; return(0); }