Massive change to the server core to remove horrid code in
[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         struct timeval  when;
44         
45         int             response_window;
46         int             max_outstanding; /* don't overload it */
47         int             currently_outstanding;
48         
49         struct timeval  zombie_period_start;
50         int             zombie_period; /* unresponsive for T, mark it dead */
51
52         int             state;
53
54         int             ping_check;
55         const char      *ping_user_name;
56         const char      *ping_user_password;
57
58         int             ping_interval;
59         int             num_pings_to_alive;
60         int             num_received_pings;
61
62         int             revive_interval; /* if it doesn't support pings */
63 } home_server;
64
65
66 typedef enum home_pool_type_t {
67         HOME_POOL_INVALID = 0,
68         HOME_POOL_LOAD_BALANCE,
69         HOME_POOL_FAIL_OVER
70 } home_pool_type_t;
71
72
73 typedef struct home_pool_t {
74         const char              *name;
75         home_pool_type_t        type;
76
77         int                     server_type;
78
79         int                     num_home_servers;
80         home_server             *servers[1];
81 } home_pool_t;
82
83
84 typedef struct _realm {
85         const char              *name;
86
87         int                     striprealm;
88
89         home_pool_t             *auth_pool;
90         home_pool_t             *acct_pool;
91 } REALM;
92
93 int realms_init(const char *filename);
94 void realms_free(void);
95 int realm_add(const char *filename, CONF_SECTION *cs);
96 REALM *realm_find(const char *name);
97
98 home_server *home_server_ldb(REALM *realm, int code);
99 home_server *home_server_find(lrad_ipaddr_t *ipaddr, int port);
100
101 #endif /* REALMS_H */