The Negotiation Request message is a request for the minimum and maximum protocol version supported by the target server-role peer. The message contains the minimum and maximum protocol version supported by the requesting client-role peer.
Ejemplo n.º 1
0
        /// <summary>
        /// Decode MSG_NEGO_REQ message.
        /// </summary>
        /// <param name="data">Data to be decoded.</param>
        /// <param name="index">Started index.</param>
        /// <returns>The MSG_NEGO_REQ struct.</returns>
        private MSG_NEGO_REQ DecodeMSG_NEGO_REQ(byte[] data, ref int index)
        {
            MSG_NEGO_REQ ret = new MSG_NEGO_REQ();

            ret.MinSupportedProtocolVersion.MinorVersion = MarshalHelper.GetUInt16(data, ref index, false);
            ret.MinSupportedProtocolVersion.MajorVersion = MarshalHelper.GetUInt16(data, ref index, false);
            ret.MaxSupportedProtocolVersion.MinorVersion = MarshalHelper.GetUInt16(data, ref index, false);
            ret.MaxSupportedProtocolVersion.MajorVersion = MarshalHelper.GetUInt16(data, ref index, false);

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a MsgNego request.
        /// </summary>
        /// <param name="minSupportedProtocolVer">The minSupportedProtocolVersion.</param>
        /// <param name="maxSupportedProtocolVer">The maxSupportedProtocolVersion.</param>
        /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param>
        /// <param name="msgTypeValues">The msgType.</param>
        /// <returns>MsgNego request.</returns>
        public PccrrNegoRequestPacket CreateMsgNegoRequest(
            ProtoVersion minSupportedProtocolVer,
            ProtoVersion maxSupportedProtocolVer,
            CryptoAlgoId_Values cryptoAlgoIdValues,
            MsgType_Values msgTypeValues)
        {
            PccrrNegoRequestPacket packet = new PccrrNegoRequestPacket();

            MSG_NEGO_REQ msgNegoReq = new MSG_NEGO_REQ();

            msgNegoReq.MinSupportedProtocolVersion = minSupportedProtocolVer;
            msgNegoReq.MaxSupportedProtocolVersion = maxSupportedProtocolVer;
            MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion {
                MajorVersion = 1, MinorVersion = 0
            });

            packet.MsgNegoReq    = msgNegoReq;
            packet.MessageHeader = messageHeader;

            return(packet);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Decode request message.
        /// </summary>
        /// <param name="rawdata">The raw data.</param>
        /// <param name="uri">The request uri.</param>
        /// <param name="method">The request method.</param>
        /// <returns>The PccrrPacket.</returns>
        public PccrrPacket DecodeRequestMessage(byte[] rawdata, Uri uri, HttpMethod method)
        {
            if (rawdata == null)
            {
                throw new ArgumentNullException("rawdata");
            }

            if (rawdata.Length == 0)
            {
                throw new ArgumentException("The rawdata should not be empty.");
            }

            int messageLength = 0;

            messageLength = rawdata.Length;

            PccrrPacket packet = null;

            if (messageLength > 0)
            {
                int index = 0;

                REQUEST_MESSAGE ret = new REQUEST_MESSAGE();
                ret.MESSAGEHEADER = this.DecodeMessageHeader(rawdata, ref index);

                switch (ret.MESSAGEHEADER.MsgType)
                {
                case MsgType_Values.MSG_NEGO_REQ:
                    PccrrNegoRequestPacket pccrrNegoRequestPacket = new PccrrNegoRequestPacket();

                    MSG_NEGO_REQ msgNEGOREQ = this.DecodeMSG_NEGO_REQ(rawdata, ref index);
                    pccrrNegoRequestPacket.MsgNegoReq    = msgNEGOREQ;
                    pccrrNegoRequestPacket.MessageHeader = ret.MESSAGEHEADER;
                    pccrrNegoRequestPacket.Method        = method;
                    pccrrNegoRequestPacket.Uri           = uri;
                    packet = pccrrNegoRequestPacket;
                    break;

                case MsgType_Values.MSG_GETBLKLIST:
                    PccrrGETBLKLISTRequestPacket pccrrGETBLKLISTRequestPacket = new PccrrGETBLKLISTRequestPacket();

                    MSG_GETBLKLIST msgGETBLKLIST = this.DecodeMSG_GETBLKLIST(rawdata, ref index);
                    pccrrGETBLKLISTRequestPacket.MsgGetBLKLIST = msgGETBLKLIST;
                    pccrrGETBLKLISTRequestPacket.MessageHeader = ret.MESSAGEHEADER;
                    pccrrGETBLKLISTRequestPacket.Method        = method;
                    pccrrGETBLKLISTRequestPacket.Uri           = uri;
                    packet = pccrrGETBLKLISTRequestPacket;
                    break;

                case MsgType_Values.MSG_GETBLKS:
                    PccrrGETBLKSRequestPacket pccrrGETBLKSRequestPacket = new PccrrGETBLKSRequestPacket();

                    MSG_GETBLKS msgGETBLKS = this.DecodeMSG_GETBLKS(rawdata, ref index);
                    pccrrGETBLKSRequestPacket.MsgGetBLKS    = msgGETBLKS;
                    pccrrGETBLKSRequestPacket.MessageHeader = ret.MESSAGEHEADER;
                    pccrrGETBLKSRequestPacket.Method        = method;
                    pccrrGETBLKSRequestPacket.Uri           = uri;
                    packet = pccrrGETBLKSRequestPacket;
                    break;

                case MsgType_Values.MSG_GETSEGLIST:
                    PccrrGetSegListRequestPacket pccrrGetSegListRequestPacket = new PccrrGetSegListRequestPacket();
                    pccrrGetSegListRequestPacket.MsgGetSegList = TypeMarshal.ToStruct <MSG_GETSEGLIST>(rawdata, ref index);
                    pccrrGetSegListRequestPacket.MessageHeader = ret.MESSAGEHEADER;
                    pccrrGetSegListRequestPacket.Method        = method;
                    pccrrGetSegListRequestPacket.Uri           = uri;
                    packet = pccrrGetSegListRequestPacket;
                    break;
                }
            }

            return(packet);
        }
        /// <summary>
        /// Decode MSG_NEGO_REQ message.
        /// </summary>
        /// <param name="data">Data to be decoded.</param>
        /// <param name="index">Started index.</param>
        /// <returns>The MSG_NEGO_REQ struct.</returns>
        private MSG_NEGO_REQ DecodeMSG_NEGO_REQ(byte[] data, ref int index)
        {
            MSG_NEGO_REQ ret = new MSG_NEGO_REQ();
            ret.MinSupportedProtocolVersion.MinorVersion = MarshalHelper.GetUInt16(data, ref index, false);
            ret.MinSupportedProtocolVersion.MajorVersion = MarshalHelper.GetUInt16(data, ref index, false);
            ret.MaxSupportedProtocolVersion.MinorVersion = MarshalHelper.GetUInt16(data, ref index, false);
            ret.MaxSupportedProtocolVersion.MajorVersion = MarshalHelper.GetUInt16(data, ref index, false);

            return ret;
        }
        /// <summary>
        /// Create a MsgNego request.
        /// </summary>
        /// <param name="minSupportedProtocolVer">The minSupportedProtocolVersion.</param>
        /// <param name="maxSupportedProtocolVer">The maxSupportedProtocolVersion.</param>
        /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param>
        /// <param name="msgTypeValues">The msgType.</param>
        /// <returns>MsgNego request.</returns>
        public PccrrNegoRequestPacket CreateMsgNegoRequest(
            ProtoVersion minSupportedProtocolVer,
            ProtoVersion maxSupportedProtocolVer,
            CryptoAlgoId_Values cryptoAlgoIdValues,
            MsgType_Values msgTypeValues)
        {
            PccrrNegoRequestPacket packet = new PccrrNegoRequestPacket();

            MSG_NEGO_REQ msgNegoReq = new MSG_NEGO_REQ();
            msgNegoReq.MinSupportedProtocolVersion = minSupportedProtocolVer;
            msgNegoReq.MaxSupportedProtocolVersion = maxSupportedProtocolVer;
            MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 });
            packet.MsgNegoReq = msgNegoReq;
            packet.MessageHeader = messageHeader;

            return packet;
        }