A Discrete-Event Network Simulator
API
planetlab-tap-creator.cc File Reference
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <net/route.h>
#include <netinet/in.h>
#include "creator-utils.h"
+ Include dependency graph for planetlab-tap-creator.cc:

Go to the source code of this file.

Macros

#define PLANETLAB_MAGIC   75867
 
#define VSYS_TUNTAP   "/vsys/fd_tuntap.control"
 
#define VSYS_VIFUP_IN   "/vsys/vif_up.in"
 
#define VSYS_VIFUP_OUT   "/vsys/vif_up.out"
 

Functions

int ReceiveVifFd (int fd, char *vif_name)
 Reads vif FD from "fd", writes interface name to vif_name, and returns vif FD. More...
 
void SetTunUp (const char *ip, const char *prefix, const char *if_name)
 Sets the TAP/TUN interface up. More...
 
int TunAlloc (int iftype, char *if_name)
 Creates a TUN/TAP device on a PlanetLab virtual machine (sliver). More...
 

Macro Definition Documentation

◆ PLANETLAB_MAGIC

#define PLANETLAB_MAGIC   75867

Definition at line 46 of file planetlab-tap-creator.cc.

◆ VSYS_TUNTAP

#define VSYS_TUNTAP   "/vsys/fd_tuntap.control"

Definition at line 48 of file planetlab-tap-creator.cc.

Referenced by TunAlloc().

◆ VSYS_VIFUP_IN

#define VSYS_VIFUP_IN   "/vsys/vif_up.in"

Definition at line 49 of file planetlab-tap-creator.cc.

Referenced by SetTunUp().

◆ VSYS_VIFUP_OUT

#define VSYS_VIFUP_OUT   "/vsys/vif_up.out"

Definition at line 50 of file planetlab-tap-creator.cc.

Referenced by SetTunUp().

Function Documentation

◆ ReceiveVifFd()

int ReceiveVifFd ( int  fd,
char *  vif_name 
)

Reads vif FD from "fd", writes interface name to vif_name, and returns vif FD.

vif_name should be IFNAMSIZ chars long.

Definition at line 61 of file planetlab-tap-creator.cc.

References ABORT_IF.

Referenced by TunAlloc().

+ Here is the caller graph for this function:

◆ SetTunUp()

void SetTunUp ( const char *  ip,
const char *  prefix,
const char *  if_name 
)

Sets the TAP/TUN interface up.

When a TAP/TUN device is created on PlanetLab it must be set up writing some configuration information to the vsys fifo at /vsys/vif_up.in

Definition at line 140 of file planetlab-tap-creator.cc.

References ABORT_IF, VSYS_VIFUP_IN, and VSYS_VIFUP_OUT.

◆ TunAlloc()

int TunAlloc ( int  iftype,
char *  if_name 
)

Creates a TUN/TAP device on a PlanetLab virtual machine (sliver).

PlanetLab provides the Vsys API to enable privileged operating system calls in an environment with restricted privileges. To create a TUN/TAP device the it is necessary to connect to the /vsys/fd_tuntap.control socket, and send the device initialization parameters.

Definition at line 105 of file planetlab-tap-creator.cc.

References ABORT_IF, ReceiveVifFd(), and VSYS_TUNTAP.

+ Here is the call graph for this function: