1**GEFAHR ACHTUNG GEFAHR:** THIS CODE IS WRITTEN IN A MEMORY UNSAFE2PROGRAMMING LANGUAGE AND ACCEPTS ARBITRARY INPUT FROM A NETWORK3CONNECTION. I AM PRETTY SURE THAT I AM NOT CAPABLE OF WRITING BUG-FREE C4CODE SO PLEASE DON'T BLAME ME IF YOUR CONSTRAINED DEVICE BECOMES PART OF5THE NEXT INTERNET OF THINGS BOTNET. KTHXBYE!67ninenano8========910ninenano is a client implementation of the 9P network for [constrained11devices][7]. It currently consists of two separated components:12131. 9p: A client implementation of the 9P network protocol142. 9pfs: Virtual 9P file system using RIOTs VFS layer1516The 9p component works on the [RIOT][3] operating system and on various17POSIX compatible operating systems. It uses only a small subset of the18functions provided by the libc and should therefore also be portable to19other operating systems and microcontroller frameworks. The 9pfs20component uses RIOT's [VFS layer][5] and thus only works on RIOT.2122However, even on RIOT you might consider using the 9p component directly23instead of 9pfs component since doing so will spare you some bytes in24the text segment.2526Status27------2829This implementation of the 9P protocol has the following limitations:30311. It only sends one T-message at a time and waits for an R-message from32 the server before sending additional T-messages.332. `flush(5)` is not implemented because it wasn't needed due to the34 first limitation.353. Only files with a maximum amount of sixteen path elements can be36 accessed using `_9pwalk`.374. Proper handling of `Rerror` messages is not implemented.385. `Twstat` is currently not implemented.3940*The fourth and fifth limitation might be resolved in feature releases.*4142Supported compilers43-------------------4445In theory this code should compile with any C99 compiler, however, the46compatibility layer for POSIX compatible operating systems uses gcc47builtins for byteswapping. Therefore the code only compiles with recent48version of gcc and clang.4950Compilation51-----------5253For using this library on RIOT you should use the provided RIOT ninenano54pkg. For compiling a static library for POSIX operating systems run the55following command:5657 $ make -f Makefile.posix5859A few CPP macros are provided for tweaking the size of the library,60these can be passed by modifying the `CFLAGS` environment variable61accordingly. Currently the following macros can be redefined:62631. `_9P_MSIZE`: Maximum message size and therefore also equal to the64 buffer size used to store 9P messages.652. `_9P_MAXFIDS`: Maximum amount of open fids for a 9P connection.6667In addition to that you can define `NDEBUG` to prevent some optional68sanity checks form being included in the resulting binary. Your69application should be fine without them they only detect violations of70invariants caused by programming errors.7172Usage73-----7475**Disclaimer:** This library requires a basic understanding of the 9P76network protocol. If you don't know how 9P works start by reading the77`intro(5)` [man page][6] shipped with the fourth edition of Plan 978operating system.7980The API is very straight forward and shouldn't change a lot anymore. If81you want to use 9P in combination with the provided VFS layer start by82reading the [VFS documentation][5]. In order to use 9pfs you need to83point the `private_data` member of your `vfs_mount_t` to an allocated84`_9pfs` superblock in addition to that the `ctx` member of the85superblock needs to be initialized using `_9pinit`.8687If you want to use the 9P component directly all you have to do is88allocate memory for a `_9pctx` and afterwards initialize it with89`_9pinit`. Consult the documentation or the examples in `examples/` and90`tests/` if you need additional help.9192Documentation93-------------9495The source code is documented in a format that can be parsed by96[Doxygen][4]. A `Doxyfile` is also provided. To generate source code97documentation using the supplied `Doxyfile` run the following command:9899 $ doxygen Doxyfile100101Afterwards the documentation will be located in a newly created folder102called `docs`, view the docs by opening `docs/index.html` in your103favorite web browser.104105Tests106-----107108ninenano comes with both unit and integration tests utilising RIOT's109test framework. The unit tests use the 9p component directly while the110integration tests use the 9p component indirectly through the 9pfs111component.112113In order to run the tests you need to setup the toolchain for RIOT's114[native family][1]. Besides you need to install go `>= 1.5`, python115`3.X` and the [pexpect][2] python package.116117In addition to that a tun devices needs to created:118119 # ip tuntap add tap0 mode tap120 # ip addr add fe80::e42a:1aff:feca:10ec dev tap0121 # ip link set tap0 up122123After creating the tun devices you can run the tests:124125 $ export TESTADDR="fe80::e42a:1aff:feca:10ec"126 $ make test127128**Note:** RIOT will add an additional IP address to the interface when129you run the tests for the first time. However, it doesn't matter which130one you use as a value for the `TESTADDR` environment variable, meaning131you can ignore the additional IP address.132133License134-------135136This program is free software: you can redistribute it and/or modify it137under the terms of the GNU General Public License as published by the138Free Software Foundation, either version 3 of the License, or (at your139option) any later version.140141This program is distributed in the hope that it will be useful, but142WITHOUT ANY WARRANTY; without even the implied warranty of143MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General144Public License for more details.145146You should have received a copy of the GNU General Public License along147with this program. If not, see <http://www.gnu.org/licenses/>.148149[1]: https://github.com/RIOT-OS/RIOT/wiki/Family:-native#toolchains150[2]: https://pypi.python.org/pypi/pexpect151[3]: http://riot-os.org/152[4]: http://www.stack.nl/~dimitri/doxygen/153[5]: http://riot-os.org/api/group__sys__vfs.html154[6]: http://man.cat-v.org/plan_9/5/intro155[7]: https://tools.ietf.org/html/rfc7228