From 85d6a2b6522d667cbc4ed329afd2d22866efd9b5 Mon Sep 17 00:00:00 2001 From: Kozlov Dmitry Date: Wed, 18 Jan 2012 14:41:48 +0400 Subject: implemented logwtmp --- accel-pppd/accel-ppp.conf | 1 + accel-pppd/extra/CMakeLists.txt | 2 ++ accel-pppd/extra/logwtmp.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 accel-pppd/extra/logwtmp.c diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index ee01891c..0e7960d9 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -20,6 +20,7 @@ pppd_compat #net-snmp #ipv6_nd #ipv6_dhcp +#logwtmp [core] log-error=/var/log/accel-ppp/core.log diff --git a/accel-pppd/extra/CMakeLists.txt b/accel-pppd/extra/CMakeLists.txt index 60fe1115..4baf4921 100644 --- a/accel-pppd/extra/CMakeLists.txt +++ b/accel-pppd/extra/CMakeLists.txt @@ -3,6 +3,8 @@ ADD_LIBRARY(ippool SHARED ippool.c) ADD_LIBRARY(ipv6pool SHARED ipv6pool.c) ADD_LIBRARY(sigchld SHARED sigchld.c) ADD_LIBRARY(chap-secrets SHARED chap-secrets.c) +ADD_LIBRARY(logwtmp SHARED logwtmp.c) +TARGET_LINK_LIBRARIES(logwtmp util) INSTALL(TARGETS pppd_compat ippool ipv6pool sigchld chap-secrets LIBRARY DESTINATION lib/accel-ppp diff --git a/accel-pppd/extra/logwtmp.c b/accel-pppd/extra/logwtmp.c new file mode 100644 index 00000000..5848102e --- /dev/null +++ b/accel-pppd/extra/logwtmp.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "ppp.h" +#include "events.h" +#include "triton.h" +#include "log.h" + +#include "memdebug.h" + + +static void ev_ppp_started(struct ppp_t *ppp) +{ + logwtmp(ppp->ifname, ppp->username, ppp->ctrl->calling_station_id); +} + +static void ev_ppp_finished(struct ppp_t *ppp) +{ + logwtmp(ppp->ifname, "", ""); +} + +static void init(void) +{ + triton_event_register_handler(EV_PPP_STARTED, (triton_event_func)ev_ppp_started); + triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ev_ppp_finished); +} + +DEFINE_INIT(200, init); -- cgit v1.2.3