/// <summary>
 /// Initialize an instance of RpcePdu class.
 /// </summary>
 /// <param name="context">context</param>
 /// <exception cref="ArgumentNullException">
 /// Thrown when context is null.
 /// </exception>
 protected RpcePdu(RpceContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.context = context;
 }
예제 #2
0
 protected RpceCoPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
     using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(pduBytes)))
     {
         FromBytes(binaryReader);
     }
 }
예제 #3
0
 /// <summary>
 /// Initialize an instance of RpcePdu class.
 /// </summary>
 /// <param name="context">context</param>
 /// <exception cref="ArgumentNullException">
 /// Thrown when context is null.
 /// </exception>
 protected RpcePdu(RpceContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.context = context;
 }
예제 #4
0
        /// <summary>
        /// Initialize an instance of RpcePdu class.
        /// </summary>
        /// <param name="context">context</param>
        /// <param name="pduBytes">A byte array contains PDU data.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when context or pduBytes is null.
        /// </exception>
        protected RpcePdu(RpceContext context, byte[] pduBytes)
            : base(pduBytes)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (pduBytes == null)
            {
                throw new ArgumentNullException("pduBytes");
            }

            this.context = context;
        }
        /// <summary>
        /// Initialize an instance of RpcePdu class.
        /// </summary>
        /// <param name="context">context</param>
        /// <param name="pduBytes">A byte array contains PDU data.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when context or pduBytes is null.
        /// </exception>
        protected RpcePdu(RpceContext context, byte[] pduBytes)
            : base(pduBytes)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (pduBytes == null)
            {
                throw new ArgumentNullException("pduBytes");
            }

            this.context = context;
        }
예제 #6
0
        /// <summary>
        /// Decode CO PDU.
        /// </summary>
        /// <param name="context">The context that received data.</param>
        /// <param name="messageBytes">bytes received</param>
        /// <param name="consumedLength">num of bytes consumed in processing</param>
        /// <param name="expectedLength">num of bytes expected if the bytes is not enough</param>
        /// <returns>pdus</returns>
        internal static RpceCoPdu[] DecodeCoPdu(
            RpceContext context,
            byte[] messageBytes,
            out int consumedLength,
            out int expectedLength)
        {
            List <RpceCoPdu> pduList = new List <RpceCoPdu>();

            consumedLength = 0;
            expectedLength = 0;

            while (consumedLength < messageBytes.Length)
            {
                if ((messageBytes.Length - consumedLength) < RpceUtility.CO_PDU_HEADER_SIZE)
                {
                    expectedLength = RpceUtility.CO_PDU_HEADER_SIZE;
                    break;
                }

                //#4 byte is drep
                uint dataRepresentation = BitConverter.ToUInt32(
                    messageBytes,
                    consumedLength + RpceUtility.DREP_FIELD_OFFSET);
                //#8 byte is frag_length
                ushort fragmentLength = BitConverter.ToUInt16(
                    messageBytes,
                    consumedLength + RpceUtility.FRAG_LENGTH_FIELD_OFFSET);
                if ((dataRepresentation & 0x0000FFFFU) != NativeMethods.NDR_LOCAL_DATA_REPRESENTATION)
                {
                    fragmentLength = EndianUtility.ReverseByteOrder(fragmentLength);
                }

                if ((messageBytes.Length - consumedLength) < fragmentLength)
                {
                    expectedLength = fragmentLength;
                    break;
                }

                byte[] pduBytes = new byte[fragmentLength];
                Buffer.BlockCopy(messageBytes, consumedLength, pduBytes, 0, fragmentLength);

                RpceCoPdu pdu = RpceUtility.DecodeCoPdu(context, pduBytes);

                pduList.Add(pdu);
                consumedLength += fragmentLength;
            }

            return(pduList.ToArray());
        }
        /// <summary>
        /// Decode CO PDU.
        /// </summary>
        /// <param name="context">The context that received data.</param>
        /// <param name="messageBytes">bytes received</param>
        /// <param name="consumedLength">num of bytes consumed in processing</param>
        /// <param name="expectedLength">num of bytes expected if the bytes is not enough</param>
        /// <returns>pdus</returns>
        internal static RpceCoPdu[] DecodeCoPdu(
            RpceContext context,
            byte[] messageBytes,
            out int consumedLength,
            out int expectedLength)
        {
            List <RpceCoPdu> pduList = new List <RpceCoPdu>();

            consumedLength = 0;
            expectedLength = 0;

            while (consumedLength < messageBytes.Length)
            {
                if ((messageBytes.Length - consumedLength) < RpceUtility.CO_PDU_HEADER_SIZE)
                {
                    expectedLength = RpceUtility.CO_PDU_HEADER_SIZE;
                    break;
                }

                //#8 byte is frag_length
                ushort fragmentLength = BitConverter.ToUInt16(
                    messageBytes,
                    consumedLength + RpceUtility.FRAG_LENGTH_FIELD_OFFSET);
                if ((messageBytes.Length - consumedLength) < fragmentLength)
                {
                    expectedLength = fragmentLength;
                    break;
                }

                byte[] pduBytes = new byte[fragmentLength];
                Buffer.BlockCopy(messageBytes, consumedLength, pduBytes, 0, fragmentLength);

                RpceCoPdu pdu = RpceUtility.DecodeCoPdu(context, pduBytes);

                pduList.Add(pdu);
                consumedLength += fragmentLength;
            }

            return(pduList.ToArray());
        }
예제 #8
0
        /// <summary>
        /// Fragment a PDU
        /// </summary>
        /// <param name="context">RpceContext to fragment PDU</param>
        /// <typeparam name="T">Type of PDU to fragment</typeparam>
        /// <param name="pdu">PDU to fragment</param>
        /// <param name="stubLength">length of data to be fragmented</param>
        /// <param name="extraLength">length of header and trailer</param>
        /// <returns>Fragmented PDUs</returns>
        private static T[] FragmentPdu <T>(
            RpceContext context,
            RpceCoPdu pdu,
            int stubLength,
            int extraLength) where T : RpceCoPdu
        {
            List <T> fragmentPduList = new List <T>();
            bool     isFirstFragment = true;

            while (stubLength > 0)
            {
                T fragmentPdu = (T)Activator.CreateInstance(typeof(T), context);
                fragmentPdu.rpc_vers       = pdu.rpc_vers;
                fragmentPdu.rpc_vers_minor = pdu.rpc_vers_minor;
                fragmentPdu.PTYPE          = pdu.PTYPE;
                fragmentPdu.pfc_flags      = pdu.pfc_flags
                                             & ~(RpceCoPfcFlags.PFC_FIRST_FRAG | RpceCoPfcFlags.PFC_LAST_FRAG);
                fragmentPdu.packed_drep = pdu.packed_drep;
                fragmentPdu.frag_length = (ushort)Math.Min(context.MaxTransmitFragmentSize, stubLength + extraLength);
                fragmentPdu.auth_length = pdu.auth_length;
                fragmentPdu.call_id     = pdu.call_id;

                if (isFirstFragment)
                {
                    fragmentPdu.pfc_flags |= RpceCoPfcFlags.PFC_FIRST_FRAG;
                    isFirstFragment        = false;
                }

                if (stubLength <= (context.MaxTransmitFragmentSize - extraLength))
                {
                    fragmentPdu.pfc_flags |= RpceCoPfcFlags.PFC_LAST_FRAG;
                }

                stubLength -= (context.MaxTransmitFragmentSize - extraLength);
                fragmentPduList.Add(fragmentPdu);
            }

            return(fragmentPduList.ToArray());
        }
예제 #9
0
        /// <summary>
        /// Generate PFC_*** based on context and package type.
        /// </summary>
        /// <param name="context">Context of the session.</param>
        /// <param name="packageType">package type.</param>
        /// <returns>RFC_*** flag.</returns>
        internal static RpceCoPfcFlags GeneratePfcFlags(RpceContext context, RpcePacketType packageType)
        {
            RpceServerSessionContext sessionContext = context as RpceServerSessionContext;

            RpceCoPfcFlags flags = RpceCoPfcFlags.PFC_FIRST_FRAG | RpceCoPfcFlags.PFC_LAST_FRAG;

            if (sessionContext == null) //client-side
            {
                if (context.SupportsConcurrentMultiplexing)
                {
                    flags |= RpceCoPfcFlags.PFC_CONC_MPX;
                }
            }
            else if ( //server-side
                (packageType == RpcePacketType.BindAck &&
                 sessionContext.ServerContext.SupportsConcurrentMultiplexing) ||    // first response, read server context
                sessionContext.SupportsConcurrentMultiplexing)    // if it's not first response, we can read session context
            {
                flags |= RpceCoPfcFlags.PFC_CONC_MPX;
            }

            if ((packageType == RpcePacketType.Bind ||
                 packageType == RpcePacketType.BindAck ||
                 packageType == RpcePacketType.AlterContext ||
                 packageType == RpcePacketType.AlterContextResp)
                &&
                context.SupportsHeaderSign)
            {
                if (sessionContext == null || //client-side
                    sessionContext.ServerContext.SupportsHeaderSign)    //server-side
                {
                    flags |= RpceCoPfcFlags.PFC_SUPPORT_HEADER_SIGN;
                }
            }

            return(flags);
        }
예제 #10
0
 /// <summary>
 /// Initialize an instance of RpceCoRequestPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoRequestPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoFaultPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoFaultPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoBindAckPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoBindAckPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoAuth3Pdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoAuth3Pdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoRequestPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoRequestPdu(RpceContext context)
     : base(context)
 {
 }
예제 #15
0
        /// <summary>
        /// Fragment a PDU into several PDUs by max_xmit_frag field.<para/>
        /// Only bind, bind_ack, alter_context, alter_context_response,
        /// request and response PDUs will be fragmented.<para/>
        /// Must call before sign/encrypt.
        /// </summary>
        /// <param name="context">RpceContext to fragment PDU</param>
        /// <param name="pdu">
        /// A PDU to be fragmented.
        /// Only bind, bind_ack, alter_context, alter_context_response,
        /// request and response PDUs will be fragmented.
        /// </param>
        /// <returns>Fragmented PDUs.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown when pdu or context is null.
        /// </exception>
        /// <exception cref="NotSupportedException">Thrown when PDU PacketType isn't supported.</exception>
        public static RpceCoPdu[] FragmentPdu(RpceContext context, RpceCoPdu pdu)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (pdu == null)
            {
                throw new ArgumentNullException("pdu");
            }

            if (pdu.frag_length > context.MaxTransmitFragmentSize)
            {
                int    headerAndTrailerSize;
                byte[] stub;

                switch (pdu.PTYPE)
                {
                case RpcePacketType.Request:

                    //Get stub of request PDU
                    RpceCoRequestPdu requestPdu = pdu as RpceCoRequestPdu;

                    if (requestPdu == null)
                    {
                        throw new ArgumentException("The pdu is not a valid RpceCoRequestPdu.");
                    }

                    headerAndTrailerSize = requestPdu.GetSize();

                    if (requestPdu.auth_verifier != null)
                    {
                        //length of auth_verifier
                        headerAndTrailerSize += RpceUtility.AUTH_VERIFIER_SIZE;
                        headerAndTrailerSize += requestPdu.auth_verifier.Value.auth_value.Length;

                        //To keep stub always be padded to 16 bytes, and pdu doesnot exceed max transmit frag size.
                        int stubLength = context.MaxTransmitFragmentSize - headerAndTrailerSize;
                        headerAndTrailerSize +=
                            RpceUtility.Align(stubLength, RpceUtility.AUTH_PAD_LENGTH) - stubLength;

                        //The beginning of the verification_trailer header MUST be 4-byte aligned
                        //with respect to the beginning of the PDU.
                        headerAndTrailerSize = RpceUtility.Align(headerAndTrailerSize, RpceUtility.STUB_PAD_LENGTH);
                    }

                    stub = requestPdu.stub ?? new byte[0];

                    //Fragment
                    RpceCoRequestPdu[] requestFragmentPduList = FragmentPdu <RpceCoRequestPdu>(
                        context,
                        pdu,
                        stub.Length,
                        headerAndTrailerSize);

                    for (int i = 0; i < requestFragmentPduList.Length; i++)
                    {
                        //SHOULD set the alloc_hint field in every PDU to
                        //be the combined stub data length of all remaining fragment PDUs.
                        requestFragmentPduList[i].alloc_hint = (uint)stub.Length;
                        requestFragmentPduList[i].p_cont_id  = requestPdu.p_cont_id;
                        requestFragmentPduList[i].opnum      = requestPdu.opnum;
                        requestFragmentPduList[i].@object    = requestPdu.@object;
                        requestFragmentPduList[i].stub       = ArrayUtility.SubArray(
                            stub,
                            0,
                            Math.Min(stub.Length, context.MaxTransmitFragmentSize - headerAndTrailerSize));

                        //For request and response PDUs, where the request and response PDUs are
                        //part of a fragmented request or response and authentication is requested,
                        //the sec_trailer structure MUST be present in every fragment of the request
                        //or response.
                        requestFragmentPduList[i].AppendAuthenticationVerifier();
                        requestFragmentPduList[i].SetLength();
                        stub = ArrayUtility.SubArray(stub, requestFragmentPduList[i].stub.Length);
                    }

                    return(requestFragmentPduList);

                case RpcePacketType.Response:

                    //Get stub of response PDU
                    RpceCoResponsePdu responsePdu = pdu as RpceCoResponsePdu;

                    if (responsePdu == null)
                    {
                        throw new ArgumentException("The PDU is not a valid RpceCoResponsePdu");
                    }

                    headerAndTrailerSize = responsePdu.GetSize();

                    if (responsePdu.auth_verifier != null)
                    {
                        //length of auth_verifier
                        headerAndTrailerSize += RpceUtility.AUTH_VERIFIER_SIZE;
                        headerAndTrailerSize += responsePdu.auth_verifier.Value.auth_value.Length;

                        //To keep stub always be padded to 16 bytes, and pdu doesnot exceed max transmit frag size.
                        int stubLength = context.MaxTransmitFragmentSize - headerAndTrailerSize;
                        headerAndTrailerSize +=
                            RpceUtility.Align(stubLength, RpceUtility.AUTH_PAD_LENGTH) - stubLength;

                        //The beginning of the verification_trailer header MUST be 4-byte aligned
                        //with respect to the beginning of the PDU.
                        headerAndTrailerSize = RpceUtility.Align(headerAndTrailerSize, RpceUtility.STUB_PAD_LENGTH);
                    }

                    stub = responsePdu.stub ?? new byte[0];

                    //Fragment
                    RpceCoResponsePdu[] responseFragmentPduList = FragmentPdu <RpceCoResponsePdu>(
                        context,
                        pdu,
                        stub.Length,
                        headerAndTrailerSize);

                    for (int i = 0; i < responseFragmentPduList.Length; i++)
                    {
                        //SHOULD set the alloc_hint field in every PDU to
                        //be the combined stub data length of all remaining fragment PDUs.
                        responseFragmentPduList[i].alloc_hint   = (uint)stub.Length;
                        responseFragmentPduList[i].p_cont_id    = responsePdu.p_cont_id;
                        responseFragmentPduList[i].cancel_count = responsePdu.cancel_count;
                        responseFragmentPduList[i].reserved     = responsePdu.reserved;
                        responseFragmentPduList[i].stub         = ArrayUtility.SubArray(
                            stub,
                            0,
                            Math.Min(stub.Length, context.MaxTransmitFragmentSize - headerAndTrailerSize));

                        //For request and response PDUs, where the request and response PDUs are
                        //part of a fragmented request or response and authentication is requested,
                        //the sec_trailer structure MUST be present in every fragment of the request
                        //or response.
                        responseFragmentPduList[i].AppendAuthenticationVerifier();
                        responseFragmentPduList[i].SetLength();
                        stub = ArrayUtility.SubArray(stub, responseFragmentPduList[i].stub.Length);
                    }

                    return(responseFragmentPduList);

                case RpcePacketType.Bind:
                case RpcePacketType.BindAck:
                case RpcePacketType.AlterContext:
                case RpcePacketType.AlterContextResp:
                case RpcePacketType.Auth3:
                    //Windows RPC support version 5.0 only.
                    //Bind fragment requires RPC ver 5.1.
                    //We don't support it.
                    throw new NotSupportedException("bind/bind_ack/alt_context/alt_context_resp/auth3 PDU fragment are not supported.");

                default:
                    throw new InvalidOperationException("PDU PacketType isn't supported.");
                }
            }

            //If we cannot fragment the PDU
            return(new RpceCoPdu[] { pdu });
        }
예제 #16
0
        /// <summary>
        /// Reassemble several fragment PDUs to one PDU.<para/>
        /// Must call after decrypt/verify.
        /// </summary>
        /// <param name="context">RpceContext to Reassemble PDU.</param>
        /// <param name="pdus">Fragment PDUs to be reassembled.</param>
        /// <returns>A ressembled PDU.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown when pdus is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown when pdus is invalid.
        /// </exception>
        /// <exception cref="InvalidOperationException">Thrown when Speicified PDU doesn't
        /// support fragment and reassemble.</exception>
        public static RpceCoPdu ReassemblePdu(RpceContext context, params RpceCoPdu[] pdus)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (pdus == null)
            {
                throw new ArgumentNullException("pdus");
            }

            if (pdus.Length == 0)
            {
                throw new ArgumentException("There's no PDU to reassemble.", "pdus");
            }

            //verify if the fisrt pdu has the valid PFC_FIRST_FRAG.
            if ((pdus[0].pfc_flags & RpceCoPfcFlags.PFC_FIRST_FRAG) == 0)
            {
                throw new ArgumentException("First PDU doesn't have PFC_FIRST_FRAG flag.", "pdus");
            }

            //verify if fragments end expected.
            for (int i = 0; i < pdus.Length - 1; i++)
            {
                if ((pdus[i].pfc_flags & RpceCoPfcFlags.PFC_LAST_FRAG) != 0)
                {
                    throw new ArgumentException("Fragments ended unexpected.", "pdus");
                }
            }

            if ((pdus[pdus.Length - 1].pfc_flags & RpceCoPfcFlags.PFC_LAST_FRAG) == 0)
            {
                throw new ArgumentException("Fragments is not ended.", "pdus");
            }

            //All PTYPEs should be the same.
            for (int i = 1; i < pdus.Length; i++)
            {
                if (pdus[i].PTYPE != pdus[0].PTYPE)
                {
                    throw new ArgumentException("PDUs' PTYPE are different.", "pdus");
                }
            }

            if (pdus.Length == 1)
            {
                return(pdus[0]);
            }

            RpceCoPdu reassembledPdu;

            switch (pdus[0].PTYPE)
            {
            case RpcePacketType.Request:
                RpceCoRequestPdu requestPdu = pdus[0] as RpceCoRequestPdu;

                if (requestPdu == null)
                {
                    throw new ArgumentException("The PDU is not a valid RpceCoRequestPdu");
                }

                for (int i = 1; i < pdus.Length; i++)
                {
                    requestPdu.stub = ArrayUtility.ConcatenateArrays(
                        requestPdu.stub,
                        ((RpceCoRequestPdu)pdus[i]).stub);
                }

                requestPdu.pfc_flags    |= RpceCoPfcFlags.PFC_LAST_FRAG;
                requestPdu.frag_length   = (ushort)(requestPdu.GetSize() + requestPdu.stub.Length);
                requestPdu.auth_length   = 0;
                requestPdu.auth_verifier = null;
                reassembledPdu           = requestPdu;
                break;

            case RpcePacketType.Response:
                RpceCoResponsePdu responsePdu = pdus[0] as RpceCoResponsePdu;

                if (responsePdu == null)
                {
                    throw new ArgumentException("The PDU is not a valid RpceCoResponsePdu");
                }

                for (int i = 1; i < pdus.Length; i++)
                {
                    responsePdu.stub = ArrayUtility.ConcatenateArrays(
                        responsePdu.stub,
                        ((RpceCoResponsePdu)pdus[i]).stub);
                }

                responsePdu.pfc_flags    |= RpceCoPfcFlags.PFC_LAST_FRAG;
                responsePdu.frag_length   = (ushort)(responsePdu.GetSize() + responsePdu.stub.Length);
                responsePdu.auth_length   = 0;
                responsePdu.auth_verifier = null;
                reassembledPdu            = responsePdu;
                break;

            case RpcePacketType.Bind:
            case RpcePacketType.BindAck:
            case RpcePacketType.AlterContext:
            case RpcePacketType.AlterContextResp:
            case RpcePacketType.Auth3:
                //Windows RPC support version 5.0 only.
                //Bind fragment requires RPC ver 5.1.
                //We don't support it.
                throw new NotSupportedException("bind/bind_ack/alt_context/alt_context_resp/auth3 PDU fragment are not supported.");

            default:
                throw new InvalidOperationException("Speicified PDU doesn't support fragment and reassemble.");
            }

            return(reassembledPdu);
        }
예제 #17
0
 /// <summary>
 /// Initialize an instance of RpceCoCancelPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoCancelPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
예제 #18
0
        public static RpceCoPdu DecodeCoPdu(
            RpceContext context,
            byte[] pduBytes)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (pduBytes == null)
            {
                throw new ArgumentNullException("pduBytes");
            }

            RpceCoPdu pdu;

            //#2 byte is PTYPE
            RpcePacketType packageType = (RpcePacketType)pduBytes[2];
            //#3 byte is PFC_*** flags
            RpceCoPfcFlags pfcFlags = (RpceCoPfcFlags)pduBytes[3];

            RpceCoPfcFlags pfcFlagsNoFragment = RpceCoPfcFlags.PFC_FIRST_FRAG | RpceCoPfcFlags.PFC_LAST_FRAG;

            if (((pfcFlags & pfcFlagsNoFragment) != pfcFlagsNoFragment) &&
                (packageType == RpcePacketType.Bind ||
                 packageType == RpcePacketType.BindAck ||
                 packageType == RpcePacketType.AlterContext ||
                 packageType == RpcePacketType.AlterContextResp ||
                 packageType == RpcePacketType.Auth3))
            {
                //If it's a fragment and PTYPE is bind/bind_ack/alter_context/alter_context_resp
                //Windows RPC support version 5.0 only.
                //Bind fragment requires RPC ver 5.1.
                //We don't support it.
                throw new NotSupportedException("bind/bind_ack/alt_context/alt_context_resp/auth3 PDU fragment are not supported.");
            }
            else
            {
                switch (packageType)
                {
                case RpcePacketType.Bind:
                    pdu = new RpceCoBindPdu(context, pduBytes);
                    break;

                case RpcePacketType.BindAck:
                    pdu = new RpceCoBindAckPdu(context, pduBytes);
                    break;

                case RpcePacketType.BindNak:
                    pdu = new RpceCoBindNakPdu(context, pduBytes);
                    break;

                case RpcePacketType.AlterContext:
                    pdu = new RpceCoAlterContextPdu(context, pduBytes);
                    break;

                case RpcePacketType.AlterContextResp:
                    pdu = new RpceCoAlterContextRespPdu(context, pduBytes);
                    break;

                case RpcePacketType.Auth3:
                    pdu = new RpceCoAuth3Pdu(context, pduBytes);
                    break;

                case RpcePacketType.Request:
                    pdu = new RpceCoRequestPdu(context, pduBytes);
                    break;

                case RpcePacketType.Response:
                    pdu = new RpceCoResponsePdu(context, pduBytes);
                    break;

                case RpcePacketType.Fault:
                    pdu = new RpceCoFaultPdu(context, pduBytes);
                    break;

                case RpcePacketType.CoCancel:
                    pdu = new RpceCoCancelPdu(context, pduBytes);
                    break;

                case RpcePacketType.Orphaned:
                    pdu = new RpceCoOrphanedPdu(context, pduBytes);
                    break;

                case RpcePacketType.Shutdown:
                    pdu = new RpceCoShutdownPdu(context, pduBytes);
                    break;

                default:
                    throw new InvalidOperationException(
                              string.Format("Receive invalid packet - {0}.", packageType));
                }
            }

            return(pdu);
        }
예제 #19
0
 /// <summary>
 /// Initialize an instance of RpceCoOrphanedPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoOrphanedPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
예제 #20
0
 /// <summary>
 /// Initialize an instance of RpceCoCancelPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoCancelPdu(RpceContext context)
     : base(context)
 {
 }
예제 #21
0
 /// <summary>
 /// Initialize an instance of RpceCoOrphanedPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoOrphanedPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoOrphanedPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoOrphanedPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoOrphanedPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoOrphanedPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoShutdownPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoShutdownPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoBindPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoBindPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoFaultPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoFaultPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoCancelPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoCancelPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoFaultPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoFaultPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoAlterContextPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoAlterContextPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoPdu class.
 /// </summary>
 /// <param name="context">context</param>
 protected RpceCoPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoAuth3Pdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoAuth3Pdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoAuth3Pdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoAuth3Pdu(RpceContext context)
     : base(context)
 {
 }
예제 #33
0
 /// <summary>
 /// Initialize an instance of RpceCoAlterContextRespPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoAlterContextRespPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoBindPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoBindPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoCancelPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoCancelPdu(RpceContext context)
     : base(context)
 {
 }
 protected RpceCoPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
     using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(pduBytes)))
     {
         FromBytes(binaryReader);
     }
 }
예제 #37
0
 /// <summary>
 /// Initialize an instance of RpceCoShutdownPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoShutdownPdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoAuth3Pdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoAuth3Pdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
예제 #39
0
 /// <summary>
 /// Initialize an instance of RpceCoShutdownPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoShutdownPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
예제 #40
0
 /// <summary>
 /// Initialize an instance of RpceCoAlterContextRespPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoAlterContextRespPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoResponsePdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoResponsePdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoAlterContextPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoAlterContextPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoResponsePdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoResponsePdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoRequestPdu class, and 
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoRequestPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoResponsePdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoResponsePdu(RpceContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoFaultPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoFaultPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoResponsePdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoResponsePdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoBindAckPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoBindAckPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
예제 #49
0
 /// <summary>
 /// Initialize an instance of RpceCoPdu class.
 /// </summary>
 /// <param name="context">context</param>
 protected RpceCoPdu(RpceContext context)
     : base(context)
 {
 }
예제 #50
0
 /// <summary>
 /// Initialize an instance of RpceCoRequestPdu class, and
 /// unmarshal a byte array to PDU struct.
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="pduBytes">A byte array contains PDU data.</param>
 public RpceCoRequestPdu(RpceContext context, byte[] pduBytes)
     : base(context, pduBytes)
 {
 }
 /// <summary>
 /// Initialize an instance of RpceCoShutdownPdu class.
 /// </summary>
 /// <param name="context">context</param>
 public RpceCoShutdownPdu(RpceContext context)
     : base(context)
 {
 }