SMB/samba support on iOS?

Qiulang picture Qiulang · Nov 7, 2011 · Viewed 30.6k times · Source

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 ?

Answer

Qiulang picture Qiulang · Jan 16, 2012

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.