/* * Process WM_CON records * If there isn't already a request node for this reqid.arrayid, * make one. */ static void wm_con(struct wkmgmtbs *wbuf) { struct wkmgmtbs *riptr = NULL; struct wmreq *rqptr; if (db_flag > 8) { Ndebug("wm_con(9): CON - reqid(%lld), arrayid(%d).\n", wbuf->reqid, wbuf->arrayid); } if ((rqptr = find_request(wbuf->reqid, wbuf->arrayid)) == NULL) { /* * This is a new request. No other records for this * request have been seen. */ if (db_flag > 2) { Ndebug("wm_con(3): Only WM_CON record " "found for reqid(%lld), subtype(%d).\n", wbuf->reqid, wbuf->subtype); } make_request(NORM_REQ); rqptr = rhead->last; rqptr->reqid = wbuf->reqid; rqptr->arrayid = wbuf->arrayid; rqptr->stime = wbuf->time; riptr = rqptr->slast->riptr; init_wkmgmtbs(riptr, wbuf); } return; }
/* Set up a request for the desired service principal, using ctx->cur_tgt. * Optionally allow the answer to be a referral. */ static krb5_error_code make_request_for_service(krb5_context context, krb5_tkt_creds_context ctx, krb5_boolean referral) { krb5_error_code code; int extra_options; TRACE_TKT_CREDS_SERVICE_REQ(context, ctx->server, referral); /* Include the caller-specified KDC options in service requests. */ extra_options = ctx->req_kdcopt; /* Automatically set the enc-tkt-in-skey flag for user-to-user requests. */ if (ctx->in_creds->second_ticket.length != 0 && (extra_options & KDC_OPT_CNAME_IN_ADDL_TKT) == 0) extra_options |= KDC_OPT_ENC_TKT_IN_SKEY; /* Set the canonicalize flag for referral requests. */ if (referral) extra_options |= KDC_OPT_CANONICALIZE; /* * Use the profile enctypes for referral requests, since we might get back * a TGT. We'll ask again with context enctypes if we get the actual * service ticket and it's not consistent with the context enctypes. */ if (referral) context->use_conf_ktypes = TRUE; ctx->tgs_in_creds = ctx->in_creds; code = make_request(context, ctx, extra_options); if (referral) context->use_conf_ktypes = FALSE; return code; }
GByteArray* sqlx_pack_PIPEFROM(struct sqlx_name_s *name, const gchar *source) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_PIPEFROM, name); metautils_message_add_field_str(req, NAME_MSGKEY_SRC, source); return message_marshall_gba_and_clean(req); }
int main() { MSocket ws; if (LoadCADB() <= 0) return -1; TTlsLink link; link.context = &ws; link.flush = &FlushFunction; // do nothing link.read_limit = 1024; link.write_limit = 1024; link.recv = &RecvFunction; link.send = &SendFunction; TinyTLSContext * ctx = ttlsCreateContext(); ttlsSetHostname(ctx, hostname); ttlsUseCertStorage(ctx, certdb); unsigned requests = 1000; for (unsigned i = 0; i < requests; ++i) { int res1 = make_request(ws, ctx, &link); printf("Connection %u result: %d\n", (unsigned)i, res1); pause(1); } return 0; }
GByteArray* sqlx_pack_PIPETO(struct sqlx_name_s *name, const gchar *target) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_PIPETO, name); metautils_message_add_field_str(req, NAME_MSGKEY_DST, target); return message_marshall_gba_and_clean(req); }
GByteArray * sqlx_pack_PROPDEL(const struct sqlx_name_s *name, const gchar * const *keys) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_PROPDEL, name); metautils_message_add_body_unref(req, STRV_encode_gba((gchar**)keys)); return message_marshall_gba_and_clean(req); }
GByteArray* sqlx_pack_REPLICATE(struct sqlx_name_s *name, struct TableSequence *tabseq) { GError *err = NULL; GByteArray *body, *encoded; MESSAGE req; EXTRA_ASSERT(name != NULL); EXTRA_ASSERT(tabseq != NULL); body = sqlx_encode_TableSequence(tabseq, &err); if (!body) { GRID_WARN("Transaction encoding error : (%d) %s", err->code, err->message); return NULL; } req = make_request("SQLX_REPLICATE", name); (void) message_set_BODY(req, body->data, body->len, NULL); encoded = message_marshall_gba(req, NULL); g_byte_array_free(body, TRUE); (void) message_destroy(req, NULL); return encoded; }
GByteArray* sqlx_pack_DUMP(struct sqlx_name_s *name, gboolean chunked) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_DUMP, name); metautils_message_add_field(req, NAME_MSGKEY_CHUNKED, &chunked, 1); return message_marshall_gba_and_clean(req); }
/* needs serious testing */ int put_request_header (struct request *req, char *name, char *value) { /* Change the content of the actual request. An alternative would be to only create a new content string when a request is being sent */ if (hash_table_get (req->headers, name) == NULL) { char *ptr; int new_length = req->content_len + strlen (name) + 2 + strlen (value) + 1; req->content = realloc (req->content, new_length); hash_table_put (req->headers, name, value); ptr = req->content + req->content_len - 2; memset (ptr, 0, new_length - req->content_len); APPEND(ptr, name, strlen (name)); APPEND(ptr, ": ", 2); APPEND(ptr, value, strlen (value)); APPEND(ptr, "\r\n", 2); APPEND(ptr, "\r\n", 2); req->content_len = new_length - 1; } else { hash_table_put (req->headers, name, value); printf ("Key-value pair (%s, %s)\n", name, hash_table_get (req->headers, name)); req = make_request (req->url, req->headers, req->method); } return 0; }
GByteArray* sqlx_pack_RESTORE(struct sqlx_name_s *name, const guint8 *raw, gsize rawsize) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_RESTORE, name); metautils_message_set_BODY(req, raw, rawsize); return message_marshall_gba_and_clean(req); }
HANDLE repGetPeers(HANDLE rep, cb_repGetPeers cb, void *cbarg, int maxResults, Constraint *cons, int clen, Ranking *ranks, int rlen, const char *ch) { if (!check_handle(rep, __FUNCTION__)) return NULL; debug("About to call getPeers with maxResults %d, constaints %s and rankings %s", maxResults, constraints2str(cons, clen), rankings2str(ranks, rlen)); char uri[10240]; request_data *rd = (request_data *)malloc(sizeof(request_data)); if (!rd) return NULL; rd->id = (void *)rd; rd->cb = cb; rd->cbarg = cbarg; rd->server = rep; rd->data = maxResults; sprintf(uri, "/GetPeers?maxresults=%d&%s%s%s", maxResults, constraints2str(cons, clen), (rlen ? "&" : ""), rankings2str(ranks, rlen)); if (ch) { if (clen + rlen > 0) strcat(uri, "&"); strcat(uri, "channel="); strcat(uri, ch); } debug("Making getPeers request with URI %s", uri); make_request(uri, _stringlist_callback, (void *)rd); return (HANDLE)(rd); }
GByteArray* sqlx_pack_GETVERS(struct sqlx_name_s *name) { EXTRA_ASSERT(name != NULL); MESSAGE req = make_request(NAME_MSGNAME_SQLX_GETVERS, name); return message_marshall_gba_and_clean(req); }
/** Send a query to look up the address for a name. * @param[in] query Callback information. * @param[in] name Hostname to look up. * @param[in] request DNS lookup structure (may be NULL). * @param[in] type Preferred request type. */ static void do_query_name(dns_callback_f callback, void *ctx, const char *name, struct reslist *request, int type) { char host_name[HOSTLEN + 1]; ircd_strncpy(host_name, name, HOSTLEN); add_local_domain(host_name, HOSTLEN); if (request == NULL) { request = make_request(callback, ctx); DupString(request->name, host_name); #ifdef IPV6 if (type != T_A) request->state = REQ_AAAA; else #endif request->state = REQ_A; } request->type = type; Debug((DEBUG_DNS, "Requesting DNS %s %s as %p", (request->state == REQ_AAAA ? "AAAA" : "A"), host_name, request)); query_name(host_name, C_IN, type, request); }
/* Set up a request for a TGT for realm, using ctx->cur_tgt. */ static krb5_error_code make_request_for_tgt(krb5_context context, krb5_tkt_creds_context ctx, const krb5_data *realm) { krb5_error_code code; /* Construct the principal krbtgt/<realm>@<cur-tgt-realm>. */ krb5_free_principal(context, ctx->tgt_princ); ctx->tgt_princ = NULL; code = krb5int_tgtname(context, realm, &ctx->cur_tgt->server->realm, &ctx->tgt_princ); if (code != 0) return code; TRACE_TKT_CREDS_TGT_REQ(context, ctx->tgt_princ, ctx->cur_tgt->server); /* Construct input creds using ctx->tgt_in_creds as a container. */ memset(&ctx->tgt_in_creds, 0, sizeof(ctx->tgt_in_creds)); ctx->tgt_in_creds.client = ctx->client; ctx->tgt_in_creds.server = ctx->tgt_princ; /* Make a request for the above creds with no extra options. */ ctx->tgs_in_creds = &ctx->tgt_in_creds; code = make_request(context, ctx, 0); return code; }
std::string AdminPortalProtocol::admin_view_get_prop(const std::string& view, const std::string& name) throw (P4PProtocolError) { check_txn(); p4p::protocol::detail::ResponseSingleTokenReader reader; make_request("GET", "admin/" + admin_token_ + '/' + url_escape(view) + "/prop/" + url_escape(name), reader); return reader.get_token(); }
void ll_rw_block(int rw, struct buffer_head * bh) { unsigned int major; major=MAJOR(bh->b_dev); make_request(major,rw,bh); }
void make_request(reference_connection const& ref_c , std::string const& method , ArgsGrammar const& args_grammar , Args const& args , service_context_list const& service_context = service_context_list()) { make_request(*ref_c.socket, ref_c.object_key, method, args_grammar, args, service_context); }
GByteArray * sqlx_pack_PROPSET_pairs(struct sqlx_name_s *name, gboolean flush, GSList *pairs) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_PROPSET, name); if (flush) metautils_message_add_field_strint (req, NAME_MSGKEY_FLUSH, 1); metautils_message_add_body_unref (req, key_value_pairs_marshall_gba (pairs, NULL)); return message_marshall_gba_and_clean(req); }
GByteArray * sqlx_pack_DESTROY(struct sqlx_name_s *name, gboolean local) { gint8 local2 = BOOL(local); MESSAGE req = make_request(NAME_MSGNAME_SQLX_DESTROY, name); if (local) metautils_message_add_field(req, NAME_MSGKEY_LOCAL, &local2, 1); return message_marshall_gba_and_clean(req); }
GByteArray * sqlx_pack_PROPSET_tab(const struct sqlx_name_s *name, gboolean flush, gchar **kv) { MESSAGE req = make_request(NAME_MSGNAME_SQLX_PROPSET, name); if (flush) metautils_message_add_field_strint (req, NAME_MSGKEY_FLUSH, 1); metautils_message_add_body_unref (req, KV_encode_gba((gchar**)kv)); return message_marshall_gba_and_clean(req); }
void AdminPortalProtocol::admin_begin_txn() throw (P4PProtocolError) { if (!admin_token_.empty()) throw AdminPortalProtocolDupTxnError(); p4p::protocol::detail::ResponseSingleTokenReader reader; make_request("GET", "admin", reader); admin_token_ = reader.get_token(); }
int main(){ printf("Ćadowanie klienta...\n"); signal(SIGINT, sigint_handler); smd = shm_open("/shm", O_RDWR, 0600); if(smd < 0){ perror("SHM OPEN ERROR!"); exit(-1); } s_area = (unsigned int*) mmap(0, sizeof(message), PROT_WRITE | PROT_READ, MAP_SHARED, smd, 0 ); if(s_area == (void*)-1){ perror("mmap error!"); exit(-1); } sem_t* sem_request = sem_open("/sem-request", O_RDWR); if(sem_request == SEM_FAILED){ perror("Request semafor error!"); exit(-1); } sem_t* sem_respond = sem_open("/sem-respond", O_RDWR); if(sem_respond == SEM_FAILED){ perror("Respond semafor error!"); exit(-1); } sem_clients = sem_open("/sem-clients", O_RDWR); if(sem_clients == SEM_FAILED){ perror("Clients semafor error!"); exit(-1); } //end of initialization msg = (void*) s_area; csem = 0; my_usr_id = -1; printf("Welcome in Hospital client!\n"); int auth = 0; // main loop while(1){ int make = make_request(&auth); sem_wait(sem_clients); csem = 1; if(make == 0 ){ copy_request(); printf("%s\n",msg->message); sem_post(sem_request); sem_wait(sem_respond); process_respond(&auth); while(msg->is_complete < 0){ sem_wait(sem_respond); process_respond(&auth); } } sem_post(sem_clients); csem = 0; } return 0; }
GByteArray* sqlx_pack_REPLICATE(struct sqlx_name_s *name, struct TableSequence *tabseq) { EXTRA_ASSERT(name != NULL); EXTRA_ASSERT(tabseq != NULL); MESSAGE req = make_request(NAME_MSGNAME_SQLX_REPLICATE, name); metautils_message_add_body_unref(req, sqlx_encode_TableSequence(tabseq, NULL)); return message_marshall_gba_and_clean(req); }
/** Send a query to look up the name for an address. * @param[in] query Callback information. * @param[in] addr Address to look up. * @param[in] request DNS lookup structure (may be NULL). */ static void do_query_number(dns_callback_f callback, void *ctx, const struct irc_in_addr *addr, struct reslist *request) { char ipbuf[128]; const unsigned char *cp; if (irc_in_addr_is_ipv4(addr)) { cp = (const unsigned char*)&addr->in6_16[6]; ircd_snprintf(NULL, ipbuf, sizeof(ipbuf), "%u.%u.%u.%u.in-addr.arpa.", (unsigned int)(cp[3]), (unsigned int)(cp[2]), (unsigned int)(cp[1]), (unsigned int)(cp[0])); } else { const char *intarpa; if (request != NULL && request->state == REQ_INT) intarpa = "int"; else intarpa = "arpa"; cp = (const unsigned char *)&addr->in6_16[0]; ircd_snprintf(NULL, ipbuf, sizeof(ipbuf), "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.%s.", (unsigned int)(cp[15]&0xf), (unsigned int)(cp[15]>>4), (unsigned int)(cp[14]&0xf), (unsigned int)(cp[14]>>4), (unsigned int)(cp[13]&0xf), (unsigned int)(cp[13]>>4), (unsigned int)(cp[12]&0xf), (unsigned int)(cp[12]>>4), (unsigned int)(cp[11]&0xf), (unsigned int)(cp[11]>>4), (unsigned int)(cp[10]&0xf), (unsigned int)(cp[10]>>4), (unsigned int)(cp[9]&0xf), (unsigned int)(cp[9]>>4), (unsigned int)(cp[8]&0xf), (unsigned int)(cp[8]>>4), (unsigned int)(cp[7]&0xf), (unsigned int)(cp[7]>>4), (unsigned int)(cp[6]&0xf), (unsigned int)(cp[6]>>4), (unsigned int)(cp[5]&0xf), (unsigned int)(cp[5]>>4), (unsigned int)(cp[4]&0xf), (unsigned int)(cp[4]>>4), (unsigned int)(cp[3]&0xf), (unsigned int)(cp[3]>>4), (unsigned int)(cp[2]&0xf), (unsigned int)(cp[2]>>4), (unsigned int)(cp[1]&0xf), (unsigned int)(cp[1]>>4), (unsigned int)(cp[0]&0xf), (unsigned int)(cp[0]>>4), intarpa); } if (request == NULL) { request = make_request(callback, ctx); request->state= REQ_PTR; request->type = T_PTR; memcpy(&request->addr, addr, sizeof(request->addr)); request->name = (char *)MyMalloc(HOSTLEN + 1); } Debug((DEBUG_DNS, "Requesting DNS PTR %s as %p", ipbuf, request)); query_name(ipbuf, C_IN, T_PTR, request); }
void ll_rw_block(int rw, struct buffer_head * bh) { unsigned int major; if ((major=MAJOR(bh->b_dev)) >= NR_BLK_DEV || !(blk_dev[major].request_fn)) { printk("Trying to read nonexistent block-device\n\r"); return; } make_request(major,rw,bh); }
GByteArray * sqlx_pack_PROPDEL(struct sqlx_name_s *name, const gchar * const *keys) { GSList *names = metautils_array_to_list((void**)keys); GByteArray *body = strings_marshall_gba(names, NULL); g_slist_free(names); MESSAGE req = make_request(NAME_MSGNAME_SQLX_PROPDEL, name); metautils_message_add_body_unref(req, body); return message_marshall_gba_and_clean(req); }
GByteArray * sqlx_pack_LOAD(struct sqlx_name_s *name, GByteArray *dump) { struct message_s *req; req = make_request("SQLX_LOAD", name); g_assert(req != NULL); message_set_BODY(req, dump->data, dump->len, NULL); return message_marshall_gba_and_clean(req); }
jstring Java_euphoria_psycho_comic_util_Utilities_request(JNIEnv *env, jstring host, jstring path) { const char *n_host = (*env)->GetStringUTFChars(env, host, 0); const char *n_path = (*env)->GetStringUTFChars(env, path, 0); LOGW("%s",n_host); Buffer *response = buffer_alloc(255); int status = 0; int sockfd = 0; struct addrinfo *res = NULL; status = init_connection(n_host, "80", &res); error_unless(status == 0, "Could not resolve host: %s\n", gai_strerror(status)); jstring result1 = (*env)->NewStringUTF(env, n_host); return result1; sockfd = make_connection(res); error_unless(sockfd > 0, "Could not make connection to '"); status = make_request(sockfd, n_host, n_path); error_unless(status > 0, "Sending request failed"); status = fetch_response(sockfd, &response, RECV_SIZE); error_unless(status >= 0, "Fetching response failed"); printf("%s\n", response->contents); close(sockfd); freeaddrinfo(res); jstring result = (*env)->NewStringUTF(env, response->contents); buffer_free(response); (*env)->ReleaseStringUTFChars(env, host, n_host); (*env)->ReleaseStringUTFChars(env, path, n_path); return result; error: if (sockfd > 0) { close(sockfd); } if (res != NULL) { freeaddrinfo(res); } (*env)->ReleaseStringUTFChars(env, host, n_host); (*env)->ReleaseStringUTFChars(env, path, n_path); return (*env)->NewStringUTF(env, "Error"); buffer_free(response); // return (*env)->NewStringUTF(env, "Hello from JNI ! Compiled with ABI " // ABI // "."); }
bool resolver::resolve(const char* name, size_t namelen, rr_type type) { if ((namelen == 0) || (namelen >= NAME_MAX_LEN)) { return false; } // Check if the name is in the cache. dns_entry* e; dns_entry entry; entry.name = const_cast<char*>(name); entry.namelen = namelen; red_black_tree<dns_entry>::iterator it; if (_M_cache.find(entry, it)) { #if DEBUG printf("[resolver::resolve] Name [%.*s] found in the cache.\n", namelen, name); #endif time_t now = time(NULL); e = it.data; const struct address* address; unsigned short naddresses; switch (e->type) { case (unsigned short) STATUS_WAITING: return true; case (unsigned short) STATUS_NO_DOMAIN: if (now < e->timestamp + (time_t) TTL_NO_DOMAIN) { return false; } break; default: // STATUS_VALID. address = e->addresses; naddresses = e->naddresses; for (unsigned short i = 0; i < naddresses; i++, address++) { if (now < address->expire) { return true; } } } #if DEBUG printf("[resolver::resolve] Have to resolve [%.*s] again.\n", namelen, name); #endif e->destroy_addresses(); } else { e = NULL; } return make_request(name, namelen, type, e != NULL); }
/* * Process WM_TERM records * Add the termination code to the reqinfo node. */ static void wm_term(struct wkmgmtbs *wbuf) { struct wkmgmtbs *riptr; struct wmreq *rqptr; if (db_flag > 8) { Ndebug("wm_term(9): TERM - reqid(%lld), arrayid(%d).\n", wbuf->reqid, wbuf->arrayid); } if ((rqptr = find_request(wbuf->reqid, wbuf->arrayid)) == NULL) { make_request(NORM_REQ); rqptr = rhead->last; rqptr->reqid = wbuf->reqid; rqptr->arrayid = wbuf->arrayid; riptr = rqptr->slast->riptr; init_wkmgmtbs(riptr, wbuf); } else if (rqptr->slast == NULL) { make_segment(rqptr, NORM_REQ); riptr = rqptr->slast->riptr; init_wkmgmtbs(riptr, wbuf); } else { riptr = rqptr->slast->riptr; } /* * The last node on the segment list should be * what we want. If not, the records in the file * are out of order. */ if (riptr->term_subtype == WM_NO_TERM) { riptr->code = wbuf->code; riptr->utime = wbuf->utime; riptr->stime = wbuf->stime; riptr->term_subtype = wbuf->subtype; } else { if (db_flag > 2) { Ndebug("wm_term(3): reqinfo node not " "at end of segment list.\n" "\triptr: term_subtype(%d), jid(0x%llx), " "wbuf->jid(0x%llx), rqptr->ltype(%d).\n", riptr->term_subtype, riptr->jid, wbuf->jid, rqptr->ltype); } return; /* ignore this record */ } rqptr->ltype = wbuf->type; rqptr->lsubtype = wbuf->subtype; return; }