improve serial / deser of ip address list

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1915 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-12-18 23:35:08 +00:00
parent 0bf5a5b79d
commit 808ac84fa8
2 changed files with 12 additions and 8 deletions

View File

@ -887,9 +887,10 @@ RsPeerNetItem *RsPeerConfigSerialiser::deserialiseNet(void *data, uint32_t *size
std::list<IpAddressTimed> ipTimedList;
while (offset < rssize) {
IpAddressTimed ipTimed;
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
uint64_t time;
ok &= getRawUInt64(data, rssize, &offset, &time);
sockaddr_clear(&ipTimed.ipAddr);
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
uint64_t time = 0;
ok &= getRawUInt64(data, rssize, &offset, &time);
if (!ok) {
break;
}

View File

@ -235,8 +235,7 @@ bool RsDiscSerialiser::serialiseItem(RsDiscOwnItem *item, void *data, uint32
ok &= setRawUInt32(data, tlvsize, &offset, item->ipAddressList.size());
//store the ip list
std::list<IpAddressTimed>::iterator ipListIt;
for (ipListIt = item->ipAddressList.begin(); ipListIt!=(item->ipAddressList.end()); ipListIt++) {
for (std::list<IpAddressTimed>::iterator ipListIt = item->ipAddressList.begin(); ipListIt != item->ipAddressList.end(); ipListIt++) {
ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, TLV_TYPE_IPV4_REMOTE, &(ipListIt->ipAddr));
ok &= setRawUInt64(data, tlvsize, &offset, ipListIt->seenTime);
}
@ -310,8 +309,10 @@ RsDiscOwnItem *RsDiscSerialiser::deserialiseOwnItem(void *data, uint32_t *pktsiz
IpAddressTimed ipTimed;
sockaddr_clear(&ipTimed.ipAddr);
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
uint64_t time;
if (!ok) { break; }
uint64_t time = 0;
ok &= getRawUInt64(data, rssize, &offset, &time);
if (!ok) { break; }
ipTimed.seenTime = time;
ipTimedList.push_back(ipTimed);
}
@ -532,9 +533,11 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
IpAddressTimed ipTimed;
sockaddr_clear(&ipTimed.ipAddr);
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
uint64_t time;
if (!ok) { break; }
uint64_t time = 0;
ok &= getRawUInt64(data, rssize, &offset, &time);
ipTimed.seenTime = time;
if (!ok) { break; }
ipTimed.seenTime = time;
ipTimedList.push_back(ipTimed);
}
item->ipAddressList = ipTimedList;