コード例 #1
0
ファイル: PDUBuilder.cs プロジェクト: yjsyyyjszf/DICOMSharp
 public PDUBuilder(PDUType type)
     : base(new MemoryStream(), true)
 {
     Write((byte)type); //pdu-type
     Write((byte)0);    //reserved - 0
     Write((uint)0);    //temp pdu-len
 }
コード例 #2
0
 /// <summary>
 /// Performs shallow copy.
 /// </summary>
 /// <param name="h"></param>
 public void Clone(Header h)
 {
     pDUType         = h.pDUType;
     protocolVersion = h.protocolVersion;
     exerciseID      = h.exerciseID;
     protocolFamily  = h.protocolFamily;
     timeStamp       = h.timeStamp;
     length          = h.length;
 }
コード例 #3
0
 public PDUHeader(PDUType type)
 {
     MajorVersion   = RPC_VERSION_MAJOR;
     MinorVersion   = RPC_VERSION_MINOR;
     Type           = type;
     Flags          = PDUFlags.None;
     DataRep        = new NdrDataRepresentation();
     FragmentLength = 0;
     AuthLength     = 0;
     CallId         = 0;
 }
コード例 #4
0
        /// <summary>
        /// All PDU of pduType will now be decoded using the supplied decoder.
        /// </summary>
        /// <param name="pduType"></param>
        /// <param name="decoder"></param>
        public void SetPduDecoder(PDUType pduType, IFactoryDecoder decoder)
        {
            DecoderAndEventPair dep;

            if (factoryDecoders.TryGetValue(pduType, out dep))
            {
                Debug.Log("Swapping out default decoder for " + pduType + " with " + decoder.GetType().ToString());
                dep.pduDecoder = decoder;
            }
            else
            {
                factoryDecoders.Add(pduType, new DecoderAndEventPair(decoder, null));
            }
        }
コード例 #5
0
ファイル: SpecialPDU.cs プロジェクト: tlsnns/NTLMClient
        public static SpecialPDU CreatePDUBody(byte[] vs, int offset, PDUType pduType, int specialPDULength)
        {
            SpecialPDU pduBody = null;

            switch (pduType)
            {
            case PDUType.response: pduBody = Response.Parser(vs, offset, specialPDULength); break;

            case PDUType.bind_ack: pduBody = BindACK.Parser(vs, offset, specialPDULength); break;

            default: throw new NotImplementedException("unknow pdu type");
            }

            return(pduBody);
        }
コード例 #6
0
        /// <summary>
        /// Decode network data.
        /// </summary>
        /// <param name="br"></param>
        public override void Decode(BinaryReader br)
        {
            isDirty         = true;
            protocolVersion = ( ProtocolVersion )br.ReadByte();
            exerciseID      = br.ReadByte();
            pDUType         = ( PDUType )br.ReadByte();
            protocolFamily  = ( ProtocolFamily )br.ReadByte();
            timeStamp       = new TimeStamp(br);
            length          = br.ReadUInt16();

            #if DIS_VERSION_7
            ownershipStatus = br.ReadByte();
            pduStatus       = br.ReadByte();
            #else
            br.BaseStream.Seek(2, SeekOrigin.Current);   // Skip padding
            #endif
        }
コード例 #7
0
 protected void Create(PDUType type) => Type = type;
コード例 #8
0
            //Protected
            protected void Create(PDUType type, PublicFunctionCodes functionCode, int startAddress, object value)
            {
                if (value.GetType() == typeof(short[]))
                {
                    short[] val = (short[])value;

                    Type = type;

                    Data.Add((byte)functionCode);

                    Data.Add(HighByte(startAddress));
                    Data.Add(LowByte(startAddress));

                    Data.Add(HighByte(val.Length));
                    Data.Add(LowByte(val.Length));

                    Data.Add((byte)(val.Length * 2));

                    for (int i = 0; i < val.Length; i++)
                    {
                        Data.Add(HighByte(val[i]));
                        Data.Add(LowByte(val[i]));
                    }
                }
                else if (value.GetType() == typeof(int[]))
                {
                    int[] val = (int[])value;

                    Type = type;

                    Data.Add((byte)functionCode);

                    Data.Add(HighByte(startAddress));
                    Data.Add(LowByte(startAddress));

                    Data.Add(HighByte(val.Length * 2));
                    Data.Add(LowByte(val.Length * 2));

                    Data.Add((byte)(val.Length * 4));

                    for (int i = 0; i < val.Length; i++)
                    {
                        Data.Add(HighByteHighWord(val[i]));
                        Data.Add(LowByteHighWord(val[i]));
                        Data.Add(HighByte(val[i]));
                        Data.Add(LowByte(val[i]));
                    }
                }
                else if (value.GetType() == typeof(float[]))
                {
                    float[] val = (float[])value;

                    Type = type;

                    Data.Add((byte)functionCode);

                    Data.Add(HighByte(startAddress));
                    Data.Add(LowByte(startAddress));

                    Data.Add(HighByte(val.Length * 2));
                    Data.Add(LowByte(val.Length * 2));

                    Data.Add((byte)(val.Length * 4));

                    for (int i = 0; i < val.Length; i++)
                    {
                        byte[] b = BitConverter.GetBytes(val[i]);
                        b = Reverse(b);
                        Data.AddRange(b);
                    }
                }
                else if (value.GetType() == typeof(int))
                {
                    Type = type;

                    Data.Add((byte)functionCode);

                    Data.Add(HighByte(startAddress));
                    Data.Add(LowByte(startAddress));

                    Data.Add(HighByte((int)value));
                    Data.Add(LowByte((int)value));
                }
                else if (value.GetType() == typeof(bool))
                {
                    Type = type;

                    Data.Add((byte)functionCode);

                    Data.Add(HighByte(startAddress));
                    Data.Add(LowByte(startAddress));

                    if ((bool)value)
                    {
                        Data.Add(0xFF);
                    }
                    else
                    {
                        Data.Add(0xFF);
                    }
                    Data.Add(0);
                }
            }
コード例 #9
0
 protected PDUBase(PDUType pdu_type)
 {
     PDUType = pdu_type;
 }
コード例 #10
0
ファイル: PDUType.cs プロジェクト: tlsnns/NTLMClient
 public static byte GetByte(this PDUType t)
 {
     return((byte)t);
 }