2016-09-21 13:37:09 +02:00
|
|
|
diff --git a/configure.ac b/configure.ac
|
2017-06-30 09:57:10 +02:00
|
|
|
index 47212ec..b011897 100644
|
2016-09-21 13:37:09 +02:00
|
|
|
--- a/configure.ac
|
|
|
|
+++ b/configure.ac
|
2017-06-30 09:57:10 +02:00
|
|
|
@@ -9,6 +9,7 @@ AC_PROG_CC
|
2016-09-21 13:37:09 +02:00
|
|
|
AC_C_CONST
|
|
|
|
AC_PROG_LIBTOOL
|
2017-06-30 09:57:10 +02:00
|
|
|
|
2016-09-21 13:37:09 +02:00
|
|
|
+PKG_CHECK_MODULES(AVAHI, avahi-client >= 0.6.4)
|
|
|
|
PKG_PROG_PKG_CONFIG
|
2017-06-30 09:57:10 +02:00
|
|
|
if test "x$PKG_CONFIG" = "x"; then
|
|
|
|
AC_MSG_ERROR([please install pkg-config])
|
2016-09-21 13:37:09 +02:00
|
|
|
diff --git a/xrdp/Makefile.am b/xrdp/Makefile.am
|
2017-06-30 09:57:10 +02:00
|
|
|
index a259ef3..2cbb762 100644
|
2016-09-21 13:37:09 +02:00
|
|
|
--- a/xrdp/Makefile.am
|
|
|
|
+++ b/xrdp/Makefile.am
|
2017-06-30 09:57:10 +02:00
|
|
|
@@ -12,7 +12,9 @@ AM_CPPFLAGS = \
|
|
|
|
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
|
2016-09-21 13:37:09 +02:00
|
|
|
-I$(top_builddir) \
|
|
|
|
-I$(top_srcdir)/common \
|
2017-06-30 09:57:10 +02:00
|
|
|
- -I$(top_srcdir)/libxrdp
|
|
|
|
+ -I$(top_srcdir)/libxrdp \
|
2016-09-21 13:37:09 +02:00
|
|
|
+ $(AVAHI_CFLAGS)
|
2017-06-30 09:57:10 +02:00
|
|
|
+
|
2016-09-21 13:37:09 +02:00
|
|
|
|
2017-06-30 09:57:10 +02:00
|
|
|
XRDP_EXTRA_LIBS =
|
2016-09-21 13:37:09 +02:00
|
|
|
|
2017-06-30 09:57:10 +02:00
|
|
|
@@ -46,6 +48,7 @@ xrdp_SOURCES = \
|
|
|
|
lang.c \
|
|
|
|
xrdp.c \
|
|
|
|
xrdp.h \
|
|
|
|
+ xrdp_avahi.c \
|
|
|
|
xrdp_bitmap.c \
|
|
|
|
xrdp_cache.c \
|
|
|
|
xrdp_encoder.c \
|
|
|
|
@@ -63,7 +66,8 @@ xrdp_SOURCES = \
|
2016-09-21 13:37:09 +02:00
|
|
|
xrdp_LDADD = \
|
|
|
|
$(top_builddir)/common/libcommon.la \
|
|
|
|
$(top_builddir)/libxrdp/libxrdp.la \
|
2017-06-30 09:57:10 +02:00
|
|
|
- $(XRDP_EXTRA_LIBS)
|
|
|
|
+ $(XRDP_EXTRA_LIBS) \
|
2016-09-21 13:37:09 +02:00
|
|
|
+ $(AVAHI_LIBS)
|
|
|
|
|
2017-06-30 09:57:10 +02:00
|
|
|
xrdpsysconfdir=$(sysconfdir)/xrdp
|
|
|
|
|
2016-09-21 13:37:09 +02:00
|
|
|
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
|
2017-06-30 09:57:10 +02:00
|
|
|
index 82e8a57..ae70874 100644
|
2016-09-21 13:37:09 +02:00
|
|
|
--- a/xrdp/xrdp.h
|
|
|
|
+++ b/xrdp/xrdp.h
|
2017-06-30 09:57:10 +02:00
|
|
|
@@ -163,6 +163,8 @@ void
|
2016-09-21 13:37:09 +02:00
|
|
|
xrdp_listen_main_loop(struct xrdp_listen* self);
|
2017-07-19 14:08:32 +02:00
|
|
|
int
|
|
|
|
xrdp_listen_test(void);
|
2017-06-30 09:57:10 +02:00
|
|
|
+int
|
2016-09-21 13:37:09 +02:00
|
|
|
+xrdp_listen_get_port(char* port, int port_bytes);
|
|
|
|
|
|
|
|
/* xrdp_region.c */
|
2017-06-30 09:57:10 +02:00
|
|
|
struct xrdp_region*
|
|
|
|
@@ -514,3 +516,8 @@ server_add_char_alpha(struct xrdp_mod* mod, int font, int character,
|
|
|
|
int
|
|
|
|
server_session_info(struct xrdp_mod *mod, const char *data, int data_bytes);
|
|
|
|
|
2016-09-21 13:37:09 +02:00
|
|
|
+/* xrdp_avahi.c */
|
2017-06-30 09:57:10 +02:00
|
|
|
+int
|
2016-09-21 13:37:09 +02:00
|
|
|
+xrdp_avahi_init(void);
|
2017-06-30 09:57:10 +02:00
|
|
|
+void
|
2016-09-21 13:37:09 +02:00
|
|
|
+xrdp_avahi_fini(void);
|
|
|
|
diff --git a/xrdp/xrdp_avahi.c b/xrdp/xrdp_avahi.c
|
2017-06-30 09:57:10 +02:00
|
|
|
index e69de29..642a333 100644
|
|
|
|
--- a/xrdp/xrdp_avahi.c
|
2016-09-21 13:37:09 +02:00
|
|
|
+++ b/xrdp/xrdp_avahi.c
|
2017-06-30 09:57:10 +02:00
|
|
|
@@ -0,0 +1,115 @@
|
2016-09-21 13:37:09 +02:00
|
|
|
+/*
|
|
|
|
+ This program is free software; you can redistribute it and/or modify
|
|
|
|
+ it under the terms of the GNU General Public License as published by
|
|
|
|
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ (at your option) any later version.
|
|
|
|
+
|
|
|
|
+ This program is distributed in the hope that it will be useful,
|
|
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ GNU General Public License for more details.
|
|
|
|
+
|
|
|
|
+ You should have received a copy of the GNU General Public License
|
|
|
|
+ along with this program; if not, write to the Free Software
|
|
|
|
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
+
|
|
|
|
+ xrdp: A Remote Desktop Protocol server.
|
|
|
|
+ Copyright (C) Novell, Inc. 2008
|
|
|
|
+
|
|
|
|
+ avahi integration
|
|
|
|
+
|
|
|
|
+*/
|
|
|
|
+
|
|
|
|
+#include <stdio.h>
|
2017-06-30 09:57:10 +02:00
|
|
|
+#include <stdlib.h>
|
2016-09-21 13:37:09 +02:00
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <avahi-client/client.h>
|
|
|
|
+#include <avahi-client/publish.h>
|
|
|
|
+#include <avahi-common/thread-watch.h>
|
|
|
|
+
|
|
|
|
+static AvahiClient *client = NULL;
|
|
|
|
+static AvahiThreadedPoll *threaded_poll = NULL;
|
|
|
|
+static AvahiEntryGroup *avahi_group = NULL;
|
|
|
|
+
|
|
|
|
+static const char *_service_name = "RDP service on %s";
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+avahi_client_callback (AvahiClient *c,
|
|
|
|
+ AvahiClientState state,
|
|
|
|
+ void *userdata)
|
|
|
|
+{
|
|
|
|
+ switch (state) {
|
|
|
|
+ case AVAHI_CLIENT_S_RUNNING:
|
|
|
|
+ avahi_group = avahi_entry_group_new (c, 0, 0);
|
|
|
|
+ if (avahi_group)
|
|
|
|
+ {
|
|
|
|
+ char hname[512];
|
|
|
|
+ char name[576];
|
|
|
|
+ char port[8];
|
|
|
|
+ /* dummy parameters */
|
|
|
|
+ char address[256];
|
2017-06-30 09:57:10 +02:00
|
|
|
+ struct xrdp_startup_params* startup_param = {(const char[]) {""}, 0, 0, 0, 0, 0, 0, 0};
|
2016-09-21 13:37:09 +02:00
|
|
|
+
|
|
|
|
+ if (gethostname (hname, sizeof (hname)))
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ sprintf (name, _service_name, hname);
|
|
|
|
+
|
|
|
|
+ xrdp_listen_get_port_address (port, sizeof (port),
|
|
|
|
+ address, sizeof (address),
|
|
|
|
+ startup_param);
|
|
|
|
+
|
|
|
|
+ avahi_entry_group_add_service (avahi_group,
|
|
|
|
+ AVAHI_IF_UNSPEC,
|
|
|
|
+ AVAHI_PROTO_UNSPEC,
|
|
|
|
+ 0,
|
|
|
|
+ name,
|
|
|
|
+ "_rdp._tcp",
|
|
|
|
+ 0,
|
|
|
|
+ 0,
|
|
|
|
+ atoi (port),
|
|
|
|
+ NULL);
|
|
|
|
+
|
|
|
|
+ avahi_entry_group_commit (avahi_group);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case AVAHI_CLIENT_FAILURE:
|
|
|
|
+ case AVAHI_CLIENT_S_COLLISION:
|
|
|
|
+ case AVAHI_CLIENT_CONNECTING:
|
|
|
|
+ break;
|
|
|
|
+ case AVAHI_CLIENT_S_REGISTERING:
|
|
|
|
+ if (avahi_group)
|
|
|
|
+ avahi_entry_group_reset (avahi_group);
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2017-06-30 09:57:10 +02:00
|
|
|
+int
|
2016-09-21 13:37:09 +02:00
|
|
|
+xrdp_avahi_init (void)
|
|
|
|
+{
|
|
|
|
+ if (!(threaded_poll = avahi_threaded_poll_new ()))
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ if (!(client = avahi_client_new (avahi_threaded_poll_get (threaded_poll),
|
|
|
|
+ 0,
|
|
|
|
+ avahi_client_callback,
|
|
|
|
+ NULL,
|
|
|
|
+ NULL)))
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ if (avahi_threaded_poll_start (threaded_poll) < 0)
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
2017-06-30 09:57:10 +02:00
|
|
|
+void
|
2016-09-21 13:37:09 +02:00
|
|
|
+xrdp_avahi_fini (void)
|
|
|
|
+{
|
|
|
|
+ avahi_threaded_poll_stop (threaded_poll);
|
|
|
|
+ if (avahi_group)
|
|
|
|
+ avahi_entry_group_free (avahi_group);
|
|
|
|
+ avahi_client_free (client);
|
|
|
|
+ avahi_threaded_poll_free (threaded_poll);
|
|
|
|
+}
|
|
|
|
diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c
|
2017-06-30 09:57:10 +02:00
|
|
|
index 0fbe61f..ed0af63 100644
|
2016-09-21 13:37:09 +02:00
|
|
|
--- a/xrdp/xrdp_listen.c
|
|
|
|
+++ b/xrdp/xrdp_listen.c
|
2017-06-30 09:57:10 +02:00
|
|
|
@@ -149,7 +149,7 @@ xrdp_process_run(void *in_val)
|
2016-09-21 13:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
-static int
|
|
|
|
+int
|
|
|
|
xrdp_listen_get_port_address(char *port, int port_bytes,
|
|
|
|
char *address, int address_bytes,
|
|
|
|
int *tcp_nodelay, int *tcp_keepalive,
|