include $(RTE_SDK)/mk/rte.vars.mk
-ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
-$(info This application can only operate in a linuxapp environment, \
-please change the definition of the RTE_TARGET environment variable)
-all:
-clean:
-else
-
# binary name
APP = exception_path
CFLAGS += $(WERROR_FLAGS)
include $(RTE_SDK)/mk/rte.extapp.mk
-
-endif
#include <getopt.h>
#include <netinet/in.h>
-#include <linux/if.h>
+#include <net/if.h>
+#ifdef RTE_EXEC_ENV_LINUXAPP
#include <linux/if_tun.h>
+#endif
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
}
}
+#ifdef RTE_EXEC_ENV_LINUXAPP
/*
* Create a tap network interface, or use existing one with same name.
* If name[0]='\0' then a name is automatically assigned and returned in name.
return fd;
}
+#else
+/*
+ * Find a free tap network interface, or create a new one.
+ * The name is automatically assigned and returned in name.
+ */
+static int tap_create(char *name)
+{
+ int i, fd = -1;
+ char devname[PATH_MAX];
+
+ for (i = 0; i < 255; i++) {
+ snprintf(devname, sizeof(devname), "/dev/tap%d", i);
+ fd = open(devname, O_RDWR);
+ if (fd >= 0 || errno != EBUSY)
+ break;
+ }
+
+ if (name)
+ snprintf(name, IFNAMSIZ, "tap%d", i);
+
+ return fd;
+}
+#endif
/* Main processing loop */
static int