]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
control sock unix now accepts connections
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Jun 2018 20:17:48 +0000 (16:17 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Jun 2018 20:17:48 +0000 (16:17 -0400)
next step, implement the various state machines necessary
for authentication, etc.

src/modules/proto_control/proto_control_tcp.c
src/modules/proto_control/proto_control_tcp.mk
src/modules/proto_control/proto_control_unix.c
src/modules/proto_control/proto_control_unix.mk

index c272f369f49e63afa9b4c55c44705ec71bc630b0..bb4f4f50459f48cf97b429b87e63fb943a8b6afd 100644 (file)
@@ -131,7 +131,6 @@ static ssize_t mod_read(void *instance, UNUSED void **packet_ctx, fr_time_t **re
                return 0;
        }
 
-
        // @todo - maybe convert timestamp?
        *recv_time_p = fr_time();
 
index 78fab9a497afb615b538509d27b0171255104972..7f70fe493701c365013e649e96ecd12c77ae69dc 100644 (file)
@@ -6,4 +6,4 @@ endif
 
 SOURCES                := proto_control_tcp.c
 
-TGT_PREREQS    := libfreeradius-util.a
+TGT_PREREQS    := libfreeradius-util.a libfreeradius-control.a
index b0a7a8f83cb41c7b451b1dbb0dc1a6ff01b748aa..8188b7542857241cf02990931dc003dc3455f1a5 100644 (file)
@@ -102,57 +102,36 @@ static ssize_t mod_read(void *instance, UNUSED void **packet_ctx, fr_time_t **re
        size_t                          packet_len = -1;
 
        fr_time_t                       *recv_time_p;
+       fr_conduit_type_t               conduit;
 
        recv_time_p = *recv_time;
 
        /*
         *      Read data into the buffer.
         */
-       data_size = read(inst->sockfd, buffer + *leftover, buffer_len - *leftover);
+       data_size = fr_conduit_read_async(inst->sockfd, &conduit, buffer, buffer_len, leftover);
        if (data_size < 0) {
-               DEBUG2("proto_control_unix got read error %zd: %s", data_size, fr_strerror());
+               DEBUG2("proto_control_tcp got read error %zd: %s", data_size, fr_strerror());
                return data_size;
        }
 
        /*
         *      Note that we return ERROR for all bad packets, as
-        *      there's no point in reading packets from a UNIX
+        *      there's no point in reading packets from a TCP
         *      connection which isn't sending us properly formatted
         *      packets.
         */
 
        /*
-        *      UNIX read of zero means the socket is dead.
+        *      Not enough for a full packet, ask the caller to read more.
         */
-       if (!data_size) {
-               DEBUG2("proto_control_unix - other side closed the socket.");
-               return -1;
+       if (conduit == FR_CONDUIT_WANT_MORE) {
+               return 0;
        }
 
        // @todo - check authentication, etc. on the socket.
        // we will need a state machine for this..
-
-       /*
-        *      Not enough for one packet.  Tell the caller that we need to read more.
-        */
-       if (data_size < 20) {
-               *leftover = data_size;
-               return 0;
-       }
-
-#if 0
-       /*
-        *      If it's not a RADIUS packet, ignore it.
-        */
-       if (!fr_radius_ok(buffer, &packet_len, inst->max_attributes, false, &reason)) {
-               /*
-                *      @todo - check for F5 load balancer packets.  <sigh>
-                */
-               DEBUG2("proto_control_unix got a packet which isn't RADIUS");
-               inst->stats.total_malformed_requests++;
-               return -1;
-       }
-#endif
+       packet_len = data_size;
 
        // @todo - maybe convert timestamp?
        *recv_time_p = fr_time();
@@ -919,6 +898,9 @@ static int mod_fd_set(void *instance, int fd)
 
        inst->sockfd = fd;
 
+       // @todo - start the negotiation
+       // We probably want a way to read / write initial data in the connection...
+
        return 0;
 }
 
index d7285816ade3f3241e2228343eee8beb1effb3fb..3e6e2ae42a6773dac2572c83312cceec3ea52a76 100644 (file)
@@ -6,4 +6,4 @@ endif
 
 SOURCES                := proto_control_unix.c
 
-TGT_PREREQS    := libfreeradius-util.a
+TGT_PREREQS    := libfreeradius-util.a libfreeradius-control.a