[gnet-devel] Adding gnutls support



I was modifying OSSIM www.ossim.net to support gnutls and at first, I
was going to take gnet out, but then I realized I could create a quick
hack that added the following member to the _GTcpSocket implementation
and 

gnutls_session_t gnutls_session;

and then I just accessed it directly. I know this is a total violation
of the api, so it appears I need to figure out what functions to create.

I just thought I would send this quick hack to introduce the member to
the struct in case there is any feedback before adding the functions to 
enable the crypto on the connection.

Basically, with gnutls, one creates a socket, a gnutls_session_t and then
tie them together with the gnutls_transport_set_ptr function.

gnutls_transport_set_ptr( gsocket->gnutls_session,
                (gnutls_transport_ptr_t) gsocket->sockfd );



brian
-- 
Brian Lavender
http://www.brie.com/brian/
#ifndef _GNET_PRIVATE_H
#define _GNET_PRIVATE_H

#include <sys/types.h>
#include <sys/socket.h>

#ifndef SOCKET
#define SOCKET gint
#endif

struct _GTcpSocket
{
  SOCKET sockfd;
  gint ref_count; /* ATOMIC */
  GIOChannel* iochannel;
  struct sockaddr_storage sa;
  /* sa is remote host for clients, local host for servers */

  GTcpSocketAcceptFunc accept_func;
  gpointer accept_data;
  guint	accept_watch;
  gnutls_session_t gnutls_session;
};

#endif
diff -bru gnet-2.0.8/configure.ac gnet.new/configure.ac
--- gnet-2.0.8/configure.ac	2008-02-03 04:04:42.000000000 -0800
+++ gnet.new/configure.ac	2008-08-17 11:43:48.000000000 -0700
@@ -196,11 +196,15 @@
 
 PKG_CHECK_MODULES(GTHREAD, [gthread-2.0 >= $GLIB_REQ], , [ AC_MSG_ERROR([The impossible happened]) ] )
 
+PKG_CHECK_MODULES(DEPS, gnutls > 2.4.0 )
+
 # These SUBSTs are primarily for gnet-config and gnet.pc
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 AC_SUBST(GTHREAD_CFLAGS)
 AC_SUBST(GTHREAD_LIBS)
+AC_SUBST(DEPS_CFLAGS)
+AC_SUBST(DEPS_LIBS)
 
 # make double sure GLib was compiled with GThread support
 AC_MSG_CHECKING([if GLib was compiled with support for threads])
diff -bru gnet-2.0.8/src/gnet-private.h gnet.new/src/gnet-private.h
--- gnet-2.0.8/src/gnet-private.h	2008-02-03 04:04:40.000000000 -0800
+++ gnet.new/src/gnet-private.h	2008-08-17 11:45:07.000000000 -0700
@@ -119,6 +119,9 @@
 
 #endif	/*********** End Windows specific ***********/
 
+// gnutls hack
+#include <gnutls/gnutls.h>
+
 #ifndef INET_ADDRSTRLEN
 #define INET_ADDRSTRLEN 16
 #endif
@@ -248,6 +251,7 @@
   GTcpSocketAcceptFunc accept_func;
   gpointer accept_data;
   guint	accept_watch;
+  gnutls_session_t gnutls_session;
 };
 
 struct _GInetAddr
diff -bru gnet-2.0.8/src/Makefile.am gnet.new/src/Makefile.am
--- gnet-2.0.8/src/Makefile.am	2008-02-03 04:04:40.000000000 -0800
+++ gnet.new/src/Makefile.am	2008-08-17 11:44:42.000000000 -0700
@@ -8,7 +8,7 @@
 @SET_MAKE@
 
 INCLUDES = -DG_LOG_DOMAIN=\"GNet\" @GNET_DEBUG_FLAGS@ \
-	$(GLIB_CFLAGS) $(GTHREAD_CFLAGS) 
+	$(GLIB_CFLAGS) $(GTHREAD_CFLAGS) $(DEPS_CFLAGS)
 
 gnetincludedir = $(includedir)/gnet-$(GNET_MAJOR_VERSION).$(GNET_MINOR_VERSION)
 
@@ -17,7 +17,7 @@
 libgnet_2_0_la_LDFLAGS = \
 	$(no_undefined) \
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-	$(GLIB_LIBS) $(GTHREAD_LIBS) $(lws2_32)
+	$(GLIB_LIBS) $(GTHREAD_LIBS) $(lws2_32) $(DEPS_LIBS)
 
 libgnet_2_0_la_SOURCES = 	\
 	gnet.c			\


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]