void dbg_reply_get_thread_list(struct dbg_context* dbg, const dbg_threadid_t* threads, size_t len) { assert(DREQ_GET_THREAD_LIST == dbg->req.type); if (0 == len) { write_packet(dbg, "l"); } else { size_t maxlen = 1/*m char*/ + (2 * sizeof(pid_t) + 1/*,*/) * len + 1/*\0*/; char* str = sys_malloc(maxlen); int i, offset = 0; str[offset++] = 'm'; for (i = 0; i < len; ++i) { offset += snprintf(&str[offset], maxlen - offset, "%02x,", threads[i]); } /* Overwrite the trailing ',' */ str[offset - 1] = '\0'; write_packet(dbg, str); sys_free((void**)&str); } consume_request(dbg); }
void test_already_launched (void) { const gchar *packet; gsize packet_size; GString *output; GString *expected_packet; const gchar command_line[] = "/bin/cat"; const gchar *user_name; user_name = g_get_user_name(); milter_manager_launch_command_encoder_encode_launch(command_encoder, &packet, &packet_size, command_line, user_name); cut_trace(write_packet(packet, packet_size)); cut_trace(write_packet(packet, packet_size)); pump_all_events(); milter_manager_reply_encoder_encode_success(reply_encoder, &packet, &packet_size); expected_packet = g_string_new_len(packet, packet_size); milter_manager_reply_encoder_encode_error(reply_encoder, &packet, &packet_size, "already launched: </bin/cat>"); g_string_append_len(expected_packet, packet, packet_size); output = gcut_string_io_channel_get_string(output_channel); cut_assert_equal_memory(expected_packet->str, expected_packet->len, output->str, output->len); }
static void *output_thread(void *_t) { atransport *t = reinterpret_cast<atransport*>(_t); apacket *p; ADB_LOGD(ADB_TSPT, "%s: starting transport output thread on fd %d, SYNC online (%d)", t->serial, t->fd, t->sync_token + 1); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 1; p->msg.arg1 = ++(t->sync_token); p->msg.magic = A_SYNC ^ 0xffffffff; if (write_packet(t->fd, t->serial, &p)) { put_apacket(p); ADB_LOGE(ADB_TSPT, "%s: failed to write SYNC packet", t->serial); goto oops; } ADB_LOGD(ADB_TSPT, "%s: data pump started", t->serial); for (;;) { p = get_apacket(); if (t->read_from_remote(p, t) == 0) { ADB_LOGD(ADB_TSPT, "%s: received remote packet, sending to transport", t->serial); if (write_packet(t->fd, t->serial, &p)) { put_apacket(p); ADB_LOGE(ADB_TSPT, "%s: failed to write apacket to transport", t->serial); goto oops; } } else { ADB_LOGE(ADB_TSPT, "%s: remote read failed for transport", t->serial); put_apacket(p); break; } } ADB_LOGD(ADB_TSPT, "%s: SYNC offline for transport", t->serial); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 0; p->msg.arg1 = 0; p->msg.magic = A_SYNC ^ 0xffffffff; if (write_packet(t->fd, t->serial, &p)) { put_apacket(p); ADB_LOGW(ADB_TSPT, "%s: failed to write SYNC apacket to transport", t->serial); } oops: ADB_LOGD(ADB_TSPT, "%s: transport output thread is exiting", t->serial); kick_transport(t); transport_unref(t); return 0; }
// The transport is opened by transport_register_func before // the read_transport and write_transport threads are started. // // The read_transport thread issues a SYNC(1, token) message to let // the write_transport thread know to start things up. In the event // of transport IO failure, the read_transport thread will post a // SYNC(0,0) message to ensure shutdown. // // The transport will not actually be closed until both threads exit, but the threads // will kick the transport on their way out to disconnect the underlying device. // // read_transport thread reads data from a transport (representing a usb/tcp connection), // and makes the main thread call handle_packet(). static void *read_transport_thread(void *_t) { atransport *t = reinterpret_cast<atransport*>(_t); apacket *p; adb_thread_setname(android::base::StringPrintf("<-%s", (t->serial != nullptr ? t->serial : "transport"))); D("%s: starting read_transport thread on fd %d, SYNC online (%d)", t->serial, t->fd, t->sync_token + 1); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 1; p->msg.arg1 = ++(t->sync_token); p->msg.magic = A_SYNC ^ 0xffffffff; if(write_packet(t->fd, t->serial, &p)) { put_apacket(p); D("%s: failed to write SYNC packet", t->serial); goto oops; } D("%s: data pump started", t->serial); for(;;) { p = get_apacket(); if(t->read_from_remote(p, t) == 0){ D("%s: received remote packet, sending to transport", t->serial); if(write_packet(t->fd, t->serial, &p)){ put_apacket(p); D("%s: failed to write apacket to transport", t->serial); goto oops; } } else { D("%s: remote read failed for transport", t->serial); put_apacket(p); break; } } D("%s: SYNC offline for transport", t->serial); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 0; p->msg.arg1 = 0; p->msg.magic = A_SYNC ^ 0xffffffff; if(write_packet(t->fd, t->serial, &p)) { put_apacket(p); D("%s: failed to write SYNC apacket to transport", t->serial); } oops: D("%s: read_transport thread is exiting", t->serial); kick_transport(t); transport_unref(t); return 0; }
static void *output_thread(void *_t) { atransport *t = _t; apacket *p; D("from_remote: starting thread for transport %p, on fd %d\n", t, t->fd ); D("from_remote: transport %p SYNC online (%d)\n", t, t->sync_token + 1); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 1; p->msg.arg1 = ++(t->sync_token); p->msg.magic = A_SYNC ^ 0xffffffff; if(write_packet(t->fd, &p)) { put_apacket(p); D("from_remote: failed to write SYNC apacket to transport %p", t); goto oops; } D("from_remote: data pump for transport %p\n", t); for(;;) { p = get_apacket(); if(t->read_from_remote(p, t) == 0){ D("from_remote: received remote packet, sending to transport %p\n", t); if(write_packet(t->fd, &p)){ put_apacket(p); D("from_remote: failed to write apacket to transport %p", t); goto oops; } } else { D("from_remote: remote read failed for transport %p\n", p); put_apacket(p); break; } } D("from_remote: SYNC offline for transport %p\n", t); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 0; p->msg.arg1 = 0; p->msg.magic = A_SYNC ^ 0xffffffff; if(write_packet(t->fd, &p)) { put_apacket(p); D("from_remote: failed to write SYNC apacket to transport %p", t); } oops: D("from_remote: thread is exiting for transport %p\n", t); kick_transport(t); transport_unref(t); return 0; }
static void send_stop_reply_packet(struct dbg_context* dbg, dbg_threadid_t thread, int sig) { if (sig >= 0) { char buf[64]; snprintf(buf, sizeof(buf) - 1, "T%02xthread:%02x;", sig, thread); write_packet(dbg, buf); } else { write_packet(dbg, "E01"); } }
static int process_vpacket(struct dbg_context* dbg, char* payload) { const char* name; char* args; args = strchr(payload, ';'); if (args) { *args++ = '\0'; } name = payload; if (!strcmp("Cont", name)) { char cmd = *args++; if ('\0' != args[1]) { *args++ = '\0'; } switch (cmd) { case 'c': dbg->req.type = DREQ_CONTINUE; dbg->req.target = dbg->resume_thread; return 1; case 's': dbg->req.type = DREQ_STEP; if (args) { dbg->req.target = parse_threadid(args, &args); assert('\0' == *args || !strcmp(args, ";c")); } else { dbg->req.target = dbg->resume_thread; } return 1; default: log_warn("Unhandled vCont command %c(%s)", cmd, args); write_packet(dbg, ""); return 0; } } if (!strcmp("Cont?", name)) { debug("gdb queries which continue commands we support"); write_packet(dbg, "vCont;c;C;s;S;t;"); return 0; } log_warn("Unhandled gdb vpacket: v%s", name); write_packet(dbg, ""); return 0; }
/* The transport is opened by transport_register_func before ** the input and output threads are started. ** ** The output thread issues a SYNC(1, token) message to let ** the input thread know to start things up. In the event ** of transport IO failure, the output thread will post a ** SYNC(0,0) message to ensure shutdown. ** ** The transport will not actually be closed until both ** threads exit, but the input thread will kick the transport ** on its way out to disconnect the underlying device. */ void *output_thread(void *_t, struct dll_io_bridge * _io_bridge) { o_bridge = _io_bridge; atransport *t = (atransport *)_t; apacket *p; D("%s: starting transport output thread on fd %d, SYNC online (%d)\n", t->serial, t->fd, t->sync_token + 1); p = get_apacket(); p->msg.command = A_SYNC; p->msg.arg0 = 1; p->msg.arg1 = ++(t->sync_token); p->msg.magic = A_SYNC ^ 0xffffffff; if(write_packet(t->fd, t->serial, &p)) { put_apacket(p); D("%s: failed to write SYNC packet\n", t->serial); goto oops; } D("%s: data pump started\n", t->serial); for(;;) { p = get_apacket(); if(t->read_from_remote(p, t) == 0){ D("%s: received remote packet, sending to transport\n", t->serial); if(write_packet(t->fd, t->serial, &p)){ put_apacket(p); D("%s: failed to write apacket to transport\n", t->serial); goto oops; } } else { D("%s: remote read failed for transport\n", t->serial); put_apacket(p); break; } } handle_output_offline(t); oops: #ifdef WIN32 handle_output_oops(t, o_bridge->AdbCloseHandle); #else handle_output_oops(t, NULL); #endif return NULL; }
void test_launch_error (gconstpointer data) { const gchar *packet; gsize packet_size; GString *output; const gchar *command; const gchar *user_name; const gchar *expected_error_message; command = gcut_data_get_string(data, "command"); user_name = gcut_data_get_string(data, "user-name"); expected_error_message = gcut_data_get_string(data, "expected-error-message"); milter_manager_launch_command_encoder_encode_launch(command_encoder, &packet, &packet_size, command, user_name); cut_trace(write_packet(packet, packet_size)); pump_all_events(); milter_manager_reply_encoder_encode_error(reply_encoder, &packet, &packet_size, expected_error_message); output = gcut_string_io_channel_get_string(output_channel); cut_assert_equal_memory(packet, packet_size, output->str, output->len); }
static void write_hex_packet(struct dbg_context* dbg, unsigned long hex) { char buf[32]; snprintf(buf, sizeof(buf) - 1, "%02lx", hex); write_packet(dbg, buf); }
static int16 ether_do_write(uint32 arg) { D(bug("ether_write\n")); // Copy packet to buffer uint8 packet[1514], *p = packet; int len = ether_arg_to_buffer(arg, p); if(len > 1514) { D(bug("illegal packet length: %d\n",len)); return eLenErr; } else { #if MONITOR bug("Sending Ethernet packet (%d bytes):\n",(int)len); dump_packet( packet, len ); #endif } // Transmit packet if (!write_packet(packet, len)) { D(bug("WARNING: couldn't transmit packet\n")); return excessCollsns; } else { // It's up to the protocol drivers to do the error checking. Even if the // i/o completion routine returns ok, there can be errors, so there is // no point to wait for write completion and try to make some sense of the // possible error codes. return noErr; } }
/* return 0 if data could not be put in packet queue. * return 1 if data was put into the queue. */ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length) { if (crypt_connection_id_not_valid(c, crypt_connection_id)) return 0; if (length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES > MAX_DATA_SIZE - 1) return 0; if (c->crypto_connections[crypt_connection_id].status != CRYPTO_CONN_ESTABLISHED) return 0; uint8_t temp_data[MAX_DATA_SIZE]; int len = encrypt_data_fast(c->crypto_connections[crypt_connection_id].shared_key, c->crypto_connections[crypt_connection_id].sent_nonce, data, length, temp_data + 1); if (len == -1) return 0; temp_data[0] = 3; if (write_packet(c->lossless_udp, c->crypto_connections[crypt_connection_id].number, temp_data, len + 1) == 0) return 0; increment_nonce(c->crypto_connections[crypt_connection_id].sent_nonce); return 1; }
/* return 0 if data could not be put in packet queue return 1 if data was put into the queue */ int write_cryptpacket(int crypt_connection_id, uint8_t * data, uint32_t length) { if(crypt_connection_id < 0 || crypt_connection_id >= MAX_CRYPTO_CONNECTIONS) { return 0; } if(length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES > MAX_DATA_SIZE - 1) { return 0; } if(crypto_connections[crypt_connection_id].status != 3) { return 0; } uint8_t temp_data[MAX_DATA_SIZE]; int len = encrypt_data(crypto_connections[crypt_connection_id].peersessionpublic_key, crypto_connections[crypt_connection_id].sessionsecret_key, crypto_connections[crypt_connection_id].sent_nonce, data, length, temp_data + 1); if(len == -1) { return 0; } temp_data[0] = 3; if(write_packet(crypto_connections[crypt_connection_id].number, temp_data, len + 1) == 0) { return 0; } increment_nonce(crypto_connections[crypt_connection_id].sent_nonce); return 1; }
static int net_stream_open(client_t* cl,char* url) { int file_format=DEMUXER_TYPE_UNKNOWN; mp_net_stream_opened_t ret; if(cl->stream) { if(!write_error(cl->fd,"A stream is currently opened\n")) return 0; return 1; } mp_msg(MSGT_NETST,MSGL_V,"Open stream %s\n",url); cl->stream = open_stream(url,NULL,&file_format); if(!cl->stream) { if(!write_error(cl->fd,"Open failed\n")) return 0; return 1; } stream_reset(cl->stream); stream_seek(cl->stream,cl->stream->start_pos); ret.file_format = file_format; ret.flags = cl->stream->flags; ret.sector_size = cl->stream->sector_size; ret.start_pos = cl->stream->start_pos; ret.end_pos = cl->stream->end_pos; net_stream_opened_2_me(&ret); if(!write_packet(cl->fd,NET_STREAM_OK,(char*)&ret,sizeof(mp_net_stream_opened_t))) return 0; return 1; }
/* * buffer_packet() * * Add the FLV packet "packet" to an internal statically-held array of FLVpacket * structs. Duplicate the data payload and update the data pointer in the packet * to point to the duplicated data. * If "flush" is non-zero, write out all the packets in the buffer using * write_packet() in order received, free all the memory used for the * payloads and reset the packet buffer count to 0. * "file_start_timestamp" should contain the timestamp for the start of the * current file, and is passed to write_packet() when flushing the buffer. */ static void buffer_packet(struct FLVpacket *packet, long file_start_timestamp, char flush) { static struct FLVpacket *pktarray = NULL; static int packets = 0, max_packets = 0; if( packets >= max_packets ) { max_packets += 5; pktarray = realloc( pktarray, max_packets * sizeof(struct FLVpacket) ); } pktarray[packets] = *packet; pktarray[packets].data = malloc(packet->datasize); memcpy(pktarray[packets].data, packet->data, packet->datasize); packets++; if(flush) /* Flush the buffer and free all data */ { /* Don't free the FLVpacket array as we may use it again */ int i; for( i = 0; i < packets; i++ ) { write_packet( &pktarray[i], file_start_timestamp ); free(pktarray[i].data); } packets = 0; } return; }
int av_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret; ret = check_packet(s, pkt); if (ret < 0) return ret; if (!pkt) { if (s->oformat->flags & AVFMT_ALLOW_FLUSH) return s->oformat->write_packet(s, pkt); return 1; } ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt); if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) return ret; ret = write_packet(s, pkt); if (ret >= 0) s->streams[pkt->stream_index]->nb_frames++; return ret; }
int av_write_frame(AVFormatContext *s, AVPacket *pkt) { int ret; ret = prepare_input_packet(s, pkt); if (ret < 0) return ret; if (!pkt) { if (s->oformat->flags & AVFMT_ALLOW_FLUSH) return s->oformat->write_packet(s, pkt); return 1; } #if FF_API_COMPUTE_PKT_FIELDS2 ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt); if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) return ret; #endif ret = write_packet(s, pkt); if (ret >= 0) s->streams[pkt->stream_index]->nb_frames++; return ret; }
void send_packet(apacket *p, atransport *t) { unsigned char *x; unsigned sum; unsigned count; p->msg.magic = p->msg.command ^ 0xffffffff; count = p->msg.data_length; x = (unsigned char *) p->data; sum = 0; while(count-- > 0){ sum += *x++; } p->msg.data_check = sum; print_packet("send", p); if (t == NULL) { D("Transport is null \n"); // Zap errno because print_packet() and other stuff have errno effect. errno = 0; fatal_errno("Transport is null"); } if(write_packet(t->transport_socket, t->serial, &p)){ fatal_errno("cannot enqueue packet on transport socket"); } }
static mp_net_stream_packet_t* send_net_stream_cmd(stream_t *s,uint16_t cmd,char* data,int len) { mp_net_stream_packet_t* pack; // Cache is enabled : lock if(s->cache_data && !lock_fd(s->fd)) return NULL; // Send a command if(!write_packet(s->fd,cmd,data,len)) { if(s->cache_data) unlock_fd(s->fd); return 0; } // Read the response pack = read_packet(s->fd); // Now we can unlock if(s->cache_data) unlock_fd(s->fd); if(!pack) return NULL; switch(pack->cmd) { case NET_STREAM_OK: return pack; case NET_STREAM_ERROR: if(pack->len > sizeof(mp_net_stream_packet_t)) mp_msg(MSGT_STREAM,MSGL_ERR, "Fill buffer failed: %s\n",pack->data); else mp_msg(MSGT_STREAM,MSGL_ERR, "Fill buffer failed\n"); free(pack); return NULL; } mp_msg(MSGT_STREAM,MSGL_ERR, "Unknown response to %d: %d\n",cmd,pack->cmd); free(pack); return NULL; }
int main() { airhook_init(&socket,time(NULL)); for (;;) { char line[1024],*command; fprintf(stderr,"] "); if (NULL == fgets(line,sizeof(line),stdin)) break; command = strtok(line," \n"); if (NULL == command || !strcmp(command,"")) ; else if (!strcmp(command,"r")) read_packet(); else if (!strcmp(command,"w")) write_packet(); else if (!strcmp(command,"p")) dump_packet(); else if (!strcmp(command,"m")) send_message(); else if (!strcmp(command,"s")) print_status(); else if (!strcmp(command,"d")) discard_message(); else { fprintf(stderr,"invalid command: %s\n" "commands: r filename -- read packet\n" " w filename length -- write packet\n" " p filename -- print packet\n" " m message -- send message\n" " s -- get status\n" " s num -- get message status\n" " d num -- discard message\n", command); } } return 0; }
static int write_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req) { int bytes = 0, count, completed = 0; while (!completed) { count = write_packet(imx_ep, req); if (count < 0) break; /* */ bytes += count; /* */ completed = (count != imx_ep->fifosize); if (unlikely(completed)) { done(imx_ep, req, 0); D_REQ(imx_ep->imx_usb->dev, "<%s> %s req<%p> %s\n", __func__, imx_ep->ep.name, req, completed ? "completed" : "not completed"); if (!EP_NO(imx_ep)) ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE); } } D_TRX(imx_ep->imx_usb->dev, "<%s> bytes sent: %d\n", __func__, bytes); return completed; }
void tm_link_rep::secure_server (string client_public) { if (secret != "") return; string k= secret_generate (); string s= rsa_encode (k, client_public); write_packet (s, LINK_IN); secret= k; }
void dbg_reply_get_is_thread_alive(struct dbg_context* dbg, int alive) { assert(DREQ_GET_IS_THREAD_ALIVE == dbg->req.type); write_packet(dbg, alive ? "OK" : "E01"); consume_request(dbg); }
// return: 0 = still running, 1 = completed, negative = errno static int write_fifo(struct goku_ep *ep, struct goku_request *req) { struct goku_udc *dev = ep->dev; u32 tmp; u8 *buf; unsigned count; int is_last; tmp = readl(&dev->regs->DataSet); buf = req->req.buf + req->req.actual; prefetch(buf); dev = ep->dev; if (unlikely(ep->num == 0 && dev->ep0state != EP0_IN)) return -EL2HLT; /* NOTE: just single-buffered PIO-IN for now. */ if (unlikely((tmp & DATASET_A(ep->num)) != 0)) return 0; /* clear our "packet available" irq */ if (ep->num != 0) writel(~INT_EPxDATASET(ep->num), &dev->regs->int_status); count = write_packet(ep->reg_fifo, buf, req, ep->ep.maxpacket); /* last packet often short (sometimes a zlp, especially on ep0) */ if (unlikely(count != ep->ep.maxpacket)) { writel(~(1<<ep->num), &dev->regs->EOP); if (ep->num == 0) { dev->ep[0].stopped = 1; dev->ep0state = EP0_STATUS; } is_last = 1; } else { if (likely(req->req.length != req->req.actual) || req->req.zero) is_last = 0; else is_last = 1; } #if 0 /* printk seemed to trash is_last...*/ //#ifdef USB_TRACE VDBG(dev, "wrote %s %u bytes%s IN %u left %p\n", ep->ep.name, count, is_last ? "/last" : "", req->req.length - req->req.actual, req); #endif /* requests complete when all IN data is in the FIFO, * or sometimes later, if a zlp was needed. */ if (is_last) { done(ep, req, 0); return 1; } return 0; }
void dbg_reply_get_offsets(struct dbg_context* dbg/*, TODO */) { assert(DREQ_GET_OFFSETS == dbg->req.type); /* XXX FIXME TODO */ write_packet(dbg, ""); consume_request(dbg); }
static void send_outgoing_packets(THREAD_DATA *td) { THREAD_DATA::net_t *n = td->net; ticks_ms_t ticks = get_ticks_ms(); /* write any outgoing packets */ if (ticks - n->ticks->last_deferred_flush > DEFERRED_PACKET_SEND_INTERVAL) { /* * if its time to flush deferred packets, grab one and place it into the SP_NORMAL queue * so it gets sent out immediately */ /* TODO: This should be rate limited based on packet size, not interval */ size_t ndeferred = 0; while (!n->queues->d_prio->empty() && ndeferred++ < 3) { // send 3 packets per interval PACKET *p = *n->queues->d_prio->begin(); n->queues->d_prio->erase(n->queues->d_prio->begin()); queue_packet_reliable(p, SP_NORMAL); } n->ticks->last_deferred_flush = ticks; } /* packet size + space for unencrypted type id */ /* TODO: fix MAX_PACKET vs constants */ uint8_t pkt[MAX_PACKET]; int pkt_count; do { pkt_count = 0; pkt_count += n->queues->h_prio->size(); pkt_count += n->queues->n_prio->size(); if (pkt_count > 0) { bool cluster = pkt_count >= 2; int pktl = 0; if (cluster) { build_packet(pkt, "AA", 0x00, 0x0e); pktl += 2; } /* pull packets from all the various queues */ pktl += pull_packets(n->queues->h_prio, &pkt[pktl], MAX_PACKET - pktl, cluster); pktl += pull_packets(n->queues->n_prio, &pkt[pktl], MAX_PACKET - pktl, cluster); write_packet(td, pkt, pktl); } } while (pkt_count > 0); }
int driver_output (ErlDrvPort port, char* buf, int len) { (void) port; return write_packet (4, 4, buf, len); }
static void flv_output_data(void *data, struct encoder_packet *packet) { struct flv_output *stream = data; struct encoder_packet parsed_packet; if (!stream->sent_headers) { write_headers(stream); stream->sent_headers = true; } if (packet->type == OBS_ENCODER_VIDEO) { obs_parse_avc_packet(&parsed_packet, packet); write_packet(stream, &parsed_packet, false); obs_free_encoder_packet(&parsed_packet); } else { write_packet(stream, packet, false); } }
void dbg_reply_watchpoint_request(struct dbg_context* dbg, int code) { assert(DREQ_WATCH_FIRST <= dbg->req.type && dbg->req.type <= DREQ_WATCH_LAST); write_packet(dbg, code ? "" : "OK"); consume_request(dbg); }
void tm_link_rep::secure_client () { if (secret != "") return; write ("!", LINK_IN); write_packet (rsa_my_public_key (), LINK_IN); bool success; string r= read_packet (LINK_OUT, 10000, success); if (!success) { stop (); return; } secret= rsa_decode (r, rsa_my_private_key ()); }