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