led: Remove unused plugin
This was originally developed for a custom device. No known users for years.
This commit is contained in:
@@ -70,7 +70,6 @@ plugins = \
|
||||
plugins/imv-swima.opt \
|
||||
plugins/imv-test.opt \
|
||||
plugins/ipseckey.opt \
|
||||
plugins/led.opt \
|
||||
plugins/kernel-libipsec.opt \
|
||||
plugins/kernel-netlink.opt \
|
||||
plugins/kernel-pfkey.opt \
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
charon.plugins.led.activity_led =
|
||||
|
||||
charon.plugins.led.blink_time = 50
|
||||
@@ -270,7 +270,6 @@ ARG_ENABL_SET([forecast], [enable forecast plugin forwarding broadcast/mul
|
||||
ARG_ENABL_SET([error-notify], [enable error notification plugin.])
|
||||
ARG_ENABL_SET([farp], [enable ARP faking plugin that responds to ARP requests to peers virtual IP])
|
||||
ARG_ENABL_SET([ha], [enable high availability cluster plugin.])
|
||||
ARG_ENABL_SET([led], [enable plugin to control LEDs on IKEv2 activity using the Linux kernel LED subsystem.])
|
||||
ARG_ENABL_SET([load-tester], [enable load testing plugin for IKEv2 daemon.])
|
||||
ARG_ENABL_SET([lookip], [enable fast virtual IP lookup and notification plugin.])
|
||||
ARG_ENABL_SET([radattr], [enable plugin to inject and process custom RADIUS attributes as IKEv2 client.])
|
||||
@@ -1612,7 +1611,6 @@ ADD_PLUGIN([lookip], [c charon])
|
||||
ADD_PLUGIN([error-notify], [c charon])
|
||||
ADD_PLUGIN([certexpire], [c charon])
|
||||
ADD_PLUGIN([systime-fix], [c charon])
|
||||
ADD_PLUGIN([led], [c charon])
|
||||
ADD_PLUGIN([coupling], [c charon])
|
||||
ADD_PLUGIN([radattr], [c charon])
|
||||
ADD_PLUGIN([addrblock], [c charon])
|
||||
@@ -1727,7 +1725,6 @@ AM_CONDITIONAL(USE_LOOKIP, test x$lookip = xtrue)
|
||||
AM_CONDITIONAL(USE_ERROR_NOTIFY, test x$error_notify = xtrue)
|
||||
AM_CONDITIONAL(USE_CERTEXPIRE, test x$certexpire = xtrue)
|
||||
AM_CONDITIONAL(USE_SYSTIME_FIX, test x$systime_fix = xtrue)
|
||||
AM_CONDITIONAL(USE_LED, test x$led = xtrue)
|
||||
AM_CONDITIONAL(USE_COUPLING, test x$coupling = xtrue)
|
||||
AM_CONDITIONAL(USE_RADATTR, test x$radattr = xtrue)
|
||||
AM_CONDITIONAL(USE_EAP_SIM, test x$eap_sim = xtrue)
|
||||
@@ -2074,7 +2071,6 @@ AC_CONFIG_FILES([
|
||||
src/libcharon/plugins/error_notify/Makefile
|
||||
src/libcharon/plugins/certexpire/Makefile
|
||||
src/libcharon/plugins/systime_fix/Makefile
|
||||
src/libcharon/plugins/led/Makefile
|
||||
src/libcharon/plugins/coupling/Makefile
|
||||
src/libcharon/plugins/radattr/Makefile
|
||||
src/libcharon/plugins/osx_attr/Makefile
|
||||
|
||||
@@ -614,13 +614,6 @@ if MONOLITHIC
|
||||
endif
|
||||
endif
|
||||
|
||||
if USE_LED
|
||||
SUBDIRS += plugins/led
|
||||
if MONOLITHIC
|
||||
libcharon_la_LIBADD += plugins/led/libstrongswan-led.la
|
||||
endif
|
||||
endif
|
||||
|
||||
if USE_COUPLING
|
||||
SUBDIRS += plugins/coupling
|
||||
if MONOLITHIC
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/libstrongswan \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
|
||||
AM_CFLAGS = \
|
||||
$(PLUGIN_CFLAGS)
|
||||
|
||||
if MONOLITHIC
|
||||
noinst_LTLIBRARIES = libstrongswan-led.la
|
||||
else
|
||||
plugin_LTLIBRARIES = libstrongswan-led.la
|
||||
endif
|
||||
|
||||
libstrongswan_led_la_SOURCES = led_plugin.h led_plugin.c \
|
||||
led_listener.h led_listener.c
|
||||
|
||||
libstrongswan_led_la_LDFLAGS = -module -avoid-version
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "led_listener.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <daemon.h>
|
||||
#include <threading/mutex.h>
|
||||
#include <processing/jobs/callback_job.h>
|
||||
|
||||
typedef struct private_led_listener_t private_led_listener_t;
|
||||
|
||||
/**
|
||||
* Private data of an led_listener_t object.
|
||||
*/
|
||||
struct private_led_listener_t {
|
||||
|
||||
/**
|
||||
* Public led_listener_t interface.
|
||||
*/
|
||||
led_listener_t public;
|
||||
|
||||
/**
|
||||
* Mutex
|
||||
*/
|
||||
mutex_t *mutex;
|
||||
|
||||
/**
|
||||
* Number of established IKE_SAs
|
||||
*/
|
||||
int count;
|
||||
|
||||
/**
|
||||
* LED blink on/off time, in ms
|
||||
*/
|
||||
int blink_time;
|
||||
|
||||
/**
|
||||
* Activity LED fd, if any
|
||||
*/
|
||||
FILE *activity;
|
||||
|
||||
/**
|
||||
* Activity LED maximum brightness
|
||||
*/
|
||||
int activity_max;
|
||||
};
|
||||
|
||||
/**
|
||||
* Open a LED brightness control file, get max brightness
|
||||
*/
|
||||
static FILE *open_led(char *name, int *max_brightness)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
FILE *f;
|
||||
|
||||
if (!name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*max_brightness = 1;
|
||||
snprintf(path, sizeof(path), "/sys/class/leds/%s/max_brightness", name);
|
||||
f = fopen(path, "r");
|
||||
if (f)
|
||||
{
|
||||
if (fscanf(f, "%d\n", max_brightness) != 1)
|
||||
{
|
||||
DBG1(DBG_CFG, "reading max brightness for '%s' failed: %s, using 1",
|
||||
name, strerror(errno));
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1(DBG_CFG, "reading max_brightness for '%s' failed: %s, using 1",
|
||||
name, strerror(errno));
|
||||
}
|
||||
|
||||
snprintf(path, sizeof(path), "/sys/class/leds/%s/brightness", name);
|
||||
f = fopen(path, "w");
|
||||
if (!f)
|
||||
{
|
||||
DBG1(DBG_CFG, "opening LED file '%s' failed: %s", path, strerror(errno));
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a LED to a given brightness
|
||||
*/
|
||||
static void set_led(FILE *led, int brightness)
|
||||
{
|
||||
if (led)
|
||||
{
|
||||
if (fprintf(led, "%d\n", brightness) <= 0 ||
|
||||
fflush(led) != 0)
|
||||
{
|
||||
DBG1(DBG_CFG, "setting LED brightness failed: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin unloaded?
|
||||
*/
|
||||
static bool plugin_gone = FALSE;
|
||||
|
||||
/**
|
||||
* Reset activity LED after timeout
|
||||
*/
|
||||
static job_requeue_t reset_activity_led(private_led_listener_t *this)
|
||||
{
|
||||
if (!plugin_gone)
|
||||
{ /* TODO: fix race */
|
||||
this->mutex->lock(this->mutex);
|
||||
if (this->count)
|
||||
{
|
||||
set_led(this->activity, this->activity_max);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_led(this->activity, 0);
|
||||
}
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blink the activity LED
|
||||
*/
|
||||
static void blink_activity(private_led_listener_t *this)
|
||||
{
|
||||
if (this->activity)
|
||||
{
|
||||
this->mutex->lock(this->mutex);
|
||||
if (this->count)
|
||||
{
|
||||
set_led(this->activity, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_led(this->activity, this->activity_max);
|
||||
}
|
||||
lib->scheduler->schedule_job_ms(lib->scheduler, (job_t*)
|
||||
callback_job_create_with_prio((callback_job_cb_t)reset_activity_led,
|
||||
this, NULL, NULL, JOB_PRIO_CRITICAL), this->blink_time);
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(listener_t, ike_state_change, bool,
|
||||
private_led_listener_t *this, ike_sa_t *ike_sa, ike_sa_state_t state)
|
||||
{
|
||||
this->mutex->lock(this->mutex);
|
||||
if (state == IKE_ESTABLISHED && ike_sa->get_state(ike_sa) != IKE_ESTABLISHED)
|
||||
{
|
||||
this->count++;
|
||||
if (this->count == 1)
|
||||
{
|
||||
set_led(this->activity, this->activity_max);
|
||||
}
|
||||
}
|
||||
if (ike_sa->get_state(ike_sa) == IKE_ESTABLISHED && state != IKE_ESTABLISHED)
|
||||
{
|
||||
this->count--;
|
||||
if (this->count == 0)
|
||||
{
|
||||
set_led(this->activity, 0);
|
||||
}
|
||||
}
|
||||
this->mutex->unlock(this->mutex);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(listener_t, message_hook, bool,
|
||||
private_led_listener_t *this, ike_sa_t *ike_sa,
|
||||
message_t *message, bool incoming, bool plain)
|
||||
{
|
||||
if (plain && (incoming || message->get_request(message)))
|
||||
{
|
||||
blink_activity(this);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(led_listener_t, destroy, void,
|
||||
private_led_listener_t *this)
|
||||
{
|
||||
this->mutex->lock(this->mutex);
|
||||
set_led(this->activity, 0);
|
||||
plugin_gone = TRUE;
|
||||
this->mutex->unlock(this->mutex);
|
||||
if (this->activity)
|
||||
{
|
||||
fclose(this->activity);
|
||||
}
|
||||
this->mutex->destroy(this->mutex);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
led_listener_t *led_listener_create()
|
||||
{
|
||||
private_led_listener_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.listener = {
|
||||
.ike_state_change = _ike_state_change,
|
||||
.message = _message_hook,
|
||||
},
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||
.blink_time = lib->settings->get_int(lib->settings,
|
||||
"%s.plugins.led.blink_time", 50, lib->ns),
|
||||
);
|
||||
|
||||
this->activity = open_led(lib->settings->get_str(lib->settings,
|
||||
"%s.plugins.led.activity_led", NULL, lib->ns),
|
||||
&this->activity_max);
|
||||
set_led(this->activity, 0);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup led_listener led_listener
|
||||
* @{ @ingroup led
|
||||
*/
|
||||
|
||||
#ifndef LED_LISTENER_H_
|
||||
#define LED_LISTENER_H_
|
||||
|
||||
#include <bus/listeners/listener.h>
|
||||
|
||||
typedef struct led_listener_t led_listener_t;
|
||||
|
||||
/**
|
||||
* Listener that controls LEDs based on IKEv2 activity/state.
|
||||
*/
|
||||
struct led_listener_t {
|
||||
|
||||
/**
|
||||
* Implements listener_t interface.
|
||||
*/
|
||||
listener_t listener;
|
||||
|
||||
/**
|
||||
* Destroy a led_listener_t.
|
||||
*/
|
||||
void (*destroy)(led_listener_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a led_listener instance.
|
||||
*/
|
||||
led_listener_t *led_listener_create();
|
||||
|
||||
#endif /** LED_LISTENER_H_ @}*/
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "led_plugin.h"
|
||||
|
||||
#include "led_listener.h"
|
||||
|
||||
#include <daemon.h>
|
||||
|
||||
typedef struct private_led_plugin_t private_led_plugin_t;
|
||||
|
||||
/**
|
||||
* private data of led plugin
|
||||
*/
|
||||
struct private_led_plugin_t {
|
||||
|
||||
/**
|
||||
* implements plugin interface
|
||||
*/
|
||||
led_plugin_t public;
|
||||
|
||||
/**
|
||||
* Listener controlling LEDs
|
||||
*/
|
||||
led_listener_t *listener;
|
||||
};
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
private_led_plugin_t *this)
|
||||
{
|
||||
return "led";
|
||||
}
|
||||
|
||||
/**
|
||||
* Register listener
|
||||
*/
|
||||
static bool plugin_cb(private_led_plugin_t *this,
|
||||
plugin_feature_t *feature, bool reg, void *cb_data)
|
||||
{
|
||||
if (reg)
|
||||
{
|
||||
charon->bus->add_listener(charon->bus, &this->listener->listener);
|
||||
}
|
||||
else
|
||||
{
|
||||
charon->bus->remove_listener(charon->bus, &this->listener->listener);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(plugin_t, get_features, int,
|
||||
private_led_plugin_t *this, plugin_feature_t *features[])
|
||||
{
|
||||
static plugin_feature_t f[] = {
|
||||
PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL),
|
||||
PLUGIN_PROVIDE(CUSTOM, "led"),
|
||||
};
|
||||
*features = f;
|
||||
return countof(f);
|
||||
}
|
||||
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_led_plugin_t *this)
|
||||
{
|
||||
this->listener->destroy(this->listener);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin constructor
|
||||
*/
|
||||
PLUGIN_DEFINE(led)
|
||||
{
|
||||
private_led_plugin_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.plugin = {
|
||||
.get_name = _get_name,
|
||||
.get_features = _get_features,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.listener = led_listener_create(),
|
||||
);
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup led led
|
||||
* @ingroup cplugins
|
||||
*
|
||||
* @defgroup led_plugin led_plugin
|
||||
* @{ @ingroup led
|
||||
*/
|
||||
|
||||
#ifndef LED_PLUGIN_H_
|
||||
#define LED_PLUGIN_H_
|
||||
|
||||
#include <plugins/plugin.h>
|
||||
|
||||
typedef struct led_plugin_t led_plugin_t;
|
||||
|
||||
/**
|
||||
* Linux LED control based on IKE activity/state.
|
||||
*/
|
||||
struct led_plugin_t {
|
||||
|
||||
/**
|
||||
* implements plugin interface
|
||||
*/
|
||||
plugin_t plugin;
|
||||
};
|
||||
|
||||
#endif /** LED_PLUGIN_H_ @}*/
|
||||
Reference in New Issue
Block a user