Track the number of outstanding packets on a TCP connection.
[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         int             max_connections;
44         int             num_connections;
45         int             max_requests;
46         int             lifetime;
47         int             idle_timeout;
48 #endif
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
98 #ifdef WITH_TCP
99         struct rad_listen_t     *listeners[1];
100 #endif
101 } home_server;
102
103
104 typedef enum home_pool_type_t {
105         HOME_POOL_INVALID = 0,
106         HOME_POOL_LOAD_BALANCE,
107         HOME_POOL_FAIL_OVER,
108         HOME_POOL_CLIENT_BALANCE,
109         HOME_POOL_CLIENT_PORT_BALANCE,
110         HOME_POOL_KEYED_BALANCE
111 } home_pool_type_t;
112
113
114 typedef struct home_pool_t {
115         const char              *name;
116         home_pool_type_t        type;
117
118         int                     server_type;
119         CONF_SECTION            *cs;
120
121         const char              *virtual_server; /* for pre/post-proxy */
122         
123         home_server             *fallback;
124
125         int                     num_home_servers;
126         home_server             *servers[1];
127 } home_pool_t;
128
129
130 typedef struct _realm {
131         const char              *name;
132
133         int                     striprealm;
134
135         home_pool_t             *auth_pool;
136         home_pool_t             *acct_pool;
137 } REALM;
138
139 int realms_init(CONF_SECTION *config);
140 void realms_free(void);
141 REALM *realm_find(const char *name); /* name is from a packet */
142 REALM *realm_find2(const char *name); /* ... with name taken from realm_find */
143
144 home_server *home_server_ldb(const char *realmname, home_pool_t *pool, REQUEST *request);
145 home_server *home_server_find(fr_ipaddr_t *ipaddr, int port);
146 int     home_server_create_listeners(void *head);
147 #ifdef WITH_COA
148 home_server *home_server_byname(const char *name, int type);
149 #endif
150 #ifdef WITH_STATS
151 home_server *home_server_bynumber(int number);
152 #endif
153 home_pool_t *home_pool_byname(const char *name, int type);
154
155 #endif /* REALMS_H */