c4d6891c17563c60c1375589ef2b81d659ab1d60
[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 #ifdef WITH_COA
19 #define HOME_TYPE_COA     (3)
20 #endif
21
22 #define HOME_PING_CHECK_NONE            (0)
23 #define HOME_PING_CHECK_STATUS_SERVER   (1)
24 #define HOME_PING_CHECK_REQUEST         (2)
25
26 #define HOME_STATE_ALIVE                (0)
27 #define HOME_STATE_ZOMBIE               (1)
28 #define HOME_STATE_IS_DEAD              (2)
29
30 typedef struct home_server {
31         const char      *name;
32
33         const char      *hostname;
34         const char      *server; /* for internal proxying */
35
36         fr_ipaddr_t     ipaddr;
37
38         int             port;
39         int             type;           /* auth/acct */
40
41 #ifdef WITH_TCP
42         int             proto;
43 #endif
44         int             max_connections;
45         int             num_connections; /* protected by proxy mutex */
46         int             max_requests;    /* for one connection */
47         int             lifetime;
48         int             idle_timeout;
49
50         /*
51          *      Maybe also have list of source IP/ports, && socket?
52          */
53
54         const char      *secret;
55
56         fr_event_t      *ev;
57         struct timeval  when;
58
59         int             response_window;
60         int             no_response_fail;
61         int             max_outstanding; /* don't overload it */
62         int             currently_outstanding;
63         int             message_authenticator;
64
65         struct timeval  revive_time;
66         struct timeval  zombie_period_start;
67         int             zombie_period; /* unresponsive for T, mark it dead */
68
69         int             state;
70
71         int             ping_check;
72         const char      *ping_user_name;
73         const char      *ping_user_password;
74
75         int             ping_interval;
76         int             num_pings_to_alive;
77         int             num_received_pings;
78         int             ping_timeout;
79
80         int             revive_interval; /* if it doesn't support pings */
81         CONF_SECTION    *cs;
82 #ifdef WITH_COA
83         int                     coa_irt;
84         int                     coa_mrc;
85         int                     coa_mrt;
86         int                     coa_mrd;
87 #endif
88 #ifdef WITH_STATS
89         int             number;
90
91         fr_ipaddr_t     src_ipaddr; /* preferred source IP address */
92
93         fr_stats_t      stats;
94
95         fr_stats_ema_t  ema;
96 #endif
97 } home_server;
98
99
100 typedef enum home_pool_type_t {
101         HOME_POOL_INVALID = 0,
102         HOME_POOL_LOAD_BALANCE,
103         HOME_POOL_FAIL_OVER,
104         HOME_POOL_CLIENT_BALANCE,
105         HOME_POOL_CLIENT_PORT_BALANCE,
106         HOME_POOL_KEYED_BALANCE
107 } home_pool_type_t;
108
109
110 typedef struct home_pool_t {
111         const char              *name;
112         home_pool_type_t        type;
113
114         int                     server_type;
115         CONF_SECTION            *cs;
116
117         const char              *virtual_server; /* for pre/post-proxy */
118         
119         home_server             *fallback;
120
121         int                     num_home_servers;
122         home_server             *servers[1];
123 } home_pool_t;
124
125
126 typedef struct _realm {
127         const char              *name;
128
129         int                     striprealm;
130
131         home_pool_t             *auth_pool;
132         home_pool_t             *acct_pool;
133 } REALM;
134
135 int realms_init(CONF_SECTION *config);
136 void realms_free(void);
137 REALM *realm_find(const char *name); /* name is from a packet */
138 REALM *realm_find2(const char *name); /* ... with name taken from realm_find */
139
140 home_server *home_server_ldb(const char *realmname, home_pool_t *pool, REQUEST *request);
141 home_server *home_server_find(fr_ipaddr_t *ipaddr, int port);
142 #ifdef WITH_COA
143 home_server *home_server_byname(const char *name, int type);
144 #endif
145 #ifdef WITH_STATS
146 home_server *home_server_bynumber(int number);
147 #endif
148 home_pool_t *home_pool_byname(const char *name, int type);
149
150 #endif /* REALMS_H */