Track Exponential moving average of response times for
[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_INVALID (0)
16 #define HOME_TYPE_AUTH    (1)
17 #define HOME_TYPE_ACCT    (2)
18
19 #define HOME_PING_CHECK_NONE            (0)
20 #define HOME_PING_CHECK_STATUS_SERVER   (1)
21 #define HOME_PING_CHECK_REQUEST         (2)
22
23 #define HOME_STATE_ALIVE                (0)
24 #define HOME_STATE_ZOMBIE               (1)
25 #define HOME_STATE_IS_DEAD              (2)
26
27 typedef struct home_server {
28         const char      *name;
29
30         const char      *hostname;
31         const char      *server; /* for internal proxying */
32
33         fr_ipaddr_t     ipaddr;
34
35         int             port;
36         int             type;           /* auth/acct */
37
38         /*
39          *      Maybe also have list of source IP/ports, && socket?
40          */
41
42         const char      *secret;
43
44         fr_event_t      *ev;
45         struct timeval  when;
46
47         int             response_window;
48         int             max_outstanding; /* don't overload it */
49         int             currently_outstanding;
50
51         struct timeval  revive_time;
52         struct timeval  zombie_period_start;
53         int             zombie_period; /* unresponsive for T, mark it dead */
54
55         int             state;
56
57         int             ping_check;
58         const char      *ping_user_name;
59         const char      *ping_user_password;
60
61         int             ping_interval;
62         int             num_pings_to_alive;
63         int             num_received_pings;
64         int             ping_timeout;
65
66         int             revive_interval; /* if it doesn't support pings */
67         CONF_SECTION    *cs;
68 #ifdef WITH_STATS
69         fr_stats_t      stats;
70
71         fr_stats_ema_t  ema;
72 #endif
73 } home_server;
74
75
76 typedef enum home_pool_type_t {
77         HOME_POOL_INVALID = 0,
78         HOME_POOL_LOAD_BALANCE,
79         HOME_POOL_FAIL_OVER,
80         HOME_POOL_CLIENT_BALANCE,
81         HOME_POOL_CLIENT_PORT_BALANCE,
82         HOME_POOL_KEYED_BALANCE
83 } home_pool_type_t;
84
85
86 typedef struct home_pool_t {
87         const char              *name;
88         home_pool_type_t        type;
89
90         int                     server_type;
91         CONF_SECTION            *cs;
92
93         const char              *virtual_server; /* for pre/post-proxy */
94         
95         home_server             *fallback;
96
97         int                     num_home_servers;
98         home_server             *servers[1];
99 } home_pool_t;
100
101
102 typedef struct _realm {
103         const char              *name;
104
105         int                     striprealm;
106
107         home_pool_t             *auth_pool;
108         home_pool_t             *acct_pool;
109 } REALM;
110
111 int realms_init(CONF_SECTION *config);
112 void realms_free(void);
113 REALM *realm_find(const char *name); /* name is from a packet */
114 REALM *realm_find2(const char *name); /* ... with name taken from realm_find */
115
116 home_server *home_server_ldb(const char *realmname, home_pool_t *pool, REQUEST *request);
117 home_server *home_server_find(fr_ipaddr_t *ipaddr, int port);
118
119 #endif /* REALMS_H */