mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 10:54:22 -05:00
add serializiont of own ipaddress list in rsdiscitem
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1903 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fbec787877
commit
c06d0c6f98
@ -180,6 +180,7 @@ uint32_t RsDiscSerialiser::sizeItem(RsDiscOwnItem *item)
|
|||||||
s += GetTlvIpAddrPortV4Size(); /* saddr */
|
s += GetTlvIpAddrPortV4Size(); /* saddr */
|
||||||
s += 2; /* contact_tf */
|
s += 2; /* contact_tf */
|
||||||
s += 4; /* discFlags */
|
s += 4; /* discFlags */
|
||||||
|
s += 4; /* ipaddress list size */
|
||||||
|
|
||||||
//add the size of the ip list
|
//add the size of the ip list
|
||||||
int ipListSize = item->ipAddressList.size();
|
int ipListSize = item->ipAddressList.size();
|
||||||
@ -220,12 +221,14 @@ bool RsDiscSerialiser::serialiseItem(RsDiscOwnItem *item, void *data, uint32
|
|||||||
ok &= setRawUInt16(data, tlvsize, &offset, item->contact_tf);
|
ok &= setRawUInt16(data, tlvsize, &offset, item->contact_tf);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->discFlags);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->discFlags);
|
||||||
|
|
||||||
//store the ip list There is no private address list for own item
|
ok &= setRawUInt32(data, tlvsize, &offset, item->ipAddressList.size());
|
||||||
// std::list<IpAddressTimed>::iterator ipListIt;
|
|
||||||
// for (ipListIt = item->ipAddressList.begin(); ipListIt!=(item->ipAddressList.end()); ipListIt++) {
|
//store the ip list
|
||||||
// ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, TLV_TYPE_IPV4_REMOTE, &(ipListIt->ipAddr));
|
std::list<IpAddressTimed>::iterator ipListIt;
|
||||||
// ok &= setRawUInt64(data, tlvsize, &offset, ipListIt->seenTime);
|
for (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);
|
||||||
|
}
|
||||||
|
|
||||||
if (offset != tlvsize)
|
if (offset != tlvsize)
|
||||||
{
|
{
|
||||||
@ -285,17 +288,22 @@ RsDiscOwnItem *RsDiscSerialiser::deserialiseOwnItem(void *data, uint32_t *pktsiz
|
|||||||
ok &= getRawUInt16(data, rssize, &offset, &(item->contact_tf));
|
ok &= getRawUInt16(data, rssize, &offset, &(item->contact_tf));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->discFlags));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->discFlags));
|
||||||
|
|
||||||
|
uint32_t listSize;
|
||||||
|
ok &= getRawUInt32(data, rssize, &offset, &listSize);
|
||||||
|
|
||||||
//get the ip adress list
|
//get the ip adress list
|
||||||
// std::list<IpAddressTimed> ipTimedList;
|
uint32_t count = 0;
|
||||||
// while (offset < rssize) {
|
std::list<IpAddressTimed> ipTimedList;
|
||||||
// IpAddressTimed ipTimed;
|
while (offset < rssize && count < listSize) {
|
||||||
// ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
|
count++;
|
||||||
// uint64_t time;
|
IpAddressTimed ipTimed;
|
||||||
// ok &= getRawUInt64(data, rssize, &offset, &time);
|
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
|
||||||
// ipTimed.seenTime = time;
|
uint64_t time;
|
||||||
// ipTimedList.push_back(ipTimed);
|
ok &= getRawUInt64(data, rssize, &offset, &time);
|
||||||
// }
|
ipTimed.seenTime = time;
|
||||||
// item->ipAddressList = ipTimedList;
|
ipTimedList.push_back(ipTimed);
|
||||||
|
}
|
||||||
|
item->ipAddressList = ipTimedList;
|
||||||
|
|
||||||
if (offset != rssize)
|
if (offset != rssize)
|
||||||
{
|
{
|
||||||
@ -376,6 +384,7 @@ uint32_t RsDiscSerialiser::sizeReply(RsDiscReply *item)
|
|||||||
s += 4; /* discFlags */
|
s += 4; /* discFlags */
|
||||||
s += GetTlvStringSize(item->aboutId);
|
s += GetTlvStringSize(item->aboutId);
|
||||||
s += item->certDER.TlvSize();
|
s += item->certDER.TlvSize();
|
||||||
|
s += 4; /* ipaddress list size */
|
||||||
|
|
||||||
//add the size of the ip list
|
//add the size of the ip list
|
||||||
int ipListSize = item->ipAddressList.size();
|
int ipListSize = item->ipAddressList.size();
|
||||||
@ -418,6 +427,7 @@ bool RsDiscSerialiser::serialiseReply(RsDiscReply *item, void *data, uint32_
|
|||||||
|
|
||||||
ok &= item->certDER.SetTlv(data, tlvsize, &offset);
|
ok &= item->certDER.SetTlv(data, tlvsize, &offset);
|
||||||
|
|
||||||
|
ok &= setRawUInt32(data, tlvsize, &offset, item->ipAddressList.size());
|
||||||
|
|
||||||
//store the ip list
|
//store the ip list
|
||||||
std::list<IpAddressTimed>::iterator ipListIt;
|
std::list<IpAddressTimed>::iterator ipListIt;
|
||||||
@ -488,9 +498,13 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize)
|
|||||||
TLV_TYPE_STR_PEERID, item->aboutId);
|
TLV_TYPE_STR_PEERID, item->aboutId);
|
||||||
ok &= item->certDER.GetTlv(data, rssize, &offset);
|
ok &= item->certDER.GetTlv(data, rssize, &offset);
|
||||||
|
|
||||||
|
uint32_t listSize;
|
||||||
|
ok &= getRawUInt32(data, rssize, &offset, &listSize);
|
||||||
|
|
||||||
//get the ip adress list
|
//get the ip adress list
|
||||||
|
uint32_t count = 0;
|
||||||
std::list<IpAddressTimed> ipTimedList;
|
std::list<IpAddressTimed> ipTimedList;
|
||||||
while (offset < rssize) {
|
while (offset < rssize && count < listSize) {
|
||||||
IpAddressTimed ipTimed;
|
IpAddressTimed ipTimed;
|
||||||
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
|
ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr);
|
||||||
uint64_t time;
|
uint64_t time;
|
||||||
|
Loading…
Reference in New Issue
Block a user