本文整理汇总了C++中SuccessOrExit函数的典型用法代码示例。如果您正苦于以下问题:C++ SuccessOrExit函数的具体用法?C++ SuccessOrExit怎么用?C++ SuccessOrExit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SuccessOrExit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SuccessOrExit
template <> otError NcpBase::HandlePropertyInsert<SPINEL_PROP_MESHCOP_COMMISSIONER_JOINERS>(void)
{
otError error = OT_ERROR_NONE;
const otExtAddress *eui64;
uint32_t timeout;
const char * psk;
SuccessOrExit(error = mDecoder.OpenStruct());
if (!mDecoder.IsAllReadInStruct())
{
SuccessOrExit(error = mDecoder.ReadEui64(eui64));
}
else
{
// Empty struct indicates any Joiner (no EUI64 is given so NULL is used.).
eui64 = NULL;
}
SuccessOrExit(error = mDecoder.CloseStruct());
SuccessOrExit(error = mDecoder.ReadUint32(timeout));
SuccessOrExit(error = mDecoder.ReadUtf8(psk));
error = otCommissionerAddJoiner(mInstance, eui64, psk, timeout);
exit:
return error;
}
示例2: otLogInfoMeshCoP
void Leader::HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
StateTlv state;
CommissionerSessionIdTlv sessionId;
StateTlv::State responseState;
otLogInfoMeshCoP(GetInstance(), "received keep alive");
SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kState, sizeof(state), state));
VerifyOrExit(state.IsValid());
SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kCommissionerSessionId, sizeof(sessionId), sessionId));
VerifyOrExit(sessionId.IsValid());
if (sessionId.GetCommissionerSessionId() != mSessionId)
{
responseState = StateTlv::kReject;
}
else if (state.GetState() != StateTlv::kAccept)
{
responseState = StateTlv::kReject;
ResignCommissioner();
}
else
{
responseState = StateTlv::kAccept;
mTimer.Start(TimerMilli::SecToMsec(kTimeoutLeaderPetition));
}
SendKeepAliveResponse(aHeader, aMessageInfo, responseState);
exit:
return;
}
示例3: SuccessOrExit
otError Dhcp6Server::AppendIaAddress(Message &aMessage, ClientIdentifier &aClient)
{
otError error = OT_ERROR_NONE;
otIp6Prefix *prefix = NULL;
// if specified, only apply specified prefixes
if (mPrefixAgentsMask)
{
for (uint8_t i = 0; i < OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES; i++)
{
if (mPrefixAgentsMask & (1 << i))
{
prefix = mPrefixAgents[i].GetPrefix();
SuccessOrExit(error = AddIaAddress(aMessage, *prefix, aClient));
}
}
}
else // if not specified, apply all configured prefixes
{
for (uint8_t i = 0; i < OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES; i++)
{
prefix = mPrefixAgents[i].GetPrefix();
if (prefix->mLength == 0)
{
continue;
}
SuccessOrExit(error = AddIaAddress(aMessage, *prefix, aClient));
}
}
exit:
return error;
}
示例4: responseInfo
void AnnounceBeginServer::HandleRequest(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
MeshCoP::ChannelMask0Tlv channelMask;
MeshCoP::CountTlv count;
MeshCoP::PeriodTlv period;
Ip6::MessageInfo responseInfo(aMessageInfo);
VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_POST);
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask));
VerifyOrExit(channelMask.IsValid());
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kCount, sizeof(count), count));
VerifyOrExit(count.IsValid());
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kPeriod, sizeof(period), period));
VerifyOrExit(period.IsValid());
SendAnnounce(channelMask.GetMask(), count.GetCount(), period.GetPeriod());
if (aHeader.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast())
{
SuccessOrExit(GetNetif().GetCoap().SendEmptyAck(aHeader, responseInfo));
otLogInfoMeshCoP(GetInstance(), "sent announce begin response");
}
exit:
return;
}
示例5: GetNetif
void EnergyScanClient::HandleReport(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
ThreadNetif & netif = GetNetif();
MeshCoP::ChannelMaskTlv channelMask;
Ip6::MessageInfo responseInfo(aMessageInfo);
OT_TOOL_PACKED_BEGIN
struct
{
MeshCoP::EnergyListTlv tlv;
uint8_t list[OPENTHREAD_CONFIG_MAX_ENERGY_RESULTS];
} OT_TOOL_PACKED_END energyList;
VerifyOrExit(aMessage.GetType() == OT_COAP_TYPE_CONFIRMABLE && aMessage.GetCode() == OT_COAP_CODE_POST);
otLogInfoMeshCoP("received energy scan report");
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask));
VerifyOrExit(channelMask.IsValid() && channelMask.GetChannelPage() == OT_RADIO_CHANNEL_PAGE);
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kEnergyList, sizeof(energyList), energyList.tlv));
VerifyOrExit(energyList.tlv.IsValid());
if (mCallback != NULL)
{
mCallback(channelMask.GetMask(), energyList.list, energyList.tlv.GetLength(), mContext);
}
SuccessOrExit(netif.GetCoap().SendEmptyAck(aMessage, responseInfo));
otLogInfoMeshCoP("sent energy scan report response");
exit:
return;
}
示例6: GetNetif
void ChildSupervisor::SendMessage(Child &aChild)
{
ThreadNetif &netif = GetNetif();
Message *message = NULL;
otError error = OT_ERROR_NONE;
uint8_t childIndex;
VerifyOrExit(aChild.GetIndirectMessageCount() == 0);
message = netif.GetInstance().mMessagePool.New(Message::kTypeSupervision, sizeof(uint8_t));
VerifyOrExit(message != NULL);
// Supervision message is an empty payload 15.4 data frame.
// The child index is stored here in the message content to allow
// the destination of the message to be later retrieved using
// `ChildSupervisor::GetDestination(message)`.
childIndex = netif.GetMle().GetChildIndex(aChild);
SuccessOrExit(error = message->Append(&childIndex, sizeof(childIndex)));
SuccessOrExit(error = netif.SendMessage(*message));
message = NULL;
otLogInfoMle(GetInstance(), "Sending supervision message to child 0x%04x", aChild.GetRloc16());
exit:
if (message != NULL)
{
message->Free();
}
}
示例7: VerifyOrExit
otError Dtls::HandleDtlsSend(const uint8_t *aBuf, uint16_t aLength, uint8_t aMessageSubType)
{
otError error = OT_ERROR_NONE;
ot::Message *message = NULL;
VerifyOrExit((message = mSocket.NewMessage(0)) != NULL, error = OT_ERROR_NO_BUFS);
message->SetSubType(aMessageSubType);
message->SetLinkSecurityEnabled(mLayerTwoSecurity);
SuccessOrExit(error = message->Append(aBuf, aLength));
// Set message sub type in case Joiner Finalize Response is appended to the message.
if (aMessageSubType != Message::kSubTypeNone)
{
message->SetSubType(aMessageSubType);
}
if (mTransportCallback)
{
SuccessOrExit(error = mTransportCallback(mTransportContext, *message, mPeerAddress));
}
else
{
SuccessOrExit(error = mSocket.SendTo(*message, mPeerAddress));
}
exit:
if (error != OT_ERROR_NONE && message != NULL)
{
message->Free();
}
return error;
}
示例8: GetNetif
void PanIdQueryClient::HandleConflict(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
ThreadNetif &netif = GetNetif();
MeshCoP::PanIdTlv panId;
MeshCoP::ChannelMask0Tlv channelMask;
Ip6::MessageInfo responseInfo(aMessageInfo);
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
aHeader.GetCode() == OT_COAP_CODE_POST);
otLogInfoMeshCoP(GetInstance(), "received panid conflict");
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kPanId, sizeof(panId), panId));
VerifyOrExit(panId.IsValid());
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask));
VerifyOrExit(channelMask.IsValid());
if (mCallback != NULL)
{
mCallback(panId.GetPanId(), channelMask.GetMask(), mContext);
}
SuccessOrExit(netif.GetCoap().SendEmptyAck(aHeader, responseInfo));
otLogInfoMeshCoP(GetInstance(), "sent panid query conflict response");
exit:
return;
}
示例9: VerifyOrExit
void ChildSupervisor::SendMessage(Child &aChild)
{
Message *message = NULL;
uint8_t childIndex;
VerifyOrExit(aChild.GetIndirectMessageCount() == 0);
message = Get<MessagePool>().New(Message::kTypeSupervision, sizeof(uint8_t));
VerifyOrExit(message != NULL);
// Supervision message is an empty payload 15.4 data frame.
// The child index is stored here in the message content to allow
// the destination of the message to be later retrieved using
// `ChildSupervisor::GetDestination(message)`.
childIndex = Get<ChildTable>().GetChildIndex(aChild);
SuccessOrExit(message->Append(&childIndex, sizeof(childIndex)));
SuccessOrExit(Get<ThreadNetif>().SendMessage(*message));
message = NULL;
otLogInfoUtil("Sending supervision message to child 0x%04x", aChild.GetRloc16());
exit:
if (message != NULL)
{
message->Free();
}
}
示例10: VerifyOrExit
void Dhcp6Server::ProcessSolicit(Message &aMessage, otIp6Address &aDst, uint8_t *aTransactionId)
{
IaNa iana;
ClientIdentifier clientIdentifier;
uint16_t optionOffset;
uint16_t offset = aMessage.GetOffset();
uint16_t length = aMessage.GetLength() - aMessage.GetOffset();
// Client Identifier (discard if not present)
VerifyOrExit((optionOffset = FindOption(aMessage, offset, length, kOptionClientIdentifier)) > 0);
SuccessOrExit(ProcessClientIdentifier(aMessage, optionOffset, clientIdentifier));
// Server Identifier (assuming Rapid Commit, discard if present)
VerifyOrExit(FindOption(aMessage, offset, length, kOptionServerIdentifier) == 0);
// Rapid Commit (assuming Rapid Commit, discard if not present)
VerifyOrExit(FindOption(aMessage, offset, length, kOptionRapidCommit) > 0);
// Elapsed Time if present
if ((optionOffset = FindOption(aMessage, offset, length, kOptionElapsedTime)) > 0)
{
SuccessOrExit(ProcessElapsedTime(aMessage, optionOffset));
}
// IA_NA (discard if not present)
VerifyOrExit((optionOffset = FindOption(aMessage, offset, length, kOptionIaNa)) > 0);
SuccessOrExit(ProcessIaNa(aMessage, optionOffset, iana));
SuccessOrExit(SendReply(aDst, aTransactionId, clientIdentifier, iana));
exit:
return;
}
示例11: VerifyOrExit
void EnergyScanClient::HandleReport(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
uint32_t mask;
OT_TOOL_PACKED_BEGIN
struct
{
MeshCoP::EnergyListTlv tlv;
uint8_t list[OPENTHREAD_CONFIG_MAX_ENERGY_RESULTS];
} OT_TOOL_PACKED_END energyList;
VerifyOrExit(aMessage.GetType() == OT_COAP_TYPE_CONFIRMABLE && aMessage.GetCode() == OT_COAP_CODE_POST);
otLogInfoMeshCoP("received energy scan report");
VerifyOrExit((mask = MeshCoP::ChannelMaskTlv::GetChannelMask(aMessage)) != 0);
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kEnergyList, sizeof(energyList), energyList.tlv));
VerifyOrExit(energyList.tlv.IsValid());
if (mCallback != NULL)
{
mCallback(mask, energyList.list, energyList.tlv.GetLength(), mContext);
}
SuccessOrExit(Get<Coap::Coap>().SendEmptyAck(aMessage, aMessageInfo));
otLogInfoMeshCoP("sent energy scan report response");
exit:
return;
}
示例12: GetNetif
otError Leader::SendKeepAliveResponse(const Coap::Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo,
StateTlv::State aState)
{
ThreadNetif &netif = GetNetif();
otError error = OT_ERROR_NONE;
Coap::Header responseHeader;
StateTlv state;
Message *message;
responseHeader.SetDefaultResponseHeader(aRequestHeader);
responseHeader.SetPayloadMarker();
VerifyOrExit((message = NewMeshCoPMessage(netif.GetCoap(), responseHeader)) != NULL, error = OT_ERROR_NO_BUFS);
state.Init();
state.SetState(aState);
SuccessOrExit(error = message->Append(&state, sizeof(state)));
SuccessOrExit(error = netif.GetCoap().SendMessage(*message, aMessageInfo));
otLogInfoMeshCoP(GetInstance(), "sent keep alive response");
exit:
if (error != OT_ERROR_NONE && message != NULL)
{
message->Free();
}
return error;
}
示例13: GetNetif
otError Joiner::Start(const char * aPSKd,
const char * aProvisioningUrl,
const char * aVendorName,
const char * aVendorModel,
const char * aVendorSwVersion,
const char * aVendorData,
otJoinerCallback aCallback,
void * aContext)
{
ThreadNetif & netif = GetNetif();
otError error;
Mac::ExtAddress joinerId;
Crc16 ccitt(Crc16::kCcitt);
Crc16 ansi(Crc16::kAnsi);
VerifyOrExit(mState == OT_JOINER_STATE_IDLE, error = OT_ERROR_BUSY);
GetNotifier().Signal(OT_CHANGED_JOINER_STATE);
// use extended address based on factory-assigned IEEE EUI-64
GetJoinerId(joinerId);
netif.GetMac().SetExtAddress(joinerId);
netif.GetMle().UpdateLinkLocalAddress();
for (size_t i = 0; i < sizeof(joinerId); i++)
{
ccitt.Update(joinerId.m8[i]);
ansi.Update(joinerId.m8[i]);
}
mCcitt = ccitt.Get();
mAnsi = ansi.Get();
error = netif.GetCoapSecure().Start(OPENTHREAD_CONFIG_JOINER_UDP_PORT);
SuccessOrExit(error);
error = netif.GetCoapSecure().SetPsk(reinterpret_cast<const uint8_t *>(aPSKd), static_cast<uint8_t>(strlen(aPSKd)));
SuccessOrExit(error);
error = netif.GetCoapSecure().GetDtls().mProvisioningUrl.SetProvisioningUrl(aProvisioningUrl);
SuccessOrExit(error);
memset(mJoinerRouters, 0, sizeof(mJoinerRouters));
SuccessOrExit(error =
netif.GetMle().Discover(0, netif.GetMac().GetPanId(), true, false, HandleDiscoverResult, this));
mVendorName = aVendorName;
mVendorModel = aVendorModel;
mVendorSwVersion = aVendorSwVersion;
mVendorData = aVendorData;
mCallback = aCallback;
mContext = aContext;
mState = OT_JOINER_STATE_DISCOVER;
exit:
return error;
}
示例14: VerifyOrExit
otError AnnounceBeginClient::SendRequest(uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod,
const Ip6::Address &aAddress)
{
otError error = OT_ERROR_NONE;
Coap::Header header;
MeshCoP::CommissionerSessionIdTlv sessionId;
MeshCoP::ChannelMask0Tlv channelMask;
MeshCoP::CountTlv count;
MeshCoP::PeriodTlv period;
Ip6::MessageInfo messageInfo;
Message *message = NULL;
VerifyOrExit(GetNetif().GetCommissioner().IsActive(), error = OT_ERROR_INVALID_STATE);
header.Init(aAddress.IsMulticast() ? OT_COAP_TYPE_NON_CONFIRMABLE : OT_COAP_TYPE_CONFIRMABLE,
OT_COAP_CODE_POST);
header.SetToken(Coap::Header::kDefaultTokenLength);
header.AppendUriPathOptions(OT_URI_PATH_ANNOUNCE_BEGIN);
header.SetPayloadMarker();
VerifyOrExit((message = MeshCoP::NewMeshCoPMessage(GetNetif().GetCoap(), header)) != NULL,
error = OT_ERROR_NO_BUFS);
sessionId.Init();
sessionId.SetCommissionerSessionId(GetNetif().GetCommissioner().GetSessionId());
SuccessOrExit(error = message->Append(&sessionId, sizeof(sessionId)));
channelMask.Init();
channelMask.SetMask(aChannelMask);
SuccessOrExit(error = message->Append(&channelMask, sizeof(channelMask)));
count.Init();
count.SetCount(aCount);
SuccessOrExit(error = message->Append(&count, sizeof(count)));
period.Init();
period.SetPeriod(aPeriod);
SuccessOrExit(error = message->Append(&period, sizeof(period)));
messageInfo.SetSockAddr(GetNetif().GetMle().GetMeshLocal16());
messageInfo.SetPeerAddr(aAddress);
messageInfo.SetPeerPort(kCoapUdpPort);
messageInfo.SetInterfaceId(GetNetif().GetInterfaceId());
SuccessOrExit(error = GetNetif().GetCoap().SendMessage(*message, messageInfo));
otLogInfoMeshCoP(GetInstance(), "sent announce begin query");
exit:
if (error != OT_ERROR_NONE && message != NULL)
{
message->Free();
}
return error;
}
示例15: ExitNow
void Mac::HandleBeginTransmit(void)
{
ThreadError error = kThreadError_None;
if (otPlatRadioIdle() != kThreadError_None)
{
mBeginTransmit.Post();
ExitNow();
}
switch (mState)
{
case kStateActiveScan:
mSendFrame.SetChannel(mScanChannel);
SendBeaconRequest(mSendFrame);
mSendFrame.SetSequence(0);
break;
case kStateTransmitBeacon:
mSendFrame.SetChannel(mChannel);
SendBeacon(mSendFrame);
mSendFrame.SetSequence(mBeaconSequence++);
break;
case kStateTransmitData:
mSendFrame.SetChannel(mChannel);
SuccessOrExit(error = mSendHead->HandleFrameRequest(mSendFrame));
mSendFrame.SetSequence(mDataSequence);
break;
default:
assert(false);
break;
}
// Security Processing
ProcessTransmitSecurity();
SuccessOrExit(error = otPlatRadioTransmit(&mSendFrame));
if (mSendFrame.GetAckRequest() && !(otPlatRadioGetCaps() & kRadioCapsAckTimeout))
{
mAckTimer.Start(kAckTimeout);
otLogDebgMac("ack timer start\n");
}
exit:
if (error != kThreadError_None)
{
assert(false);
}
}