Skip to content

Commit

Permalink
Rename transport to IO
Browse files Browse the repository at this point in the history
Rename a bunch of structures.

Use the standard module instantiation framework for fr_io_t
  • Loading branch information
arr2036 committed Jun 6, 2017
1 parent 09beb3d commit cd4a335
Show file tree
Hide file tree
Showing 22 changed files with 432 additions and 394 deletions.
89 changes: 50 additions & 39 deletions src/include/protocol.h
Expand Up @@ -30,7 +30,7 @@ extern "C" {
#endif

#include <freeradius-devel/dl.h>
#include <freeradius-devel/io/transport.h>
#include <freeradius-devel/io/io.h>

/*
* We'll use this below.
Expand All @@ -48,28 +48,28 @@ typedef void (*rad_listen_free_t)(rad_listen_t *);
typedef struct rad_protocol_t {
RAD_MODULE_COMMON; //!< Common fields to all loadable modules.

uint32_t transports; //!< What can transport this protocol.
bool tls; //!< Whether protocol can be wrapped in TLS.
uint32_t transports; //!< What can transport this protocol.
bool tls; //!< Whether protocol can be wrapped in TLS.

rad_listen_unlang_t bootstrap; //!< Phase1 - Basic validation checks of virtual server.
rad_listen_unlang_t compile; //!< Phase2 - Compile unlang sections in the virtual
rad_listen_unlang_t bootstrap; //!< Phase1 - Basic validation checks of virtual server.
rad_listen_unlang_t compile; //!< Phase2 - Compile unlang sections in the virtual
//!< server that map to packet types used by the protocol.

rad_listen_parse_t parse; //!< Perform extra processing of the configuration data
rad_listen_parse_t parse; //!< Perform extra processing of the configuration data
//!< specified by config.

rad_listen_parse_t open; //!< Open a descriptor.
rad_listen_parse_t open; //!< Open a descriptor.

rad_listen_recv_t recv; //!< Read an incoming packet from the descriptor.
rad_listen_send_t send; //!< Write an outgoing packet to the descriptor.
rad_listen_error_t error; //!< Handle error/eol on the descriptor.
rad_listen_recv_t recv; //!< Read an incoming packet from the descriptor.
rad_listen_send_t send; //!< Write an outgoing packet to the descriptor.
rad_listen_error_t error; //!< Handle error/eol on the descriptor.

rad_listen_print_t print; //!< Print a line describing the packet being sent or the
rad_listen_print_t print; //!< Print a line describing the packet being sent or the
//!< packet that was received.
rad_listen_debug_t debug; //!< Print an attribute list for debugging.
rad_listen_debug_t debug; //!< Print an attribute list for debugging.

rad_listen_encode_t encode; //!< Encode an outgoing packet.
rad_listen_decode_t decode; //!< Decode an incoming packet.
rad_listen_encode_t encode; //!< Encode an outgoing packet.
rad_listen_decode_t decode; //!< Decode an incoming packet.
} rad_protocol_t;

#define TRANSPORT_NONE 0
Expand All @@ -85,52 +85,63 @@ int common_socket_open(CONF_SECTION *cs, rad_listen_t *this);
int common_socket_print(rad_listen_t const *this, char *buffer, size_t bufsize);
void common_packet_debug(REQUEST *request, RADIUS_PACKET *packet, bool received);


typedef int (*fr_app_bootstrap_t)(CONF_SECTION *);

/*
* src/lib/io/transport.h
* src/lib/io/io.h
*/
typedef struct fr_transport_t fr_transport_t;
typedef struct fr_io_op_t fr_io_op_t;

/*
* src/lib/io/schedule.h
/** Validate configurable elements of an fr_ctx_t
*
* @param[in] io_cs Configuration describing the I/O mechanism.
* @param[in] instance data. Pre-populated by parsing io_cs.
* @return
* - 0 on success.
* - -1 on failure.
*/
typedef struct fr_schedule_t fr_schedule_t;

typedef int (*fr_app_parse_t)(fr_schedule_t *sc, CONF_SECTION *, bool);
typedef int (*fr_app_io_instantiate_t)(CONF_SECTION *io_cs, void *instance);

/*
* Functions for new virtual servers and listeners
/** Public structure describing an I/O path for a protocol
*
* This structure is exported by I/O modules e.g. proto_radius_udp.
*/
typedef struct fr_app_t {
typedef struct fr_app_io_t {
RAD_MODULE_COMMON; //!< Common fields to all loadable modules.

fr_app_bootstrap_t bootstrap;
fr_app_parse_t parse;
} fr_app_t;

typedef int (*fr_app_io_open_t)(TALLOC_CTX *ctx, int *, void **, fr_transport_t **, CONF_SECTION *, bool);
fr_app_io_instantiate_t instantiate; //!< Perform any config validation, and per-instance work.
fr_io_op_t op; //!< Open/close/read/write functions for sending/receiving
//!< protocol data.
} fr_app_io_t;

/*
* Functions for new virtual servers and listeners
* src/lib/io/schedule.h
*/
typedef struct fr_app_io_t {
typedef struct fr_schedule_t fr_schedule_t;
typedef int (*fr_app_instantiate_t)(fr_schedule_t *sc, CONF_SECTION *cs, bool validate_config);

/** Describes a new application (protocol)
*
*/
typedef struct fr_app_t {
RAD_MODULE_COMMON; //!< Common fields to all loadable modules.

fr_app_io_open_t open;
} fr_app_io_t;
fr_app_bootstrap_t bootstrap;
fr_app_instantiate_t instantiate;
} fr_app_t;

typedef int (*fr_app_subtype_compile_t)(CONF_SECTION *cs);
typedef int (*fr_app_subtype_instantiate_t)(CONF_SECTION *cs);

/*
* Functions for new virtual servers and listeners
/** Public structure describing an application (protocol) specialisation
*
* Some protocols perform multiple distinct functions, and use
* different state machines to perform those functions.
*/
typedef struct fr_app_subtype_t {
RAD_MODULE_COMMON; //!< Common fields to all loadable modules.

fr_app_subtype_compile_t compile;
fr_transport_process_t process;
fr_app_subtype_instantiate_t instantiate; //!< Perform any config validation, and per-instance work.
fr_io_process_t process; //!< Entry point into the protocol subtype's state machine.
} fr_app_subtype_t;

#ifdef __cplusplus
Expand Down
17 changes: 5 additions & 12 deletions src/lib/io/channel.h
Expand Up @@ -27,6 +27,7 @@ RCSIDH(channel_h, "$Id$")

#include <freeradius-devel/io/message.h>
#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/io.h>

#include <sys/types.h>
#include <sys/event.h>
Expand All @@ -48,16 +49,7 @@ typedef struct fr_channel_t fr_channel_t;
* Forward declaration until such time as we fix the code so that
* the network threads can push transports to worker threads.
*/
typedef struct fr_transport_t fr_transport_t;

typedef struct fr_packet_io_t {
int fd; //!< the file descriptor
uint32_t priority; //!< 0 is higher priority than 1

void *ctx; //!< for the transport
fr_transport_t *transport; //!< the transport structure
} fr_packet_io_t;

typedef struct fr_io fr_io_t;

typedef enum fr_channel_event_t {
FR_CHANNEL_ERROR = 0,
Expand Down Expand Up @@ -100,8 +92,6 @@ typedef struct fr_channel_data_t {
} channel;
};

fr_packet_io_t io; //!< for tracking packet transport, etc.

union {
struct {
fr_time_t *start_time; //!< time original request started (network -> worker)
Expand All @@ -115,6 +105,9 @@ typedef struct fr_channel_data_t {
} reply;
};

uint32_t priority; //!< Priority of this packet.

fr_io_t *io; //!< for tracking packet transport, etc.
} fr_channel_data_t;

fr_channel_t *fr_channel_create(TALLOC_CTX *ctx, fr_control_t *master, fr_control_t *worker) CC_HINT(nonnull);
Expand Down

0 comments on commit cd4a335

Please sign in to comment.