Skip to content

Commit

Permalink
load_balancer: port script functions to new param interface
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlad-patrascu committed Apr 2, 2019
1 parent 5884732 commit a5b8571
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 353 deletions.
27 changes: 3 additions & 24 deletions modules/load_balancer/lb_data.c
Expand Up @@ -1037,37 +1037,16 @@ int do_lb_disable_dst(struct sip_msg *req, struct lb_data *data, unsigned int ve
/* Checks, if the IP PORT is a LB destination
*/
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)
str *ip_str, int port, int group, int active)
{
pv_value_t val;
struct ip_addr *ip;
int port;
struct lb_dst *dst;
int k;

/* get the address to test */
if (pv_get_spec_value( _m, pv_ip, &val)!=0) {
LM_ERR("failed to get IP value from PV\n");
if ( (ip=str2ip(ip_str))==NULL && (ip=str2ip6(ip_str))==NULL) {
LM_ERR("IP val is not IP <%.*s>\n",ip_str->len,ip_str->s);
return -1;
}
if ( (val.flags&PV_VAL_STR)==0 ) {
LM_ERR("IP PV val is not string\n");
return -1;
}
if ( (ip=str2ip( &val.rs ))==NULL && (ip=str2ip6( &val.rs ))==NULL) {
LM_ERR("IP val is not IP <%.*s>\n",val.rs.len,val.rs.s);
return -1;
}

/* get the port to test */
if (pv_port) {
if (fixup_get_ivalue(_m, (gparam_p)pv_port, &port) != 0) {
LM_ERR("failed to get PORT value from PV\n");
return -1;
}
} else {
port = 0;
}

/* and now search !*/
for( dst=data->dsts ; dst ; dst=dst->next) {
Expand Down
8 changes: 3 additions & 5 deletions modules/load_balancer/lb_data.h
Expand Up @@ -26,7 +26,6 @@
#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"
Expand Down Expand Up @@ -108,11 +107,10 @@ 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);
str *ip_str, int 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_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);

Expand Down
9 changes: 0 additions & 9 deletions modules/load_balancer/lb_parser.h
Expand Up @@ -40,15 +40,6 @@ struct lb_res_str_list {
struct lb_res_str* resources;
};

#define RES_TEXT (1<<0)
#define RES_ELEM (1<<1)

struct lb_res_parse {
char type;
void *param;
};


struct lb_res_str* search_resource_str( struct lb_res_str_list *lb_rl,
str *name);

Expand Down

0 comments on commit a5b8571

Please sign in to comment.