本文整理汇总了C++中Header::GetSource方法的典型用法代码示例。如果您正苦于以下问题:C++ Header::GetSource方法的具体用法?C++ Header::GetSource怎么用?C++ Header::GetSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::GetSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddMplOption
ThreadError AddMplOption(Message &message, Header &header, IpProto nextHeader, uint16_t payloadLength)
{
ThreadError error = kThreadError_None;
HopByHopHeader hbhHeader;
OptionMpl mplOption;
hbhHeader.SetNextHeader(nextHeader);
hbhHeader.SetLength(0);
sMpl.InitOption(mplOption, HostSwap16(header.GetSource().mFields.m16[7]));
SuccessOrExit(error = message.Prepend(&mplOption, sizeof(mplOption)));
SuccessOrExit(error = message.Prepend(&hbhHeader, sizeof(hbhHeader)));
header.SetPayloadLength(sizeof(hbhHeader) + sizeof(mplOption) + payloadLength);
header.SetNextHeader(kProtoHopOpts);
exit:
return error;
}
示例2: VerifyOrExit
ThreadError Ip6::SendDatagram(Message &message, MessageInfo &messageInfo, IpProto ipproto)
{
ThreadError error = kThreadError_None;
Header header;
uint16_t payloadLength = message.GetLength();
uint16_t checksum;
const NetifUnicastAddress *source;
header.Init();
header.SetPayloadLength(payloadLength);
header.SetNextHeader(ipproto);
header.SetHopLimit(messageInfo.mHopLimit ? messageInfo.mHopLimit : kDefaultHopLimit);
if (messageInfo.GetSockAddr().IsUnspecified())
{
VerifyOrExit((source = Netif::SelectSourceAddress(messageInfo)) != NULL, error = kThreadError_Error);
header.SetSource(source->GetAddress());
}
else
{
header.SetSource(messageInfo.GetSockAddr());
}
header.SetDestination(messageInfo.GetPeerAddr());
if (header.GetDestination().IsLinkLocal() || header.GetDestination().IsLinkLocalMulticast())
{
VerifyOrExit(messageInfo.mInterfaceId != 0, error = kThreadError_Drop);
}
if (messageInfo.GetPeerAddr().IsRealmLocalMulticast())
{
SuccessOrExit(error = AddMplOption(message, header, ipproto, payloadLength));
}
SuccessOrExit(error = message.Prepend(&header, sizeof(header)));
// compute checksum
checksum = ComputePseudoheaderChecksum(header.GetSource(), header.GetDestination(),
payloadLength, ipproto);
switch (ipproto)
{
case kProtoUdp:
SuccessOrExit(error = Udp::UpdateChecksum(message, checksum));
break;
case kProtoIcmp6:
SuccessOrExit(error = Icmp::UpdateChecksum(message, checksum));
break;
default:
break;
}
exit:
if (error == kThreadError_None)
{
error = HandleDatagram(message, NULL, messageInfo.mInterfaceId, NULL, false);
}
return error;
}