From 2c6147d4d47e68301e13545fc0a95bd3a16f0e30 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 23 Mar 2015 05:02:36 +0100 Subject: Add multitap mode This new mode of operation uses one TAP interface per peer. --- src/config.y | 2 ++ src/fastd.h | 1 + src/handshake.c | 1 + src/iface.c | 1 + src/lex.c | 1 + src/options.c | 2 ++ src/options.def.h | 2 +- src/types.h | 1 + 8 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config.y b/src/config.y index 12beb4b..36b7368 100644 --- a/src/config.y +++ b/src/config.y @@ -103,6 +103,7 @@ %token TOK_METHOD %token TOK_MODE %token TOK_MTU +%token TOK_MULTITAP %token TOK_NO %token TOK_ON %token TOK_PACKET @@ -373,6 +374,7 @@ pmtu: autobool ; mode: TOK_TAP { conf.mode = MODE_TAP; } + | TOK_MULTITAP { conf.mode = MODE_MULTITAP; } | TOK_TUN { conf.mode = MODE_TUN; } ; diff --git a/src/fastd.h b/src/fastd.h index 1abe48f..212d439 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -417,6 +417,7 @@ static inline void fastd_setnonblock(int fd) { static inline size_t fastd_max_payload(void) { switch (conf.mode) { case MODE_TAP: + case MODE_MULTITAP: return conf.mtu+ETH_HLEN; case MODE_TUN: return conf.mtu; diff --git a/src/handshake.c b/src/handshake.c index 4aa198d..726c117 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -108,6 +108,7 @@ static inline uint32_t as_uint(const fastd_handshake_record_t *record) { static inline uint8_t get_mode_id(void) { switch (conf.mode) { case MODE_TAP: + case MODE_MULTITAP: return 0; case MODE_TUN: diff --git a/src/iface.c b/src/iface.c index 09eb509..3361f72 100644 --- a/src/iface.c +++ b/src/iface.c @@ -75,6 +75,7 @@ typedef enum fastd_iface_type { static inline fastd_iface_type_t get_iface_type(void) { switch (conf.mode) { case MODE_TAP: + case MODE_MULTITAP: return IFACE_TYPE_TAP; case MODE_TUN: diff --git a/src/lex.c b/src/lex.c index 1fe927c..f8e5c22 100644 --- a/src/lex.c +++ b/src/lex.c @@ -100,6 +100,7 @@ static const keyword_t keywords[] = { { "method", TOK_METHOD }, { "mode", TOK_MODE }, { "mtu", TOK_MTU }, + { "multitap", TOK_MULTITAP }, { "no", TOK_NO }, { "on", TOK_ON }, { "packet", TOK_PACKET }, diff --git a/src/options.c b/src/options.c index 7680819..44b097b 100644 --- a/src/options.c +++ b/src/options.c @@ -218,6 +218,8 @@ static void option_hide_mac_addresses(void) { static void option_mode(const char *arg) { if (!strcmp(arg, "tap")) conf.mode = MODE_TAP; + else if (!strcmp(arg, "multitap")) + conf.mode = MODE_MULTITAP; else if (!strcmp(arg, "tun")) conf.mode = MODE_TUN; else diff --git a/src/options.def.h b/src/options.def.h index 6d0efca..a170f3c 100644 --- a/src/options.def.h +++ b/src/options.def.h @@ -28,7 +28,7 @@ SEPARATOR; #endif #ifdef WITH_CMDLINE_OPERATION -OPTION_ARG(option_mode, "--mode" OR "-m", "tap|tun", "Sets the mode of the interface"); +OPTION_ARG(option_mode, "--mode" OR "-m", "tap|multitap|tun", "Sets the mode of operation"); OPTION_ARG(option_interface, "--interface" OR "-i", "", "Sets the name of the TUN/TAP interface to use"); OPTION_ARG(option_mtu, "--mtu" OR "-M", "", "Sets the MTU; must be at least 576"); OPTION_ARG(option_bind, "--bind" OR "-b", "
[:]", "Sets the bind address"); diff --git a/src/types.h b/src/types.h index 5a4bd06..488f8f9 100644 --- a/src/types.h +++ b/src/types.h @@ -65,6 +65,7 @@ typedef enum fastd_packet_type { /** The supported modes of operation */ typedef enum fastd_mode { MODE_TAP, /**< TAP (Layer 2/Ethernet mode) */ + MODE_MULTITAP, /**< TAP (Layer 2/Ethernet mode, one interface per peer) */ MODE_TUN, /**< TUN (Layer 3/IP mode) */ } fastd_mode_t; -- cgit v1.2.3