summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/includes
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2020-07-01 14:16:31 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-07-03 14:14:16 +0200
commita35b7c42ee20986414e61b254c22e82fb8619abe (patch)
tree472673c0f32c1d99b02efab8d541f196e76d6072 /admin/WebConsole/includes
parent5249c5dfa0f478b2372ca19274c192cdf0dc3ced (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 'admin/WebConsole/includes')
-rw-r--r--admin/WebConsole/includes/RecopilaIpesMacs.php19
-rw-r--r--admin/WebConsole/includes/restfunctions.php6
2 files changed, 22 insertions, 3 deletions
diff --git a/admin/WebConsole/includes/RecopilaIpesMacs.php b/admin/WebConsole/includes/RecopilaIpesMacs.php
index 2ded1775..4601a4a2 100644
--- a/admin/WebConsole/includes/RecopilaIpesMacs.php
+++ b/admin/WebConsole/includes/RecopilaIpesMacs.php
@@ -166,4 +166,21 @@ function RecorreOrdenadores($cmd){
$rs->Cerrar();
}
-
+function get_netmasks($cmd, &$macs, &$netmasks){
+ $macs = str_replace(";", "','", $macs);
+ $cmd->texto="SELECT mac, mascara
+ FROM ordenadores
+ WHERE mac IN ('".$macs."')";
+ $rs=new Recordset;
+ $rs->Comando=&$cmd;
+ if (!$rs->Abrir()) return;
+ $macs = "";
+ while (!$rs->EOF){
+ $macs.=$rs->campos["mac"].";";
+ $netmasks.=$rs->campos["mascara"].";";
+ $rs->Siguiente();
+ }
+ $rs->Cerrar();
+ $macs = substr($macs, 0, -1);
+ $netmasks = substr($netmasks, 0, -1);
+}
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index 81821ff9..88e486ac 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -35,6 +35,7 @@ define('OG_REST_CMD_GET_SCHEDULE', 'schedule/get');
define('OG_REST_PARAM_CLIENTS', 'clients');
define('OG_REST_PARAM_ADDR', 'addr');
define('OG_REST_PARAM_MAC', 'mac');
+define('OG_REST_PARAM_NETMASK', 'netmask');
define('OG_REST_PARAM_DISK', 'disk');
define('OG_REST_PARAM_PART', 'partition');
define('OG_REST_PARAM_RUN', 'run');
@@ -187,7 +188,7 @@ function clients($case, $ips) {
return $trama_notificacion;
}
-function wol($type_wol, $macs, $ips) {
+function wol($type_wol, $macs, $ips, $netmasks) {
switch ($type_wol) {
default:
@@ -202,7 +203,8 @@ function wol($type_wol, $macs, $ips) {
for($i=0; $i<count($macs); $i++) {
$clients[] = array(OG_REST_PARAM_ADDR => $ips[$i],
- OG_REST_PARAM_MAC => $macs[$i]);
+ OG_REST_PARAM_MAC => $macs[$i],
+ OG_REST_PARAM_NETMASK => $netmasks[$i]);
}
$data = array(OG_REST_PARAM_TYPE => $wol,