const char* ccnl_matchMode2str(int mode) { switch (mode) { case CMP_EXACT: return CONSTSTR("CMP_EXACT"); case CMP_MATCH: return CONSTSTR("CMP_MATCH"); case CMP_LONGEST: return CONSTSTR("CMP_LONGEST"); } return CONSTSTR("?"); }
static void sessionTracerLogStop (const char *domain, const char *type, int caused_by_failure, const char *reason, u_int32_t established, u_int32_t duration) { aslmsg m; char * buf; char data[256] = {0}; m = asl_new(ASL_TYPE_MSG); asl_set(m, "com.apple.message.domain", domain); asl_set(m, "com.apple.message.type", type); asl_set(m, ASL_KEY_FACILITY, domain); asl_set(m, ASL_KEY_MSG, sessionString); if (caused_by_failure) { asl_set(m, "com.apple.message.result", CONSTSTR("failure")); // failure } else { asl_set(m, "com.apple.message.result", CONSTSTR("success")); // success } if (reason) { asl_set(m, "com.apple.message.reason", reason); } else { // reason was NULL; make sure success/failure have different signature if (caused_by_failure) { asl_set(m, "com.apple.message.reason", CONSTSTR("Internal/Server-side error")); } else { asl_set(m, "com.apple.message.reason", CONSTSTR("User/System initiated the disconnect")); } } buf = sessionTracerBucketizeTime(duration); if (established) { asl_set(m, "com.apple.message.connectiontime", buf); // stuff the up time into value snprintf(data, sizeof(data), "SCNCController: Disconnecting."); asl_set(m, "com.apple.message.controller", data); asl_log(NULL, m, ASL_LEVEL_NOTICE, ""); } else { asl_set(m, "com.apple.message.negotiatingtime", buf); /// stuff the negoing time into value2 snprintf(data, sizeof(data), "SCNCController: Disconnecting."); asl_set(m, "com.apple.message.controller", data); asl_log(NULL, m, ASL_LEVEL_NOTICE, ""); } asl_free(m); }
void sessionTracerLogEstablished (struct service *serv) { if (serv) { aslmsg m; char data[256] = {0}; const char *type = sessionGetType(serv); if (!strcmp(type, nullString)) { /* We do not trace VPN */ return; } const char *domain = sessionGetConnectionLessDomain(); if (sessionCheckIfEstablished(serv)) { // already established no need to log (mostly here due to sleep-wake) return; } sessionIsEstablished(serv); m = asl_new(ASL_TYPE_MSG); asl_set(m, "com.apple.message.domain", domain); asl_set(m, "com.apple.message.type", type); asl_set(m, "com.apple.message.result", CONSTSTR("success")); asl_set(m, "com.apple.message.reason", CONSTSTR("established")); asl_set(m, ASL_KEY_FACILITY, domain); asl_set(m, ASL_KEY_MSG, sessionString); sessionTracerLogPPPInfo(m, serv); snprintf(data, sizeof(data), "SCNCController: Connected."); asl_set(m, "com.apple.message.controller", data); asl_log(NULL, m, ASL_LEVEL_NOTICE, ""); asl_free(m); } }
const char* ccnl_enc2str(int enc) { switch(enc) { case CCNL_ENC_CCNB: return CONSTSTR("ccnb"); case CCNL_ENC_NDN2013: return CONSTSTR("ndn2013"); case CCNL_ENC_CCNX2014: return CONSTSTR("ccnbx2014"); case CCNL_ENC_IOT2014: return CONSTSTR("iot2014"); case CCNL_ENC_LOCALRPC: return CONSTSTR("localrpc"); case CCNL_ENC_CISCO2015: return CONSTSTR("cisco2015"); default: break; } return CONSTSTR("?"); }
int ccnl_snprintfPrefixPathDetailed(char *buf, unsigned int buflen, struct ccnl_prefix_s *pr, int ccntlv_skip, int escape_components, int call_slash) { int i, j; char *tmpBuf = buf; unsigned int remLen = buflen, totalLen = 0, skip = 0; // Conform to snprintf standard assert((buf != NULL || buflen == 0) && "buf can be (null) only if buflen is zero"); if (!pr) { int numChars = snprintf(buf, buflen, "%p", (void *) NULL); if (numChars < 0) goto encodingError; else if ((unsigned int) numChars >= buflen) goto notEnoughCapacity; return numChars; } #ifdef USE_NFN if (pr->nfnflags & CCNL_PREFIX_NFN) ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR("nfn")); if (pr->nfnflags & CCNL_PREFIX_THUNK) ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR("thunk")); if (pr->nfnflags) ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR("[")); #endif #if (defined(USE_SUITE_CCNTLV) || defined(USE_SUITE_CISTLV)) // && defined(USE_NFN) // In the future it is possibly helpful to see the type information // in the logging output. However, this does not work with NFN because // it uses this function to create the names in NFN expressions // resulting in CCNTLV type information names within expressions. if (ccntlv_skip && (0 #ifdef USE_SUITE_CCNTLV || pr->suite == CCNL_SUITE_CCNTLV #endif #ifdef USE_SUITE_CISTLV || pr->suite == CCNL_SUITE_CISTLV #endif )) skip = 4; #endif for (i = 0; i < pr->compcnt; i++) { #ifdef USE_NFN if (call_slash || (strncmp("call", (char*) pr->comp[i]+skip, 4) && strncmp("(call", (char*) pr->comp[i]+skip, 5))) { #endif ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR("/")); #ifdef USE_NFN } else { ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR(" ")); } #endif for (j = skip; j < pr->complen[i]; j++) { unsigned char c = pr->comp[i][j]; if (c < 0x20 || c >= 0x7f || (escape_components && c == '/')) ccnl_snprintf(&tmpBuf,&remLen,&totalLen, CONSTSTR("%%%02x"), c); else ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR("%c"), c); } } #ifdef USE_NFN if (pr->nfnflags) { ccnl_snprintf(&tmpBuf, &remLen, &totalLen, CONSTSTR("]")); } #endif if (!tmpBuf) goto encodingError; if (totalLen >= buflen) goto notEnoughCapacity; return totalLen; notEnoughCapacity: DEBUGMSG_CPFX(WARNING, "Buffer has not enough capacity for prefix name. Available: %u, needed: %u\n", buflen, totalLen+1); return totalLen; encodingError: DEBUGMSG_CPFX(ERROR, "Encoding error occured while creating path of prefix: %p\n", (void *) pr); if (buf && buflen > 0) { buf[0] = '\0'; } return -1; }