'Open the named tunnel using the given mode.
@param name: The name of the tunnel to open.
@type name: L{bytes}
@param mode: Flags from L{TunnelFlags} with exactly one of
L{TunnelFlags.IFF_TUN} or L{TunnelFlags.IFF_TAP} set.
@return: A L{_TunnelDescription} representing the newly opened tunnel.'

def _openTunnel(self, name, mode):

    flags = ((self._system.O_RDWR | self._system.O_CLOEXEC) | self._system.O_NONBLOCK)
    config = struct.pack(('%dsH' % (_IFNAMSIZ,)), name, mode.value)
    fileno = self._system.open(_TUN_KO_PATH, flags)
    result = self._system.ioctl(fileno, _TUNSETIFF, config)
    return _TunnelDescription(fileno, result[:_IFNAMSIZ].strip('\x00'))
