Commit bf09c058 authored by Jens Georg's avatar Jens Georg

Add a Linux context manager

This is based on RT Netlink sockets, see rtnetlink(7)
parent b2483259
......@@ -44,7 +44,7 @@ PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
AC_ARG_WITH([context_manager],
AS_HELP_STRING(
[--with-context-manager=@<:@network-manager/unix@:>@],
[--with-context-manager=@<:@network-manager/unix/linux@:>@],
[Context Manager backend to use]),,
[with_context_manager="unix"])
......@@ -54,6 +54,32 @@ AC_MSG_RESULT([${with_context_manager}])
AM_CONDITIONAL([USE_NETWORK_MANAGER],
[test "x$with_context_manager" = "xnetwork-manager"])
USE_NETLINK=no
if test "x$with_context_manager" = "xlinux"; then
dnl check for netlink (Linux)
AC_CHECK_HEADERS([sys/socket.h linux/rtnetlink.h],
[ USE_NETLINK=yes ],
[ USE_NETLINK=no ],
[ #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
if test "x$USE_NETLINK" = "xno"
then
AC_MSG_NOTICE([No rtnetlink found, falling back to unix context
manager])
else
AC_CHECK_HEADERS([linux/wireless.h], [], [],
[ #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
])
fi
fi
AM_CONDITIONAL(USE_NETLINK, test "x$USE_NETLINK" = "xyes")
AC_SUBST(USE_NETLINK)
# glib-genmarshal
GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
AC_SUBST(GLIB_GENMARSHAL)
......
......@@ -9,8 +9,18 @@ CONTEXT_MANAGER_IMPL =
CONTEXT_MANAGER_CFLAGS =
endif
if USE_NETLINK
NETLINK_CFLAGS = -DUSE_NETLINK
CONTEXT_MANAGER_IMPL += \
gupnp-linux-context-manager.c \
gupnp-linux-context-manager.h
else
NETLINK_CFLAGS =
endif
AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
$(NETLINK_CFLAGS) \
-I$(top_srcdir) \
$(CONTEXT_MANAGER_CFLAGS)
......@@ -87,6 +97,8 @@ libgupnp_1_0_la_LIBADD = $(LIBGUPNP_LIBS) $(DBUS_GLIB_LIBS) $(LIBCONIC_LIBS)
EXTRA_DIST = gupnp-marshal.list \
gupnp-network-manager.c \
gupnp-network-manager.h \
gupnp-linux-context-manager.c \
gupnp-linux-context-manager.h \
gupnp-unix-context-manager.c \
gupnp-unix-context-manager.h
......
......@@ -373,6 +373,9 @@ gupnp_context_manager_new (GMainContext *main_context,
if (gupnp_network_manager_is_available (main_context))
impl_type = GUPNP_TYPE_NETWORK_MANAGER;
#elif USE_NETLINK
#include "gupnp-linux-context-manager.h"
impl_type = GUPNP_TYPE_LINUX_CONTEXT_MANAGER;
#endif
if (impl_type == G_TYPE_INVALID)
......
This diff is collapsed.
/*
* Copyright (C) 2011 Jens Georg.
*
* Author: Jens Georg <mail@jensge.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GUPNP_LINUX_CONTEXT_MANAGER_H__
#define __GUPNP_LINUX_CONTEXT_MANAGER_H__
#include "gupnp-context-manager.h"
G_BEGIN_DECLS
GType
gupnp_linux_context_manager_get_type (void) G_GNUC_CONST;
#define GUPNP_TYPE_LINUX_CONTEXT_MANAGER \
(gupnp_linux_context_manager_get_type ())
#define GUPNP_LINUX_CONTEXT_MANAGER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
GUPNP_TYPE_LINUX_CONTEXT_MANAGER, \
GUPnPLinuxContextManager))
#define GUPNP_LINUX_CONTEXT_MANAGER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_CAST ((obj), \
GUPNP_TYPE_LINUX_CONTEXT_MANAGER, \
GUPnPLinuxContextManagerClass))
#define GUPNP_IS_LINUX_CONTEXT_MANAGER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
GUPNP_TYPE_LINUX_CONTEXT_MANAGER))
#define GUPNP_IS_LINUX_CONTEXT_MANAGER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((obj), \
GUPNP_TYPE_LINUX_CONTEXT_MANAGER))
#define GUPNP_LINUX_CONTEXT_MANAGER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
GUPNP_TYPE_LINUX_CONTEXT_MANAGER, \
GUPnPLinuxContextManagerClass))
typedef struct _GUPnPLinuxContextManagerPrivate GUPnPLinuxContextManagerPrivate;
typedef struct {
GUPnPContextManager parent;
GUPnPLinuxContextManagerPrivate *priv;
} GUPnPLinuxContextManager;
typedef struct {
GUPnPContextManagerClass parent_class;
/* future padding */
void (* _gupnp_reserved1) (void);
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
} GUPnPLinuxContextManagerClass;
G_END_DECLS
#endif /* __GUPNP_LINUX_CONTEXT_MANAGER_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment