Example #1
0
        public static RPCPDU GetPDU(byte[] buffer, int offset)
        {
            PacketTypeName packetType = (PacketTypeName)ByteReader.ReadByte(buffer, 2);

            switch (packetType)
            {
            case PacketTypeName.Request:
                return(new RequestPDU(buffer, offset));

            case PacketTypeName.Response:
                return(new ResponsePDU(buffer, offset));

            case PacketTypeName.Fault:
                return(new FaultPDU(buffer, offset));

            case PacketTypeName.Bind:
                return(new BindPDU(buffer, offset));

            case PacketTypeName.BindAck:
                return(new BindAckPDU(buffer, offset));

            case PacketTypeName.BindNak:
                return(new BindNakPDU(buffer, offset));

            default:
                throw new NotImplementedException();
            }
        }
Example #2
0
 public RPCPDU(byte[] buffer, int offset)
 {
     VersionMajor       = ByteReader.ReadByte(buffer, offset + 0);
     VersionMinor       = ByteReader.ReadByte(buffer, offset + 1);
     PacketType         = (PacketTypeName)ByteReader.ReadByte(buffer, offset + 2);
     Flags              = (PacketFlags)ByteReader.ReadByte(buffer, offset + 3);
     DataRepresentation = new DataRepresentationFormat(buffer, offset + 4);
     FragmentLength     = LittleEndianConverter.ToUInt16(buffer, offset + 8);
     AuthLength         = LittleEndianConverter.ToUInt16(buffer, offset + 10);
     CallID             = LittleEndianConverter.ToUInt32(buffer, offset + 12);
 }
Example #3
0
        public static RPCPDU GetPDU(byte[]?buffer, int offset)
        {
            PacketTypeName packetType = (PacketTypeName)ByteReader.ReadByte(buffer, 2);

            return(packetType switch
            {
                PacketTypeName.Request => new RequestPDU(buffer, offset),
                PacketTypeName.Response => new ResponsePDU(buffer, offset),
                PacketTypeName.Fault => new FaultPDU(buffer, offset),
                PacketTypeName.Bind => new BindPDU(buffer, offset),
                PacketTypeName.BindAck => new BindAckPDU(buffer, offset),
                PacketTypeName.BindNak => new BindNakPDU(buffer, offset),
                _ => throw new NotImplementedException()
            });
 public void Should_Return_Valid_Packet_Names_For_Packet_Types(Type packetType, PacketTypeName packetTypeName)
 {
     Assert.Equal(packetTypeName, packetType.GetPacketTypeName());
 }