// C-Level interrupt/exception handler. NOTE: We are running on the stack // of the thread that was interrupted! void irq_handle_exception(int code, uint32 errcode) { int handled = 0; // Nested exception? if (inside_int) { irq_handler hnd = irq_handlers[EXC_DOUBLE_FAULT]; if (hnd != NULL) hnd(EXC_DOUBLE_FAULT, irq_srt_addr); else irq_dump_regs(code, errcode); thd_pslist(dbgio_printf); process_print_list(dbgio_printf); panic("double fault"); } inside_int = 1; // If there's a global handler, call it if (irq_hnd_global) { irq_hnd_global(code, irq_srt_addr); handled = 1; } // If there's a handler, call it { irq_handler hnd = irq_handlers[code]; if (hnd != NULL) { hnd(code, irq_srt_addr); handled = 1; } } // Did it get handled? if (!handled) { irq_handler hnd = irq_handlers[EXC_UNHANDLED_EXC]; if (hnd != NULL) hnd(code, irq_srt_addr); else irq_dump_regs(code, errcode); panic("unhandled IRQ/Exception"); } inside_int = 0; }
T& get (const std::string& filename, int type) { Synchronizable::lock_holder hnd(synchronize()); if (assets.count(type) == 0) { gdx_cpp::Gdx::app->error("AssetManager.hpp", "Asset '%s' not loaded", filename.c_str()); } const AssetMap& assetsByType = assets[type]; assert(assetsByType.count(filename)); T& asset = (T&) *assetsByType[filename]; return asset; }
static int dissect_ipmi_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint hf_parent_item, gint ett_tree, const ipmi_context_t * ctx) { ipmi_packet_data_t * data; ipmi_netfn_t * cmd_list; ipmi_cmd_t * cmd; proto_item * ti; proto_tree * cmd_tree = NULL, * tmp_tree; guint8 prev_level, cc_val; guint offset, siglen, is_resp; const char * cc_str, * netfn_str; /* get packet data */ data = get_packet_data(pinfo); if (!data) { return 0; } /* get prefix length */ siglen = ipmi_getsiglen(ctx->hdr.netfn); /* get response flag */ is_resp = ctx->hdr.netfn & 1; /* check message length */ if (tvb_captured_length(tvb) < ctx->hdr_len + siglen + is_resp + !(ctx->flags & IPMI_D_NO_CKS)) { /* don bother with anything */ return call_data_dissector(tvb, pinfo, tree); } /* save nest level */ prev_level = data->curr_level; /* assign next nest level */ data->curr_level = data->next_level; /* increment next nest level */ data->next_level++; /* check for the first invocation */ if (!data->curr_level) { /* get current frame data */ data->curr_frame = get_frame_data(data, pinfo->num); data->curr_frame_num = pinfo->num; /* copy frame timestamp */ memcpy(&data->curr_frame->ts, &pinfo->abs_ts, sizeof(nstime_t)); /* cache channel and direction */ data->curr_channel = ctx->hdr.channel; data->curr_dir = ctx->hdr.dir; /* remove requests which are too old */ remove_old_requests(data, &pinfo->abs_ts); } if (data->curr_level < MAX_NEST_LEVEL) { if (ctx->hdr.netfn & 1) { /* perform request/response matching */ match_request_response(data, &ctx->hdr, ctx->flags); } else { /* add request to the list for later matching */ add_request(data, &ctx->hdr); } } /* get command list by network function code */ cmd_list = ipmi_getnetfn(ctx->hdr.netfn, tvb_get_ptr(tvb, ctx->hdr_len + is_resp, siglen)); /* get command descriptor */ cmd = ipmi_getcmd(cmd_list, ctx->hdr.cmd); /* check if response */ if (is_resp) { /* get completion code */ cc_val = tvb_get_guint8(tvb, ctx->hdr_len); /* get completion code desc */ cc_str = ipmi_get_completion_code(cc_val, cmd); } else { cc_val = 0; cc_str = NULL; } /* check if not inside a message */ if (!data->curr_level) { /* add packet info */ add_command_info(pinfo, cmd, is_resp, cc_val, cc_str, ctx->flags & IPMI_D_BROADCAST ? TRUE : FALSE); } if (tree) { /* add parent node */ if (!data->curr_level) { ti = proto_tree_add_item(tree, hf_parent_item, tvb, 0, -1, ENC_NA); cmd_tree = proto_item_add_subtree(ti, ett_tree); } else { char str[ITEM_LABEL_LENGTH]; if (is_resp) { g_snprintf(str, ITEM_LABEL_LENGTH, "Rsp, %s, %s", cmd->desc, cc_str); } else { g_snprintf(str, ITEM_LABEL_LENGTH, "Req, %s", cmd->desc); } if (proto_registrar_get_ftype(hf_parent_item) == FT_STRING) { ti = proto_tree_add_string(tree, hf_parent_item, tvb, 0, -1, str); cmd_tree = proto_item_add_subtree(ti, ett_tree); } else cmd_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tree, NULL, str); } if (data->curr_level < MAX_NEST_LEVEL) { /* check if response */ if (ctx->hdr.netfn & 1) { /* get current command data */ ipmi_cmd_data_t * rs_data = data->curr_frame->cmd_data[data->curr_level]; if (rs_data->matched_frame_num) { nstime_t ns; /* add "Request to:" field */ ti = proto_tree_add_uint(cmd_tree, hf_ipmi_response_to, tvb, 0, 0, rs_data->matched_frame_num); /* mark field as a generated one */ PROTO_ITEM_SET_GENERATED(ti); /* calculate delta time */ nstime_delta(&ns, &pinfo->abs_ts, &get_frame_data(data, rs_data->matched_frame_num)->ts); /* add "Response time" field */ ti = proto_tree_add_time(cmd_tree, hf_ipmi_response_time, tvb, 0, 0, &ns); /* mark field as a generated one */ PROTO_ITEM_SET_GENERATED(ti); } } else { /* get current command data */ ipmi_cmd_data_t * rq_data = data->curr_frame->cmd_data[data->curr_level]; if (rq_data->matched_frame_num) { /* add "Response in:" field */ ti = proto_tree_add_uint(cmd_tree, hf_ipmi_response_in, tvb, 0, 0, rq_data->matched_frame_num); /* mark field as a generated one */ PROTO_ITEM_SET_GENERATED(ti); } } } /* set starting offset */ offset = 0; /* check if message is broadcast */ if (ctx->flags & IPMI_D_BROADCAST) { /* skip first byte */ offset++; } /* check if session handle is specified */ if (ctx->flags & IPMI_D_SESSION_HANDLE) { /* add session handle field */ proto_tree_add_item(cmd_tree, hf_ipmi_session_handle, tvb, offset++, 1, ENC_LITTLE_ENDIAN); } /* check if responder address is specified */ if (ctx->flags & IPMI_D_TRG_SA) { /* add response address field */ proto_tree_add_item(cmd_tree, hf_ipmi_header_trg, tvb, offset++, 1, ENC_LITTLE_ENDIAN); } /* get NetFn string */ netfn_str = ipmi_getnetfnname(ctx->hdr.netfn, cmd_list); /* Network function + target LUN */ tmp_tree = proto_tree_add_subtree_format(cmd_tree, tvb, offset, 1, ett_header_byte_1, NULL, "Target LUN: 0x%02x, NetFN: %s %s (0x%02x)", ctx->hdr.rs_lun, netfn_str, is_resp ? "Response" : "Request", ctx->hdr.netfn); /* add Net Fn */ proto_tree_add_uint_format(tmp_tree, hf_ipmi_header_netfn, tvb, offset, 1, ctx->hdr.netfn << 2, "NetFn: %s %s (0x%02x)", netfn_str, is_resp ? "Response" : "Request", ctx->hdr.netfn); proto_tree_add_item(tmp_tree, hf_ipmi_header_trg_lun, tvb, offset++, 1, ENC_LITTLE_ENDIAN); /* check if cks1 is specified */ if (!(ctx->flags & IPMI_D_NO_CKS)) { guint8 cks = tvb_get_guint8(tvb, offset); /* Header checksum */ if (ctx->cks1) { guint8 correct = cks - ctx->cks1; proto_tree_add_uint_format_value(cmd_tree, hf_ipmi_header_crc, tvb, offset++, 1, cks, "0x%02x (incorrect, expected 0x%02x)", cks, correct); } else { proto_tree_add_uint_format_value(cmd_tree, hf_ipmi_header_crc, tvb, offset++, 1, cks, "0x%02x (correct)", cks); } } /* check if request address is specified */ if (!(ctx->flags & IPMI_D_NO_RQ_SA)) { /* add request address field */ proto_tree_add_item(cmd_tree, hf_ipmi_header_src, tvb, offset++, 1, ENC_LITTLE_ENDIAN); } /* check if request sequence is specified */ if (!(ctx->flags & IPMI_D_NO_SEQ)) { /* Sequence number + source LUN */ tmp_tree = proto_tree_add_subtree_format(cmd_tree, tvb, offset, 1, ett_header_byte_4, NULL, "%s: 0x%02x, SeqNo: 0x%02x", (ctx->flags & IPMI_D_TMODE) ? "Bridged" : "Source LUN", ctx->hdr.rq_lun, ctx->hdr.rq_seq); if (ctx->flags & IPMI_D_TMODE) { proto_tree_add_item(tmp_tree, hf_ipmi_header_bridged, tvb, offset, 1, ENC_LITTLE_ENDIAN); } else { proto_tree_add_item(tmp_tree, hf_ipmi_header_src_lun, tvb, offset, 1, ENC_LITTLE_ENDIAN); } /* print seq no */ proto_tree_add_item(tmp_tree, hf_ipmi_header_sequence, tvb, offset++, 1, ENC_LITTLE_ENDIAN); } /* command code */ proto_tree_add_uint_format_value(cmd_tree, hf_ipmi_header_command, tvb, offset++, 1, ctx->hdr.cmd, "%s (0x%02x)", cmd->desc, ctx->hdr.cmd); if (is_resp) { /* completion code */ proto_tree_add_uint_format_value(cmd_tree, hf_ipmi_header_completion, tvb, offset++, 1, cc_val, "%s (0x%02x)", cc_str, cc_val); } if (siglen) { /* command prefix (if present) */ ti = proto_tree_add_item(cmd_tree, hf_ipmi_header_sig, tvb, offset, siglen, ENC_NA); proto_item_append_text(ti, " (%s)", netfn_str); } } if (tree || (cmd->flags & CMD_CALLRQ)) { /* calculate message data length */ guint data_len = tvb_captured_length(tvb) - ctx->hdr_len - siglen - (is_resp ? 1 : 0) - !(ctx->flags & IPMI_D_NO_CKS); /* create data subset */ tvbuff_t * data_tvb = tvb_new_subset_length(tvb, ctx->hdr_len + siglen + (is_resp ? 1 : 0), data_len); /* Select sub-handler */ ipmi_cmd_handler_t hnd = is_resp ? cmd->parse_resp : cmd->parse_req; if (hnd && tvb_captured_length(data_tvb)) { /* create data field */ tmp_tree = proto_tree_add_subtree(cmd_tree, data_tvb, 0, -1, ett_data, NULL, "Data"); /* save current command */ data->curr_hdr = &ctx->hdr; /* save current completion code */ data->curr_ccode = cc_val; /* call command parser */ hnd(data_tvb, pinfo, tmp_tree); } } /* check if cks2 is specified */ if (tree && !(ctx->flags & IPMI_D_NO_CKS)) { guint8 cks; /* get cks2 offset */ offset = tvb_captured_length(tvb) - 1; /* get cks2 */ cks = tvb_get_guint8(tvb, offset); /* Header checksum */ if (ctx->cks2) { guint8 correct = cks - ctx->cks2; proto_tree_add_uint_format_value(cmd_tree, hf_ipmi_data_crc, tvb, offset, 1, cks, "0x%02x (incorrect, expected 0x%02x)", cks, correct); } else { proto_tree_add_uint_format_value(cmd_tree, hf_ipmi_data_crc, tvb, offset, 1, cks, "0x%02x (correct)", cks); } } /* decrement next nest level */ data->next_level = data->curr_level; /* restore previous nest level */ data->curr_level = prev_level; return tvb_captured_length(tvb); }
void CursesAction::drawImpl() { if(isDisabled()) { wbkgd(hnd(), COLOR_PAIR(2)); wattrset(hnd(), 0); } else { bool menuOpen = _menu && _menu->isOpen(); bool standout = menuOpen || wattr().testFlag(Focused); if(_blink) standout = !standout; int attr = standout ? A_STANDOUT : A_NORMAL; if(_activateWait || menuOpen) attr |= A_BOLD; else if(isDisabled()) attr |= A_DIM; wbkgd(hnd(), COLOR_PAIR(1)); wattrset(hnd(), attr); } char space = isDisabled() || has_colors() ? ' ' : ACS_CKBOARD; wmove(hnd(), 0, 0); waddch(hnd(), space); foreach(char c, text().toLocal8Bit()) { if(c == '_') { if(!isDisabled()) wattron(hnd(), A_UNDERLINE); continue; } else if(c == ' ') c = space; waddch(hnd(), c); wattroff(hnd(), A_UNDERLINE); } waddch(hnd(), space); int left = width() - 2 - text().length(); while(left > 0) { waddch(hnd(), ' '); left--; } }
/*! Load the virtual hosts from a XML configuration file Returns non-null on errors. \param filename The XML file to open. */ int XmlVhostHandler::load (const char *filename) { XmlParser parser; xmlDocPtr doc; xmlNodePtr node; if (parser.open (filename)) { Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("Error opening %s"), filename); return -1; } doc = parser.getDoc (); node = doc->children->children; for (; node; node = node->next ) { xmlNodePtr lcur; Vhost *vh; if (xmlStrcmp (node->name, (const xmlChar *) "VHOST")) continue; lcur = node->children; vh = new Vhost (logManager); SslContext* sslContext = vh->getVhostSSLContext (); while (lcur) { XmlConf::build (lcur, vh->getHashedDataTrees (), vh->getHashedData ()); if (!xmlStrcmp (lcur->name, (const xmlChar *) "HOST")) { int useRegex = 0; for (xmlAttr *attrs = lcur->properties; attrs; attrs = attrs->next) { if (!xmlStrcmp (attrs->name, (const xmlChar *) "isRegex") && attrs->children && attrs->children->content && (!xmlStrcmp (attrs->children->content, (const xmlChar *) "YES"))) useRegex = 1; } vh->addHost ((const char *)lcur->children->content, useRegex); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "NAME")) { vh->setName ((char *) lcur->children->content); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "LOCATION")) { string loc; for (xmlAttr *attrs = lcur->properties; attrs; attrs = attrs->next) if (!xmlStrcmp (attrs->name, (const xmlChar *) "path")) loc = ((const char *) attrs->children->content); MimeRecord *record = XmlMimeHandler::readRecord (lcur); MimeRecord *prev = vh->addLocationMime (loc, record); if (prev) { Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("The location `%s' is registered multiple times"), loc.c_str ()); delete prev; } vh->getLocationsMime ()->put (loc, record); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "SSL_PRIVATEKEY")) { string pk ((char *) lcur->children->content); sslContext->setPrivateKeyFile (pk); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "SSL_CERTIFICATE")) { string certificate ((char *) lcur->children->content); sslContext->setCertificateFile (certificate); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "CONNECTIONS_PRIORITY")) { vh->setDefaultPriority (atoi ((const char *)lcur->children->content)); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "SSL_PASSWORD")) { string pw ((char *) lcur->children->content); sslContext->setPassword (pw); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "IP")) { int useRegex = 0; xmlAttr *attrs = lcur->properties; while (attrs) { if (!xmlStrcmp (attrs->name, (const xmlChar *) "isRegex") && !xmlStrcmp (attrs->children->content, (const xmlChar *) "YES")) useRegex = 1; attrs = attrs->next; } vh->addIP ((char *) lcur->children->content, useRegex); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "PORT")) { int val = atoi ((char *) lcur->children->content); if (val > (1 << 16) || val <= 0) Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("An invalid port was specified: %s"), lcur->children->content); vh->setPort ((u_short)val); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "PROTOCOL")) { char* lastChar = (char *) lcur->children->content; while (*lastChar != '\0') { *lastChar = tolower (*lastChar); lastChar++; } vh->setProtocolName ((char *) lcur->children->content); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "DOCROOT")) { char* lastChar = (char *) lcur->children->content; while (*(lastChar+1) != '\0') lastChar++; if (*lastChar == '\\' || *lastChar == '/') *lastChar = '\0'; vh->setDocumentRoot ((const char *)lcur->children->content); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "SYSROOT")) { char* lastChar = (char *) lcur->children->content; while (*(lastChar+1) != '\0') lastChar++; if (*lastChar == '\\' || *lastChar == '/') *lastChar = '\0'; vh->setSystemRoot ((const char *)lcur->children->content); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "CACHEROOT")) { char* lastChar = (char *) lcur->children->content; while (*(lastChar+1) != '\0') lastChar++; if (*lastChar == '\\' || *lastChar == '/') *lastChar = '\0'; vh->setCacheRoot ((const char *)lcur->children->content); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "ACCESSLOG")) { loadXMLlogData ("ACCESSLOG", vh, lcur); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "WARNINGLOG")) { loadXMLlogData ("WARNINGLOG", vh, lcur); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "MIME_FILE")) { string hnd ("xml"); for (xmlAttr *attrs = lcur->properties; attrs; attrs = attrs->next) { if (!xmlStrcmp (attrs->name, (const xmlChar *) "name") && attrs->children && attrs->children->content) hnd.assign((const char *) attrs->children->content); } const char *filename = (const char *) lcur->children->content; MimeManagerHandler *handler = Server::getInstance ()->getMimeManager ()->buildHandler (hnd); try { handler->load (filename); } catch (...) { delete handler; handler = NULL; Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("Error loading mime types file: %s"), filename); } vh->setMimeHandler (handler); } else if (!xmlStrcmp (lcur->name, (const xmlChar *) "THROTTLING_RATE")) { u_long rate = (u_long)atoi ((char *) lcur->children->content); vh->setThrottlingRate (rate); } lcur = lcur->next; }/* while (lcur) */ if (vh->openLogFiles ()) { Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("Error opening log files")); delete vh; vh = 0; continue; } if (vh->initializeSSL () < 0) { Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("Error initializing SSL for %s"), vh->getName ()); delete vh; vh = 0; continue; } if (addVHost (vh)) { Server::getInstance ()->log (MYSERVER_LOG_MSG_ERROR, _("Internal error")); delete vh; vh = 0; continue; } } parser.close (); changeLocationsOwner (); return 0; }