summaryrefslogtreecommitdiff
path: root/pfinet/tunnel.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-05 00:33:28 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-02-05 00:33:28 +0100
commit93932c891eb76fa96f99aea275325c6048b62747 (patch)
treeab46a9335ec660003f2e6ecb5e244ac8cfe7252c /pfinet/tunnel.c
parenta4693935b02c509fe029a0653391f8a030e4d615 (diff)
Permit to use a tunnel not in /dev
* pfinet/main.c (find_device): Use basename of NAME for the comparison against "tun" and "dummy". * pfinet/tunnel.c (setup_tunnel_device): Only prepend "/dev/" to tun name if the parameter is not a path.
Diffstat (limited to 'pfinet/tunnel.c')
-rw-r--r--pfinet/tunnel.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/pfinet/tunnel.c b/pfinet/tunnel.c
index cf907f59..5d2544b2 100644
--- a/pfinet/tunnel.c
+++ b/pfinet/tunnel.c
@@ -149,6 +149,7 @@ setup_tunnel_device (char *name, struct device **device)
error_t err;
struct tunnel_device *tdev;
struct device *dev;
+ char *base_name;
/* Do global initialization before setting up first tunnel device. */
if (!tunnel_dev)
@@ -165,7 +166,13 @@ setup_tunnel_device (char *name, struct device **device)
*device = dev = &tdev->dev;
- dev->name = strdup (name);
+ base_name = strrchr (name, '/');
+ if (base_name)
+ base_name++;
+ else
+ base_name = name;
+
+ dev->name = strdup (base_name);
dev->priv = tdev;
dev->get_stats = tunnel_get_stats;
@@ -187,8 +194,11 @@ setup_tunnel_device (char *name, struct device **device)
dev_init_buffers (dev);
- /* Setting up the translator at /dev/tunX. */
- asprintf (&tdev->devname, "/dev/%s", tdev->dev.name);
+ if (base_name != name)
+ tdev->devname = strdup (name);
+ else
+ /* Setting up the translator at /dev/tunX. */
+ asprintf (&tdev->devname, "/dev/%s", tdev->dev.name);
tdev->underlying = file_name_lookup (tdev->devname, O_CREAT|O_NOTRANS, 0664);
if (tdev->underlying == MACH_PORT_NULL)