mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
add main loop callback and move android arp code to this callback
This commit is contained in:
parent
0ab9f3229e
commit
72701a5e83
|
@ -114,10 +114,6 @@ typedef struct ether_hdr ether_hdr_t;
|
||||||
#include <zstd.h>
|
#include <zstd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __ANDROID_NDK__
|
|
||||||
#define ARP_PERIOD_INTERVAL (10) /* sec */
|
|
||||||
#endif /* #ifdef __ANDROID_NDK__ */
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <netinet/udp.h>
|
#include <netinet/udp.h>
|
||||||
|
@ -239,6 +235,9 @@ typedef struct n2n_edge_callbacks {
|
||||||
|
|
||||||
/* Called whenever the IP address of the TAP interface changes. */
|
/* Called whenever the IP address of the TAP interface changes. */
|
||||||
void (*ip_address_changed)(n2n_edge_t *eee, uint32_t old_ip, uint32_t new_ip);
|
void (*ip_address_changed)(n2n_edge_t *eee, uint32_t old_ip, uint32_t new_ip);
|
||||||
|
|
||||||
|
/* Called periodically in the main loop. */
|
||||||
|
void (*main_loop_period)(n2n_edge_t *eee, time_t now);
|
||||||
} n2n_edge_callbacks_t;
|
} n2n_edge_callbacks_t;
|
||||||
|
|
||||||
/* ***************************************************** */
|
/* ***************************************************** */
|
||||||
|
|
|
@ -1825,9 +1825,6 @@ int run_edge_loop(n2n_edge_t * eee, int *keep_running) {
|
||||||
time_t lastTransop=0;
|
time_t lastTransop=0;
|
||||||
time_t last_purge_known = 0;
|
time_t last_purge_known = 0;
|
||||||
time_t last_purge_pending = 0;
|
time_t last_purge_pending = 0;
|
||||||
#ifdef __ANDROID_NDK__
|
|
||||||
time_t lastArpPeriod=0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
struct tunread_arg arg;
|
struct tunread_arg arg;
|
||||||
|
@ -1941,12 +1938,9 @@ int run_edge_loop(n2n_edge_t * eee, int *keep_running) {
|
||||||
eee->cb.ip_address_changed(eee, old_ip, eee->device.ip_addr);
|
eee->cb.ip_address_changed(eee, old_ip, eee->device.ip_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID_NDK__
|
if (eee->cb.main_loop_period)
|
||||||
if((nowTime - lastArpPeriod) > ARP_PERIOD_INTERVAL) {
|
eee->cb.main_loop_period(eee, nowTime);
|
||||||
uip_arp_timer();
|
|
||||||
lastArpPeriod = nowTime;
|
|
||||||
}
|
|
||||||
#endif /* #ifdef __ANDROID_NDK__ */
|
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
Loading…
Reference in New Issue
Block a user