Domanda

I check iOS document and also google it for a while and get the impression that iOS does not support samba (although there is a samba app for jailbreak iPhone).

But then how do the app FileBrowser achieves that? Does that mean they implemented samba support by their own ?

I also find there is an open source library called tango that provides limited support for samba. So my question is that the best samba support I can get ?

È stato utile?

Soluzione

I spent quite some time in implementing my own SMB client so I would like to share some experience here.

First do not use tango in your production code because once you become familiar with SMB you will realize that its implementation is problematic, e.g. it does not support unicode and in some several cases it is not correctly padding so you can't access the folder. And I also heard people said they can't connect window 7 with it.

Second, to summarize my experience I find jcifs guys had said the best: "anyone who wants to implement the CIFS needs to know one very important thing - the "official" CIFS documentation is not accurate and does not reflect reality. There is NO specification. Do not believe anything you read in the IETF draft or the SNIA document (same document different formatting). Use it only as a hint. The definitive reference is whatever you see on the wire.

WireShark Rules!

... look at JCIFS for design inspiration such as how it puts the request and response into a map by MID and encodes and decodes frames.

Then implement the following commands:

  • SMB_COM_NEGOTIATE
    SMB_COM_SESSION_SETUP_ANDX
    SMB_COM_TREE_CONNECT_ANDX
    SMB_COM_NT_CREATE_ANDX
    SMB_COM_READ_ANDX
    SMB_COM_WRITE_ANDX
    SMB_COM_CLOSE
  • all responses for above "

The only thing I can add is that , you also need to implement TRANS2_FIND_FIRST2 request/response to query the files inside a folder and if you want to find out how many shared folders the server exposes you need to implement NetShareEnum Request/Response.

Altri suggerimenti

I used libsmbclient from samba package (http://www.samba.org) for SMB operations on iOS. You can look on my project https://github.com/kolyvan/kxsmb (objective-c wrapper on libsmbclient). For now it supports a limited set of SMB operations. It mostly was designed for browsing local net and retrieving files from SMB shares.

iOS doesn't give you access to a filesystem that you may be used to. You can read and write files inside your own App's private area, but that's all. You could potentially implement another file system in your application, but you won't be able to use normal file operations.

I'd bet FileBrowser implements the protocol inside their app and implements a file system like layer on top of that for access. I'd guess you could either try to port an existing samba library or roll your own.

iOS does not have any APIs to work with SMB. However, SMB is currently documented by Microsoft and implementing it is not impossible (although not easy too). I've created a freeware project which contains most of what you need to handle SMB. See

https://sourceforge.net/projects/smb4ios/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top