Exemple #1
0
rdpRdp* rdp_new(freerdp* instance)
{
	rdpRdp* rdp;

	rdp = (rdpRdp*) xzalloc(sizeof(rdpRdp));

	if (rdp != NULL)
	{
		rdp->instance = instance;
		rdp->settings = settings_new((void*) instance);
		if (instance != NULL)
			instance->settings = rdp->settings;

		rdp->transport   = transport_new(rdp->settings);
		rdp->license     = license_new(rdp);
//		rdp->input       = input_new(rdp);
//		rdp->update      = update_new(rdp);
		rdp->fastpath    = fastpath_new(rdp);
		rdp->nego        = nego_new(rdp->transport);
		rdp->mcs         = mcs_new(rdp->transport);
		rdp->redirection = redirection_new();
		rdp->mppc        = mppc_new(rdp);
	}

	return rdp;
}
Exemple #2
0
BOOL rdp_client_reconnect(rdpRdp* rdp)
{
	UINT32 i;

	transport_disconnect(rdp->transport);

	mcs_free(rdp->mcs);
	nego_free(rdp->nego);
	license_free(rdp->license);
	transport_free(rdp->transport);

	/* Reset virtual channel status */
	for (i = 0; i < rdp->mcs->channelCount; i++)
	{
		rdp->mcs->channels[i].joined = FALSE;
	}

	rdp->transport = transport_new(rdp->settings);
	rdp->license = license_new(rdp);
	rdp->nego = nego_new(rdp->transport);
	rdp->mcs = mcs_new(rdp->transport);

	rdp->transport->layer = TRANSPORT_LAYER_TCP;

	return rdp_client_connect(rdp);
}
Exemple #3
0
boolean rdp_client_redirect(rdpRdp* rdp)
{
	rdpSettings* settings = rdp->settings;
	rdpRedirection* redirection = rdp->redirection;

	rdp_client_disconnect(rdp);

	mcs_free(rdp->mcs);
	nego_free(rdp->nego);
	license_free(rdp->license);
	transport_free(rdp->transport);
	rdp->transport = transport_new(settings);
	rdp->license = license_new(rdp);
	rdp->nego = nego_new(rdp->transport);
	rdp->mcs = mcs_new(rdp->transport);

	rdp->transport->layer = TRANSPORT_LAYER_TCP;
	settings->redirected_session_id = redirection->sessionID;

	if (redirection->flags & LB_LOAD_BALANCE_INFO)
		nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);

	if (redirection->flags & LB_TARGET_NET_ADDRESS)
		settings->hostname = redirection->targetNetAddress.ascii;
	else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
		settings->hostname = redirection->targetNetBiosName.ascii;

	if (redirection->flags & LB_USERNAME)
		settings->username = redirection->username.ascii;

	if (redirection->flags & LB_DOMAIN)
		settings->domain = redirection->domain.ascii;

	return rdp_client_connect(rdp);
}
Exemple #4
0
rdpRdp* rdp_new(freerdp* instance)
{
	rdpRdp* rdp;

	rdp = (rdpRdp*) malloc(sizeof(rdpRdp));

	if (rdp != NULL)
	{
		ZeroMemory(rdp, sizeof(rdpRdp));

		rdp->instance = instance;
		rdp->settings = freerdp_settings_new((void*) instance);

		if (instance != NULL)
			instance->settings = rdp->settings;

		rdp->extension = extension_new(instance);
		rdp->transport = transport_new(rdp->settings);
		rdp->license = license_new(rdp);
		rdp->input = input_new(rdp);
		rdp->update = update_new(rdp);
		rdp->fastpath = fastpath_new(rdp);
		rdp->nego = nego_new(rdp->transport);
		rdp->mcs = mcs_new(rdp->transport);
		rdp->redirection = redirection_new();
		rdp->mppc_dec = mppc_dec_new();
		rdp->mppc_enc = mppc_enc_new(PROTO_RDP_50);
	}

	return rdp;
}
Exemple #5
0
rdpIso *
iso_new(struct rdp_mcs *mcs)
{
	rdpIso *self;

	self = (rdpIso *) xmalloc(sizeof(rdpIso));

	if (self != NULL)
	{
		memset(self, 0, sizeof(rdpIso));
		self->mcs = mcs;
		self->tcp = tcp_new(self);
		self->nego = nego_new(self);
	}

	return self;
}
Exemple #6
0
rdpRdp* rdp_new(rdpContext* context)
{
	rdpRdp* rdp;
	DWORD flags;

	rdp = (rdpRdp*) malloc(sizeof(rdpRdp));

	if (rdp)
	{
		ZeroMemory(rdp, sizeof(rdpRdp));

		rdp->context = context;
		rdp->instance = context->instance;

		flags = 0;

		if (context->ServerMode)
			flags |= FREERDP_SETTINGS_SERVER_MODE;

		if (!context->settings)
			context->settings = freerdp_settings_new(flags);

		rdp->settings = context->settings;
		rdp->settings->instance = context->instance;

		if (context->instance)
			context->instance->settings = rdp->settings;

		rdp->extension = extension_new(context->instance);
		rdp->transport = transport_new(rdp->settings);
		rdp->transport->rdp = rdp;
		rdp->license = license_new(rdp);
		rdp->input = input_new(rdp);
		rdp->update = update_new(rdp);
		rdp->fastpath = fastpath_new(rdp);
		rdp->nego = nego_new(rdp->transport);
		rdp->mcs = mcs_new(rdp->transport);
		rdp->redirection = redirection_new();
		rdp->autodetect = autodetect_new();
		rdp->heartbeat = heartbeat_new();
		rdp->multitransport = multitransport_new();
		rdp->bulk = bulk_new(context);
	}

	return rdp;
}
Exemple #7
0
rdpRdp* rdp_new()
{
	rdpRdp* rdp;

	rdp = (rdpRdp*) xzalloc(sizeof(rdpRdp));

	if (rdp != NULL)
	{
		rdp->connected = False;
		rdp->settings = settings_new();
		rdp->registry = registry_new(rdp->settings);
		rdp->transport = transport_new(rdp->settings);
		rdp->license = license_new(rdp);
		rdp->nego = nego_new(rdp->transport);
		rdp->mcs = mcs_new(rdp->transport);
	}

	return rdp;
}
Exemple #8
0
void rdp_reset(rdpRdp* rdp)
{
    rdpSettings* settings;

    settings = rdp->settings;

    bulk_reset(rdp->bulk);

    crypto_rc4_free(rdp->rc4_decrypt_key);
    rdp->rc4_decrypt_key = NULL;
    crypto_rc4_free(rdp->rc4_encrypt_key);
    rdp->rc4_encrypt_key = NULL;
    crypto_des3_free(rdp->fips_encrypt);
    rdp->fips_encrypt = NULL;
    crypto_des3_free(rdp->fips_decrypt);
    rdp->fips_decrypt = NULL;
    crypto_hmac_free(rdp->fips_hmac);
    rdp->fips_hmac = NULL;

    mcs_free(rdp->mcs);
    nego_free(rdp->nego);
    license_free(rdp->license);
    transport_free(rdp->transport);

    free(settings->ServerRandom);
    settings->ServerRandom = NULL;
    free(settings->ServerCertificate);
    settings->ServerCertificate = NULL;
    free(settings->ClientAddress);
    settings->ClientAddress = NULL;

    rdp->transport = transport_new(rdp->settings);
    rdp->transport->rdp = rdp;
    rdp->license = license_new(rdp);
    rdp->nego = nego_new(rdp->transport);
    rdp->mcs = mcs_new(rdp->transport);
    rdp->transport->layer = TRANSPORT_LAYER_TCP;
}
Exemple #9
0
boolean rdp_client_redirect(rdpRdp* rdp)
{
	rdpSettings* settings = rdp->settings;
	rdpRedirection* redirection = rdp->redirection;

	rdp_client_disconnect(rdp);

	/* FIXME: this is a subset of rdp_free */
	crypto_rc4_free(rdp->rc4_decrypt_key);
	crypto_rc4_free(rdp->rc4_encrypt_key);
	crypto_des3_free(rdp->fips_encrypt);
	crypto_des3_free(rdp->fips_decrypt);
	crypto_hmac_free(rdp->fips_hmac);
	mcs_free(rdp->mcs);
	nego_free(rdp->nego);
	license_free(rdp->license);
	transport_free(rdp->transport);

	/* FIXME: this is a subset of settings_free */
	freerdp_blob_free(settings->server_random);
	freerdp_blob_free(settings->server_certificate);
	xfree(settings->ip_address);

	rdp->transport = transport_new(settings);
	rdp->license = license_new(rdp);
	rdp->nego = nego_new(rdp->transport);
	rdp->mcs = mcs_new(rdp->transport);

	rdp->transport->layer = TRANSPORT_LAYER_TCP;
	settings->redirected_session_id = redirection->sessionID;

	if (redirection->flags & LB_LOAD_BALANCE_INFO)
	{
		nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);
	}
	else
	{
		if (redirection->flags & LB_TARGET_NET_ADDRESS)
		{
			xfree(settings->hostname);
			settings->hostname = xstrdup(redirection->targetNetAddress.ascii);
		}
		else if (redirection->flags & LB_TARGET_FQDN)
		{
			xfree(settings->hostname);
			settings->hostname = xstrdup(redirection->targetFQDN.ascii);
		}
		else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
		{
			xfree(settings->hostname);
			settings->hostname = xstrdup(redirection->targetNetBiosName.ascii);
		}
	}

	if (redirection->flags & LB_USERNAME)
	{
		xfree(settings->username);
		settings->username = xstrdup(redirection->username.ascii);
	}

	if (redirection->flags & LB_DOMAIN)
	{
		xfree(settings->domain);
		settings->domain = xstrdup(redirection->domain.ascii);
	}

	if (redirection->flags & LB_PASSWORD)
	{
		settings->password_cookie = &redirection->password_cookie;
	}

	return rdp_client_connect(rdp);
}
Exemple #10
0
BOOL rdp_client_redirect(rdpRdp* rdp)
{
	rdpSettings* settings = rdp->settings;
	rdpRedirection* redirection = rdp->redirection;

	rdp_client_disconnect(rdp);

	/* FIXME: this is a subset of rdp_free */
	crypto_rc4_free(rdp->rc4_decrypt_key);
	crypto_rc4_free(rdp->rc4_encrypt_key);
	crypto_des3_free(rdp->fips_encrypt);
	crypto_des3_free(rdp->fips_decrypt);
	crypto_hmac_free(rdp->fips_hmac);
	mcs_free(rdp->mcs);
	nego_free(rdp->nego);
	license_free(rdp->license);
	transport_free(rdp->transport);

	free(settings->ServerRandom);
	free(settings->ServerCertificate);
	free(settings->ClientAddress);

	rdp->transport = transport_new(settings);
	rdp->license = license_new(rdp);
	rdp->nego = nego_new(rdp->transport);
	rdp->mcs = mcs_new(rdp->transport);

	rdp->transport->layer = TRANSPORT_LAYER_TCP;
	settings->RedirectedSessionId = redirection->sessionID;

	if (redirection->flags & LB_LOAD_BALANCE_INFO)
	{
		nego_set_routing_token(rdp->nego, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
	}
	else
	{
		if (redirection->flags & LB_TARGET_NET_ADDRESS)
		{
			free(settings->ServerHostname);
			settings->ServerHostname = _strdup(redirection->targetNetAddress.ascii);
		}
		else if (redirection->flags & LB_TARGET_FQDN)
		{
			free(settings->ServerHostname);
			settings->ServerHostname = _strdup(redirection->targetFQDN.ascii);
		}
		else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
		{
			free(settings->ServerHostname);
			settings->ServerHostname = _strdup(redirection->targetNetBiosName.ascii);
		}
	}

	if (redirection->flags & LB_USERNAME)
	{
		free(settings->Username);
		settings->Username = _strdup(redirection->username.ascii);
	}

	if (redirection->flags & LB_DOMAIN)
	{
		free(settings->Domain);
		settings->Domain = _strdup(redirection->domain.ascii);
	}

	if (redirection->flags & LB_PASSWORD)
	{
		settings->RedirectionPassword = redirection->PasswordCookie;
		settings->RedirectionPasswordLength = redirection->PasswordCookieLength;
	}

	return rdp_client_connect(rdp);
}
Exemple #11
0
tbool rdp_client_redirect(rdpRdp* rdp)
{
	rdpSettings* settings = rdp->settings;
	rdpRedirection* redirection = rdp->redirection;

	rdp_client_disconnect(rdp);

	mcs_free(rdp->mcs);
	nego_free(rdp->nego);
	license_free(rdp->license);
	transport_free(rdp->transport);
	rdp->transport = transport_new(settings);
	rdp->license = license_new(rdp);
	rdp->nego = nego_new(rdp->transport);
	rdp->mcs = mcs_new(rdp->transport);

	rdp->transport->layer = TRANSPORT_LAYER_TCP;
	settings->redirected_session_id = redirection->sessionID;

	if (redirection->flags & LB_LOAD_BALANCE_INFO)
	{
		nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);
	}
	else
	{
		if (redirection->flags & LB_TARGET_NET_ADDRESS)
		{
			xfree(settings->hostname);
			settings->hostname = xstrdup(redirection->targetNetAddress.ascii);
		}
		else if (redirection->flags & LB_TARGET_FQDN)
		{
			xfree(settings->hostname);
			settings->hostname = xstrdup(redirection->targetFQDN.ascii);
		}
		else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
		{
			xfree(settings->hostname);
			settings->hostname = xstrdup(redirection->targetNetBiosName.ascii);
		}
	}

	if (redirection->flags & LB_USERNAME)
	{
		xfree(settings->username);
		settings->username = xstrdup(redirection->username.ascii);
	}

	if (redirection->flags & LB_DOMAIN)
	{
		xfree(settings->domain);
		settings->domain = xstrdup(redirection->domain.ascii);
	}

	if (redirection->flags & LB_PASSWORD)
	{
		settings->password_cookie = &redirection->password_cookie;
	}

	return rdp_client_connect(rdp);
}
Exemple #12
0
rdpRdp* rdp_new(rdpContext* context)
{
    rdpRdp* rdp;
    DWORD flags;
    BOOL newSettings = FALSE;

    rdp = (rdpRdp*) calloc(1, sizeof(rdpRdp));
    if (!rdp)
        return NULL;

    rdp->context = context;
    rdp->instance = context->instance;

    flags = 0;

    if (context->ServerMode)
        flags |= FREERDP_SETTINGS_SERVER_MODE;

    if (!context->settings)
    {
        context->settings = freerdp_settings_new(flags);
        if (!context->settings)
            goto out_free;
        newSettings = TRUE;
    }

    rdp->settings = context->settings;
    rdp->settings->instance = context->instance;

    if (context->instance)
        context->instance->settings = rdp->settings;

    rdp->transport = transport_new(rdp->settings);
    if (!rdp->transport)
        goto out_free_settings;

    rdp->transport->rdp = rdp;

    rdp->license = license_new(rdp);
    if (!rdp->license)
        goto out_free_transport;

    rdp->input = input_new(rdp);
    if (!rdp->input)
        goto out_free_license;

    rdp->update = update_new(rdp);
    if (!rdp->update)
        goto out_free_input;

    rdp->fastpath = fastpath_new(rdp);
    if (!rdp->fastpath)
        goto out_free_update;

    rdp->nego = nego_new(rdp->transport);
    if (!rdp->nego)
        goto out_free_fastpath;

    rdp->mcs = mcs_new(rdp->transport);
    if (!rdp->mcs)
        goto out_free_nego;

    rdp->redirection = redirection_new();
    if (!rdp->redirection)
        goto out_free_mcs;

    rdp->autodetect = autodetect_new();
    if (!rdp->autodetect)
        goto out_free_redirection;

    rdp->heartbeat = heartbeat_new();
    if (!rdp->heartbeat)
        goto out_free_autodetect;

    rdp->multitransport = multitransport_new();
    if (!rdp->multitransport)
        goto out_free_heartbeat;

    rdp->bulk = bulk_new(context);
    if (!rdp->bulk)
        goto out_free_multitransport;

    return rdp;

out_free_multitransport:
    multitransport_free(rdp->multitransport);
out_free_heartbeat:
    heartbeat_free(rdp->heartbeat);
out_free_autodetect:
    autodetect_free(rdp->autodetect);
out_free_redirection:
    redirection_free(rdp->redirection);
out_free_mcs:
    mcs_free(rdp->mcs);
out_free_nego:
    nego_free(rdp->nego);
out_free_fastpath:
    fastpath_free(rdp->fastpath);
out_free_update:
    update_free(rdp->update);
out_free_input:
    input_free(rdp->input);
out_free_license:
    license_free(rdp->license);
out_free_transport:
    transport_free(rdp->transport);
out_free_settings:
    if (newSettings)
        freerdp_settings_free(rdp->settings);
out_free:
    free(rdp);
    return NULL;
}