Home |
SMB Client |
SMB ClientSMB (Server Message Block) is a protocol designed by Microsoft to allow networked computers to share files. Microsoft uses SMB to allow Windows machines to make resources such as disk trees (SMB name for directories) available to others on the network. The SMB Client add-on for RTIP-32 only supports the SMB protocol version 1.0, which is no longer supported by Windows 10. For this reason, this product is depricated. The SMB3 Client, which supports protocol versions 1, 2, and 3.1.1, is recommended instead. The SMB Client add-on for RTIP-32 allows an On Time RTOS-32 embedded system to access files located on a network share published by another computer on the network. The file I/O API is the standard Win32 API also used to access local files. Application programs can thus open files with the same functions (e.g., fopen("\\\\Server\\Share\\C\\SomeFile.txt", "rt")). The SMB Client defines an RTTarget-32 Installable File System, declared in header file Smbcapi.h: RTFileSystemHandlers RTSMBFileSystem; By default, the following file system configuration is linked from library Smbc.lib (if it is linked before Rtfiles.lib and Rtt32.lib): static RTFileSystem Console = { RT_FS_CONSOLE, 0, 0, &RTConsoleFileSystem }; static RTFileSystem LPTFiles = { RT_FS_LPT_DEVICE, 0, 0, &RTLPTFileSystem }; static RTFileSystem NETFileSystem = { RT_FS_NET_FILE | RT_FS_IS_DEFAULT, 0, 0, &RTSMBFileSystem }; RTFileSystem * RTFileSystemList[] = { &Console, &LPTFiles, &NETFileSystem, NULL }; The console, printer, and SMB client file systems are present. If this is not what you want, you must include your own RTFileSystemList. Here is an example which links the console file system, RTFiles-32 (drives A-Z), and the SMB client: static RTFileSystem Console = { RT_FS_CONSOLE, 0, 0, &RTConsoleFileSystem }; static RTFileSystem FATFiles = { RT_FS_FILE | RT_FS_IS_DEFAULT, 0x3FFFFFFF, 0x00000FFF, &RTFilesFileSystem }; static RTFileSystem NETFileSystem = { RT_FS_NET_FILE, 0, 0, &RTSMBFileSystem }; RTFileSystem * RTFileSystemList[] = { &Console, &FATFiles, &NETFileSystem, NULL }; Once the SMB client has been initialized with rtsmb_cli_init_ex and rtsmb_cli_ez_set_user_ex files located on remote computer shares can be opened just like local files. The SMB client does not have a documented native file I/O API. Rather, it make all file I/O available through the Win32 API. This means that all APIs which are implemented using the Win32 API can also be used (for example all C/C++ run-time system function such as fopen(), C++ iostream, etc.). The SMB Client supports the following Win32 API functions:
The file name syntax to use is: \\Server\Share\[Path\]Filename where Server is either an IP address in decimal dotted notation (example: 123.45.67.8) or a DNS name (example: smb.domain.com) or a Net-BIOS name of a server on the local LAN segment (example: MYSERVER). The server name may not exceed 16 characters in length. The length of the share name is limited to 12 characters. The combined server, share, path, and file name may not exceed 260 bytes total length. File names are case sensitive only if the server connected to treats file names case sensitive. The SMB client supports setting a default directory, so this code would open file \\MyServer\C\AUTOEXEC.BAT: chdir("\\\\MyServer\\C"); f = fopen("AUTOEXEC.BAT", "rt"); The Win32 file find functions FindFirstFile and FindNextFile are fully supported to find files and shares. For example, the search string "\\MyServer\*" would find all shares published by server "MyServer". The SMB Client is an optional add-on for RTIP-32 and must be purchased in addition to RTIP-32 to be available. Applications requiring the SMB Client must include header file Smbcapi.h and link library Smbc.lib. The SMB Client API is documented in the RTIP-32 Reference Manual. Demo program SMBClient shows how the SMB client is used.
|