The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
proto_detail.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: d6e360a7de23fac314f6fa4fc5e936df68e54441 $
20 *
21 * @file proto_detail.h
22 * @brief Detail master protocol handler.
23 *
24 * @copyright 2017 Alan DeKok (alan@freeradius.org)
25 */
26RCSIDH(detail_h, "$Id: d6e360a7de23fac314f6fa4fc5e936df68e54441 $")
27
28#include <freeradius-devel/io/application.h>
29#include <freeradius-devel/server/module_rlm.h>
30#include <freeradius-devel/util/retry.h>
31#include <freeradius-devel/util/dlist.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37typedef struct {
38 CONF_SECTION *server_cs; //!< server CS for this listener
39 fr_app_t *self; //!< child / parent linking issues
40 char const *type; //!< packet type name
41
42 module_instance_t *io_submodule; //!< As provided by the transport_parse
43 ///< callback. Broken out into the
44 ///< app_io_* fields below for convenience.
45
46 fr_app_io_t const *app_io; //!< Easy access to the app_io handle.
47 void *app_io_instance; //!< Easy access to the app_io instance.
48 CONF_SECTION *app_io_conf; //!< Easy access to the app_io's config section.
49// proto_detail_app_io_t *app_io_private; //!< Internal interface for proto_radius.
50
52
53 fr_app_io_t const *work_io; //!< Easy access to the app_io handle.
54 void *work_io_instance; //!< Easy access to the app_io instance.
55 CONF_SECTION *work_io_conf; //!< Easy access to the app_io's config secti
56
57 fr_dict_t const *dict; //!< root dictionary
59
60 uint32_t code; //!< packet code to use for incoming packets
61 uint32_t max_packet_size; //!< for message ring buffer
62 uint32_t num_messages; //!< for message ring buffer
63 uint32_t priority; //!< for packet processing, larger == higher
64
65 /** Hacked in functionality to allow easy testing of the detail reader.
66 */
67 bool exit_when_done; //!< exit when done reading the current file.
68
69 fr_schedule_t *sc; //!< the scheduler, where we insert new readers
70
71 fr_listen_t *listen; //!< The listener structure which describes
72 //!< the I/O path.
74
76
77/*
78 * The detail "work" data structure, shared by all of the detail readers.
79 */
81 CONF_SECTION *cs; //!< our configuration section
82
83 proto_detail_t *parent; //!< The module that spawned us!
84 char const *directory; //!< containing the file below
85 char const *filename; //!< file name, usually with wildcards
86 char const *filename_work; //!< work file name
87
88 uint32_t poll_interval; //!< interval between polling
89
90 fr_retry_config_t retry_config; //!< retry config with irt, mrt, etc.
91 uint16_t max_outstanding; //!< number of packets to run in parallel
92
93 bool track_progress; //!< do we track progress by writing?
94 bool retransmit; //!< are we retransmitting on error?
95 bool immediate; //!< start reading the detail files immediately
96
97 int mode; //!< O_RDWR or O_RDONLY
98
100
101 fr_client_t *client; //!< so the rest of the server doesn't complain
102};
103
105
107 char const *name; //!< debug name for printing
108 proto_detail_work_t const *inst; //!< instance data
109
110 int fd; //!< file descriptor
111 int vnode_fd; //!< file descriptor for vnode_delete
112
113 fr_event_list_t *el; //!< for various timers
114 fr_network_t *nr; //!< for Linux-specific callbacks
115 fr_listen_t *listen; //!< talloc_parent() is slow
116 proto_detail_work_thread_t *file_parent; //!< thread instance of the directory reader that spawned us
117
118 char const *filename_work; //!< work file name
119 fr_dlist_head_t list; //!< for retransmissions
120
121 uint32_t outstanding; //!< number of currently outstanding records;
122 fr_time_delta_t lock_interval; //!< interval between trying the locks.
123
124 bool eof; //!< are we at EOF on reading?
125 bool closing; //!< we should be closing the file
126 bool paused; //!< Is reading paused?
127
128 int count; //!< number of packets we read from this file.
129
130 size_t leftover;
132
133 size_t last_search; //!< where we last searched in the buffer
134 //!< MUST be offset, as the buffers can change.
135 unsigned int last_line; //!< line number of the last record read.
136
137 off_t file_size; //!< size of the file
138 off_t header_offset; //!< offset of the current header we're reading
139 off_t read_offset; //!< where we're reading from in filename_work
140
141 fr_event_timer_t const *ev; //!< for detail file timers.
142
143 pthread_mutex_t worker_mutex; //!< for the workers
144 int num_workers; //!< number of workers
145};
146
147#include <pthread.h>
148
149#ifdef __cplusplus
150}
151#endif
Public structure describing an I/O path for a protocol.
Definition app_io.h:33
Describes a new application (protocol)
Definition application.h:71
#define RCSIDH(h, id)
Definition build.h:484
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
Head of a doubly linked list.
Definition dlist.h:51
Describes a host allowed to send packets to the server.
Definition client.h:80
Stores all information relating to an event list.
Definition event.c:411
A timer event.
Definition event.c:102
unsigned short uint16_t
unsigned int uint32_t
unsigned char uint8_t
long long int off_t
size_t last_search
where we last searched in the buffer MUST be offset, as the buffers can change.
proto_detail_t * parent
The module that spawned us!
proto_detail_work_thread_t * file_parent
thread instance of the directory reader that spawned us
CONF_SECTION * work_io_conf
Easy access to the app_io's config secti.
bool immediate
start reading the detail files immediately
fr_rb_node_t filename_node
for dedup
fr_dict_attr_t const * attr_packet_type
char const * directory
containing the file below
char const * filename_work
work file name
bool paused
Is reading paused?
uint32_t max_packet_size
for message ring buffer
fr_time_delta_t lock_interval
interval between trying the locks.
int count
number of packets we read from this file.
bool track_progress
do we track progress by writing?
unsigned int last_line
line number of the last record read.
bool eof
are we at EOF on reading?
bool exit_when_done
Hacked in functionality to allow easy testing of the detail reader.
fr_listen_t * listen
talloc_parent() is slow
void * work_io_instance
Easy access to the app_io instance.
char const * filename
file name, usually with wildcards
CONF_SECTION * server_cs
server CS for this listener
fr_client_t * client
so the rest of the server doesn't complain
char const * name
debug name for printing
bool retransmit
are we retransmitting on error?
module_instance_t * io_submodule
As provided by the transport_parse callback.
fr_event_timer_t const * ev
for detail file timers.
int num_workers
number of workers
CONF_SECTION * app_io_conf
Easy access to the app_io's config section.
uint16_t max_outstanding
number of packets to run in parallel
fr_event_list_t * el
for various timers
fr_app_io_t const * work_io
Easy access to the app_io handle.
CONF_SECTION * cs
our configuration section
off_t file_size
size of the file
pthread_mutex_t worker_mutex
for the workers
fr_dict_t const * dict
root dictionary
fr_app_io_t const * app_io
Easy access to the app_io handle.
fr_schedule_t * sc
the scheduler, where we insert new readers
char const * filename_work
work file name
module_instance_t * work_submodule
the worker
off_t header_offset
offset of the current header we're reading
uint32_t poll_interval
interval between polling
proto_detail_work_t const * inst
instance data
fr_dlist_head_t list
for retransmissions
uint32_t code
packet code to use for incoming packets
fr_retry_config_t retry_config
retry config with irt, mrt, etc.
uint32_t num_messages
for message ring buffer
fr_app_t * self
child / parent linking issues
int mode
O_RDWR or O_RDONLY.
int fd
file descriptor
char const * type
packet type name
bool closing
we should be closing the file
void * app_io_instance
Easy access to the app_io instance.
uint32_t priority
for packet processing, larger == higher
int vnode_fd
file descriptor for vnode_delete
fr_listen_t * listen
The listener structure which describes the I/O path.
off_t read_offset
where we're reading from in filename_work
uint32_t outstanding
number of currently outstanding records;
fr_network_t * nr
for Linux-specific callbacks
The scheduler.
Definition schedule.c:125
Module instance data.
Definition module.h:265
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80