diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/fastd.c | 4 | ||||
-rw-r--r-- | src/fastd.h | 8 | ||||
-rw-r--r-- | src/iface.c (renamed from src/tuntap.c) | 28 | ||||
-rw-r--r-- | src/poll.c | 2 | ||||
-rw-r--r-- | src/receive.c | 2 |
6 files changed, 23 insertions, 23 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e7dd5d1..dfcaf62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,7 @@ add_executable(fastd handshake.c hkdf_sha256.c fastd.c + iface.c lex.c log.c options.c @@ -39,7 +40,6 @@ add_executable(fastd shell.c socket.c status.c - tuntap.c vector.c verify.c ${BISON_fastd_config_parse_OUTPUTS} diff --git a/src/fastd.c b/src/fastd.c index 228d65e..69efca5 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -526,7 +526,7 @@ static inline void init(int argc, char *argv[]) { on_pre_up(); - ctx.iface = fastd_tuntap_open(NULL); + ctx.iface = fastd_iface_open(NULL); /* change groups before trying to write the PID file as they can be relevant for file access */ set_groups(); @@ -647,7 +647,7 @@ static inline void cleanup(void) { delete_peers(); on_down(ctx.iface); - fastd_tuntap_close(ctx.iface); + fastd_iface_close(ctx.iface); fastd_status_close(); close_sockets(); diff --git a/src/fastd.h b/src/fastd.h index 5e81890..8704cc1 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -368,10 +368,10 @@ bool fastd_android_protect_socket(int fd); void fastd_resolve_peer(fastd_peer_t *peer, fastd_remote_t *remote); -fastd_iface_t * fastd_tuntap_open(fastd_peer_t *peer); -void fastd_tuntap_handle(fastd_iface_t *iface); -void fastd_tuntap_write(fastd_iface_t *iface, fastd_buffer_t buffer); -void fastd_tuntap_close(fastd_iface_t *iface); +fastd_iface_t * fastd_iface_open(fastd_peer_t *peer); +void fastd_iface_handle(fastd_iface_t *iface); +void fastd_iface_write(fastd_iface_t *iface, fastd_buffer_t buffer); +void fastd_iface_close(fastd_iface_t *iface); void fastd_cap_init(void); void fastd_cap_drop(void); diff --git a/src/tuntap.c b/src/iface.c index a817090..b448cbd 100644 --- a/src/tuntap.c +++ b/src/iface.c @@ -66,7 +66,7 @@ static const bool multiaf_tun = true; #ifdef __linux__ /** Opens the TUN/TAP device helper shared by Android and Linux targets */ -static void tuntap_open_linux(fastd_iface_t *iface, const char *dev_name) { +static void open_iface_linux(fastd_iface_t *iface, const char *dev_name) { struct ifreq ifr = {}; iface->fd = FASTD_POLL_FD(POLL_TYPE_IFACE, open(dev_name, O_RDWR|O_NONBLOCK)); @@ -118,7 +118,7 @@ static void tuntap_open_linux(fastd_iface_t *iface, const char *dev_name) { #if defined(__ANDROID__) /** Opens the TUN/TAP device */ -static void tuntap_open(fastd_iface_t *iface) { +static void open_iface(fastd_iface_t *iface) { if (conf.android_integration) { if (conf.mode != MODE_TUN) exit_error("Non root Android supports only TUN mode"); @@ -129,15 +129,15 @@ static void tuntap_open(fastd_iface_t *iface) { fastd_android_send_pid(); } else { /* this requires root on Android */ - tuntap_open_linux(iface, "/dev/tun"); + open_iface_linux(iface, "/dev/tun"); } } #elif defined(__linux__) /** Opens the TUN/TAP device */ -static void tuntap_open(fastd_iface_t *iface) { - tuntap_open_linux(iface, "/dev/net/tun"); +static void open_iface(fastd_iface_t *iface) { + open_iface_linux(iface, "/dev/net/tun"); } #elif defined(__FreeBSD__) || defined(__OpenBSD__) @@ -194,7 +194,7 @@ static void setup_tap(fastd_iface_t *iface) { } /** Opens the TUN/TAP device */ -static void tuntap_open(fastd_iface_t *iface) { +static void open_iface(fastd_iface_t *iface) { char ifname[5+IFNAMSIZ] = "/dev/"; const char *type; @@ -280,7 +280,7 @@ static void setup_tap(fastd_iface_t *iface) { } /** Opens the TUN/TAP device */ -static void tuntap_open(fastd_iface_t *iface) { +static void open_iface(fastd_iface_t *iface) { char ifname[5+IFNAMSIZ] = "/dev/"; if (!conf.ifname) exit_error("config error: no interface name given."); @@ -314,7 +314,7 @@ static void tuntap_open(fastd_iface_t *iface) { #elif __APPLE__ /** Opens the TUN/TAP device */ -static void tuntap_open(fastd_iface_t *iface) { +static void open_iface(fastd_iface_t *iface) { const char *devtype; switch (conf.mode) { case MODE_TAP: @@ -365,7 +365,7 @@ static void tuntap_open(fastd_iface_t *iface) { /** Reads a packet from the TUN/TAP device */ -void fastd_tuntap_handle(fastd_iface_t *iface) { +void fastd_iface_handle(fastd_iface_t *iface) { size_t max_len = fastd_max_payload(); fastd_buffer_t buffer; @@ -387,7 +387,7 @@ void fastd_tuntap_handle(fastd_iface_t *iface) { } /** Writes a packet to the TUN/TAP device */ -void fastd_tuntap_write(fastd_iface_t *iface, fastd_buffer_t buffer) { +void fastd_iface_write(fastd_iface_t *iface, fastd_buffer_t buffer) { if (multiaf_tun && conf.mode == MODE_TUN) { uint8_t version = *((uint8_t *)buffer.data) >> 4; uint32_t af; @@ -402,7 +402,7 @@ void fastd_tuntap_write(fastd_iface_t *iface, fastd_buffer_t buffer) { break; default: - pr_warn("fastd_tuntap_write: unknown IP version %u", version); + pr_warn("fastd_iface_write: unknown IP version %u", version); return; } @@ -414,12 +414,12 @@ void fastd_tuntap_write(fastd_iface_t *iface, fastd_buffer_t buffer) { pr_debug2_errno("write"); } -fastd_iface_t * fastd_tuntap_open(fastd_peer_t *peer) { +fastd_iface_t * fastd_iface_open(fastd_peer_t *peer) { fastd_iface_t *iface = fastd_new(fastd_iface_t); iface->peer = peer; pr_debug("initializing tun/tap device..."); - tuntap_open(iface); + open_iface(iface); if (iface->name) pr_debug("tun/tap device `%s' initialized.", iface->name); @@ -432,7 +432,7 @@ fastd_iface_t * fastd_tuntap_open(fastd_peer_t *peer) { } /** Closes the TUN/TAP device */ -void fastd_tuntap_close(fastd_iface_t *iface) { +void fastd_iface_close(fastd_iface_t *iface) { if (!fastd_poll_fd_close(&iface->fd)) pr_warn_errno("closing tun/tap: close"); @@ -86,7 +86,7 @@ static inline void handle_fd(fastd_poll_fd_t *fd, bool input, bool error) { fastd_iface_t *iface = container_of(fd, fastd_iface_t, fd); if (input) - fastd_tuntap_handle(iface); + fastd_iface_handle(iface); } break; diff --git a/src/receive.c b/src/receive.c index a19039e..2f0c87c 100644 --- a/src/receive.c +++ b/src/receive.c @@ -306,7 +306,7 @@ void fastd_handle_receive(fastd_peer_t *peer, fastd_buffer_t buffer, bool reorde if (reordered) fastd_stats_add(peer, STAT_RX_REORDERED, buffer.len); - fastd_tuntap_write(peer->iface ?: ctx.iface, buffer); + fastd_iface_write(peer->iface ?: ctx.iface, buffer); if (conf.mode == MODE_TAP && conf.forward) { fastd_send_data(buffer, peer); |