created libradius shared by eap-radius and tnc-pdp plugins
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 18 Nov 2011 18:42:05 +0000 (19:42 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 13 Mar 2012 15:27:17 +0000 (16:27 +0100)
configure.in
src/libcharon/plugins/eap_radius/Makefile.am
src/libcharon/plugins/tnc_pdp/Makefile.am
src/libcharon/plugins/tnc_pdp/tnc_pdp.c
src/libradius/Makefile.am

index f533a8b..4e607c3 100644 (file)
@@ -254,7 +254,7 @@ if test x$eap_tls = xtrue -o x$eap_ttls = xtrue -o x$eap_peap = xtrue; then
        tls=true;
 fi
 
-if test x$eap_radius = xtrue -o x$radattr = xtrue; then
+if test x$eap_radius = xtrue -o x$radattr = xtrue -o x$tnc_pdp = xtrue; then
        radius=true;
 fi
 
index 181497a..625d4a9 100644 (file)
@@ -9,6 +9,8 @@ noinst_LTLIBRARIES = libstrongswan-eap-radius.la
 else
 libstrongswan_eap_radius_la_LIBADD = $(top_builddir)/src/libradius/libradius.la
 plugin_LTLIBRARIES = libstrongswan-eap-radius.la
+libstrongswan_eap_radius_la_LIBADD = \
+       $(top_builddir)/src/libradius/libradius.la
 endif
 
 libstrongswan_eap_radius_la_SOURCES = \
index 7123dd9..170a6f9 100644 (file)
@@ -2,7 +2,8 @@
 INCLUDES = \
        -I$(top_srcdir)/src/libstrongswan \
        -I$(top_srcdir)/src/libhydra \
-       -I$(top_srcdir)/src/libcharon
+       -I$(top_srcdir)/src/libcharon \
+       -I$(top_srcdir)/src/libradius
 
 AM_CFLAGS = -rdynamic
 
@@ -11,6 +12,7 @@ noinst_LTLIBRARIES = libstrongswan-tnc-pdp.la
 else
 plugin_LTLIBRARIES = libstrongswan-tnc-pdp.la
 libstrongswan_tnc_pdp_la_LIBADD = \
+       $(top_builddir)/src/libradius/libradius.la \
        $(top_builddir)/src/libtls/libtls.la \
        $(top_builddir)/src/libtnccs/libtnccs.la
 endif
index f0cf866..54cf4b3 100644 (file)
@@ -18,6 +18,8 @@
 #include <errno.h>
 #include <unistd.h>
 
+#include <radius_message.h>
+
 #include <daemon.h>
 #include <debug.h>
 #include <threading/thread.h>
@@ -28,7 +30,7 @@ typedef struct private_tnc_pdp_t private_tnc_pdp_t;
 /**
  * Maximum size of a RADIUS IP packet
  */
-#define MAX_PACKET 2048
+#define MAX_PACKET 4096
 
 /**
  * private data of tnc_pdp_t
@@ -128,6 +130,7 @@ static job_requeue_t receive(private_tnc_pdp_t *this)
 {
        while (TRUE)
        {
+               radius_message_t *request;
                char buffer[MAX_PACKET];
                int max_fd = 0, selected = 0, bytes_read = 0;
                fd_set rfds;
@@ -198,6 +201,16 @@ static job_requeue_t receive(private_tnc_pdp_t *this)
                source = host_create_from_sockaddr((sockaddr_t*)&src);
                DBG2(DBG_NET, "received RADIUS packet from %#H", source);
                DBG3(DBG_NET, "%b", buffer, bytes_read);
+               request = radius_message_parse_response(chunk_create(buffer, bytes_read));
+               if (request)
+               {
+                       DBG2(DBG_NET, "received valid RADIUS message");
+                       request->destroy(request);
+               }
+               else
+               {
+                       DBG1(DBG_NET, "received invalid RADIUS message, ignored");
+               }
                source->destroy(source);
        }
        return JOB_REQUEUE_FAIR;
index 618dbbc..f891e01 100644 (file)
@@ -7,3 +7,4 @@ libradius_la_SOURCES = \
        radius_socket.h radius_socket.c \
        radius_client.h radius_client.c \
        radius_config.h radius_config.c
+