Exemple #1
0
        public override void ParseBytes(byte[] data)
        {
            if (Version == P2PVersion.P2PV1)
            {
                base.ParseBytes(data);

                P2Pv1Header head = this.V1Header;

                Guid = new Guid(
                    (int)head.AckSessionId,

                    (short)(head.AckIdentifier & 0x0000FFFF),
                    (short)((head.AckIdentifier & 0xFFFF0000) >> 16),

                    (byte)((head.AckTotalSize & 0x00000000000000FF)),
                    (byte)((head.AckTotalSize & 0x000000000000FF00) >> 8),
                    (byte)((head.AckTotalSize & 0x0000000000FF0000) >> 16),
                    (byte)((head.AckTotalSize & 0x00000000FF000000) >> 24),
                    (byte)((head.AckTotalSize & 0x000000FF00000000) >> 32),
                    (byte)((head.AckTotalSize & 0x0000FF0000000000) >> 40),
                    (byte)((head.AckTotalSize & 0x00FF000000000000) >> 48),
                    (byte)((head.AckTotalSize & 0xFF00000000000000) >> 56)
                    );
            }
            else
            {
                // Don't call base.ParseBytes(); Data is 16 bytes for v2.
                Guid = HashedNonceGenerator.CreateGuidFromData(Version, data);
            }

            InnerBody = new byte[0];
        }
Exemple #2
0
        public override P2PHeader CreateNak()
        {
            P2Pv1Header nak = (P2Pv1Header)CreateAck();

            nak.Flags = P2PFlag.NegativeAck;
            return(nak);
        }
Exemple #3
0
        public override P2PHeader CreateAck()
        {
            P2Pv1Header ack = new P2Pv1Header();

            ack.SessionId     = SessionId;
            ack.TotalSize     = 0;
            ack.Flags         = P2PFlag.Acknowledgement;
            ack.AckSessionId  = Identifier;
            ack.AckIdentifier = AckSessionId;
            ack.AckTotalSize  = TotalSize;
            return(ack);
        }
Exemple #4
0
 public override P2PHeader CreateAck()
 {
     P2Pv1Header ack = new P2Pv1Header();
     ack.SessionId = SessionId;
     ack.TotalSize = 0;
     ack.Flags = P2PFlag.Acknowledgement;
     ack.AckSessionId = Identifier;
     ack.AckIdentifier = AckSessionId;
     ack.AckTotalSize = TotalSize;
     return ack;
 }