Teonet library
0.4.7
|
#include <stdio.h>
#include <stdint.h>
#include <sys/socket.h>
#include <pbl.h>
#include "teonet_l0_client.h"
Go to the source code of this file.
Data Structures | |
struct | ksnetArpClass |
File: net_arp.h Author: Kirill Scherba kiril l@sc herba .ruMore... | |
Macros | |
#define | ARP_TABLE_DATA_LENGTH(X) |
Typedefs | |
typedef struct ksnetArpClass | ksnetArpClass |
File: net_arp.h Author: Kirill Scherba kiril l@sc herba .ruMore... | |
typedef int(* | peer_callback )(ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp_data, void *data) |
Functions | |
ksnetArpClass * | ksnetArpInit (void *ke) |
File: net_arp.c Author: Kirill Scherba kiril l@sc herba .ruMore... | |
void | ksnetArpDestroy (ksnetArpClass *ka) |
Destroy ARP table. More... | |
void | ksnetArpAdd (ksnetArpClass *ka, char *name, ksnet_arp_data_ext *data) |
Add or update record in KSNet Peer ARP table. More... | |
void | ksnetArpAddHost (ksnetArpClass *ka) |
Add (or update) this host to ARP table. More... | |
void * | ksnetArpSetHostPort (ksnetArpClass *ka, char *name, int port) |
Change port at existing arp data associated with key (per name) More... | |
ksnet_arp_data_ext * | ksnetArpGet (ksnetArpClass *ka, char *name) |
Get ARP table data by Peer Name. More... | |
int | ksnetArpSize (ksnetArpClass *ka) |
Returns the number of entries in arp map. More... | |
int | ksnetArpRemove (ksnetArpClass *ka, char *name) |
Remove Peer from the ARP table. More... | |
void | ksnetArpRemoveAll (ksnetArpClass *ka) |
Remove all records instead host from ARP table. More... | |
int | ksnetArpShow (ksnetArpClass *ka) |
Show KSNet ARP table. More... | |
char * | ksnetArpShowStr (ksnetArpClass *ka) |
Show (return string) KSNet ARP table. More... | |
int | ksnetArpGetAll_ (ksnetArpClass *ka, peer_callback cb, void *data, int flag) |
Get all known peer without current host. More... | |
int | ksnetArpGetAll (ksnetArpClass *ka, peer_callback cb, void *data) |
Get all known peer without current host. More... | |
int | ksnetArpGetAllH (ksnetArpClass *ka, peer_callback cb, void *data) |
Get all known peer with current host. More... | |
ksnet_arp_data * | ksnetArpFindByAddr (ksnetArpClass *ka, __CONST_SOCKADDR_ARG addr, char **peer_name) |
Find ARP data by address. More... | |
ksnet_arp_data_ar * | ksnetArpShowData (ksnetArpClass *ka) |
Return ARP table in digital format. More... | |
ksnet_arp_data_ext_ar * | teoArpGetExtendedArpTable (ksnetArpClass *ka) |
Return extended ARP table. More... | |
char * | ksnetArpShowDataJson (ksnet_arp_data_ar *peers_data, size_t *peers_data_json_len) |
Convert peers data to JSON. More... | |
char * | teoArpGetExtendedArpTable_json (ksnet_arp_data_ext_ar *peers_data, size_t *peers_data_json_len) |
void | teoArpGetExtendedArpTable_json_delete (char *obj) |
size_t | ksnetArpShowDataLength (ksnet_arp_data_ar *peers_data) |
Return size of ksnet_arp_data_ar data. More... | |
size_t | teoArpGetExtendedArpTableLength (ksnet_arp_data_ext_ar *peers_data) |
char * | ksnetArpShowLine (int num, char *name, ksnet_arp_data *data) |
Show (return string) one record of KSNet ARP table. More... | |
char * | ksnetArpShowHeader (int header_f) |
Show (return string) with KSNet ARP table header. More... | |
void | ksnetArpMetrics (ksnetArpClass *ka) |
Send arp table metrics. More... | |
#define ARP_TABLE_DATA_LENGTH | ( | X | ) |
typedef struct ksnetArpClass ksnetArpClass |
typedef int(* peer_callback)(ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp_data, void *data) |
void ksnetArpAdd | ( | ksnetArpClass * | ka, |
char * | name, | ||
ksnet_arp_data_ext * | data | ||
) |
Add or update record in KSNet Peer ARP table.
ka | |
name | |
data |
References ksnetArpClass::map.
Referenced by ksnCoreCheckNewPeer(), ksnetArpAddHost(), monitor_timer_one_cb(), and peer_type_cb().
void ksnetArpAddHost | ( | ksnetArpClass * | ka | ) |
Add (or update) this host to ARP table.
ka |
References ksnetEvMgrClass::ev_loop, free(), teonet_cfg::host_name, ksnetEvMgrClass::kc, ksnetArpClass::ke, ke, ksnetArpAdd(), localhost, ksnCoreClass::port, ksnetEvMgrClass::teo_cfg, teoGetFullAppTypeFromHostInfo(), and teoGetHostInfo().
Referenced by ksnetArpInit(), and ksnetArpRemoveAll().
void ksnetArpDestroy | ( | ksnetArpClass * | ka | ) |
ksnet_arp_data* ksnetArpFindByAddr | ( | ksnetArpClass * | ka, |
__CONST_SOCKADDR_ARG | addr, | ||
char ** | peer_name | ||
) |
Find ARP data by address.
ka | Pointer to ksnetArpClass |
addr | Address |
peer_name | [out] Peer name (may be null) |
References find_arp_by_addr_cb(), and ksnetArpGetAllH().
Referenced by remove_peer_addr().
ksnet_arp_data_ext* ksnetArpGet | ( | ksnetArpClass * | ka, |
char * | name | ||
) |
Get ARP table data by Peer Name.
ka | Pointer to ksnetArpClass |
name | Peer name |
References ksnetArpClass::map.
Referenced by event_cb(), ksnCoreCheckNewPeer(), ksnCoreSendCmdto(), and peer_type_cb().
|
inline |
Get all known peer without current host.
Send it too fnd_peer_cb callback
ka | |
peer_callback | int peer_callback(ksnetArpClass *ka, char *peer_name, ksnet_arp_data *arp_data, void *data) |
data |
References ksnetArpGetAll_().
Referenced by idle_activity_cb(), ksnCoreCheckNewPeer(), ksnCoreDestroy(), ksnCoreSendCmdto(), monitor_timer_cb(), send_cmd_disconnect_peer_cb(), and teoBroadcastSend().
int ksnetArpGetAll_ | ( | ksnetArpClass * | ka, |
peer_callback | cb, | ||
void * | data, | ||
int | flag | ||
) |
Get all known peer without current host.
Send it too fnd_peer_cb callback
ka | |
peer_callback | int peer_callback(ksnetArpClass *ka, char *peer_name, ksnet_arp_data *arp_data, void *data) |
data | |
flag | Include this host if true |
References ksnetArpClass::map.
Referenced by ksnetArpGetAll(), and ksnetArpGetAllH().
|
inline |
Get all known peer with current host.
Send it too fnd_peer_cb callback
ka | |
peer_callback | cb |
data |
References ksnetArpGetAll_().
Referenced by ksnetArpFindByAddr().
ksnetArpClass* ksnetArpInit | ( | void * | ke | ) |
File: net_arp.c Author: Kirill Scherba kiril l@sc herba .ru
Created on April 12, 2015, 7:19 PM
KSNet ARP Table manager Initialize ARP table
References ksnetArpClass::ke, ke, ksnetArpAddHost(), ksnetArpClass::map, and teo_malloc().
Referenced by ksnCoreInit().
void ksnetArpMetrics | ( | ksnetArpClass * | ka | ) |
Send arp table metrics.
References free(), kev, ksnetArpShowData(), and teoMetricGaugef().
Referenced by metric_teonet_count().
int ksnetArpRemove | ( | ksnetArpClass * | ka, |
char * | name | ||
) |
Remove Peer from the ARP table.
ka | Pointer to ksnetArpClass |
name | Peer name to remove |
References free(), ksnetArpClass::ke, ksnStreamClosePeer(), and ksnetArpClass::map.
Referenced by cmd_disconnected_cb().
void ksnetArpRemoveAll | ( | ksnetArpClass * | ka | ) |
Remove all records instead host from ARP table.
Free ARP Hash map, create new and add this host to created ARP Hash map
ka |
References free(), ksnetEvMgrClass::kc, ksnetArpClass::ke, ke, ksnetArpAddHost(), ksnCoreClass::ku, ksnetArpClass::map, teonet_cfg::r_host_name, and ksnetEvMgrClass::teo_cfg.
Referenced by ksnTCPProxyClientStop().
void* ksnetArpSetHostPort | ( | ksnetArpClass * | ka, |
char * | name, | ||
int | port | ||
) |
Change port at existing arp data associated with key (per name)
ka | |
name | |
port |
References ksnetArpClass::map.
Referenced by ksnCoreInit().
int ksnetArpShow | ( | ksnetArpClass * | ka | ) |
Show KSNet ARP table.
ka |
References _ANSI_CLS, calculate_lines(), teonet_cfg::color_output_disable_f, DISPLAY_M, free(), ksnetArpClass::ke, ksnet_printf(), and ksnetArpShowStr().
Referenced by hotkeys_cb(), and peer_idle_cb().
ksnet_arp_data_ar* ksnetArpShowData | ( | ksnetArpClass * | ka | ) |
Return ARP table in digital format.
ka | Pointer to the ksnetArpClass |
References data, ksnetArpClass::ke, ksnetEvMgrGetTime(), ksnetArpClass::map, and teo_malloc().
Referenced by ksnetArpMetrics().
char* ksnetArpShowDataJson | ( | ksnet_arp_data_ar * | peers_data, |
size_t * | peers_data_json_len | ||
) |
Convert peers data to JSON.
peers_data | Pointer to ksnet_arp_data_ar |
peers_data_json_len | [out] Result json string length |
References malloc().
|
inline |
Return size of ksnet_arp_data_ar data.
peers_data |
char* ksnetArpShowHeader | ( | int | header_f | ) |
Show (return string) with KSNet ARP table header.
header_f | Header flag. If 1 - return Header, if 0 - return Footer |
References ksnet_formatMessage(), and ksnet_sformatMessage().
Referenced by tcp_read_cb().
char* ksnetArpShowLine | ( | int | num, |
char * | name, | ||
ksnet_arp_data * | data | ||
) |
Show (return string) one record of KSNet ARP table.
num | Record number |
name | Peer name |
data | Pointer to ksnet_arp_data structure |
References free(), ksnet_formatMessage(), LIGHTGREEN, and NONE.
Referenced by tcp_read_cb().
char* ksnetArpShowStr | ( | ksnetArpClass * | ka | ) |
Show (return string) KSNet ARP table.
ka |
References data, free(), ksnetArpClass::ke, ksnet_formatMessage(), ksnet_sformatMessage(), LIGHTGREEN, ksnetArpClass::map, NONE, and null_str.
Referenced by ksnetArpShow().
int ksnetArpSize | ( | ksnetArpClass * | ka | ) |
Returns the number of entries in arp map.
ka | Pointer to ksnetArpClass |
References ksnetArpClass::map.
ksnet_arp_data_ext_ar* teoArpGetExtendedArpTable | ( | ksnetArpClass * | ka | ) |
Return extended ARP table.
ka | Pointer to the ksnetArpClass |
References data, ksnetArpClass::map, and teo_malloc().
char* teoArpGetExtendedArpTable_json | ( | ksnet_arp_data_ext_ar * | peers_data, |
size_t * | peers_data_json_len | ||
) |
References malloc().
void teoArpGetExtendedArpTable_json_delete | ( | char * | obj | ) |
References free().
|
inline |