class LinuxTap(LinuxApplication):
_rtype = "linux::Tap"
_help = "Creates a TAP device on a Linux host"
- _backend = "linux"
+
+ IFF_TUN = 0x0001
+ IFF_TAP = 0x0002
@classmethod
def _register_attributes(cls):
- endpoint_ip = Attribute("endpoint_ip", "IPv4 Address",
+ ip = Attribute("ip", "IPv4 Address",
flags = Flags.Design)
mac = Attribute("mac", "MAC Address",
flags = Flags.Design)
- endpoint_prefix = Attribute("endpoint_prefix", "IPv4 network prefix",
- type = Types.Integer,
+ prefix = Attribute("prefix", "IPv4 network prefix",
flags = Flags.Design)
mtu = Attribute("mtu", "Maximum transmition unit for device",
"Bash script to be executed before releasing the resource",
flags = Flags.Design)
- cls._register_attribute(endpoint_ip)
+ cls._register_attribute(ip)
cls._register_attribute(mac)
- cls._register_attribute(endpoint_prefix)
+ cls._register_attribute(prefix)
cls._register_attribute(mtu)
cls._register_attribute(devname)
cls._register_attribute(up)
def node(self):
node = self.get_connected(LinuxNode.get_rtype())
if node: return node[0]
- raise RuntimeError, "TAP/TUN devices must be connected to Node"
+ raise RuntimeError, "linux::TAP/TUN devices must be connected to a linux::Node"
@property
def gre_enabled(self):
tdiffsec(tnow(), self._last_state_check) > state_check_delay:
if self.get("deviceName"):
- (out, err), proc = self.node.execute("ifconfig")
+ (out, err), proc = self.node.execute("ip a")
if out.strip().find(self.get("deviceName")) == -1:
# tap is not running is not running (socket not found)
def _udp_connect_command(self, remote_endpoint, connection_run_home,
cipher, cipher_key, bwlimit, txqueuelen):
- # Set the remote endpoint
- self.set("pointopoint", remote_endpoint.get("endpoint_ip"))
+ # Set the remote endpoint to the IP of the device
+ self.set("pointopoint", remote_endpoint.get("ip"))
# Planetlab TAPs always use PI headers
from nepi.resources.planetlab.tap import PlanetlabTap
if self.is_rm_instance(PlanetlabTap.get_rtype()):
self.set("pi", True)
+ # Public IP of the remote NODE to stablish tunnel
remote_ip = remote_endpoint.node.get("ip")
local_port_file = os.path.join(self.run_home,
return command
def _gre_connect_command(self, remote_endpoint, connection_run_home):
- # Set the remote endpoint
- self.set("pointopoint", remote_endpoint.get("endpoint_ip"))
+ # Set the remote endpoint to (private) device IP
+ self.set("pointopoint", remote_endpoint.get("ip"))
+ ## public node IP
self.set("greRemote", remote_endpoint.node.get("ip"))
# Generate GRE connect command
return command
- def establish_udp_connection(self, remote_endpoint, port):
+ def establish_udp_connection(self, remote_endpoint,
+ connection_app_home,
+ connection_run_home,
+ port):
# upload remote port number to file
rem_port = "%s\n" % port
self.node.upload(rem_port,
self.vif_prefix,
"pi" if self.get("pi") else ""))
start_command.append("sudo -S ip link set %s up" % self.get("deviceName"))
- start_command.append("sudo -S ip addr add %s/%d dev %s" % (
- self.get("endpoint_ip"),
- self.get("endpoint_prefix"),
+ start_command.append("sudo -S ip addr add %s/%s dev %s" % (
+ self.get("ip"),
+ self.get("prefix"),
self.get("deviceName"),
))
self.node.get("ip"),
self.get("greKey")
))
- command.append("sudo -S ip addr add %s/%d peer %s/%d dev %s" % (
- self.get("endpoint_ip"),
- self.get("endpoint_prefix"),
+ command.append("sudo -S ip addr add %s/%s peer %s/%s dev %s" % (
+ self.get("ip"),
+ self.get("prefix"),
self.get("pointopoint"),
- self.get("endpoint_prefix"),
+ self.get("prefix"),
self.get("deviceName"),
))
command.append("sudo -S ip link set %s up " % self.get("deviceName"))
def vif_type(self):
return "IFF_TAP"
+ @property
+ def vif_type_flag(self):
+ return LinuxTap.IFF_TAP
+
@property
def vif_prefix(self):
return "tap"