Skip to content

Commit

Permalink
get_next_su -> get_next_hu
Browse files Browse the repository at this point in the history
pass hu throuth ssl web.
  • Loading branch information
sobomax committed Nov 30, 2023
1 parent 7a32c9f commit 363f003
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
ser_error = 0;
break;

}while( get_next_su( p, &to.su, (ser_error==E_IP_BLOCKED)?0:1)==0 );
}while( get_next_hu( p, &to, (ser_error==E_IP_BLOCKED)?0:1)==0 );

tcp_no_new_conn = 0;

Expand Down
6 changes: 3 additions & 3 deletions modules/dispatcher/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int add_dest2list(int id, str uri, struct socket_info *sock, str *comsock, int s

/* For DNS-Lookups */
struct proxy_l *proxy;
union sockaddr_union sau;
struct sockaddr_hu sau;

/* check uri */
if(parse_uri(uri.s, uri.len, &puri)!=0 || puri.host.len>254)
Expand Down Expand Up @@ -327,8 +327,8 @@ int add_dest2list(int id, str uri, struct socket_info *sock, str *comsock, int s
LM_DBG("first gw ip addr [%s]:%d\n",
ip_addr2a(&dp->ips[0]), dp->ports[0]);
/* get the next available IPs from DNS */
while (dp->ips_cnt<DS_MAX_IPS && (get_next_su( proxy, &sau, 0)==0) ) {
su2ip_addr( &dp->ips[dp->ips_cnt], &sau);
while (dp->ips_cnt<DS_MAX_IPS && (get_next_hu( proxy, &sau, 0)==0) ) {
su2ip_addr( &dp->ips[dp->ips_cnt], &sau.su);
dp->ports[dp->ips_cnt] = proxy->port;
dp->protos[dp->ips_cnt] = proxy->proto;
LM_DBG("additional gw ip addr [%s]:%d, proto %d\n",
Expand Down
6 changes: 3 additions & 3 deletions modules/drouting/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ add_dst(
#define GWABUF_MAX_SIZE 512
char gwabuf[GWABUF_MAX_SIZE];
char *p;
union sockaddr_union sau;
struct sockaddr_hu sau;
struct proxy_l *proxy;
unsigned int sip_prefix;
str gwas;
Expand Down Expand Up @@ -678,8 +678,8 @@ add_dst(

pgw->ips_no = 1;

while (pgw->ips_no<DR_MAX_IPS && (get_next_su( proxy, &sau, 0)==0) ) {
su2ip_addr( &pgw->ips[pgw->ips_no], &sau);
while (pgw->ips_no<DR_MAX_IPS && (get_next_hu( proxy, &sau, 0)==0) ) {
su2ip_addr( &pgw->ips[pgw->ips_no], &sau.su);
pgw->ports[pgw->ips_no] = proxy->port;
pgw->protos[pgw->ips_no] = proxy->proto;
LM_DBG("additional gw ip addr [%s]\n",
Expand Down
6 changes: 3 additions & 3 deletions modules/load_balancer/lb_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int add_lb_dsturi( struct lb_data *data, int id, int group, char *uri,
struct lb_resource *res;
struct sip_uri puri;
struct proxy_l *proxy;
union sockaddr_union sau;
struct sockaddr_hu sau;
int uri_len, attrs_len;
int i;
str fs_url = { NULL, 0 };
Expand Down Expand Up @@ -327,8 +327,8 @@ int add_lb_dsturi( struct lb_data *data, int id, int group, char *uri,
LM_DBG("first dst ip addr [%s]:%d\n",
ip_addr2a(&dst->ips[0]), dst->ports[0]);
/* get the next available IPs from DNS */
while (dst->ips_cnt<LB_MAX_IPS && (get_next_su( proxy, &sau, 0)==0) ) {
su2ip_addr( &dst->ips[dst->ips_cnt], &sau);
while (dst->ips_cnt<LB_MAX_IPS && (get_next_hu( proxy, &sau, 0)==0) ) {
su2ip_addr( &dst->ips[dst->ips_cnt], &sau.su);
dst->ports[dst->ips_cnt] = proxy->port;
dst->protos[dst->ips_cnt] = proxy->proto;
LM_DBG("additional dst ip addr [%s]:%d, proto %d\n",
Expand Down
2 changes: 1 addition & 1 deletion modules/proto_hep/hep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ int send_hep_message(trace_message message, trace_dest dest, struct socket_info*
}
ret=0;
break;
} while ( get_next_su( p, &to->su, 0)==0);
} while ( get_next_hu( p, to, 0)==0);

free_proxy(p);
pkg_free(p);
Expand Down
2 changes: 1 addition & 1 deletion modules/sipcapture/sipcapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -4334,7 +4334,7 @@ static int w_hep_relay(struct sip_msg *msg)
}

break;
} while( get_next_su( proxy, &to.su, 0)==0 );
} while( get_next_hu( proxy, &to, 0)==0 );

free_proxy(proxy);
pkg_free(proxy);
Expand Down
2 changes: 1 addition & 1 deletion modules/tls_mgm/tls_lib_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/* TLS library specific conn ops */
typedef int (*tls_lib_conn_init_f)(struct tcp_connection *c,
struct tls_domain *tls_dom);
struct tls_domain *tls_dom, const struct sockaddr_hu *);
typedef void (*tls_lib_conn_clean_f)(struct tcp_connection* c,
struct tls_domain **tls_dom);
typedef int (*tls_lib_update_fd_f)(struct tcp_connection* c, int fd);
Expand Down
6 changes: 3 additions & 3 deletions modules/tls_mgm/tls_mgm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,12 +1348,12 @@ static mi_response_t *tls_list(const mi_params_t *params,
return NULL;
}

int tls_conn_init(struct tcp_connection *c, struct tls_domain *tls_dom)
int tls_conn_init(struct tcp_connection *c, struct tls_domain *tls_dom, const struct sockaddr_hu *hu)
{
if (tls_library == TLS_LIB_OPENSSL)
return openssl_api.tls_conn_init(c, tls_dom);
return openssl_api.tls_conn_init(c, tls_dom, hu);
else if (tls_library == TLS_LIB_WOLFSSL)
return wolfssl_api.tls_conn_init(c, tls_dom);
return wolfssl_api.tls_conn_init(c, tls_dom, hu);
else {
LM_CRIT("No TLS library module loaded\n");
return -1;
Expand Down
3 changes: 2 additions & 1 deletion modules/tls_openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static int mod_init(void);
static void mod_destroy(void);

/* openssl conn ops */
int openssl_tls_conn_init(struct tcp_connection* c, struct tls_domain *tls_dom);
int openssl_tls_conn_init(struct tcp_connection* c, struct tls_domain *tls_dom,
const struct sockaddr_hu *hu);
void openssl_tls_conn_clean(struct tcp_connection *c,
struct tls_domain **tls_dom);
int openssl_tls_update_fd(struct tcp_connection *c, int fd);
Expand Down
3 changes: 2 additions & 1 deletion modules/tls_wolfssl/wolfssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ static int load_tls_wolfssl(struct wolfssl_binds *binds);
static int mod_init(void);
static void mod_destroy(void);

int _wolfssl_tls_conn_init(struct tcp_connection* c, struct tls_domain *tls_dom);
int _wolfssl_tls_conn_init(struct tcp_connection* c, struct tls_domain *tls_dom,
const struct sockaddr_hu *hu);
void _wolfssl_tls_conn_clean(struct tcp_connection *c,
struct tls_domain **tls_dom);
int _wolfssl_tls_update_fd(struct tcp_connection *c, int fd);
Expand Down
2 changes: 1 addition & 1 deletion modules/tls_wolfssl/wolfssl_conn_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int _wolfssl_tls_update_fd(struct tcp_connection *c, int fd)
}

int _wolfssl_tls_conn_init(struct tcp_connection* c,
struct tls_domain *tls_dom)
struct tls_domain *tls_dom, const struct sockaddr_hu *hu)
{
/*
* new connection within a single process, no lock necessary
Expand Down
2 changes: 1 addition & 1 deletion modules/tm/t_fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
}
/* get next dns entry */
if ( t->uac[i].proxy==0 ||
get_next_su( t->uac[i].proxy, &t->uac[i].request.dst.to.su,
get_next_hu( t->uac[i].proxy, &t->uac[i].request.dst.to,
(ser_error==E_IP_BLOCKED)?0:1)!=0 )
break;
t->uac[i].request.dst.proto = t->uac[i].proxy->proto;
Expand Down
2 changes: 1 addition & 1 deletion modules/tm/t_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ static inline int do_dns_failover(struct cell *t)
uac = &t->uac[picked_branch];

/* check if the DNS resolver can get at least one new IP */
if ( get_next_su( uac->proxy, &uac->request.dst.to.su, 1)!=0 )
if ( get_next_hu( uac->proxy, &uac->request.dst.to, 1)!=0 )
return -1;

LM_DBG("new destination available\n");
Expand Down
2 changes: 1 addition & 1 deletion modules/tracer/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3470,7 +3470,7 @@ static int trace_send_duplicate(char *buf, int len, struct sip_uri *uri)
}
ret = 0;
break;
}while( get_next_su( p, &to->su, 0)==0 );
}while( get_next_hu( p, to, 0)==0 );

free_proxy(p); /* frees only p content, not p itself */
pkg_free(p);
Expand Down
6 changes: 3 additions & 3 deletions resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,7 @@ void free_dns_res( struct proxy_l *p )



int get_next_su(struct proxy_l *p, union sockaddr_union* su, int add_to_bl)
int get_next_hu(struct proxy_l *p, struct sockaddr_hu* hu, int add_to_bl)
{
struct hostent *he;
struct bl_rule *list;
Expand All @@ -2035,7 +2035,7 @@ int get_next_su(struct proxy_l *p, union sockaddr_union* su, int add_to_bl)
/* any more available IPs in he ? */
if ( p->host.h_addr_list[++p->addr_idx] ) {
/* yes -> return the IP*/
hostent2su( su, &p->host, p->addr_idx, (p->port)?p->port:SIP_PORT);
hostent2hu( hu, &p->host, p->addr_idx, (p->port)?p->port:SIP_PORT);
return 0;
}

Expand All @@ -2057,7 +2057,7 @@ int get_next_su(struct proxy_l *p, union sockaddr_union* su, int add_to_bl)
return -1;
}

hostent2su( su, &p->host, 0, (p->port)?p->port:SIP_PORT);
hostent2hu( hu, &p->host, 0, (p->port)?p->port:SIP_PORT);
p->addr_idx = 0;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion resolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void free_dns_res( struct proxy_l *p );
struct dns_node *dns_res_copy(struct dns_node *s);

/*! \brief taked the next destination from a resolver state machine */
int get_next_su(struct proxy_l *p, union sockaddr_union* su, int add_to_bl);
int get_next_hu(struct proxy_l *p, struct sockaddr_hu* su, int add_to_bl);


int resolv_init();
Expand Down

0 comments on commit 363f003

Please sign in to comment.