本文整理汇总了C++中ip6::MessageInfo::GetSockPort方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageInfo::GetSockPort方法的具体用法?C++ MessageInfo::GetSockPort怎么用?C++ MessageInfo::GetSockPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ip6::MessageInfo
的用法示例。
在下文中一共展示了MessageInfo::GetSockPort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleUdpReceive
void Dtls::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
switch (mState)
{
case MeshCoP::Dtls::kStateClosed:
ExitNow();
case MeshCoP::Dtls::kStateOpen:
{
Ip6::SockAddr sockAddr;
sockAddr.mAddress = aMessageInfo.GetPeerAddr();
sockAddr.mPort = aMessageInfo.GetPeerPort();
mSocket.Connect(sockAddr);
mPeerAddress.SetPeerAddr(aMessageInfo.GetPeerAddr());
mPeerAddress.SetPeerPort(aMessageInfo.GetPeerPort());
mPeerAddress.SetInterfaceId(aMessageInfo.GetInterfaceId());
if (Get<ThreadNetif>().IsUnicastAddress(aMessageInfo.GetSockAddr()))
{
mPeerAddress.SetSockAddr(aMessageInfo.GetSockAddr());
}
mPeerAddress.SetSockPort(aMessageInfo.GetSockPort());
SuccessOrExit(Setup(false));
break;
}
default:
// Once DTLS session is started, communicate only with a peer.
VerifyOrExit((mPeerAddress.GetPeerAddr() == aMessageInfo.GetPeerAddr()) &&
(mPeerAddress.GetPeerPort() == aMessageInfo.GetPeerPort()));
break;
}
#if OPENTHREAD_ENABLE_BORDER_AGENT || OPENTHREAD_ENABLE_COMMISSIONER
if (mState == MeshCoP::Dtls::kStateConnecting)
{
SetClientId(mPeerAddress.GetPeerAddr().mFields.m8, sizeof(mPeerAddress.GetPeerAddr().mFields));
}
#endif
Receive(aMessage, aMessage.GetOffset(), aMessage.GetLength() - aMessage.GetOffset());
exit:
return;
}
示例2: Receive
void CoapSecure::Receive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
ThreadNetif &netif = GetNetif();
if (!netif.GetDtls().IsStarted())
{
Ip6::SockAddr sockAddr;
sockAddr.mAddress = aMessageInfo.GetPeerAddr();
sockAddr.mPort = aMessageInfo.GetPeerPort();
mSocket.Connect(sockAddr);
mPeerAddress.SetPeerAddr(aMessageInfo.GetPeerAddr());
mPeerAddress.SetPeerPort(aMessageInfo.GetPeerPort());
mPeerAddress.SetInterfaceId(aMessageInfo.GetInterfaceId());
if (netif.IsUnicastAddress(aMessageInfo.GetSockAddr()))
{
mPeerAddress.SetSockAddr(aMessageInfo.GetSockAddr());
}
mPeerAddress.SetSockPort(aMessageInfo.GetSockPort());
netif.GetDtls().Start(false, &CoapSecure::HandleDtlsConnected, &CoapSecure::HandleDtlsReceive,
CoapSecure::HandleDtlsSend, this);
}
else
{
// Once DTLS session is started, communicate only with a peer.
VerifyOrExit((mPeerAddress.GetPeerAddr() == aMessageInfo.GetPeerAddr()) &&
(mPeerAddress.GetPeerPort() == aMessageInfo.GetPeerPort()));
}
netif.GetDtls().SetClientId(mPeerAddress.GetPeerAddr().mFields.m8, sizeof(mPeerAddress.GetPeerAddr().mFields));
netif.GetDtls().Receive(aMessage, aMessage.GetOffset(), aMessage.GetLength() - aMessage.GetOffset());
exit:
return;
}