Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
net_arp.h
Go to the documentation of this file.
1 
10 #ifndef NETARP_H
11 #define NETARP_H
12 
13 #include <stdio.h>
14 #include <stdint.h>
15 #include <sys/socket.h>
16 
17 #include <pbl.h>
18 
19 #include "teonet_l0_client.h"
20 
24 typedef struct ksnetArpClass {
25  PblMap* map;
26  void *ke;
28 
29 
30 
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef int (*peer_callback)(ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp_data, void *data);
37 
38 // Peers ARP table functions
41 void ksnetArpAdd(ksnetArpClass *ka, char* name, ksnet_arp_data_ext *data);
43 void *ksnetArpSetHostPort(ksnetArpClass *ka, char* name, int port);
44 ksnet_arp_data_ext *ksnetArpGet(ksnetArpClass *ka, char *name);
46 int ksnetArpRemove(ksnetArpClass *ka, char* name);
50 int ksnetArpGetAll_(ksnetArpClass *ka, peer_callback cb, void *data, int flag);
53 ksnet_arp_data *ksnetArpFindByAddr(ksnetArpClass *ka, __CONST_SOCKADDR_ARG addr, char **peer_name);
54 
55 ksnet_arp_data_ar *ksnetArpShowData(ksnetArpClass *ka);
56 ksnet_arp_data_ext_ar *teoArpGetExtendedArpTable(ksnetArpClass *ka);
57 char *ksnetArpShowDataJson(ksnet_arp_data_ar *peers_data, size_t *peers_data_json_len);
58 char *teoArpGetExtendedArpTable_json(ksnet_arp_data_ext_ar *peers_data, size_t *peers_data_json_len);
60 size_t ksnetArpShowDataLength(ksnet_arp_data_ar *peers_data);
61 size_t teoArpGetExtendedArpTableLength(ksnet_arp_data_ext_ar *peers_data);
62 
63 #define ARP_TABLE_DATA_LENGTH(X) _Generic((X), \
64  ksnet_arp_data_ar* : ksnetArpShowDataLength, \
65  ksnet_arp_data_ext_ar* : teoArpGetExtendedArpTableLength \
66  ) (X)
67 
68 char *ksnetArpShowLine(int num, char *name, ksnet_arp_data* data);
69 char *ksnetArpShowHeader(int header_f);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* NETARP_H */
File: net_arp.h Author: Kirill Scherba kirill@scherba.ru
Definition: net_arp.h:24
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
size_t ksnetArpShowDataLength(ksnet_arp_data_ar *peers_data)
Return size of ksnet_arp_data_ar data.
Definition: net_arp.c:502
int(* peer_callback)(ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp_data, void *data)
Definition: net_arp.h:36
void ksnetArpDestroy(ksnetArpClass *ka)
Destroy ARP table.
Definition: net_arp.c:45
char * teoArpGetExtendedArpTable_json(ksnet_arp_data_ext_ar *peers_data, size_t *peers_data_json_len)
Definition: net_arp.c:457
int ksnetArpGetAllH(ksnetArpClass *ka, peer_callback cb, void *data)
Get all known peer with current host.
Definition: net_arp.c:277
ksnetArpClass * ksnetArpInit(void *ke)
File: net_arp.c Author: Kirill Scherba kirill@scherba.ru
Definition: net_arp.c:27
void ksnetArpMetrics(ksnetArpClass *ka)
Send arp table metrics.
Definition: net_arp.c:401
void ksnetArpAdd(ksnetArpClass *ka, char *name, ksnet_arp_data_ext *data)
Add or update record in KSNet Peer ARP table.
Definition: net_arp.c:95
ksnet_arp_data * ksnetArpFindByAddr(ksnetArpClass *ka, __CONST_SOCKADDR_ARG addr, char **peer_name)
Find ARP data by address.
Definition: net_arp.c:317
ksnet_arp_data_ar * ksnetArpShowData(ksnetArpClass *ka)
Return ARP table in digital format.
Definition: net_arp.c:339
void ksnetArpAddHost(ksnetArpClass *ka)
Add (or update) this host to ARP table.
Definition: net_arp.c:108
int ksnetArpSize(ksnetArpClass *ka)
Returns the number of entries in arp map.
Definition: net_arp.c:83
char * ksnetArpShowHeader(int header_f)
Show (return string) with KSNet ARP table header.
Definition: net_arp.c:524
int ksnetArpShow(ksnetArpClass *ka)
Show KSNet ARP table.
Definition: net_arp.c:683
#define ke
struct ksnetArpClass ksnetArpClass
File: net_arp.h Author: Kirill Scherba kirill@scherba.ru
char * ksnetArpShowDataJson(ksnet_arp_data_ar *peers_data, size_t *peers_data_json_len)
Convert peers data to JSON.
Definition: net_arp.c:423
void * ke
Pointer to Event Manager class object.
Definition: net_arp.h:26
ksnet_arp_data_ext * ksnetArpGet(ksnetArpClass *ka, char *name)
Get ARP table data by Peer Name.
Definition: net_arp.c:70
void teoArpGetExtendedArpTable_json_delete(char *obj)
Definition: net_arp.c:493
char * ksnetArpShowLine(int num, char *name, ksnet_arp_data *data)
Show (return string) one record of KSNet ARP table.
Definition: net_arp.c:553
void * ksnetArpSetHostPort(ksnetArpClass *ka, char *name, int port)
Change port at existing arp data associated with key (per name)
Definition: net_arp.c:141
size_t teoArpGetExtendedArpTableLength(ksnet_arp_data_ext_ar *peers_data)
Definition: net_arp.c:506
ksnet_arp_data_ext_ar * teoArpGetExtendedArpTable(ksnetArpClass *ka)
Return extended ARP table.
Definition: net_arp.c:372
int ksnetArpGetAll_(ksnetArpClass *ka, peer_callback cb, void *data, int flag)
Get all known peer without current host.
Definition: net_arp.c:231
int ksnetArpRemove(ksnetArpClass *ka, char *name)
Remove Peer from the ARP table.
Definition: net_arp.c:161
void ksnetArpRemoveAll(ksnetArpClass *ka)
Remove all records instead host from ARP table.
Definition: net_arp.c:202
char * ksnetArpShowStr(ksnetArpClass *ka)
Show (return string) KSNet ARP table.
Definition: net_arp.c:597
PblMap * map
Hash Map to store KSNet ARP table.
Definition: net_arp.h:25
int ksnetArpGetAll(ksnetArpClass *ka, peer_callback cb, void *data)
Get all known peer without current host.
Definition: net_arp.c:266