/// <summary> /// Send message MSG_NEGO_REQ /// </summary> public void SendMsgNegoReq() { PccrrNegoRequestPacket packet = this.pccrrStack.CreateMsgNegoRequest(this.minSupV, this.maxSupV, this.cryptoAlgo, MsgType_Values.MSG_NEGO_REQ, this.protoVer); this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout)); PccrrPacket respMSG = this.pccrrStack.ExpectPacket(); PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket; MSG_NEGO_RESP msgNegoResp = pccrrNegoResponsePacket.MsgNegoResp; MESSAGE_HEADER messageHeader = pccrrNegoResponsePacket.MessageHeader; TRANSPORT_RESPONSE_HEADER transportRespH = pccrrNegoResponsePacket.TransportResponseHeader; RESPONSE_MESSAGE respMessage = new RESPONSE_MESSAGE(); respMessage.MESSAGEBODY = msgNegoResp; respMessage.MESSAGEHEADER = messageHeader; respMessage.TRANSPORTRESPONSEHEADER = transportRespH; this.uiPayload = Marshal.SizeOf(messageHeader) + Marshal.SizeOf(msgNegoResp); this.VerifyHttpResponse(); PccrrBothRoleCaptureCode.CaptureHttpRequirements(); this.VerifyMsgNegoResp(msgNegoResp); this.VerifyMessageHeader(messageHeader); PccrrBothRoleCaptureCode.CaptureMessageHeaderRequirements(messageHeader, this.uiPayload); this.VerifyTransportResponseHeader(transportRespH); PccrrBothRoleCaptureCode.CaptureMessageRequirements(); this.VerifyResponseMessage(respMessage); this.ReceiveMsgNegoResp(); }
/// <summary> /// Send message MSG_GETBLKLIST. /// </summary> /// <param name="sid">segment id.</param> /// <param name="blockRang">Block ranges client wants to get.</param> /// <param name="isVersionSupported">The version in message is supported by server or not.</param> public void SendMsgGetBlkList(byte[] sid, BLOCKRANGE[] blockRang, bool isVersionSupported) { PccrrGETBLKLISTRequestPacket packet; BLOCK_RANGE[] blockRanges = Helper.ConvertToStackBLOCKRANGEArray(blockRang); if (!isVersionSupported) { packet = this.pccrrStack.CreateMsgGetBlkListRequest(sid, blockRanges, this.cryptoAlgo, MsgType_Values.MSG_GETBLKLIST, this.protoErrorVer); } else { packet = this.pccrrStack.CreateMsgGetBlkListRequest(sid, blockRanges, this.cryptoAlgo, MsgType_Values.MSG_GETBLKLIST, this.protoVer); } this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout)); PccrrPacket respMSG = this.pccrrStack.ExpectPacket(); if (!isVersionSupported) { PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket; if (pccrrNegoResponsePacket != null) { this.ReceiveMsgNegoResp(); } } else { PccrrBLKLISTResponsePacket pccrrBLKLISTResponsePacket = respMSG as PccrrBLKLISTResponsePacket; MSG_BLKLIST msgBLKLIST = pccrrBLKLISTResponsePacket.MsgBLKLIST; MESSAGE_HEADER messageHeader = pccrrBLKLISTResponsePacket.MessageHeader; TRANSPORT_RESPONSE_HEADER transportRespH = pccrrBLKLISTResponsePacket.TransportResponseHeader; RESPONSE_MESSAGE respMessage = new RESPONSE_MESSAGE(); respMessage.MESSAGEBODY = msgBLKLIST; respMessage.MESSAGEHEADER = messageHeader; respMessage.TRANSPORTRESPONSEHEADER = transportRespH; if (msgBLKLIST.BlockRanges.Length != 0) { BLOCK_RANGE blockRange = pccrrBLKLISTResponsePacket.MsgBLKLIST.BlockRanges[0]; PccrrBothRoleCaptureCode.CaptureBlockRangeRequirements(blockRange); } this.VerifyMsgBlkList(msgBLKLIST); PccrrBothRoleCaptureCode.CaptureCommonDataTypesRequirements(msgBLKLIST); this.VerifyResponseMessage(respMessage); BLOCKRANGE[] blkRanges = Helper.ConvertFromStackBLOCKRANGEArray(msgBLKLIST.BlockRanges); this.ReceiveMsgBlkList(msgBLKLIST.BlockRangeCount, blkRanges, msgBLKLIST.NextBlockIndex); } }
/// <summary> /// Verify the received message from client. /// </summary> /// <param name="remoteAddr">The remote address.</param> /// <param name="pccrrPacket">The pccrrPacket.</param> private void RetrievalTransport_Receive(IPEndPoint remoteAddr, PccrrPacket pccrrPacket) { PccrrGETBLKSRequestPacket pccrrGETBLKSRequestPacket = pccrrPacket as PccrrGETBLKSRequestPacket; if (pccrrGETBLKSRequestPacket != null) { MSG_GETBLKS msgGETBLKS = pccrrGETBLKSRequestPacket.MsgGetBLKS; MESSAGE_HEADER messageHEADER = pccrrGETBLKSRequestPacket.MessageHeader; this.sid = msgGETBLKS.SegmentID; REQUEST_MESSAGE requestMESSAGE = new REQUEST_MESSAGE(); requestMESSAGE.MESSAGEBODY = msgGETBLKS; requestMESSAGE.MESSAGEHEADER = messageHEADER; this.uiPayload = Marshal.SizeOf(messageHEADER) + Marshal.SizeOf(msgGETBLKS) + 24; PccrrBothRoleCaptureCode.CaptureBlockRangeRequirements(msgGETBLKS.ReqBlockRanges[0]); PccrrBothRoleCaptureCode.CaptureMessageHeaderRequirements(messageHEADER, this.uiPayload); this.VerifyGetBlocks(msgGETBLKS); this.VerifyRequestMessage(requestMESSAGE); PccrrBothRoleCaptureCode.CaptureSegmentIdRequirements(msgGETBLKS.SegmentID); PccrrBothRoleCaptureCode.CaptureHttpRequirements(); PccrrBothRoleCaptureCode.CaptureMessageRequirements(); this.ReceiveMsgGetBlk(msgGETBLKS.ReqBlockRanges[0].Index); } else { PccrrGETBLKLISTRequestPacket pccrrGETBLKLISTRequestPacket = pccrrPacket as PccrrGETBLKLISTRequestPacket; if (pccrrGETBLKLISTRequestPacket != null) { MSG_GETBLKLIST msgGETBLKLIST = pccrrGETBLKLISTRequestPacket.MsgGetBLKLIST; this.sid = msgGETBLKLIST.SegmentID; this.VerifyGetBlkList(msgGETBLKLIST); PccrrBothRoleCaptureCode.CaptureCommonDataTypesRequirements(msgGETBLKLIST); _BLOCKRANGE[] blockRanges = ClientHelper.ConvertFromStackBLOCKRANGEArray(msgGETBLKLIST.NeededBlockRanges); this.ReceiveMsgGetBlkList(blockRanges); } else { this.ReceiveMsgNegoReq(); } } }
/// <summary> /// Initialize adapter data and create connection. /// </summary> /// <param name="testSite">the test site</param> public override void Initialize(ITestSite testSite) { base.Initialize(ReqConfigurableSite.GetReqConfigurableSite(testSite)); this.Site.DefaultProtocolDocShortName = "MS-PCCRR"; this.isDistributedMode = bool.Parse(this.GetProperty("Environment.IsDistributedMode")); if (!this.isDistributedMode) { this.isWindows = string.Equals( testSite.Properties["Environment.SecondContentClient.OSVersion"], "win2k8r2", StringComparison.OrdinalIgnoreCase); } else { this.isWindows = string.Equals( testSite.Properties["Environment.DistributedSUT.OSVersion"], "win2k8r2", StringComparison.OrdinalIgnoreCase); } this.cryptoAlgo = (CryptoAlgoId_Values)Enum.Parse(typeof(CryptoAlgoId_Values), this.GetProperty("PCCRR.Protocol.CryptoAlgoId_Value")); this.port = int.Parse(this.GetProperty("PCCRR.Protocol.HttpPort")); PccrrBothRoleCaptureCode.Initialize(this.Site); this.minSupV.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MinSupportedProtocolVersion.MinorVer")); this.minSupV.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MinSupportedProtocolVersion.MajorVer")); this.maxSupV.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MaxSupportedProtocolVersion.MinorVer")); this.maxSupV.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MaxSupportedProtocolVersion.MajorVer")); this.minErrorSupV.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.Error.MinSupportedProtocolVersion")); this.minErrorSupV.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MaxSupportedProtocolVersion.MajorVer")); this.maxErrorSupV.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.Error.MaxSupportedProtocolVersion")); this.maxErrorSupV.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MaxSupportedProtocolVersion.MajorVer")); this.protoVer.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MinorVer")); this.protoVer.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MajorVer")); this.protoErrorVer.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.ErrorProtocolVersion")); this.protoErrorVer.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_RESP.MaxSupportedProtocolVersion.MajorVer")); this.pccrrStackSer = new PccrrServer(this.port, string.Empty, IPAddressType.IPv4); this.pccrrStackSer.MessageArrived += new MessageArrivedEventArgs(this.RetrievalTransport_Receive); this.pccrrStackSer.StartListening(); }
/// <summary> /// Initialize adapter data and create connection. /// </summary> /// <param name="testSite">the test site</param> public override void Initialize(ITestSite testSite) { base.Initialize(ReqConfigurableSite.GetReqConfigurableSite(testSite)); this.Site.DefaultProtocolDocShortName = "MS-PCCRR"; PccrrBothRoleCaptureCode.Initialize(this.Site); this.isDistributedMode = bool.Parse(this.GetProperty("Environment.IsDistributedMode")); if (this.isDistributedMode) { this.isWindows = string.Equals( this.GetProperty("Environment.DistributedSUT.OSVersion"), "win2k8r2", StringComparison.OrdinalIgnoreCase); this.serverName = this.GetProperty("Environment.DistributedSUT.MachineName"); } else { this.isWindows = string.Equals( this.GetProperty("Environment.HostedCacheServer.OSVersion"), "win2k8r2", StringComparison.OrdinalIgnoreCase); this.serverName = this.GetProperty("Environment.HostedCacheServer.MachineName"); } this.cryptoAlgo = (CryptoAlgoId_Values)Enum.Parse(typeof(CryptoAlgoId_Values), this.GetProperty("PCCRR.Protocol.CryptoAlgoId_Value")); this.timeout = int.Parse(this.GetProperty("PCCRR.Protocol.timeout")); this.port = int.Parse(this.GetProperty("PCCRR.Protocol.Http.Port")); this.protoErrorVer.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.ErrorProtocolVersion")); this.protoErrorVer.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.ErrorProtocolVersion")); this.minSupV.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MinorVer")); this.minSupV.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MajorVer")); this.maxSupV.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MaxSupportedProtocolVersion.MinorVer")); this.maxSupV.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MaxSupportedProtocolVersion.MajorVer")); this.protoVer.MinorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MinorVer")); this.protoVer.MajorVersion = ushort.Parse(this.GetProperty("PCCRR.Protocol.MSG_NEGO_REQ.MinSupportedProtocolVersion.MajorVer")); this.pccrrStack = new PccrrClient(this.serverName, this.port, PccrrUri, HttpMethod.POST); }
/// <summary> /// Send message MSG_GETBLKS /// </summary> /// <param name="sid">segment id.</param> /// <param name="blockRang">Block ranges client wants to get</param> /// <param name="isVersionSupported">The version in this message is supported in server.</param> public void SendMsgGetBlks(byte[] sid, BLOCKRANGE[] blockRang, bool isVersionSupported) { PccrrGETBLKSRequestPacket packet; BLOCK_RANGE[] blockRanges = Helper.ConvertToStackBLOCKRANGEArray(blockRang); if (!isVersionSupported) { packet = this.pccrrStack.CreateMsgGetBlksRequest(sid, this.cryptoAlgo, MsgType_Values.MSG_GETBLKS, this.protoErrorVer); } else { packet = this.pccrrStack.CreateMsgGetBlksRequest(sid, this.cryptoAlgo, MsgType_Values.MSG_GETBLKS, this.protoVer); } for (int i = 0; i < blockRanges.Length; i++) { if (blockRanges.Length == 1) { packet.MsgGetBLKS.ReqBlockRanges[i].Index = blockRanges[i].Index; packet.MsgGetBLKS.ReqBlockRanges[i].Count = blockRanges[i].Count; } else { MSG_GETBLKS msgGETBLKS = packet.MsgGetBLKS; msgGETBLKS.ReqBlockRanges = new BLOCK_RANGE[blockRanges.Length]; msgGETBLKS.ReqBlockRangeCount = (uint)blockRanges.Length; packet.MsgGetBLKS = msgGETBLKS; packet.MsgGetBLKS.ReqBlockRanges[i].Index = blockRanges[i].Index; packet.MsgGetBLKS.ReqBlockRanges[i].Count = blockRanges[i].Count; } } this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout)); PccrrPacket respMSG = this.pccrrStack.ExpectPacket(); if (!isVersionSupported) { PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket; if (pccrrNegoResponsePacket != null) { this.ReceiveMsgNegoResp(); } } else { PccrrBLKResponsePacket pccrrBLKResponsePacket = respMSG as PccrrBLKResponsePacket; MSG_BLK msgBLK = pccrrBLKResponsePacket.MsgBLK; MESSAGE_HEADER messageHeader = pccrrBLKResponsePacket.MessageHeader; TRANSPORT_RESPONSE_HEADER transportRespH = pccrrBLKResponsePacket.TransportResponseHeader; RESPONSE_MESSAGE respMessage = new RESPONSE_MESSAGE(); respMessage.MESSAGEBODY = msgBLK; respMessage.MESSAGEHEADER = messageHeader; respMessage.TRANSPORTRESPONSEHEADER = transportRespH; this.VerifyMsgBlk(msgBLK); PccrrBothRoleCaptureCode.CaptureSegmentIdRequirements(msgBLK.SegmentId); this.VerifyResponseMessage(respMessage); bool isSizeOfBlockZero = false; if (msgBLK.SizeOfBlock == 0) { isSizeOfBlockZero = true; } else { isSizeOfBlockZero = false; } bool isBlockEmpty = false; if (msgBLK.Block.Length == 0) { isBlockEmpty = true; } else { isBlockEmpty = false; } CryptoAlgoIdValues crypAlgoId = Helper.ConvertFromStackCryptoAlgoIdValues(pccrrBLKResponsePacket.MessageHeader.CryptoAlgoId); this.ReceiveMsgBlk(msgBLK.BlockIndex, msgBLK.NextBlockIndex, isSizeOfBlockZero, isBlockEmpty, crypAlgoId); } }