From 4f20a4d89cf9b4c20c550c4437c468578a902b88 Mon Sep 17 00:00:00 2001 From: joss17 Date: Fri, 18 Dec 2009 17:51:23 +0000 Subject: [PATCH] fix the serial of rsdisc git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1904 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/serialiser/rsdiscitems.cc | 33 +++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/serialiser/rsdiscitems.cc b/libretroshare/src/serialiser/rsdiscitems.cc index 8e2fca9a3..4916fc437 100644 --- a/libretroshare/src/serialiser/rsdiscitems.cc +++ b/libretroshare/src/serialiser/rsdiscitems.cc @@ -146,6 +146,7 @@ void RsDiscOwnItem::clear() memset(&saddr, 0, sizeof(laddr)); contact_tf = 0; discFlags = 0; + ipAddressList.clear(); } std::ostream &RsDiscOwnItem::print(std::ostream &out, uint16_t indent) @@ -168,6 +169,16 @@ std::ostream &RsDiscOwnItem::print(std::ostream &out, uint16_t indent) printIndent(out, int_Indent); out << "DiscFlags: " << discFlags << std::endl; + printIndent(out, int_Indent); + out << "IpAddressListSize: " << ipAddressList.size() << std::endl; + + printIndent(out, int_Indent); + out << "RsDiscOwnItem::print() IpAddressList: " << std::endl; + for (std::list::iterator ipListIt = ipAddressList.begin(); ipListIt!=(ipAddressList.end()); ipListIt++) { + printIndent(out, int_Indent); + out << inet_ntoa(ipListIt->ipAddr.sin_addr) << ":" << ntohs(ipListIt->ipAddr.sin_port) << " seenTime : " << ipListIt->seenTime << std::endl; + } + printRsItemEnd(out, "RsDiscOwnItem", indent); return out; } @@ -210,7 +221,7 @@ bool RsDiscSerialiser::serialiseItem(RsDiscOwnItem *item, void *data, uint32 std::cerr << "RsDiscSerialiser::serialiseItem() Size: " << tlvsize << std::endl; #endif - /* skip the header */ + /* skip the header */ offset += 8; /* add mandatory parts first */ @@ -292,9 +303,9 @@ RsDiscOwnItem *RsDiscSerialiser::deserialiseOwnItem(void *data, uint32_t *pktsiz ok &= getRawUInt32(data, rssize, &offset, &listSize); //get the ip adress list - uint32_t count = 0; + int count = 0; std::list ipTimedList; - while (offset < rssize && count < listSize) { + while (offset < rssize && count < (int)listSize) { count++; IpAddressTimed ipTimed; ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr); @@ -344,6 +355,7 @@ void RsDiscReply::clear() discFlags = 0; aboutId.clear(); certDER.TlvClear(); + ipAddressList.clear(); } std::ostream &RsDiscReply::print(std::ostream &out, uint16_t indent) @@ -366,6 +378,16 @@ std::ostream &RsDiscReply::print(std::ostream &out, uint16_t indent) printIndent(out, int_Indent); out << "DiscFlags: " << discFlags << std::endl; + printIndent(out, int_Indent); + out << "IpAddressListSize: " << ipAddressList.size() << std::endl; + + printIndent(out, int_Indent); + out << "RsDiscOwnItem::print() IpAddressList: " << std::endl; + for (std::list::iterator ipListIt = ipAddressList.begin(); ipListIt!=(ipAddressList.end()); ipListIt++) { + printIndent(out, int_Indent); + out << inet_ntoa(ipListIt->ipAddr.sin_addr) << ":" << ntohs(ipListIt->ipAddr.sin_port) << " seenTime : " << ipListIt->seenTime << std::endl; + } + printIndent(out, int_Indent); out << "AboutId: " << aboutId << std::endl; certDER.print(out, int_Indent); @@ -502,9 +524,10 @@ RsDiscReply *RsDiscSerialiser::deserialiseReply(void *data, uint32_t *pktsize) ok &= getRawUInt32(data, rssize, &offset, &listSize); //get the ip adress list - uint32_t count = 0; + int count = 0; std::list ipTimedList; - while (offset < rssize && count < listSize) { + while (offset < rssize && count < (int)listSize) { + count++; IpAddressTimed ipTimed; ok &= GetTlvIpAddrPortV4(data, rssize, &offset, TLV_TYPE_IPV4_REMOTE, &ipTimed.ipAddr); uint64_t time;