6LoWPAN: Introduce test vectors and improvements (#947)

* 6LoWPAN: Add compression flag to the Context structure.

* IP: Add option to initialize IPv6 header.

* 6LoWPAN: Bugfixes for compression and decompression procedure.

* 6LoWPAN: Add test vectors for 6LoWPAN compression and decompression.
This commit is contained in:
Łukasz Duda
2016-11-09 01:00:08 -08:00
committed by Jonathan Hui
parent c4eff62024
commit ede95a1220
12 changed files with 2252 additions and 348 deletions
+3 -4
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="openthread.configuration.props" />
<Import Project="openthread.configuration.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{FD64BF17-8D36-4578-8D13-77B123BE30D3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
@@ -80,14 +80,13 @@
<ClCompile Include="..\..\tests\unit\test_timer.cpp" />
<ClCompile Include="..\..\tests\unit\test_toolchain.cpp" />
<ClCompile Include="..\..\tests\unit\test_util.cpp" />
<ClCompile Include="..\..\tests\unit\test_vector.c" />
<ClCompile Include="..\..\tests\unit\test_windows.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\tests\unit\test_platform.h" />
<ClInclude Include="..\..\tests\unit\test_lowpan.hpp" />
<ClInclude Include="..\..\tests\unit\test_util.h" />
<ClInclude Include="..\..\tests\unit\test_util.hpp" />
<ClInclude Include="..\..\tests\unit\test_vector.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libopenthread-ncp-uart.vcxproj">
@@ -103,4 +102,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+3 -6
View File
@@ -15,9 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\tests\unit\test_vector.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\tests\unit\test_aes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -62,14 +59,14 @@
<ClInclude Include="..\..\tests\unit\test_platform.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\tests\unit\test_lowpan.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\tests\unit\test_util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\tests\unit\test_util.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\tests\unit\test_vector.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
+7
View File
@@ -44,6 +44,7 @@
#include <net/socket.hpp>
using Thread::Encoding::BigEndian::HostSwap16;
using Thread::Encoding::BigEndian::HostSwap32;
namespace Thread {
@@ -138,6 +139,12 @@ public:
*/
void Init() { mVersionClassFlow.m32[0] = 0; mVersionClassFlow.m8[0] = kVersion6; }
/**
* This method initializes the IPv6 header and sets Version, Traffic Control and Flow Label fields.
*
*/
void Init(uint32_t aVersionClassFlow) { mVersionClassFlow.m32[0] = HostSwap32(aVersionClassFlow); }
/**
* This method indicates whether or not the IPv6 Version is set to 6.
*
+63 -33
View File
@@ -174,6 +174,7 @@ int Lowpan::CompressDestinationIid(const Mac::Address &aMacAddr, const Ip6::Addr
int Lowpan::CompressMulticast(const Ip6::Address &aIpAddr, uint16_t &aHcCtl, uint8_t *aBuf)
{
uint8_t *cur = aBuf;
Context multicastContext;
aHcCtl |= kHcMulticast;
@@ -181,12 +182,14 @@ int Lowpan::CompressMulticast(const Ip6::Address &aIpAddr, uint16_t &aHcCtl, uin
{
if (aIpAddr.mFields.m8[i])
{
// Check if multicast address can be compressed to 8-bits (ff02::00xx)
if (aIpAddr.mFields.m8[1] == 0x02 && i >= 15)
{
aHcCtl |= kHcDstAddrMode3;
cur[0] = aIpAddr.mFields.m8[15];
cur++;
}
// Check if multicast address can be compressed to 32-bits (ffxx::00xx:xxxx)
else if (i >= 13)
{
aHcCtl |= kHcDstAddrMode2;
@@ -194,7 +197,8 @@ int Lowpan::CompressMulticast(const Ip6::Address &aIpAddr, uint16_t &aHcCtl, uin
memcpy(cur + 1, aIpAddr.mFields.m8 + 13, 3);
cur += 4;
}
else if (i >= 9)
// Check if multicast address can be compressed to 48-bits (ffxx::00xx:xxxx:xxxx)
else if (i >= 11)
{
aHcCtl |= kHcDstAddrMode1;
cur[0] = aIpAddr.mFields.m8[1];
@@ -203,8 +207,21 @@ int Lowpan::CompressMulticast(const Ip6::Address &aIpAddr, uint16_t &aHcCtl, uin
}
else
{
memcpy(cur, aIpAddr.mFields.m8, sizeof(Ip6::Address));
cur += sizeof(Ip6::Address);
// Check if multicast address can be compressed using Context ID 0.
if (mNetworkData.GetContext(0, multicastContext) == kThreadError_None &&
multicastContext.mPrefixLength == aIpAddr.mFields.m8[3] &&
memcmp(multicastContext.mPrefix, aIpAddr.mFields.m8 + 4, 8) == 0)
{
aHcCtl |= kHcDstAddrContext | kHcDstAddrMode0;
memcpy(cur, aIpAddr.mFields.m8 + 1, 2);
memcpy(cur + 2, aIpAddr.mFields.m8 + 12, 4);
cur += 6;
}
else
{
memcpy(cur, aIpAddr.mFields.m8, sizeof(Ip6::Address));
cur += sizeof(Ip6::Address);
}
}
break;
@@ -223,16 +240,20 @@ int Lowpan::Compress(Message &aMessage, const Mac::Address &aMacSource, const Ma
Context srcContext, dstContext;
bool srcContextValid = true, dstContextValid = true;
uint8_t nextHeader;
uint8_t ecn = 0;
uint8_t dscp = 0;
aMessage.Read(aMessage.GetOffset(), sizeof(ip6Header), &ip6Header);
if (mNetworkData.GetContext(ip6Header.GetSource(), srcContext) != kThreadError_None)
if (mNetworkData.GetContext(ip6Header.GetSource(), srcContext) != kThreadError_None ||
srcContext.mCompressFlag == false)
{
mNetworkData.GetContext(0, srcContext);
srcContextValid = false;
}
if (mNetworkData.GetContext(ip6Header.GetDestination(), dstContext) != kThreadError_None)
if (mNetworkData.GetContext(ip6Header.GetDestination(), dstContext) != kThreadError_None ||
dstContext.mCompressFlag == false)
{
mNetworkData.GetContext(0, dstContext);
dstContextValid = false;
@@ -251,35 +272,42 @@ int Lowpan::Compress(Message &aMessage, const Mac::Address &aMacSource, const Ma
cur++;
}
// Traffic Class
if (((ip6HeaderBytes[0] & 0x0f) == 0) && ((ip6HeaderBytes[1] & 0xf0) == 0))
{
hcCtl |= kHcTrafficClass;
}
dscp = ((ip6HeaderBytes[0] << 2) & 0x3c) | (ip6HeaderBytes[1] >> 6);
ecn = (ip6HeaderBytes[1] << 2) & 0xc0;
// Flow Label
if (((ip6HeaderBytes[1] & 0x0f) == 0) && ((ip6HeaderBytes[2]) == 0) && ((ip6HeaderBytes[3]) == 0))
{
hcCtl |= kHcFlowLabel;
}
if ((hcCtl & kHcTrafficFlowMask) != kHcTrafficFlow)
{
cur[0] = ((ip6HeaderBytes[1] >> 4) << 6) & 0xff;
if ((hcCtl & kHcTrafficClass) == 0)
if (dscp == 0 && ecn == 0)
{
cur[0] |= ((ip6HeaderBytes[0] & 0x0f) << 2) | (ip6HeaderBytes[1] >> 6);
// Elide Flow Label and Traffic Class.
hcCtl |= kHcTrafficClass | kHcFlowLabel;
}
else
{
// Elide Flow Label and carry Traffic Class in-line.
hcCtl |= kHcFlowLabel;
cur[0] = ecn | dscp;
cur++;
}
}
else if (dscp == 0)
{
// Carry Flow Label and ECN only with 2-bit padding.
hcCtl |= kHcTrafficClass;
if ((hcCtl & kHcFlowLabel) == 0)
{
cur[0] |= ip6HeaderBytes[1] & 0x0f;
cur[1] = ip6HeaderBytes[2];
cur[2] = ip6HeaderBytes[3];
cur += 3;
}
cur[0] = ecn | (ip6HeaderBytes[1] & 0x0f);
memcpy(cur + 1, ip6HeaderBytes + 2, 2);
cur += 3;
}
else
{
// Carry Flow Label and Traffic Class in-line.
cur[0] = ecn | dscp;
cur[1] = ip6HeaderBytes[1] & 0x0f;
memcpy(cur + 2, ip6HeaderBytes + 2, 2);
cur += 4;
}
// Next Header
@@ -703,17 +731,17 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
break;
}
if ((hcCtl & kHcSrcAddrContext) == 0)
if ((hcCtl & kHcSrcAddrModeMask) != kHcSrcAddrMode0)
{
if ((hcCtl & kHcSrcAddrModeMask) != 0)
if ((hcCtl & kHcSrcAddrContext) == 0)
{
ip6Header.GetSource().mFields.m16[0] = HostSwap16(0xfe80);
}
}
else
{
VerifyOrExit(srcContextValid,);
CopyContext(srcContext, ip6Header.GetSource());
else
{
VerifyOrExit(srcContextValid,);
CopyContext(srcContext, ip6Header.GetSource());
}
}
if ((hcCtl & kHcMulticast) == 0)
@@ -723,6 +751,7 @@ int Lowpan::DecompressBaseHeader(Ip6::Header &ip6Header, const Mac::Address &aMa
switch (hcCtl & kHcDstAddrModeMask)
{
case kHcDstAddrMode0:
VerifyOrExit((hcCtl & kHcDstAddrContext) == 0,);
VerifyOrExit(remaining >= sizeof(Ip6::Address),);
memcpy(&ip6Header.GetDestination(), cur, sizeof(ip6Header.GetDestination()));
cur += sizeof(Ip6::Address);
@@ -1019,6 +1048,7 @@ int Lowpan::Decompress(Message &aMessage, const Mac::Address &aMacSource, const
compressed = (((static_cast<uint16_t>(cur[0]) << 8) | cur[1]) & kHcNextHeader) != 0;
VerifyOrExit((rval = DecompressBaseHeader(ip6Header, aMacSource, aMacDest, cur, remaining)) >= 0,);
cur += rval;
remaining -= rval;
+1
View File
@@ -72,6 +72,7 @@ struct Context
const uint8_t *mPrefix; ///< A pointer to the prefix.
uint8_t mPrefixLength; ///< The prefix length.
uint8_t mContextId; ///< The Context ID.
bool mCompressFlag; ///< The Context compression flag.
};
/**
+4
View File
@@ -141,6 +141,7 @@ ThreadError Leader::GetContext(const Ip6::Address &aAddress, Lowpan::Context &aC
aContext.mPrefix = mMle.GetMeshLocalPrefix();
aContext.mPrefixLength = 64;
aContext.mContextId = 0;
aContext.mCompressFlag = true;
}
for (NetworkDataTlv *cur = reinterpret_cast<NetworkDataTlv *>(mTlvs);
@@ -171,6 +172,7 @@ ThreadError Leader::GetContext(const Ip6::Address &aAddress, Lowpan::Context &aC
aContext.mPrefix = prefix->GetPrefix();
aContext.mPrefixLength = prefix->GetPrefixLength();
aContext.mContextId = contextTlv->GetContextId();
aContext.mCompressFlag = contextTlv->IsCompress();
}
}
@@ -188,6 +190,7 @@ ThreadError Leader::GetContext(uint8_t aContextId, Lowpan::Context &aContext)
aContext.mPrefix = mMle.GetMeshLocalPrefix();
aContext.mPrefixLength = 64;
aContext.mContextId = 0;
aContext.mCompressFlag = true;
ExitNow(error = kThreadError_None);
}
@@ -216,6 +219,7 @@ ThreadError Leader::GetContext(uint8_t aContextId, Lowpan::Context &aContext)
aContext.mPrefix = prefix->GetPrefix();
aContext.mPrefixLength = prefix->GetPrefixLength();
aContext.mContextId = contextTlv->GetContextId();
aContext.mCompressFlag = contextTlv->IsCompress();
ExitNow(error = kThreadError_None);
}
+2 -2
View File
@@ -34,9 +34,9 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
#
noinst_HEADERS = \
test_platform.h \
test_lowpan.hpp \
test_util.h \
test_util.hpp \
test_vector.h \
$(NULL)
#
@@ -130,7 +130,7 @@ test_link_quality_LDADD = $(COMMON_LDADD)
test_link_quality_SOURCES = test_platform.cpp test_link_quality.cpp
test_lowpan_LDADD = $(COMMON_LDADD)
test_lowpan_SOURCES = test_platform.cpp test_lowpan.cpp test_util.cpp test_vector.c
test_lowpan_SOURCES = test_platform.cpp test_lowpan.cpp test_util.cpp
test_mac_frame_LDADD = $(COMMON_LDADD)
test_mac_frame_SOURCES = test_platform.cpp test_mac_frame.cpp
+1886 -69
View File
File diff suppressed because it is too large Load Diff
+282
View File
@@ -0,0 +1,282 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TEST_LOWPAN_HPP
#define TEST_LOWPAN_HPP
#include <stdint.h>
#include <openthread.h>
#include <mac/mac.hpp>
#include <net/ip6_headers.hpp>
#include <thread/thread_netif.hpp>
#include <thread/lowpan.hpp>
namespace Thread {
class TestIphcVector
{
public:
enum
{
kContextUnused = 255,
kPayloadMaxLength = 512
};
struct Payload
{
uint8_t mData[kPayloadMaxLength];
uint16_t mLength;
};
/**
* Default constructor for the object.
*
*/
TestIphcVector(const char *aTestName) {
memset(this, 0, sizeof(*this));
mTestName = aTestName;
mSrcContext.mContextId = kContextUnused;
mDstContext.mContextId = kContextUnused;
}
/**
* This method sets long MAC source address.
*
* @param aAddress Pointer to the long MAC address.
*
*/
void SetMacSource(const uint8_t *aAddress) {
mMacSource.mLength = OT_EXT_ADDRESS_SIZE;
memcpy(&mMacSource.mExtAddress, aAddress, mMacSource.mLength);
}
/**
* This method sets short MAC source address.
*
* @param aAddress Short MAC address.
*
*/
void SetMacSource(uint16_t aAddress) {
mMacSource.mLength = 2;
mMacSource.mShortAddress = aAddress;
}
/**
* This method sets long MAC destination address.
*
* @param aAddress Pointer to the long MAC address.
*
*/
void SetMacDestination(const uint8_t *aAddress) {
mMacDestination.mLength = OT_EXT_ADDRESS_SIZE;
memcpy(&mMacDestination.mExtAddress, aAddress, mMacDestination.mLength);
}
/**
* This method sets short MAC destination address.
*
* @param aAddress Short MAC address.
*
*/
void SetMacDestination(uint16_t aAddress) {
mMacDestination.mLength = 2;
mMacDestination.mShortAddress = aAddress;
}
/**
* This method initializes IPv6 Header.
*
* @param aVersionClassFlow Value of the Version, Traffic class and Flow control fields.
* @param aPayloadLength Value of the payload length field.
* @param aNextHeader Value of the next header field.
* @param aHopLimit Value of the hop limit field.
* @param aSource String represents IPv6 source address.
* @param aDestination String represents IPv6 destination address.
*
*/
void SetIpHeader(uint32_t aVersionClassFlow, uint16_t aPayloadLength,
Ip6::IpProto aNextHeader, uint8_t aHopLimit,
const char *aSource, const char *aDestination) {
mIpHeader.Init(aVersionClassFlow);
mIpHeader.SetPayloadLength(aPayloadLength);
mIpHeader.SetNextHeader(aNextHeader);
mIpHeader.SetHopLimit(aHopLimit);
mIpHeader.GetSource().FromString(aSource);
mIpHeader.GetDestination().FromString(aDestination);
}
/**
* This method initializes IPv6 Encapsulated Header.
*
* @param aVersionClassFlow Value of the Version, Traffic class and Flow control fields.
* @param aPayloadLength Value of the payload length field.
* @param aNextHeader Value of the next header field.
* @param aHopLimit Value of the hop limit field.
* @param aSource String represents IPv6 source address.
* @param aDestination String represents IPv6 destination address.
*
*/
void SetIpTunneledHeader(uint32_t aVersionClassFlow, uint16_t aPayloadLength,
Ip6::IpProto aNextHeader, uint8_t aHopLimit,
const char *aSource, const char *aDestination) {
mIpTunneledHeader.Init(aVersionClassFlow);
mIpTunneledHeader.SetPayloadLength(aPayloadLength);
mIpTunneledHeader.SetNextHeader(aNextHeader);
mIpTunneledHeader.SetHopLimit(aHopLimit);
mIpTunneledHeader.GetSource().FromString(aSource);
mIpTunneledHeader.GetDestination().FromString(aDestination);
}
/**
* This method initializes IPv6 Extension Header.
*
* @param aExtHeader Pointer to the extension header data.
* @param aExtHeaderLength Length of the extension header data.
*
*/
void SetExtHeader(const uint8_t *aExtHeader, uint16_t aExtHeaderLength) {
memcpy(mExtHeader.mData, aExtHeader, aExtHeaderLength);
mExtHeader.mLength = aExtHeaderLength;
}
/**
* This method initializes UDP Header.
*
* @param aSource Value of the source port.
* @param aDestination Value of the destination port.
* @param aLength Value of the length field.
* @param aChecksum Value of the checksum field.
*
*/
void SetUDPHeader(uint16_t aSource, uint16_t aDestination, uint16_t aLength,
uint16_t aChecksum) {
mUdpHeader.SetSourcePort(aSource);
mUdpHeader.SetDestinationPort(aDestination);
mUdpHeader.SetLength(aLength);
mUdpHeader.SetChecksum(aChecksum);
}
/**
* This method initializes LOWPAN_IPHC Header.
*
* @param aIphc Pointer to the LOWPAN_IPHC header.
* @param aIphcLength Length of the LOWPAN_IPHC header.
*
*/
void SetIphcHeader(const uint8_t *aIphc, uint16_t aIphcLength) {
memcpy(mIphcHeader.mData, aIphc, aIphcLength);
mIphcHeader.mLength = aIphcLength;
}
/**
* This method sets the expect result of the compression / decompression procedure.
*
* @param aError Expected result.
*
*/
void SetError(ThreadError aError) { mError = aError; }
/**
* This method initializes IPv6 Payload (uncompressed data).
*
* @param aPayload Pointer to the payload data.
* @param aLength Length of the payload data.
*
*/
void SetPayload(const uint8_t *aPayload, uint16_t aLength) {
memcpy(mPayload.mData, aPayload, aLength);
mPayload.mLength = aLength;
}
/**
* This method sets the offset from the beginning of the IPv6 header to the uncompressed
* payload.
*
* @param aPayloadOffset The offset from the beginning of the IPv6 header to the uncompressed
* payload.
*
*/
void SetPayloadOffset(uint16_t aPayloadOffset) { mPayloadOffset = aPayloadOffset; }
/**
* This method returns compressed LOWPAN_IPHC frame.
*
* @returns The compressed stream.
*
*/
void GetCompressedStream(uint8_t *aIphc, uint16_t &aIphcLength);
/**
* This method returns message object with the uncompressed IPv6 packet.
*
* @returns The message object with the uncompressed IPv6 packet.
*
*/
void GetUncompressedStream(Message &aMessage);
/**
* This method returns data with the uncompressed IPv6 packet.
*
* @returns The data with the uncompressed IPv6 packet.
*
*/
void GetUncompressedStream(uint8_t *aIp6, uint16_t &aIp6Length);
/**
* This fields represent uncompressed IPv6 packet.
*
*/
Mac::Address mMacSource;
Mac::Address mMacDestination;
Ip6::Header mIpHeader;
Payload mExtHeader;
Ip6::Header mIpTunneledHeader;
Ip6::UdpHeader mUdpHeader;
/**
* This fields represent compressed IPv6 packet.
*
*/
Payload mIphcHeader;
uint16_t mPayloadOffset;
Lowpan::Context mSrcContext;
Lowpan::Context mDstContext;
/**
* General purpose fields.
*
*/
Payload mPayload;
ThreadError mError;
const char *mTestName;
};
} // namespace Thread
#endif // TEST_LOWPAN_HPP
+1 -3
View File
@@ -55,7 +55,7 @@ void otTestPrintHex(uint8_t *aBuffer, int aLength)
if (i % 16 == 7) { printf(" "); }
if (i % 16 == 15) { printf("\n"); }
if (i % 16 == 15 && aLength != i + 1) { printf("\n"); }
}
printf("\n");
@@ -70,5 +70,3 @@ void otTestPrintHex(std::vector<uint8_t> &aBytes)
{
otTestPrintHex((uint8_t *)&aBytes[0], static_cast<int>(aBytes.size()));
}
-157
View File
@@ -1,157 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "test_vector.h"
test_lowpan_vector_t sTestVectorLowpan[] =
{
{
// I1_t1_AF_pass.pcap
.mTest = "LL64 unicast ICMP ping request",
.mCompressed =
"61 cc 1d ce fa 03 00 00 00 00 0a 6e 14 01 00 00 "
"00 00 0a 6e 14 7a 33 3a 80 00 30 be 00 00 00 00 "
"41 42 43 44 45 46 47 48 48 ff",
.mRaw =
"60 00 00 00 00 10 3a 40 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 01 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 03 80 00 30 be 00 00 00 00 "
"41 42 43 44 45 46 47 48",
.mMac =
{
.mSrc = "14 6e 0a 00 00 00 00 01",
.mDst = "14 6e 0a 00 00 00 00 03",
.mPanid = 0xFACE,
},
.mSrc = "fe80::166e:a00:0:1",
.mDst = "fe80::166e:a00:0:3",
.mHops = 64
},
{
// I1_t1_AF_pass.pcap
.mTest = "LL64 unicast ICMP ping reply",
.mCompressed =
"61 cc 07 ce fa 01 00 00 00 00 0a 6e 14 03 00 00 "
"00 00 0a 6e 14 7a 33 3a 81 00 2f be 00 00 00 00 "
"41 42 43 44 45 46 47 48 37 59",
.mRaw =
"60 00 00 00 00 10 3a 40 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 03 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 01 81 00 2f be 00 00 00 00 "
"41 42 43 44 45 46 47 48",
.mMac =
{
.mSrc = "14 6e 0a 00 00 00 00 03",
.mDst = "14 6e 0a 00 00 00 00 01",
.mPanid = 0xFACE,
},
},
{
// I1_t2_AF_AS_pass.pcap
.mTest = "LL16 unicast ICMP ping request",
.mCompressed =
"61 88 13 ce fa 00 10 00 00 7a 33 3a 80 00 63 9e "
"00 00 00 00 41 42 43 44 45 46 47 48 84 5f",
.mRaw =
"60 00 00 00 00 10 3a 40 fe 80 00 00 00 00 00 00 "
"00 00 00 ff fe 00 00 00 fe 80 00 00 00 00 00 00 "
"00 00 00 ff fe 00 10 00 80 00 63 9e 00 00 00 00 "
"41 42 43 44 45 46 47 48"
},
{
// I1_t2_AF_AS_pass.pcap
.mTest = "LL16 unicast ICMP ping reply",
.mCompressed =
"61 88 0f ce fa 00 00 00 10 7a 33 3a 81 00 62 9e "
"00 00 00 00 41 42 43 44 45 46 47 48 e0 35",
.mRaw =
"60 00 00 00 00 10 3a 40 fe 80 00 00 00 00 00 00 "
"00 00 00 ff fe 00 10 00 fe 80 00 00 00 00 00 00 "
"00 00 00 ff fe 00 00 00 81 00 62 9e 00 00 00 00 "
"41 42 43 44 45 46 47 48"
},
{
// I1_t3_SF_pass.pcap
.mTest = "LL64 multicast FF02::1 ICMP ping request",
.mCompressed =
"41 c8 99 ce fa ff ff 01 00 00 00 00 0a 6e 14 7a "
"3b 3a 01 80 00 54 b4 40 41 42 43 44 45 46 47 68 "
"44",
.mRaw =
"60 00 00 00 00 0c 3a 40 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 01 ff 02 00 00 00 00 00 00 "
"00 00 00 00 00 00 00 01 80 00 54 b4 40 41 42 43 "
"44 45 46 47 "
},
{
// I1_t3_SF_pass.pcap
.mTest = "LL64 multicast FF02::1 ICMP ping reply",
.mCompressed =
"61 cc fc ce fa 01 00 00 00 00 0a 6e 14 02 00 00 "
"00 00 0a 6e 14 7a 33 3a 81 00 33 c7 40 41 42 43 "
"44 45 46 47 1a 80",
.mRaw =
"60 00 00 00 00 0c 3a 40 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 02 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 01 81 00 33 c7 40 41 42 43 "
"44 45 46 47"
},
{
// I1_t4_FS_pass.pcap
.mTest = "LL16 multicast FF02::1 ICMP ping request",
.mCompressed =
"41 88 df ce fa ff ff 00 08 7a 3b 3a 01 80 00 76 "
"0e 00 01 00 04 50 50 50 50 50 50 50 50 50 50 50 "
"50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 "
"50 50 50 50 50 a7 d2",
.mRaw =
"60 00 00 00 00 28 3a 40 fe 80 00 00 00 00 00 00 "
"00 00 00 ff fe 00 08 00 ff 02 00 00 00 00 00 00 "
"00 00 00 00 00 00 00 01 80 00 76 0e 00 01 00 04 "
"50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 "
"50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 "
},
{
// I1_t4_FS_pass.pcap
.mTest = "LL16 multicast FF02::1 ICMP ping reply",
.mCompressed =
"61 c8 41 ce fa 00 08 03 00 00 00 00 0a 6e 14 7a "
"33 3a 81 00 55 20 00 01 00 04 50 50 50 50 50 50 "
"50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 "
"50 50 50 50 50 50 50 50 50 50 ab 56",
.mRaw =
"60 00 00 00 00 28 3a 40 fe 80 00 00 00 00 00 00 "
"16 6e 0a 00 00 00 00 03 fe 80 00 00 00 00 00 00 "
"00 00 00 ff fe 00 08 00 81 00 55 20 00 01 00 04 "
"50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 "
"50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 "
},
};
const unsigned sTestVectorLowpanLen =
sizeof(sTestVectorLowpan) / sizeof(sTestVectorLowpan[0]);
-74
View File
@@ -1,74 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TEST_VECTOR_H
#define TEST_VECTOR_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef const struct
{
const char *mResult;
uint16_t mFcf;
uint16_t mSeq;
uint16_t mPanid; ///< default panid is destination panid
const char *mSrc;
const char *mDst;
} test_mac_vector_t;
typedef const struct
{
const char *mTest;
const char *mCompressed;
const char *mRaw;
const char *mPrefix;
test_mac_vector_t mMac;
uint16_t mTraffic;
uint16_t mFlow;
uint16_t mHops;
const char *mSrc;
const char *mDst;
} test_lowpan_vector_t;
extern test_lowpan_vector_t sTestVectorLowpan[];
extern const unsigned sTestVectorLowpanLen;
#ifdef __cplusplus
}
#endif
#endif