forked from OpenSIPS/opensips
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lb_data.h
122 lines (99 loc) · 3.49 KB
/
lb_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* load balancer module - complex call load balancing
*
* Copyright (C) 2009 Voice Sistem SRL
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
* 2009-02-01 initial version (bogdan)
*/
#ifndef LB_LB_DATA_H_
#define LB_LB_DATA_H_
#include "../../mod_fix.h"
#include "../../str.h"
#include "../../locking.h"
#include "../../parser/msg_parser.h"
#include "../dialog/dlg_load.h"
#include "lb_parser.h"
#define LB_FLAGS_RELATIVE (1<<0) /* do relative versus absolute estimation. default is absolute */
#define LB_FLAGS_NEGATIVE (1<<1) /* do not skip negative loads. default to skip */
#define LB_FLAGS_RANDOM (1<<2) /* pick a random destination among all selected dsts with equal load */
#define LB_FLAGS_DEFAULT 0
#define LB_DST_PING_DSBL_FLAG (1<<0)
#define LB_DST_PING_PERM_FLAG (1<<1)
#define LB_DST_STAT_DSBL_FLAG (1<<2)
#define LB_DST_STAT_NOEN_FLAG (1<<3)
/* max number of IPs for a destination (DNS loookup) */
#define LB_MAX_IPS 32
struct lb_resource {
str name;
gen_lock_t *lock;
struct dlg_profile_table *profile;
unsigned int bitmap_size;
unsigned int *dst_bitmap;
struct lb_resource *next;
};
struct lb_resource_map {
struct lb_resource *resource;
unsigned int max_load;
};
struct lb_dst {
unsigned int group;
unsigned int id;
str uri;
str profile_id;
unsigned int rmap_no;
unsigned int flags;
struct lb_resource_map *rmap;
struct ip_addr ips[LB_MAX_IPS]; /* IP-Address of the entry */
unsigned short int ports[LB_MAX_IPS]; /* Port of the request URI */
unsigned short int protos[LB_MAX_IPS]; /* Protocol of the request URI */
unsigned short ips_cnt;
struct lb_dst *next;
};
struct lb_data {
unsigned int res_no;
struct lb_resource * resources;
unsigned int dst_no;
struct lb_dst *dsts;
struct lb_dst *last_dst;
};
struct lb_data* load_lb_data(void);
int add_lb_dsturi( struct lb_data *data, int id, int group, char *uri,
char* resource, unsigned int flags);
void free_lb_data(struct lb_data *data);
int do_lb_start(struct sip_msg *req, int group, struct lb_res_str_list *rl,
unsigned int flags, struct lb_data *data);
int do_lb_next(struct sip_msg *req, struct lb_data *data);
int do_lb_reset(struct sip_msg *req, struct lb_data *data);
int do_lb_is_started(struct sip_msg *req);
int do_lb_disable_dst(struct sip_msg *req, struct lb_data *data, unsigned int verbose);
int lb_is_dst(struct lb_data *data, struct sip_msg *_m,
pv_spec_t *pv_ip, gparam_t *pv_port, int group, int active);
int lb_count_call(struct lb_data *data, struct sip_msg *req,
struct ip_addr *ip, int port, int group, struct lb_res_str_list *rl, int dir);
int lb_init_event(void);
void lb_raise_event(struct lb_dst *dst);
/* failover stuff */
extern int group_avp_name;
extern int flags_avp_name;
extern int mask_avp_name;
extern int id_avp_name;
extern int res_avp_name;
#endif