Reorder functions

Move functions so that they can be called from enable_tunnel() (in the
following commit).
This commit is contained in:
Romain Vimont 2019-12-09 22:14:43 +01:00
parent a8ceaf5284
commit d1a9a76cc6

View file

@ -126,6 +126,20 @@ disable_tunnel_forward(const char *serial, uint16_t local_port) {
return process_check_success(process, "adb forward --remove");
}
static bool
disable_tunnel(struct server *server) {
if (server->tunnel_forward) {
return disable_tunnel_forward(server->serial, server->local_port);
}
return disable_tunnel_reverse(server->serial);
}
static socket_t
listen_on_port(uint16_t port) {
#define IPV4_LOCALHOST 0x7F000001
return net_listen(IPV4_LOCALHOST, port, 1);
}
static bool
enable_tunnel(struct server *server) {
if (enable_tunnel_reverse(server->serial, server->local_port)) {
@ -137,14 +151,6 @@ enable_tunnel(struct server *server) {
return enable_tunnel_forward(server->serial, server->local_port);
}
static bool
disable_tunnel(struct server *server) {
if (server->tunnel_forward) {
return disable_tunnel_forward(server->serial, server->local_port);
}
return disable_tunnel_reverse(server->serial);
}
static process_t
execute_server(struct server *server, const struct server_params *params) {
char max_size_string[6];
@ -187,13 +193,6 @@ execute_server(struct server *server, const struct server_params *params) {
return adb_execute(server->serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
}
#define IPV4_LOCALHOST 0x7F000001
static socket_t
listen_on_port(uint16_t port) {
return net_listen(IPV4_LOCALHOST, port, 1);
}
static socket_t
connect_and_read_byte(uint16_t port) {
socket_t socket = net_connect(IPV4_LOCALHOST, port);