All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
detail.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_DETAIL_H
17 #define _FR_DETAIL_H
18 /**
19  * $Id: 33bfbd308fe3c6ff9f0088f926561833e91766bd $
20  *
21  * @file include/detail.h
22  * @brief API to deserialise packets in detail file format and inject them into the server.
23  *
24  * @copyright 2015 The FreeRADIUS server project
25  */
26 RCSIDH(detail_h, "$Id: 33bfbd308fe3c6ff9f0088f926561833e91766bd $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef enum detail_state_t {
42 
43 /*
44  * Allow people to revert to the old behavior if desired.
45  * Also, use the old code if we don't have threads.
46  * FIXME: delete the old (crappy) code, and enable the new
47  * code to work without threads. One thing at a time...
48  */
49 #ifndef WITHOUT_DETAIL_THREAD
50 # ifdef HAVE_PTHREAD_H
51 # define WITH_DETAIL_THREAD (1)
52 # endif
53 #endif
54 
55 typedef struct listen_detail_t {
56  fr_event_t *ev; /* has to be first entry (ugh) */
57  char const *name; //!< Identifier used in log messages
59  char const *filename;
60  char const *filename_work;
62  int work_fd;
63 
64 #ifdef WITH_DETAIL_THREAD
65  int master_pipe[2];
66  int child_pipe[2];
67  pthread_t pthread_id;
68 #endif
69 
70  FILE *fp;
71  off_t offset;
73  time_t timestamp;
74  time_t running;
76 
77  off_t last_offset;
79  bool done_entry; //!< Are we done reading this entry?
80  bool track; //!< Do we track progress through the file?
81 
82  uint32_t load_factor; /* 1..100 */
83  uint32_t poll_interval;
84  uint32_t retry_interval;
85 
86  int signal;
87  int packets;
88  int tries;
89  bool one_shot;
91  int has_rtt;
92  int srtt;
93  int rttvar;
94  uint32_t counter;
95  struct timeval last_packet;
98 
99 int detail_recv(rad_listen_t *listener);
100 int detail_send(rad_listen_t *listener, REQUEST *request);
101 void detail_free(rad_listen_t *this);
102 int detail_print(rad_listen_t const *this, char *buffer, size_t bufsize);
103 int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request);
104 int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request);
105 int detail_parse(CONF_SECTION *cs, rad_listen_t *this);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* _FR_DETAIL_H */
time_t running
Definition: detail.h:74
#define RCSIDH(h, id)
Definition: build.h:136
struct listen_detail_t listen_detail_t
off_t offset
Definition: detail.h:71
uint32_t counter
Definition: detail.h:94
VALUE_PAIR * vps
Definition: detail.h:61
int outstanding
Definition: detail.h:90
#define UNUSED
Definition: libradius.h:134
char const * filename
Definition: detail.h:59
int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request)
Definition: detail.c:1027
time_t timestamp
Definition: detail.h:73
detail_state_t
Definition: detail.h:32
fr_ipaddr_t client_ip
Definition: detail.h:75
off_t timestamp_offset
Definition: detail.h:78
fr_event_t * ev
Definition: detail.h:56
uint32_t retry_interval
Definition: detail.h:84
RADCLIENT detail_client
Definition: detail.h:96
uint32_t poll_interval
Definition: detail.h:83
int detail_print(rad_listen_t const *this, char *buffer, size_t bufsize)
Definition: detail.c:962
int detail_socket_open(CONF_SECTION *cs, rad_listen_t *this)
FILE * fp
Definition: detail.h:70
Stores an attribute, a value and various bits of other data.
Definition: pair.h:112
struct timeval last_packet
Definition: detail.h:95
bool track
Do we track progress through the file?
Definition: detail.h:80
Describes a host allowed to send packets to the server.
Definition: clients.h:35
void detail_free(rad_listen_t *this)
Definition: detail.c:914
int detail_recv(rad_listen_t *listener)
Definition: detail.c:316
char const * filename_work
Definition: detail.h:60
off_t last_offset
Definition: detail.h:77
char const * name
Identifier used in log messages.
Definition: detail.h:57
bool one_shot
Definition: detail.h:89
uint32_t load_factor
Definition: detail.h:82
int delay_time
Definition: detail.h:58
int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request)
Definition: detail.c:999
bool done_entry
Are we done reading this entry?
Definition: detail.h:79
IPv4/6 prefix.
Definition: inet.h:41
int detail_send(rad_listen_t *listener, REQUEST *request)
Definition: detail.c:64
detail_state_t state
Definition: detail.h:72
int detail_parse(CONF_SECTION *cs, rad_listen_t *this)
Definition: detail.c:1109