Merge branch 'master' of github.com:FreeRDP/xrdp

ulab-next
Laxmikant Rashinkar 12 years ago
commit 1f1b6e8738

@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2012
* Copyright (C) Jay Sorg 2004-2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -427,29 +427,42 @@ g_tcp_set_keepalive(int sck)
/*****************************************************************************/
/* returns a newly created socket or -1 on error */
/* in win32 a socket is an unsigned int, in linux, its an int */
int APP_CC
g_tcp_socket(void)
{
#if defined(_WIN32)
int rv;
int option_value;
#if defined(_WIN32)
int option_len;
#else
int rv;
int option_value;
unsigned int option_len;
#endif
/* in win32 a socket is an unsigned int, in linux, its an int */
rv = (int)socket(PF_INET, SOCK_STREAM, 0);
#if !defined(NO_ARPA_INET_H_IP6)
rv = (int)socket(AF_INET6, SOCK_STREAM, 0);
#else
rv = (int)socket(AF_INET, SOCK_STREAM, 0);
#endif
if (rv < 0)
{
return -1;
}
#if !defined(NO_ARPA_INET_H_IP6)
option_len = sizeof(option_value);
if (getsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
&option_len) == 0)
{
if (option_value != 0)
{
option_value = 0;
option_len = sizeof(option_value);
setsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
option_len);
}
}
#endif
option_len = sizeof(option_value);
if (getsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value,
&option_len) == 0)
{
@ -494,17 +507,18 @@ g_tcp_local_socket(void)
void APP_CC
g_tcp_close(int sck)
{
char ip[256] ;
char ip[256];
if (sck == 0)
{
return;
}
#if defined(_WIN32)
closesocket(sck);
#else
g_write_ip_address(sck,ip,255);
log_message(LOG_LEVEL_INFO,"An established connection closed to endpoint: %s", ip);
g_write_ip_address(sck, ip, 255);
log_message(LOG_LEVEL_INFO, "An established connection closed to "
"endpoint: %s", ip);
close(sck);
#endif
}
@ -514,34 +528,55 @@ g_tcp_close(int sck)
int APP_CC
g_tcp_connect(int sck, const char *address, const char *port)
{
struct sockaddr_in s;
struct hostent *h;
g_memset(&s, 0, sizeof(struct sockaddr_in));
s.sin_family = AF_INET;
s.sin_port = htons((tui16)atoi(port));
s.sin_addr.s_addr = inet_addr(address);
if (s.sin_addr.s_addr == INADDR_NONE)
int res = 0;
struct addrinfo p;
struct addrinfo *h = (struct addrinfo *)NULL;
struct addrinfo *rp = (struct addrinfo *)NULL;
/* initialize (zero out) local variables: */
g_memset(&p, 0, sizeof(struct addrinfo));
/* in IPv6-enabled environments, set the AI_V4MAPPED
* flag in ai_flags and specify ai_family=AF_INET6 in
* order to ensure that getaddrinfo() returns any
* available IPv4-mapped addresses in case the target
* host does not have a true IPv6 address:
*/
p.ai_socktype = SOCK_STREAM;
p.ai_protocol = IPPROTO_TCP;
#if !defined(NO_ARPA_INET_H_IP6)
p.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED;
p.ai_family = AF_INET6;
if (g_strcmp(address, "127.0.0.1") == 0)
{
h = gethostbyname(address);
if (h != 0)
res = getaddrinfo("::1", port, &p, &h);
}
else
{
res = getaddrinfo(address, port, &p, &h);
}
#else
p.ai_flags = AI_ADDRCONFIG;
p.ai_family = AF_INET;
res = getaddrinfo(address, port, &p, &h);
#endif
if (res > -1)
{
if (h->h_name != 0)
if (h != NULL)
{
if (h->h_addr_list != 0)
for (rp = h; rp != NULL; rp = rp->ai_next)
{
if ((*(h->h_addr_list)) != 0)
rp = h;
res = connect(sck, (struct sockaddr *)(rp->ai_addr),
rp->ai_addrlen);
if (res != -1)
{
s.sin_addr.s_addr = *((int *)(*(h->h_addr_list)));
}
break; /* Success */
}
}
}
}
return connect(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
return res;
}
/*****************************************************************************/
@ -578,23 +613,117 @@ g_tcp_set_non_blocking(int sck)
return 0;
}
/*****************************************************************************/
/* return boolean */
static int APP_CC
address_match(const char *address, struct addrinfo *j)
{
struct sockaddr_in *ipv4_in;
struct sockaddr_in6 *ipv6_in;
if (address == 0)
{
return 1;
}
if (address[0] == 0)
{
return 1;
}
if (g_strcmp(address, "0.0.0.0") == 0)
{
return 1;
}
if ((g_strcmp(address, "127.0.0.1") == 0) ||
(g_strcmp(address, "::1") == 0) ||
(g_strcmp(address, "localhost") == 0))
{
if (j->ai_addr != 0)
{
if (j->ai_addr->sa_family == AF_INET)
{
ipv4_in = (struct sockaddr_in *) (j->ai_addr);
if (inet_pton(AF_INET, "127.0.0.1", &(ipv4_in->sin_addr)))
{
return 1;
}
}
if (j->ai_addr->sa_family == AF_INET6)
{
ipv6_in = (struct sockaddr_in6 *) (j->ai_addr);
if (inet_pton(AF_INET6, "::1", &(ipv6_in->sin6_addr)))
{
return 1;
}
}
}
}
if (j->ai_addr != 0)
{
if (j->ai_addr->sa_family == AF_INET)
{
ipv4_in = (struct sockaddr_in *) (j->ai_addr);
if (inet_pton(AF_INET, address, &(ipv4_in->sin_addr)))
{
return 1;
}
}
if (j->ai_addr->sa_family == AF_INET6)
{
ipv6_in = (struct sockaddr_in6 *) (j->ai_addr);
if (inet_pton(AF_INET6, address, &(ipv6_in->sin6_addr)))
{
return 1;
}
}
}
return 0;
}
/*****************************************************************************/
/* returns error, zero is good */
static int APP_CC
g_tcp_bind_flags(int sck, const char *port, const char *address, int flags)
{
int res;
int error;
struct addrinfo hints;
struct addrinfo *i;
res = -1;
g_memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = flags;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
error = getaddrinfo(NULL, port, &hints, &i);
if (error == 0)
{
while ((i != 0) && (res < 0))
{
if (address_match(address, i))
{
res = bind(sck, i->ai_addr, i->ai_addrlen);
}
i = i->ai_next;
}
}
return res;
}
/*****************************************************************************/
/* returns error, zero is good */
int APP_CC
g_tcp_bind(int sck, char *port)
g_tcp_bind(int sck, const char *port)
{
struct sockaddr_in s;
int flags;
memset(&s, 0, sizeof(struct sockaddr_in));
s.sin_family = AF_INET;
s.sin_port = htons((tui16)atoi(port));
s.sin_addr.s_addr = INADDR_ANY;
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
flags = AI_ADDRCONFIG | AI_PASSIVE;
return g_tcp_bind_flags(sck, port, 0, flags);
}
/*****************************************************************************/
int APP_CC
g_tcp_local_bind(int sck, char *port)
g_tcp_local_bind(int sck, const char *port)
{
#if defined(_WIN32)
return -1;
@ -611,21 +740,12 @@ g_tcp_local_bind(int sck, char *port)
/*****************************************************************************/
/* returns error, zero is good */
int APP_CC
g_tcp_bind_address(int sck, char *port, const char *address)
g_tcp_bind_address(int sck, const char *port, const char *address)
{
struct sockaddr_in s;
memset(&s, 0, sizeof(struct sockaddr_in));
s.sin_family = AF_INET;
s.sin_port = htons((tui16)atoi(port));
s.sin_addr.s_addr = INADDR_ANY;
if (inet_aton(address, &s.sin_addr) < 0)
{
return -1; /* bad address */
}
int flags;
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
flags = AI_ADDRCONFIG | AI_PASSIVE;
return g_tcp_bind_flags(sck, port, address, flags);
}
/*****************************************************************************/
@ -2017,7 +2137,7 @@ g_htoi(char *str)
/*****************************************************************************/
int APP_CC
g_pos(char *str, const char *to_find)
g_pos(const char *str, const char *to_find)
{
char *pp;

@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2012
* Copyright (C) Jay Sorg 2004-2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -78,11 +78,11 @@ g_tcp_force_recv(int sck, char* data, int len);
int APP_CC
g_tcp_set_non_blocking(int sck);
int APP_CC
g_tcp_bind(int sck, char* port);
g_tcp_bind(int sck, const char *port);
int APP_CC
g_tcp_local_bind(int sck, char* port);
g_tcp_local_bind(int sck, const char* port);
int APP_CC
g_tcp_bind_address(int sck, char* port, const char* address);
g_tcp_bind_address(int sck, const char* port, const char* address);
int APP_CC
g_tcp_listen(int sck);
int APP_CC
@ -196,7 +196,7 @@ g_atoi(const char* str);
int APP_CC
g_htoi(char* str);
int APP_CC
g_pos(char* str, const char* to_find);
g_pos(const char* str, const char* to_find);
int APP_CC
g_mbstowcs(twchar* dest, const char* src, int n);
int APP_CC

@ -69,6 +69,11 @@ then
fi
fi
AC_CHECK_MEMBER([struct in6_addr.s6_addr],
[],
[AC_DEFINE(NO_ARPA_INET_H_IP6, 1, [for IPv6])],
[#include <arpa/inet.h>])
if test "x$enable_nopam" = "xyes"
then
AC_DEFINE([USE_NOPAM],1,[Disable PAM])

@ -1,4 +1,5 @@
#%PAM-1.0
auth required pam_unix.so shadow nullok
auth required pam_env.so readenv=1
account required pam_unix.so
@include common-auth
@include common-account
@include common-session
@include common-password

@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2009-2012
* Copyright (C) Jay Sorg 2009-2013
* Copyright (C) Laxmikant Rashinkar 2009-2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -45,6 +45,7 @@ static int g_rdpsnd_index = -1;
static int g_rdpdr_index = -1;
static int g_rail_index = -1;
static int g_drdynvc_index = -1;
static int g_sent = 0; /* if sent data to xrdp, waiting response */
/* state info for dynamic virtual channels */
static struct xrdp_api_data *g_dvc_channels[MAX_DVC_CHANNELS];
@ -149,6 +150,7 @@ send_data_from_chan_item(struct chan_item *chan_item)
s_mark_end(s);
LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: -- "
"size %d chan_flags 0x%8.8x", size, chan_flags));
g_sent = 1;
error = trans_force_write(g_con_trans);
if (error != 0)
@ -214,7 +216,10 @@ send_channel_data(int chan_id, char *data, int size)
if (g_chan_items[index].id == chan_id)
{
add_data_to_chan_item(g_chan_items + index, data, size);
if (g_sent == 0)
{
check_chan_items();
}
return 0;
}
}
@ -478,6 +483,7 @@ static int APP_CC
process_message_channel_data_response(struct stream *s)
{
LOG(10, ("process_message_channel_data_response:"));
g_sent = 0;
check_chan_items();
return 0;
}

@ -262,7 +262,6 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
char *data;
int bytes;
int sent;
int display_num;
int fd;
struct header h;
struct sockaddr_un s;
@ -276,9 +275,8 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
fd = socket(PF_LOCAL, SOCK_STREAM, 0);
memset(&s, 0, sizeof(s));
s.sun_family = AF_UNIX;
display_num = get_display_num_from_display(getenv("DISPLAY"));
bytes = sizeof(s.sun_path) - 1;
snprintf(s.sun_path, bytes, CHANSRV_PORT_STR, display_num);
snprintf(s.sun_path, bytes, CHANSRV_PORT_STR, u->display_num);
pa_log("trying to conenct to %s", s.sun_path);
if (connect(fd, (struct sockaddr *)&s,
sizeof(struct sockaddr_un)) != 0) {
@ -296,15 +294,11 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
//pa_log("bytes %d", bytes);
/* from rewind */
if (u->skip_bytes > 0)
{
if (bytes > u->skip_bytes)
{
if (u->skip_bytes > 0) {
if (bytes > u->skip_bytes) {
bytes -= u->skip_bytes;
u->skip_bytes = 0;
}
else
{
} else {
u->skip_bytes -= bytes;
return bytes;
}

@ -4,7 +4,7 @@ Pulse audio notes.
to see what version of PA is on your machine
pulseaudio --version
IMA ADPCM
To build xrdp pulse sink,
get the pulse source that most closely matches your version on
@ -25,3 +25,48 @@ autospawn = no
daemon-binary = /bin/true
xfreerdp -a 24 -z --plugin rdpsnd --data alsa:hw:0,0 -- 127.0.0.1
to get ./configure on pulse source to run
apt-get install libsndfile1-dev
apt-get install libspeex-dev
apt-get install libspeexdsp-dev
alsamixer
apt-get install alsa-utils
/etc/asound.conf
---------------------------------
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
---------------------------------
/etc/pulse/default.pa
---------------------------------
.nofail
.fail
load-module module-augment-properties
#load-module module-alsa-sink device=hw:0
#load-module module-alsa-source device=hw:0
#load-module module-pipe-sink
#load-module module-pipe-source
#load-module module-null-sink
load-module module-xrdp-sink
load-module module-native-protocol-unix
#load-module module-udev-detect tsched=0
---------------------------------

@ -26,12 +26,6 @@
#include "libscp_tcp.h"
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
extern struct log_config *s_log;
/*****************************************************************************/
@ -124,11 +118,5 @@ scp_tcp_force_send(int sck, char *data, int len)
int DEFAULT_CC
scp_tcp_bind(int sck, char *addr, char *port)
{
struct sockaddr_in s;
memset(&s, 0, sizeof(struct sockaddr_in));
s.sin_family = AF_INET;
s.sin_port = htons(atoi(port));
s.sin_addr.s_addr = inet_addr(addr);
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
return g_tcp_bind_address(sck, port, addr);
}

Loading…
Cancel
Save