/// <summary> /// Create a MsgGetBlks request. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <returns>MsgGetBlks request.</returns> public PccrrGETBLKSRequestPacket CreateMsgGetBlksRequest( byte[] segmentId, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { if (segmentId == null) { segmentId = new byte[0]; } PccrrGETBLKSRequestPacket packet = new PccrrGETBLKSRequestPacket(); MSG_GETBLKS msgGetBlksReq = new MSG_GETBLKS(); msgGetBlksReq.DataForVrfBlock = null; byte[] zeroPad = new byte[0] { }; BLOCK_RANGE[] reqBlockRanges = new BLOCK_RANGE[1]; reqBlockRanges[0].Index = 0; reqBlockRanges[0].Count = 1; msgGetBlksReq.ReqBlockRanges = reqBlockRanges; msgGetBlksReq.ReqBlockRangeCount = (uint)reqBlockRanges.Length; msgGetBlksReq.ZeroPad = zeroPad; msgGetBlksReq.SizeOfSegmentID = (uint)segmentId.Length; msgGetBlksReq.SizeOfDataForVrfBlock = 0; msgGetBlksReq.SegmentID = segmentId; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgGetBLKS = msgGetBlksReq; packet.MessageHeader = messageHeader; return(packet); }
/// <summary> /// Create a MsgBlk response. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="block">The block.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <param name="isLastBLKAvail">If it is true, the block is the last available block.</param> /// <returns>The MsgBlk response.</returns> public PccrrBLKResponsePacket CreateMsgBlkResponse( byte[] segmentId, byte[] block, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues, bool isLastBLKAvail) { if (segmentId == null) { segmentId = new byte[0]; } if (block == null) { block = new byte[0]; } PccrrBLKResponsePacket packet = new PccrrBLKResponsePacket(); MSG_BLK msgBlkResp = new MSG_BLK(); byte[] zeroPad = new byte[0] { }; byte[] zeroPad_2 = new byte[0] { }; byte[] zeroPad_3 = new byte[0] { }; byte[] iVBlock = new byte[0] { }; msgBlkResp.ZeroPad3 = zeroPad_3; msgBlkResp.ZeroPad2 = zeroPad_2; msgBlkResp.ZeroPad = zeroPad; msgBlkResp.VrfBlock = null; msgBlkResp.SizeOfVrfBlock = 0; msgBlkResp.SizeOfSegmentId = (uint)segmentId.Length; msgBlkResp.SizeOfIVBlock = (uint)iVBlock.Length; msgBlkResp.SizeOfBlock = (uint)block.Length; msgBlkResp.SegmentId = segmentId; msgBlkResp.IVBlock = iVBlock; msgBlkResp.Block = block; msgBlkResp.BlockIndex = 0; if (!isLastBLKAvail) { msgBlkResp.NextBlockIndex = 1; } else { msgBlkResp.NextBlockIndex = 0; } MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgBLK = msgBlkResp; packet.MessageHeader = messageHeader; return(packet); }
/// <summary> /// Create MessageHeader. /// </summary> /// <param name="cryptoAlgoIdValues">The cryptoAlgoIdValues.</param> /// <param name="msgTypeValues">The msgTypeValues.</param> /// <param name="protoVer">The protoVer.</param> /// <returns>The MESSAGE_HEADER struct.</returns> public static MESSAGE_HEADER CreateMessageHeader(CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues, ProtoVersion protoVer) { MESSAGE_HEADER messageHeader = new MESSAGE_HEADER(); messageHeader.CryptoAlgoId = cryptoAlgoIdValues; messageHeader.MsgType = msgTypeValues; messageHeader.MsgSize = 16; messageHeader.ProtVer = protoVer; return messageHeader; }
/// <summary> /// Create a MsgNego response. /// </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>The MsgNego response.</returns> public PccrrNegoResponsePacket CreateMsgNegoResponse( ProtoVersion minSupportedProtocolVer, ProtoVersion maxSupportedProtocolVer, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { PccrrNegoResponsePacket packet = new PccrrNegoResponsePacket(); MSG_NEGO_RESP msgNegoResp = new MSG_NEGO_RESP(); msgNegoResp.MaxSupporteProtocolVersion = maxSupportedProtocolVer; msgNegoResp.MinSupporteProtocolVersion = minSupportedProtocolVer; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgNegoResp = msgNegoResp; packet.MessageHeader = messageHeader; return(packet); }
/// <summary> /// Create a MsgBlkList response. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="blockRanges">The blockRanges.</param> /// <param name="nextBlockIndex">The nextBlockIndex.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <returns>The MsgBlkList response.</returns> public PccrrBLKLISTResponsePacket CreateMsgBlkListResponse( byte[] segmentId, BLOCK_RANGE[] blockRanges, uint nextBlockIndex, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { if (segmentId == null) { segmentId = new byte[0]; } if (blockRanges == null) { blockRanges = new BLOCK_RANGE[0]; } PccrrBLKLISTResponsePacket packet = new PccrrBLKLISTResponsePacket(); MSG_BLKLIST msgBlkListResp = new MSG_BLKLIST(); byte[] zeroPad = new byte[0] { }; msgBlkListResp.ZeroPad = zeroPad; msgBlkListResp.SizeOfSegmentId = (uint)segmentId.Length; msgBlkListResp.SegmentId = segmentId; msgBlkListResp.BlockRanges = blockRanges; msgBlkListResp.BlockRangeCount = (uint)blockRanges.Length; msgBlkListResp.NextBlockIndex = nextBlockIndex; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgBLKLIST = msgBlkListResp; packet.MessageHeader = messageHeader; return(packet); }
/// <summary> /// Create a MsgGetBlkList request. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="blockRanges">The needed BlockRanges.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <returns>MsgGetBlkList request.</returns> public PccrrGETBLKLISTRequestPacket CreateMsgGetBlkListRequest( byte[] segmentId, BLOCK_RANGE[] blockRanges, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { if (segmentId == null) { segmentId = new byte[0]; } if (blockRanges == null) { blockRanges = new BLOCK_RANGE[0]; } PccrrGETBLKLISTRequestPacket packet = new PccrrGETBLKLISTRequestPacket(); MSG_GETBLKLIST msgGetBlkListReq = new MSG_GETBLKLIST(); byte[] zeroPad = new byte[0] { }; msgGetBlkListReq.SegmentID = segmentId; msgGetBlkListReq.SizeOfSegmentID = (uint)segmentId.Length; msgGetBlkListReq.NeededBlockRanges = blockRanges; msgGetBlkListReq.NeededBlocksRangeCount = (uint)blockRanges.Length; msgGetBlkListReq.ZeroPad = zeroPad; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgGetBLKLIST = msgGetBlkListReq; packet.MessageHeader = messageHeader; return(packet); }
/// <summary> /// Create MessageHeader. /// </summary> /// <param name="cryptoAlgoIdValues">The cryptoAlgoIdValues.</param> /// <param name="msgTypeValues">The msgTypeValues.</param> /// <param name="protoVer">The protoVer.</param> /// <returns>The MESSAGE_HEADER struct.</returns> public static MESSAGE_HEADER CreateMessageHeader(CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues, ProtoVersion protoVer) { MESSAGE_HEADER messageHeader = new MESSAGE_HEADER(); messageHeader.CryptoAlgoId = cryptoAlgoIdValues; messageHeader.MsgType = msgTypeValues; messageHeader.MsgSize = 16; messageHeader.ProtVer = protoVer; return(messageHeader); }
/// <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; }
/// <summary> /// Create a MsgGetBlks request. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <returns>MsgGetBlks request.</returns> public PccrrGETBLKSRequestPacket CreateMsgGetBlksRequest( byte[] segmentId, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { if (segmentId == null) { segmentId = new byte[0]; } PccrrGETBLKSRequestPacket packet = new PccrrGETBLKSRequestPacket(); MSG_GETBLKS msgGetBlksReq = new MSG_GETBLKS(); msgGetBlksReq.DataForVrfBlock = null; byte[] zeroPad = new byte[0] { }; BLOCK_RANGE[] reqBlockRanges = new BLOCK_RANGE[1]; reqBlockRanges[0].Index = 0; reqBlockRanges[0].Count = 1; msgGetBlksReq.ReqBlockRanges = reqBlockRanges; msgGetBlksReq.ReqBlockRangeCount = (uint)reqBlockRanges.Length; msgGetBlksReq.ZeroPad = zeroPad; msgGetBlksReq.SizeOfSegmentID = (uint)segmentId.Length; msgGetBlksReq.SizeOfDataForVrfBlock = 0; msgGetBlksReq.SegmentID = segmentId; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgGetBLKS = msgGetBlksReq; packet.MessageHeader = messageHeader; return packet; }
/// <summary> /// Create a MsgGetBlkList request. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="blockRanges">The needed BlockRanges.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <returns>MsgGetBlkList request.</returns> public PccrrGETBLKLISTRequestPacket CreateMsgGetBlkListRequest( byte[] segmentId, BLOCK_RANGE[] blockRanges, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { if (segmentId == null) { segmentId = new byte[0]; } if (blockRanges == null) { blockRanges = new BLOCK_RANGE[0]; } PccrrGETBLKLISTRequestPacket packet = new PccrrGETBLKLISTRequestPacket(); MSG_GETBLKLIST msgGetBlkListReq = new MSG_GETBLKLIST(); byte[] zeroPad = new byte[0] { }; msgGetBlkListReq.SegmentID = segmentId; msgGetBlkListReq.SizeOfSegmentID = (uint)segmentId.Length; msgGetBlkListReq.NeededBlockRanges = blockRanges; msgGetBlkListReq.NeededBlocksRangeCount = (uint)blockRanges.Length; msgGetBlkListReq.ZeroPad = zeroPad; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgGetBLKLIST = msgGetBlkListReq; packet.MessageHeader = messageHeader; return packet; }
/// <summary> /// Create a MsgBlk response. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="block">The block.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <param name="isLastBLKAvail">If it is true, the block is the last available block.</param> /// <returns>The MsgBlk response.</returns> public PccrrBLKResponsePacket CreateMsgBlkResponse( byte[] segmentId, byte[] block, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues, bool isLastBLKAvail) { if (segmentId == null) { segmentId = new byte[0]; } if (block == null) { block = new byte[0]; } PccrrBLKResponsePacket packet = new PccrrBLKResponsePacket(); MSG_BLK msgBlkResp = new MSG_BLK(); byte[] zeroPad = new byte[0] { }; byte[] zeroPad_2 = new byte[0] { }; byte[] zeroPad_3 = new byte[0] { }; byte[] iVBlock = new byte[0] { }; msgBlkResp.ZeroPad3 = zeroPad_3; msgBlkResp.ZeroPad2 = zeroPad_2; msgBlkResp.ZeroPad = zeroPad; msgBlkResp.VrfBlock = null; msgBlkResp.SizeOfVrfBlock = 0; msgBlkResp.SizeOfSegmentId = (uint)segmentId.Length; msgBlkResp.SizeOfIVBlock = (uint)iVBlock.Length; msgBlkResp.SizeOfBlock = (uint)block.Length; msgBlkResp.SegmentId = segmentId; msgBlkResp.IVBlock = iVBlock; msgBlkResp.Block = block; msgBlkResp.BlockIndex = 0; if (!isLastBLKAvail) { msgBlkResp.NextBlockIndex = 1; } else { msgBlkResp.NextBlockIndex = 0; } MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgBLK = msgBlkResp; packet.MessageHeader = messageHeader; return packet; }
/// <summary> /// Create a MsgBlkList response. /// </summary> /// <param name="segmentId">The segmentId.</param> /// <param name="blockRanges">The blockRanges.</param> /// <param name="nextBlockIndex">The nextBlockIndex.</param> /// <param name="cryptoAlgoIdValues">The cryptoAlgoId.</param> /// <param name="msgTypeValues">The msgType.</param> /// <returns>The MsgBlkList response.</returns> public PccrrBLKLISTResponsePacket CreateMsgBlkListResponse( byte[] segmentId, BLOCK_RANGE[] blockRanges, uint nextBlockIndex, CryptoAlgoId_Values cryptoAlgoIdValues, MsgType_Values msgTypeValues) { if (segmentId == null) { segmentId = new byte[0]; } if (blockRanges == null) { blockRanges = new BLOCK_RANGE[0]; } PccrrBLKLISTResponsePacket packet = new PccrrBLKLISTResponsePacket(); MSG_BLKLIST msgBlkListResp = new MSG_BLKLIST(); byte[] zeroPad = new byte[0] { }; msgBlkListResp.ZeroPad = zeroPad; msgBlkListResp.SizeOfSegmentId = (uint)segmentId.Length; msgBlkListResp.SegmentId = segmentId; msgBlkListResp.BlockRanges = blockRanges; msgBlkListResp.BlockRangeCount = (uint)blockRanges.Length; msgBlkListResp.NextBlockIndex = nextBlockIndex; MESSAGE_HEADER messageHeader = PccrrUtitlity.CreateMessageHeader(cryptoAlgoIdValues, msgTypeValues, new ProtoVersion { MajorVersion = 1, MinorVersion = 0 }); packet.MsgBLKLIST = msgBlkListResp; packet.MessageHeader = messageHeader; return packet; }