Added "keyed-balance", which allows load balancing based
[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
32         lrad_ipaddr_t   ipaddr;
33
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         lrad_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  zombie_period_start;
52         int             zombie_period; /* unresponsive for T, mark it dead */
53
54         int             state;
55
56         int             ping_check;
57         const char      *ping_user_name;
58         const char      *ping_user_password;
59
60         int             ping_interval;
61         int             num_pings_to_alive;
62         int             num_received_pings;
63         int             ping_timeout;
64
65         int             revive_interval; /* if it doesn't support pings */
66 } home_server;
67
68
69 typedef enum home_pool_type_t {
70         HOME_POOL_INVALID = 0,
71         HOME_POOL_LOAD_BALANCE,
72         HOME_POOL_FAIL_OVER,
73         HOME_POOL_CLIENT_BALANCE,
74         HOME_POOL_CLIENT_PORT_BALANCE,
75         HOME_POOL_KEYED_BALANCE
76 } home_pool_type_t;
77
78
79 typedef struct home_pool_t {
80         const char              *name;
81         home_pool_type_t        type;
82
83         int                     server_type;
84
85         int                     num_home_servers;
86         home_server             *servers[1];
87 } home_pool_t;
88
89
90 typedef struct _realm {
91         const char              *name;
92
93         int                     striprealm;
94
95         home_pool_t             *auth_pool;
96         home_pool_t             *acct_pool;
97 } REALM;
98
99 int realms_init(CONF_SECTION *config);
100 void realms_free(void);
101 int realm_add(CONF_SECTION *cs);
102 REALM *realm_find(const char *name);
103
104 home_server *home_server_ldb(const char *realmname, home_pool_t *pool, REQUEST *request);
105 home_server *home_server_find(lrad_ipaddr_t *ipaddr, int port);
106
107 #endif /* REALMS_H */