All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
realms.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_REALMS_H
17 #define _FR_REALMS_H
18 /**
19  * $Id: 9d3cfe787e6b0707c2e5d2f2df8df66a82159af7 $
20  *
21  * @file include/realms.h
22  * @brief Request forwarding API.
23  *
24  * @copyright 2015 The FreeRADIUS server project
25  */
26 RCSIDH(realms_h, "$Id: 9d3cfe787e6b0707c2e5d2f2df8df66a82159af7 $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 extern bool home_servers_udp; //!< Whether there are any UDP home servers
33 
34 typedef enum {
36  HOME_TYPE_AUTH, //!< Authentication server
37  HOME_TYPE_ACCT, //!< Accounting server
38  HOME_TYPE_AUTH_ACCT //!< Authentication and accounting server
39 
40 #ifdef WITH_COA
41  ,HOME_TYPE_COA //!< CoA destination (NAS or Proxy)
42 #endif
43 } home_type_t;
44 
45 typedef enum {
51 
52 typedef enum {
57 } home_state_t;
58 
59 typedef struct fr_socket_limit_t {
60  uint32_t max_connections;
61  uint32_t num_connections;
62  uint32_t max_requests;
63  uint32_t num_requests;
64  uint32_t lifetime;
65  uint32_t idle_timeout;
67 
68 typedef struct home_server {
69  char const *log_name; //!< The name used for log messages.
70 
71  char const *name; //!< Name the server may be referenced by for querying
72  //!< stats or when specifying home servers for a pool.
73 
74  bool dual; //!< One of a pair of homeservers on consecutive ports.
75  char const *server; //!< For internal proxying
76  char const *parent_server;
77 
78  fr_ipaddr_t ipaddr; //!< IP address of home server.
79  uint16_t port;
80 
81  char const *type_str; //!< String representation of type.
82  home_type_t type; //!< Auth, Acct, CoA etc.
83 
84  char const *src_ipaddr_str; //!< Need to parse the string specially as it may
85  //!< require a DNS lookup and the address family for that
86  //!< is the same as ipaddr.
87  fr_ipaddr_t src_ipaddr; //!< Resolved version of src_ipaddr_str. Preferred source
88  //!< IP address (useful for multihomed systems).
89 
90  char const *proto_str; //!< String representation of protocol.
91  int proto; //!< TCP or UDP.
92 
94 
95  char const *secret;
96 
98  struct timeval when;
99 
100  struct timeval response_window;
103  uint32_t max_outstanding; //!< Maximum outstanding requests.
105 
109  struct timeval revive_time;
110  struct timeval zombie_period_start;
111  uint32_t zombie_period; //!< Unresponsive for T, mark it dead.
112 
113  int state;
114 
115  char const *ping_check_str;
116  home_ping_check_t ping_check; //!< What method we use to perform the 'ping'
117  //!< none, status-server or fake request.
118 
119  char const *ping_user_name;
120  char const *ping_user_password;
121 
122  uint32_t ping_interval;
124  uint32_t num_sent_pings;
126  uint32_t ping_timeout;
127 
128  uint32_t revive_interval; //!< How often we revive it (if it doesn't support pings).
130 #ifdef WITH_COA
131  uint32_t coa_irt;
132  uint32_t coa_mrc;
133  uint32_t coa_mrt;
134  uint32_t coa_mrd;
135 #endif
136 #ifdef WITH_TLS
137  fr_tls_server_conf_t *tls;
138 #endif
139 
140 #ifdef WITH_STATS
141  int number;
142 
144 
146 #endif
147 } home_server_t;
148 
149 
150 typedef enum home_pool_type_t {
158 
159 
160 typedef struct home_pool_t {
161  char const *name;
163 
166 
167  char const *virtual_server; /* for pre/post-proxy */
168 
172 
175 } home_pool_t;
176 
177 
178 typedef struct _realm {
179  char const *name;
180 
182 
185 #ifdef WITH_COA
187 #endif
188 } REALM;
189 
191 
192 int realms_init(CONF_SECTION *config);
193 void realms_free(void);
194 REALM *realm_find(char const *name); /* name is from a packet */
195 REALM *realm_find2(char const *name); /* ... with name taken from realm_find */
196 
199 void realm_pool_free(home_pool_t *pool);
202 
203 void home_server_update_request(home_server_t *home, REQUEST *request);
204 home_server_t *home_server_ldb(char const *realmname, home_pool_t *pool, REQUEST *request);
205 home_server_t *home_server_find(fr_ipaddr_t *ipaddr, uint16_t port, int proto);
206 
209 #ifdef WITH_COA
210 home_server_t *home_server_byname(char const *name, int type);
211 #endif
212 #ifdef WITH_STATS
214 #endif
215 home_pool_t *home_pool_byname(char const *name, int type);
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* _FR_REALMS_H */
void home_server_update_request(home_server_t *home, REQUEST *request)
Definition: realms.c:2285
CONF_SECTION * cs
Definition: realms.c:56
home_server_t * servers[1]
Definition: realms.h:174
char const * name
Name the server may be referenced by for querying stats or when specifying home servers for a pool...
Definition: realms.h:71
REALM * realm_find2(char const *name)
Definition: realms.c:2201
#define RCSIDH(h, id)
Definition: build.h:136
fr_ipaddr_t src_ipaddr
Resolved version of src_ipaddr_str.
Definition: realms.h:87
struct home_pool_t home_pool_t
int realms_init(CONF_SECTION *config)
Definition: realms.c:2070
bool home_servers_udp
Whether there are any UDP home servers.
Definition: realms.c:38
char const * ping_user_name
Definition: realms.h:119
uint32_t ping_interval
Definition: realms.h:122
char const * ping_check_str
Definition: realms.h:115
int in_fallback
Definition: realms.h:170
fr_socket_limit_t limit
Definition: realms.h:93
fr_stats_t stats
Definition: realms.h:143
char const * ping_user_password
Definition: realms.h:120
time_t last_packet_recv
Definition: realms.h:107
struct timeval when
Definition: realms.h:98
static char const * name
home_type_t server_type
Definition: realms.h:164
uint32_t coa_mrd
Definition: realms.h:134
CONF_SECTION * cs
Definition: realms.h:129
void realm_home_server_sanitize(home_server_t *home, CONF_SECTION *cs)
Definition: realms.c:362
home_server_t * home_server_bynumber(int number)
Definition: realms.c:2692
uint32_t num_pings_to_alive
Definition: realms.h:123
home_pool_t * auth_pool
Definition: realms.h:183
Definition: realms.h:178
fr_event_t * ev
Definition: realms.h:97
home_pool_type_t
Definition: realms.h:150
uint32_t max_connections
Definition: realms.h:60
char const * type_str
String representation of type.
Definition: realms.h:81
home_type_t
Definition: realms.h:34
CONF_SECTION * cs
Definition: realms.h:165
uint32_t coa_irt
Definition: realms.h:131
static char const * proto
Definition: radclient.c:63
Authentication and accounting server.
Definition: realms.h:38
uint32_t response_timeouts
Definition: realms.h:101
struct home_server home_server_t
char const * server
For internal proxying.
Definition: realms.h:75
uint32_t max_requests
Definition: realms.h:62
uint32_t ping_timeout
Definition: realms.h:126
struct fr_socket_limit_t fr_socket_limit_t
time_t last_failed_open
Definition: realms.h:108
home_server_t * home_server_ldb(char const *realmname, home_pool_t *pool, REQUEST *request)
Definition: realms.c:2352
bool strip_realm
Definition: realms.h:181
CONF_SECTION * home_server_cs_afrom_client(CONF_SECTION *client)
Fixup a client configuration section to specify a home server.
Definition: realms.c:889
home_pool_t * coa_pool
Definition: realms.h:186
struct timeval revive_time
Definition: realms.h:109
uint32_t num_connections
Definition: realms.h:61
uint32_t num_requests
Definition: realms.h:63
char const * proto_str
String representation of protocol.
Definition: realms.h:90
CoA destination (NAS or Proxy)
Definition: realms.h:41
int realm_pool_add(home_pool_t *pool, CONF_SECTION *cs)
time_t time_all_dead
Definition: realms.h:171
home_state_t
Definition: realms.h:52
int num_home_servers
Definition: realms.h:173
void realms_free(void)
Definition: realms.c:256
bool dual
One of a pair of homeservers on consecutive ports.
Definition: realms.h:74
uint32_t idle_timeout
Definition: realms.h:65
char const * log_name
The name used for log messages.
Definition: realms.h:69
home_pool_type_t type
Definition: realms.h:162
REALM * realm_find(char const *name)
Definition: realms.c:2235
uint32_t max_outstanding
Maximum outstanding requests.
Definition: realms.h:103
home_server_t * fallback
Definition: realms.h:169
uint32_t coa_mrc
Definition: realms.h:132
home_ping_check_t ping_check
What method we use to perform the 'ping' none, status-server or fake request.
Definition: realms.h:116
uint32_t num_received_pings
Definition: realms.h:125
bool realm_home_server_add(home_server_t *home)
Add an already allocate home_server_t to the various trees.
Definition: realms.c:485
home_ping_check_t
Definition: realms.h:45
char const * name
Definition: realms.h:179
int state
Definition: realms.h:113
char const * src_ipaddr_str
Need to parse the string specially as it may require a DNS lookup and the address family for that is ...
Definition: realms.h:84
int realm_realm_add(REALM *r, CONF_SECTION *cs)
home_server_t * home_server_afrom_cs(TALLOC_CTX *ctx, realm_config_t *rc, CONF_SECTION *cs)
Alloc a new home server defined by a CONF_SECTION.
Definition: realms.c:569
char const * virtual_server
Definition: realms.h:167
time_t last_packet_sent
Definition: realms.h:106
uint32_t currently_outstanding
Definition: realms.h:104
uint32_t max_response_timeouts
Definition: realms.h:102
struct _realm REALM
IPv4/6 prefix.
Definition: inet.h:41
int number
Definition: realms.h:141
char const * parent_server
Definition: realms.h:76
void realm_pool_free(home_pool_t *pool)
Definition: realms.c:1011
home_pool_t * home_pool_byname(char const *name, int type)
Definition: realms.c:2704
home_server_t * home_server_byname(char const *name, int type)
Definition: realms.c:2679
home_server_t * home_server_find(fr_ipaddr_t *ipaddr, uint16_t port, int proto)
Definition: realms.c:2660
struct timeval zombie_period_start
Definition: realms.h:110
uint32_t coa_mrt
Definition: realms.h:133
home_pool_t * acct_pool
Definition: realms.h:184
Accounting server.
Definition: realms.h:37
static int r
Definition: rbmonkey.c:66
uint32_t revive_interval
How often we revive it (if it doesn't support pings).
Definition: realms.h:128
fr_stats_ema_t ema
Definition: realms.h:145
home_type_t type
Auth, Acct, CoA etc.
Definition: realms.h:82
char const * secret
Definition: realms.h:95
uint16_t port
Definition: realms.h:79
char const * name
Definition: realms.h:161
uint32_t lifetime
Definition: realms.h:64
uint32_t zombie_period
Unresponsive for T, mark it dead.
Definition: realms.h:111
int proto
TCP or UDP.
Definition: realms.h:91
uint32_t num_sent_pings
Definition: realms.h:124
Authentication server.
Definition: realms.h:36
fr_ipaddr_t ipaddr
IP address of home server.
Definition: realms.h:78
struct timeval response_window
Definition: realms.h:100