From 98d651c47de0b4906abc19d97ce7ea6d5978f0d9 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Thu, 29 Oct 2009 00:31:16 +0000 Subject: [PATCH] Adding tun/tap test module, for users to refer to. --- tun_test.c | 26 ++++++++++++++++++++++++++ tunalloc.h | 6 ++++++ 2 files changed, 32 insertions(+) create mode 100644 tun_test.c create mode 100644 tunalloc.h diff --git a/tun_test.c b/tun_test.c new file mode 100644 index 0000000..947019f --- /dev/null +++ b/tun_test.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include + +#include "tunalloc.h" + +int main(void) +{ + printf("Allocating tap device via VSYS\n"); + + char if_name[IFNAMSIZ]; + + int tun_fd = tun_alloc(IFF_TAP, if_name); + + printf("Allocated tap device: %s fd=%d\n", if_name, tun_fd); + + printf("Sleeping for 120 secs...\n"); + + sleep(120); + + printf("Closing\n"); + + return 0; +} diff --git a/tunalloc.h b/tunalloc.h new file mode 100644 index 0000000..3e5caae --- /dev/null +++ b/tunalloc.h @@ -0,0 +1,6 @@ +#ifndef _TUNALLOC_H +#define _TUNALLOC_H + +int tun_alloc(int iftype, char *if_name); + +#endif -- 2.43.0