diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-03-23 05:02:36 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-03-23 05:02:36 +0100 |
commit | 2c6147d4d47e68301e13545fc0a95bd3a16f0e30 (patch) | |
tree | 6f0d98631ac7c8034b59a60eb92deca53a4547a7 | |
parent | 3371cf38ac3fad7c2d446400a772b25992ee8c82 (diff) | |
download | fastd-2c6147d4d47e68301e13545fc0a95bd3a16f0e30.tar fastd-2c6147d4d47e68301e13545fc0a95bd3a16f0e30.zip |
Add multitap mode
This new mode of operation uses one TAP interface per peer.
-rw-r--r-- | src/config.y | 2 | ||||
-rw-r--r-- | src/fastd.h | 1 | ||||
-rw-r--r-- | src/handshake.c | 1 | ||||
-rw-r--r-- | src/iface.c | 1 | ||||
-rw-r--r-- | src/lex.c | 1 | ||||
-rw-r--r-- | src/options.c | 2 | ||||
-rw-r--r-- | src/options.def.h | 2 | ||||
-rw-r--r-- | src/types.h | 1 |
8 files changed, 10 insertions, 1 deletions
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: @@ -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", "<name>", "Sets the name of the TUN/TAP interface to use"); OPTION_ARG(option_mtu, "--mtu" OR "-M", "<mtu>", "Sets the MTU; must be at least 576"); OPTION_ARG(option_bind, "--bind" OR "-b", "<address>[:<port>]", "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; |