Teonet library
0.4.7
|
#include <stdlib.h>
#include <string.h>
#include "net_multi.h"
#include "utils/rlutil.h"
#include "utils/teo_memory.h"
Macros | |
#define | add_line() |
Functions | |
ksnMultiClass * | ksnMultiInit (ksnMultiData *md, void *user_data) |
Initialize ksnMultiClass object. More... | |
void | teoMultiRun (ksnMultiClass *km) |
Start teonet event loop (for all functions added with ksnMultiInit) More... | |
void | teoMultiAddNet (ksnMultiClass *km, ksn_event_cb_type e_cb, const char *host, int port, const char *network, void *user_data) |
Add new network. More... | |
void | teoMultiRemoveNet (ksnMultiClass *km, const char *network) |
Remove network. More... | |
void | ksnMultiDestroy (ksnMultiClass *km) |
Destroy ksnMultiClass object and running networks. More... | |
ksnetEvMgrClass * | teoMultiGetByNumber (ksnMultiClass *km, int number) |
Get network by number. More... | |
ksnetEvMgrClass * | teoMultiGetByNetwork (ksnMultiClass *km, char *network_name) |
Get network by network name. More... | |
bool | teoMultiIsNetworkExist (ksnMultiClass *km, int number) |
Check if network with input number is exist. More... | |
void | ksnMultiSetNumNets (ksnMultiClass *km, int num) |
Set number of networks to all modules list networks. More... | |
char * | ksnMultiShowListStr (ksnMultiClass *km) |
Show list of networks. More... | |
ksnet_arp_data * | teoMultiSendCmdToNet (ksnMultiClass *km, char *peer, char *network, uint8_t cmd, void *data, size_t data_len) |
Send command by name (or type) and by network. More... | |
ksnet_arp_data * | ksnMultiSendCmdTo (ksnMultiClass *km, char *to, uint8_t cmd, void *data, size_t data_len) |
: It will be new function for broadcast sending Send command by name to peer More... | |
#define add_line | ( | ) |
Referenced by ksnMultiShowListStr().
void ksnMultiDestroy | ( | ksnMultiClass * | km | ) |
Destroy ksnMultiClass object and running networks.
km | Pointer to ksnMultiClass |
References free(), ksnetEvMgrFree(), ksnetEvMgrRestart(), ksnetEvMgrStop(), ksnMultiClass::last_net_idx, ksnMultiClass::list, and teoMultiGetByNumber().
Referenced by main(), and sigusr2_cb().
ksnMultiClass* ksnMultiInit | ( | ksnMultiData * | md, |
void * | user_data | ||
) |
Initialize ksnMultiClass object.
md | Pointer to initialize input data |
user_data | Pointer to user data added to every teonet network |
References ksnMultiData::argc, ksnMultiData::argv, ksnMultiData::event_cb, teonet_cfg::host_name, ke, ksnetEvMgrClass::km, KSN_BUFFER_SM_SIZE, KSN_MAX_HOST_NAME, ksnetEvMgrInitPort(), ksnetEvMgrRun(), ksnMultiClass::last_net_idx, ksnMultiClass::list, ksnMultiData::names, ksnMultiClass::net_count, ksnetEvMgrClass::net_count, ksnetEvMgrClass::net_idx, teonet_cfg::network, ksnMultiData::networks, ksnMultiData::num, teonet_cfg::port, ksnMultiData::ports, read_config(), READ_CONFIGURATION, READ_OPTIONS, ksnetEvMgrClass::teo_cfg, and teo_malloc().
Referenced by main().
ksnet_arp_data* ksnMultiSendCmdTo | ( | ksnMultiClass * | km, |
char * | to, | ||
uint8_t | cmd, | ||
void * | data, | ||
size_t | data_len | ||
) |
: It will be new function for broadcast sending Send command by name to peer
km | Pointer to ksnMultiClass |
to | Recipient peer name |
cmd | Command |
data | Command data |
data_len | Data length |
Referenced by ksnCoreSendCmdto().
void ksnMultiSetNumNets | ( | ksnMultiClass * | km, |
int | num | ||
) |
Set number of networks to all modules list networks.
km | Pointer to ksnMultiClass |
num | Number of networks |
References ke, ksnMultiClass::list, and ksnMultiClass::net_count.
char* ksnMultiShowListStr | ( | ksnMultiClass * | km | ) |
Show list of networks.
km | Pointer to ksnMultiClass |
References add_line, ke, ksnet_formatMessage(), ksnet_sformatMessage(), LIGHTCYAN, LIGHTGREEN, ksnMultiClass::list, and NONE.
Referenced by hotkeys_cb().
void teoMultiAddNet | ( | ksnMultiClass * | km, |
ksn_event_cb_type | e_cb, | ||
const char * | host, | ||
int | port, | ||
const char * | network, | ||
void * | user_data | ||
) |
Add new network.
km | Pointer to ksnMultiClass |
event_cb | Teonet event callback |
host | Host name |
port | Port number |
network | Network name |
user_data | Pointer to user data added to this teonet network |
References ksnetEvMgrClass::argc, ksnetEvMgrClass::argv, teonet_cfg::host_name, ksnetEvMgrClass::km, KSN_BUFFER_SM_SIZE, KSN_MAX_HOST_NAME, ksnetEvMgrInitPort(), ksnetEvMgrRun(), ksnMultiClass::last_net_idx, ksnMultiClass::list, ksnMultiClass::net_count, ksnetEvMgrClass::net_count, ksnetEvMgrClass::net_idx, teonet_cfg::network, teonet_cfg::port, read_config(), READ_CONFIGURATION, READ_OPTIONS, ksnetEvMgrClass::teo_cfg, and teoMultiGetByNumber().
Referenced by event_cb().
ksnetEvMgrClass* teoMultiGetByNetwork | ( | ksnMultiClass * | km, |
char * | network_name | ||
) |
Get network by network name.
km | Pointer to ksnMultiClass |
network_name | Network name |
References ke, and ksnMultiClass::list.
ksnetEvMgrClass* teoMultiGetByNumber | ( | ksnMultiClass * | km, |
int | number | ||
) |
Get network by number.
km | Pointer to ksnMultiClass |
num | Number of network |
References ke, and ksnMultiClass::list.
Referenced by ksnMultiDestroy(), teoMultiAddNet(), and teoMultiRun().
bool teoMultiIsNetworkExist | ( | ksnMultiClass * | km, |
int | number | ||
) |
Check if network with input number is exist.
km | Pointer to ksnMultiClass |
num | Number of network |
References ke, and ksnMultiClass::list.
Referenced by hotkeys_cb().
void teoMultiRemoveNet | ( | ksnMultiClass * | km, |
const char * | network | ||
) |
Remove network.
km | Pointer to ksnMultiClass |
network | Network name |
References free(), ke, ksnetEvMgrFree(), ksnetEvMgrStop(), ksnMultiClass::list, and ksnMultiClass::net_count.
void teoMultiRun | ( | ksnMultiClass * | km | ) |
Start teonet event loop (for all functions added with ksnMultiInit)
km | Pointer to ksnMultiClass |
References ksnetEvMgrClass::ev_loop, ksnMultiClass::last_net_idx, and teoMultiGetByNumber().
Referenced by main().
ksnet_arp_data* teoMultiSendCmdToNet | ( | ksnMultiClass * | km, |
char * | peer, | ||
char * | network, | ||
uint8_t | cmd, | ||
void * | data, | ||
size_t | data_len | ||
) |
Send command by name (or type) and by network.
km | Pointer to ksnMultiClass |
peer | Peer name |
network | Network name |
cmd | Command ID |
data | Pointer to data |
data_len | Data length |
References ke, ksnCoreSendCmdto(), and ksnMultiClass::list.