Added configurable timeouts specifically for ping checks.
[freeradius.git] / src / include / realms.h
1 #ifndef REALMS_H
2 #define REALMS_H
3
4 /*
5  * realms.h     Structures, prototypes and global variables
6  *              for realms
7  *
8  * Version:     $Id$
9  *
10  */
11
12 #include <freeradius-devel/ident.h>
13 RCSIDH(realms_h, "$Id$")
14
15 #define HOME_TYPE_AUTH (1)
16 #define HOME_TYPE_ACCT (2)
17
18 #define HOME_PING_CHECK_NONE            (0)
19 #define HOME_PING_CHECK_STATUS_SERVER   (1)
20 #define HOME_PING_CHECK_REQUEST         (2)
21
22 #define HOME_STATE_ALIVE                (0)
23 #define HOME_STATE_ZOMBIE               (1)
24 #define HOME_STATE_IS_DEAD              (2)
25
26 typedef struct home_server {
27         const char      *name;
28
29         const char      *hostname;
30
31         lrad_ipaddr_t   ipaddr;
32
33         
34         int             port;
35         int             type;           /* auth/acct */
36
37         /*
38          *      Maybe also have list of source IP/ports, && socket?
39          */
40
41         const char      *secret;
42
43         lrad_event_t    *ev;
44         struct timeval  when;
45         
46         int             response_window;
47         int             max_outstanding; /* don't overload it */
48         int             currently_outstanding;
49         
50         struct timeval  zombie_period_start;
51         int             zombie_period; /* unresponsive for T, mark it dead */
52
53         int             state;
54
55         int             ping_check;
56         const char      *ping_user_name;
57         const char      *ping_user_password;
58
59         int             ping_interval;
60         int             num_pings_to_alive;
61         int             num_received_pings;
62         int             ping_timeout;
63
64         int             revive_interval; /* if it doesn't support pings */
65 } home_server;
66
67
68 typedef enum home_pool_type_t {
69         HOME_POOL_INVALID = 0,
70         HOME_POOL_LOAD_BALANCE,
71         HOME_POOL_FAIL_OVER,
72         HOME_POOL_CLIENT_BALANCE
73 } home_pool_type_t;
74
75
76 typedef struct home_pool_t {
77         const char              *name;
78         home_pool_type_t        type;
79
80         int                     server_type;
81
82         int                     num_home_servers;
83         home_server             *servers[1];
84 } home_pool_t;
85
86
87 typedef struct _realm {
88         const char              *name;
89
90         int                     striprealm;
91
92         home_pool_t             *auth_pool;
93         home_pool_t             *acct_pool;
94 } REALM;
95
96 int realms_init(const char *filename);
97 void realms_free(void);
98 int realm_add(const char *filename, CONF_SECTION *cs);
99 REALM *realm_find(const char *name);
100
101 home_server *home_server_ldb(const char *realmname, home_pool_t *pool, REQUEST *request);
102 home_server *home_server_find(lrad_ipaddr_t *ipaddr, int port);
103
104 #endif /* REALMS_H */