SMB/samba support on iOS?

会有一股神秘感。 提交于 2019-11-27 03:27:05

问题


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 ?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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/



来源:https://stackoverflow.com/questions/8032314/smb-samba-support-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!