Skip to content

Commit

Permalink
mk: mbed-crypto => mbedtls; clang-6 => clang-8
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Jun 20, 2020
1 parent 747c1a5 commit 8206ad3
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 113 deletions.
30 changes: 11 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,32 @@ addons:
apt:
packages:
- build-essential
- clang-6.0
- clang-format-6.0
- cmake
- gcc-arm-none-eabi
- clang-8
- clang-format-8
- lcov
- lld-6.0
- llvm-6.0
- lld-8
- llvm-8
- libboost-dev
- libnewlib-arm-none-eabi
- libstdc++-arm-none-eabi-newlib
- ninja-build

before_install:
- pip install cpp-coveralls meson
- pip install cpp-coveralls cmake meson

install:
- |
: install googletest
cd $HOME
curl -L https://github.com/google/googletest/archive/release-1.10.0.tar.gz | tar -xz
mkdir gtest
cd gtest
curl -sL https://github.com/google/googletest/archive/release-1.10.0.tar.gz | tar -xz
mkdir gtest-build && cd gtest-build
cmake -G Ninja ../googletest-release-1.10.0
ninja
sudo ninja install
- |
: install Mbed Crypto
: install Mbed TLS
cd $HOME
curl -L https://github.com/ARMmbed/mbed-crypto/archive/mbedcrypto-3.1.0.tar.gz | tar -xz
mkdir mbedcrypto
cd mbedcrypto
cmake -G Ninja ../mbed-crypto-mbedcrypto-3.1.0 -DENABLE_PROGRAMS=0 -DENABLE_TESTING=0
curl -sL https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.16.6.tar.gz | tar -xz
mkdir mbedtls-build && cd mbedtls-build
cmake -G Ninja ../mbedtls-mbedtls-2.16.6 -DENABLE_PROGRAMS=0 -DENABLE_TESTING=0
ninja
sudo ninja install
- |
Expand All @@ -60,11 +54,9 @@ script:
- meson build.coverage -Db_coverage=true -Dwerror=true -Dunittest=enabled
- meson build.sanitize -Db_sanitize=address,undefined -Dunittest=enabled
- LDFLAGS='-fuse-ld=lld -L/usr/local/lib' meson build.llvm --native-file mk/native-llvm.txt --buildtype debugoptimized -Dunittest=enabled
- meson build.thumb --cross-file mk/cross-thumb.txt
- cd $TRAVIS_BUILD_DIR/build.coverage && ninja test
- cd $TRAVIS_BUILD_DIR/build.sanitize && ninja test
- cd $TRAVIS_BUILD_DIR/build.llvm && ninja test
- cd $TRAVIS_BUILD_DIR/build.thumb && ninja
- cd $TRAVIS_BUILD_DIR
- build_platform esp8266
- build_platform esp32
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Transports

KeyChain

* Crypto: using [Mbed Crypto](https://github.com/ARMmbed/mbed-crypto) library
* Crypto: using [Mbed TLS](https://github.com/ARMmbed/mbedtls) library
* SHA256: yes
* ECDSA: P-256 curve only
* HMAC-SHA256: no
Expand All @@ -56,7 +56,7 @@ For Linux,
* C++ compiler such as GCC, install Ubuntu package `build-essential`
* [Meson](https://mesonbuild.com/), install pip package `meson`
* [Ninja build system](https://ninja-build.org/), install Ubuntu package `ninja-build`
* [Mbed Crypto](https://github.com/ARMmbed/mbed-crypto), install from source
* [Mbed TLS](https://github.com/ARMmbed/mbedtls), install from source
* [Boost](https://www.boost.org/) header-only libraries, install Ubuntu package `libboost-dev`
* [Google Test](https://github.com/google/googletest), install from source (only needed by unit tests)
* Note: all dependencies are optional, but extra porting work will be necessary
Expand Down
16 changes: 0 additions & 16 deletions mk/cross-thumb.txt

This file was deleted.

2 changes: 1 addition & 1 deletion mk/format-code.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
cd "$( dirname "${BASH_SOURCE[0]}" )"/..
find -name '*.[hc]pp' -or -name '*.ino' | \
xargs clang-format-6.0 -i -style=file
xargs clang-format-8 -i -style=file
6 changes: 3 additions & 3 deletions mk/native-llvm.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[binaries]
c = '/usr/bin/clang-6.0'
cpp = '/usr/bin/clang++-6.0'
c = '/usr/bin/clang-8'
cpp = '/usr/bin/clang++-8'
ld = 'lld'
ar = '/usr/bin/llvm-ar-6.0'
ar = '/usr/bin/llvm-ar-8'
2 changes: 1 addition & 1 deletion src/ndnph/core/simple-queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DynamicSimpleQueue : public SimpleQueue<T>

~DynamicSimpleQueue()
{
delete[] this->template getArray();
delete[] this->getArray();
}
};

Expand Down
85 changes: 43 additions & 42 deletions src/ndnph/packet/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,53 +72,54 @@ class SignedDataRef : public RefRegion<DataObj>
}

encoder.resetFront(const_cast<uint8_t*>(afterSig));
encoder.prependTlv(TT::Data,
[=](Encoder& encoder) {
uint8_t* room = encoder.prependRoom(signedPortion.size());
assert(room != nullptr);
if (room != signedPortion.begin()) {
std::memmove(room, signedPortion.begin(), signedPortion.size());
}
},
[=](Encoder& encoder) {
uint8_t* room = encoder.prependRoom(sigLen);
assert(room != nullptr);
if (room != sigBuf) {
std::memmove(room, sigBuf, sigLen);
}
encoder.prependTypeLength(TT::DSigValue, sigLen);
});
encoder.prependTlv(
TT::Data,
[=](Encoder& encoder) {
uint8_t* room = encoder.prependRoom(signedPortion.size());
assert(room != nullptr);
if (room != signedPortion.begin()) {
std::memmove(room, signedPortion.begin(), signedPortion.size());
}
},
[=](Encoder& encoder) {
uint8_t* room = encoder.prependRoom(sigLen);
assert(room != nullptr);
if (room != sigBuf) {
std::memmove(room, sigBuf, sigLen);
}
encoder.prependTypeLength(TT::DSigValue, sigLen);
});
}

private:
void encodeSignedPortion(Encoder& encoder) const
{
encoder.prepend(obj->name,
[this](Encoder& encoder) {
encoder.prependTlv(
TT::MetaInfo, Encoder::OmitEmpty,
[this](Encoder& encoder) {
if (obj->contentType != detail::DataObj::DefaultContentType) {
encoder.prependTlv(TT::ContentType, tlv::NNI(obj->contentType));
}
},
[this](Encoder& encoder) {
if (obj->freshnessPeriod != detail::DataObj::DefaultFreshnessPeriod) {
encoder.prependTlv(TT::FreshnessPeriod, tlv::NNI(obj->freshnessPeriod));
}
},
[this](Encoder& encoder) {
if (obj->isFinalBlock) {
auto comp = obj->name[-1];
encoder.prependTlv(TT::FinalBlockId,
tlv::Value(comp.tlv(), comp.size()));
}
});
},
[this](Encoder& encoder) {
encoder.prependTlv(TT::Content, Encoder::OmitEmpty, obj->content);
},
m_sigInfo);
encoder.prepend(
obj->name,
[this](Encoder& encoder) {
encoder.prependTlv(
TT::MetaInfo, Encoder::OmitEmpty,
[this](Encoder& encoder) {
if (obj->contentType != detail::DataObj::DefaultContentType) {
encoder.prependTlv(TT::ContentType, tlv::NNI(obj->contentType));
}
},
[this](Encoder& encoder) {
if (obj->freshnessPeriod != detail::DataObj::DefaultFreshnessPeriod) {
encoder.prependTlv(TT::FreshnessPeriod, tlv::NNI(obj->freshnessPeriod));
}
},
[this](Encoder& encoder) {
if (obj->isFinalBlock) {
auto comp = obj->name[-1];
encoder.prependTlv(TT::FinalBlockId, tlv::Value(comp.tlv(), comp.size()));
}
});
},
[this](Encoder& encoder) {
encoder.prependTlv(TT::Content, Encoder::OmitEmpty, obj->content);
},
m_sigInfo);
}

private:
Expand Down
22 changes: 11 additions & 11 deletions src/ndnph/packet/interest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ class ParameterizedInterestRef : public InterestRefBase
void encodeImpl(Encoder& encoder, const Fn& encodeParams) const
{
tlv::Value params;
encoder.prependTlv(TT::Interest,
[this, &params](Encoder& encoder) { encodeName(encoder, params); },
[this](Encoder& encoder) { encodeMiddle(encoder); },
[&](Encoder& encoder) {
const uint8_t* afterParams = encoder.begin();
encodeParams(encoder);
if (!encoder) {
return;
}
params = tlv::Value(encoder.begin(), afterParams);
});
encoder.prependTlv(
TT::Interest, [this, &params](Encoder& encoder) { encodeName(encoder, params); },
[this](Encoder& encoder) { encodeMiddle(encoder); },
[&](Encoder& encoder) {
const uint8_t* afterParams = encoder.begin();
encodeParams(encoder);
if (!encoder) {
return;
}
params = tlv::Value(encoder.begin(), afterParams);
});
}

protected:
Expand Down
25 changes: 13 additions & 12 deletions src/ndnph/packet/lp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ class LpEncodable
encoder.prepend(l3);
return;
}
encoder.prependTlv(TT::LpPacket,
[this](Encoder& encoder) {
if (pitToken != 0) {
encoder.prependTlv(TT::PitToken, tlv::NNI8(pitToken));
}
},
[this](Encoder& encoder) {
if (nack) {
encoder.prepend(nack);
}
},
[this](Encoder& encoder) { encoder.prependTlv(TT::LpPayload, l3); });
encoder.prependTlv(
TT::LpPacket,
[this](Encoder& encoder) {
if (pitToken != 0) {
encoder.prependTlv(TT::PitToken, tlv::NNI8(pitToken));
}
},
[this](Encoder& encoder) {
if (nack) {
encoder.prepend(nack);
}
},
[this](Encoder& encoder) { encoder.prependTlv(TT::LpPayload, l3); });
}

public:
Expand Down
3 changes: 2 additions & 1 deletion tests/mock/bridge-fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class BridgeFixture : public g::Test
}

template<typename InitB, typename CondB, typename FinalB = void (*)()>
void runInThreads(const InitB& initB, const CondB& condB, const FinalB& finalB = [] {})
void runInThreads(
const InitB& initB, const CondB& condB, const FinalB& finalB = [] {})
{
std::atomic_bool stopA(false);
std::thread threadA([&] {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tlv/encoder.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ TEST(Encoder, Prepend)
std::vector<uint8_t> valueE({ 0xE0, 0xE1 });
std::vector<uint8_t> valueF({ 0xF0, 0xF1 });

bool ok = encoder.prepend(MyEncodable<0xA0>(), [](Encoder& encoder) { encoder.prependTlv(0xA1); },
MyEncodable<0xA2>());
bool ok = encoder.prepend(
MyEncodable<0xA0>(), [](Encoder& encoder) { encoder.prependTlv(0xA1); }, MyEncodable<0xA2>());
ok = ok && encoder.prependTlv(0xC0, Encoder::OmitEmpty, tlv::Value(value0.data(), value0.size()),
tlv::Value(value0.data(), value0.size()));
ok = ok && encoder.prependTlv(0xC1, tlv::Value(value0.data(), value0.size()),
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/tlv/ev-decoder.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class Target2 : public Target0
public:
bool decodeFrom(const Decoder::Tlv& input)
{
return EvDecoder::decodeEx(input, {}, EvDecoder::DefaultUnknownCb(),
[](uint32_t type) { return type == 0xA2; },
EvDecoder::def<0xA1>([this](const Decoder::Tlv&) { ++a1; }));
return EvDecoder::decodeEx(
input, {}, EvDecoder::DefaultUnknownCb(), [](uint32_t type) { return type == 0xA2; },
EvDecoder::def<0xA1>([this](const Decoder::Tlv&) { ++a1; }));
}
};

Expand Down

0 comments on commit 8206ad3

Please sign in to comment.