mirror of
https://github.com/OpenVPN/openvpn.git
synced 2026-02-18 18:19:42 -05:00
route.c: change the signature of get_default_gateway()
As a preparation of an upcoming refactoring of get_default_gateway(), add `dest` parameter to specify destination address to which we are looking the best route. Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a Signed-off-by: Lev Stipakov <lev@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20250129095038.19056-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30685.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
34f302247c
commit
0fcfc8381f
5 changed files with 11 additions and 10 deletions
|
|
@ -5866,7 +5866,7 @@ add_option(struct options *options,
|
|||
get_ipv6_addr(p[1], &remote, NULL, M_WARN);
|
||||
}
|
||||
net_ctx_init(NULL, &net_ctx);
|
||||
get_default_gateway(&rgi, &net_ctx);
|
||||
get_default_gateway(&rgi, 0, &net_ctx);
|
||||
get_default_gateway_ipv6(&rgi6, &remote, &net_ctx);
|
||||
print_default_gateway(M_INFO, &rgi, &rgi6);
|
||||
openvpn_exit(OPENVPN_EXIT_STATUS_GOOD); /* exit point */
|
||||
|
|
|
|||
|
|
@ -655,7 +655,7 @@ init_route_list(struct route_list *rl,
|
|||
rl->spec.flags |= RTSA_DEFAULT_METRIC;
|
||||
}
|
||||
|
||||
get_default_gateway(&rl->rgi, ctx);
|
||||
get_default_gateway(&rl->rgi, remote_host, ctx);
|
||||
if (rl->rgi.flags & RGI_ADDR_DEFINED)
|
||||
{
|
||||
setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
|
||||
|
|
@ -2733,7 +2733,7 @@ get_default_gateway_row(const MIB_IPFORWARDTABLE *routes)
|
|||
}
|
||||
|
||||
void
|
||||
get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
|
||||
get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
|
||||
{
|
||||
struct gc_arena gc = gc_new();
|
||||
|
||||
|
|
@ -3282,7 +3282,7 @@ show_routes(int msglev)
|
|||
#elif defined(TARGET_ANDROID)
|
||||
|
||||
void
|
||||
get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
|
||||
get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
|
||||
{
|
||||
/* Android, set some pseudo GW, addr is in host byte order,
|
||||
* Determining the default GW on Android 5.0+ is non trivial
|
||||
|
|
@ -3323,7 +3323,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
|
|||
#elif defined(TARGET_LINUX)
|
||||
|
||||
void
|
||||
get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
|
||||
get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
|
||||
{
|
||||
struct gc_arena gc = gc_new();
|
||||
int sd = -1;
|
||||
|
|
@ -3561,7 +3561,7 @@ struct rtmsg {
|
|||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
void
|
||||
get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
|
||||
get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
|
||||
{
|
||||
struct gc_arena gc = gc_new();
|
||||
struct rtmsg m_rtmsg;
|
||||
|
|
@ -3943,7 +3943,7 @@ done:
|
|||
#elif defined(TARGET_HAIKU)
|
||||
|
||||
void
|
||||
get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
|
||||
get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
|
||||
{
|
||||
CLEAR(*rgi);
|
||||
|
||||
|
|
@ -4047,7 +4047,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
|
|||
* may be disabled by missing items.
|
||||
*/
|
||||
void
|
||||
get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
|
||||
get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
|
||||
{
|
||||
CLEAR(*rgi);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ void setenv_routes_ipv6(struct env_set *es, const struct route_ipv6_list *rl6);
|
|||
bool is_special_addr(const char *addr_str);
|
||||
|
||||
void get_default_gateway(struct route_gateway_info *rgi,
|
||||
in_addr_t dest,
|
||||
openvpn_net_ctx_t *ctx);
|
||||
|
||||
void get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi,
|
||||
|
|
|
|||
|
|
@ -1990,7 +1990,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
|
|||
{
|
||||
/* push mac addr */
|
||||
struct route_gateway_info rgi;
|
||||
get_default_gateway(&rgi, session->opt->net_ctx);
|
||||
get_default_gateway(&rgi, 0, session->opt->net_ctx);
|
||||
if (rgi.flags & RGI_HWADDR_DEFINED)
|
||||
{
|
||||
buf_printf(&out, "IV_HWADDR=%s\n", format_hex_ex(rgi.hwaddr, 6, 0, 1, ":", &gc));
|
||||
|
|
|
|||
|
|
@ -671,7 +671,7 @@ warn_on_use_of_common_subnets(openvpn_net_ctx_t *ctx)
|
|||
struct route_gateway_info rgi;
|
||||
const unsigned int needed = (RGI_ADDR_DEFINED|RGI_NETMASK_DEFINED);
|
||||
|
||||
get_default_gateway(&rgi, ctx);
|
||||
get_default_gateway(&rgi, 0, ctx);
|
||||
if ((rgi.flags & needed) == needed)
|
||||
{
|
||||
const in_addr_t lan_network = rgi.gateway.addr & rgi.gateway.netmask;
|
||||
|
|
|
|||
Loading…
Reference in a new issue