diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 7 | ||||
-rw-r--r-- | src/fastd.c | 2 | ||||
-rw-r--r-- | src/fastd.h | 9 | ||||
-rw-r--r-- | src/iface.c | 2 |
4 files changed, 18 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c index deb3208..1ac9e81 100644 --- a/src/config.c +++ b/src/config.c @@ -545,6 +545,13 @@ void fastd_configure(int argc, char *const argv[]) { /** Performs some basic checks on the configuration */ static void config_check_base(void) { + if (fastd_use_android_integration()) { + if (conf.mode != MODE_TUN) + exit_error("In Android integration mode only TUN interfaces are supported"); + + if (!fastd_config_single_iface()) + exit_error("In Android integration mode exactly one peer must be configured"); + } } /** Performs more checks on the configuration */ diff --git a/src/fastd.c b/src/fastd.c index 43e0c9c..fd6f19e 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -500,7 +500,7 @@ static inline void init(int argc, char *argv[]) { fastd_on_pre_up(); - if (conf.mode == MODE_TAP) { + if (conf.mode == MODE_TAP || fastd_use_android_integration()) { ctx.iface = fastd_iface_open(conf.ifname, NULL); if (!ctx.iface) exit(1); /* An error message has already been printed by fastd_iface_open() */ diff --git a/src/fastd.h b/src/fastd.h index b320c74..f05fe47 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -568,3 +568,12 @@ static inline void fastd_on_down(fastd_iface_t *iface) { static inline void fastd_on_post_down(void) { fastd_shell_command_exec(&conf.on_post_down, NULL); } + +/** Returns true if android integration is enabled */ +static inline bool fastd_use_android_integration(void) { +#ifdef __ANDROID__ + return conf.android_integration; +#else + return false; +#endif +} diff --git a/src/iface.c b/src/iface.c index 3361f72..d7caa30 100644 --- a/src/iface.c +++ b/src/iface.c @@ -162,7 +162,7 @@ static void open_iface_linux(fastd_iface_t *iface, const char *ifname, const cha static void open_iface(fastd_iface_t *iface, const char *ifname) { if (conf.android_integration) { if (get_iface_type() != IFACE_TYPE_TUN) - exit_error("Non root Android supports only TUN mode"); + exit_bug("Non-TUN iface type with Android integration"); pr_debug("using android TUN fd"); iface->fd = FASTD_POLL_FD(POLL_TYPE_IFACE, fastd_android_receive_tunfd()); |