这篇教程C++ verbose函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中verbose函数的典型用法代码示例。如果您正苦于以下问题:C++ verbose函数的具体用法?C++ verbose怎么用?C++ verbose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了verbose函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: init/* * init() is called when the plugin is loaded, before any other functions * are called. Put global initialization here. */extern int init(void){ verbose("%s loaded", plugin_name); return SLURM_SUCCESS;}
开发者ID:cernops,项目名称:slurm,代码行数:9,
示例2: mainint main(int argc, char *argv[]){ log_options_t logopt = LOG_OPTS_STDERR_ONLY; job_desc_msg_t desc; resource_allocation_response_msg_t *alloc; time_t before, after; allocation_msg_thread_t *msg_thr; char **env = NULL, *cluster_name; int status = 0; int retries = 0; pid_t pid = getpid(); pid_t tpgid = 0; pid_t rc_pid = 0; int i, rc = 0; static char *msg = "Slurm job queue full, sleeping and retrying."; slurm_allocation_callbacks_t callbacks; slurm_conf_init(NULL); log_init(xbasename(argv[0]), logopt, 0, NULL); _set_exit_code(); if (spank_init_allocator() < 0) { error("Failed to initialize plugin stack"); exit(error_exit); } /* Be sure to call spank_fini when salloc exits */ if (atexit((void (*) (void)) spank_fini) < 0) error("Failed to register atexit handler for plugins: %m"); if (initialize_and_process_args(argc, argv) < 0) { error("salloc parameter parsing"); exit(error_exit); } /* reinit log with new verbosity (if changed by command line) */ if (opt.verbose || opt.quiet) { logopt.stderr_level += opt.verbose; logopt.stderr_level -= opt.quiet; logopt.prefix_level = 1; log_alter(logopt, 0, NULL); } if (spank_init_post_opt() < 0) { error("Plugin stack post-option processing failed"); exit(error_exit); } _set_spank_env(); _set_submit_dir_env(); if (opt.cwd && chdir(opt.cwd)) { error("chdir(%s): %m", opt.cwd); exit(error_exit); } if (opt.get_user_env_time >= 0) { bool no_env_cache = false; char *sched_params; char *user = uid_to_string(opt.uid); if (xstrcmp(user, "nobody") == 0) { error("Invalid user id %u: %m", (uint32_t)opt.uid); exit(error_exit); } sched_params = slurm_get_sched_params(); no_env_cache = (sched_params && strstr(sched_params, "no_env_cache")); xfree(sched_params); env = env_array_user_default(user, opt.get_user_env_time, opt.get_user_env_mode, no_env_cache); xfree(user); if (env == NULL) exit(error_exit); /* error already logged */ _set_rlimits(env); } /* * Job control for interactive salloc sessions: only if ... * * a) input is from a terminal (stdin has valid termios attributes), * b) controlling terminal exists (non-negative tpgid), * c) salloc is not run in allocation-only (--no-shell) mode, * NOTE: d and e below are configuration dependent * d) salloc runs in its own process group (true in interactive * shells that support job control), * e) salloc has been configured at compile-time to support background * execution and is not currently in the background process group. */ if (tcgetattr(STDIN_FILENO, &saved_tty_attributes) < 0) { /* * Test existence of controlling terminal (tpgid > 0) * after first making sure stdin is not redirected. */ } else if ((tpgid = tcgetpgrp(STDIN_FILENO)) < 0) {#ifdef HAVE_ALPS_CRAY//.........这里部分代码省略.........
开发者ID:adammoody,项目名称:slurm,代码行数:101,
示例3: do_authloop/* * read packets, try to authenticate the user and * return only if authentication is successful */static voiddo_authloop(Authctxt *authctxt){ int authenticated = 0; u_int bits; Key *client_host_key; BIGNUM *n; char *client_user, *password; char info[1024]; u_int dlen; u_int ulen; int prev, type = 0; struct passwd *pw = authctxt->pw; debug("Attempting authentication for %s%.100s.", authctxt->valid ? "" : "illegal user ", authctxt->user); /* If the user has no password, accept authentication immediately. */ if (options.password_authentication &&#ifdef KRB5 (!options.kerberos_authentication || options.kerberos_or_local_passwd) &&#endif PRIVSEP(auth_password(authctxt, ""))) { auth_log(authctxt, 1, "without authentication", ""); return; } /* Indicate that authentication is needed. */ packet_start(SSH_SMSG_FAILURE); packet_send(); packet_write_wait(); client_user = NULL; for (;;) { /* default to fail */ authenticated = 0; info[0] = '/0'; /* Get a packet from the client. */ prev = type; type = packet_read(); /* * If we started challenge-response authentication but the * next packet is not a response to our challenge, release * the resources allocated by get_challenge() (which would * normally have been released by verify_response() had we * received such a response) */ if (prev == SSH_CMSG_AUTH_TIS && type != SSH_CMSG_AUTH_TIS_RESPONSE) abandon_challenge_response(authctxt); /* Process the packet. */ switch (type) { case SSH_CMSG_AUTH_RHOSTS_RSA: if (!options.rhosts_rsa_authentication) { verbose("Rhosts with RSA authentication disabled."); break; } /* * Get client user name. Note that we just have to * trust the client; root on the client machine can * claim to be any user. */ client_user = packet_get_string(&ulen); /* Get the client host key. */ client_host_key = key_new(KEY_RSA1); bits = packet_get_int(); packet_get_bignum(client_host_key->rsa->e); packet_get_bignum(client_host_key->rsa->n); if (bits != BN_num_bits(client_host_key->rsa->n)) verbose("Warning: keysize mismatch for client_host_key: " "actual %d, announced %d", BN_num_bits(client_host_key->rsa->n), bits); packet_check_eom(); authenticated = auth_rhosts_rsa(pw, client_user, client_host_key); key_free(client_host_key); snprintf(info, sizeof info, " ruser %.100s", client_user); break; case SSH_CMSG_AUTH_RSA: if (!options.rsa_authentication) { verbose("RSA authentication disabled."); break; } /* RSA authentication requested. */ if ((n = BN_new()) == NULL) fatal("do_authloop: BN_new failed");//.........这里部分代码省略.........
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:101,
示例4: answer_from_cache/** answer query from the cache */static intanswer_from_cache(struct worker* worker, struct query_info* qinfo, struct reply_info* rep, uint16_t id, uint16_t flags, struct comm_reply* repinfo, struct edns_data* edns){ uint32_t timenow = *worker->env.now; uint16_t udpsize = edns->udp_size; int secure; int must_validate = !(flags&BIT_CD) && worker->env.need_to_validate; /* see if it is possible */ if(rep->ttl < timenow) { /* the rrsets may have been updated in the meantime. * we will refetch the message format from the * authoritative server */ return 0; } if(!rrset_array_lock(rep->ref, rep->rrset_count, timenow)) return 0; /* locked and ids and ttls are OK. */ /* check CNAME chain (if any) */ if(rep->an_numrrsets > 0 && (rep->rrsets[0]->rk.type == htons(LDNS_RR_TYPE_CNAME) || rep->rrsets[0]->rk.type == htons(LDNS_RR_TYPE_DNAME))) { if(!reply_check_cname_chain(rep)) { /* cname chain invalid, redo iterator steps */ verbose(VERB_ALGO, "Cache reply: cname chain broken"); bail_out: rrset_array_unlock_touch(worker->env.rrset_cache, worker->scratchpad, rep->ref, rep->rrset_count); regional_free_all(worker->scratchpad); return 0; } } /* check security status of the cached answer */ if( rep->security == sec_status_bogus && must_validate) { /* BAD cached */ edns->edns_version = EDNS_ADVERTISED_VERSION; edns->udp_size = EDNS_ADVERTISED_SIZE; edns->ext_rcode = 0; edns->bits &= EDNS_DO; error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL, qinfo, id, flags, edns); rrset_array_unlock_touch(worker->env.rrset_cache, worker->scratchpad, rep->ref, rep->rrset_count); regional_free_all(worker->scratchpad); if(worker->stats.extended) { worker->stats.ans_bogus ++; worker->stats.ans_rcode[LDNS_RCODE_SERVFAIL] ++; } return 1; } else if( rep->security == sec_status_unchecked && must_validate) { verbose(VERB_ALGO, "Cache reply: unchecked entry needs " "validation"); goto bail_out; /* need to validate cache entry first */ } else if(rep->security == sec_status_secure) { if(reply_all_rrsets_secure(rep)) secure = 1; else { if(must_validate) { verbose(VERB_ALGO, "Cache reply: secure entry" " changed status"); goto bail_out; /* rrset changed, re-verify */ } secure = 0; } } else secure = 0; edns->edns_version = EDNS_ADVERTISED_VERSION; edns->udp_size = EDNS_ADVERTISED_SIZE; edns->ext_rcode = 0; edns->bits &= EDNS_DO; if(!reply_info_answer_encode(qinfo, rep, id, flags, repinfo->c->buffer, timenow, 1, worker->scratchpad, udpsize, edns, (int)(edns->bits & EDNS_DO), secure)) { error_encode(repinfo->c->buffer, LDNS_RCODE_SERVFAIL, qinfo, id, flags, edns); } /* cannot send the reply right now, because blocking network syscall * is bad while holding locks. */ rrset_array_unlock_touch(worker->env.rrset_cache, worker->scratchpad, rep->ref, rep->rrset_count); regional_free_all(worker->scratchpad); if(worker->stats.extended) { if(secure) worker->stats.ans_secure++; server_stats_insrcode(&worker->stats, repinfo->c->buffer); } /* go and return this buffer to the client */ return 1;}
开发者ID:RS-liuyang,项目名称:rsdns,代码行数:91,
示例5: dnskey_verify_rrset_sigenum sec_status dnskey_verify_rrset_sig(struct regional* region, ldns_buffer* buf, struct val_env* ve, uint32_t now, struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* dnskey, size_t dnskey_idx, size_t sig_idx, struct rbtree_t** sortree, int* buf_canon, char** reason){ enum sec_status sec; uint8_t* sig; /* RRSIG rdata */ size_t siglen; size_t rrnum = rrset_get_count(rrset); uint8_t* signer; /* rrsig signer name */ size_t signer_len; unsigned char* sigblock; /* signature rdata field */ unsigned int sigblock_len; uint16_t ktag; /* DNSKEY key tag */ unsigned char* key; /* public key rdata field */ unsigned int keylen; rrset_get_rdata(rrset, rrnum + sig_idx, &sig, &siglen); /* min length of rdatalen, fixed rrsig, root signer, 1 byte sig */ if(siglen < 2+20) { verbose(VERB_QUERY, "verify: signature too short"); *reason = "signature too short"; return sec_status_bogus; } if(!(dnskey_get_flags(dnskey, dnskey_idx) & DNSKEY_BIT_ZSK)) { verbose(VERB_QUERY, "verify: dnskey without ZSK flag"); *reason = "dnskey without ZSK flag"; return sec_status_bogus; } if(dnskey_get_protocol(dnskey, dnskey_idx) != LDNS_DNSSEC_KEYPROTO) { /* RFC 4034 says DNSKEY PROTOCOL MUST be 3 */ verbose(VERB_QUERY, "verify: dnskey has wrong key protocol"); *reason = "dnskey has wrong protocolnumber"; return sec_status_bogus; } /* verify as many fields in rrsig as possible */ signer = sig+2+18; signer_len = dname_valid(signer, siglen-2-18); if(!signer_len) { verbose(VERB_QUERY, "verify: malformed signer name"); *reason = "signer name malformed"; return sec_status_bogus; /* signer name invalid */ } if(!dname_subdomain_c(rrset->rk.dname, signer)) { verbose(VERB_QUERY, "verify: signer name is off-tree"); *reason = "signer name off-tree"; return sec_status_bogus; /* signer name offtree */ } sigblock = (unsigned char*)signer+signer_len; if(siglen < 2+18+signer_len+1) { verbose(VERB_QUERY, "verify: too short, no signature data"); *reason = "signature too short, no signature data"; return sec_status_bogus; /* sig rdf is < 1 byte */ } sigblock_len = (unsigned int)(siglen - 2 - 18 - signer_len); /* verify key dname == sig signer name */ if(query_dname_compare(signer, dnskey->rk.dname) != 0) { verbose(VERB_QUERY, "verify: wrong key for rrsig"); log_nametypeclass(VERB_QUERY, "RRSIG signername is", signer, 0, 0); log_nametypeclass(VERB_QUERY, "the key name is", dnskey->rk.dname, 0, 0); *reason = "signer name mismatches key name"; return sec_status_bogus; } /* verify covered type */ /* memcmp works because type is in network format for rrset */ if(memcmp(sig+2, &rrset->rk.type, 2) != 0) { verbose(VERB_QUERY, "verify: wrong type covered"); *reason = "signature covers wrong type"; return sec_status_bogus; } /* verify keytag and sig algo (possibly again) */ if((int)sig[2+2] != dnskey_get_algo(dnskey, dnskey_idx)) { verbose(VERB_QUERY, "verify: wrong algorithm"); *reason = "signature has wrong algorithm"; return sec_status_bogus; } ktag = htons(dnskey_calc_keytag(dnskey, dnskey_idx)); if(memcmp(sig+2+16, &ktag, 2) != 0) { verbose(VERB_QUERY, "verify: wrong keytag"); *reason = "signature has wrong keytag"; return sec_status_bogus; } /* verify labels is in a valid range */ if((int)sig[2+3] > dname_signame_label_count(rrset->rk.dname)) { verbose(VERB_QUERY, "verify: labelcount out of range"); *reason = "signature labelcount out of range"; return sec_status_bogus; } /* original ttl, always ok *///.........这里部分代码省略.........
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:101,
示例6: messagevoid ConcurrentMergeScheduler::message(const String& message) { if (verbose() && !_writer.expired()) { IndexWriterPtr(_writer)->message(L"CMS: " + message); }}
开发者ID:304471720,项目名称:LucenePlusPlus,代码行数:5,
示例7: handle_query/* * Parses data buffer to a query, finds the correct answer * and calls the given function for every packet to send. */voidhandle_query(uint8_t* inbuf, ssize_t inlen, struct entry* entries, int* count, enum transport_type transport, void (*sendfunc)(uint8_t*, size_t, void*), void* userdata, FILE* verbose_out){ ldns_status status; ldns_pkt *query_pkt = NULL; ldns_pkt *answer_pkt = NULL; struct reply_packet *p; ldns_rr *query_rr = NULL; uint8_t *outbuf = NULL; size_t answer_size = 0; struct entry* entry = NULL; ldns_rdf *stop_command = ldns_dname_new_frm_str("server.stop."); status = ldns_wire2pkt(&query_pkt, inbuf, (size_t)inlen); if (status != LDNS_STATUS_OK) { verbose(1, "Got bad packet: %s/n", ldns_get_errorstr_by_id(status)); ldns_rdf_free(stop_command); return; } query_rr = ldns_rr_list_rr(ldns_pkt_question(query_pkt), 0); verbose(1, "query %d: id %d: %s %d bytes: ", ++(*count), (int)ldns_pkt_id(query_pkt), (transport==transport_tcp)?"TCP":"UDP", (int)inlen); if(verbose_out) ldns_rr_print(verbose_out, query_rr); if(verbose_out) ldns_pkt_print(verbose_out, query_pkt); if (ldns_rr_get_type(query_rr) == LDNS_RR_TYPE_TXT && ldns_rr_get_class(query_rr) == LDNS_RR_CLASS_CH && ldns_dname_compare(ldns_rr_owner(query_rr), stop_command) == 0) { exit(0); } /* fill up answer packet */ entry = find_match(entries, query_pkt, transport); if(!entry || !entry->reply_list) { verbose(1, "no answer packet for this query, no reply./n"); ldns_pkt_free(query_pkt); ldns_rdf_free(stop_command); return; } for(p = entry->reply_list; p; p = p->next) { verbose(3, "Answer pkt:/n"); if (p->reply_from_hex) { /* try to parse the hex packet, if it can be * parsed, we can use adjust rules. if not, * send packet literally */ status = ldns_buffer2pkt_wire(&answer_pkt, p->reply_from_hex); if (status == LDNS_STATUS_OK) { adjust_packet(entry, answer_pkt, query_pkt); if(verbose_out) ldns_pkt_print(verbose_out, answer_pkt); status = ldns_pkt2wire(&outbuf, answer_pkt, &answer_size); verbose(2, "Answer packet size: %u bytes./n", (unsigned int)answer_size); if (status != LDNS_STATUS_OK) { verbose(1, "Error creating answer: %s/n", ldns_get_errorstr_by_id(status)); ldns_pkt_free(query_pkt); ldns_rdf_free(stop_command); return; } ldns_pkt_free(answer_pkt); answer_pkt = NULL; } else { verbose(3, "Could not parse hex data (%s), sending hex data directly./n", ldns_get_errorstr_by_id(status)); /* still try to adjust ID */ answer_size = ldns_buffer_capacity(p->reply_from_hex); outbuf = LDNS_XMALLOC(uint8_t, answer_size); memcpy(outbuf, ldns_buffer_begin(p->reply_from_hex), answer_size); if(entry->copy_id) { ldns_write_uint16(outbuf, ldns_pkt_id(query_pkt)); } } } else { answer_pkt = ldns_pkt_clone(p->reply); adjust_packet(entry, answer_pkt, query_pkt); if(verbose_out) ldns_pkt_print(verbose_out, answer_pkt); status = ldns_pkt2wire(&outbuf, answer_pkt, &answer_size); verbose(1, "Answer packet size: %u bytes./n", (unsigned int)answer_size); if (status != LDNS_STATUS_OK) { verbose(1, "Error creating answer: %s/n", ldns_get_errorstr_by_id(status)); ldns_pkt_free(query_pkt); ldns_rdf_free(stop_command); return; } ldns_pkt_free(answer_pkt); answer_pkt = NULL; } if(p->packet_sleep) { verbose(3, "sleeping for next packet %d secs/n", p->packet_sleep);#ifdef HAVE_SLEEP sleep(p->packet_sleep);#else Sleep(p->packet_sleep * 1000);//.........这里部分代码省略.........
开发者ID:benlaurie,项目名称:ldns,代码行数:101,
示例8: main//.........这里部分代码省略......... if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) return sys_errmsg("%s: unable to get NAND oobinfo", mtd_device); /* Check for autoplacement */ if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) { /* Get the position of the free bytes */ if (!oobinfo.oobfree[0][1]) return errmsg(" Eeep. Autoplacement selected and no empty space in oob"); clmpos = oobinfo.oobfree[0][0]; clmlen = oobinfo.oobfree[0][1]; if (clmlen > 8) clmlen = 8; } else { /* Legacy mode */ switch (mtd.oob_size) { case 8: clmpos = 6; clmlen = 2; break; case 16: clmpos = 8; clmlen = 8; break; case 64: clmpos = 16; clmlen = 8; break; } } cleanmarker.totlen = cpu_to_je32(8); } cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(cleanmarker) - 4)); } /* * Now do the actual erasing of the MTD device */ if (eb_cnt == 0) eb_cnt = (mtd.size / mtd.eb_size) - eb_start; for (eb = eb_start; eb < eb_start + eb_cnt; eb++) { offset = (off_t)eb * mtd.eb_size; if (!noskipbad) { int ret = mtd_is_bad(&mtd, fd, eb); if (ret > 0) { verbose(!quiet, "Skipping bad block at %08"PRIxoff_t, offset); continue; } else if (ret < 0) { if (errno == EOPNOTSUPP) { noskipbad = 1; if (isNAND) return errmsg("%s: Bad block check not available", mtd_device); } else return sys_errmsg("%s: MTD get bad block failed", mtd_device); } } show_progress(&mtd, offset, eb, eb_start, eb_cnt); if (unlock) { if (mtd_unlock(&mtd, fd, eb) != 0) { sys_errmsg("%s: MTD unlock failure", mtd_device); continue; } } if (mtd_erase(mtd_desc, &mtd, fd, eb) != 0) { sys_errmsg("%s: MTD Erase failure", mtd_device); continue; } /* format for JFFS2 ? */ if (!jffs2) continue; /* write cleanmarker */ if (isNAND) { if (mtd_write_oob(mtd_desc, &mtd, fd, (uint64_t)offset + clmpos, clmlen, &cleanmarker) != 0) { sys_errmsg("%s: MTD writeoob failure", mtd_device); continue; } } else { if (lseek(fd, offset, SEEK_SET) < 0) { sys_errmsg("%s: MTD lseek failure", mtd_device); continue; } if (write(fd, &cleanmarker, sizeof(cleanmarker)) != sizeof(cleanmarker)) { sys_errmsg("%s: MTD write failure", mtd_device); continue; } } verbose(!quiet, " Cleanmarker written at %"PRIxoff_t, offset); } show_progress(&mtd, offset, eb, eb_start, eb_cnt); bareverbose(!quiet, "/n"); return 0;}
开发者ID:MartinBielik,项目名称:mtd-utils,代码行数:101,
示例9: match_all/** match all of the packet */static intmatch_all(ldns_pkt* q, ldns_pkt* p, bool mttl){ if(ldns_pkt_get_opcode(q) != ldns_pkt_get_opcode(p)) { verbose(3, "allmatch: opcode different"); return 0;} if(ldns_pkt_get_rcode(q) != ldns_pkt_get_rcode(p)) { verbose(3, "allmatch: rcode different"); return 0;} if(ldns_pkt_id(q) != ldns_pkt_id(p)) { verbose(3, "allmatch: id different"); return 0;} if(cmp_bool(ldns_pkt_qr(q), ldns_pkt_qr(p)) != 0) { verbose(3, "allmatch: qr different"); return 0;} if(cmp_bool(ldns_pkt_aa(q), ldns_pkt_aa(p)) != 0) { verbose(3, "allmatch: aa different"); return 0;} if(cmp_bool(ldns_pkt_tc(q), ldns_pkt_tc(p)) != 0) { verbose(3, "allmatch: tc different"); return 0;} if(cmp_bool(ldns_pkt_rd(q), ldns_pkt_rd(p)) != 0) { verbose(3, "allmatch: rd different"); return 0;} if(cmp_bool(ldns_pkt_cd(q), ldns_pkt_cd(p)) != 0) { verbose(3, "allmatch: cd different"); return 0;} if(cmp_bool(ldns_pkt_ra(q), ldns_pkt_ra(p)) != 0) { verbose(3, "allmatch: ra different"); return 0;} if(cmp_bool(ldns_pkt_ad(q), ldns_pkt_ad(p)) != 0) { verbose(3, "allmatch: ad different"); return 0;} if(ldns_pkt_qdcount(q) != ldns_pkt_qdcount(p)) { verbose(3, "allmatch: qdcount different"); return 0;} if(ldns_pkt_ancount(q) != ldns_pkt_ancount(p)) { verbose(3, "allmatch: ancount different"); return 0;} if(ldns_pkt_nscount(q) != ldns_pkt_nscount(p)) { verbose(3, "allmatch: nscount different"); return 0;} if(ldns_pkt_arcount(q) != ldns_pkt_arcount(p)) { verbose(3, "allmatch: arcount different"); return 0;} if(!match_list(ldns_pkt_question(q), ldns_pkt_question(p), 0)) { verbose(3, "allmatch: qd section different"); return 0;} if(!match_list(ldns_pkt_answer(q), ldns_pkt_answer(p), mttl)) { verbose(3, "allmatch: an section different"); return 0;} if(!match_list(ldns_pkt_authority(q), ldns_pkt_authority(p), mttl)) { verbose(3, "allmatch: ar section different"); return 0;} if(!match_list(ldns_pkt_additional(q), ldns_pkt_additional(p), mttl)) { verbose(3, "allmatch: ns section different"); return 0;} return 1;}
开发者ID:benlaurie,项目名称:ldns,代码行数:42,
示例10: find_match/* finds entry in list, or returns NULL */struct entry* find_match(struct entry* entries, ldns_pkt* query_pkt, enum transport_type transport){ struct entry* p = entries; ldns_pkt* reply = NULL; for(p=entries; p; p=p->next) { verbose(3, "comparepkt: "); reply = p->reply_list->reply; if(p->match_opcode && ldns_pkt_get_opcode(query_pkt) != ldns_pkt_get_opcode(reply)) { verbose(3, "bad opcode/n"); continue; } if(p->match_qtype && get_qtype(query_pkt) != get_qtype(reply)) { verbose(3, "bad qtype/n"); continue; } if(p->match_qname) { if(!get_owner(query_pkt) || !get_owner(reply) || ldns_dname_compare( get_owner(query_pkt), get_owner(reply)) != 0) { verbose(3, "bad qname/n"); continue; } } if(p->match_subdomain) { if(!get_owner(query_pkt) || !get_owner(reply) || (ldns_dname_compare(get_owner(query_pkt), get_owner(reply)) != 0 && !ldns_dname_is_subdomain( get_owner(query_pkt), get_owner(reply)))) { verbose(3, "bad subdomain/n"); continue; } } if(p->match_serial && get_serial(query_pkt) != p->ixfr_soa_serial) { verbose(3, "bad serial/n"); continue; } if(p->match_do && !ldns_pkt_edns_do(query_pkt)) { verbose(3, "no DO bit set/n"); continue; } if(p->match_noedns && ldns_pkt_edns(query_pkt)) { verbose(3, "bad; EDNS OPT present/n"); continue; } if(p->match_ednsdata_raw && !match_ednsdata(query_pkt, p->reply_list)) { verbose(3, "bad EDNS data match./n"); continue; } if(p->match_transport != transport_any && p->match_transport != transport) { verbose(3, "bad transport/n"); continue; } if(p->match_all && !match_all(query_pkt, reply, p->match_ttl)) { verbose(3, "bad allmatch/n"); continue; } verbose(3, "match!/n"); return p; } return NULL;}
开发者ID:benlaurie,项目名称:ldns,代码行数:68,
示例11: ports_create_if/** * Helper for ports_open. Creates one interface (or NULL for default). * @param ifname: The interface ip address. * @param do_auto: use automatic interface detection. * If enabled, then ifname must be the wildcard name. * @param do_udp: if udp should be used. * @param do_tcp: if udp should be used. * @param hints: for getaddrinfo. family and flags have to be set by caller. * @param port: Port number to use (as string). * @param list: list of open ports, appended to, changed to point to list head. * @param rcv: receive buffer size for UDP * @param snd: send buffer size for UDP * @param ssl_port: ssl service port number * @param reuseport: try to set SO_REUSEPORT if nonNULL and true. * set to false on exit if reuseport failed due to no kernel support. * @return: returns false on error. */static intports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp, struct addrinfo *hints, const char* port, struct listen_port** list, size_t rcv, size_t snd, int ssl_port, int* reuseport){ int s, noip6=0; if(!do_udp && !do_tcp) return 0; if(do_auto) { if((s = make_sock_port(SOCK_DGRAM, ifname, port, hints, 1, &noip6, rcv, snd, reuseport)) == -1) { if(noip6) { log_warn("IPv6 protocol not available"); return 1; } return 0; } /* getting source addr packet info is highly non-portable */ if(!set_recvpktinfo(s, hints->ai_family)) {#ifndef USE_WINSOCK close(s);#else closesocket(s);#endif return 0; } if(!port_insert(list, s, listen_type_udpancil)) {#ifndef USE_WINSOCK close(s);#else closesocket(s);#endif return 0; } } else if(do_udp) { /* regular udp socket */ if((s = make_sock_port(SOCK_DGRAM, ifname, port, hints, 1, &noip6, rcv, snd, reuseport)) == -1) { if(noip6) { log_warn("IPv6 protocol not available"); return 1; } return 0; } if(!port_insert(list, s, listen_type_udp)) {#ifndef USE_WINSOCK close(s);#else closesocket(s);#endif return 0; } } if(do_tcp) { int is_ssl = ((strchr(ifname, '@') && atoi(strchr(ifname, '@')+1) == ssl_port) || (!strchr(ifname, '@') && atoi(port) == ssl_port)); if((s = make_sock_port(SOCK_STREAM, ifname, port, hints, 1, &noip6, 0, 0, reuseport)) == -1) { if(noip6) { /*log_warn("IPv6 protocol not available");*/ return 1; } return 0; } if(is_ssl) verbose(VERB_ALGO, "setup TCP for SSL service"); if(!port_insert(list, s, is_ssl?listen_type_ssl: listen_type_tcp)) {#ifndef USE_WINSOCK close(s);#else closesocket(s);#endif return 0; } } return 1;}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:96,
示例12: timer// ===========================================================================// IIncidentListener interfaces overrides: incident handling// ===========================================================================void DataOnDemandSvc::handle ( const Incident& incident ){ Gaudi::Utils::LockedChrono timer ( m_timer_all , m_locked_all ) ; ++m_stat ; // proper incident type? if ( incident.type() != m_trapType ) { return ; } // RETURN const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident); if ( 0 == inc ) { return ; } // RETURN // update if needed! if ( m_updateRequired ) { update() ; } if ( MSG::VERBOSE >= outputLevel() ) { verbose() << "Incident: [" << incident.type () << "] " << " = " << incident.source () << " Location:" << inc->tag() << endmsg; } // ========================================================================== // const std::string& tag = inc->tag(); Gaudi::StringKey tag ( inc->tag() ) ; // ========================================================================== NodeMap::iterator icl = m_nodes.find ( tag ) ; if ( icl != m_nodes.end() ) { StatusCode sc = execHandler ( tag , icl->second ) ; if ( sc.isSuccess() ) { ++m_statNode ; } return ; // RETURN } // ========================================================================== AlgMap::iterator ialg = m_algs.find ( tag ) ; if ( ialg != m_algs.end() ) { StatusCode sc = execHandler ( tag , ialg->second ) ; if ( sc.isSuccess() ) { ++m_statAlg ; } return ; // RETURN } // ========================================================================== // Fall back on the tools if (m_toolSvc) { if (MSG::VERBOSE >= outputLevel()) verbose() << "Try to find mapping with mapping tools" << endmsg; Finder finder(no_prefix(inc->tag(), m_prefix), m_nodeMappers, m_algMappers); // - try the node mappers std::string node = finder.node(); if (isGood(node)) { // if one is found update the internal node mapping and try again. if (MSG::VERBOSE >= outputLevel()) verbose() << "Found Node handler: " << node << endmsg; i_setNodeHandler(inc->tag(), node); handle(incident); --m_stat; // avoid double counting because of recursion return; } // - try alg mappings Gaudi::Utils::TypeNameString alg = finder.alg(); if (isGood(alg)) { // we got an algorithm, update alg map and try to handle again if (MSG::VERBOSE >= outputLevel()) verbose() << "Found Algorithm handler: " << alg << endmsg; i_setAlgHandler(inc->tag(), alg).ignore(); handle(incident); --m_stat; // avoid double counting because of recursion return; } }}
开发者ID:atlas-org,项目名称:gaudi,代码行数:72,
示例13: errorvoid L2OrthoHP::adapt(double thr, int strat, bool h_only, bool iso_only, double conv_exp, int max_order){ if (!have_errors) error("Element errors have to be calculated first, see calc_error()."); int i, j; Mesh* mesh[10]; for (j = 0; j < num; j++) { mesh[j] = spaces[j]->get_mesh(); rsln[j]->set_quad_2d(&g_quad_2d_std); rsln[j]->enable_transform(false); } double err0 = 1000.0; double processed_error = 0.0; for (i = 0; i < nact; i++) { int comp = esort[i][1]; int id = esort[i][0]; double err = errors[comp][id]; // first refinement strategy: // refine elements until prescribed amount of error is processed // if more elements have similar error refine all to keep the mesh symmetric if ((strat == 0) && (processed_error > sqrt(thr) * total_err) && fabs((err - err0)/err0) > 1e-3) break; // second refinement strategy: // refine all elements whose error is bigger than some portion of maximal error if ((strat == 1) && (err < thr * errors[esort[0][1]][esort[0][0]])) break; Element* e; e = mesh[comp]->get_element(id); int split = 0; int p[4]; int current = spaces[comp]->get_element_order(id); //verbose("Refining element #%d, Component #%d, Error %g%%", e_id, comp, errors[comp][e_id]); if (h_only && iso_only) p[0] = p[1] = p[2] = p[3] = current; else get_optimal_refinement(e, current, rsln[comp], split, p, h_only, iso_only, conv_exp, max_order); //apply found division if (split < 0) { spaces[comp]->set_element_order(id, p[0]); } else if (split == 0) { mesh[comp]->refine_element(id); for (j = 0; j < 4; j++) spaces[comp]->set_element_order(e->sons[j]->id, p[j]); } else { mesh[comp]->refine_element(id, split); for (j = 0; j < 2; j++) spaces[comp]->set_element_order(e->sons[ (split == 1) ? j : j+2 ]->id, p[j]); } err0 = err; processed_error += err; } for (j = 0; j < num; j++) rsln[j]->enable_transform(true); verbose("Refined %d elements.", i); have_errors = false;}
开发者ID:davidquantum,项目名称:hermes2dold,代码行数:71,
示例14: genePredAddExonFramesstatic struct exonInfo *buildGIList(char *database, struct genePred *pred, char *mafTable, unsigned options){struct exonInfo *giList = NULL;unsigned *exonStart = pred->exonStarts;unsigned *lastStart = &exonStart[pred->exonCount];unsigned *exonEnd = pred->exonEnds;int *frames = pred->exonFrames;boolean includeUtr = options & MAFGENE_INCLUDEUTR;if (frames == NULL) { genePredAddExonFrames(pred); frames = pred->exonFrames; }assert(frames != NULL);int start = 0;/* first skip 5' UTR if the includeUtr option is not set */if (!includeUtr) { for(; exonStart < lastStart; exonStart++, exonEnd++, frames++) { int size = *exonEnd - *exonStart; if (*exonStart + size > pred->cdsStart) break; } }for(; exonStart < lastStart; exonStart++, exonEnd++, frames++) { struct exonInfo *gi; int thisStart = *exonStart; int thisEnd = *exonEnd; if (!includeUtr) { if (thisStart > pred->cdsEnd) break; if (thisStart < pred->cdsStart) thisStart = pred->cdsStart; if (thisEnd > pred->cdsEnd) thisEnd = pred->cdsEnd; } int thisSize = thisEnd - thisStart; if (!includeUtr) verbose(3, "in %d %d cds %d %d/n",*exonStart,*exonEnd, thisStart, thisEnd); AllocVar(gi); gi->frame = *frames; gi->name = pred->name; gi->ali = getAliForRange(database, mafTable, pred->chrom, thisStart, thisEnd); gi->chromStart = thisStart; gi->chromEnd = thisEnd; gi->exonStart = start; gi->exonSize = thisSize; verbose(3, "exon size %d/n", thisSize); gi->strand = pred->strand[0]; start += gi->exonSize; slAddHead(&giList, gi); if (!includeUtr) { if (thisEnd == pred->cdsEnd) break; } }slReverse(&giList);return giList;}
开发者ID:maximilianh,项目名称:kent,代码行数:80,
示例15: mainintmain (int argc, char** argv){ gint total = 0; gint passed = 0; gint failed = 0; gint i; for (i = 1; i < argc; i++) if (strcmp ("--noisy", argv[i]) == 0) noisy = TRUE; TEST_COMPILATION("*A?B*", G_MATCH_ALL, "*A?B*", 3); TEST_COMPILATION("ABC*DEFGH", G_MATCH_ALL_TAIL, "HGFED*CBA", 8); TEST_COMPILATION("ABCDEF*GH", G_MATCH_ALL, "ABCDEF*GH", 8); TEST_COMPILATION("ABC**?***??**DEF*GH", G_MATCH_ALL, "ABC*???DEF*GH", 11); TEST_COMPILATION("*A?AA", G_MATCH_ALL_TAIL, "AA?A*", 4); TEST_COMPILATION("ABCD*", G_MATCH_HEAD, "ABCD", 4); TEST_COMPILATION("*ABCD", G_MATCH_TAIL, "ABCD", 4); TEST_COMPILATION("ABCDE", G_MATCH_EXACT, "ABCDE", 5); TEST_COMPILATION("A?C?E", G_MATCH_ALL, "A?C?E", 5); TEST_COMPILATION("*?x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("?*x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("*?*x", G_MATCH_ALL_TAIL, "x?*", 2); TEST_COMPILATION("x*??", G_MATCH_ALL_TAIL, "??*x", 3); TEST_EQUAL("*A?B*", "*A?B*", TRUE); TEST_EQUAL("A*BCD", "A*BCD", TRUE); TEST_EQUAL("ABCD*", "ABCD****", TRUE); TEST_EQUAL("A1*", "A1*", TRUE); TEST_EQUAL("*YZ", "*YZ", TRUE); TEST_EQUAL("A1x", "A1x", TRUE); TEST_EQUAL("AB*CD", "AB**CD", TRUE); TEST_EQUAL("AB*?*CD", "AB*?CD", TRUE); TEST_EQUAL("AB*?CD", "AB?*CD", TRUE); TEST_EQUAL("AB*CD", "AB*?*CD", FALSE); TEST_EQUAL("ABC*", "ABC?", FALSE); TEST_MATCH("*x", "x", TRUE); TEST_MATCH("*x", "xx", TRUE); TEST_MATCH("*x", "yyyx", TRUE); TEST_MATCH("*x", "yyxy", FALSE); TEST_MATCH("?x", "x", FALSE); TEST_MATCH("?x", "xx", TRUE); TEST_MATCH("?x", "yyyx", FALSE); TEST_MATCH("?x", "yyxy", FALSE); TEST_MATCH("*?x", "xx", TRUE); TEST_MATCH("?*x", "xx", TRUE); TEST_MATCH("*?x", "x", FALSE); TEST_MATCH("?*x", "x", FALSE); TEST_MATCH("*?*x", "yx", TRUE); TEST_MATCH("*?*x", "xxxx", TRUE); TEST_MATCH("x*??", "xyzw", TRUE); TEST_MATCH("*x", "/xc3/x84x", TRUE); TEST_MATCH("?x", "/xc3/x84x", TRUE); TEST_MATCH("??x", "/xc3/x84x", FALSE); TEST_MATCH("ab/xc3/xa4/xc3/xb6", "ab/xc3/xa4/xc3/xb6", TRUE); TEST_MATCH("ab/xc3/xa4/xc3/xb6", "abao", FALSE); TEST_MATCH("ab?/xc3/xb6", "ab/xc3/xa4/xc3/xb6", TRUE); TEST_MATCH("ab?/xc3/xb6", "abao", FALSE); TEST_MATCH("ab/xc3/xa4?", "ab/xc3/xa4/xc3/xb6", TRUE); TEST_MATCH("ab/xc3/xa4?", "abao", FALSE); TEST_MATCH("ab??", "ab/xc3/xa4/xc3/xb6", TRUE); TEST_MATCH("ab*", "ab/xc3/xa4/xc3/xb6", TRUE); TEST_MATCH("ab*/xc3/xb6", "ab/xc3/xa4/xc3/xb6", TRUE); TEST_MATCH("ab*/xc3/xb6", "aba/xc3/xb6x/xc3/xb6", TRUE); TEST_MATCH("", "abc", FALSE); TEST_MATCH("", "", TRUE); TEST_MATCH("abc", "abc", TRUE); TEST_MATCH("*fo1*bar", "yyyfoxfo1bar", TRUE); TEST_MATCH("12*fo1g*bar", "12yyyfoxfo1gbar", TRUE); TEST_MATCH("__________:*fo1g*bar", "__________:yyyfoxfo1gbar", TRUE); TEST_MATCH("*abc*cde", "abcde", FALSE); TEST_MATCH("*abc*cde", "abccde", TRUE); TEST_MATCH("*abc*cde", "abcxcde", TRUE); TEST_MATCH("*abc*?cde", "abccde", FALSE); TEST_MATCH("*abc*?cde", "abcxcde", TRUE); TEST_MATCH("*abc*def", "abababcdededef", TRUE); TEST_MATCH("*abc*def", "abcbcbcdededef", TRUE); TEST_MATCH("*acbc*def", "acbcbcbcdededef", TRUE); TEST_MATCH("*a?bc*def", "acbcbcbcdededef", TRUE); TEST_MATCH("*abc*def", "bcbcbcdefdef", FALSE); TEST_MATCH("*abc*def*ghi", "abcbcbcbcbcbcdefefdefdefghi", TRUE); TEST_MATCH("*abc*def*ghi", "bcbcbcbcbcbcdefdefdefdefghi", FALSE); TEST_MATCH("_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_*abc*def*ghi", "_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_abcbcbcbcbcbcdefefdefdefghi", TRUE); TEST_MATCH("fooooooo*a*bc", "fooooooo_a_bd_a_bc", TRUE); verbose ("/n%u tests passed, %u failed/n", passed, failed); return failed;}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:92,
示例16: anchor_read_bind_file_wild/** * Read a BIND9 like files with trust anchors in named.conf format. * Performs wildcard processing of name. * @param anchors: anchor storage. * @param buffer: parsing buffer. * @param pat: pattern string. (can be wildcarded) * @return false on error. */static intanchor_read_bind_file_wild(struct val_anchors* anchors, sldns_buffer* buffer, const char* pat){#ifdef HAVE_GLOB glob_t g; size_t i; int r, flags; if(!strchr(pat, '*') && !strchr(pat, '?') && !strchr(pat, '[') && !strchr(pat, '{') && !strchr(pat, '~')) { return anchor_read_bind_file(anchors, buffer, pat); } verbose(VERB_QUERY, "wildcard found, processing %s", pat); flags = 0 #ifdef GLOB_ERR | GLOB_ERR#endif#ifdef GLOB_NOSORT | GLOB_NOSORT#endif#ifdef GLOB_BRACE | GLOB_BRACE#endif#ifdef GLOB_TILDE | GLOB_TILDE#endif ; memset(&g, 0, sizeof(g)); r = glob(pat, flags, NULL, &g); if(r) { /* some error */ if(r == GLOB_NOMATCH) { verbose(VERB_QUERY, "trusted-keys-file: " "no matches for %s", pat); return 1; } else if(r == GLOB_NOSPACE) { log_err("wildcard trusted-keys-file %s: " "pattern out of memory", pat); } else if(r == GLOB_ABORTED) { log_err("wildcard trusted-keys-file %s: expansion " "aborted (%s)", pat, strerror(errno)); } else { log_err("wildcard trusted-keys-file %s: expansion " "failed (%s)", pat, strerror(errno)); } /* ignore globs that yield no files */ return 1; } /* process files found, if any */ for(i=0; i<(size_t)g.gl_pathc; i++) { if(!anchor_read_bind_file(anchors, buffer, g.gl_pathv[i])) { log_err("error reading wildcard " "trusted-keys-file: %s", g.gl_pathv[i]); globfree(&g); return 0; } } globfree(&g); return 1;#else /* not HAVE_GLOB */ return anchor_read_bind_file(anchors, buffer, pat);#endif /* HAVE_GLOB */}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:71,
示例17: load_hostkeysvoidload_hostkeys(struct hostkeys *hostkeys, const char *host, const char *path){ FILE *f; char line[8192]; u_long linenum = 0, num_loaded = 0; char *cp, *cp2, *hashed_host; HostkeyMarker marker; Key *key; int kbits; if ((f = fopen(path, "r")) == NULL) return; debug3("%s: loading entries for host /"%.100s/" from file /"%s/"", __func__, host, path); while (read_keyfile_line(f, path, line, sizeof(line), &linenum) == 0) { cp = line; /* Skip any leading whitespace, comments and empty lines. */ for (; *cp == ' ' || *cp == '/t'; cp++) ; if (!*cp || *cp == '#' || *cp == '/n') continue; if ((marker = check_markers(&cp)) == MRK_ERROR) { verbose("%s: invalid marker at %s:%lu", __func__, path, linenum); continue; } /* Find the end of the host name portion. */ for (cp2 = cp; *cp2 && *cp2 != ' ' && *cp2 != '/t'; cp2++) ; /* Check if the host name matches. */ if (match_hostname(host, cp, (u_int) (cp2 - cp)) != 1) { if (*cp != HASH_DELIM) continue; hashed_host = host_hash(host, cp, (u_int) (cp2 - cp)); if (hashed_host == NULL) { debug("Invalid hashed host line %lu of %s", linenum, path); continue; } if (strncmp(hashed_host, cp, (u_int) (cp2 - cp)) != 0) continue; } /* Got a match. Skip host name. */ cp = cp2; /* * Extract the key from the line. This will skip any leading * whitespace. Ignore badly formatted lines. */ key = key_new(KEY_UNSPEC); if (!hostfile_read_key(&cp, &kbits, key)) { key_free(key); key = key_new(KEY_RSA1); if (!hostfile_read_key(&cp, &kbits, key)) { key_free(key); continue; } } if (!hostfile_check_key(kbits, key, host, path, linenum)) continue; debug3("%s: found %skey type %s in file %s:%lu", __func__, marker == MRK_NONE ? "" : (marker == MRK_CA ? "ca " : "revoked "), key_type(key), path, linenum); hostkeys->entries = xrealloc(hostkeys->entries, hostkeys->num_entries + 1, sizeof(*hostkeys->entries)); hostkeys->entries[hostkeys->num_entries].host = xstrdup(host); hostkeys->entries[hostkeys->num_entries].file = xstrdup(path); hostkeys->entries[hostkeys->num_entries].line = linenum; hostkeys->entries[hostkeys->num_entries].key = key; hostkeys->entries[hostkeys->num_entries].marker = marker; hostkeys->num_entries++; num_loaded++; } debug3("%s: loaded %lu keys", __func__, num_loaded); fclose(f); return;}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:85,
示例18: update_part/* * update_part - create or update a partition's configuration data * IN part_desc - description of partition changes * IN create_flag - create a new partition * RET 0 or an error code * global: part_list - list of partition entries * last_part_update - update time of partition records */extern int update_part (update_part_msg_t * part_desc, bool create_flag){ int error_code; struct part_record *part_ptr; if (part_desc->name == NULL) { info("update_part: invalid partition name, NULL"); return ESLURM_INVALID_PARTITION_NAME; } error_code = SLURM_SUCCESS; part_ptr = list_find_first(part_list, &list_find_part, part_desc->name); if (create_flag) { if (part_ptr) { verbose("Duplicate partition name for create (%s)", part_desc->name); return ESLURM_INVALID_PARTITION_NAME; } info("update_part: partition %s being created", part_desc->name); part_ptr = create_part_record(); xfree(part_ptr->name); part_ptr->name = xstrdup(part_desc->name); } else { if (!part_ptr) { verbose("Update for partition not found (%s)", part_desc->name); return ESLURM_INVALID_PARTITION_NAME; } } last_part_update = time(NULL); if (part_desc->max_time != NO_VAL) { info("update_part: setting max_time to %u for partition %s", part_desc->max_time, part_desc->name); part_ptr->max_time = part_desc->max_time; } if ((part_desc->default_time != NO_VAL) && (part_desc->default_time > part_ptr->max_time)) { info("update_part: DefaultTime would exceed MaxTime for " "partition %s", part_desc->name); } else if (part_desc->default_time != NO_VAL) { info("update_part: setting default_time to %u " "for partition %s", part_desc->default_time, part_desc->name); part_ptr->default_time = part_desc->default_time; } if (part_desc->max_nodes != NO_VAL) { info("update_part: setting max_nodes to %u for partition %s", part_desc->max_nodes, part_desc->name); part_ptr->max_nodes = part_desc->max_nodes; part_ptr->max_nodes_orig = part_desc->max_nodes; select_g_alter_node_cnt(SELECT_SET_MP_CNT, &part_ptr->max_nodes); } if (part_desc->min_nodes != NO_VAL) { info("update_part: setting min_nodes to %u for partition %s", part_desc->min_nodes, part_desc->name); part_ptr->min_nodes = part_desc->min_nodes; part_ptr->min_nodes_orig = part_desc->min_nodes; select_g_alter_node_cnt(SELECT_SET_MP_CNT, &part_ptr->min_nodes); } if (part_desc->grace_time != NO_VAL) { info("update_part: setting grace_time to %u for partition %s", part_desc->grace_time, part_desc->name); part_ptr->grace_time = part_desc->grace_time; } if (part_desc->flags & PART_FLAG_HIDDEN) { info("update_part: setting hidden for partition %s", part_desc->name); part_ptr->flags |= PART_FLAG_HIDDEN; } else if (part_desc->flags & PART_FLAG_HIDDEN_CLR) { info("update_part: clearing hidden for partition %s", part_desc->name); part_ptr->flags &= (~PART_FLAG_HIDDEN); } if (part_desc->flags & PART_FLAG_ROOT_ONLY) { info("update_part: setting root_only for partition %s", part_desc->name); part_ptr->flags |= PART_FLAG_ROOT_ONLY; } else if (part_desc->flags & PART_FLAG_ROOT_ONLY_CLR) { info("update_part: clearing root_only for partition %s",//.........这里部分代码省略.........
开发者ID:lipari,项目名称:slurm,代码行数:101,
示例19: verify_canonrrset/** * Check a canonical sig+rrset and signature against a dnskey * @param buf: buffer with data to verify, the first rrsig part and the * canonicalized rrset. * @param algo: DNSKEY algorithm. * @param sigblock: signature rdata field from RRSIG * @param sigblock_len: length of sigblock data. * @param key: public key data from DNSKEY RR. * @param keylen: length of keydata. * @param reason: bogus reason in more detail. * @return secure if verification succeeded, bogus on crypto failure, * unchecked on format errors and alloc failures. */enum sec_statusverify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock, unsigned int sigblock_len, unsigned char* key, unsigned int keylen, char** reason){ /* uses libNSS */ /* large enough for the different hashes */ unsigned char hash[HASH_LENGTH_MAX]; unsigned char hash2[HASH_LENGTH_MAX*2]; HASH_HashType htype = 0; SECKEYPublicKey* pubkey = NULL; SECItem secsig = {siBuffer, sigblock, sigblock_len}; SECItem sechash = {siBuffer, hash, 0}; SECStatus res; unsigned char* prefix = NULL; /* prefix for hash, RFC3110, RFC5702 */ size_t prefixlen = 0; int err; if(!nss_setup_key_digest(algo, &pubkey, &htype, key, keylen, &prefix, &prefixlen)) { verbose(VERB_QUERY, "verify: failed to setup key"); *reason = "use of key for crypto failed"; SECKEY_DestroyPublicKey(pubkey); return sec_status_bogus; }#ifdef USE_DSA /* need to convert DSA, ECDSA signatures? */ if((algo == LDNS_DSA || algo == LDNS_DSA_NSEC3)) { if(sigblock_len == 1+2*SHA1_LENGTH) { secsig.data ++; secsig.len --; } else { SECItem* p = DSAU_DecodeDerSig(&secsig); if(!p) { verbose(VERB_QUERY, "verify: failed DER decode"); *reason = "signature DER decode failed"; SECKEY_DestroyPublicKey(pubkey); return sec_status_bogus; } if(SECITEM_CopyItem(pubkey->arena, &secsig, p)) { log_err("alloc failure in DER decode"); SECKEY_DestroyPublicKey(pubkey); SECITEM_FreeItem(p, PR_TRUE); return sec_status_unchecked; } SECITEM_FreeItem(p, PR_TRUE); } }#endif /* USE_DSA */ /* do the signature cryptography work */ /* hash the data */ sechash.len = HASH_ResultLen(htype); if(sechash.len > sizeof(hash)) { verbose(VERB_QUERY, "verify: hash too large for buffer"); SECKEY_DestroyPublicKey(pubkey); return sec_status_unchecked; } if(HASH_HashBuf(htype, hash, (unsigned char*)sldns_buffer_begin(buf), (unsigned int)sldns_buffer_limit(buf)) != SECSuccess) { verbose(VERB_QUERY, "verify: HASH_HashBuf failed"); SECKEY_DestroyPublicKey(pubkey); return sec_status_unchecked; } if(prefix) { int hashlen = sechash.len; if(prefixlen+hashlen > sizeof(hash2)) { verbose(VERB_QUERY, "verify: hashprefix too large"); SECKEY_DestroyPublicKey(pubkey); return sec_status_unchecked; } sechash.data = hash2; sechash.len = prefixlen+hashlen; memcpy(sechash.data, prefix, prefixlen); memmove(sechash.data+prefixlen, hash, hashlen); } /* verify the signature */ res = PK11_Verify(pubkey, &secsig, &sechash, NULL /*wincx*/); SECKEY_DestroyPublicKey(pubkey); if(res == SECSuccess) { return sec_status_secure; } err = PORT_GetError(); if(err != SEC_ERROR_BAD_SIGNATURE) {//.........这里部分代码省略.........
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:101,
示例20: library/** This function implements a callback from the nuclear data library modules. The arguments for this function are the data as read from the library (Note that single precision is sufficient for library data). These data are copied into NuclearData::nPaths, NuclearData::E, NuclearData::relations, NuclearData::emitted, NuclearData::paths, NuclearData::D[ngroups], and NuclearData::single respectively. */void NuclearData::setData(int numRxns, float* radE, int* daugKza, char** emissions, float** xSection, float thalf, float *totalXSection){ int gNum, rxnNum, totalRxnNum=-1; verbose(4,"Setting NuclearData members."); cleanUp(); /* set dimensions */ nPaths = numRxns; origNPaths = nPaths; if (nPaths < 0) return; /* only need relations and emitted if nPaths > 0 */ if (nPaths > 0) { relations = new int[nPaths]; memCheck(relations,"NuclearData::setData(...) : relations"); emitted = new char*[nPaths]; memCheck(emitted,"NuclearData::setData(...) : emitted"); } paths = new double*[nPaths+1]; memCheck(paths,"NuclearData::setData(...) : paths"); E[0] = radE[0]; E[1] = radE[1]; E[2] = radE[2]; /* initialize total x-sections */ /* total of all paths */ paths[nPaths] = new double[nGroups+1]; memCheck(paths[nPaths],"NuclearData::setData(...) : paths[n]"); for (gNum=0;gNum<nGroups;gNum++) paths[nPaths][gNum] = 0; /* if we are passed a total xsection (we must be in reverse mode) */ if ( (NuclearData::mode == MODE_REVERSE) && (totalXSection != NULL) ) { delete[] single; single = NULL; P = NULL; single = new double[nGroups+1]; for (gNum=0;gNum<nGroups;gNum++) single[gNum] = totalXSection[gNum]*1e-24; D = single; } else D = paths[nPaths]; //For FEINDLib, a value of thalf is "inf" for a stable isotope. D[nGroups] will be re-initialized. if (thalf>0) D[nGroups] = log(2.0)/thalf; else D[nGroups] = 0; /* setup each reaction */ if ( (NuclearData::mode == MODE_REVERSE) || (totalXSection == NULL) ) // ALARALib and ADJLib always yield "true" for (rxnNum=0;rxnNum<nPaths;rxnNum++) { debug(4,"Copying reaction %d with %d groups.",rxnNum,nGroups+1); relations[rxnNum] = daugKza[rxnNum]; /* log location of total reaction */ if (daugKza[rxnNum] == 0) totalRxnNum = rxnNum; emitted[rxnNum] = new char[strlen(emissions[rxnNum])+1]; memCheck(emitted[rxnNum],"NuclearData::setData(...) : emitted[n]"); strcpy(emitted[rxnNum],emissions[rxnNum]); paths[rxnNum] = new double[nGroups+1]; memCheck(paths[rxnNum],"NuclearData::setData(...) : paths[n]"); for (gNum=0;gNum<nGroups;gNum++) { paths[rxnNum][gNum] = xSection[rxnNum][gNum]*1e-24; if (strcmp(emitted[rxnNum],"x")) paths[nPaths][gNum] += paths[rxnNum][gNum]; } paths[rxnNum][nGroups] = xSection[rxnNum][nGroups]; } else //FIENDLib always comes here. It doesn't have a emitted particle implemented { for (rxnNum=0;rxnNum<nPaths;rxnNum++) { debug(4,"Copying reaction %d with %d groups.",rxnNum,nGroups+1); relations[rxnNum] = daugKza[rxnNum];//.........这里部分代码省略.........
开发者ID:svalinn,项目名称:ALARA,代码行数:101,
示例21: setup_key_digest/** * Setup key and digest for verification. Adjust sig if necessary. * * @param algo: key algorithm * @param evp_key: EVP PKEY public key to create. * @param digest_type: digest type to use * @param key: key to setup for. * @param keylen: length of key. * @return false on failure. */static intsetup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type, unsigned char* key, size_t keylen){#ifdef USE_DSA DSA* dsa;#endif RSA* rsa; switch(algo) {#ifdef USE_DSA case LDNS_DSA: case LDNS_DSA_NSEC3: *evp_key = EVP_PKEY_new(); if(!*evp_key) { log_err("verify: malloc failure in crypto"); return 0; } dsa = sldns_key_buf2dsa_raw(key, keylen); if(!dsa) { verbose(VERB_QUERY, "verify: " "sldns_key_buf2dsa_raw failed"); return 0; } if(EVP_PKEY_assign_DSA(*evp_key, dsa) == 0) { verbose(VERB_QUERY, "verify: " "EVP_PKEY_assign_DSA failed"); return 0; } *digest_type = EVP_dss1(); break;#endif /* USE_DSA */ case LDNS_RSASHA1: case LDNS_RSASHA1_NSEC3:#if defined(HAVE_EVP_SHA256) && defined(USE_SHA2) case LDNS_RSASHA256:#endif#if defined(HAVE_EVP_SHA512) && defined(USE_SHA2) case LDNS_RSASHA512:#endif *evp_key = EVP_PKEY_new(); if(!*evp_key) { log_err("verify: malloc failure in crypto"); return 0; } rsa = sldns_key_buf2rsa_raw(key, keylen); if(!rsa) { verbose(VERB_QUERY, "verify: " "sldns_key_buf2rsa_raw SHA failed"); return 0; } if(EVP_PKEY_assign_RSA(*evp_key, rsa) == 0) { verbose(VERB_QUERY, "verify: " "EVP_PKEY_assign_RSA SHA failed"); return 0; } /* select SHA version */#if defined(HAVE_EVP_SHA256) && defined(USE_SHA2) if(algo == LDNS_RSASHA256) *digest_type = EVP_sha256(); else#endif#if defined(HAVE_EVP_SHA512) && defined(USE_SHA2) if(algo == LDNS_RSASHA512) *digest_type = EVP_sha512(); else#endif *digest_type = EVP_sha1(); break; case LDNS_RSAMD5: *evp_key = EVP_PKEY_new(); if(!*evp_key) { log_err("verify: malloc failure in crypto"); return 0; } rsa = sldns_key_buf2rsa_raw(key, keylen); if(!rsa) { verbose(VERB_QUERY, "verify: " "sldns_key_buf2rsa_raw MD5 failed"); return 0; } if(EVP_PKEY_assign_RSA(*evp_key, rsa) == 0) { verbose(VERB_QUERY, "verify: " "EVP_PKEY_assign_RSA MD5 failed"); return 0; } *digest_type = EVP_md5();//.........这里部分代码省略.........
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:101,
示例22: worker_mem_report/** Report on memory usage by this thread and global */static voidworker_mem_report(struct worker* ATTR_UNUSED(worker), struct serviced_query* ATTR_UNUSED(cur_serv)){#ifdef UNBOUND_ALLOC_STATS /* debug func in validator module */ size_t total, front, back, mesh, msg, rrset, infra, ac, superac; size_t me, iter, val; int i; if(verbosity < VERB_ALGO) return; front = listen_get_mem(worker->front); back = outnet_get_mem(worker->back); msg = slabhash_get_mem(worker->env.msg_cache); rrset = slabhash_get_mem(&worker->env.rrset_cache->table); infra = infra_get_mem(worker->env.infra_cache); mesh = mesh_get_mem(worker->env.mesh); ac = alloc_get_mem(&worker->alloc); superac = alloc_get_mem(&worker->daemon->superalloc); iter = 0; val = 0; for(i=0; i<worker->env.mesh->mods.num; i++) { fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh-> mods.mod[i]->get_mem)); if(strcmp(worker->env.mesh->mods.mod[i]->name, "validator")==0) val += (*worker->env.mesh->mods.mod[i]->get_mem) (&worker->env, i); else iter += (*worker->env.mesh->mods.mod[i]->get_mem) (&worker->env, i); } me = sizeof(*worker) + sizeof(*worker->base) + sizeof(*worker->comsig) + comm_point_get_mem(worker->cmd_com) + sizeof(worker->rndstate) + regional_get_mem(worker->scratchpad) + sizeof(*worker->env.scratch_buffer) + ldns_buffer_capacity(worker->env.scratch_buffer) + forwards_get_mem(worker->env.fwds); if(cur_serv) { me += serviced_get_mem(cur_serv); } total = front+back+mesh+msg+rrset+infra+iter+val+ac+superac+me; log_info("Memory conditions: %u front=%u back=%u mesh=%u msg=%u " "rrset=%u infra=%u iter=%u val=%u " "alloccache=%u globalalloccache=%u me=%u", (unsigned)total, (unsigned)front, (unsigned)back, (unsigned)mesh, (unsigned)msg, (unsigned)rrset, (unsigned)infra, (unsigned)iter, (unsigned)val, (unsigned)ac, (unsigned)superac, (unsigned)me); debug_total_mem(total);#else /* no UNBOUND_ALLOC_STATS */ size_t val = 0; int i; if(verbosity < VERB_QUERY) return; for(i=0; i<worker->env.mesh->mods.num; i++) { fptr_ok(fptr_whitelist_mod_get_mem(worker->env.mesh-> mods.mod[i]->get_mem)); if(strcmp(worker->env.mesh->mods.mod[i]->name, "validator")==0) val += (*worker->env.mesh->mods.mod[i]->get_mem) (&worker->env, i); } verbose(VERB_QUERY, "cache memory msg=%u rrset=%u infra=%u val=%u", (unsigned)slabhash_get_mem(worker->env.msg_cache), (unsigned)slabhash_get_mem(&worker->env.rrset_cache->table), (unsigned)infra_get_mem(worker->env.infra_cache), (unsigned)val);#endif /* UNBOUND_ALLOC_STATS */}
开发者ID:RS-liuyang,项目名称:rsdns,代码行数:69,
示例23: worker_handle_requestint worker_handle_request(struct comm_point* c, void* arg, int error, struct comm_reply* repinfo){ struct worker* worker = (struct worker*)arg; int ret; hashvalue_t h; struct lruhash_entry* e; struct query_info qinfo; struct edns_data edns; enum acl_access acl; if(error != NETEVENT_NOERROR) { /* some bad tcp query DNS formats give these error calls */ verbose(VERB_ALGO, "handle request called with err=%d", error); return 0; } acl = acl_list_lookup(worker->daemon->acl, &repinfo->addr, repinfo->addrlen); if(acl == acl_deny) { comm_point_drop_reply(repinfo); if(worker->stats.extended) worker->stats.unwanted_queries++; return 0; } else if(acl == acl_refuse) { ldns_buffer_set_limit(c->buffer, LDNS_HEADER_SIZE); ldns_buffer_write_at(c->buffer, 4, (uint8_t*)"/0/0/0/0/0/0/0/0", 8); LDNS_QR_SET(ldns_buffer_begin(c->buffer)); LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), LDNS_RCODE_REFUSED); log_addr(VERB_ALGO, "refused query from", &repinfo->addr, repinfo->addrlen); log_buf(VERB_ALGO, "refuse", c->buffer); if(worker->stats.extended) worker->stats.unwanted_queries++; return 1; } if((ret=worker_check_request(c->buffer, worker)) != 0) { verbose(VERB_ALGO, "worker check request: bad query."); log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen); if(ret != -1) { LDNS_QR_SET(ldns_buffer_begin(c->buffer)); LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), ret); return 1; } comm_point_drop_reply(repinfo); return 0; } worker->stats.num_queries++; /* see if query is in the cache */ if(!query_info_parse(&qinfo, c->buffer)) { verbose(VERB_ALGO, "worker parse request: formerror."); log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen); ldns_buffer_rewind(c->buffer); LDNS_QR_SET(ldns_buffer_begin(c->buffer)); LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), LDNS_RCODE_FORMERR); server_stats_insrcode(&worker->stats, c->buffer); return 1; } if(qinfo.qtype == LDNS_RR_TYPE_AXFR || qinfo.qtype == LDNS_RR_TYPE_IXFR) { verbose(VERB_ALGO, "worker request: refused zone transfer."); log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen); LDNS_QR_SET(ldns_buffer_begin(c->buffer)); LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), LDNS_RCODE_REFUSED); if(worker->stats.extended) { worker->stats.qtype[qinfo.qtype]++; server_stats_insrcode(&worker->stats, c->buffer); } return 1; } if((ret=parse_edns_from_pkt(c->buffer, &edns)) != 0) { verbose(VERB_ALGO, "worker parse edns: formerror."); log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen); ldns_buffer_rewind(c->buffer); LDNS_QR_SET(ldns_buffer_begin(c->buffer)); LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), ret); server_stats_insrcode(&worker->stats, c->buffer); return 1; } if(edns.edns_present && edns.edns_version != 0) { edns.ext_rcode = (uint8_t)(EDNS_RCODE_BADVERS>>4); edns.edns_version = EDNS_ADVERTISED_VERSION; edns.udp_size = EDNS_ADVERTISED_SIZE; edns.bits &= EDNS_DO; verbose(VERB_ALGO, "query with bad edns version."); log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen); error_encode(c->buffer, EDNS_RCODE_BADVERS&0xf, &qinfo, *(uint16_t*)ldns_buffer_begin(c->buffer), ldns_buffer_read_u16_at(c->buffer, 2), NULL); attach_edns_record(c->buffer, &edns); return 1; }
开发者ID:RS-liuyang,项目名称:rsdns,代码行数:96,
示例24: nss_setup_key_digest//.........这里部分代码省略......... 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 }; static unsigned char p_sha512[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40 }; /* from RFC6234 */ /* for future RSASHA384 .. static unsigned char p_sha384[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30}; */ switch(algo) {#ifdef USE_DSA case LDNS_DSA: case LDNS_DSA_NSEC3: *pubkey = nss_buf2dsa(key, keylen); if(!*pubkey) { log_err("verify: malloc failure in crypto"); return 0; } *htype = HASH_AlgSHA1; /* no prefix for DSA verification */ break;#endif case LDNS_RSASHA1: case LDNS_RSASHA1_NSEC3:#ifdef USE_SHA2 case LDNS_RSASHA256:#endif#ifdef USE_SHA2 case LDNS_RSASHA512:#endif *pubkey = nss_buf2rsa(key, keylen); if(!*pubkey) { log_err("verify: malloc failure in crypto"); return 0; } /* select SHA version */#ifdef USE_SHA2 if(algo == LDNS_RSASHA256) { *htype = HASH_AlgSHA256; *prefix = p_sha256; *prefixlen = sizeof(p_sha256); } else#endif#ifdef USE_SHA2 if(algo == LDNS_RSASHA512) { *htype = HASH_AlgSHA512; *prefix = p_sha512; *prefixlen = sizeof(p_sha512); } else#endif { *htype = HASH_AlgSHA1; *prefix = p_sha1; *prefixlen = sizeof(p_sha1); } break; case LDNS_RSAMD5: *pubkey = nss_buf2rsa(key, keylen); if(!*pubkey) { log_err("verify: malloc failure in crypto"); return 0; } *htype = HASH_AlgMD5; *prefix = p_md5; *prefixlen = sizeof(p_md5); break;#ifdef USE_ECDSA case LDNS_ECDSAP256SHA256: *pubkey = nss_buf2ecdsa(key, keylen, LDNS_ECDSAP256SHA256); if(!*pubkey) { log_err("verify: malloc failure in crypto"); return 0; } *htype = HASH_AlgSHA256; /* no prefix for DSA verification */ break; case LDNS_ECDSAP384SHA384: *pubkey = nss_buf2ecdsa(key, keylen, LDNS_ECDSAP384SHA384); if(!*pubkey) { log_err("verify: malloc failure in crypto"); return 0; } *htype = HASH_AlgSHA384; /* no prefix for DSA verification */ break;#endif /* USE_ECDSA */ case LDNS_ECC_GOST: default: verbose(VERB_QUERY, "verify: unknown algorithm %d", algo); return 0; } return 1;}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:101,
示例25: copyMafs/* copyMafs - copy all the maf alignments into * one sequence for each species */static void copyMafs(struct hash *siHash, struct exonInfo **giList, boolean inExons){int start = 0;struct exonInfo *gi = *giList;for(; gi; gi = gi->next) { int thisSize = 0; struct mafAli *ali = gi->ali; for(; ali; ali = ali->next) { int newStart = copyAli(siHash, ali, start); thisSize += newStart - start; start = newStart; } struct hashCookie cookie = hashFirst(siHash); struct hashEl *hel; if (inExons || (gi->next == NULL)) while ((hel = hashNext(&cookie)) != NULL) { struct speciesInfo *si = hel->val; pushPosString(si); } }boolean frameNeg = ((*giList)->strand == '-');if (frameNeg) { int size = 0; struct hashCookie cookie = hashFirst(siHash); struct hashEl *hel; verbose(3, "flipping exons/n"); while ((hel = hashNext(&cookie)) != NULL) { struct speciesInfo *si = hel->val; if (si == NULL) continue; if (size != 0) assert(size == si->size); else size = si->size; reverseComplement(si->nucSequence, si->size); slReverse(&si->posStrings); } gi = *giList; for(; gi; gi = gi->next) { verbose(3, "old start %d ",gi->exonStart); gi->exonStart = size - (gi->exonStart + gi->exonSize); verbose(3, "new start %d size %d /n",gi->exonStart, gi->exonSize); if (gi->next == NULL) assert(gi->exonStart == 0); } slReverse(giList); }}
开发者ID:maximilianh,项目名称:kent,代码行数:70,
示例26: respip_data_answer/** * See if response-ip or tag data should override the original answer rrset * (which is rep->rrsets[rrset_id]) and if so override it. * This is (mostly) equivalent to localzone.c:local_data_answer() but for * response-ip actions. * Note that this function distinguishes error conditions from "success but * not overridden". This is because we want to avoid accidentally applying * the "no data" action in case of error. * @param raddr: address span that requires an action * @param action: action to apply * @param qtype: original query type * @param rep: original reply message * @param rrset_id: the rrset ID in 'rep' to which the action should apply * @param new_repp: see respip_rewrite_reply * @param tag: if >= 0 the tag ID used to determine the action and data * @param tag_datas: data corresponding to 'tag'. * @param tag_datas_size: size of 'tag_datas' * @param tagname: array of tag names, used for logging * @param num_tags: size of 'tagname', used for logging * @param redirect_rrsetp: ptr to redirect record * @param region: region for building new reply * @return 1 if overridden, 0 if not overridden, -1 on error. */static intrespip_data_answer(const struct resp_addr* raddr, enum respip_action action, uint16_t qtype, const struct reply_info* rep, size_t rrset_id, struct reply_info** new_repp, int tag, struct config_strlist** tag_datas, size_t tag_datas_size, char* const* tagname, int num_tags, struct ub_packed_rrset_key** redirect_rrsetp, struct regional* region){ struct ub_packed_rrset_key* rp = raddr->data; struct reply_info* new_rep; *redirect_rrsetp = NULL; if(action == respip_redirect && tag != -1 && (size_t)tag<tag_datas_size && tag_datas[tag]) { struct query_info dataqinfo; struct ub_packed_rrset_key r; /* Extract parameters of the original answer rrset that can be * rewritten below, in the form of query_info. Note that these * can be different from the info of the original query if the * rrset is a CNAME target.*/ memset(&dataqinfo, 0, sizeof(dataqinfo)); dataqinfo.qname = rep->rrsets[rrset_id]->rk.dname; dataqinfo.qname_len = rep->rrsets[rrset_id]->rk.dname_len; dataqinfo.qtype = ntohs(rep->rrsets[rrset_id]->rk.type); dataqinfo.qclass = ntohs(rep->rrsets[rrset_id]->rk.rrset_class); memset(&r, 0, sizeof(r)); if(local_data_find_tag_datas(&dataqinfo, tag_datas[tag], &r, region)) { verbose(VERB_ALGO, "response-ip redirect with tag data [%d] %s", tag, (tag<num_tags?tagname[tag]:"null")); /* use copy_rrset() to 'normalize' memory layout */ rp = copy_rrset(&r, region); if(!rp) return -1; } } if(!rp) return 0; /* If we are using response-ip-data, we need to make a copy of rrset * to replace the rrset's dname. Note that, unlike local data, we * rename the dname for other actions than redirect. This is because * response-ip-data isn't associated to any specific name. */ if(rp == raddr->data) { rp = copy_rrset(rp, region); if(!rp) return -1; rp->rk.dname = rep->rrsets[rrset_id]->rk.dname; rp->rk.dname_len = rep->rrsets[rrset_id]->rk.dname_len; } /* Build a new reply with redirect rrset. We keep any preceding CNAMEs * and replace the address rrset that triggers the action. If it's * type ANY query, however, no other answer records should be kept * (note that it can't be a CNAME chain in this case due to * sanitizing). */ if(qtype == LDNS_RR_TYPE_ANY) rrset_id = 0; new_rep = make_new_reply_info(rep, region, rrset_id + 1, rrset_id); if(!new_rep) return -1; rp->rk.flags |= PACKED_RRSET_FIXEDTTL; /* avoid adjusting TTL */ new_rep->rrsets[rrset_id] = rp; *redirect_rrsetp = rp; *new_repp = new_rep; return 1;}
开发者ID:Bluecoreg,项目名称:monero,代码行数:94,
示例27: os_ReportdStart//.........这里部分代码省略......... if(*tmp_str != '/0') { _os_report_add_tostore(tmp_str, r_filter->top_group, al_data); } } } /* Adding to the location top filter. */ _os_report_add_tostore(al_data->location, r_filter->top_location, al_data); if(al_data->filename != NULL) { _os_report_add_tostore(al_data->filename, r_filter->top_files, al_data); } } /* No report available */ if(alerts_filtered == 0) { if(!r_filter->report_name) merror("%s: INFO: Report completed and zero alerts post-filter.", __local_name); else merror("%s: INFO: Report '%s' completed and zero alerts post-filter.", __local_name, r_filter->report_name); return; } if(r_filter->report_name) verbose("%s: INFO: Report '%s' completed. Creating output...", __local_name, r_filter->report_name); else verbose("%s: INFO: Report completed. Creating output...", __local_name); l_print_out(" "); if(r_filter->report_name) l_print_out("Report '%s' completed.", r_filter->report_name); else l_print_out("Report completed. =="); l_print_out("------------------------------------------------"); l_print_out("->Processed alerts: %d", alerts_processed); l_print_out("->Post-filtering alerts: %d", alerts_filtered); l_print_out("->First alert: %s", first_alert); l_print_out("->Last alert: %s", last_alert); l_print_out(" "); l_print_out(" "); OSStore_Sort(r_filter->top_srcip, _os_report_sort_compare); OSStore_Sort(r_filter->top_user, _os_report_sort_compare); OSStore_Sort(r_filter->top_level, _os_report_sort_compare); OSStore_Sort(r_filter->top_group, _os_report_sort_compare); OSStore_Sort(r_filter->top_location, _os_report_sort_compare); OSStore_Sort(r_filter->top_rule, _os_report_sort_compare); OSStore_Sort(r_filter->top_files, _os_report_sort_compare); if(r_filter->top_srcip) os_report_printtop(r_filter->top_srcip, "Source ip", 0); if(r_filter->top_user) os_report_printtop(r_filter->top_user, "Username", 0);
开发者ID:asielenrique,项目名称:ossec-hids-local,代码行数:66,
注:本文中的verbose函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ verbose_printf函数代码示例 C++ ver函数代码示例 |