-#!/usr/bin/env python
# -*- coding: utf-8 -*-
from constants import TESTBED_ID, TESTBED_VERSION
passfd.sendfd(sock, tap.fd, '0')
# TODO: after succesful transfer, the tap device should close the fd
-def connect_tunchannel_tap(testbed_instance, chan_guid, tap_guid):
+def connect_tunchannel_tun(testbed_instance, chan_guid, tap_guid):
+ connect_tunchannel_tap(testbed_instance, chan_guid, tap_guid, ethernet_mode=False)
+
+def connect_tunchannel_tap(testbed_instance, chan_guid, tap_guid, ethernet_mode=True):
tap = testbed_instance._elements[tap_guid]
chan = testbed_instance._elements[chan_guid]
chan.tun_socket = os.fdopen(tap.fd)
# Set the channel to ethernet mode (it's a tap)
- chan.ethernet_mode = True
+ chan.ethernet_mode = ethernet_mode
# Check to see if the device uses PI headers
# It's normally so
IFF_NO_PI = 0x00001000
struct_ifreq = "x"*16+"H"+"x"*22
flags = struct.unpack(struct_ifreq,
- fcntl.ioctl(tap.fd, TUNGETIFF, struct.pack(struct_ifreq,0)) )
+ fcntl.ioctl(tap.fd, TUNGETIFF, struct.pack(struct_ifreq,0)) )[0]
with_pi = (0 == (flags & IFF_NO_PI))
except:
# maybe the kernel doesn't support the IOCTL,
return
routes = testbed_instance._add_route[guid]
for route in routes:
- (destination, netprefix, nexthop, metric) = route
+ (destination, netprefix, nexthop, metric, device) = route
element.add_route(prefix = destination, prefix_len = netprefix,
nexthop = nexthop, metric = metric)
dict({
"from": (TESTBED_ID, TUNCHANNEL, "->fd" ),
"to": (TESTBED_ID, TUNIFACE, "fd->" ),
- "init_code": connect_tunchannel_tap,
+ "init_code": connect_tunchannel_tun,
"can_cross": False
}),
dict({
"name": "up",
"help": "Link up",
"type": Attribute.BOOL,
- "value": False,
+ "value": True,
+ "flags": Attribute.NoDefaultValue,
"validation_function": validation.is_bool
}),
"device_name": dict({