Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
028c596
install: added missing python deps for Linux. #1087
alfreb Jan 24, 2017
9ea75fe
Merge pull request #1088 from alfred-bratterud/dev
alfreb Jan 24, 2017
1319e58
pci: Enable missing command flags
fwsGonzo Jan 24, 2017
4b34758
vmrunner: make mac optional, use virtio/tap by default
alfreb Jan 24, 2017
4f1f7a5
Merge branch 'dev' of github.com:hioa-cs/IncludeOS into dev
fwsGonzo Jan 24, 2017
e51db87
install: Added pip installation & modules to macOS install #1087
AndreasAakesson Jan 25, 2017
7f66405
Merge pull request #1089 from alfred-bratterud/dev
alfreb Jan 25, 2017
261fd3e
Merge pull request #1090 from AndreasAakesson/dev
alfreb Jan 25, 2017
80326dc
kernel: Rearrange ELF symbol header, simplify some things
fwsGonzo Jan 25, 2017
a359cb3
posix: Add various stubs to signal, mman and a few linux stubs
fwsGonzo Jan 25, 2017
f0e2c83
boot: no cmake required for binaries, use verbose option, added json …
alfreb Jan 25, 2017
c8cb2b4
boot: added metavar to config arg
alfreb Jan 25, 2017
93c2161
posix: Add dlfcn stubs
fwsGonzo Jan 25, 2017
6b9564d
Merge pull request #1091 from fwsGonzo/dev
fwsGonzo Jan 26, 2017
762d4de
seed: Restructured seed and added a template for building libraries
AndreasAakesson Jan 26, 2017
5ce1118
posix: add uio header, make utsname.h includable from c files
ingve Jan 26, 2017
3739659
readme: A link
AndreasAakesson Jan 26, 2017
8e41942
test: separated validation of tests from vm config validation
alfreb Jan 26, 2017
06c39ad
test: http test now runs server in separate thread
alfreb Jan 26, 2017
ad1c61f
prettify: removed extra newline for warnings
alfreb Jan 26, 2017
cdd0460
Merge pull request #1092 from alfred-bratterud/dev
alfreb Jan 27, 2017
f9a7dcc
Merge pull request #1094 from ingve/posixstubs
alfreb Jan 27, 2017
bf9c232
Merge pull request #1093 from AndreasAakesson/dev
alfreb Jan 27, 2017
46f8ac7
Posix socket: RW -> WR
AnnikaH Jan 27, 2017
8da5ef5
http: Simplified Connection to be more general, client now uses speci…
AndreasAakesson Jan 27, 2017
59cd09d
boot/vmrunner: don't assume image name in config and don't look for S…
alfreb Jan 27, 2017
9099097
Merge pull request #1096 from AnnikaH/dev
alfreb Jan 27, 2017
9115187
Merge pull request #1097 from alfred-bratterud/dev
alfreb Jan 27, 2017
936b776
vmbuild: Avoid using IncludeOS sys headers
AndreasAakesson Jan 27, 2017
bb1d351
diskbuild: Avoid using IncludeOS sys headers by copy FAT structs
fwsGonzo Jan 27, 2017
1b1bcb1
test: Update to reflect connection rename in 8da5ef5
AndreasAakesson Jan 27, 2017
1e930d1
http: Added forgotten inline on Connection constructor
AndreasAakesson Jan 27, 2017
326d12b
Merge pull request #1098 from AndreasAakesson/dev
alfreb Jan 30, 2017
b15912d
posix: pwd-related functions
ingve Jan 30, 2017
a6c4ec9
Merge branch 'dev' of https://github.com/hioa-cs/IncludeOS into posix…
ingve Jan 30, 2017
9008ba2
posix: Clean up header mess
AndreasAakesson Jan 30, 2017
b11b042
posix: Made unittests work on Mac
AndreasAakesson Jan 30, 2017
488e04c
build: Now building with -nostdlibinc (only clang builtin headers)
AndreasAakesson Jan 30, 2017
bae5b87
Merge pull request #1103 from AndreasAakesson/posix
alfreb Jan 30, 2017
19a65ca
some posix documentation / guidelines
alfreb Jan 30, 2017
a1cf2cd
Merge branch 'dev' of github.com:alfred-bratterud/IncludeOS
alfreb Jan 30, 2017
1ba220b
Merge pull request #1102 from ingve/posixstubs
alfreb Jan 30, 2017
8277a0a
Merge pull request #1104 from alfred-bratterud/dev
alfreb Jan 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ endif(silent)
set(CAPABS "${CAPABS} ${OPTIMIZE}")

# these kinda work with llvm
set(CMAKE_CXX_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -c -m32 -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
set(CMAKE_C_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -c -m32 -DOS_VERSION=\"\"${OS_VERSION}\"\"")
set(CMAKE_CXX_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
set(CMAKE_C_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -DOS_VERSION=\"\"${OS_VERSION}\"\"")

# either download or cross-compile needed libraries
option(from_bundle "Download and use pre-compiled libraries for cross-comilation" ON)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ More information is [available on the wiki](https://github.com/hioa-cs/IncludeOS

### Writing your first service

1. Copy the [./seed](./seed) directory to a convenient location like `~/your_service`. Then, just start implementing the `Service::start` function in the `Service` class, located in [your_service/service.cpp](./seed/service.cpp) (Very simple example provided). This function will be called once the OS is up and running.
2. Update the [CMakeLists.txt](./seed/CMakeLists.txt) to specify the name of your project, enable any needed drivers or plugins, etc.
1. Copy the [./seed/service](./seed/service) directory to a convenient location like `~/your_service`. Then, just start implementing the `Service::start` function in the `Service` class, located in [your_service/service.cpp](./seed/service/service.cpp) (Very simple example provided). This function will be called once the OS is up and running.
2. Update the [CMakeLists.txt](./seed/service/CMakeLists.txt) to specify the name of your project, enable any needed drivers or plugins, etc.

**Example:**

```
$ cp -r seed ~/my_service
$ cp -r seed/service ~/my_service
$ cd ~/my_service
$ emacs service.cpp
... add your code
Expand Down
6 changes: 0 additions & 6 deletions api/kernel/mman.hpp

This file was deleted.

31 changes: 15 additions & 16 deletions api/net/http/client.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2016 Oslo and Akershus University College of Applied Sciences
// Copyright 2016-2017 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,26 +19,24 @@
#ifndef HTTP_CLIENT_HPP
#define HTTP_CLIENT_HPP

#include "common.hpp"
#include "request.hpp"
#include "response.hpp"
// http
#include "client_connection.hpp"

#include <net/tcp/tcp.hpp>
#include "connection.hpp"
#include "error.hpp"
#include <vector>
#include <map>

namespace http {

class Client {
public:
using TCP = net::TCP;
using Host = net::tcp::Socket;
using TCP = net::TCP;
using Host = net::tcp::Socket;

using Connection_set = std::vector<std::unique_ptr<Connection>>;
using Connection_mapset = std::map<Host, Connection_set>;
using Connection_set = std::vector<std::unique_ptr<Client_connection>>;
using Connection_mapset = std::map<Host, Connection_set>;

using timeout_duration = Connection::timeout_duration;
using timeout_duration = Client_connection::timeout_duration;

const static timeout_duration DEFAULT_TIMEOUT; // client.cpp, 5s
constexpr static size_t DEFAULT_BUFSIZE = 2048;
Expand Down Expand Up @@ -153,10 +151,11 @@ namespace http {
inline void post(Host host, std::string path, Header_set hfields, const std::string& data, Response_handler cb, Options options = {});

private:
TCP& tcp_;
Connection_mapset conns_;
friend class Client_connection;

bool keep_alive_ = false;
TCP& tcp_;
Connection_mapset conns_;
bool keep_alive_ = false;

void resolve(const std::string& host, ResolveCallback);

Expand All @@ -172,9 +171,9 @@ namespace http {
/** Add data and content length */
void add_data(Request&, const std::string& data);

Connection& get_connection(const Host host);
Client_connection& get_connection(const Host host);

void close(Connection&);
void close(Client_connection&);

}; // < class Client

Expand Down
69 changes: 69 additions & 0 deletions api/net/http/client_connection.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2016-2017 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once
#ifndef HTTP_CLIENT_CONNECTION_HPP
#define HTTP_CLIENT_CONNECTION_HPP

// http
#include "common.hpp"
#include "connection.hpp"
#include "error.hpp"

#include <util/timer.hpp>

namespace http {

class Client;

class Client_connection : public Connection {
public:
using timeout_duration = std::chrono::milliseconds;

public:
explicit Client_connection(Client&, TCP_conn);

bool available() const
{ return on_response_ == nullptr && keep_alive_; }

bool occupied() const
{ return !available(); }

void send(Request_ptr, Response_handler, const size_t bufsize, timeout_duration = timeout_duration::zero());

private:
Client& client_;
Response_handler on_response_;
Timer timer_;
timeout_duration timeout_dur_;

void send_request(const size_t bufsize);

void recv_response(buffer_t buf, size_t len);

void end_response(Error err = Error::NONE);

void timeout_request()
{ end_response(Error::TIMEOUT); }

void close();

}; // < class Client_connection

} // < namespace http

#endif // < HTTP_CLIENT_CONNECTION_HPP
79 changes: 32 additions & 47 deletions api/net/http/connection.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2016 Oslo and Akershus University College of Applied Sciences
// Copyright 2016-2017 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,74 +19,59 @@
#ifndef HTTP_CONNECTION_HPP
#define HTTP_CONNECTION_HPP

#include "common.hpp"
// http
#include "request.hpp"
#include "response.hpp"
#include "error.hpp"

#include <net/tcp/connection.hpp>
#include <map>
#include <vector>
#include <delegate>
#include <util/timer.hpp>

namespace http {

class Connection {
public:
using TCP_conn_ptr = net::tcp::Connection_ptr;
using Peer = net::tcp::Socket;
using buffer_t = net::tcp::buffer_t;
using Close_handler = delegate<void(Connection&)>;
using timeout_duration = std::chrono::milliseconds;
using TCP_conn = net::tcp::Connection_ptr;
using Peer = net::tcp::Socket;
using buffer_t = net::tcp::buffer_t;

public:

explicit Connection(TCP_conn_ptr, Close_handler);
inline explicit Connection(TCP_conn tcpconn, bool keep_alive = true);

template <typename TCP>
explicit Connection(TCP&, Peer, Close_handler);

bool available() const
{ return on_response_ == nullptr && keep_alive_; }

bool occupied() const
{ return !available(); }
explicit Connection(TCP&, Peer);

void send(Request_ptr, Response_handler, const size_t bufsize, timeout_duration = timeout_duration::zero());

net::tcp::port_t local_port() const
net::tcp::port_t local_port() const noexcept
{ return (tcpconn_) ? tcpconn_->local_port() : 0; }

Peer peer() const
Peer peer() const noexcept
{ return (tcpconn_) ? tcpconn_->remote() : Peer(); }
//bool operator==(const Connection& other)
//{ return this == &other; }
//{ return tcpconn_->local_port() == other.tcpconn_->local_port(); }

private:
TCP_conn_ptr tcpconn_;
void timeout()
{ tcpconn_->is_closing() ? tcpconn_->abort() : tcpconn_->close(); }

protected:
TCP_conn tcpconn_;
Request_ptr req_;
Response_ptr res_;
Close_handler on_close_;
Response_handler on_response_;
Timer timer_;

timeout_duration timeout_dur_;
bool keep_alive_;

void send_request(const size_t bufsize);

void recv_response(buffer_t buf, size_t len);

void end_response(Error err = Error::NONE);

void timeout_request()
{ end_response(Error::TIMEOUT); }

void close();
bool keep_alive_;

}; // < class Connection

inline Connection::Connection(TCP_conn tcpconn, bool keep_alive)
: tcpconn_{std::move(tcpconn)},
req_{nullptr},
res_{nullptr},
keep_alive_{keep_alive}
{
Ensures(tcpconn_ != nullptr);
debug("<http::Connection> Created %u -> %s %p\n", local_port(), peer().to_string().c_str(), this);
}

template <typename TCP>
Connection::Connection(TCP& tcp, Peer addr)
: Connection(tcp.connect(addr))
{
}

} // < namespace http

#endif // < HTTP_CONNECTION_HPP
11 changes: 11 additions & 0 deletions api/posix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# IncludeOS POSIX extensions

IncludeOS intends to provide a POSIX interface suffucient for linking and running many conventional C libraries and programs. A lot of the POSIX functionality will be header-only stubs and some of it is provided externally by e.g. the compiler or standard library.

### Other providers of POSIX content
* *newlib*: is our current C library which also provides many POSIX features (indeed the C standard itself overlaps with POSIX). Newlib provides most of the C standard library, including `stdlib.h`, `stdio.h`, `math.h` etc., but is mising some C11 extensions. Those are rarely used and provided here as stubs.
* *clang*: Clang provides a few POSIX headers such as `stddef.h`, `stdarg.h` and `limits.h`. It also provides compiler intrinsics such as `x86intrin.h`. When building IncludeOS we use the `-nostdlibinc` flag to allow inclusion of these headers, without including the standard library headers from the host.

### Guidelines for this folder
* Only actually standardized POSIX content should live here, and only content not allready provided by alternative sources above.
* Extensions to POSIX headers that IncludeOS needs, but which isn't present on one of the supportet platforms (e.g. macOS or Linux) should not live here, since we'd like to be able to build directly on those platforms with their respective POSIX implementations. As an example, our syslog implementation defines `LOG_INTERNAL` in addition to `LOG_MAIL` etc. While defining this symbol in the `syslog.h` POSIX header is allowed by the standard it introduces an implicit expectation in IncludeOS application code making it less portable. Such extensions can be placed in the IncludeOS API instead.
39 changes: 39 additions & 0 deletions api/posix/dlfcn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2017 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef POSIX_DLFCN_H
#define POSIX_DLFCN_H

#ifdef __cplusplus
extern "C" {
#endif

#define RTLD_LAZY 1 // Relocations are performed at an implementation-dependent time.
#define RTLD_NOW 2 // Relocations are performed when the object is loaded.
#define RTLD_GLOBAL 3 // All symbols are available for relocation processing of other modules.
#define RTLD_LOCAL 4 // All symbols are not made available for relocation processing by other modules.

void *dlopen(const char *, int);
void *dlsym(void *, const char *);
int dlclose(void *);
char *dlerror(void);

#ifdef __cplusplus
}
#endif

#endif // < POSIX_DLFCN_H
8 changes: 7 additions & 1 deletion api/sys/math.h → api/posix/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#ifndef SYS_MATH_H
#define SYS_MATH_H

#ifdef __cplusplus
extern "C" {
#endif

// Long double math stubs
long double cosl(long double);
Expand Down Expand Up @@ -85,7 +88,10 @@ long double tgammal(long double);
long double truncl(long double);
long double nanl(const char*);


#ifdef __cplusplus
}
#endif

#include_next <math.h>

#endif
Loading