Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ DIST_SUBDIRS = \
src/protocols/rdp \
src/protocols/ssh \
src/protocols/telnet \
src/protocols/ipmi \
src/protocols/vnc

SUBDIRS = \
Expand Down Expand Up @@ -73,6 +74,10 @@ if ENABLE_TELNET
SUBDIRS += src/protocols/telnet
endif

if ENABLE_IPMI
SUBDIRS += src/protocols/ipmi
endif

if ENABLE_VNC
SUBDIRS += src/protocols/vnc
endif
Expand Down
41 changes: 41 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ AC_SUBST([COMMON_SSH_INCLUDE], '-I$(top_srcdir)/src/common-ssh')
AC_SUBST([LIBGUAC_CLIENT_KUBERNETES_LTLIB], '$(top_builddir)/src/protocols/kubernetes/libguac-client-kubernetes.la')
AC_SUBST([LIBGUAC_CLIENT_KUBERNETES_INCLUDE], '-I$(top_srcdir)/src/protocols/kubernetes')

# IPMI support
AC_SUBST([LIBGUAC_CLIENT_IPMI_LTLIB], '$(top_builddir)/src/protocols/ipmi/libguac-client-ipmi.la')
AC_SUBST([LIBGUAC_CLIENT_IPMI_INCLUDE], '-I$(top_srcdir)/src/protocols/ipmi')

# RDP support
AC_SUBST([LIBGUAC_CLIENT_RDP_LTLIB], '$(top_builddir)/src/protocols/rdp/libguac-client-rdp.la')
AC_SUBST([LIBGUAC_CLIENT_RDP_INCLUDE], '-I$(top_srcdir)/src/protocols/rdp')
Expand Down Expand Up @@ -1304,6 +1308,38 @@ AM_CONDITIONAL([ENABLE_TELNET], [test "x${have_libtelnet}" = "xyes" \

AC_SUBST(TELNET_LIBS)

#
# FreeIPMI (libipmiconsole + libfreeipmi)
#

have_freeipmi=disabled
IPMI_LIBS=
IPMI_CFLAGS=
AC_ARG_WITH([ipmi],
[AS_HELP_STRING([--with-ipmi],
[support IPMI Serial-over-LAN @<:@default=check@:>@])],
[],
[with_ipmi=check])

if test "x$with_ipmi" != "xno"
then
have_freeipmi=yes

# The SOL console is driven by libipmiconsole, while chassis power
# management is driven by libfreeipmi.
AC_CHECK_HEADER([ipmiconsole.h],, [have_freeipmi=no])
AC_CHECK_LIB([ipmiconsole], [ipmiconsole_ctx_create],
[IPMI_LIBS="$IPMI_LIBS -lipmiconsole"], [have_freeipmi=no])
AC_CHECK_LIB([freeipmi], [ipmi_ctx_create],
[IPMI_LIBS="$IPMI_LIBS -lfreeipmi"], [have_freeipmi=no])
fi

AM_CONDITIONAL([ENABLE_IPMI], [test "x${have_freeipmi}" = "xyes" \
-a "x${have_terminal}" = "xyes"])

AC_SUBST(IPMI_CFLAGS)
AC_SUBST(IPMI_LIBS)

#
# libwebp
#
Expand Down Expand Up @@ -1489,6 +1525,8 @@ AC_CONFIG_FILES([Makefile
src/protocols/rdp/tests/Makefile
src/protocols/ssh/Makefile
src/protocols/telnet/Makefile
src/protocols/ipmi/Makefile
src/protocols/ipmi/tests/Makefile
src/protocols/vnc/Makefile])
AC_OUTPUT

Expand All @@ -1500,6 +1538,7 @@ AM_COND_IF([ENABLE_KUBERNETES], [build_kubernetes=yes], [build_kubernetes=no])
AM_COND_IF([ENABLE_RDP], [build_rdp=yes], [build_rdp=no])
AM_COND_IF([ENABLE_SSH], [build_ssh=yes], [build_ssh=no])
AM_COND_IF([ENABLE_TELNET], [build_telnet=yes], [build_telnet=no])
AM_COND_IF([ENABLE_IPMI], [build_ipmi=yes], [build_ipmi=no])
AM_COND_IF([ENABLE_VNC], [build_vnc=yes], [build_vnc=no])

#
Expand Down Expand Up @@ -1549,6 +1588,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION
libssl .............. ${have_ssl}
libswscale .......... ${have_libswscale}
libtelnet ........... ${have_libtelnet}
freeipmi ............ ${have_freeipmi}
libVNCServer ........ ${have_libvncserver}
libvorbis ........... ${have_vorbis}
libpulse ............ ${have_pulse}
Expand All @@ -1562,6 +1602,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION
RDP ........... ${build_rdp}
SSH ........... ${build_ssh}
Telnet ........ ${build_telnet}
IPMI .......... ${build_ipmi}
VNC ........... ${build_vnc}

Services / tools:
Expand Down
73 changes: 73 additions & 0 deletions src/protocols/ipmi/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# NOTE: Parts of this file (Makefile.am) are automatically transcluded verbatim
# into Makefile.in. Though the build system (GNU Autotools) automatically adds
# its own license boilerplate to the generated Makefile.in, that boilerplate
# does not apply to the transcluded portions of Makefile.am which are licensed
# to you by the ASF under the Apache License, Version 2.0, as described above.
#

AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4

SUBDIRS = . tests

lib_LTLIBRARIES = libguac-client-ipmi.la

libguac_client_ipmi_la_SOURCES = \
argv.c \
chassis.c \
client.c \
clipboard.c \
control.c \
input.c \
ipmi.c \
menu.c \
pipe.c \
settings.c \
user.c

noinst_HEADERS = \
argv.h \
chassis.h \
client.h \
clipboard.h \
control.h \
input.h \
ipmi.h \
menu.h \
pipe.h \
settings.h \
user.h

libguac_client_ipmi_la_CFLAGS = \
-Werror -Wall -Iinclude \
@LIBGUAC_INCLUDE@ \
@IPMI_CFLAGS@ \
@TERMINAL_INCLUDE@

libguac_client_ipmi_la_LIBADD = \
@COMMON_LTLIB@ \
@LIBGUAC_LTLIB@ \
@TERMINAL_LTLIB@ \
@IPMI_LIBS@

libguac_client_ipmi_la_LDFLAGS = \
-version-info 0:0:0 \
@PTHREAD_LIBS@
96 changes: 96 additions & 0 deletions src/protocols/ipmi/argv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "config.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike recently submitted a PR that makes including config.h unnecessary - see #691.

#include "argv.h"
#include "ipmi.h"
#include "terminal/terminal.h"

#include <guacamole/protocol.h>
#include <guacamole/socket.h>
#include <guacamole/user.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int guac_ipmi_argv_callback(guac_user* user, const char* mimetype,
const char* name, const char* value, void* data) {

guac_client* client = user->client;
guac_ipmi_client* ipmi_client = (guac_ipmi_client*) client->data;
guac_terminal* terminal = ipmi_client->term;

/* Skip if terminal not yet ready */
if (terminal == NULL)
return 0;

/* Update color scheme */
if (strcmp(name, GUAC_IPMI_ARGV_COLOR_SCHEME) == 0)
guac_terminal_apply_color_scheme(terminal, value);

/* Update font name */
else if (strcmp(name, GUAC_IPMI_ARGV_FONT_NAME) == 0)
guac_terminal_apply_font(terminal, value, -1, 0);

/* Update only if font size is sane */
else if (strcmp(name, GUAC_IPMI_ARGV_FONT_SIZE) == 0) {
int size = atoi(value);
if (size > 0)
guac_terminal_apply_font(terminal, NULL, size,
ipmi_client->settings->resolution);
}

return 0;

}

void* guac_ipmi_send_current_argv(guac_user* user, void* data) {

/* Defer to the batch handler, using the user's socket to send the data */
guac_ipmi_send_current_argv_batch(user->client, user->socket);

return NULL;

}

void guac_ipmi_send_current_argv_batch(
guac_client* client, guac_socket* socket) {

guac_ipmi_client* ipmi_client = (guac_ipmi_client*) client->data;
guac_terminal* terminal = ipmi_client->term;

/* Send current color scheme */
guac_client_stream_argv(client, socket, "text/plain",
GUAC_IPMI_ARGV_COLOR_SCHEME,
guac_terminal_get_color_scheme(terminal));

/* Send current font name */
guac_client_stream_argv(client, socket, "text/plain",
GUAC_IPMI_ARGV_FONT_NAME,
guac_terminal_get_font_name(terminal));

/* Send current font size */
char font_size[64];
snprintf(font_size, sizeof(font_size), "%i",
guac_terminal_get_font_size(terminal));
guac_client_stream_argv(client, socket, "text/plain",
GUAC_IPMI_ARGV_FONT_SIZE, font_size);

}
89 changes: 89 additions & 0 deletions src/protocols/ipmi/argv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#ifndef GUAC_IPMI_ARGV_H
#define GUAC_IPMI_ARGV_H

#include <guacamole/argv.h>
#include <guacamole/user.h>

/**
* The name of the parameter that specifies/updates the color scheme used by
* the terminal emulator.
*/
#define GUAC_IPMI_ARGV_COLOR_SCHEME "color-scheme"

/**
* The name of the parameter that specifies/updates the name of the font used
* by the terminal emulator.
*/
#define GUAC_IPMI_ARGV_FONT_NAME "font-name"

/**
* The name of the parameter that specifies/updates the font size used by the
* terminal emulator.
*/
#define GUAC_IPMI_ARGV_FONT_SIZE "font-size"

/**
* Handles a received argument value from a Guacamole "argv" instruction,
* updating the given connection parameter.
*/
guac_argv_callback guac_ipmi_argv_callback;

/**
* Sends the current values of all non-sensitive parameters which may be set
* while the connection is running to the given user. Note that the user
* receiving these values will not necessarily be able to set new values
* themselves if their connection is read-only. This function can be used as
* the callback for guac_client_foreach_user() and guac_client_for_owner()
*
* @param user
* The user that should receive the values of all non-sensitive parameters
* which may be set while the connection is running.
*
* @param data
* The guac_ipmi_client instance associated with the current connection.
*
* @return
* Always NULL.
*/
void* guac_ipmi_send_current_argv(guac_user* user, void* data);

/**
* Sends the current values of all non-sensitive parameters which may be set
* while the connection is running to the users associated with the provided
* socket. Note that the users receiving these values will not necessarily be
* able to set new values themselves if their connection is read-only.
*
* @param client
* The client associated with the users that should receive the values of
* all non-sensitive parameters which may be set while the connection is
* running.
*
* @param socket
* The socket to send the arguments to the batch of users along.
*
* @return
* Always NULL.
*/
void guac_ipmi_send_current_argv_batch(
guac_client* client, guac_socket* socket);

#endif
Loading
Loading