Example #1
0
void
svz_tunnel_free (struct tclient * tclient)
{
  if (tclient->ibuf)
    stream_free(tclient->ibuf);
  if (tclient->obuf)
    stream_free(tclient->obuf);
  if (tclient->wb)
    buffer_free(tclient->wb);

  XFREE(MTYPE_ZCLIENT, tclient);
}
Example #2
0
/* This function is only called when exiting, because
   many parts of the code do not check for I/O errors, so they could
   reference an invalid pointer if the structure was ever freed.

   Free zclient structure. */
void
zclient_free (struct zclient *zclient)
{
  if (zclient->ibuf)
    stream_free(zclient->ibuf);
  if (zclient->obuf)
    stream_free(zclient->obuf);
  if (zclient->wb)
    buffer_free(zclient->wb);

  XFREE (MTYPE_ZCLIENT, zclient);
}
static int mcp_ppp_all_config_syn_parse_update(struct stream *data_s)
{
	int type;
	int len;
	struct stream* tmp_s;

    tmp_s = stream_new(10240);
	while(STREAM_READABLE(data_s) >= 4)
	{
		type = stream_getw(data_s);
		len = stream_getw(data_s);
		//zlog_debug("<%s,%d> type:%d len:%d", __FUNCTION__, __LINE__, type, len);

        if(len == 0)
            continue;
            
		switch(type)
		{
		    case MCP_PPPD_CONFIG_SYN_REMOT_USERINFO: 
				stream_put(tmp_s, data_s->data + stream_get_getp(data_s), len);
				mcp_recv_pppd_remote_userinfo_ack(tmp_s);
				stream_forward_getp(data_s, len);
				stream_reset(tmp_s);
				break;
				
			case MCP_PPPD_CONFIG_SYN_MULTILINK_INFO: 
				stream_put(tmp_s, data_s->data + stream_get_getp(data_s), len);
				mcp_recv_pppd_multilink_info_ack(tmp_s);
				stream_forward_getp(data_s, len);
				stream_reset(tmp_s);
				break;

			case MCP_PPPD_CONFIG_SYN_INTERFACE_INFO: 
			    stream_put(tmp_s, data_s->data + stream_get_getp(data_s), len);
			    mcp_recv_pppd_interface_info_ack(tmp_s, 1);
				stream_forward_getp(data_s, len);
				stream_reset(tmp_s);
				break;
			    
			default:
				zlog_err("mcp<%s:%d> wrong type:%u",__FUNCTION__,__LINE__,type);
				goto error;
		}		
	}

    stream_free(tmp_s);
	return 0;

error:
    stream_free(tmp_s);
	return -1;	
}
Example #4
0
void transport_free(rdpTransport* transport)
{
    if (transport != NULL)
    {
        stream_free(transport->recv_buffer);
        stream_free(transport->recv_stream);
        stream_free(transport->send_stream);
        if (transport->tls)
            tls_free(transport->tls);
        tcp_free(transport->tcp);
        xfree(transport);
    }
}
Example #5
0
/* start a new process */
extern process *
noshell_proc_start(char **av, stream *inp, stream *outp, stream *errp, int newpg, char *who)
{
	process *pp;
	int i, n;

	if ((pp = (process *)malloc(sizeof(process))) == 0) {
		if (inp != 0)
			stream_free(inp);
		if (outp != 0)
			stream_free(outp);
		if (errp != 0)
			stream_free(errp);
		return 0;
	}
	pp->std[0] = inp;
	pp->std[1] = outp;
	pp->std[2] = errp;
	switch (pp->pid = fork()) {
	case -1:
		proc_free(pp);
		return 0;
	case 0:
		if(newpg)
			sysdetach();
		for (i=0; i<3; i++)
			if (pp->std[i] != 0){
				close(Bfildes(pp->std[i]->fp));
				while(pp->std[i]->fd < 3)
					pp->std[i]->fd = dup(pp->std[i]->fd, -1);
			}
		for (i=0; i<3; i++)
			if (pp->std[i] != 0)
				dup(pp->std[i]->fd, i);
		for (n = sysfiles(); i < n; i++)
			close(i);
		if(who)
			become(av, who);
		exec(av[0], av);
		perror("proc_start");
		exits("proc_start");
	default:
		for (i=0; i<3; i++)
			if (pp->std[i] != 0) {
				close(pp->std[i]->fd);
				pp->std[i]->fd = -1;
			}
		return pp;
	}
}
Example #6
0
boolean WTSVirtualChannelClose(
	/* __in */ void* hChannelHandle)
{
	STREAM* s;
	wts_data_item* item;
	WTSVirtualChannelManager* vcm;
	rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle;

	if (channel)
	{
		vcm = channel->vcm;

		if (channel->channel_type == RDP_PEER_CHANNEL_TYPE_SVC)
		{
			if (channel->index < channel->client->settings->num_channels)
				channel->client->settings->channels[channel->index].handle = NULL;
		}
		else
		{
			WaitForSingleObject(vcm->mutex, INFINITE);
			list_remove(vcm->dvc_channel_list, channel);
			ReleaseMutex(vcm->mutex);

			if (channel->dvc_open_state == DVC_OPEN_STATE_SUCCEEDED)
			{
				s = stream_new(8);
				wts_write_drdynvc_header(s, CLOSE_REQUEST_PDU, channel->channel_id);
				WTSVirtualChannelWrite(vcm->drdynvc_channel, stream_get_head(s), stream_get_length(s), NULL);
				stream_free(s);
			}
		}
		if (channel->receive_data)
			stream_free(channel->receive_data);
		if (channel->receive_event)
			wait_obj_free(channel->receive_event);
		if (channel->receive_queue)
		{
			while ((item = (wts_data_item*) list_dequeue(channel->receive_queue)) != NULL)
			{
				wts_data_item_free(item);
			}
			list_free(channel->receive_queue);
		}
		if (channel->mutex)
			CloseHandle(channel->mutex);
		xfree(channel);
	}
	return true;
}
Example #7
0
boolean rpc_ntlm_http_in_connect(rdpRpc* rpc)
{
	STREAM* s;
	int ntlm_token_length;
	uint8* ntlm_token_data;
	HttpResponse* http_response;
	rdpNtlm* ntlm = rpc->ntlm_http_in->ntlm;

	ntlm_client_init(ntlm, true, rpc->settings->username,
			rpc->settings->domain, rpc->settings->password);

	ntlm_authenticate(ntlm);

	s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer, 0, TSG_CHANNEL_IN);

	/* Send IN Channel Request */

	DEBUG_RPC("\n%s", s->data);
	tls_write_all(rpc->tls_in, s->data, s->size);
	stream_free(s);

	/* Receive IN Channel Response */

	http_response = http_response_recv(rpc->tls_in);

	ntlm_token_data = NULL;
	crypto_base64_decode((uint8*) http_response->AuthParam, strlen(http_response->AuthParam),
			&ntlm_token_data, &ntlm_token_length);

	ntlm->inputBuffer.pvBuffer = ntlm_token_data;
	ntlm->inputBuffer.cbBuffer = ntlm_token_length;

	ntlm_authenticate(ntlm);

	http_response_free(http_response);

	s = rpc_ntlm_http_request(rpc, &ntlm->outputBuffer, 0x40000000, TSG_CHANNEL_IN);

	/* Send IN Channel Request */

	DEBUG_RPC("\n%s", s->data);
	tls_write_all(rpc->tls_in, s->data, s->size);
	stream_free(s);

	ntlm_client_uninit(ntlm);
	ntlm_free(ntlm);

	return true;
}
Example #8
0
void test_nsc_encode(void)
{
	int i;
	uint8* rgb_data;
	STREAM* enc_stream;
	NSC_CONTEXT* context;

	rgb_data = (uint8 *) malloc(64 * 64 * 3);
	for (i = 0; i < 64; i++)
		memcpy(rgb_data + i * 64 * 3, rgb_scanline_data, 64 * 3);

	context = nsc_context_new();
	nsc_context_set_cpu_opt(context, CPU_SSE2);
	nsc_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);

	enc_stream = stream_new(65536);
	stream_clear(enc_stream);

	for (i = 0; i < 30000; i++)
	{
		stream_set_pos(enc_stream, 0);
		nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3);
	}
	/*freerdp_hexdump(stream_get_head(enc_stream), stream_get_length(enc_stream));*/
	nsc_process_message(context, 32, 64, 64, stream_get_head(enc_stream), stream_get_length(enc_stream));
	/*freerdp_hexdump(context->bmpdata, 64 * 64 * 4);*/
	stream_free(enc_stream);

	nsc_context_free(context);
}
Example #9
0
static void svc_plugin_open_event(uint32 openHandle, uint32 event, void* pData, uint32 dataLength,
	uint32 totalLength, uint32 dataFlags)
{
	rdpSvcPlugin* plugin;

	DEBUG_SVC("openHandle %d event %d dataLength %d totalLength %d dataFlags %d",
		openHandle, event, dataLength, totalLength, dataFlags);

	plugin = (rdpSvcPlugin*)svc_plugin_find_by_open_handle(openHandle);
	if (plugin == NULL)
	{
		printf("svc_plugin_open_event: error no match\n");
		return;
	}
	switch (event)
	{
		case CHANNEL_EVENT_DATA_RECEIVED:
			svc_plugin_process_received(plugin, pData, dataLength, totalLength, dataFlags);
			break;
		case CHANNEL_EVENT_WRITE_COMPLETE:
			stream_free((STREAM*)pData);
			break;
		case CHANNEL_EVENT_USER:
			svc_plugin_process_event(plugin, (RDP_EVENT*)pData);
			break;
	}
}
Example #10
0
KrbAPREQ* krb_apreq_new(KRB_CONTEXT* krb_ctx, Ticket* ticket, Authenticator* krb_auth)
{
	KrbAPREQ* krb_apreq;
	STREAM* as;
	rdpBlob msg;
	rdpBlob* encmsg;
	uint32 len;

	as = stream_new(1024);
	stream_seek(as, 1023);

	krb_apreq = xnew(KrbAPREQ);
	krb_apreq->pvno = KRB_VERSION;
	krb_apreq->type = KRB_TAG_APREQ;
	krb_apreq->ap_options = 0x00000000 | 0x00000000 | 0x00000000; /* Reserved (bit 31), Use session Key (bit 30), Mututal Required (bit 29) */
	krb_apreq->ticket = ticket;

	if (krb_auth != NULL)
	{
		len = krb_encode_authenticator(as, krb_auth);
		msg.data = as->p;
		msg.length = len;
		encmsg = crypto_kdcmsg_encrypt(&msg, krb_ctx->askey, 7); /* RFC4757 section 3 for msgtype (T=7) */
		krb_apreq->enc_auth.enctype = krb_ctx->askey->enctype;
		krb_apreq->enc_auth.kvno = -1;
		krb_apreq->enc_auth.encblob.data = encmsg->data;
		krb_apreq->enc_auth.encblob.length =  encmsg->length;
		xfree(encmsg);
	}
	
	stream_free(as);
	
	return krb_apreq;
}
Example #11
0
void test_ber_write_length(void)
{
	STREAM *s1, *s2;

	s1 = stream_new(sizeof(ber_length_expected_1));
	s2 = stream_new(sizeof(ber_length_expected_2));

	ber_write_length(s1, 64);
	ASSERT_STREAM(s1, (uint8*) ber_length_expected_1, sizeof(ber_length_expected_1));

	ber_write_length(s2, 404);
	ASSERT_STREAM(s2, (uint8*) ber_length_expected_2, sizeof(ber_length_expected_2));

	stream_free(s1);
	stream_free(s2);
}
void ppp_remark_mem_free(void)
{
 //   int i = 0;

    ppp_if_mem_free();
    
    if(multilink_if_list != NULL) {
        list_delete(multilink_if_list);
        multilink_if_list = NULL;
    }

    if(remote_userinfo_list != NULL) {
        list_delete(remote_userinfo_list);
        remote_userinfo_list = NULL;
    }

    if(g_ppp_mcp_sock->ibuf != NULL)
        stream_free(g_ppp_mcp_sock->ibuf);

    if(g_ppp_mcp_sock->obuf != NULL)
        stream_fifo_free(g_ppp_mcp_sock->obuf);

    if(g_ppp_mcp_sock->fd > 0)
        close(g_ppp_mcp_sock->fd);
        
    if(g_ppp_mcp_sock != NULL)
        free(g_ppp_mcp_sock);
        
    return;
}
Example #13
0
void test_peer_context_free(freerdp_peer* client, testPeerContext* context)
{
	if (context)
	{
		if (context->debug_channel_thread)
		{
			freerdp_thread_stop(context->debug_channel_thread);
			freerdp_thread_free(context->debug_channel_thread);
		}

		stream_free(context->s);
		free(context->icon_data);
		free(context->bg_data);

		rfx_context_free(context->rfx_context);
		nsc_context_free(context->nsc_context);

		if (context->debug_channel)
			WTSVirtualChannelClose(context->debug_channel);

		if (context->audin)
			audin_server_context_free(context->audin);

		if (context->rdpsnd)
			rdpsnd_server_context_free(context->rdpsnd);

		WTSDestroyVirtualChannelManager(context->vcm);
	}
}
Example #14
0
void credssp_read_ts_credentials(rdpCredssp* credssp, PSecBuffer ts_credentials)
{
    wStream* s;
    int length;
    int ts_password_creds_length;

    s = stream_new(0);
    stream_attach(s, ts_credentials->pvBuffer, ts_credentials->cbBuffer);

    /* TSCredentials (SEQUENCE) */
    ber_read_sequence_tag(s, &length);

    /* [0] credType (INTEGER) */
    ber_read_contextual_tag(s, 0, &length, TRUE);
    ber_read_integer(s, NULL);

    /* [1] credentials (OCTET STRING) */
    ber_read_contextual_tag(s, 1, &length, TRUE);
    ber_read_octet_string_tag(s, &ts_password_creds_length);

    credssp_read_ts_password_creds(credssp, s);

    stream_detach(s);
    stream_free(s);
}
Example #15
0
BOOL rts_send_ping_pdu(rdpRpc* rpc)
{
	STREAM* s;
	RTS_PDU_HEADER header;

	header.rpc_vers = 5;
	header.rpc_vers_minor = 0;
	header.ptype = PTYPE_RTS;
	header.pfc_flags = PFC_FIRST_FRAG | PFC_LAST_FRAG;
	header.packed_drep[0] = 0x10;
	header.packed_drep[1] = 0x00;
	header.packed_drep[2] = 0x00;
	header.packed_drep[3] = 0x00;
	header.frag_length = 20;
	header.auth_length = 0;
	header.call_id = 0;
	header.flags = 1;
	header.numberOfCommands = 0;

	DEBUG_RPC("Sending Ping RTS PDU");

	s = stream_new(header.frag_length);
	rts_pdu_header_write(s, &header); /* RTS Header (20 bytes) */
	stream_seal(s);

	rpc_in_write(rpc, s->data, s->size);

	stream_free(s);

	return TRUE;
}
Example #16
0
static void svc_plugin_open_event(UINT32 openHandle, UINT32 event, void* pData, UINT32 dataLength,
	UINT32 totalLength, UINT32 dataFlags)
{
	rdpSvcPlugin* plugin;

	DEBUG_SVC("openHandle %d event %d dataLength %d totalLength %d dataFlags %d",
		openHandle, event, dataLength, totalLength, dataFlags);

	plugin = (rdpSvcPlugin*) svc_plugin_find_by_open_handle(openHandle);

	if (!plugin)
	{
		fprintf(stderr, "svc_plugin_open_event: error no match\n");
		return;
	}

	switch (event)
	{
		case CHANNEL_EVENT_DATA_RECEIVED:
			svc_plugin_process_received(plugin, pData, dataLength, totalLength, dataFlags);
			break;

		case CHANNEL_EVENT_WRITE_COMPLETE:
			stream_free((wStream*) pData);
			break;

		case CHANNEL_EVENT_USER:
			svc_plugin_process_event(plugin, (wMessage*) pData);
			break;
	}
}
Example #17
0
/*
 * @file stream.c
 * @brief ICE stream functionality
 */
Stream *
stream_new (guint n_components)
{
  Stream *stream;
  guint n;
  gboolean errors = FALSE;
  GSList *modified_list;
  Component *component;

  stream = g_slice_new0 (Stream);
  for (n = 0; n < n_components; n++) {
    component = component_new (n + 1);
    if (component) {
      modified_list = g_slist_append (stream->components, component);
      if (modified_list)
	stream->components = modified_list;
      else 
	errors = TRUE;
    }
    else
      errors = TRUE;
  }

  if (errors) {
    stream_free (stream);
    return NULL;
  }

  stream->n_components = n_components;
  stream->initial_binding_request_received = FALSE;

  return stream;
}
Example #18
0
int dev_redir_send_drive_close_request(tui16 Component, tui16 PacketId,
                                       tui32 DeviceId,
                                       tui32 FileId,
                                       tui32 CompletionId,
                                       tui32 MajorFunction,
                                       tui32 MinorFunc,
                                       int pad_len)
{
    struct stream *s;
    int            bytes;

    stream_new(s, 1024);

    dev_redir_insert_dev_io_req_header(s, DeviceId, FileId, CompletionId,
                                       MajorFunction, MinorFunc);

    if (pad_len)
        stream_seek(s, pad_len);

    /* send to client */
    bytes = stream_len(s);
    send_channel_data(g_rdpdr_chan_id, s->data, bytes);

    stream_free(s);
    return 0;
}
Example #19
0
/* Called after a peer disconnects */
void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
{
	if (context)
	{
		mf_info_peer_unregister(context->info, context);
		
		dispatch_suspend(info_timer);
		
		stream_free(context->s);
		
		rfx_context_free(context->rfx_context);
		//nsc_context_free(context->nsc_context);
		
#ifdef CHANNEL_AUDIN_SERVER
		if (context->audin)
			audin_server_context_free(context->audin);
#endif
		
		//#ifdef CHANNEL_RDPSND_SERVER
		mf_peer_rdpsnd_stop();
		if (context->rdpsnd)
			rdpsnd_server_context_free(context->rdpsnd);
		//#endif
		
		//#ifdef WITH_SERVER_CHANNELS
		WTSDestroyVirtualChannelManager(context->vcm);
		//#endif
	}
}
Example #20
0
static void sample_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
{
	int bytes;
	STREAM* data_out;
	samplePlugin* sample = (samplePlugin*) plugin;

	printf("sample_process_receive:\n");

	if (!sample)
	{
		printf("sample_process_receive: sample is nil\n");
		return;
	}

	/* process data in (from server) here */
	/* here we just send the same data back */

	bytes = stream_get_size(data_in);
	printf("sample_process_receive: got bytes %d\n", bytes);

	if (bytes > 0)
	{
		data_out = stream_new(bytes);
		stream_copy(data_out, data_in, bytes);
		/* svc_plugin_send takes ownership of data_out, that is why
		   we do not free it */

		bytes = stream_get_length(data_in);
		printf("sample_process_receive: sending bytes %d\n", bytes);

		svc_plugin_send(plugin, data_out);
	}

	stream_free(data_in);
}
Example #21
0
void test_stream(void)
{
	STREAM * stream;
	int pos;
	uint32 n;
	uint64 n64;

	stream = stream_new(1);
	pos = stream_get_pos(stream);

	stream_write_uint8(stream, 0xFE);

	stream_check_size(stream, 14);
	stream_write_uint16(stream, 0x0102);
	stream_write_uint32(stream, 0x03040506);
	stream_write_uint64(stream, 0x0708091011121314LL);

	/* freerdp_hexdump(stream->buffer, 15); */

	stream_set_pos(stream, pos);
	stream_seek(stream, 3);
	stream_read_uint32(stream, n);
	stream_read_uint64(stream, n64);

	CU_ASSERT(n == 0x03040506);
	CU_ASSERT(n64 == 0x0708091011121314LL);

	stream_free(stream);
}
Example #22
0
int
xrdpvr_set_geometry(void *channel, int stream_id, int xpos, int ypos, int width, int height)
{
    STREAM  *s;
    char    *cptr;
    int     rv;
    int     len;

printf("xrdpvr_set_geometry: entered; x=%d y=%d\n", xpos, ypos);

    stream_new(s, MAX_PDU_SIZE);

    stream_ins_u32_le(s, 0); /* number of bytes to follow */
    stream_ins_u32_le(s, CMD_SET_GEOMETRY);
    stream_ins_u32_le(s, stream_id);
    stream_ins_u32_le(s, xpos);
    stream_ins_u32_le(s, ypos);
    stream_ins_u32_le(s, width);
    stream_ins_u32_le(s, height);

    /* insert number of bytes in stream */
    len = stream_length(s) - 4;
    cptr = s->p;
    s->p = s->data;
    stream_ins_u32_le(s, len);
    s->p = cptr;

    /* write data to virtual channel */
    rv = xrdpvr_write_to_client(channel, s);
    stream_free(s);
    return rv;
}
Example #23
0
int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, uint32 ChannelId)
{
	DVCMAN_CHANNEL* channel;
	IWTSVirtualChannel* ichannel;

	channel = dvcman_find_channel_by_id(pChannelMgr, ChannelId);

	if (channel == NULL)
	{
		DEBUG_WARN("ChannelId %d not found!", ChannelId);
		return 1;
	}

	if (channel->dvc_data)
	{
		stream_free(channel->dvc_data);
		channel->dvc_data = NULL;
	}

	DEBUG_DVC("dvcman_close_channel: channel %d closed", ChannelId);
	ichannel = (IWTSVirtualChannel*)channel;
	ichannel->Close(ichannel);

	return 0;
}
Example #24
0
/**
 * set audio format
 *
 * @param  channel    opaque handle returned by WTSVirtualChannelOpenEx
 * @param  stream_id  unique identification number for this stream
 *
 * @return  0 on success, -1 on error
 *****************************************************************************/
int
xrdpvr_set_audio_format(void *channel, uint32_t stream_id)
{
    STREAM  *s;
    char    *cptr;
    int     rv;
    int     len;

    stream_new(s, MAX_PDU_SIZE);

    stream_ins_u32_le(s, 0); /* number of bytes to follow */
    stream_ins_u32_le(s, CMD_SET_AUDIO_FORMAT);
    stream_ins_u32_le(s, stream_id);

    /* insert number of bytes in stream */
    len = stream_length(s) - 4;
    cptr = s->p;
    s->p = s->data;
    stream_ins_u32_le(s, len);
    s->p = cptr;

    /* write data to virtual channel */
    rv = xrdpvr_write_to_client(channel, s);
    stream_free(s);
    return rv;
}
Example #25
0
void test_decode(void)
{
	RFX_CONTEXT* context;
	BYTE decode_buffer[4096 * 3];
	STREAM* s;

	s = stream_new(sizeof(y_data) + sizeof(cb_data) + sizeof(cr_data));
	stream_write(s, y_data, sizeof(y_data));
	stream_write(s, cb_data, sizeof(cb_data));
	stream_write(s, cr_data, sizeof(cr_data));
	stream_set_pos(s, 0);

	context = rfx_context_new();
	context->mode = RLGR3;
	rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);
	rfx_decode_rgb(context, s,
		sizeof(y_data), test_quantization_values,
		sizeof(cb_data), test_quantization_values,
		sizeof(cr_data), test_quantization_values,
		decode_buffer);
	rfx_context_free(context);
	stream_free(s);

	dump_ppm_image(decode_buffer);
}
Example #26
0
/**
 * send video data to client
 *
 * @param  channel    opaque handle returned by WTSVirtualChannelOpenEx
 * @param  stream_id  unique identification number for this stream
 * @param  data_len   number of bytes to send
 * @param  data       video data to send
 *
 * @return  0 on success, -1 on error
 *****************************************************************************/
int
xrdpvr_send_video_data(void *channel, uint32_t stream_id, uint32_t data_len, uint8_t *data)
{
    STREAM  *s;
    char    *cptr;
    int     rv;
    int     len;

    stream_new(s, MAX_PDU_SIZE + data_len);

    stream_ins_u32_le(s, 0); /* number of bytes to follow */
    stream_ins_u32_le(s, CMD_SEND_VIDEO_DATA);
    stream_ins_u32_le(s, stream_id);
    stream_ins_u32_le(s, data_len);
    stream_ins_byte_array(s, data, data_len);

    /* insert number of bytes in stream */
    len = stream_length(s) - 4;
    cptr = s->p;
    s->p = s->data;
    stream_ins_u32_le(s, len);
    s->p = cptr;

    /* write data to virtual channel */
    rv = xrdpvr_write_to_client(channel, s);
    stream_free(s);

#ifdef DEBUG_FRAGMENTS
    printf("### sent %d + 4 bytes video data to client\n", len);
#endif

    return rv;
}
Example #27
0
boolean WTSVirtualChannelClose(
    /* __in */ void* hChannelHandle)
{
    wts_data_item* item;
    rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle;

    if (channel != NULL)
    {
        if (channel->index < channel->client->settings->num_channels)
            channel->client->settings->channels[channel->index].handle = NULL;
        stream_free(channel->receive_data);
        if (channel->receive_event)
            wait_obj_free(channel->receive_event);
        if (channel->receive_queue)
        {
            while ((item = (wts_data_item*) list_dequeue(channel->receive_queue)) != NULL)
            {
                wts_data_item_free(item);
            }
            list_free(channel->receive_queue);
        }
        if (channel->mutex)
            freerdp_mutex_free(channel->mutex);
        xfree(channel);
    }

    return true;
}
Example #28
0
/**
 * send audio data to client
 *
 * @param  channel    opaque handle returned by WTSVirtualChannelOpenEx
 * @param  stream_id  unique identification number for this stream
 * @param  data_len   number of bytes to send
 * @param  data       audio data to send
 *
 * @return  0 on success, -1 on error
 *****************************************************************************/
int
xrdpvr_send_audio_data(void *channel, uint32_t stream_id, uint32_t data_len, uint8_t *data)
{
    STREAM  *s;
    char    *cptr;
    int     rv;
    int     len;

    stream_new(s, MAX_PDU_SIZE + data_len);

    stream_ins_u32_le(s, 0); /* number of bytes to follow */
    stream_ins_u32_le(s, CMD_SEND_AUDIO_DATA);
    stream_ins_u32_le(s, stream_id);
    stream_ins_u32_le(s, data_len);
    stream_ins_byte_array(s, data, data_len);

    /* insert number of bytes in stream */
    len = stream_length(s) - 4;
    cptr = s->p;
    s->p = s->data;
    stream_ins_u32_le(s, len);
    s->p = cptr;

    /* write data to virtual channel */
    rv = xrdpvr_write_to_client(channel, s);
    stream_free(s);
    return rv;
}
Example #29
0
static void svc_plugin_process_terminated(rdpSvcPlugin* plugin)
{
	svc_data_in_item* item;

	freerdp_thread_stop(plugin->priv->thread);
	freerdp_thread_free(plugin->priv->thread);

	plugin->channel_entry_points.pVirtualChannelClose(plugin->priv->open_handle);
	xfree(plugin->channel_entry_points.pExtendedData);

	svc_plugin_remove(plugin);

	while ((item = list_dequeue(plugin->priv->data_in_list)) != NULL)
		svc_data_in_item_free(item);
	list_free(plugin->priv->data_in_list);

	if (plugin->priv->data_in != NULL)
	{
		stream_free(plugin->priv->data_in);
		plugin->priv->data_in = NULL;
	}
	xfree(plugin->priv);
	plugin->priv = NULL;

	IFCALL(plugin->terminate_callback, plugin);
}
Example #30
0
void test_nsc_encode(void)
{
	int i;
	BYTE* rgb_data;
	wStream* enc_stream;
	NSC_CONTEXT* context;

	rgb_data = (BYTE *) malloc(64 * 64 * 3);
	for (i = 0; i < 64; i++)
		memcpy(rgb_data + i * 64 * 3, rgb_scanline_data, 64 * 3);

	context = nsc_context_new();
	nsc_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);

	enc_stream = stream_new(65536);
	stream_clear(enc_stream);

	for (i = 0; i < 30000; i++)
	{
		Stream_SetPosition(enc_stream, 0);
		nsc_compose_message(context, enc_stream, rgb_data, 64, 64, 64 * 3);
	}
	/*winpr_HexDump(Stream_Buffer(enc_stream), Stream_GetPosition(enc_stream));*/
	nsc_process_message(context, 32, 64, 64, Stream_Buffer(enc_stream), Stream_GetPosition(enc_stream));
	/*winpr_HexDump(context->bmpdata, 64 * 64 * 4);*/
	stream_free(enc_stream);

	nsc_context_free(context);
}