From: Alan T. DeKok Date: Thu, 7 Jun 2018 20:17:48 +0000 (-0400) Subject: control sock unix now accepts connections X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=207d503f679c32233e54c5a5ce1e4481ca52302e;p=thirdparty%2Ffreeradius-server.git control sock unix now accepts connections next step, implement the various state machines necessary for authentication, etc. --- diff --git a/src/modules/proto_control/proto_control_tcp.c b/src/modules/proto_control/proto_control_tcp.c index c272f369f49..bb4f4f50459 100644 --- a/src/modules/proto_control/proto_control_tcp.c +++ b/src/modules/proto_control/proto_control_tcp.c @@ -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(); diff --git a/src/modules/proto_control/proto_control_tcp.mk b/src/modules/proto_control/proto_control_tcp.mk index 78fab9a497a..7f70fe49370 100644 --- a/src/modules/proto_control/proto_control_tcp.mk +++ b/src/modules/proto_control/proto_control_tcp.mk @@ -6,4 +6,4 @@ endif SOURCES := proto_control_tcp.c -TGT_PREREQS := libfreeradius-util.a +TGT_PREREQS := libfreeradius-util.a libfreeradius-control.a diff --git a/src/modules/proto_control/proto_control_unix.c b/src/modules/proto_control/proto_control_unix.c index b0a7a8f83cb..8188b754285 100644 --- a/src/modules/proto_control/proto_control_unix.c +++ b/src/modules/proto_control/proto_control_unix.c @@ -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. - */ - 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; } diff --git a/src/modules/proto_control/proto_control_unix.mk b/src/modules/proto_control/proto_control_unix.mk index d7285816ade..3e6e2ae42a6 100644 --- a/src/modules/proto_control/proto_control_unix.mk +++ b/src/modules/proto_control/proto_control_unix.mk @@ -6,4 +6,4 @@ endif SOURCES := proto_control_unix.c -TGT_PREREQS := libfreeradius-util.a +TGT_PREREQS := libfreeradius-util.a libfreeradius-control.a