Moved record_* functions to tls_session_t structure, so that
authoraland <aland>
Tue, 22 Mar 2005 00:53:13 +0000 (00:53 +0000)
committeraland <aland>
Tue, 22 Mar 2005 00:53:13 +0000 (00:53 +0000)
we can (hopefully) remove all inter-module linking.

It's not done yet (and untested), but TTLS should now NOT require
linking against rlm_eap_tls

src/modules/rlm_eap/types/rlm_eap_peap/peap.c
src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c
src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.h
src/modules/rlm_eap/types/rlm_eap_tls/tls.c
src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c

index b4820f4..427b480 100644 (file)
@@ -19,7 +19,7 @@
  *
  *   Copyright 2003 Alan DeKok <aland@freeradius.org>
  */
-#include "eap_tls.h"
+#include "rlm_eap_tls.h"
 #include "eap_peap.h"
 
 /*
@@ -45,14 +45,14 @@ static int eappeap_failure(EAP_HANDLER *handler, tls_session_t *tls_session)
        tlv_packet[9] = 0;
        tlv_packet[10] = EAP_TLV_FAILURE;
 
-       record_plus(&tls_session->clean_in, tlv_packet, 11);
+       (tls_session->record_plus)(&tls_session->clean_in, tlv_packet, 11);
 
        /*
         *      FIXME: Check the return code.
         */
        tls_handshake_send(tls_session);
-       record_init(&tls_session->clean_in);
-
+       (tls_session->record_init)(&tls_session->clean_in);
+       
        return 1;
 }
 
@@ -80,13 +80,13 @@ static int eappeap_success(EAP_HANDLER *handler, tls_session_t *tls_session)
        tlv_packet[9] = 0;
        tlv_packet[10] = EAP_TLV_SUCCESS;
 
-       record_plus(&tls_session->clean_in, tlv_packet, 11);
+       (tls_session->record_plus)(&tls_session->clean_in, tlv_packet, 11);
 
        /*
         *      FIXME: Check the return code.
         */
        tls_handshake_send(tls_session);
-       record_init(&tls_session->clean_in);
+       (tls_session->record_init)(&tls_session->clean_in);
 
        return 1;
 }
@@ -216,13 +216,13 @@ static int vp2eap(tls_session_t *tls_session, VALUE_PAIR *vp)
         *      Send the EAP data, WITHOUT the header.
         */
 #if 1
-       record_plus(&tls_session->clean_in, vp->strvalue + EAP_HEADER_LEN,
+       (tls_session->record_plus)(&tls_session->clean_in, vp->strvalue + EAP_HEADER_LEN,
                vp->length - EAP_HEADER_LEN);
 #else
-       record_plus(&tls_session->clean_in, vp->strvalue, vp->length);
+       (tls_session->record_plus)(&tls_session->clean_in, vp->strvalue, vp->length);
 #endif
        tls_handshake_send(tls_session);
-       record_init(&tls_session->clean_in);
+       (tls_session->record_init)(&tls_session->clean_in);
 
        return 1;
 }
@@ -551,7 +551,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
         *
         *      I *really* don't like these 'record_t' things...
         */
-       data_len = record_minus(&tls_session->dirty_in, buffer, sizeof(buffer));
+       data_len = (tls_session->record_minus)(&tls_session->dirty_in, buffer, sizeof(buffer));
        data = buffer;
 
        /*
@@ -566,7 +566,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
         *      go there, too...
         */
        BIO_write(tls_session->into_ssl, buffer, data_len);
-       record_init(&tls_session->clean_out);
+       (tls_session->record_init)(&tls_session->clean_out);
 
        /*
         *      Read (and decrypt) the tunneled data from the SSL session,
index 90474a3..37f1973 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include "autoconf.h"
-#include "eap_tls.h"
+#include "rlm_eap_tls.h"
 #include "eap_peap.h"
 
 typedef struct rlm_eap_peap_t {
@@ -187,11 +187,11 @@ static int eappeap_authenticate(void *arg, EAP_HANDLER *handler)
                        eap_packet.length[1] = EAP_HEADER_LEN + 1;
                        eap_packet.data[0] = PW_EAP_IDENTITY;
 
-                       record_plus(&tls_session->clean_in,
-                                   &eap_packet, sizeof(eap_packet));
-
+                       (tls_session->record_plus)(&tls_session->clean_in,
+                                                 &eap_packet, sizeof(eap_packet));
+                       
                        tls_handshake_send(tls_session);
-                       record_init(&tls_session->clean_in);
+                       (tls_session->record_init)(&tls_session->clean_in);
                }
                eaptls_request(handler->eap_ds, tls_session);
                DEBUG2("  rlm_eap_peap: EAPTLS_SUCCESS");
index 33a8709..206daf8 100644 (file)
@@ -147,6 +147,14 @@ typedef struct _tls_session_t {
        record_t        dirty_in;
        record_t        dirty_out;
 
+       void            (*record_init)(record_t *buf);
+       void            (*record_close)(record_t *buf);
+       unsigned int    (*record_plus)(record_t *buf, const unsigned char *ptr,
+                                      unsigned int size);
+       unsigned int    (*record_minus)(record_t *buf, unsigned char *ptr,
+                                       unsigned int size);
+       
+
        /*
         * Framed-MTU attribute in RADIUS,
         * if present, can also be used to set this
index 125aed5..975dcc9 100644 (file)
@@ -43,6 +43,14 @@ tls_session_t *eaptls_new_session(SSL_CTX *ssl_ctx, int client_cert)
        state->ssl = new_tls;
 
        /*
+        *      Initialize callbacks
+        */
+       state->record_init = record_init;
+       state->record_close = record_close;
+       state->record_plus = record_plus;
+       state->record_minus = record_minus;
+
+       /*
         *      Create & hook the BIOs to handle the dirty side of the
         *      SSL.  This is *very important* as we want to handle
         *      the transmission part.  Now the only IO interface
index d95771a..e3b4c4b 100644 (file)
@@ -19,7 +19,7 @@
  *
  *   Copyright 2003 Alan DeKok <aland@freeradius.org>
  */
-#include "eap_tls.h"
+#include "rlm_eap_tls.h"
 #include "eap_ttls.h"
 
 /*
@@ -540,13 +540,13 @@ static int vp2diameter(tls_session_t *tls_session, VALUE_PAIR *first)
                }
 #endif
 
-               record_plus(&tls_session->clean_in, buffer, total);
+               (tls_session->record_plus)(&tls_session->clean_in, buffer, total);
 
                /*
                 *      FIXME: Check the return code.
                 */
                tls_handshake_send(tls_session);
-               record_init(&tls_session->clean_in);
+               (tls_session->record_init)(&tls_session->clean_in);
        }
 
        /*
@@ -873,7 +873,7 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
         *
         *      I *really* don't like these 'record_t' things...
         */
-       data_len = record_minus(&tls_session->dirty_in, buffer, sizeof(buffer));
+       data_len = (tls_session->record_minus)(&tls_session->dirty_in, buffer, sizeof(buffer));
        data = buffer;
 
        /*
@@ -888,7 +888,7 @@ int eapttls_process(EAP_HANDLER *handler, tls_session_t *tls_session)
         *      go there, too...
         */
        BIO_write(tls_session->into_ssl, buffer, data_len);
-       record_init(&tls_session->clean_out);
+       (tls_session->record_init)(&tls_session->clean_out);
 
        /*
         *      Read (and decrypt) the tunneled data from the SSL session,