diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-09-30 10:17:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-09-30 10:45:39 +0200 |
commit | 5e112453b2e953c5fa1d248355610ddf06f21b4a (patch) | |
tree | 93404a849643120123b89fd626c5a6512081b4da /arch/sandbox/os/tap.c | |
parent | 0c817d3ffac2aa9f5c2f5848a9aa351894dea786 (diff) | |
download | barebox-5e112453b2e953c5fa1d248355610ddf06f21b4a.tar.gz barebox-5e112453b2e953c5fa1d248355610ddf06f21b4a.tar.xz |
Sandbox: Fix make system
Sandbox compilation failed with:
gcc -Wp,-MD,arch/sandbox/lib/.tap.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.3.1/include -I/usr/include -Iinclude -P -Wall -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(tap)" -D"KBUILD_MODNAME=KBUILD_STR(tap)" -c -o arch/sandbox/lib/tap.o arch/sandbox/lib/tap.c
In file included from /usr/include/bits/socket.h:32,
from /usr/include/sys/socket.h:36,
from arch/sandbox/lib/tap.c:29:
/usr/include/limits.h:125:26: error: limits.h: No such file or directory
/usr/include/limits.h uses the next_include directive
This was because of the -nostdinc
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox/os/tap.c')
-rw-r--r-- | arch/sandbox/os/tap.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/sandbox/os/tap.c b/arch/sandbox/os/tap.c new file mode 100644 index 0000000000..ebd828b2b2 --- /dev/null +++ b/arch/sandbox/os/tap.c @@ -0,0 +1,68 @@ +/* + * tap.c - host side functions for tap driver + * + * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <linux/if.h> +#include <linux/if_tun.h> +#include <string.h> + +int tap_alloc(char *dev) +{ + struct ifreq ifr; + int fd, err; + + if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { + perror("could not open /dev/net/tun"); + return -1; + } + + memset(&ifr, 0, sizeof(ifr)); + + /* Flags: IFF_TUN - TUN device (no Ethernet headers) + * IFF_TAP - TAP device + * + * IFF_NO_PI - Do not provide packet information + */ + ifr.ifr_flags = IFF_TAP | IFF_NO_PI; + if (*dev) + strncpy(ifr.ifr_name, dev, IFNAMSIZ); + + if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) { + perror("could not get tap device"); + close(fd); + return err; + } + + strcpy(dev, ifr.ifr_name); + return fd; +} + +/** + * @file + * @brief Host side functions for tap driver + */ |