/* * 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. *//* ... */#ifndefIP6_MPL_HPP_#defineIP6_MPL_HPP_/** * @file * This file includes definitions for MPL. *//* ... */#include"openthread-core-config.h"#include"common/locator.hpp"#include"common/message.hpp"#include"common/non_copyable.hpp"#include"common/time_ticker.hpp"#include"common/timer.hpp"#include"net/ip6_headers.hpp"7 includesnamespaceot{namespaceIp6{/** * @addtogroup core-ip6-mpl * * @brief * This module includes definitions for MPL. * * @{ *//* ... *//** * Implements MPL header generation and parsing. *//* ... */OT_TOOL_PACKED_BEGINclassMplOption:publicOption{public:staticconstexpruint8_tkType=0x6d;///< MPL option type - 01 1 01101staticconstexpruint8_tkMinSize=(2+sizeof(Option));///< Minimum size (num of bytes) of `MplOption`/** * MPL Seed Id Lengths. *//* ... */enumSeedIdLength:uint8_t{kSeedIdLength0=0<<6,///< 0-byte MPL Seed Id Length.kSeedIdLength2=1<<6,///< 2-byte MPL Seed Id Length.kSeedIdLength8=2<<6,///< 8-byte MPL Seed Id Length.kSeedIdLength16=3<<6,///< 16-byte MPL Seed Id Length.}{...};/** * Initializes the MPL Option. * * The @p aSeedIdLength MUST be either `kSeedIdLength0` or `kSeedIdLength2`. Other values are not supported. * * @param[in] aSeedIdLength The MPL Seed Id Length. *//* ... */voidInit(SeedIdLengthaSeedIdLength);/** * Returns the MPL Seed Id Length value. * * @returns The MPL Seed Id Length value. *//* ... */SeedIdLengthGetSeedIdLength(void)const{returnstatic_cast<SeedIdLength>(mControl&kSeedIdLengthMask);}/** * Indicates whether or not the MPL M flag is set. * * @retval TRUE If the MPL M flag is set. * @retval FALSE If the MPL M flag is not set. *//* ... */boolIsMaxFlagSet(void)const{return(mControl&kMaxFlag)!=0;}/** * Clears the MPL M flag. *//* ... */voidClearMaxFlag(void){mControl&=~kMaxFlag;}/** * Sets the MPL M flag. *//* ... */voidSetMaxFlag(void){mControl|=kMaxFlag;}/** * Returns the MPL Sequence value. * * @returns The MPL Sequence value. *//* ... */uint8_tGetSequence(void)const{returnmSequence;}/** * Sets the MPL Sequence value. * * @param[in] aSequence The MPL Sequence value. *//* ... */voidSetSequence(uint8_taSequence){mSequence=aSequence;}/** * Returns the MPL Seed Id value. * * @returns The MPL Seed Id value. *//* ... */uint16_tGetSeedId(void)const{returnBigEndian::HostSwap16(mSeedId);}/** * Sets the MPL Seed Id value. * * @param[in] aSeedId The MPL Seed Id value. *//* ... */voidSetSeedId(uint16_taSeedId){mSeedId=BigEndian::HostSwap16(aSeedId);}...private:staticconstexpruint8_tkSeedIdLengthMask=3<<6;staticconstexpruint8_tkMaxFlag=1<<5;uint8_tmControl;uint8_tmSequence;uint16_tmSeedId;...}{...}OT_TOOL_PACKED_END;/** * Implements MPL message processing. *//* ... */classMpl:publicInstanceLocator,privateNonCopyable{friendclassot::TimeTicker;public:/** * Initializes the MPL object. * * @param[in] aInstance A reference to the OpenThread instance. *//* ... */explicitMpl(Instance&aInstance);/** * Initializes the MPL option. * * @param[in] aOption A reference to the MPL header to initialize. * @param[in] aAddress A reference to the IPv6 Source Address. *//* ... */voidInitOption(MplOption&aOption,constAddress&aAddress);/** * Processes an MPL option. When the MPL module acts as an MPL Forwarder * it disseminates MPL Data Message using Trickle timer expirations. When acts as an * MPL Seed it allows to send the first MPL Data Message directly, then sets up Trickle * timer expirations for subsequent retransmissions. * * @param[in] aMessage A reference to the message. * @param[in] aOffsetRange The offset range in @p aMessage to read the MPL option. * @param[in] aAddress A reference to the IPv6 Source Address. * @param[out] aReceive Set to FALSE if the MPL message is a duplicate and must not * go through the receiving process again, untouched otherwise. * * @retval kErrorNone Successfully processed the MPL option. * @retval kErrorDrop The MPL message is a duplicate and should be dropped. *//* ... */ErrorProcessOption(Message&aMessage,constOffsetRange&aOffsetRange,constAddress&aAddress,bool&aReceive);#ifOPENTHREAD_FTD/** * Returns a reference to the buffered message set. * * @returns A reference to the buffered message set. *//* ... */constMessageQueue&GetBufferedMessageSet(void)const{returnmBufferedMessageSet;}/* ... */#endif...private:staticconstexpruint16_tkNumSeedEntries=OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES;staticconstexpruint32_tkSeedEntryLifetime=OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRY_LIFETIME;staticconstexpruint32_tkSeedEntryLifetimeDt=1000;staticconstexpruint8_tkDataMessageInterval=64;structSeedEntry{uint16_tmSeedId;uint8_tmSequence;uint8_tmLifetime;}{ ... };voidHandleTimeTick(void);ErrorUpdateSeedSet(uint16_taSeedId,uint8_taSequence);SeedEntrymSeedSet[kNumSeedEntries];uint8_tmSequence;#ifOPENTHREAD_FTDstaticconstexpruint8_tkChildRetransmissions=0;// MPL retransmissions for Children.staticconstexpruint8_tkRouterRetransmissions=2;// MPL retransmissions for Routers.structMetadata:publicMessage::FooterData<Metadata>{voidGenerateNextTransmissionTime(TimeMilliaCurrentTime,uint8_taInterval);TimeMillimTransmissionTime;uint16_tmSeedId;uint8_tmSequence;uint8_tmTransmissionCount;uint8_tmIntervalOffset;}{...};uint8_tDetermineMaxRetransmissions(void)const;voidHandleRetransmissionTimer(void);voidAddBufferedMessage(Message&aMessage,uint16_taSeedId,uint8_taSequence);usingRetxTimer=TimerMilliIn<Mpl,&Mpl::HandleRetransmissionTimer>;MessageQueuemBufferedMessageSet;RetxTimermRetransmissionTimer;/* ... */#endif// OPENTHREAD_FTD...}{...};/** * @} *//* ... */}{...}// namespace Ip6}{...}// namespace ot/* ... */#endif// IP6_MPL_HPP_
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.