Browse Source

Merge pull request #318 from switch-iot/hin2n_arp

add main loop callback and move android arp code to this callback
pull/324/head
Luca Deri 4 years ago
committed by GitHub
parent
commit
b17719383f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      include/n2n.h
  2. 12
      src/edge_utils.c

7
include/n2n.h

@ -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;
/* ***************************************************** */ /* ***************************************************** */

12
src/edge_utils.c

@ -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…
Cancel
Save