Teonet library
0.4.7
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include "hotkeys.h"
#include "ev_mgr.h"
#include "net_multi.h"
#include "utils/rlutil.h"
#include "utils/utils.h"
#include "tr-udp_stat.h"
#include "utils/teo_memory.h"
#include "text-filter/text-filter.h"
Macros | |
#define | MODULE _ANSI_CYAN "event_manager" _ANSI_NONE |
File: hotkeys.c Author: Kirill Scherba kiril l@sc herba .ruMore... | |
#define | COLOR_DW "\033[01;32m" |
#define | COLOR_END "\033[0m" |
#define | kev ((ksnetEvMgrClass*)ke) |
#define | khv kev->kh |
#define | kc kev->kc |
#define | switch_to_net(p_ke) |
#define | MONITOR_TIMER_INTERVAL 5.0 |
#define | PEER_TIMER_INTERVAL 0.150 |
#define | TR_UDP_TIMER_INTERVAL 0.150 |
Enumerations | |
enum | wait_y { Y_NONE, Y_QUIT } |
Yes answer action. More... | |
Functions | |
void | stdin_cb (EV_P_ ev_io *w, int revents) |
STDIN (has data) callback. More... | |
void | idle_stdin_cb (EV_P_ ev_idle *w, int revents) |
STDIN Idle callback: execute STDIN callback in idle time. More... | |
ping_timer_data * | ping_timer_init (ksnCoreClass *kn, char *peer) |
Initialize ping timer. More... | |
void | ping_timer_stop (ping_timer_data **pt) |
Stop ping timer. More... | |
monitor_timer_data * | monitor_timer_init (ksnCoreClass *kn) |
Initialize monitor timer. More... | |
void | monitor_timer_stop (monitor_timer_data **mt) |
Stop monitor timer. More... | |
peer_timer_data * | peer_timer_init (ksnCoreClass *kn) |
Initialize peer timer. More... | |
void | peer_timer_stop (peer_timer_data **pet) |
Stop peer timer. More... | |
tr_udp_timer_data * | tr_udp_timer_init (ksnCoreClass *kn) |
Initialize tr_udp timer. More... | |
void | tr_udp_timer_stop (tr_udp_timer_data **pet) |
Stop tr_udp timer. More... | |
void | hotkeysResetFilter (ksnetHotkeysClass *hotkeys) |
void | teoHotkeySetFilter (ksnetHotkeysClass *hotkeys, char *filter) |
unsigned char | teoFilterFlagCheck (void *ke) |
unsigned char | teoLogCheck (void *ke, void *log) |
int | hotkeys_cb (ksnetEvMgrClass *ke, void *data, ev_idle *w) |
Callback procedure which called by event manager when STDIN FD has any data. More... | |
void | _keys_non_blocking_start (ksnetHotkeysClass *kh) |
Start keyboard non-blocking mode. More... | |
ksnetHotkeysClass * | ksnetHotkeysInit (void *ke) |
Initialize hot keys module. More... | |
void | ksnetHotkeysDestroy (ksnetHotkeysClass *kh) |
De-initialize hot key module. More... | |
void | ping_timer_cb (EV_P_ ev_timer *w, int revents) |
Ping timer callback. More... | |
int | monitor_timer_one_cb (ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data) |
Send network monitor ping to one peer. More... | |
void | monitor_timer_cb (EV_P_ ev_timer *w, int revents) |
Monitor timer callback. More... | |
void | peer_idle_cb (EV_P_ ev_idle *iw, int revents) |
Peer show idle callback. More... | |
void | peer_timer_cb (EV_P_ ev_timer *tw, int revents) |
Peer timer callback. More... | |
void | tr_udp_idle_cb (EV_P_ ev_idle *iw, int revents) |
TR-UDP show idle callback. More... | |
void | tr_udp_timer_cb (EV_P_ ev_timer *tw, int revents) |
TR-UDP timer callback. More... | |
Variables | |
const char * | SHOW = "show" |
const char * | DONT_SHOW = "don't show" |
const char * | START = "start" |
const char * | STOP = "stop" |
const char * | ON = "on" |
const char * | OFF = "off" |
const char * | PING = "ping" |
const char * | TRACE = "trace" |
const char * | MONITOR = "monitor" |
const char * | TRIPTIME = "triptime" |
#define COLOR_DW "\033[01;32m" |
Referenced by hotkeys_cb().
#define COLOR_END "\033[0m" |
Referenced by hotkeys_cb().
#define kc kev->kc |
#define kev ((ksnetEvMgrClass*)ke) |
Referenced by hotkeys_cb().
#define khv kev->kh |
Referenced by hotkeys_cb(), teoFilterFlagCheck(), and teoLogCheck().
#define MODULE _ANSI_CYAN "event_manager" _ANSI_NONE |
File: hotkeys.c Author: Kirill Scherba kiril l@sc herba .ru
Created on April 16, 2015, 10:43 PM
Hot keys monitor module
Referenced by idle_stdin_cb(), and stdin_cb().
#define MONITOR_TIMER_INTERVAL 5.0 |
Referenced by monitor_timer_init().
#define PEER_TIMER_INTERVAL 0.150 |
Referenced by peer_timer_init().
#define switch_to_net | ( | p_ke | ) |
Referenced by hotkeys_cb().
#define TR_UDP_TIMER_INTERVAL 0.150 |
Referenced by tr_udp_timer_init().
enum wait_y |
void _keys_non_blocking_start | ( | ksnetHotkeysClass * | kh | ) |
Start keyboard non-blocking mode.
kh |
References ECHO, ksnetHotkeysClass::new_settings, and ksnetHotkeysClass::non_blocking.
Referenced by event_cb(), hotkeys_cb(), and ksnetHotkeysInit().
int hotkeys_cb | ( | ksnetEvMgrClass * | ke, |
void * | data, | ||
ev_idle * | w | ||
) |
Callback procedure which called by event manager when STDIN FD has any data.
References _keys_non_blocking_start(), _keys_non_blocking_stop, COLOR_DW, COLOR_END, DEBUG_KSNET, DONT_SHOW, EV_K_HOTKEY, EV_K_USER, free(), hotkeysResetFilter(), kc, ke, kev, ksnetEvMgrClass::kh, khv, ksnetEvMgrClass::km, KSN_BUFFER_SM_SIZE, ksnCommandSendCmdEcho(), ksnetArpShow(), ksnetEvMgrStop(), ksnetHotkeysDestroy(), ksnMultiGet, ksnMultiShowListStr(), ksnTRUDPqueuesShow(), ksnTRUDPstatShow(), ksnVpnListShow(), M_ENAMBE_VPN, monitor_timer_init(), monitor_timer_stop(), ksnetEvMgrClass::n_next, ksnetEvMgrClass::n_prev, ksnetEvMgrClass::net_idx, OFF, ON, peer_timer_init(), peer_timer_stop(), PING, ping_timer_init(), ping_timer_stop(), SHOW, START, STOP, switch_to_net, teoHotkeySetFilter(), teoMultiIsNetworkExist(), teoSScrSubscriptionList(), tr_udp_timer_init(), tr_udp_timer_stop(), TRACE, TRACE_LEN, trimlf(), Y_NONE, and Y_QUIT.
Referenced by idle_stdin_cb().
void hotkeysResetFilter | ( | ksnetHotkeysClass * | hotkeys | ) |
References ksnetHotkeysClass::filter, and free().
Referenced by hotkeys_cb(), and teoHotkeySetFilter().
void idle_stdin_cb | ( | EV_P_ ev_idle * | w, |
int | revents | ||
) |
STDIN Idle callback: execute STDIN callback in idle time.
param loop
w | |
revents |
References stdin_idle_data::data, DEBUG_VV, free(), hotkeys_cb(), stdin_idle_data::ke, ksn_printf, MODULE, and stdin_idle_data::stdin_w.
Referenced by ksnetHotkeysInit().
void ksnetHotkeysDestroy | ( | ksnetHotkeysClass * | kh | ) |
De-initialize hot key module.
kh |
References _keys_non_blocking_stop, ksnetEvMgrClass::ev_loop, free(), ke, ksnetHotkeysClass::ke, ksnetEvMgrClass::kh, and ksnetHotkeysClass::stdin_w.
Referenced by hotkeys_cb(), and modules_destroy().
ksnetHotkeysClass* ksnetHotkeysInit | ( | void * | ke | ) |
Initialize hot keys module.
ke |
References _keys_non_blocking_start(), ksnetHotkeysClass::filter, ksnetHotkeysClass::filter_f, idle_stdin_cb(), ksnetHotkeysClass::idle_stdin_w, kc, ke, ksnetHotkeysClass::ke, malloc(), ksnetHotkeysClass::mt, ksnetHotkeysClass::peer_m, peer_timer_init(), ksnetHotkeysClass::pet, ksnetHotkeysClass::pt, ksnetHotkeysClass::put, stdin_cb(), ksnetHotkeysClass::stdin_w, ksnetHotkeysClass::tr_udp_m, ksnetHotkeysClass::tr_udp_queues_m, tr_udp_timer_init(), ksnetHotkeysClass::wait_y, and Y_NONE.
Referenced by modules_init().
void monitor_timer_cb | ( | EV_P_ ev_timer * | w, |
int | revents | ||
) |
Monitor timer callback.
param loop
w | |
revents |
References ksnCoreClass::ka, monitor_timer_data::kn, ksnetArpGetAll(), and monitor_timer_one_cb().
Referenced by monitor_timer_init().
monitor_timer_data * monitor_timer_init | ( | ksnCoreClass * | kn | ) |
Initialize monitor timer.
kn |
References ksnCoreClass::ke, monitor_timer_data::kn, monitor_timer_data::loop, monitor_timer_cb(), MONITOR_TIMER_INTERVAL, teo_malloc(), and monitor_timer_data::w.
Referenced by hotkeys_cb().
int monitor_timer_one_cb | ( | ksnetArpClass * | ka, |
char * | peer_name, | ||
ksnet_arp_data_ext * | arp, | ||
void * | data | ||
) |
Send network monitor ping to one peer.
ka | |
peer_name | |
arp_data | |
data |
References ksnetArpClass::ke, ksnCommandSendCmdEcho(), ksnetArpAdd(), LIGHTGREEN, LIGHTRED, MONITOR, MONITOR_LEN, and NONE.
Referenced by monitor_timer_cb().
void monitor_timer_stop | ( | monitor_timer_data ** | mt | ) |
void peer_idle_cb | ( | EV_P_ ev_idle * | iw, |
int | revents | ||
) |
Peer show idle callback.
param loop
iw | |
revents |
References ksnCoreClass::ka, peer_timer_data::kn, ksnetArpShow(), peer_timer_data::loop, peer_timer_data::num_lines, STOP, and peer_timer_data::tw.
Referenced by peer_timer_init().
void peer_timer_cb | ( | EV_P_ ev_timer * | tw, |
int | revents | ||
) |
Peer timer callback.
param loop
tw | |
revents |
References peer_timer_data::iw, and peer_timer_data::loop.
Referenced by peer_timer_init().
peer_timer_data * peer_timer_init | ( | ksnCoreClass * | kn | ) |
Initialize peer timer.
kn |
References peer_timer_data::iw, ksnCoreClass::ke, peer_timer_data::kn, peer_timer_data::loop, peer_idle_cb(), peer_timer_cb(), PEER_TIMER_INTERVAL, teo_malloc(), and peer_timer_data::tw.
Referenced by hotkeys_cb(), and ksnetHotkeysInit().
void peer_timer_stop | ( | peer_timer_data ** | pet | ) |
void ping_timer_cb | ( | EV_P_ ev_timer * | w, |
int | revents | ||
) |
Ping timer callback.
param loop
w | |
revents |
References ksnCoreClass::kco, ping_timer_data::kn, ksnCommandSendCmdEcho(), ping_timer_data::peer_name, PING, and PING_LEN.
Referenced by ping_timer_init().
ping_timer_data * ping_timer_init | ( | ksnCoreClass * | kn, |
char * | peer | ||
) |
Initialize ping timer.
kn | Pointer to ksnCoreClass |
peer | Peer name |
References ksnCoreClass::ke, ping_timer_data::kn, ping_timer_data::loop, ping_timer_data::peer_name, ping_timer_data::peer_name_len, ping_timer_cb(), teo_malloc(), and ping_timer_data::w.
Referenced by hotkeys_cb().
void ping_timer_stop | ( | ping_timer_data ** | pt | ) |
void stdin_cb | ( | EV_P_ ev_io * | w, |
int | revents | ||
) |
STDIN (has data) callback.
param loop
w | |
revents |
References data, DEBUG_VV, KSN_BUFFER_SM_SIZE, ksn_puts, malloc(), MODULE, teo_malloc(), and w.
Referenced by ksnetHotkeysInit().
unsigned char teoFilterFlagCheck | ( | void * | ke | ) |
References khv.
Referenced by ksnet_printf().
void teoHotkeySetFilter | ( | ksnetHotkeysClass * | hotkeys, |
char * | filter | ||
) |
References ksnetHotkeysClass::filter, hotkeysResetFilter(), and malloc().
Referenced by hotkeys_cb(), and modules_init().
unsigned char teoLogCheck | ( | void * | ke, |
void * | log | ||
) |
References khv, and log_string_match().
Referenced by ksnet_printf().
void tr_udp_idle_cb | ( | EV_P_ ev_idle * | iw, |
int | revents | ||
) |
TR-UDP show idle callback.
param loop
iw | |
revents |
References tr_udp_timer_data::kc, ksnCoreClass::ke, ksnTRUDPqueuesShow(), ksnTRUDPstatShow(), ksnCoreClass::ku, tr_udp_timer_data::loop, tr_udp_timer_data::num, tr_udp_timer_data::num_lines, STOP, and tr_udp_timer_data::tw.
Referenced by tr_udp_timer_init().
void tr_udp_timer_cb | ( | EV_P_ ev_timer * | tw, |
int | revents | ||
) |
TR-UDP timer callback.
param loop
tw | |
revents |
References tr_udp_timer_data::iw, and tr_udp_timer_data::loop.
Referenced by tr_udp_timer_init().
tr_udp_timer_data * tr_udp_timer_init | ( | ksnCoreClass * | kn | ) |
Initialize tr_udp timer.
kn |
References tr_udp_timer_data::iw, tr_udp_timer_data::kc, ksnCoreClass::ke, tr_udp_timer_data::loop, tr_udp_timer_data::num, teo_malloc(), tr_udp_idle_cb(), tr_udp_timer_cb(), TR_UDP_TIMER_INTERVAL, and tr_udp_timer_data::tw.
Referenced by hotkeys_cb(), and ksnetHotkeysInit().
void tr_udp_timer_stop | ( | tr_udp_timer_data ** | pet | ) |
const char * DONT_SHOW = "don't show" |
Referenced by hotkeys_cb().
const char * MONITOR = "monitor" |
Referenced by monitor_timer_one_cb().
const char * OFF = "off" |
Referenced by hotkeys_cb().
const char * ON = "on" |
Referenced by hotkeys_cb().
const char * PING = "ping" |
Referenced by hotkeys_cb(), and ping_timer_cb().
const char* SHOW = "show" |
Referenced by hotkeys_cb().
const char * START = "start" |
Referenced by hotkeys_cb().
const char * STOP = "stop" |
Referenced by hotkeys_cb(), peer_idle_cb(), and tr_udp_idle_cb().
const char * TRACE = "trace" |
Referenced by hotkeys_cb().
const char * TRIPTIME = "triptime" |
Referenced by check_connected_cb().