Commit 694cd370 authored by filatov's avatar filatov
Browse files

clean up 6LoWPAN repository structure

parents
Loading
Loading
Loading
Loading
+73 KiB

File added.

No diff preview for this file type.

+133 KiB

File added.

No diff preview for this file type.

6lowpan.tcproj

0 → 100644
+238 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<solution>
 <scripts>
  <items>
   <script>
    <name>Ats6lowpan</name>
    <file>ttcn/Ats6lowpan/Ats6lowpan.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>Ats6lowpanParameters</name>
    <file>ttcn/Ats6lowpan/Ats6lowpanParameters.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_AbstractData</name>
    <file>ttcn/LibCommon/LibCommon_AbstractData.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_BasicTypesAndValues</name>
    <file>ttcn/LibCommon/LibCommon_BasicTypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_DataStrings</name>
    <file>ttcn/LibCommon/LibCommon_DataStrings.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_Sync</name>
    <file>ttcn/LibCommon/LibCommon_Sync.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_SyncExamples</name>
    <file>ttcn/LibCommon/LibCommon_SyncExamples.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_TextStrings</name>
    <file>ttcn/LibCommon/LibCommon_TextStrings.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_Time</name>
    <file>ttcn/LibCommon/LibCommon_Time.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibCommon_VerdictControl</name>
    <file>ttcn/LibCommon/LibCommon_VerdictControl.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_6lowpan_Interface</name>
    <file>ttcn/LibIpv6/Lib6lowpan/LibIpv6_6lowpan_Interface.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_6lowpan_TypesAndValues</name>
    <file>ttcn/LibIpv6/Lib6lowpan/LibIpv6_6lowpan_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2460Root_Functions</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2460Root_Functions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2460Root_Templates</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2460Root_Templates.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2460Root_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2460Root_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2461NeighborDiscovery_Functions</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2461NeighborDiscovery_Functions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2461NeighborDiscovery_Templates</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2461NeighborDiscovery_Templates.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2461NeighborDiscovery_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2461NeighborDiscovery_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2462StatelessAddressAutoconf_Functions</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2462StatelessAddressAutoconf_Functions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2462StatelessAddressAutoconf_Templates</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2462StatelessAddressAutoconf_Templates.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2462StatelessAddressAutoconf_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2462StatelessAddressAutoconf_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2463Icmpv6_Functions</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2463Icmpv6_Functions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2463Icmpv6_Templates</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2463Icmpv6_Templates.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2463Icmpv6_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2463Icmpv6_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2894RouterRenumbering_Functions</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2894RouterRenumbering_Functions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc2894RouterRenumbering_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibCore/LibIpv6_Rfc2894RouterRenumbering_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_RfcXXXXMIPv6_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibMobility/LibIpv6_RfcXXXXMIPv6_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_ExternalFunctions</name>
    <file>ttcn/LibIpv6/LibMultiRfcs/LibIpv6_ExternalFunctions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Interface</name>
    <file>ttcn/LibIpv6/LibMultiRfcs/LibIpv6_Interface.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_ModuleParameters</name>
    <file>ttcn/LibIpv6/LibMultiRfcs/LibIpv6_ModuleParameters.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_MultiRfcs_Functions</name>
    <file>ttcn/LibIpv6/LibMultiRfcs/LibIpv6_MultiRfcs_Functions.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_MultiRfcs_Templates</name>
    <file>ttcn/LibIpv6/LibMultiRfcs/LibIpv6_MultiRfcs_Templates.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_MultiRfcs_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibMultiRfcs/LibIpv6_MultiRfcs_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc0768Udp_Templates</name>
    <file>ttcn/LibIpv6/LibUdp/LibIpv6_Rfc0768Udp_Templates.ttcn</file>
    <type>ttcn3</type>
   </script>
   <script>
    <name>LibIpv6_Rfc0768Udp_TypesAndValues</name>
    <file>ttcn/LibIpv6/LibUdp/LibIpv6_Rfc0768Udp_TypesAndValues.ttcn</file>
    <type>ttcn3</type>
   </script>
  </items>
 </scripts>
 <verstool />
 <sut>
  <exe>__build__/default/Ats6lowpan_SUT </exe>
  <target>__build__/default/Ats6lowpan_SUT</target>
 </sut>
 <codec_rules>CodecRules_6lowpan.txt</codec_rules>
 <ExternalAttributeFiles>
  <items />
 </ExternalAttributeFiles>
 <ModuleParFiles>
  <items />
 </ModuleParFiles>
 <TestcaseSelections>
  <items />
 </TestcaseSelections>
 <TestCampaigns>
  <items />
 </TestCampaigns>
 <ttcn3_settings>
  <tc_block />
  <ttcn3_version>Ttcn3_2011</ttcn3_version>
  <ext_codec />
  <ext_cdpath>__build__/default/libAts6lowpan_CD.so</ext_cdpath>
  <asn>BER</asn>
  <dll_timeout>10</dll_timeout>
  <port>7777</port>
  <ctime>60</ctime>
  <sa_count>1</sa_count>
  <rtime>20</rtime>
  <codec_type>dll</codec_type>
  <enc>
   <plain>
    <byte_order>le</byte_order>
    <signed />
    <int>dword</int>
    <float>double</float>
    <custom_int>8</custom_int>
    <string>null</string>
    <custom_str>32</custom_str>
    <char>U16</char>
    <bool>dword</bool>
    <bin>dword</bin>
    <custom_bin>16</custom_bin>
    <align>1</align>
    <coll>word</coll>
    <str_unit>bytes</str_unit>
    <pad />
    <str_end>\r\n</str_end>
    <uni_end>\r\n</uni_end>
    <any>none</any>
   </plain>
  </enc>
  <no_bs_dq />
  <length-form>definite</length-form>
 </ttcn3_settings>
</solution>
 No newline at end of file

CD/6lowpan-codets.cpp

0 → 100644
+274 −0
Original line number Original line Diff line number Diff line
#include "gen_classes.h"

// 6lowpan codec implementation
//
// Please read the Codec Generation section of the T3DevKit documentation in
// order to understand how this CoDec is designed.
//
// --->  http://t3devkit.gforge.inria.fr/doc/userref/
//

namespace t3devlib {
namespace gen {


void SixLowpanFrame::PreEncode (Buffer& buff) throw (EncodeError)
{
	UInt8 u8;

	u8.SetValue (Get_hwSrc().GetLength() / 8);
	u8.Encode (buff);

	u8.SetValue (Get_hwDst().GetLength() / 8);
	u8.Encode (buff);
}

void SixLowpanFrame::PreDecodeField (int id, Buffer& buff) throw (DecodeError)
{
	UInt8 u8;
	static bool all_hyp_done;

	if (id == id_hwSrc) {
		u8.Decode (buff);
		SetHypFieldLength (id_hwSrc, u8.GetValue()*8);

		u8.Decode (buff);
		SetHypFieldLength (id_hwDst, u8.GetValue()*8);

		all_hyp_done = false;
		return;
	}
	
	if (all_hyp_done)
		return;
	
	if (buff.GetBitsLeft() < 8) {
		if ((id >= id_mesh) && (GetHypFieldIsPresent (id) < 0))
		{
			SetHypFieldIsPresent (id, 0);
		}
		return;
	}

	// read the first byte (dispatch)
	int position = buff.GetPosition();
	u8.Decode (buff);
	buff.SetPosition (position);

	uint8_t dispatch = u8.GetValue();
	bool is_present = false;
	
	switch (id)
	{
	case id_mesh:
		is_present = ((dispatch & 0xc0) == 0x80);	// 10  xxxxxx	MESH
		break;

	case id_broadcast:
		is_present = (dispatch == 0x50);		// 01  010000	LOWPAN_BC0
		break;

	case id_frag:
		is_present = ((dispatch & 0xd8) == 0xc0);	// 11  000xxx	FRAG1
								// 11  100xxx	FRAGN
		if (is_present)
		{
			SetHypFieldIsPresent (id_hc,		0);
			SetHypFieldIsPresent (id_dispatch,	0);
			SetHypFieldIsPresent (id_ipv6,		0);
			SetHypFieldIsPresent (id_payload,	1);
			all_hyp_done = true;
		}
		break;

	case id_hc:
		is_present = ((dispatch & 0xe0) == 0x60);	// 01  1xxxxx	HC
		if (is_present) {
			SetHypFieldIsPresent (id_dispatch,	0);
			SetHypFieldIsPresent (id_ipv6,		0);
			SetHypFieldIsPresent (id_payload,	1);
			all_hyp_done = true;
		}
		break;

	case id_dispatch:
		is_present = (dispatch == 0x41);		// 01  000001	Uncompressed IPv6
		if (is_present) {
			SetHypFieldIsPresent (id_ipv6,		1);
			SetHypFieldIsPresent (id_payload,	0);
		} else {
			SetHypFieldIsPresent (id_ipv6,		0);
			SetHypFieldIsPresent (id_payload,	1);
		}
		all_hyp_done = true;
		break;
	}

	SetHypFieldIsPresent (id, (is_present ? 1 : 0));
}

static int decode_length_unicast (int ac, int am)
{
	switch (am)
	{
	case 0:
		return ac ? 0 : 128;
	case 1:
		return 64;
	case 2:
		return 16;
	case 3:
		return 0;
	}
}

void SixLowpanHC::PreDecode (Buffer& buff) throw (DecodeError)
{
	// reset hypsize
	SetHypSize (-1);
}
void SixLowpanHCHeader::PreDecode (Buffer& buff) throw (DecodeError)
{
	int position = buff.GetPosition();
	UInt8 u8;
	u8.Decode (buff);
	buff.SetPosition (position);

	uint8_t dispatch = u8.GetValue();

	if ((dispatch & 0xe0) == 0x60)
	{
		SetHypChosenId (id_iphc);
	}
	else if ((dispatch & 0xf0) == 0xe0)
	{
		SetHypChosenId (id_ipext);
	}
	else if ((dispatch & 0xf8) == 0xf0)
	{
		SetHypChosenId (id_udp);
	}
}

void SixLowpanIPHC::PreDecodeField (int id, Buffer& buff) throw (DecodeError)
{
	if (id == id_sci) {
		// ECN + DSCP + Flow Label
		uint8_t tf = Get_tf().GetValue();


		SetHypFieldIsPresent (id_inline_ecn,	(tf<3) ? 1 : 0);
		SetHypFieldIsPresent (id_inline_dscp,	((tf%2) == 0) ? 1 : 0);

		uint8_t fl_present = (tf<2) ? 1 : 0;
		SetHypFieldIsPresent (id_inline_tf_pad,	fl_present);
		SetHypFieldIsPresent (id_inline_fl,	fl_present);
		if (fl_present)
			SetHypFieldLength    (id_inline_tf_pad,	tf ? 2 : 4);

		// Next header
		if (Get_nh().GetValue()) {
			// elided
			SetHypFieldIsPresent (id_inline_nh,	0);
		} else {
			// inline
			SetHypFieldIsPresent (id_inline_nh,	1);

			// no NHC header
			SixLowpanHC::SetHypSize (-2);
		}

		// Hop limit
		SetHypFieldIsPresent (id_inline_hl,	Get_hl().GetValue() ? 0 : 1);

		// CID
		uint8_t cid_present = Get_cid().GetValue() ? 1 : 0;
		SetHypFieldIsPresent (id_sci, cid_present);
		SetHypFieldIsPresent (id_dci, cid_present);
	
		// Source address
		int src_len = decode_length_unicast (Get_sac().GetValue(), Get_sam().GetValue());
		int src_present = src_len ? 1 : 0;
		SetHypFieldIsPresent (id_inline_src, src_present);
		if (src_present)
			SetHypFieldLength (id_inline_src, src_len);

		// Destination address
		int dst_len;
		int dam = Get_dam().GetValue();
		int dac = Get_dac().GetValue();
		if (!Get_m().GetValue()) {
			// unicast
			dst_len = decode_length_unicast (dac, dam);
		} else {
			// multicast
			if (dac == 0)
			{
				static const uint8_t  mcast_length[] = {128, 48, 32, 8};
				dst_len = mcast_length[dam];
			} else {
				dst_len = 48;
			}
		}
		int dst_present = dst_len ? 1 : 0;
		SetHypFieldIsPresent (id_inline_dst, dst_present);
		if (dst_present)
			SetHypFieldLength (id_inline_dst, dst_len);
	}
}

void SixLowpanNHCIPExt::PostDecodeField (int id, Buffer& buff) throw (DecodeError)
{
	if (id == id_nh)
	{
		if (Get_nh().GetValue())
		{
			// elided
			SetHypFieldIsPresent (id_inline_nh,	0);
		} else {
			// inline
			SetHypFieldIsPresent (id_inline_nh,	1);

			// no NHC header
			SixLowpanHC::SetHypSize (-2);
		}
	}
}

void SixLowpanNHCUDP::PostDecodeField (int id, Buffer& buff) throw (DecodeError)
{
	if (id == id_p)
	{
		// checksum
		SetHypFieldIsPresent (id_inline_checksum,
			(Get_c().GetValue() ? 0 : 1));

		// ports
		switch (Get_p().GetValue())
		{
		case 0:
			SetHypFieldLength (id_inline_sport, 16);
			SetHypFieldLength (id_inline_dport, 16);
			break;
		case 1:
			SetHypFieldLength (id_inline_sport, 16);
			SetHypFieldLength (id_inline_dport, 8);
			break;
		case 2:
			SetHypFieldLength (id_inline_sport, 8);
			SetHypFieldLength (id_inline_dport, 16);
			break;
		case 3:
			SetHypFieldLength (id_inline_sport, 4);
			SetHypFieldLength (id_inline_dport, 4);
			break;
		}

		// no NHC header
		SixLowpanHC::SetHypSize (-2);
	}
}


} // namespace gen
}

CD/6lowpan.h

0 → 100644
+20 −0
Original line number Original line Diff line number Diff line
#ifndef s6lowpan_h
#define s6lowpan_h 1

// IPv6 and 6lowpan codec implementation
//
// Please read the Codec Generation section of the T3DevKit documentation in
// order to understand how this CoDec is designed.
//
// --->  http://t3devkit.gforge.inria.fr/doc/userref/
//

namespace t3devlib {
  namespace gen {
    // Primitive types from module LibIpv6_6lowpan_TypesAndValues 
    typedef t3devlib::Octetstring SixLowpanHwAddress;
  }
  
}

#endif