mirror of https://git.48k.eu/ogserver
#990 Use lab netmask to calculate broadcast address
ogServer gets netmask address from computer (ordenadores) table, see commit a35b7c4. Netmask field is empty in most cases, is only filled when the user adds computers with dhcpd.conf syntax and cannot be edited in computer properties view. Labs/rooms (aulas) table also have netmask field, WebConsole backend ensures it is not empty and can be edited in lab properties view. Get netmask from labs table to ensure it is not empty.master
parent
4bd409774c
commit
e6c2c26f09
21
src/rest.c
21
src/rest.c
|
@ -471,8 +471,13 @@ static int og_cmd_wol(json_t *element, struct og_msg_params *params)
|
|||
}
|
||||
|
||||
result = dbi_conn_queryf(dbi->conn,
|
||||
"SELECT ip, mac, mascara FROM ordenadores "
|
||||
"WHERE ip IN (%s)", ips_str);
|
||||
"SELECT ordenadores.ip, ordenadores.mac, "
|
||||
"aulas.netmask "
|
||||
"FROM ordenadores "
|
||||
"INNER JOIN aulas "
|
||||
"ON ordenadores.idaula = aulas.idaula "
|
||||
"WHERE ordenadores.ip IN (%s)",
|
||||
ips_str);
|
||||
if (!result) {
|
||||
dbi_conn_error(dbi->conn, &msglog);
|
||||
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
||||
|
@ -484,7 +489,7 @@ static int og_cmd_wol(json_t *element, struct og_msg_params *params)
|
|||
for (i = 0; dbi_result_next_row(result); i++) {
|
||||
params->ips_array[i] = dbi_result_get_string_copy(result, "ip");
|
||||
params->mac_array[i] = dbi_result_get_string_copy(result, "mac");
|
||||
params->netmask_array[i] = dbi_result_get_string_copy(result, "mascara");
|
||||
params->netmask_array[i] = dbi_result_get_string_copy(result, "netmask");
|
||||
}
|
||||
|
||||
dbi_result_free(result);
|
||||
|
@ -2185,8 +2190,12 @@ static int og_cmd_legacy_wol(const char *input, struct og_cmd *cmd)
|
|||
}
|
||||
|
||||
result = dbi_conn_queryf(dbi->conn,
|
||||
"SELECT mascara FROM ordenadores "
|
||||
"WHERE ip = '%s'", cmd->ip);
|
||||
"SELECT aulas.netmask "
|
||||
"FROM ordenadores "
|
||||
"INNER JOIN aulas "
|
||||
"ON ordenadores.idaula = aulas.idaula "
|
||||
"WHERE ordenadores.ip = '%s'",
|
||||
cmd->ip);
|
||||
if (!result) {
|
||||
dbi_conn_error(dbi->conn, &msglog);
|
||||
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
||||
|
@ -2198,7 +2207,7 @@ static int og_cmd_legacy_wol(const char *input, struct og_cmd *cmd)
|
|||
|
||||
og_cmd_init(cmd, OG_METHOD_NO_HTTP, OG_CMD_WOL, NULL);
|
||||
cmd->params.netmask_array[0] = dbi_result_get_string_copy(result,
|
||||
"mascara");
|
||||
"netmask");
|
||||
cmd->params.mac_array[0] = strdup(cmd->mac);
|
||||
cmd->params.wol_type = strdup(wol_type);
|
||||
|
||||
|
|
Loading…
Reference in New Issue