*
* No data will be read from or written to the fd, except by the io_data callbacks here.
*
- * @param[in] listen the listener for this socket
+ * @param[in] li the listener for this socket
* @return
* - 0 on success
* - <0 on error
*/
-typedef int (*fr_io_open_t)(fr_listen_t *listen);
+typedef int (*fr_io_open_t)(fr_listen_t *li);
/** Return a selectable file descriptor for this I/O path
*
* Return the file descriptor associated with this I/O path.
*
- * @param[in] listen the listener for this socket
+ * @param[in] li the listener for this socket
*/
-typedef int (*fr_io_get_fd_t)(fr_listen_t const *listen);
+typedef int (*fr_io_get_fd_t)(fr_listen_t const *li);
/** Set a selectable file descriptor for this I/O path
*
*
- * @param[in] listen the listener for this socket
+ * @param[in] li the listener for this socket
* @param[in] fd the FD to set
*/
-typedef int (*fr_io_set_fd_t)(fr_listen_t *listen, int fd);
+typedef int (*fr_io_set_fd_t)(fr_listen_t *li, int fd);
/** Decode a raw packet and convert it into a request.
*
int rcode;
fr_io_connection_t *connection;
dl_instance_t *dl_inst = NULL;
- fr_listen_t *listen;
+ fr_listen_t *li;
RADCLIENT *radclient;
/*
/*
* Get the child listener.
*/
- MEM(listen = connection->child = talloc(connection, fr_listen_t));
- memcpy(listen, inst->listen, sizeof(*listen));
+ MEM(li = connection->child = talloc(connection, fr_listen_t));
+ memcpy(li, inst->listen, sizeof(*li));
/*
* Glue in the actual app_io
*/
- listen->app_io = inst->child->app_io;
- listen->app_io_instance = dl_inst->data;
- listen->thread_instance = listen->app_io_instance;
+ li->app_io = inst->child->app_io;
+ li->app_io_instance = dl_inst->data;
+ li->thread_instance = li->app_io_instance;
/*
* There isn't a need to re-parse the
/*
* Create the listener, based on our listener.
*/
- MEM(listen = connection->listen = talloc(connection, fr_listen_t));
+ MEM(li = connection->listen = talloc(connection, fr_listen_t));
/*
* Note that our instance is effectively 'const'.
* i.e. we can't add things to it. Instead, we have to
* put all variable data into the connection.
*/
- memcpy(listen, inst->listen, sizeof(*listen));
+ memcpy(li, inst->listen, sizeof(*li));
/*
* Glue in the connection to the listener.
*/
- rad_assert(listen->app_io == &fr_master_app_io);
- listen->app_io_instance = connection;
- listen->thread_instance = listen->app_io_instance;
+ rad_assert(li->app_io == &fr_master_app_io);
+ li->app_io_instance = connection;
+ li->thread_instance = li->app_io_instance;
/*
* Instantiate the child, and open the socket.
/** Open a new listener
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
fr_io_instance_t *inst;
fr_io_connection_t *connection;
fr_listen_t *child;
int rcode;
- get_inst(listen->app_io_instance, &inst, &connection, &child);
+ get_inst(li->app_io_instance, &inst, &connection, &child);
/*
* One connection can't open another one.
/** Get the file descriptor for this socket.
*
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
fr_io_instance_t *inst;
fr_io_connection_t *connection;
fr_listen_t *child;
- get_inst(listen->app_io_instance, &inst, &connection, &child);
+ get_inst(li->app_io_instance, &inst, &connection, &child);
return inst->app_io->fd(child);
}
int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *io, fr_schedule_t *sc,
size_t default_message_size, size_t num_messages)
{
- fr_listen_t *listen, *child;
+ fr_listen_t *li, *child;
/*
* Build the #fr_listen_t. This describes the complete
* path data takes from the socket to the decoder and
* back again.
*/
- listen = talloc_zero(ctx, fr_listen_t);
+ li = talloc_zero(ctx, fr_listen_t);
- listen->app = io->app;
- listen->app_instance = io->app_instance;
- listen->server_cs = io->server_cs;
+ li->app = io->app;
+ li->app_instance = io->app_instance;
+ li->server_cs = io->server_cs;
/*
* Set configurable parameters for message ring buffer.
*/
- listen->default_message_size = default_message_size;
- listen->num_messages = num_messages;
+ li->default_message_size = default_message_size;
+ li->num_messages = num_messages;
- io->listen = listen;
+ io->listen = li;
io->sc = sc;
/*
/*
* Set the listener to call our master trampoline function.
*/
- listen->app_io = &fr_master_app_io;
- listen->app_io_instance = io;
- listen->thread_instance = listen->app_io_instance;
+ li->app_io = &fr_master_app_io;
+ li->app_io_instance = io;
+ li->thread_instance = li->app_io_instance;
/*
* Create the child listener, so that it can later be
* passed to the app_io functions.
*/
- child = io->child = talloc_zero(listen, fr_listen_t);
- memcpy(child, listen, sizeof(*child));
+ child = io->child = talloc_zero(li, fr_listen_t);
+ memcpy(child, li, sizeof(*child));
/*
* Reset these fields to point to the actual data.
*/
if (io->app_io->open(child) < 0) {
cf_log_err(io->app_io_conf, "Failed opening %s interface", io->app_io->name);
- talloc_free(listen);
+ talloc_free(li);
return -1;
}
* Add the socket to the scheduler, which might
* end up in a different thread.
*/
- if (!fr_schedule_listen_add(sc, listen)) {
- talloc_free(listen);
+ if (!fr_schedule_listen_add(sc, li)) {
+ talloc_free(li);
return -1;
}
/** Open a TCP listener for control sockets
*
*/
-static int mod_open(fr_listen_t *listener)
+static int mod_open(fr_listen_t *li)
{
- proto_control_tcp_t *inst = talloc_get_type_abort(listener->app_io_instance, proto_control_tcp_t);
+ proto_control_tcp_t *inst = talloc_get_type_abort(li->app_io_instance, proto_control_tcp_t);
int sockfd = 0;
uint16_t port = inst->port;
/** Get the file descriptor for this socket.
*
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_control_tcp_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_control_tcp_t);
+ proto_control_tcp_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_control_tcp_t);
return inst->sockfd;
}
/** Set the file descriptor for this socket.
*
*/
-static int mod_fd_set(fr_listen_t *listen, int fd)
+static int mod_fd_set(fr_listen_t *li, int fd)
{
- proto_control_tcp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_control_tcp_t);
+ proto_control_tcp_t *inst = talloc_get_type_abort(li->thread_instance, proto_control_tcp_t);
inst->sockfd = fd;
/** Open a UNIX listener for control sockets
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
- proto_control_unix_t *inst = talloc_get_type_abort(listen->app_io_instance, proto_control_unix_t);
+ proto_control_unix_t *inst = talloc_get_type_abort(li->app_io_instance, proto_control_unix_t);
int sockfd = 0;
CONF_ITEM *ci;
/** Get the file descriptor for this socket.
*
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_control_unix_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_control_unix_t);
+ proto_control_unix_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_control_unix_t);
return inst->sockfd;
}
/** Set the file descriptor for this socket.
*
*/
-static int mod_fd_set(fr_listen_t *listen, int fd)
+static int mod_fd_set(fr_listen_t *li, int fd)
{
- proto_control_unix_t *inst = talloc_get_type_abort(listen->thread_instance, proto_control_unix_t);
+ proto_control_unix_t *inst = talloc_get_type_abort(li->thread_instance, proto_control_unix_t);
#ifndef HAVE_FUNOPEN
cookie_io_functions_t io;
#endif
*/
static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
{
- fr_listen_t *listen;
+ fr_listen_t *li;
proto_detail_t *inst = talloc_get_type_abort(instance, proto_detail_t);
/*
* path, data takes from the socket to the decoder and
* back again.
*/
- listen = talloc_zero(inst, fr_listen_t);
+ li = talloc_zero(inst, fr_listen_t);
- listen->app_io = inst->app_io;
- listen->app_io_instance = inst->app_io_instance;
- listen->thread_instance = listen->app_io_instance;
+ li->app_io = inst->app_io;
+ li->app_io_instance = inst->app_io_instance;
+ li->thread_instance = li->app_io_instance;
- listen->app = &proto_detail;
- listen->app_instance = instance;
- listen->server_cs = inst->server_cs;
+ li->app = &proto_detail;
+ li->app_instance = instance;
+ li->server_cs = inst->server_cs;
/*
* Set configurable parameters for message ring buffer.
*/
- listen->default_message_size = inst->max_packet_size;
- listen->num_messages = inst->num_messages;
+ li->default_message_size = inst->max_packet_size;
+ li->num_messages = inst->num_messages;
/*
* Open the file.
*/
- if (inst->app_io->open(listen) < 0) {
+ if (inst->app_io->open(li) < 0) {
cf_log_err(conf, "Failed opening %s interface", inst->app_io->name);
- talloc_free(listen);
+ talloc_free(li);
return -1;
}
* directly.
*/
if (strcmp(inst->io_submodule->module->name, "proto_detail_work") == 0) {
- if (!fr_schedule_listen_add(sc, listen)) {
- talloc_free(listen);
+ if (!fr_schedule_listen_add(sc, li)) {
+ talloc_free(li);
return -1;
}
- inst->listen = listen;
+ inst->listen = li;
return 0;
}
/*
* Watch the directory for changes.
*/
- if (!fr_schedule_directory_add(sc, listen)) {
- talloc_free(listen);
+ if (!fr_schedule_directory_add(sc, li)) {
+ talloc_free(li);
return -1;
}
- inst->listen = listen; /* Probably won't need it, but doesn't hurt */
+ inst->listen = li; /* Probably won't need it, but doesn't hurt */
inst->sc = sc;
return 0;
/** Open a detail listener
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
- proto_detail_file_t *inst = talloc_get_type_abort(listen->app_io_instance, proto_detail_file_t);
+ proto_detail_file_t *inst = talloc_get_type_abort(li->app_io_instance, proto_detail_file_t);
int oflag;
#ifdef O_EVTONLY
/** Get the file descriptor for this IO instance
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_detail_file_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_detail_file_t);
+ proto_detail_file_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_detail_file_t);
return inst->fd;
}
{
bool opened = false;
proto_detail_work_t *work;
- fr_listen_t *listen = NULL;
+ fr_listen_t *li = NULL;
struct stat st;
fr_event_vnode_func_t funcs = { .delete = mod_vnode_delete };
return 1;
}
- MEM(listen = talloc_zero(NULL, fr_listen_t));
+ MEM(li = talloc_zero(NULL, fr_listen_t));
/*
* Create a new listener, and insert it into the
* This listener is parented from the worker. So that
* when the worker goes away, so does the listener.
*/
- listen->app_io = inst->parent->work_io;
+ li->app_io = inst->parent->work_io;
- listen->app = inst->parent->self;
- listen->app_instance = inst->parent;
- listen->server_cs = inst->parent->server_cs;
+ li->app = inst->parent->self;
+ li->app_instance = inst->parent;
+ li->server_cs = inst->parent->server_cs;
/*
* The worker may be in a different thread, so avoid
* talloc threading issues by using a NULL TALLOC_CTX.
*/
- MEM(listen->app_io_instance = work = talloc(listen, proto_detail_work_t));
- listen->thread_instance = listen->app_io_instance;
+ MEM(li->app_io_instance = work = talloc(li, proto_detail_work_t));
+ li->thread_instance = li->app_io_instance;
memcpy(work, inst->parent->work_submodule->data, sizeof(*work));
inst->name, inst->filename_work, fr_syserror(errno));
close(fd);
- talloc_free(listen);
+ talloc_free(li);
return -1;
}
/*
* Set configurable parameters for message ring buffer.
*/
- listen->default_message_size = inst->parent->max_packet_size;
- listen->num_messages = inst->parent->num_messages;
+ li->default_message_size = inst->parent->max_packet_size;
+ li->num_messages = inst->parent->num_messages;
PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex);
inst->parent->num_workers++;
/*
* Instantiate the new worker.
*/
- if (listen->app_io->instantiate &&
- (listen->app_io->instantiate(work,
+ if (li->app_io->instantiate &&
+ (li->app_io->instantiate(work,
inst->parent->work_io_conf) < 0)) {
- ERROR("Failed instantiating %s", listen->app_io->name);
+ ERROR("Failed instantiating %s", li->app_io->name);
goto error;
}
/*
* Limit the number of messages, retransmission, etc.
*/
- if (work->max_outstanding < listen->num_messages) {
- listen->num_messages = work->max_outstanding;
+ if (work->max_outstanding < li->num_messages) {
+ li->num_messages = work->max_outstanding;
}
if (work->max_outstanding < 1) work->max_outstanding = 1;
/*
* Open the detail.work file.
*/
- if (listen->app_io->open(listen->app_io_instance) < 0) {
- ERROR("Failed opening %s", listen->app_io->name);
+ if (li->app_io->open(li->app_io_instance) < 0) {
+ ERROR("Failed opening %s", li->app_io->name);
goto error;
}
opened = true;
- if (!fr_schedule_listen_add(inst->parent->sc, listen)) {
+ if (!fr_schedule_listen_add(inst->parent->sc, li)) {
error:
if (fr_event_fd_delete(inst->el, inst->vnode_fd, FR_EVENT_FILTER_VNODE) < 0) {
PERROR("Failed removing DELETE callback when opening work file");
inst->vnode_fd = -1;
if (opened) {
- (void) listen->app_io->close(listen->app_io_instance);
- listen = NULL;
+ (void) li->app_io->close(li->app_io_instance);
+ li = NULL;
}
detach:
- if (listen) (void) listen->app_io->detach(listen->app_io_instance);
- talloc_free(listen);
+ if (li) (void) li->app_io->detach(li->app_io_instance);
+ talloc_free(li);
return -1;
}
/** Open a detail listener
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
- proto_detail_work_t *inst = talloc_get_type_abort(listen->app_io_instance, proto_detail_work_t);
+ proto_detail_work_t *inst = talloc_get_type_abort(li->app_io_instance, proto_detail_work_t);
/*
* Open the file if we haven't already been given one.
inst->fd = -1;
if (inst->free_on_close) {
- fr_listen_t *listen = talloc_get_type_abort(talloc_parent(inst), fr_listen_t);
+ fr_listen_t *li = talloc_get_type_abort(talloc_parent(inst), fr_listen_t);
- talloc_free(listen);
+ talloc_free(li);
}
return 0;
/** Get the file descriptor for this IO instance
*
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_detail_work_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_detail_work_t);
+ proto_detail_work_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_detail_work_t);
return inst->fd;
}
/** Open a UDP listener for DHCPV4
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
- proto_dhcpv4_udp_t *inst = talloc_get_type_abort(listen->app_io_instance, proto_dhcpv4_udp_t);
+ proto_dhcpv4_udp_t *inst = talloc_get_type_abort(li->app_io_instance, proto_dhcpv4_udp_t);
int sockfd = 0;
uint16_t port = inst->port;
/** Get the file descriptor for this socket.
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_dhcpv4_udp_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_dhcpv4_udp_t);
+ proto_dhcpv4_udp_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_dhcpv4_udp_t);
return inst->sockfd;
}
/** Set the file descriptor for this socket.
*
*/
-static int mod_fd_set(fr_listen_t *listen, int fd)
+static int mod_fd_set(fr_listen_t *li, int fd)
{
- proto_dhcpv4_udp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_dhcpv4_udp_t);
+ proto_dhcpv4_udp_t *inst = talloc_get_type_abort(li->thread_instance, proto_dhcpv4_udp_t);
inst->sockfd = fd;
/** Describe the socket we opened to the LDAP server
*
- * @param[in] listen abstracting the connection to the server.
+ * @param[in] li abstracting the connection to the server.
* @param[out] buffer Where to write text describing the socket.
* @param[in] bufsize the length of data written to buffe.r
* @return 1.
* Sets various fields in the request->packet with information from the file descriptor
* we received from libldap.
*
- * @param[in] listen The common listener encapsulating the libldap fd.
+ * @param[in] li The common listener encapsulating the libldap fd.
* @param[in] inst of the proto_ldap_sync module.
* @param[in] sync_id the unique identifier of the sync.
* @return
*
* @param[in] ctx to allocate cookie buffer in.
* @param[out] cookie Where to write the cookie we loaded.
- * @param[in] listen structure encapsulating the LDAP
+ * @param[in] li structure encapsulating the LDAP
* @param[in] config of the sync we're loading the cookie for.
* @return
* - -1 on failure.
* circumstances. This needs to be fixed, but is waiting on v4.0.0
* re-architecture.
*
- * @param[in] listen encapsulating the libldap socket.
+ * @param[in] li encapsulating the libldap socket.
* @return
* - 1 on success.
* - 0 on failure.
* @note This is performed synchronously.
*
* @param[in] cs specifying the listener configuration.
- * @param[in] listen structure encapsulating the libldap socket.
+ * @param[in] li structure encapsulating the libldap socket.
* @return
* - 0 on success.
* - -1 on error.
/** Parse socket configuration
*
* @param[in] cs specifying the listener configuration.
- * @param[in] listen structure encapsulating the libldap socket.
+ * @param[in] li structure encapsulating the libldap socket.
* @return
* - 0 on success.
* - -1 on error.
/** Compile the various recv/load/store sections
*
* @param[in] server_cs The virtual server containing the sections to compile.
- * @param[in] listen_cs The listen config section.
+ * @param[in] li_cs The listen config section.
*/
static int proto_ldap_listen_compile(CONF_SECTION *server_cs, UNUSED CONF_SECTION *listen_cs)
{
/** Open a TCP listener for RADIUS
*
*/
-static int mod_open(fr_listen_t *listener)
+static int mod_open(fr_listen_t *li)
{
- proto_radius_tcp_t *inst = talloc_get_type_abort(listener->app_io_instance, proto_radius_tcp_t);
+ proto_radius_tcp_t *inst = talloc_get_type_abort(li->app_io_instance, proto_radius_tcp_t);
int sockfd = 0;
uint16_t port = inst->port;
/** Get the file descriptor for this socket.
*
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_radius_tcp_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_radius_tcp_t);
+ proto_radius_tcp_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_radius_tcp_t);
return inst->sockfd;
}
/** Set the file descriptor for this socket.
*/
-static int mod_fd_set(fr_listen_t *listen, int fd)
+static int mod_fd_set(fr_listen_t *li, int fd)
{
- proto_radius_tcp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_radius_tcp_t);
+ proto_radius_tcp_t *inst = talloc_get_type_abort(li->thread_instance, proto_radius_tcp_t);
inst->sockfd = fd;
/** Open a UDP listener for RADIUS
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
- proto_radius_udp_t *inst = talloc_get_type_abort(listen->app_io_instance, proto_radius_udp_t);
+ proto_radius_udp_t *inst = talloc_get_type_abort(li->app_io_instance, proto_radius_udp_t);
int sockfd = 0;
uint16_t port = inst->port;
/** Get the file descriptor for this socket.
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_radius_udp_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_radius_udp_t);
+ proto_radius_udp_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_radius_udp_t);
return inst->sockfd;
}
/** Set the file descriptor for this socket.
*
*/
-static int mod_fd_set(fr_listen_t *listen, int fd)
+static int mod_fd_set(fr_listen_t *li, int fd)
{
- proto_radius_udp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_radius_udp_t);
+ proto_radius_udp_t *inst = talloc_get_type_abort(li->thread_instance, proto_radius_udp_t);
inst->sockfd = fd;
/** Open a UDP listener for VMPS
*
*/
-static int mod_open(fr_listen_t *listen)
+static int mod_open(fr_listen_t *li)
{
- proto_vmps_udp_t *inst = talloc_get_type_abort(listen->app_io_instance, proto_vmps_udp_t);
+ proto_vmps_udp_t *inst = talloc_get_type_abort(li->app_io_instance, proto_vmps_udp_t);
int sockfd = 0;
uint16_t port = inst->port;
/** Get the file descriptor for this socket.
*
*/
-static int mod_fd(fr_listen_t const *listen)
+static int mod_fd(fr_listen_t const *li)
{
- proto_vmps_udp_t const *inst = talloc_get_type_abort_const(listen->thread_instance, proto_vmps_udp_t);
+ proto_vmps_udp_t const *inst = talloc_get_type_abort_const(li->thread_instance, proto_vmps_udp_t);
return inst->sockfd;
}
/** Set the file descriptor for this socket.
*
*/
-static int mod_fd_set(fr_listen_t *listen, int fd)
+static int mod_fd_set(fr_listen_t *li, int fd)
{
- proto_vmps_udp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_vmps_udp_t);
+ proto_vmps_udp_t *inst = talloc_get_type_abort(li->thread_instance, proto_vmps_udp_t);
inst->sockfd = fd;