#ifdef TARGET_ANDROID
int
-management_callback_network_change (void *arg)
+management_callback_network_change (void *arg, bool samenetwork)
{
/* Check if the client should translate the network change to a SIGUSR1 to
reestablish the connection or just reprotect the socket
At the moment just assume that, for all settings that use pull (not
--static) and are not using peer-id reestablishing the connection is
- required
+ required (unless the network is the same)
The function returns -1 on invalid fd and -2 if the socket cannot be
reused. On the -2 return value the man_network_change function triggers
return -1;
socketfd = c->c2.link_socket->sd;
- if (!c->options.pull || c->c2.tls_multi->use_peer_id)
+ if (!c->options.pull || c->c2.tls_multi->use_peer_id || samenetwork)
return socketfd;
else
return -2;
#ifdef TARGET_ANDROID
static void
-man_network_change (struct management *man)
+man_network_change (struct management *man, bool samenetwork)
{
/* Called to signal the OpenVPN that the network configuration has changed and
the client should either float or reconnect.
*/
if (man->persist.callback.network_change)
{
- int fd = (*man->persist.callback.network_change)(man->persist.callback.arg);
+ int fd = (*man->persist.callback.network_change)
+ (man->persist.callback.arg, samenetwork);
man->connection.fdtosend = fd;
msg (M_CLIENT, "PROTECTFD: fd '%d' sent to be protected", fd);
if (fd == -2)
#ifdef TARGET_ANDROID
else if (streq (p[0], "network-change"))
{
- man_network_change(man);
+ bool samenetwork = false;
+ if (p[1] && streq(p[1], "samenetwork"))
+ samenetwork = true;
+
+ man_network_change(man, samenetwork);
}
#endif
else if (streq (p[0], "load-stats"))
bool (*proxy_cmd) (void *arg, const char **p);
bool (*remote_cmd) (void *arg, const char **p);
#ifdef TARGET_ANDROID
- int (*network_change) (void *arg);
+ int (*network_change) (void *arg, bool samenetwork);
#endif
};