GUACAMOLE-1245: Merge support for specifying Wake-on-LAN port.
diff --git a/src/libguac/guacamole/wol.h b/src/libguac/guacamole/wol.h
index cdbb739..9af1a8d 100644
--- a/src/libguac/guacamole/wol.h
+++ b/src/libguac/guacamole/wol.h
@@ -42,11 +42,15 @@
* @param broadcast_addr
* The broadcast address to which to send the magic Wake-on-LAN packet.
*
+ * @param udp_port
+ * The UDP port to use when sending the WoL packet.
+ *
* @return
* Zero if the packet is successfully sent to the destination; non-zero
* if the packet cannot be sent.
*/
-int guac_wol_wake(const char* mac_addr, const char* broadcast_addr);
+int guac_wol_wake(const char* mac_addr, const char* broadcast_addr,
+ const unsigned short udp_port);
#endif /* GUAC_WOL_H */
diff --git a/src/libguac/wol.c b/src/libguac/wol.c
index dcbd07c..9d69306 100644
--- a/src/libguac/wol.c
+++ b/src/libguac/wol.c
@@ -69,6 +69,9 @@
* @param broadcast_addr
* The broadcast address to which to send the magic WoL packet.
*
+ * @param udp_port
+ * The UDP port to use when sending the WoL packet.
+ *
* @param packet
* The magic WoL packet to send.
*
@@ -76,13 +79,13 @@
* The number of bytes sent, or zero if nothing could be sent.
*/
static ssize_t __guac_wol_send_packet(const char* broadcast_addr,
- unsigned char packet[]) {
+ const unsigned short udp_port, unsigned char packet[]) {
struct sockaddr_in wol_dest;
int wol_socket;
/* Determine the IP version, starting with IPv4. */
- wol_dest.sin_port = htons(GUAC_WOL_PORT);
+ wol_dest.sin_port = htons(udp_port);
wol_dest.sin_family = AF_INET;
int retval = inet_pton(wol_dest.sin_family, broadcast_addr, &(wol_dest.sin_addr));
@@ -165,7 +168,8 @@
}
-int guac_wol_wake(const char* mac_addr, const char* broadcast_addr) {
+int guac_wol_wake(const char* mac_addr, const char* broadcast_addr,
+ const unsigned short udp_port) {
unsigned char wol_packet[GUAC_WOL_PACKET_SIZE];
unsigned int dest_mac[6];
@@ -183,7 +187,8 @@
__guac_wol_create_magic_packet(wol_packet, dest_mac);
/* Send the packet and record bytes sent. */
- int bytes_sent = __guac_wol_send_packet(broadcast_addr, wol_packet);
+ int bytes_sent = __guac_wol_send_packet(broadcast_addr, udp_port,
+ wol_packet);
/* Return 0 if bytes were sent, otherwise return an error. */
if (bytes_sent)
diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c
index d7b7589..ce6a279 100644
--- a/src/protocols/rdp/rdp.c
+++ b/src/protocols/rdp/rdp.c
@@ -615,7 +615,8 @@
"and pausing for %d seconds.", settings->wol_wait_time);
/* Send the Wake-on-LAN request. */
- if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr))
+ if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
+ settings->wol_udp_port))
return NULL;
/* If wait time is specified, sleep for that amount of time. */
diff --git a/src/protocols/rdp/settings.c b/src/protocols/rdp/settings.c
index 57760d9..dd8a96f 100644
--- a/src/protocols/rdp/settings.c
+++ b/src/protocols/rdp/settings.c
@@ -124,6 +124,7 @@
"wol-send-packet",
"wol-mac-addr",
"wol-broadcast-addr",
+ "wol-udp-port",
"wol-wait-time",
NULL
};
@@ -610,6 +611,11 @@
IDX_WOL_BROADCAST_ADDR,
/**
+ * The UDP port to use in the magic WoL packet.
+ */
+ IDX_WOL_UDP_PORT,
+
+ /**
* The amount of time, in seconds, to wait after sending the WoL packet
* before attempting to connect to the host. This should be a reasonable
* amount of time to allow the remote host to fully boot and respond to
@@ -1133,6 +1139,11 @@
guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv,
IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST);
+ /* Parse the WoL broadcast port. */
+ settings->wol_udp_port = (unsigned short)
+ guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
+ IDX_WOL_UDP_PORT, GUAC_WOL_PORT);
+
/* Parse the WoL wait time. */
settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_RDP_CLIENT_ARGS, argv,
@@ -1202,6 +1213,7 @@
/* Free load balancer information string */
free(settings->load_balance_info);
+ /* Free Wake-on-LAN strings */
free(settings->wol_mac_addr);
free(settings->wol_broadcast_addr);
diff --git a/src/protocols/rdp/settings.h b/src/protocols/rdp/settings.h
index d809221..323ba5d 100644
--- a/src/protocols/rdp/settings.h
+++ b/src/protocols/rdp/settings.h
@@ -584,6 +584,11 @@
char* wol_broadcast_addr;
/**
+ * The UDP port to use when sending the magic WoL packet.
+ */
+ unsigned short wol_udp_port;
+
+ /**
* The amount of time to wait after sending the magic WoL packet before
* continuing the connection.
*/
diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c
index 242e1d2..b286555 100644
--- a/src/protocols/ssh/settings.c
+++ b/src/protocols/ssh/settings.c
@@ -72,6 +72,7 @@
"wol-send-packet",
"wol-mac-addr",
"wol-broadcast-addr",
+ "wol-udp-port",
"wol-wait-time",
NULL
};
@@ -318,6 +319,11 @@
IDX_WOL_BROADCAST_ADDR,
/**
+ * The UDP port to use when sending the WoL packet.
+ */
+ IDX_WOL_UDP_PORT,
+
+ /**
* The amount of time to wait after sending the magic WoL packet prior to
* continuing the connection attempt. The default is no wait time
* (0 seconds).
@@ -533,6 +539,10 @@
guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST);
+ settings->wol_udp_port = (unsigned short)
+ guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
+ IDX_WOL_UDP_PORT, GUAC_WOL_PORT);
+
settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_WOL_WAIT_TIME, GUAC_WOL_DEFAULT_BOOT_WAIT_TIME);
diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h
index d106b0a..64691de 100644
--- a/src/protocols/ssh/settings.h
+++ b/src/protocols/ssh/settings.h
@@ -303,6 +303,11 @@
char* wol_broadcast_addr;
/**
+ * The UDP port to use when sending the magic WoL packet.
+ */
+ unsigned short wol_udp_port;
+
+ /**
* The amount of time to wait for the system to wake after sending the packet.
*/
int wol_wait_time;
diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c
index 03f5b0b..aaa5a8e 100644
--- a/src/protocols/ssh/ssh.c
+++ b/src/protocols/ssh/ssh.c
@@ -208,7 +208,8 @@
"and pausing for %d seconds.", settings->wol_wait_time);
/* Send the Wake-on-LAN request. */
- if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr))
+ if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
+ settings->wol_udp_port))
return NULL;
/* If wait time is specified, sleep for that amount of time. */
diff --git a/src/protocols/telnet/settings.c b/src/protocols/telnet/settings.c
index 91b9e11..464f936 100644
--- a/src/protocols/telnet/settings.c
+++ b/src/protocols/telnet/settings.c
@@ -63,6 +63,7 @@
"wol-send-packet",
"wol-mac-addr",
"wol-broadcast-addr",
+ "wol-udp-port",
"wol-wait-time",
NULL
};
@@ -259,6 +260,11 @@
IDX_WOL_BROADCAST_ADDR,
/**
+ * The UDP port to use when sending the WoL packet.
+ */
+ IDX_WOL_UDP_PORT,
+
+ /**
* The amount of time, in seconds, to wait after the magic WoL packet is
* sent before continuing the connection attempt. The default is not to
* wait at all (0 seconds).
@@ -511,6 +517,11 @@
guac_user_parse_args_string(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST);
+ /* Parse the WoL broadcast port. */
+ settings->wol_udp_port = (unsigned short)
+ guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
+ IDX_WOL_UDP_PORT, GUAC_WOL_PORT);
+
/* Parse the WoL wait time. */
settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
@@ -553,6 +564,10 @@
/* Free terminal emulator type. */
free(settings->terminal_type);
+
+ /* Free WoL settings. */
+ free(settings->wol_mac_addr);
+ free(settings->wol_broadcast_addr);
/* Free overall structure */
free(settings);
diff --git a/src/protocols/telnet/settings.h b/src/protocols/telnet/settings.h
index dfaaa97..c55dc52 100644
--- a/src/protocols/telnet/settings.h
+++ b/src/protocols/telnet/settings.h
@@ -276,6 +276,11 @@
char* wol_broadcast_addr;
/**
+ * The UDP port to use when sending the WoL packet.
+ */
+ unsigned short wol_udp_port;
+
+ /**
* The number of seconds to wait after sending the magic WoL packet before
* continuing the connection.
*/
diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c
index 8d8d439..b2b3106 100644
--- a/src/protocols/telnet/telnet.c
+++ b/src/protocols/telnet/telnet.c
@@ -564,7 +564,8 @@
"and pausing for %d seconds.", settings->wol_wait_time);
/* Send the Wake-on-LAN request. */
- if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr))
+ if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
+ settings->wol_udp_port))
return NULL;
/* If wait time is specified, sleep for that amount of time. */
diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c
index c6f3646..691e708 100644
--- a/src/protocols/vnc/settings.c
+++ b/src/protocols/vnc/settings.c
@@ -89,6 +89,7 @@
"wol-send-packet",
"wol-mac-addr",
"wol-broadcast-addr",
+ "wol-udp-port",
"wol-wait-time",
NULL
};
@@ -361,6 +362,11 @@
IDX_WOL_BROADCAST_ADDR,
/**
+ * The UDP port to use when sending the WoL packet.
+ */
+ IDX_WOL_UDP_PORT,
+
+ /**
* The number of seconds to wait after sending the magic WoL packet before
* attempting to connect to the remote host. The default is not to wait
* at all (0 seconds).
@@ -608,6 +614,11 @@
guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv,
IDX_WOL_BROADCAST_ADDR, GUAC_WOL_LOCAL_IPV4_BROADCAST);
+ /* Parse the WoL broadcast port. */
+ settings->wol_udp_port = (unsigned short)
+ guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
+ IDX_WOL_UDP_PORT, GUAC_WOL_PORT);
+
/* Parse the WoL wait time. */
settings->wol_wait_time =
guac_user_parse_args_int(user, GUAC_VNC_CLIENT_ARGS, argv,
@@ -652,6 +663,10 @@
/* Free PulseAudio settings */
free(settings->pa_servername);
#endif
+
+ /* Free Wake-on-LAN strings */
+ free(settings->wol_mac_addr);
+ free(settings->wol_broadcast_addr);
/* Free settings structure */
free(settings);
diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h
index 8d5659e..6d1c657 100644
--- a/src/protocols/vnc/settings.h
+++ b/src/protocols/vnc/settings.h
@@ -290,6 +290,11 @@
char* wol_broadcast_addr;
/**
+ * The UDP port to use when sending the WoL packet.
+ */
+ unsigned short wol_udp_port;
+
+ /**
* The number of seconds after sending the magic WoL packet to wait before
* attempting to connect to the remote host.
*/
diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c
index a310e51..cd09951 100644
--- a/src/protocols/vnc/vnc.c
+++ b/src/protocols/vnc/vnc.c
@@ -247,7 +247,8 @@
"and pausing for %d seconds.", settings->wol_wait_time);
/* Send the Wake-on-LAN request. */
- if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr))
+ if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
+ settings->wol_udp_port))
return NULL;
/* If wait time is specified, sleep for that amount of time. */