diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2020-07-03 12:42:00 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-07-03 14:11:35 +0200 |
commit | 06af0c26f4c46088d8a6f97877f865527bcbc409 (patch) | |
tree | f4ba170d0be8a1192a4f23d8c85a5c103e1b2885 /src/rest.c | |
parent | d6789f1384eb515f7bbe0d25762ffb82567eec38 (diff) |
#990 Use client broadcast address on WoL
Some universities have computers in a different subnet where the
ogServer is, but ogServer WoL functionality only supported to send
packet to its own subnets. This commit solves this.
Now ogServer sends two WoL packets per client, one with the broadcast
address of the interface indicated in the config file, the other with
the broadcast address calculated with the address and netmask of the
client.
To ensure that the second WoL works correctly you must configure
correctly the IP and netmask of the clients. Also, you have to configure
the network of your organization to route WoL packet to the correct
subnet.
Diffstat (limited to 'src/rest.c')
-rw-r--r-- | src/rest.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -109,6 +109,7 @@ static bool og_send_cmd(char *ips_array[], int ips_array_len, #define OG_REST_PARAM_TIME_HOURS (1UL << 37) #define OG_REST_PARAM_TIME_AM_PM (1UL << 38) #define OG_REST_PARAM_TIME_MINUTES (1UL << 39) +#define OG_REST_PARAM_NETMASK (1UL << 40) static LIST_HEAD(client_list); @@ -508,6 +509,14 @@ static int og_json_parse_target(json_t *element, struct og_msg_params *params) json_string_value(value); params->flags |= OG_REST_PARAM_MAC; + } else if (!strcmp(key, "netmask")) { + if (json_typeof(value) != JSON_STRING) + return -1; + + params->netmask_array[params->ips_array_len] = + json_string_value(value); + + params->flags |= OG_REST_PARAM_NETMASK; } } @@ -580,11 +589,13 @@ static int og_cmd_wol(json_t *element, struct og_msg_params *params) if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR | OG_REST_PARAM_MAC | + OG_REST_PARAM_NETMASK | OG_REST_PARAM_WOL_TYPE)) return -1; if (!Levanta((char **)params->ips_array, (char **)params->mac_array, - params->ips_array_len, (char *)params->wol_type)) + (char **)params->netmask_array, params->ips_array_len, + (char *)params->wol_type)) return -1; return 0; @@ -2252,6 +2263,7 @@ void og_schedule_run(unsigned int task_id, unsigned int schedule_id, if (Levanta((char **)cmd->params.ips_array, (char **)cmd->params.mac_array, + (char **)cmd->params.netmask_array, cmd->params.ips_array_len, (char *)cmd->params.wol_type)) og_dbi_update_action(cmd->id, true); |