Skip to content
Implementation of 9P2000 protocol
C++ CMake Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake
debian
docs
examples
external
include/styxe
src
test
.gitignore
.gitmodules
.travis.yml
CMakeLists.txt
CONTRIBUTING.md
CPPLINT.cfg
LICENSE
Makefile.in
PROJECT.name
README.md
conanfile.txt
configure
lgtm.yml
libstyxe.pc.in

README.md

libstyxe C++ standard License


TravisCI Codecov Coverity Coverage Status LGTM

A library for parsing 9P2000 protocol messages.

library: a collection of types, functions, classes, etc. implementing a set of facilities (abstractions) meant to be potentially used as part of more that one program. From Cpp Code guidelines gloassay

It also includes 9P2000.e extension. To learn more about the extension please see http://erlangonxen.org/more/9p2000e

Using this library

To create 9P message:

The library is using Solace::ByteWriter / Solace::ByteReader to read/write byte streams. Note that this adaptors do not allocate memory. So the user is responsible for creating a buffer of appropriate size to write the resulting message to. Note that the size of the target buffer should be no more then negotiated message size for the current session.

#include <styxe/styxe.hpp>

...
Solace::ByteWriter buffer{...};

// Write TVersion request into the beffer
styxe::RequestBuilder{destBuffer}
            .version();
...
// Write TOpen request into the given destination buffer
styxe::RequestBuilder{destBuffer}
            .open(42, styxe::OpenMode::READ));

Parsing 9P message from a byte buffer:

Parsing of 9P protocol messages differ slightly depending on if you are implementing server - expecting request type messages - or a client - parsing server responses.

Parsing requests (server side):

styxe::Parser parser{...};
...
Solace::ByteReader buffer{...};
parser.parseMessageHeader{buffer}
    .then([&](styxe::MessageHeader&& header) {
        return parser.parseRequest(header, buffer)
            .then(handleRequest);
    })
    .orElse([](Error&& err) {
        std::cerr << "Error parsing request: " << err << std::endl;
    });

Parsing response (client side):

styxe::Parser parser{...};
...
parser.parseMessageHeader(buffer)
    .then([&](styxe::MessageHeader&& header) {
        return parser.parseResponse(header, buffer)
            .then(handleRequest);
    })
    .orElse([](Error&& err) {
        std::cerr << "Error parsing response: " << err << std::endl;
    });

See examples for other example usage of this library.

Dependencies

This library depends on libsolace for low level data manipulation primitives such as ByteReader/ByteWriter and Result<> type. Since it is only a 9P protocol parser - there is dependency on the IO. It is library users responsibility to provide data stream.

GTest

Note test framework used is gtest and it is managed via git modules. Don't forget to do git submodule update --init --recursive on a new checkout to pull sub-module dependencies.

Building

Build tool dependencies

In order to build this project following tools must be present in the system:

  • git (to check out project and it’s external modules, see dependencies section)
  • doxygen (for documentation)
  • cppcheck (static code analysis, latest version from git is used as part of the 'codecheck' step)
  • cpplint (for static code analysis in addition to cppcheck)
  • valgrind (for runtime code quality verification)

This project is using C++17 features extensively. The minimal tested/required version of gcc is gcc-7. CI is using clang-6 and gcc-7. To install build tools on Debian based Linux distribution:

sudo apt-get update -qq
sudo apt-get install git doxygen python-pip valgrind ggcov
sudo pip install cpplint

The library has one external dependency: libsolace which is managed via conan. Please make sure conan is installed on your system if you want to build this project.

Building the project

# In the project check-out directory:
# To build debug version with sanitizer enabled (recommended for development)
./configure --enable-debug --enable-sanitizer

# To build the library it self
make

# To build and run unit tests:
make test

# To run valgrind on test suit:
# Note: `valgrind` doesn’t work with ./configure --enable-sanitize option
make verify

# To build API documentation using doxygen:
make doc

To install locally for testing:

make --prefix=/user/home/<username>/test/lib install

To install system wide (as root):

make install

To run code quality check before submission of a patch:

# Verify code quality before submission
make codecheck

Contributing changes

The framework is work in progress and contributions are very welcomed. Please see CONTRIBUTING.md for details on how to contribute to this project.

Please note that in order to maintain code quality a set of static code analysis tools is used as part of the build process. Thus all contributions must be verified by this tools before PR can be accepted.

License

The library available under Apache License 2.0 Please see LICENSE for details.

Authors

Please see AUTHORS file for the list of contributors.

You can’t perform that action at this time.