Author: alanmc
Date: 2006-09-13 11:07:37 -0400 (Wed, 13 Sep 2006)
New Revision: 65356
Modified:
branches/BitSharp/bitsharp/src/MonoTorrent.Client/PeerMessages/HandshakeMessage.cs
Log:
Printing out all activated bits and their corresponding index for handshakes
Modified:
branches/BitSharp/bitsharp/src/MonoTorrent.Client/PeerMessages/HandshakeMessage.cs
===================================================================
---
branches/BitSharp/bitsharp/src/MonoTorrent.Client/PeerMessages/HandshakeMessage.cs
2006-09-13 15:05:46 UTC (rev 65355)
+++
branches/BitSharp/bitsharp/src/MonoTorrent.Client/PeerMessages/HandshakeMessage.cs
2006-09-13 15:07:37 UTC (rev 65356)
@@ -110,7 +110,7 @@
public HandshakeMessage()
{
this.FastPeersFlag = 0x04;
-
+#warning This isn't necessary. Endianness just affects the order of the bytes,
not the bits
if (BitConverter.IsLittleEndian)
this.ExtendedFlag = 1<<7;
@@ -198,10 +198,29 @@
CheckForSupports(buffer, offset + protocolStringLength + 1);
}
+
private void CheckForSupports(byte[] buffer, int
reservedBytesStartIndex)
{
this.supportsExtended = (this.ExtendedFlag &
buffer[reservedBytesStartIndex]) != 0;
this.supportsFastPeer = (this.FastPeersFlag &
buffer[reservedBytesStartIndex + 7]) != 0;
+ int bitNumber = 0;
+ for (int i = reservedBytesStartIndex; i < reservedBytesStartIndex
+ 8; i++)
+ {
+ if (buffer[i] != 0)
+ {
+ for (int j = 7; j >= 0; j--)
+ {
+ int temp = 1 << j;
+ if ((buffer[i] & temp) > 0)
+ {
+ int value = ((i - reservedBytesStartIndex) * 8 + 7
- j) + 1;
+ System.Diagnostics.Debug.Write("\n");
+ System.Diagnostics.Debug.Write(value.ToString());
+ System.Diagnostics.Debug.Write("\t" + this.PeerId);
+ }
+ }
+ }
+ }
}
@@ -250,4 +269,4 @@
}
#endregion
}
-}
\ No newline at end of file
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches