本文整理汇总了C++中UdpSocket::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ UdpSocket::GetNext方法的具体用法?C++ UdpSocket::GetNext怎么用?C++ UdpSocket::GetNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UdpSocket
的用法示例。
在下文中一共展示了UdpSocket::GetNext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveSocket
otError Udp::RemoveSocket(UdpSocket &aSocket)
{
if (mSockets == &aSocket)
{
mSockets = mSockets->GetNext();
}
else
{
for (UdpSocket *socket = mSockets; socket; socket = socket->GetNext())
{
if (socket->GetNext() == &aSocket)
{
socket->SetNext(aSocket.GetNext());
break;
}
}
}
aSocket.SetNext(NULL);
return OT_ERROR_NONE;
}
示例2: AddSocket
otError Udp::AddSocket(UdpSocket &aSocket)
{
for (UdpSocket *cur = mSockets; cur; cur = cur->GetNext())
{
if (cur == &aSocket)
{
ExitNow();
}
}
aSocket.SetNext(mSockets);
mSockets = &aSocket;
exit:
return OT_ERROR_NONE;
}
示例3: HandleMessage
otError Udp::HandleMessage(Message &aMessage, MessageInfo &aMessageInfo)
{
otError error = OT_ERROR_NONE;
UdpHeader udpHeader;
uint16_t payloadLength;
uint16_t checksum;
payloadLength = aMessage.GetLength() - aMessage.GetOffset();
// check length
VerifyOrExit(payloadLength >= sizeof(UdpHeader), error = OT_ERROR_PARSE);
// verify checksum
checksum = Ip6::ComputePseudoheaderChecksum(aMessageInfo.GetPeerAddr(), aMessageInfo.GetSockAddr(),
payloadLength, kProtoUdp);
checksum = aMessage.UpdateChecksum(checksum, aMessage.GetOffset(), payloadLength);
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
VerifyOrExit(checksum == 0xffff, error = OT_ERROR_DROP);
#endif
VerifyOrExit(aMessage.Read(aMessage.GetOffset(), sizeof(udpHeader), &udpHeader) == sizeof(udpHeader),
error = OT_ERROR_PARSE);
aMessage.MoveOffset(sizeof(udpHeader));
aMessageInfo.mPeerPort = udpHeader.GetSourcePort();
aMessageInfo.mSockPort = udpHeader.GetDestinationPort();
// find socket
for (UdpSocket *socket = mSockets; socket; socket = socket->GetNext())
{
if (socket->GetSockName().mPort != udpHeader.GetDestinationPort())
{
continue;
}
if (socket->GetSockName().mScopeId != 0 &&
socket->GetSockName().mScopeId != aMessageInfo.mInterfaceId)
{
continue;
}
if (!aMessageInfo.GetSockAddr().IsMulticast() &&
!socket->GetSockName().GetAddress().IsUnspecified() &&
socket->GetSockName().GetAddress() != aMessageInfo.GetSockAddr())
{
continue;
}
// verify source if connected socket
if (socket->GetPeerName().mPort != 0)
{
if (socket->GetPeerName().mPort != udpHeader.GetSourcePort())
{
continue;
}
if (!socket->GetPeerName().GetAddress().IsUnspecified() &&
socket->GetPeerName().GetAddress() != aMessageInfo.GetPeerAddr())
{
continue;
}
}
socket->HandleUdpReceive(aMessage, aMessageInfo);
}
exit:
return error;
}