[farsight2/master] Remove internal copy of gupnp-igd
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:25:38 PST 2008
---
Makefile.am | 8 +-
configure.ac | 5 -
gst-libs/Makefile.am | 2 +-
gst-libs/ext/Makefile.am | 7 -
gst-libs/ext/fsupnp/Makefile.am | 42 -
.../ext/fsupnp/fs-upnp-simple-igd-marshal.list | 2 -
gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c | 296 -------
gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.h | 88 --
gst-libs/ext/fsupnp/fs-upnp-simple-igd.c | 854 --------------------
gst-libs/ext/fsupnp/fs-upnp-simple-igd.h | 125 ---
tests/Makefile.am | 6 +-
tests/check/Makefile.am | 18 -
tests/check/upnp/InternetGatewayDevice.xml | 60 --
tests/check/upnp/WANIPConnection.xml | 421 ----------
tests/check/upnp/fsupnp.c | 273 -------
tests/upnp/Makefile.am | 13 -
tests/upnp/test-thread.c | 77 --
tests/upnp/test.c | 91 ---
18 files changed, 4 insertions(+), 2384 deletions(-)
delete mode 100644 gst-libs/ext/Makefile.am
delete mode 100644 gst-libs/ext/fsupnp/Makefile.am
delete mode 100644 gst-libs/ext/fsupnp/fs-upnp-simple-igd-marshal.list
delete mode 100644 gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c
delete mode 100644 gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.h
delete mode 100644 gst-libs/ext/fsupnp/fs-upnp-simple-igd.c
delete mode 100644 gst-libs/ext/fsupnp/fs-upnp-simple-igd.h
delete mode 100644 tests/check/upnp/InternetGatewayDevice.xml
delete mode 100644 tests/check/upnp/WANIPConnection.xml
delete mode 100644 tests/check/upnp/fsupnp.c
delete mode 100644 tests/upnp/Makefile.am
delete mode 100644 tests/upnp/test-thread.c
delete mode 100644 tests/upnp/test.c
diff --git a/Makefile.am b/Makefile.am
index 95befb0..7a54148 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,11 +42,7 @@ check-torture:
endif
pcverfiles = farsight2- at GST_MAJORMINOR@.pc
-pcinfiles = farsight2.pc.in farsight2-upnp.pc.in
-
-if HAVE_GUPNP
-pcverfiles += farsight2-upnp.pc
-endif
+pcinfiles = farsight2.pc.in
%- at GST_MAJORMINOR@.pc: %.pc
cp $< $@
@@ -54,7 +50,7 @@ endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pcverfiles)
-CLEANFILES = $(pcverfiles) farsight2-upnp.pc
+CLEANFILES = $(pcverfiles)
DISTCLEANFILES = $(pcinfiles:.in=)
diff --git a/configure.ac b/configure.ac
index 8fe0622..1a0509c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -384,7 +384,6 @@ if test "x$WANT_GUPNP" = "xyes" && test "x$HAVE_GUPNP" = "xno"; then
AC_ERROR([Requested GUPnP IGD, but it is not available])
fi
-AM_CONDITIONAL(HAVE_GUPNP, test "x$HAVE_GUPNP" = "xyes")
if test "x$HAVE_GUPNP" = "xyes"; then
AC_DEFINE(HAVE_GUPNP,,[Have the GUPnP IGD library])
fi
@@ -395,7 +394,6 @@ dnl *** output files ***
AC_CONFIG_FILES(
Makefile
farsight2.pc
-farsight2-upnp.pc
gst/Makefile
gst/fsrtpconference/Makefile
gst/funnel/Makefile
@@ -403,8 +401,6 @@ gst/videoanyrate/Makefile
gst-libs/Makefile
gst-libs/gst/Makefile
gst-libs/gst/farsight/Makefile
-gst-libs/ext/Makefile
-gst-libs/ext/fsupnp/Makefile
transmitters/Makefile
transmitters/rawudp/Makefile
transmitters/multicast/Makefile
@@ -416,7 +412,6 @@ tests/check/Makefile
tests/rtp/Makefile
tests/gui/Makefile
tests/commandline/Makefile
-tests/upnp/Makefile
docs/Makefile
docs/libs/Makefile
docs/version.entities
diff --git a/gst-libs/Makefile.am b/gst-libs/Makefile.am
index c77dc62..062cb55 100644
--- a/gst-libs/Makefile.am
+++ b/gst-libs/Makefile.am
@@ -1 +1 @@
-SUBDIRS = gst ext
+SUBDIRS = gst
diff --git a/gst-libs/ext/Makefile.am b/gst-libs/ext/Makefile.am
deleted file mode 100644
index 76755e2..0000000
--- a/gst-libs/ext/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-if HAVE_GUPNP
-SUBDIRS = fsupnp
-else
-SUBDIRS =
-endif
-
-DIST_SUBDIRS = fsupnp
diff --git a/gst-libs/ext/fsupnp/Makefile.am b/gst-libs/ext/fsupnp/Makefile.am
deleted file mode 100644
index 24372b7..0000000
--- a/gst-libs/ext/fsupnp/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-lib_LTLIBRARIES = libfsupnp.la
-
-fsupnpincludedir = $(includedir)/gstreamer- at GST_MAJORMINOR@/ext/fsupnp
-
-fsupnpinclude_HEADERS = \
- fs-upnp-simple-igd.h \
- fs-upnp-simple-igd-thread.h
-
-libfsupnp_la_SOURCES = \
- fs-upnp-simple-igd.c \
- fs-upnp-simple-igd-thread.c \
- fs-upnp-simple-igd-marshal.c
-
-
-noinst_HEADERS = fs-upnp-simple-igd-marshal.h
-
-
-BUILT_SOURCES = \
- fs-upnp-simple-igd-marshal.c \
- fs-upnp-simple-igd-marshal.h
-
-CLEANFILES = $(BUILT_SOURCES)
-
-fs-upnp-simple-igd-marshal.h: fs-upnp-simple-igd-marshal.list Makefile
- glib-genmarshal --header --prefix=_fs_upnp_simple_igd_marshal $(srcdir)/$< > $@.tmp
- mv $@.tmp $@
-
-fs-upnp-simple-igd-marshal.c: fs-upnp-simple-igd-marshal.list Makefile
- echo "#include \"glib-object.h\"" >> $@.tmp
- echo "#include \"fs-upnp-simple-igd-marshal.h\"" >> $@.tmp
- glib-genmarshal --body --prefix=_fs_upnp_simple_igd_marshal $(srcdir)/$< >> $@.tmp
- mv $@.tmp $@
-
-libfsupnp_la_CFLAGS = \
- $(GUPNP_CFLAGS) \
- -I$(top_srcdir)/gst-libs
-
-libfsupnp_la_LIBADD = \
- $(GUPNP_LIBS)
-
-libfsupnp_la_LDFLAGS = \
- $(GUPNP_LDFLAGS)
diff --git a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-marshal.list b/gst-libs/ext/fsupnp/fs-upnp-simple-igd-marshal.list
deleted file mode 100644
index 8b8f99c..0000000
--- a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-marshal.list
+++ /dev/null
@@ -1,2 +0,0 @@
-VOID:STRING,STRING,STRING,UINT,STRING,UINT,STRING
-VOID:POINTER,STRING,UINT,STRING
diff --git a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c b/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c
deleted file mode 100644
index 55c4a32..0000000
--- a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Farsight2 - Farsight UPnP IGD abstraction
- *
- * Copyright 2008 Collabora Ltd.
- * @author: Olivier Crete <olivier.crete at collabora.co.uk>
- * Copyright 2008 Nokia Corp.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include "fs-upnp-simple-igd-thread.h"
-
-
-struct _FsUpnpSimpleIgdThreadPrivate
-{
- GThread *thread;
- GMainContext *context;
- GMutex *mutex;
-
- /* Protected by mutex */
- gboolean quit_loop;
- GMainLoop *loop;
-};
-
-
-#define FS_UPNP_SIMPLE_IGD_THREAD_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_UPNP_SIMPLE_IGD_THREAD, \
- FsUpnpSimpleIgdThreadPrivate))
-
-#define FS_UPNP_SIMPLE_IGD_THREAD_LOCK(o) g_mutex_lock ((o)->priv->mutex)
-#define FS_UPNP_SIMPLE_IGD_THREAD_UNLOCK(o) g_mutex_unlock ((o)->priv->mutex)
-
-
-G_DEFINE_TYPE (FsUpnpSimpleIgdThread, fs_upnp_simple_igd_thread,
- FS_TYPE_UPNP_SIMPLE_IGD);
-
-static void fs_upnp_simple_igd_thread_constructed (GObject *object);
-static void fs_upnp_simple_igd_thread_dispose (GObject *object);
-static void fs_upnp_simple_igd_thread_finalize (GObject *object);
-
-static void fs_upnp_simple_igd_thread_add_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description);
-static void fs_upnp_simple_igd_thread_remove_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port);
-
-static void
-fs_upnp_simple_igd_thread_class_init (FsUpnpSimpleIgdThreadClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- FsUpnpSimpleIgdClass *simple_igd_class = FS_UPNP_SIMPLE_IGD_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (FsUpnpSimpleIgdThreadPrivate));
-
- gobject_class->constructed = fs_upnp_simple_igd_thread_constructed;
- gobject_class->dispose = fs_upnp_simple_igd_thread_dispose;
- gobject_class->finalize = fs_upnp_simple_igd_thread_finalize;
-
- simple_igd_class->add_port = fs_upnp_simple_igd_thread_add_port;
- simple_igd_class->remove_port = fs_upnp_simple_igd_thread_remove_port;
-}
-
-
-static void
-fs_upnp_simple_igd_thread_init (FsUpnpSimpleIgdThread *self)
-{
- self->priv = FS_UPNP_SIMPLE_IGD_THREAD_GET_PRIVATE (self);
-
- self->priv->mutex = g_mutex_new ();
- self->priv->context = g_main_context_new ();
-
- g_object_set (self, "main-context", self->priv->context, NULL);
-}
-
-static gboolean
-main_loop_quit (gpointer user_data)
-{
- GMainLoop *loop = user_data;
-
- g_main_loop_quit (loop);
- return FALSE;
-}
-
-
-static void
-fs_upnp_simple_igd_thread_dispose (GObject *object)
-{
- FsUpnpSimpleIgdThread *self = FS_UPNP_SIMPLE_IGD_THREAD_CAST (object);
-
- FS_UPNP_SIMPLE_IGD_THREAD_LOCK (self);
- if (self->priv->loop)
- {
- GSource *stop_src;
- g_main_loop_ref (self->priv->loop);
- stop_src = g_idle_source_new ();
- g_source_set_priority (stop_src, G_PRIORITY_HIGH);
- g_source_set_callback (stop_src, main_loop_quit, self->priv->loop,
- g_main_loop_unref);
- g_source_attach (stop_src, self->priv->context);
- g_source_unref (stop_src);
- g_main_loop_quit (self->priv->loop);
- }
- self->priv->quit_loop = TRUE;
- FS_UPNP_SIMPLE_IGD_THREAD_UNLOCK (self);
-
- g_thread_join (self->priv->thread);
- self->priv->thread = NULL;
-
- G_OBJECT_CLASS (fs_upnp_simple_igd_thread_parent_class)->dispose (object);
-}
-
-static void
-fs_upnp_simple_igd_thread_finalize (GObject *object)
-{
- FsUpnpSimpleIgdThread *self = FS_UPNP_SIMPLE_IGD_THREAD_CAST (object);
-
- g_main_context_unref (self->priv->context);
- g_mutex_free (self->priv->mutex);
-
- G_OBJECT_CLASS (fs_upnp_simple_igd_thread_parent_class)->finalize (object);
-}
-
-static gpointer
-thread_func (gpointer data)
-{
- FsUpnpSimpleIgdThread *self = data;
- GMainLoop *loop = g_main_loop_new (self->priv->context, FALSE);
- gboolean quit_loop;
-
- FS_UPNP_SIMPLE_IGD_THREAD_LOCK (self);
- self->priv->loop = loop;
- quit_loop = self->priv->quit_loop;
- FS_UPNP_SIMPLE_IGD_THREAD_UNLOCK (self);
-
- if (!quit_loop)
- g_main_loop_run (loop);
-
- FS_UPNP_SIMPLE_IGD_THREAD_LOCK (self);
- self->priv->loop = NULL;
- FS_UPNP_SIMPLE_IGD_THREAD_UNLOCK (self);
-
- g_main_loop_unref (loop);
-
- return NULL;
-}
-
-static void
-fs_upnp_simple_igd_thread_constructed (GObject *object)
-{
- FsUpnpSimpleIgdThread *self = FS_UPNP_SIMPLE_IGD_THREAD_CAST (object);
-
- if (G_OBJECT_CLASS (fs_upnp_simple_igd_thread_parent_class)->constructed)
- G_OBJECT_CLASS (fs_upnp_simple_igd_thread_parent_class)->constructed (object);
-
- self->priv->thread = g_thread_create (thread_func, self, TRUE, NULL);
- g_return_if_fail (self->priv->thread);
-}
-
-struct AddRemovePortData {
- FsUpnpSimpleIgd *self;
- gchar *protocol;
- guint16 external_port;
- gchar *local_ip;
- guint16 local_port;
- guint32 lease_duration;
- gchar *description;
-};
-
-static gboolean
-add_port_idle_func (gpointer user_data)
-{
- struct AddRemovePortData *data = user_data;
- FsUpnpSimpleIgdClass *klass =
- FS_UPNP_SIMPLE_IGD_CLASS (fs_upnp_simple_igd_thread_parent_class);
-
- if (!data->self)
- return FALSE;
-
- if (klass->add_port)
- klass->add_port (data->self, data->protocol, data->external_port,
- data->local_ip, data->local_port, data->lease_duration,
- data->description);
-
- return FALSE;
-}
-
-
-static gboolean
-remove_port_idle_func (gpointer user_data)
-{
- struct AddRemovePortData *data = user_data;
- FsUpnpSimpleIgdClass *klass =
- FS_UPNP_SIMPLE_IGD_CLASS (fs_upnp_simple_igd_thread_parent_class);
-
- if (!data->self)
- return FALSE;
-
- if (klass->remove_port)
- klass->remove_port (data->self, data->protocol, data->external_port);
-
- return FALSE;
-}
-
-static void
-free_add_remove_port_data (gpointer user_data)
-{
- struct AddRemovePortData *data = user_data;
-
- if (data->self)
- g_object_remove_weak_pointer (G_OBJECT (data->self),
- (gpointer*) &data->self);
- g_free (data->protocol);
- g_free (data->local_ip);
- g_free (data->description);
-
- g_slice_free (struct AddRemovePortData, data);
-}
-
-static void
-fs_upnp_simple_igd_thread_add_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description)
-{
- FsUpnpSimpleIgdThread *realself = FS_UPNP_SIMPLE_IGD_THREAD (self);
- struct AddRemovePortData *data = g_slice_new0 (struct AddRemovePortData);
- GSource *source;
-
- data->self = self;
- data->protocol = g_strdup (protocol);
- data->external_port = external_port;
- data->local_ip = g_strdup (local_ip);
- data->local_port = local_port;
- data->lease_duration = lease_duration;
- data->description = g_strdup (description);
-
- source = g_idle_source_new ();
- g_object_add_weak_pointer (G_OBJECT (self), (gpointer*) &data->self);
- g_source_set_callback (source, add_port_idle_func, data,
- free_add_remove_port_data);
- g_source_set_priority (source, G_PRIORITY_DEFAULT);
- g_source_attach (source, realself->priv->context);
- g_source_unref (source);
- g_main_context_wakeup (realself->priv->context);
-}
-
-static void
-fs_upnp_simple_igd_thread_remove_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port)
-{
- FsUpnpSimpleIgdThread *realself = FS_UPNP_SIMPLE_IGD_THREAD (self);
- struct AddRemovePortData *data = g_slice_new0 (struct AddRemovePortData);
- GSource *source;
-
- data->self = self;
- data->protocol = g_strdup (protocol);
- data->external_port = external_port;
-
- source = g_idle_source_new ();
- g_object_add_weak_pointer (G_OBJECT (self), (gpointer*) &data->self);
- g_source_set_callback (source, remove_port_idle_func, data,
- free_add_remove_port_data);
- g_source_set_priority (source, G_PRIORITY_DEFAULT);
- g_source_attach (source, realself->priv->context);
- g_source_unref (source);
- g_main_context_wakeup (realself->priv->context);
-}
-
-
-FsUpnpSimpleIgdThread *
-fs_upnp_simple_igd_thread_new ()
-{
- return g_object_new (FS_TYPE_UPNP_SIMPLE_IGD_THREAD, NULL);
-}
diff --git a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.h b/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.h
deleted file mode 100644
index 9d1386c..0000000
--- a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Farsight2 - Farsight UPnP IGD abstraction
- *
- * Copyright 2008 Collabora Ltd.
- * @author: Olivier Crete <olivier.crete at collabora.co.uk>
- * Copyright 2008 Nokia Corp.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __FS_UPNP_SIMPLE_IGD_THREAD_H__
-#define __FS_UPNP_SIMPLE_IGD_THREAD_H__
-
-#include <ext/fsupnp/fs-upnp-simple-igd.h>
-
-G_BEGIN_DECLS
-
-/* TYPE MACROS */
-#define FS_TYPE_UPNP_SIMPLE_IGD_THREAD \
- (fs_upnp_simple_igd_thread_get_type ())
-#define FS_UPNP_SIMPLE_IGD_THREAD(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_UPNP_SIMPLE_IGD_THREAD, \
- FsUpnpSimpleIgdThread))
-#define FS_UPNP_SIMPLE_IGD_THREAD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_UPNP_SIMPLE_IGD_THREAD, \
- FsUpnpSimpleIgdThreadClass))
-#define FS_IS_UPNP_SIMPLE_IGD_THREAD(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_UPNP_SIMPLE_IGD_THREAD))
-#define FS_IS_UPNP_SIMPLE_IGD_THREAD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_UPNP_SIMPLE_IGD_THREAD))
-#define FS_UPNP_SIMPLE_IGD_THREAD_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_UPNP_SIMPLE_IGD_THREAD, \
- FsUpnpSimpleIgdThreadClass))
-#define FS_UPNP_SIMPLE_IGD_THREAD_CAST(obj) \
- ((FsUpnpSimpleIgdThread *) (obj))
-
-typedef struct _FsUpnpSimpleIgdThread FsUpnpSimpleIgdThread;
-typedef struct _FsUpnpSimpleIgdThreadClass FsUpnpSimpleIgdThreadClass;
-typedef struct _FsUpnpSimpleIgdThreadPrivate FsUpnpSimpleIgdThreadPrivate;
-
-/**
- * FsUpnpSimpleIgdThreadClass:
- * @parent_class: Our parent
- *
- * The Raw UDP component transmitter class
- */
-
-struct _FsUpnpSimpleIgdThreadClass
-{
- FsUpnpSimpleIgdClass parent_class;
-
- /*virtual functions */
- /*< private >*/
-};
-
-/**
- * FsUpnpSimpleIgdThread:
- *
- * All members are private, access them using methods and properties
- */
-struct _FsUpnpSimpleIgdThread
-{
- FsUpnpSimpleIgd parent;
-
- /*< private >*/
- FsUpnpSimpleIgdThreadPrivate *priv;
-};
-
-GType fs_upnp_simple_igd_thread_get_type (void);
-
-FsUpnpSimpleIgdThread *
-fs_upnp_simple_igd_thread_new (void);
-
-G_END_DECLS
-
-#endif /* __FS_UPNP_SIMPLE_IGD_THREAD_H__ */
diff --git a/gst-libs/ext/fsupnp/fs-upnp-simple-igd.c b/gst-libs/ext/fsupnp/fs-upnp-simple-igd.c
deleted file mode 100644
index b93e0e7..0000000
--- a/gst-libs/ext/fsupnp/fs-upnp-simple-igd.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*
- * Farsight2 - Farsight UPnP IGD abstraction
- *
- * Copyright 2008 Collabora Ltd.
- * @author: Olivier Crete <olivier.crete at collabora.co.uk>
- * Copyright 2008 Nokia Corp.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include "fs-upnp-simple-igd.h"
-#include "fs-upnp-simple-igd-marshal.h"
-
-#include <string.h>
-
-#include <libgupnp/gupnp-control-point.h>
-
-
-struct _FsUpnpSimpleIgdPrivate
-{
- GMainContext *main_context;
-
- GUPnPContext *gupnp_context;
- GUPnPControlPoint *cp;
-
- GPtrArray *service_proxies;
-
- GPtrArray *mappings;
-
- gulong avail_handler;
- gulong unavail_handler;
-
- guint request_timeout;
-};
-
-struct Proxy {
- FsUpnpSimpleIgd *parent;
- GUPnPServiceProxy *proxy;
-
- gchar *external_ip;
- GUPnPServiceProxyAction *external_ip_action;
- gboolean external_ip_failed;
-
- GPtrArray *proxymappings;
-};
-
-struct Mapping {
- gchar *protocol;
- guint external_port;
- gchar *local_ip;
- guint16 local_port;
- guint32 lease_duration;
- gchar *description;
-};
-
-struct ProxyMapping {
- struct Proxy *proxy;
- struct Mapping *mapping;
-
- GUPnPServiceProxyAction *action;
- GSource *timeout_src;
-
- gboolean mapped;
-
- GSource *renew_src;
-};
-
-/* signals */
-enum
-{
- SIGNAL_MAPPED_EXTERNAL_PORT,
- SIGNAL_ERROR_MAPPING_PORT,
- LAST_SIGNAL
-};
-
-/* props */
-enum
-{
- PROP_0,
- PROP_REQUEST_TIMEOUT,
- PROP_MAIN_CONTEXT
-};
-
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-
-#define FS_UPNP_SIMPLE_IGD_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_UPNP_SIMPLE_IGD, \
- FsUpnpSimpleIgdPrivate))
-
-
-G_DEFINE_TYPE (FsUpnpSimpleIgd, fs_upnp_simple_igd, G_TYPE_OBJECT);
-
-
-static void fs_upnp_simple_igd_constructed (GObject *object);
-static void fs_upnp_simple_igd_dispose (GObject *object);
-static void fs_upnp_simple_igd_finalize (GObject *object);
-static void fs_upnp_simple_igd_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static void fs_upnp_simple_igd_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-
-static void fs_upnp_simple_igd_gather (FsUpnpSimpleIgd *self,
- struct Proxy *prox);
-static void fs_upnp_simple_igd_add_proxy_mapping (FsUpnpSimpleIgd *self,
- struct Proxy *prox,
- struct Mapping *mapping);
-
-static void free_proxy (struct Proxy *prox);
-static void free_mapping (struct Mapping *mapping);
-
-static void stop_proxymapping (struct ProxyMapping *pm);
-
-static void fs_upnp_simple_igd_add_port_real (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description);
-static void fs_upnp_simple_igd_remove_port_real (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port);
-
-GQuark
-fs_upnp_simple_igd_get_error_domain (void)
-{
- return g_quark_from_static_string ("fs-upnp-simple-igd-error");
-}
-
-
-static void
-fs_upnp_simple_igd_class_init (FsUpnpSimpleIgdClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (FsUpnpSimpleIgdPrivate));
-
- gobject_class->constructed = fs_upnp_simple_igd_constructed;
- gobject_class->dispose = fs_upnp_simple_igd_dispose;
- gobject_class->finalize = fs_upnp_simple_igd_finalize;
- gobject_class->set_property = fs_upnp_simple_igd_set_property;
- gobject_class->get_property = fs_upnp_simple_igd_get_property;
-
- klass->add_port = fs_upnp_simple_igd_add_port_real;
- klass->remove_port = fs_upnp_simple_igd_remove_port_real;
-
- g_object_class_install_property (gobject_class,
- PROP_REQUEST_TIMEOUT,
- g_param_spec_uint ("request-timeout",
- "The timeout after which a request is considered to have failed",
- "After this timeout, the request is considered to have failed and"
- "is dropped (in seconds).",
- 0, G_MAXUINT, 5,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
- PROP_MAIN_CONTEXT,
- g_param_spec_pointer ("main-context",
- "The GMainContext to use",
- "This GMainContext will be used for all async activities",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- /**
- * FsUpnpSimpleIgd::mapped-external-port
- * @self: #FsUpnpSimpleIgd that emitted the signal
- * @proto: the requested protocol ("UDP" or "TCP")
- * @external_ip: the external IP
- * @replaces_external_ip: if this mapping replaces another mapping,
- * this is the old external IP
- * @external_port: the external port
- * @local_ip: internal ip this is forwarded to
- * @local_port: the local port
- * @description: the user's selected description
- *
- * This signal means that an IGD has been found that that adding a port
- * mapping has succeeded.
- *
- */
- signals[SIGNAL_MAPPED_EXTERNAL_PORT] = g_signal_new ("mapped-external-port",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL,
- NULL,
- _fs_upnp_simple_igd_marshal_VOID__STRING_STRING_STRING_UINT_STRING_UINT_STRING,
- G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT,
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
-
- /**
- * FsUpnpSimpleIgd::error-mapping-port
- * @self: #FsUpnpSimpleIgd that emitted the signal
- * @error: a #GError
- * @proto: The requested protocol
- * @external_port: the requested external port
- * @description: the passed description
- *
- * This means that mapping a port on a specific IGD has failed (it may still
- * succeed on other IGDs on the network).
- */
- signals[SIGNAL_ERROR_MAPPING_PORT] = g_signal_new ("error-mapping-port",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL,
- NULL,
- _fs_upnp_simple_igd_marshal_VOID__POINTER_STRING_UINT_STRING,
- G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_UINT,
- G_TYPE_STRING);
-}
-
-static void
-fs_upnp_simple_igd_init (FsUpnpSimpleIgd *self)
-{
- self->priv = FS_UPNP_SIMPLE_IGD_GET_PRIVATE (self);
-
- self->priv->request_timeout = 5;
-
- self->priv->service_proxies = g_ptr_array_new ();
- self->priv->mappings = g_ptr_array_new ();
-}
-
-static void
-fs_upnp_simple_igd_dispose (GObject *object)
-{
- FsUpnpSimpleIgd *self = FS_UPNP_SIMPLE_IGD_CAST (object);
-
- if (self->priv->avail_handler)
- g_signal_handler_disconnect (self->priv->cp, self->priv->avail_handler);
- self->priv->avail_handler = 0;
-
- if (self->priv->unavail_handler)
- g_signal_handler_disconnect (self->priv->cp, self->priv->unavail_handler);
- self->priv->unavail_handler = 0;
-
- while (self->priv->mappings->len)
- {
- free_mapping (
- g_ptr_array_index (self->priv->mappings, 0));
- g_ptr_array_remove_index_fast (self->priv->mappings, 0);
- }
-
- while (self->priv->service_proxies->len)
- {
- free_proxy (
- g_ptr_array_index (self->priv->service_proxies, 0));
- g_ptr_array_remove_index_fast (self->priv->service_proxies, 0);
- }
-
- if (self->priv->cp)
- g_object_unref (self->priv->cp);
- self->priv->cp = NULL;
-
- if (self->priv->gupnp_context)
- g_object_unref (self->priv->gupnp_context);
- self->priv->gupnp_context = NULL;
-
- G_OBJECT_CLASS (fs_upnp_simple_igd_parent_class)->dispose (object);
-}
-
-
-static void
-_external_ip_address_changed (GUPnPServiceProxy *proxy, const gchar *variable,
- GValue *value, gpointer user_data)
-{
- struct Proxy *prox = user_data;
- gchar *new_ip;
- guint i;
-
- g_return_if_fail (G_VALUE_HOLDS_STRING(value));
-
- new_ip = g_value_dup_string (value);
-
- for (i=0; i < prox->proxymappings->len; i++)
- {
- struct ProxyMapping *pm = g_ptr_array_index (prox->proxymappings, i);
-
- if (pm->mapped)
- g_signal_emit (prox->parent, signals[SIGNAL_MAPPED_EXTERNAL_PORT], 0,
- pm->mapping->protocol, new_ip, prox->external_ip,
- pm->mapping->external_port, pm->mapping->local_ip,
- pm->mapping->local_port, pm->mapping->description);
- }
-
- g_free (prox->external_ip);
- prox->external_ip = new_ip;
-}
-
-static void
-free_proxymapping (struct ProxyMapping *pm)
-{
- g_slice_free (struct ProxyMapping, pm);
-}
-
-static void
-free_proxy (struct Proxy *prox)
-{
- if (prox->external_ip_action)
- gupnp_service_proxy_cancel_action (prox->proxy, prox->external_ip_action);
-
- gupnp_service_proxy_remove_notify (prox->proxy, "ExternalIPAddress",
- _external_ip_address_changed, prox);
-
- g_object_unref (prox->proxy);
- g_ptr_array_foreach (prox->proxymappings, (GFunc) stop_proxymapping, NULL);
- g_ptr_array_foreach (prox->proxymappings, (GFunc) free_proxymapping, NULL);
- g_ptr_array_free (prox->proxymappings, TRUE);
- g_free (prox->external_ip);
- g_slice_free (struct Proxy, prox);
-}
-
-static void
-free_mapping (struct Mapping *mapping)
-{
- g_free (mapping->protocol);
- g_free (mapping->local_ip);
- g_free (mapping->description);
- g_slice_free (struct Mapping, mapping);
-}
-
-static void
-fs_upnp_simple_igd_finalize (GObject *object)
-{
- FsUpnpSimpleIgd *self = FS_UPNP_SIMPLE_IGD_CAST (object);
-
- g_main_context_unref (self->priv->main_context);
-
- g_warn_if_fail (self->priv->service_proxies->len == 0);
- g_ptr_array_free (self->priv->service_proxies, TRUE);
-
- g_warn_if_fail (self->priv->mappings->len == 0);
- g_ptr_array_free (self->priv->mappings, TRUE);
-
- G_OBJECT_CLASS (fs_upnp_simple_igd_parent_class)->finalize (object);
-}
-
-static void
-fs_upnp_simple_igd_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- FsUpnpSimpleIgd *self = FS_UPNP_SIMPLE_IGD_CAST (object);
-
- switch (prop_id) {
- case PROP_REQUEST_TIMEOUT:
- g_value_set_uint (value, self->priv->request_timeout);
- break;
- case PROP_MAIN_CONTEXT:
- g_value_set_pointer (value, self->priv->main_context);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-fs_upnp_simple_igd_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- FsUpnpSimpleIgd *self = FS_UPNP_SIMPLE_IGD_CAST (object);
-
- switch (prop_id) {
- case PROP_REQUEST_TIMEOUT:
- self->priv->request_timeout = g_value_get_uint (value);
- break;
- case PROP_MAIN_CONTEXT:
- if (!self->priv->main_context && g_value_get_pointer (value))
- {
- self->priv->main_context = g_value_get_pointer (value);
- g_main_context_ref (self->priv->main_context);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-_cp_service_avail (GUPnPControlPoint *cp,
- GUPnPServiceProxy *proxy,
- FsUpnpSimpleIgd *self)
-{
- struct Proxy *prox = g_slice_new0 (struct Proxy);
- guint i;
-
- prox->parent = self;
- prox->proxy = g_object_ref (proxy);
- prox->proxymappings = g_ptr_array_new ();
-
- fs_upnp_simple_igd_gather (self, prox);
-
- for (i = 0; i < self->priv->mappings->len; i++)
- fs_upnp_simple_igd_add_proxy_mapping (self, prox,
- g_ptr_array_index (self->priv->mappings, i));
-
- g_ptr_array_add(self->priv->service_proxies, prox);
-}
-
-
-static void
-_cp_service_unavail (GUPnPControlPoint *cp,
- GUPnPServiceProxy *proxy,
- FsUpnpSimpleIgd *self)
-{
- guint i;
-
- for (i=0; i < self->priv->service_proxies->len; i++)
- {
- struct Proxy *prox =
- g_ptr_array_index (self->priv->service_proxies, i);
-
- if (!strcmp (gupnp_service_info_get_udn (GUPNP_SERVICE_INFO (prox->proxy)),
- gupnp_service_info_get_udn (GUPNP_SERVICE_INFO (prox->proxy))))
- {
- g_ptr_array_foreach (prox->proxymappings, (GFunc) stop_proxymapping,
- NULL);
- g_ptr_array_foreach (prox->proxymappings, (GFunc) free_proxymapping,
- NULL);
- free_proxy (prox);
- g_ptr_array_remove_index_fast (self->priv->service_proxies, i);
- break;
- }
- }
-}
-
-
-static void
-fs_upnp_simple_igd_constructed (GObject *object)
-{
- FsUpnpSimpleIgd *self = FS_UPNP_SIMPLE_IGD_CAST (object);
-
- if (!self->priv->main_context)
- self->priv->main_context = g_main_context_ref (g_main_context_default ());
-
- self->priv->gupnp_context = gupnp_context_new (self->priv->main_context,
- NULL, 0, NULL);
- g_return_if_fail (self->priv->gupnp_context);
-
- self->priv->cp = gupnp_control_point_new (self->priv->gupnp_context,
- "urn:schemas-upnp-org:service:WANIPConnection:1");
- g_return_if_fail (self->priv->cp);
-
- self->priv->avail_handler = g_signal_connect (self->priv->cp,
- "service-proxy-available",
- G_CALLBACK (_cp_service_avail), self);
- self->priv->unavail_handler = g_signal_connect (self->priv->cp,
- "service-proxy-unavailable",
- G_CALLBACK (_cp_service_unavail), self);
-
- gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (self->priv->cp),
- TRUE);
-
- if (G_OBJECT_CLASS (fs_upnp_simple_igd_parent_class)->constructed)
- G_OBJECT_CLASS (fs_upnp_simple_igd_parent_class)->constructed (object);
-}
-
-FsUpnpSimpleIgd *
-fs_upnp_simple_igd_new (GMainContext *main_context)
-{
- return g_object_new (FS_TYPE_UPNP_SIMPLE_IGD,
- "main-context", main_context, NULL);
-}
-
-
-static void
-_service_proxy_got_external_ip_address (GUPnPServiceProxy *proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
-{
- struct Proxy *prox = user_data;
- FsUpnpSimpleIgd *self = prox->parent;
- GError *error = NULL;
- gchar *ip = NULL;
-
- g_return_if_fail (prox->external_ip_action == action);
-
- prox->external_ip_action = NULL;
-
- if (gupnp_service_proxy_end_action (proxy, action, &error,
- "NewExternalIPAddress", G_TYPE_STRING, &ip,
- NULL))
- {
- guint i;
-
- for (i=0; i < prox->proxymappings->len; i++)
- {
- struct ProxyMapping *pm = g_ptr_array_index (prox->proxymappings, i);
-
- if (pm->mapped)
- g_signal_emit (self, signals[SIGNAL_MAPPED_EXTERNAL_PORT], 0,
- pm->mapping->protocol, ip, prox->external_ip,
- pm->mapping->external_port, pm->mapping->local_ip,
- pm->mapping->local_port, pm->mapping->description);
- }
-
- g_free (prox->external_ip);
- prox->external_ip = ip;
- }
- else
- {
- guint i;
-
- prox->external_ip_failed = TRUE;
- g_return_if_fail (error);
-
- for (i=0; i < prox->proxymappings->len; i++)
- {
- struct ProxyMapping *pm = g_ptr_array_index (prox->proxymappings, i);
-
- g_signal_emit (self, signals[SIGNAL_ERROR_MAPPING_PORT], error->domain,
- error, pm->mapping->protocol, pm->mapping->external_port,
- pm->mapping->description);
- }
- }
- g_clear_error (&error);
-}
-
-static void
-fs_upnp_simple_igd_gather (FsUpnpSimpleIgd *self,
- struct Proxy *prox)
-{
- prox->external_ip_action = gupnp_service_proxy_begin_action (prox->proxy,
- "GetExternalIPAddress",
- _service_proxy_got_external_ip_address, prox, NULL);
-
- gupnp_service_proxy_add_notify (prox->proxy, "ExternalIPAddress",
- G_TYPE_STRING, _external_ip_address_changed, prox);
-
- gupnp_service_proxy_set_subscribed (prox->proxy, TRUE);
-}
-
-static void
-_service_proxy_renewed_port_mapping (GUPnPServiceProxy *proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
-{
- struct ProxyMapping *pm = user_data;
- FsUpnpSimpleIgd *self = pm->proxy->parent;
- GError *error = NULL;
-
- if (!gupnp_service_proxy_end_action (proxy, action, &error,
- NULL))
- {
- g_return_if_fail (error);
- g_signal_emit (self, signals[SIGNAL_ERROR_MAPPING_PORT], error->domain,
- error, pm->mapping->protocol, pm->mapping->external_port,
- pm->mapping->description);
- }
- g_clear_error (&error);
-}
-
-static gboolean
-_renew_mapping_timeout (gpointer user_data)
-{
- struct ProxyMapping *pm = user_data;
-
- gupnp_service_proxy_begin_action (pm->proxy->proxy,
- "AddPortMapping",
- _service_proxy_renewed_port_mapping, pm,
- "NewRemoteHost", G_TYPE_STRING, "",
- "NewExternalPort", G_TYPE_UINT, pm->mapping->external_port,
- "NewProtocol", G_TYPE_STRING, pm->mapping->protocol,
- "NewInternalPort", G_TYPE_UINT, pm->mapping->local_port,
- "NewInternalClient", G_TYPE_STRING, pm->mapping->local_ip,
- "NewEnabled", G_TYPE_BOOLEAN, TRUE,
- "NewPortMappingDescription", G_TYPE_STRING, pm->mapping->description,
- "NewLeaseDuration", G_TYPE_UINT, pm->mapping->lease_duration,
- NULL);
-
- return TRUE;
-}
-
-static void
-_service_proxy_added_port_mapping (GUPnPServiceProxy *proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
-{
- struct ProxyMapping *pm = user_data;
- FsUpnpSimpleIgd *self = pm->proxy->parent;
- GError *error = NULL;
-
- g_return_if_fail (pm->action == action);
-
- pm->action = NULL;
-
- if (gupnp_service_proxy_end_action (proxy, action, &error,
- NULL))
- {
- pm->mapped = TRUE;
-
- if (pm->proxy->external_ip)
- g_signal_emit (self, signals[SIGNAL_MAPPED_EXTERNAL_PORT], 0,
- pm->mapping->protocol, pm->proxy->external_ip, NULL,
- pm->mapping->external_port, pm->mapping->local_ip,
- pm->mapping->local_port, pm->mapping->description);
-
-
-
- pm->renew_src =
- g_timeout_source_new_seconds (pm->mapping->lease_duration / 2);
- g_source_set_callback (pm->renew_src,
- _renew_mapping_timeout, pm, NULL);
- g_source_attach (pm->renew_src, self->priv->main_context);
-
- }
- else
- {
- g_return_if_fail (error);
- g_signal_emit (self, signals[SIGNAL_ERROR_MAPPING_PORT], error->domain,
- error, pm->mapping->protocol, pm->mapping->external_port,
- pm->mapping->description);
- }
- g_clear_error (&error);
-
- stop_proxymapping (pm);
-}
-
-static gboolean
-_service_proxy_add_mapping_timeout (gpointer user_data)
-{
- struct ProxyMapping *pm = user_data;
- FsUpnpSimpleIgd *self = pm->proxy->parent;
- const GError error = {FS_UPNP_SIMPLE_IGD_ERROR,
- FS_UPNP_SIMPLE_IGD_ERROR_TIMEOUT,
- "Timeout while mapping port"};
-
- stop_proxymapping (pm);
-
- g_signal_emit (self, signals[SIGNAL_ERROR_MAPPING_PORT],
- FS_UPNP_SIMPLE_IGD_ERROR, &error,
- pm->mapping->protocol, pm->mapping->external_port,
- pm->mapping->description);
-
- return FALSE;
-}
-
-static void
-fs_upnp_simple_igd_add_proxy_mapping (FsUpnpSimpleIgd *self, struct Proxy *prox,
- struct Mapping *mapping)
-{
- struct ProxyMapping *pm = g_slice_new0 (struct ProxyMapping);
-
- pm->proxy = prox;
- pm->mapping = mapping;
-
- pm->action = gupnp_service_proxy_begin_action (prox->proxy,
- "AddPortMapping",
- _service_proxy_added_port_mapping, pm,
- "NewRemoteHost", G_TYPE_STRING, "",
- "NewExternalPort", G_TYPE_UINT, mapping->external_port,
- "NewProtocol", G_TYPE_STRING, mapping->protocol,
- "NewInternalPort", G_TYPE_UINT, mapping->local_port,
- "NewInternalClient", G_TYPE_STRING, mapping->local_ip,
- "NewEnabled", G_TYPE_BOOLEAN, TRUE,
- "NewPortMappingDescription", G_TYPE_STRING, mapping->description,
- "NewLeaseDuration", G_TYPE_UINT, mapping->lease_duration,
- NULL);
-
- pm->timeout_src =
- g_timeout_source_new_seconds (self->priv->request_timeout);
- g_source_set_callback (pm->timeout_src,
- _service_proxy_add_mapping_timeout, pm, NULL);
- g_source_attach (pm->timeout_src, self->priv->main_context);
-
- g_ptr_array_add (prox->proxymappings, pm);
-}
-
-static void
-fs_upnp_simple_igd_add_port_real (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description)
-{
- struct Mapping *mapping = g_slice_new0 (struct Mapping);
- guint i;
-
- g_return_if_fail (protocol && local_ip);
- g_return_if_fail (!strcmp (protocol, "UDP") || !strcmp (protocol, "TCP"));
-
- mapping->protocol = g_strdup (protocol);
- mapping->external_port = external_port;
- mapping->local_ip = g_strdup (local_ip);
- mapping->local_port = local_port;
- mapping->lease_duration = lease_duration;
- mapping->description = g_strdup (description);
-
- if (!mapping->description)
- mapping->description = g_strdup ("");
-
- g_ptr_array_add (self->priv->mappings, mapping);
-
- for (i=0; i < self->priv->service_proxies->len; i++)
- {
- struct Proxy *prox = g_ptr_array_index (self->priv->service_proxies, i);
-
- if (prox->external_ip_failed)
- {
- GError error = {FS_UPNP_SIMPLE_IGD_ERROR,
- FS_UPNP_SIMPLE_IGD_ERROR_EXTERNAL_ADDRESS,
- "Could not get external address"};
- g_signal_emit (self, signals[SIGNAL_ERROR_MAPPING_PORT],
- FS_UPNP_SIMPLE_IGD_ERROR,
- &error, mapping->protocol, mapping->external_port,
- mapping->description);
- }
- else
- {
- fs_upnp_simple_igd_add_proxy_mapping (self, prox, mapping);
- }
- }
-}
-
-void
-fs_upnp_simple_igd_add_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description)
-{
- FsUpnpSimpleIgdClass *klass = FS_UPNP_SIMPLE_IGD_GET_CLASS (self);
-
- g_return_if_fail (klass->add_port);
-
- klass->add_port (self, protocol, external_port, local_ip, local_port,
- lease_duration, description);
-}
-
-
-static void
-_service_proxy_delete_port_mapping (GUPnPServiceProxy *proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
-{
- GError *error = NULL;
-
-
- if (!gupnp_service_proxy_end_action (proxy, action, &error,
- NULL))
- {
- g_return_if_fail (error);
- g_warning ("Error deleting port mapping: %s", error->message);
- }
- g_clear_error (&error);
-}
-
-static void
-fs_upnp_simple_igd_remove_port_real (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port)
-{
- guint i, j;
- struct Mapping *mapping;
-
- g_return_if_fail (protocol);
-
- for (i = 0; i < self->priv->mappings->len; i++)
- {
- struct Mapping *tmpmapping = g_ptr_array_index (self->priv->mappings, i);
- if (tmpmapping->external_port == external_port &&
- !strcmp (tmpmapping->protocol, protocol))
- {
- mapping = tmpmapping;
- break;
- }
- }
- g_return_if_fail (mapping);
-
- g_ptr_array_remove_index_fast (self->priv->mappings, i);
-
- for (i=0; i < self->priv->service_proxies->len; i++)
- {
- struct Proxy *prox = g_ptr_array_index (self->priv->service_proxies, i);
-
- for (j=0; j < prox->proxymappings->len; j++)
- {
- struct ProxyMapping *pm = g_ptr_array_index (prox->proxymappings, j);
- if (pm->mapping == mapping)
- {
- stop_proxymapping (pm);
-
- if (pm->renew_src)
- {
- g_source_destroy (pm->renew_src);
- g_source_unref (pm->renew_src);
- }
- pm->renew_src = NULL;
-
- if (pm->mapped)
- gupnp_service_proxy_begin_action (prox->proxy,
- "DeletePortMapping",
- _service_proxy_delete_port_mapping, self,
- "NewRemoteHost", G_TYPE_STRING, "",
- "NewExternalPort", G_TYPE_UINT, mapping->external_port,
- "NewProtocol", G_TYPE_STRING, mapping->protocol,
- NULL);
-
- free_proxymapping (pm);
- g_ptr_array_remove_index_fast (prox->proxymappings, j);
- j--;
- }
- }
- }
-
- free_mapping (mapping);
-}
-
-void
-fs_upnp_simple_igd_remove_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port)
-{
- FsUpnpSimpleIgdClass *klass = FS_UPNP_SIMPLE_IGD_GET_CLASS (self);
-
- g_return_if_fail (klass->remove_port);
-
- klass->remove_port (self, protocol, external_port);
-}
-
-static void
-stop_proxymapping (struct ProxyMapping *pm)
-{
- if (pm->action)
- gupnp_service_proxy_cancel_action (pm->proxy->proxy,
- pm->action);
- pm->action = NULL;
-
- if (pm->timeout_src)
- {
- g_source_destroy (pm->timeout_src);
- g_source_unref (pm->timeout_src);
- }
- pm->timeout_src = NULL;
-}
diff --git a/gst-libs/ext/fsupnp/fs-upnp-simple-igd.h b/gst-libs/ext/fsupnp/fs-upnp-simple-igd.h
deleted file mode 100644
index 3f6dc7e..0000000
--- a/gst-libs/ext/fsupnp/fs-upnp-simple-igd.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Farsight2 - Farsight UPnP IGD abstraction
- *
- * Copyright 2008 Collabora Ltd.
- * @author: Olivier Crete <olivier.crete at collabora.co.uk>
- * Copyright 2008 Nokia Corp.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __FS_UPNP_SIMPLE_IGD_H__
-#define __FS_UPNP_SIMPLE_IGD_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/* TYPE MACROS */
-#define FS_TYPE_UPNP_SIMPLE_IGD \
- (fs_upnp_simple_igd_get_type ())
-#define FS_UPNP_SIMPLE_IGD(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_UPNP_SIMPLE_IGD, \
- FsUpnpSimpleIgd))
-#define FS_UPNP_SIMPLE_IGD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_UPNP_SIMPLE_IGD, \
- FsUpnpSimpleIgdClass))
-#define FS_IS_UPNP_SIMPLE_IGD(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_UPNP_SIMPLE_IGD))
-#define FS_IS_UPNP_SIMPLE_IGD_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_UPNP_SIMPLE_IGD))
-#define FS_UPNP_SIMPLE_IGD_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_UPNP_SIMPLE_IGD, \
- FsUpnpSimpleIgdClass))
-#define FS_UPNP_SIMPLE_IGD_CAST(obj) \
- ((FsUpnpSimpleIgd *) (obj))
-
-typedef struct _FsUpnpSimpleIgd FsUpnpSimpleIgd;
-typedef struct _FsUpnpSimpleIgdClass FsUpnpSimpleIgdClass;
-typedef struct _FsUpnpSimpleIgdPrivate FsUpnpSimpleIgdPrivate;
-
-/**
- * FsUpnpSimpleIgdClass:
- * @parent_class: Our parent
- *
- * The Raw UDP component transmitter class
- */
-
-struct _FsUpnpSimpleIgdClass
-{
- GObjectClass parent_class;
-
- /*virtual functions */
-
- void (*add_port) (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description);
-
- void (*remove_port) (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port);
-
- /*< private >*/
-};
-
-/**
- * FsUpnpSimpleIgd:
- *
- * All members are private, access them using methods and properties
- */
-struct _FsUpnpSimpleIgd
-{
- GObject parent;
-
- /*< private >*/
- FsUpnpSimpleIgdPrivate *priv;
-};
-
-#define FS_UPNP_SIMPLE_IGD_ERROR (fs_upnp_simple_igd_get_error_domain ())
-
-typedef enum {
- FS_UPNP_SIMPLE_IGD_ERROR_EXTERNAL_ADDRESS,
- FS_UPNP_SIMPLE_IGD_ERROR_TIMEOUT
-} FsUpnpSimpleIgdError;
-
-GQuark fs_upnp_simple_igd_get_error_domain (void);
-
-GType fs_upnp_simple_igd_get_type (void);
-
-FsUpnpSimpleIgd *
-fs_upnp_simple_igd_new (GMainContext *context);
-
-void
-fs_upnp_simple_igd_add_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint16 external_port,
- const gchar *local_ip,
- guint16 local_port,
- guint32 lease_duration,
- const gchar *description);
-
-void
-fs_upnp_simple_igd_remove_port (FsUpnpSimpleIgd *self,
- const gchar *protocol,
- guint external_port);
-
-G_END_DECLS
-
-#endif /* __FS_UPNP_SIMPLE_IGD_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 90d87e4..5a2161a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,10 +4,6 @@ if HAVE_GST_CHECK
SUBDIRS_CHECK += check
endif
-if HAVE_GUPNP
-SUBDIRS_CHECK += upnp
-endif
-
SUBDIRS = $(SUBDIRS_CHECK) rtp gui commandline
-DIST_SUBDIRS = check rtp gui commandline upnp
+DIST_SUBDIRS = check rtp gui commandline
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index b0d7a10..7b342e8 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -41,11 +41,6 @@ check_PROGRAMS = \
rtp/conference \
utils/binadded
-if HAVE_GUPNP
-check_PROGRAMS += upnp/fsupnp
-endif
-
-
AM_CFLAGS = \
$(CFLAGS) \
$(FS2_INTERNAL_CFLAGS) \
@@ -100,16 +95,3 @@ rtp_sendcodecs_SOURCES = \
utils_binadded_CFLAGS = $(AM_CFLAGS)
utils_binadded_SOURCES = \
utils/binadded.c
-
-if HAVE_GUPNP
-
-upnp_fsupnp_CFLAGS = $(AM_CFLAGS) $(GUPNP_CFLAGS)
-upnp_fsupnp_LDADD = $(LDADD) \
- $(GUPNP_LIBS) \
- $(top_builddir)/gst-libs/ext/fsupnp/libfsupnp.la
-
-endif
-
-
-upnp_fsupnp_SOURCES = \
- upnp/fsupnp.c
diff --git a/tests/check/upnp/InternetGatewayDevice.xml b/tests/check/upnp/InternetGatewayDevice.xml
deleted file mode 100644
index 7fb34c9..0000000
--- a/tests/check/upnp/InternetGatewayDevice.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0"?>
-<root xmlns="urn:schemas-upnp-org:device-1-0">
- <specVersion>
- <major>1</major>
- <minor>0</minor>
- </specVersion>
- <device>
- <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
- <friendlyName>short user-friendly title</friendlyName>
- <manufacturer>manufacturer name</manufacturer>
- <manufacturerURL>URL to manufacturer site</manufacturerURL>
- <modelDescription>long user-friendly title</modelDescription>
- <modelName>model name</modelName>
- <modelNumber>model number</modelNumber>
- <modelURL>URL to model site</modelURL>
- <serialNumber>manufacturer's serial number</serialNumber>
- <UDN>uuid:UUID1</UDN>
- <UPC>Universal Product Code</UPC>
- <deviceList>
- <device>
- <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
- <friendlyName>short user-friendly title</friendlyName>
- <manufacturer>manufacturer name</manufacturer>
- <manufacturerURL>URL to manufacturer site</manufacturerURL>
- <modelDescription>long user-friendly title</modelDescription>
- <modelName>model name</modelName>
- <modelNumber>model number</modelNumber>
- <modelURL>URL to model site</modelURL>
- <serialNumber>manufacturer's serial number</serialNumber>
- <UDN>uuid:UUID2</UDN>
- <UPC>Universal Product Code</UPC>
- <deviceList>
- <device>
- <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
- <friendlyName>short user-friendly title</friendlyName>
- <manufacturer>manufacturer name</manufacturer>
- <manufacturerURL>URL to manufacturer site</manufacturerURL>
- <modelDescription>long user-friendly title</modelDescription>
- <modelName>model name</modelName>
- <modelNumber>model number</modelNumber>
- <modelURL>URL to model site</modelURL>
- <serialNumber>manufacturer's serial number</serialNumber>
- <UDN>uuid:UUID3</UDN>
- <UPC>Universal Product Code</UPC>
- <serviceList>
- <service>
- <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
- <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
- <SCPDURL>/WANIPConnection.xml</SCPDURL>
- <controlURL>/WANIPConnection/Control</controlURL>
- <eventSubURL>/WANIPConnection/Event</eventSubURL>
- </service>
- </serviceList>
- </device>
- </deviceList>
-</device>
-
- </deviceList>
- </device>
-</root>
diff --git a/tests/check/upnp/WANIPConnection.xml b/tests/check/upnp/WANIPConnection.xml
deleted file mode 100644
index 40a6d33..0000000
--- a/tests/check/upnp/WANIPConnection.xml
+++ /dev/null
@@ -1,421 +0,0 @@
-<?xml version="1.0"?>
-<scpd xmlns="urn:schemas-upnp-org:service-1-0">
- <specVersion>
- <major>1</major>
- <minor>0</minor>
- </specVersion>
- <actionList>
- <action>
- <name>SetConnectionType</name>
- <argumentList>
- <argument>
- <name>NewConnectionType</name>
- <direction>in</direction>
- <relatedStateVariable>ConnectionType</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>GetConnectionTypeInfo</name>
- <argumentList>
- <argument>
- <name>NewConnectionType</name>
- <direction>out</direction>
- <relatedStateVariable>ConnectionType</relatedStateVariable>
- </argument>
- <argument>
- <name>NewPossibleConnectionTypes</name>
- <direction>out</direction>
-<relatedStateVariable>PossibleConnectionTypes</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>RequestConnection</name>
- </action>
- <action>
- <name>RequestTermination</name>
- </action>
- <action>
- <name>ForceTermination</name>
- </action>
- <action>
- <name>SetAutoDisconnectTime</name>
- <argumentList>
- <argument>
- <name>NewAutoDisconnectTime</name>
- <direction>in</direction>
- <relatedStateVariable>AutoDisconnectTime</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>SetIdleDisconnectTime</name>
- <argumentList>
- <argument>
- <name>NewIdleDisconnectTime</name>
- <direction>in</direction>
- <relatedStateVariable>IdleDisconnectTime</relatedStateVariable>
- </argument>
- </argumentList>
-</action>
-<action>
-<name>SetWarnDisconnectDelay</name>
- <argumentList>
- <argument>
- <name>NewWarnDisconnectDelay</name>
- <direction>in</direction>
- <relatedStateVariable>WarnDisconnectDelay</relatedStateVariable>
- </argument>
- </argumentList>
-</action>
-<action>
-<name>GetStatusInfo</name>
- <argumentList>
- <argument>
- <name>NewConnectionStatus</name>
- <direction>out</direction>
- <relatedStateVariable>ConnectionStatus</relatedStateVariable>
- </argument>
- <argument>
- <name>NewLastConnectionError</name>
- <direction>out</direction>
- <relatedStateVariable>LastConnectionError</relatedStateVariable>
- </argument>
- <argument>
- <name>NewUptime</name>
- <direction>out</direction>
- <relatedStateVariable>Uptime</relatedStateVariable>
- </argument>
- </argumentList>
-</action>
-<action>
-<name>GetAutoDisconnectTime</name>
- <argumentList>
- <argument>
- <name>NewAutoDisconnectTime</name>
- <direction>out</direction>
- <relatedStateVariable>AutoDisconnectTime</relatedStateVariable>
- </argument>
- </argumentList>
-</action>
-<action>
-<name>GetIdleDisconnectTime</name>
- <argumentList>
- <argument>
- <name>NewIdleDisconnectTime</name>
- <direction>out</direction>
- <relatedStateVariable>IdleDisconnectTime</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>GetWarnDisconnectDelay</name>
- <argumentList>
- <argument>
- <name>NewWarnDisconnectDelay</name>
- <direction>out</direction>
- <relatedStateVariable>WarnDisconnectDelay</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>GetNATRSIPStatus</name>
- <argumentList>
- <argument>
- <name>NewRSIPAvailable</name>
- <direction>out</direction>
- <relatedStateVariable>RSIPAvailable</relatedStateVariable>
- </argument>
- <argument>
- <name>NewNATEnabled</name>
- <direction>out</direction>
- <relatedStateVariable>NATEnabled</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>GetGenericPortMappingEntry</name>
- <argumentList>
- <argument>
- <name>NewPortMappingIndex</name>
- <direction>in</direction>
-<relatedStateVariable>PortMappingNumberOfEntries</relatedStateVariable>
- </argument>
- <argument>
- <name>NewRemoteHost</name>
- <direction>out</direction>
- <relatedStateVariable>RemoteHost</relatedStateVariable>
- </argument>
- <argument>
- <name>NewExternalPort</name>
- <direction>out</direction>
- <relatedStateVariable>ExternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewProtocol</name>
- <direction>out</direction>
- <relatedStateVariable>PortMappingProtocol</relatedStateVariable>
- </argument>
- <argument>
- <name>NewInternalPort</name>
- <direction>out</direction>
- <relatedStateVariable>InternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewInternalClient</name>
- <direction>out</direction>
- <relatedStateVariable>InternalClient</relatedStateVariable>
- </argument>
- <argument>
- <name>NewEnabled</name>
- <direction>out</direction>
-<relatedStateVariable>PortMappingEnabled</relatedStateVariable>
- </argument>
- <argument>
- <name>NewPortMappingDescription</name>
- <direction>out</direction>
- <relatedStateVariable>PortMappingDescription</relatedStateVariable>
- </argument>
- <argument>
- <name>NewLeaseDuration</name>
- <direction>out</direction>
-<relatedStateVariable>PortMappingLeaseDuration</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>GetSpecificPortMappingEntry </name>
- <argumentList>
- <argument>
- <name>NewRemoteHost</name>
- <direction>in</direction>
- <relatedStateVariable>RemoteHost</relatedStateVariable>
- </argument>
- <argument>
- <name>NewExternalPort</name>
- <direction>in</direction>
- <relatedStateVariable>ExternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewProtocol</name>
- <direction>in</direction>
- <relatedStateVariable>PortMappingProtocol</relatedStateVariable>
- </argument>
- <argument>
- <name>NewInternalPort</name>
- <direction>out</direction>
- <relatedStateVariable>InternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewInternalClient</name>
- <direction>out</direction>
- <relatedStateVariable>InternalClient</relatedStateVariable>
- </argument>
- <argument>
- <name>NewEnabled</name>
- <direction>out</direction>
- <relatedStateVariable>PortMappingEnabled</relatedStateVariable>
- </argument>
- <argument>
- <name>NewPortMappingDescription</name>
- <direction>out</direction>
- <relatedStateVariable>PortMappingDescription</relatedStateVariable>
- </argument>
- <argument>
- <name>NewLeaseDuration</name>
- <direction>out</direction>
- <relatedStateVariable>PortMappingLeaseDuration</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>AddPortMapping</name>
- <argumentList>
- <argument>
- <name>NewRemoteHost</name>
- <direction>in</direction>
- <relatedStateVariable>RemoteHost</relatedStateVariable>
- </argument>
- <argument>
- <name>NewExternalPort</name>
- <direction>in</direction>
- <relatedStateVariable>ExternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewProtocol</name>
- <direction>in</direction>
- <relatedStateVariable>PortMappingProtocol</relatedStateVariable>
- </argument>
- <argument>
- <name>NewInternalPort</name>
- <direction>in</direction>
- <relatedStateVariable>InternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewInternalClient</name>
- <direction>in</direction>
- <relatedStateVariable>InternalClient</relatedStateVariable>
- </argument>
- <argument>
- <name>NewEnabled</name>
- <direction>in</direction>
- <relatedStateVariable>PortMappingEnabled</relatedStateVariable>
- </argument>
- <argument>
- <name>NewPortMappingDescription</name>
- <direction>in</direction>
-<relatedStateVariable>PortMappingDescription</relatedStateVariable>
- </argument>
- <argument>
- <name>NewLeaseDuration</name>
- <direction>in</direction>
-<relatedStateVariable>PortMappingLeaseDuration</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>DeletePortMapping</name>
- <argumentList>
- <argument>
- <name>NewRemoteHost</name>
- <direction>in</direction>
- <relatedStateVariable>RemoteHost</relatedStateVariable>
- </argument>
- <argument>
- <name>NewExternalPort</name>
- <direction>in</direction>
- <relatedStateVariable>ExternalPort</relatedStateVariable>
- </argument>
- <argument>
- <name>NewProtocol</name>
- <direction>in</direction>
- <relatedStateVariable>PortMappingProtocol</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <action>
- <name>GetExternalIPAddress</name>
- <argumentList>
- <argument>
- <name>NewExternalIPAddress</name>
- <direction>out</direction>
- <relatedStateVariable>ExternalIPAddress</relatedStateVariable>
- </argument>
- </argumentList>
- </action>
- <!-- Declarations for other actions added by UPnP vendor (if any) go here -->
- </actionList>
- <serviceStateTable>
- <stateVariable sendEvents="no">
- <name>ConnectionType</name>
- <dataType>string</dataType>
- </stateVariable>
- <stateVariable sendEvents="yes">
- <name>PossibleConnectionTypes</name>
- <dataType>string</dataType>
- <allowedValueList>
- <allowedValue>Unconfigured</allowedValue>
- <allowedValue>IP_Routed</allowedValue>
- <allowedValue>IP_Bridged</allowedValue>
- </allowedValueList>
- </stateVariable>
- <stateVariable sendEvents="yes">
- <name>ConnectionStatus</name>
- <dataType>string</dataType>
- <allowedValueList>
- <allowedValue>Unconfigured</allowedValue>
- <allowedValue>Connecting</allowedValue>
- <allowedValue>Connected</allowedValue>
- <allowedValue>PendingDisconnect</allowedValue>
- <allowedValue>Disconnecting</allowedValue>
- <allowedValue>Disconnected</allowedValue>
- </allowedValueList>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>Uptime</name>
- <dataType>ui4</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>LastConnectionError</name>
- <dataType>string</dataType>
- <allowedValueList>
- <allowedValue>ERROR_NONE</allowedValue>
- <allowedValue>ERROR_COMMAND_ABORTED</allowedValue>
- <allowedValue>ERROR_NOT_ENABLED_FOR_INTERNET</allowedValue>
- <allowedValue>ERROR_USER_DISCONNECT</allowedValue>
- <allowedValue>ERROR_ISP_DISCONNECT</allowedValue>
- <allowedValue>ERROR_IDLE_DISCONNECT</allowedValue>
- <allowedValue>ERROR_FORCED_DISCONNECT</allowedValue>
- <allowedValue>ERROR_NO_CARRIER</allowedValue>
- <allowedValue>ERROR_IP_CONFIGURATION</allowedValue>
- <allowedValue>ERROR_UNKNOWN</allowedValue>
- </allowedValueList>
-</stateVariable>
- <stateVariable sendEvents="no">
- <name>AutoDisconnectTime</name>
- <dataType>ui4</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>IdleDisconnectTime</name>
- <dataType>ui4</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>WarnDisconnectDelay</name>
- <dataType>ui4</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>RSIPAvailable</name>
- <dataType>boolean</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>NATEnabled</name>
- <dataType>boolean</dataType>
-</stateVariable>
-<stateVariable sendEvents="yes">
- <name>ExternalIPAddress</name>
- <dataType>string</dataType>
-</stateVariable>
-<stateVariable sendEvents="yes">
- <name>PortMappingNumberOfEntries</name>
- <dataType>ui2</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>PortMappingEnabled</name>
- <dataType>boolean</dataType>
-</stateVariable>
-<stateVariable sendEvents="no">
- <name>PortMappingLeaseDuration</name>
- <dataType>ui4</dataType>
- </stateVariable>
- <stateVariable sendEvents="no">
- <name>RemoteHost</name>
- <dataType>string</dataType>
- </stateVariable>
- <stateVariable sendEvents="no">
- <name>ExternalPort</name>
- <dataType>ui2</dataType>
- </stateVariable>
- <stateVariable sendEvents="no">
- <name>InternalPort</name>
- <dataType>ui2</dataType>
- </stateVariable>
- <stateVariable sendEvents="no">
- <name>PortMappingProtocol</name>
- <dataType>string</dataType>
- <allowedValueList>
- <allowedValue>TCP</allowedValue>
- <allowedValue>UDP</allowedValue>
- </allowedValueList>
- </stateVariable>
- <stateVariable sendEvents="no">
- <name>InternalClient</name>
- <dataType>string</dataType>
- </stateVariable>
- <stateVariable sendEvents="no">
- <name>PortMappingDescription</name>
- <dataType>string</dataType>
- </stateVariable>
- <!-- Declarations for other state variables added by UPnP vendor (if any) go here -->
- </serviceStateTable>
-</scpd>
diff --git a/tests/check/upnp/fsupnp.c b/tests/check/upnp/fsupnp.c
deleted file mode 100644
index 4640b29..0000000
--- a/tests/check/upnp/fsupnp.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* Farsigh2 unit tests for FsCodec
- *
- * Copyright (C) 2007 Collabora, Nokia
- * @author: Olivier Crete <olivier.crete at collabora.co.uk>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <string.h>
-
-#include <gst/check/gstcheck.h>
-#include <ext/fsupnp/fs-upnp-simple-igd.h>
-#include <ext/fsupnp/fs-upnp-simple-igd-thread.h>
-
-#include <libgupnp/gupnp.h>
-
-static GMainLoop *loop = NULL;
-
-
-GST_START_TEST (test_fsupnp_new)
-{
- FsUpnpSimpleIgd *igd = fs_upnp_simple_igd_new (NULL);
- FsUpnpSimpleIgdThread *igdthread = fs_upnp_simple_igd_thread_new ();
- FsUpnpSimpleIgdThread *igdthread1 = fs_upnp_simple_igd_thread_new ();
-
- g_object_unref (igd);
- g_object_unref (igdthread);
- g_object_unref (igdthread1);
-}
-GST_END_TEST;
-
-
-
-static void
-get_external_ip_address_cb (GUPnPService *service,
- GUPnPServiceAction *action,
- gpointer user_data)
-{
- gupnp_service_action_set (action,
- "NewExternalIPAddress", G_TYPE_STRING, "127.0.0.3",
- NULL);
- gupnp_service_action_return (action);
-
-}
-
-static void
-add_port_mapping_cb (GUPnPService *service,
- GUPnPServiceAction *action,
- gpointer user_data)
-{
- gchar *remote_host = NULL;
- guint external_port = 0;
- gchar *proto = NULL;
- guint internal_port = 0;
- gchar *internal_client = NULL;
- gboolean enabled = -1;
- gchar *desc = NULL;
- guint lease = 0;
-
- gupnp_service_action_get (action,
- "NewRemoteHost", G_TYPE_STRING, &remote_host,
- "NewExternalPort", G_TYPE_UINT, &external_port,
- "NewProtocol", G_TYPE_STRING, &proto,
- "NewInternalPort", G_TYPE_UINT, &internal_port,
- "NewInternalClient", G_TYPE_STRING, &internal_client,
- "NewEnabled", G_TYPE_BOOLEAN, &enabled,
- "NewPortMappingDescription", G_TYPE_STRING, &desc,
- "NewLeaseDuration", G_TYPE_UINT, &lease,
- NULL);
-
- fail_unless (remote_host && !strcmp (remote_host, ""), "Remote host invalid");
- fail_unless (external_port == 6543, "wrong external port");
- fail_unless (proto && (!strcmp (proto, "UDP") || !strcmp (proto, "TCP")));
- fail_unless (internal_port == 6543, "wrong internal port");
- fail_unless (internal_client && !strcmp (internal_client, "192.168.4.22"));
- fail_unless (enabled == TRUE, "enable is not true");
- fail_unless (desc != NULL, "no desc");
- fail_unless (lease == 10, "no lease");
-
- g_free (remote_host);
- g_free (proto);
- g_free (internal_client);
- g_free (desc);
-
- gupnp_service_action_return (action);
-}
-
-
-static void
-delete_port_mapping_cb (GUPnPService *service,
- GUPnPServiceAction *action,
- gpointer user_data)
-{
- gchar *remote_host = NULL;
- guint external_port = 0;
- gchar *proto = NULL;
-
- gupnp_service_action_get (action,
- "NewRemoteHost", G_TYPE_STRING, &remote_host,
- "NewExternalPort", G_TYPE_UINT, &external_port,
- "NewProtocol", G_TYPE_STRING, &proto,
- NULL);
-
- fail_if (remote_host == NULL, "remote host NULL on remove");
- fail_unless (external_port, "external port wrong on remove");
- fail_unless (proto && !strcmp (proto, "UDP"), "proto wrong on remove");
-
- gupnp_service_action_return (action);
-
- g_free (remote_host);
- g_free (proto);
-
- g_main_loop_quit (loop);
-}
-
-static void
-mapping_external_port_cb (FsUpnpSimpleIgd *igd, gchar *proto,
- gchar *external_ip, gchar *replaces_external_ip, guint external_port,
- gchar *local_ip, guint local_port, gchar *description, gpointer user_data)
-{
- GUPnPService *service = GUPNP_SERVICE (user_data);
-
- fail_unless (external_port == 6543, "wrong external port");
- fail_unless (proto && !strcmp (proto, "UDP"));
- fail_unless (local_port == 6543, "wrong internal port");
- fail_unless (local_ip && !strcmp (local_ip, "192.168.4.22"));
- fail_unless (description != NULL, "no description");
-
- if (replaces_external_ip)
- {
- fail_unless (!strcmp (replaces_external_ip, "127.0.0.3"));
- fail_unless (external_ip && !strcmp (external_ip, "127.0.0.2"));
- fs_upnp_simple_igd_remove_port (igd, "UDP", external_port);
- }
- else
- {
- fail_unless (external_ip && !strcmp (external_ip, "127.0.0.3"));
- gupnp_service_notify (service,
- "ExternalIPAddress", G_TYPE_STRING, "127.0.0.2", NULL);
- }
-}
-
-static void
-error_mapping_port_cb (FsUpnpSimpleIgd *igd, GError *error, gchar *proto,
- guint external_port, gchar *description, gpointer user_data)
-{
- fail ("Error mapping external port: %s", error->message);
-}
-
-
-static void
-run_fsupnp_test (GMainContext *mainctx, FsUpnpSimpleIgd *igd)
-{
- GUPnPContext *context;
- GUPnPRootDevice *dev;
- GUPnPServiceInfo *service;
- GUPnPDeviceInfo *subdev1;
- GUPnPDeviceInfo *subdev2;
-
- context = gupnp_context_new (mainctx, NULL, 0, NULL);
- fail_if (context == NULL, "Can't get gupnp context");
-
- gupnp_context_host_path (context, "upnp/InternetGatewayDevice.xml", "/InternetGatewayDevice.xml");
- gupnp_context_host_path (context, "upnp/WANIPConnection.xml", "/WANIPConnection.xml");
-
- dev = gupnp_root_device_new (context, "/InternetGatewayDevice.xml");
- fail_if (dev == NULL, "could not get root dev");
-
- subdev1 = gupnp_device_info_get_device (GUPNP_DEVICE_INFO (dev),
- "urn:schemas-upnp-org:device:WANDevice:1");
- fail_if (subdev1 == NULL, "Could not get WANDevice");
-
- subdev2 = gupnp_device_info_get_device (subdev1,
- "urn:schemas-upnp-org:device:WANConnectionDevice:1");
- fail_if (subdev2 == NULL, "Could not get WANConnectionDevice");
- g_object_unref (subdev1);
-
- service = gupnp_device_info_get_service (subdev2,
- "urn:schemas-upnp-org:service:WANIPConnection:1");
- fail_if (service == NULL, "Could not get WANIPConnection");
- g_object_unref (subdev2);
-
- g_signal_connect (service, "action-invoked::GetExternalIPAddress",
- G_CALLBACK (get_external_ip_address_cb), NULL);
- g_signal_connect (service, "action-invoked::AddPortMapping",
- G_CALLBACK (add_port_mapping_cb), NULL);
- g_signal_connect (service, "action-invoked::DeletePortMapping",
- G_CALLBACK (delete_port_mapping_cb), NULL);
-
- gupnp_root_device_set_available (dev, TRUE);
-
-
- g_signal_connect (igd, "mapped-external-port",
- G_CALLBACK (mapping_external_port_cb), service);
- g_signal_connect (igd, "error-mapping-port",
- G_CALLBACK (error_mapping_port_cb), NULL);
-
- fs_upnp_simple_igd_add_port (igd, "UDP", 6543, "192.168.4.22",
- 6543, 10, "Farsight test");
-
- loop = g_main_loop_new (mainctx, FALSE);
-
- g_main_loop_run (loop);
-
- g_object_unref (context);
-}
-
-GST_START_TEST (test_fsupnp_default_ctx)
-{
- FsUpnpSimpleIgd *igd = fs_upnp_simple_igd_new (NULL);
-
- run_fsupnp_test (NULL, igd);
- g_object_unref (igd);
-}
-GST_END_TEST;
-
-GST_START_TEST (test_fsupnp_custom_ctx)
-{
- GMainContext *mainctx = g_main_context_new ();
- FsUpnpSimpleIgd *igd = fs_upnp_simple_igd_new (mainctx);
-
- run_fsupnp_test (mainctx, igd);
- g_object_unref (igd);
- g_main_context_unref (mainctx);
-}
-GST_END_TEST;
-
-
-GST_START_TEST (test_fsupnp_thread)
-{
- FsUpnpSimpleIgdThread *igd = fs_upnp_simple_igd_thread_new ();
- GMainContext *mainctx = g_main_context_new ();
-
- run_fsupnp_test (mainctx, FS_UPNP_SIMPLE_IGD (igd));
- g_object_unref (igd);
- g_main_context_unref (mainctx);
-}
-GST_END_TEST;
-
-
-static Suite *
-fsupnp_suite (void)
-{
- Suite *s = suite_create ("fsupnp");
- TCase *tc_chain = tcase_create ("fsupnp");
-
- suite_add_tcase (s, tc_chain);
-
- tcase_add_test (tc_chain, test_fsupnp_new);
- tcase_add_test (tc_chain, test_fsupnp_default_ctx);
- tcase_add_test (tc_chain, test_fsupnp_custom_ctx);
- tcase_add_test (tc_chain, test_fsupnp_thread);
-
- return s;
-}
-
-GST_CHECK_MAIN (fsupnp);
diff --git a/tests/upnp/Makefile.am b/tests/upnp/Makefile.am
deleted file mode 100644
index c936067..0000000
--- a/tests/upnp/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-
-noinst_PROGRAMS = test test-thread
-
-
-LDADD = \
- $(top_builddir)/gst-libs/ext/fsupnp/libfsupnp.la \
- $(GUPNP_LIBS)
-
-test_CFLAGS = $(GUPNP_CFLAGS) \
- -I$(top_srcdir)/gst-libs
-
-test_thread_CFLAGS = $(GUPNP_CFLAGS) \
- -I$(top_srcdir)/gst-libs
diff --git a/tests/upnp/test-thread.c b/tests/upnp/test-thread.c
deleted file mode 100644
index 83ad9db..0000000
--- a/tests/upnp/test-thread.c
+++ /dev/null
@@ -1,77 +0,0 @@
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <glib.h>
-
-#include <ext/fsupnp/fs-upnp-simple-igd-thread.h>
-
-static void
-_mapped_external_port (FsUpnpSimpleIgd *igd, gchar *proto,
- gchar *external_ip, gchar *replaces_external_ip, guint external_port,
- gchar *local_ip, guint local_port,
- gchar *description, gpointer user_data)
-{
- g_debug ("proto:%s ex:%s oldex:%s exp:%u local:%s localp:%u desc:%s",
- proto, external_ip, replaces_external_ip, external_port, local_ip,
- local_port, description);
-
-}
-
-
-
-static void
-_error_mapping_external_port (FsUpnpSimpleIgd *igd, GError *error,
- gchar *proto, guint external_port,
- gchar *description, gpointer user_data)
-{
- g_error ("proto:%s port:%u desc:%s error: %s", proto, external_port,
- description, error->message);
-}
-
-
-int
-main (int argc, char **argv)
-{
- FsUpnpSimpleIgdThread *igd = NULL;
- guint external_port, internal_port;
-
-
- if (argc != 5)
- {
- g_print ("Usage: %s <external port> <local ip> <local port> <description>\n",
- argv[0]);
- return 0;
- }
-
- external_port = atoi (argv[1]);
- internal_port = atoi (argv[3]);
- g_return_val_if_fail (external_port && internal_port, 1);
-
- g_type_init ();
- g_thread_init (NULL);
-
- igd = fs_upnp_simple_igd_thread_new ();
-
- g_signal_connect (igd, "mapped-external-port",
- G_CALLBACK (_mapped_external_port),
- NULL);
- g_signal_connect (igd, "error-mapping-port",
- G_CALLBACK (_error_mapping_external_port),
- NULL);
-
- fs_upnp_simple_igd_add_port (FS_UPNP_SIMPLE_IGD (igd),
- "TCP", external_port, argv[2],
- internal_port, 20, argv[4]);
-
- sleep (30);
-
- fs_upnp_simple_igd_remove_port (FS_UPNP_SIMPLE_IGD (igd), "TCP",
- external_port);
-
- sleep (5);
-
- g_object_unref (igd);
-
- return 0;
-}
diff --git a/tests/upnp/test.c b/tests/upnp/test.c
deleted file mode 100644
index 725bc42..0000000
--- a/tests/upnp/test.c
+++ /dev/null
@@ -1,91 +0,0 @@
-
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include <ext/fsupnp/fs-upnp-simple-igd.h>
-
-GMainContext *ctx = NULL;
-GMainLoop *loop = NULL;
-FsUpnpSimpleIgd *igd = NULL;
-guint external_port, internal_port;
-
-static gboolean
-_remove_port (gpointer user_data)
-{
- g_debug ("removing port");
- fs_upnp_simple_igd_remove_port (igd, "TCP", external_port);
-
- return FALSE;
-}
-
-static void
-_mapped_external_port (FsUpnpSimpleIgd *igd, gchar *proto,
- gchar *external_ip, gchar *replaces_external_ip, guint external_port,
- gchar *local_ip, guint local_port,
- gchar *description, gpointer user_data)
-{
- GSource *src;
-
- g_debug ("proto:%s ex:%s oldex:%s exp:%u local:%s localp:%u desc:%s",
- proto, external_ip, replaces_external_ip, external_port, local_ip,
- local_port, description);
-
- src = g_timeout_source_new_seconds (30);
- g_source_set_callback (src, _remove_port, user_data, NULL);
- g_source_attach (src, ctx);
-}
-
-
-
-static void
-_error_mapping_external_port (FsUpnpSimpleIgd *igd, GError *error,
- gchar *proto, guint external_port,
- gchar *description, gpointer user_data)
-{
- g_error ("proto:%s port:%u desc:%s error: %s", proto, external_port,
- description, error->message);
-}
-
-
-int
-main (int argc, char **argv)
-{
-
- if (argc != 5)
- {
- g_print ("Usage: %s <external port> <local ip> <local port> <description>\n",
- argv[0]);
- return 0;
- }
-
- external_port = atoi (argv[1]);
- internal_port = atoi (argv[3]);
- g_return_val_if_fail (external_port && internal_port, 1);
-
- g_type_init ();
- g_thread_init (NULL);
-
- ctx = g_main_context_new ();
- loop = g_main_loop_new (ctx, FALSE);
-
- igd = fs_upnp_simple_igd_new (ctx);
-
- g_signal_connect (igd, "mapped-external-port",
- G_CALLBACK (_mapped_external_port),
- NULL);
- g_signal_connect (igd, "error-mapping-port",
- G_CALLBACK (_error_mapping_external_port),
- NULL);
-
- fs_upnp_simple_igd_add_port (igd, "TCP", external_port, argv[2],
- internal_port, 20, argv[4]);
-
- g_main_loop_run (loop);
-
- g_object_unref (igd);
- g_main_loop_unref (loop);
- g_main_context_unref (ctx);
-
- return 0;
-}
--
1.5.6.5
More information about the farsight-commits
mailing list