/* returns error */ int APP_CC read_preamble_packet(struct xrdp_process* self) { // Using the session stream int ns_len = 0; int idx; int len; // cache a pointer to client_info struct xrdp_client_info *client_info = self->session->client_info; struct stream* s; make_stream(s); init_stream(s, 10000); DEBUG(("in read_preamble_packet")); // 5 bytes should include the colon if (trans_force_read_s(self->server_trans, s, 5) == 0) { idx = g_pos(s->data, ":") + 1; // skip colon ns_len = g_atoi(s->data); DEBUG(("Preamble length %i", ns_len)); len = ns_len - 5 + idx + 1; // trailing comma as well DEBUG(("Preamble to read %i", len)); if (trans_force_read_s(self->server_trans, s, len) == 0) { DEBUG(("Preamble body %s", s->data)); // this will be used as a processing buffer when data required // so do not assume will exist in this state later on. client_info->osirium_preamble_buffer = (char*)g_malloc(ns_len+1, 1); in_uint8s(s, idx); // skip netstring header in_uint8a(s, client_info->osirium_preamble_buffer, ns_len); DEBUG(("Preamble %s", client_info->osirium_preamble_buffer)); free_stream(s); return 0; } } free_stream(s); DEBUG(("out read_preamble_packet")); return 0; }
/* returns error */ int APP_CC xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len) { DEBUG((" in xrdp_tcp_recv, gota get %d bytes", len)); init_stream(s, len); if (trans_force_read_s(self->trans, s, len) != 0) { DEBUG((" error in trans_force_read_s")); return 1; } DEBUG((" out xrdp_tcp_recv")); return 0; }
int APP_CC trans_force_read(struct trans *self, int size) { return trans_force_read_s(self, self->in_s, size); }