Commit Graph

28 Commits

Author SHA1 Message Date
Abtin Keshavarzian 8f112eeb5a [locator] adding Get<Type> to InstanceLocator (#3714)
This commit changes how the objects in OpenThread access each other.
It adds a template `Get<Type>()` method in `InstanceLocator`. This
method returns a reference to a given `Type` object belonging to the
OpenThread instance (e.g. `Get<MeshForwarder>()` returns a reference
to `MeshForwarder` object on the OpenThread instance). The
`InstanceLocator` is used as base class of all OpenThread classes so
every class can easily access any other object. This commit also
changes how the main instance is retrieved in `InstanceLocator` for
the single-instance case. The method `GetInstance()` directly uses the
raw buffer `gInstanceRaw`. This change helps make the `GetInstance()`
and in turn all `Get<Type>()` methods in-line. This commit also
removes the existing getters across all classes to use the new
`Get<Type>()` model.
2019-04-02 09:07:25 -07:00
Jonathan Hui b7a9e7afd7 [tests] add conditionals around unit tests (#3616) 2019-02-22 09:00:01 -08:00
Jonathan Hui 49641e1d4e [lowpan] introduce buffer writer to lowpan compressor (#3597) 2019-02-19 20:46:28 -08:00
Jonathan Hui c116441212 [api] change type from uint8_t * to otMeshLocalPrefix (#2966) 2018-08-17 08:59:37 -07:00
Jonathan Hui 51c62a29d0 [network-data] optimize network data update via MLE (#2612)
This commit reduces stack usage when receiving/updating network data via MLE
by copying the network data directly out of the message and skipping the TLV
read.
2018-03-12 18:27:07 +00:00
Jonathan Hui 69d98d4a53 [code-style] apply clang-format 2018-02-09 21:43:42 +00:00
Abtin Keshavarzian 02c876ef62 [instance] define ot::Instance class (#2307)
This commit makes the following changes: It defines the public
`otInstance` as an empty opaque structure which is used by all public
C OpenThread APIs. It defines a new class `ot::Instance` (inheriting
from `otInstance) which is then used in core source files. The
functionality related to the instance is also moved/added into the
newly added `Instance` class (as class/static or member methods).
2017-11-13 08:27:57 -08:00
Buke Po 1ff8824d18 [message] decouple message and ip6 (#2028) 2017-07-25 08:46:53 -07:00
Abtin Keshavarzian bbab3074ed [instance] single OpenThread instance optimizations (#1926)
This commit new configuration option `enable-multiple-instances` and
its corresponding option `OPENTHREAD_ENABLE_MULTIPLE_INSTANCES`. When
enabled OpenThread supports handling of multiple instances. By default
this is disabled.

This commit also adds two optimizations for single instance case to
simplify the code and also help reduce memory/RAM usage:

(1) OpenThread objects/classes typically keep a reference to a higher
level object (e.g., many classes keep track of owning `ThreadNetif`)
to be able to access other objects/methods within OpenThread class
hierarchy. In single instance mode, the reference member variables are
removed and instead global functions are used to access the singleton
objects from one class to the other. To implement this, a group of
`<Object>Locator` classes are defined (e.g., `ThreadNetifLocator`,
etc.) which are then used as base class of other OpenThread classes.

(2) OpenThread objects which provide a callback/handler (e.g.,
`Timer`, `Tasklet`, etc.) have `void *mContext` member variable which
is used to keep track of the owner of the object. In single instance
mode the `mConext` member variables are removed since the owner is
expected to be a singleton and can be uniquely determined from the
callback function.

To implement this, two changes are made: First the handler methods are
modified to provide a reference to the object (e.g., `Timer` handler
will provide a `Timer &aTimer` as a parameter of its handler
callback). Second, a new base class `Context` is introduced which
hides the implementation providing an arbitrary context information. A
new static method `GetOwner(aContext)` is added to classes which own a
callback providing objects. This method help convert a `Context` to
the reference of the owner class object.
2017-06-30 11:48:26 -07:00
Jonathan Hui 48b9299544 Clean up error names. (#1764) 2017-05-23 09:34:35 -07:00
Jonathan Hui fbfd76a990 Apply #include code style. (#1723) 2017-05-05 11:28:29 -07:00
Jonathan Hui 1eabda6a08 Change top-level namespace from 'Thread' to 'ot'. (#1664) 2017-04-27 22:29:05 -07:00
Buke Po 145a3adfc1 fix code style issue make pretty founds. (#1622) 2017-04-19 21:35:25 -07:00
Jonathan Hui 5105a0bc5e Fix clang warning in lowpan unit test. (#975) 2016-11-16 17:24:46 +08:00
Łukasz Duda ede95a1220 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.
2016-11-09 01:00:08 -08:00
Łukasz Duda fbbd26d24b 6LOWPAN: Add support to compression and decompression of IP-in-IP. (#887) 2016-10-26 13:13:53 -07:00
Nick Banks 25cea9414b Windows Unit Test Support (#629)
Window Unit Test Support
2016-09-20 18:11:19 -07:00
Jonathan Hui 44350178ad Change copyright to The OpenThread Authors. (#583)
- Add a top-level file named AUTHORS which identifies the copyright
holders of the project.
2016-09-13 15:57:11 -07:00
Nick Banks ffbe65c6dd otInstance Declarations (#473)
* Add otInstance type declaration and update ot APIs to take it as input.
2016-09-12 14:29:43 -07:00
Jonathan Hui e22c123904 Remove globals from message.cpp. 2016-09-07 13:30:22 -07:00
Jonathan Hui 7f899dc6dd Remove globals from ip6.cpp. 2016-09-07 13:30:22 -07:00
Jonathan Hui 6d958ba51b Fix compiler warnings in unit tests. (#488) 2016-08-29 11:41:59 -07:00
Jonathan Hui 9b6afb31c0 Require compiler warnings. (#418) 2016-08-18 12:22:12 -07:00
Shu Chen 7130798123 Add diagnostics module in OpenThread (#343)
* Add diagnostics module in OpenThread

  - provide the same diagnostics interface for both CLI and NCP usage
  - implement common diagnostics features based on existing platform interface defined in 'include/platform/'
  - other more platform specific diagnostics features will be processed under platform layer
  - update CLI interface to support diagnostics feature
  - update both Posix and CC2538 platform to support diagnostics feature

* Add diagnostics module unit test

   - move platform.h from "examples/platform" to "include/platform"
   - add test_diag.cpp to test diagnostics module

* Add a configuration option that would enable/disable diagnostics module

Add --enable-diag configuration option to enable/disable diagnostics module when building OpenThread.
2016-08-11 10:26:51 -07:00
Marcin K Szczodrak 318fe4b415 turn on warnings and errors (#280) 2016-07-25 21:19:07 -07:00
Jonathan Hui 9baa18e6e6 Rename otPlatSerial* to otPlatUart*. (#253) 2016-07-07 12:18:58 -07:00
Jonathan Hui e9be30ae21 Fix code style. (#194) 2016-06-22 13:21:47 -07:00
turon 31bc49de32 test: Lowpan module unit tests (#151)
* Added initial unit tests for 6LoWPAN layer decompression. Extended unit test framework with helper functions for setting up ASCI hex test vectors.

* Added missing license headers. Cleanly broke C++ into .hpp vs .h.

* Added multicast test vectors to 6lo decompression unit tests.

* Make pretty.

* Added Lowpan::Compress unit test.

* Allow extended initializer lists for unit test build.

* Split out sTestVectorLowpan into pure C99 file as it uses struct { .mField = initializers; } which may upset stricter C++ compilers such as clang++.

* Fix make distcheck - add stubs to test_lowpan for unhandled driver callbacks.

* Resolve most comments besides otDump suggestion.
2016-06-21 13:05:31 -07:00