Exemple #1
0
        /// <summary>
        /// Reads file transfer information from the byte stream into the <see cref="FileTransferConnection"/>
        /// </summary>
        /// <param name="connection">The <see cref="FileTransferConnection"/> to populate with information</param>
        public void ReadFileTransferInformation(FileTransferConnection connection)
        {
            FileHeader fh = connection.FileHeader;

            fh.Cookie                 = ReadByteArray(fh.Cookie.Length);
            fh.Encryption             = ReadUshort();
            fh.Compression            = ReadUshort();
            connection.TotalFiles     = ReadUshort();
            connection.FilesRemaining = ReadUshort();
            connection.TotalParts     = ReadUshort();
            fh.PartsLeft              = ReadUshort();
            connection.TotalFileSize  = ReadUint();
            fh.Size     = ReadUint();
            fh.modtime  = ReadUint();
            fh.Checksum = ReadUint();
            fh.ResourceForkReceivedChecksum = ReadUint();
            fh.ResourceForkSize             = ReadUint();
            fh.cretime = ReadUint();
            fh.ResourceForkChecksum = ReadUint();
            fh.nrecvd           = ReadUint();
            fh.ReceivedChecksum = ReadUint();

            fh.IdString    = ReadNullTerminatedString(32);
            fh.flags       = ReadByte();
            fh.lnameoffset = ReadByte();
            fh.lsizeoffset = ReadByte();
            fh.dummy       = ReadByteArray(fh.dummy.Length);
            fh.macfileinfo = ReadByteArray(fh.macfileinfo.Length);
            fh.nencode     = ReadUshort();
            fh.nlanguage   = ReadUshort();

            fh.Name = ReadNullTerminatedString(64);
        }
        /// <summary>
        /// Creates a new file transfer connection
        /// </summary>
        /// <param name="method">The <see cref="DirectConnectionMethod"/> to use for the transfer</param>
        /// <param name="role">The <see cref="DirectConnectRole"/> of the local client in the transfer</param>
        public FileTransferConnection CreateNewFileTransferConnection(DirectConnectionMethod method,
                                                                      DirectConnectRole role)
        {
            FileTransferConnection retval = new FileTransferConnection(_parent, _id++, method, role);

            _directconnections.Add(retval);
            return(retval);
        }
Exemple #3
0
        public static byte[] CreateFileTransferMessage(ushort type, FileTransferConnection conn)
        {
            int index = 0;

            byte[] retval = new byte[256];
            InsertString(retval, "OFT2", Encoding.ASCII, ref index);
            InsertUshort(retval, 0x0100, ref index);
            InsertUshort(retval, type, ref index);
            InsertFileHeader(retval, conn, ref index);

            return(retval);
        }
Exemple #4
0
        /// <summary>
        /// Reads file transfer information from the byte stream into the <see cref="FileTransferConnection"/>
        /// </summary>
        /// <param name="connection">The <see cref="FileTransferConnection"/> to populate with information</param>
        public void ReadFileTransferInformation(FileTransferConnection connection)
        {
            FileHeader fh = connection.FileHeader;

            fh.Cookie = ReadByteArray(fh.Cookie.Length);
            fh.Encryption = ReadUshort();
            fh.Compression = ReadUshort();
            connection.TotalFiles = ReadUshort();
            connection.FilesRemaining = ReadUshort();
            connection.TotalParts = ReadUshort();
            fh.PartsLeft = ReadUshort();
            connection.TotalFileSize = ReadUint();
            fh.Size = ReadUint();
            fh.modtime = ReadUint();
            fh.Checksum = ReadUint();
            fh.ResourceForkReceivedChecksum = ReadUint();
            fh.ResourceForkSize = ReadUint();
            fh.cretime = ReadUint();
            fh.ResourceForkChecksum = ReadUint();
            fh.nrecvd = ReadUint();
            fh.ReceivedChecksum = ReadUint();

            fh.IdString = ReadNullTerminatedString(32);
            fh.flags = ReadByte();
            fh.lnameoffset = ReadByte();
            fh.lsizeoffset = ReadByte();
            fh.dummy = ReadByteArray(fh.dummy.Length);
            fh.macfileinfo = ReadByteArray(fh.macfileinfo.Length);
            fh.nencode = ReadUshort();
            fh.nlanguage = ReadUshort();

            fh.Name = ReadNullTerminatedString(64);
        }
Exemple #5
0
        public static void InsertFileHeader(byte[] buffer, FileTransferConnection conn, ref int index)
        {
            FileHeader fh = conn.FileHeader;

            int i;

            byte[] idstring = new byte[32];
            byte[] dummy    = new byte[69];
            byte[] macinfo  = new byte[16];
            byte[] filename = new byte[64];

            for (i = 0; i < 32 && i < fh.IdString.Length; i++)
            {
                idstring[i] = (byte)fh.IdString[i];
            }
            idstring[31] = 0x00;
            while (i < 32)
            {
                idstring[i++] = 0x00;
            }

            for (i = 0; i < 69; i++)
            {
                dummy[i] = 0x00;
            }

            for (i = 0; i < 16; i++)
            {
                macinfo[i] = 0x00;
            }

            for (i = 0; i < 64 && i < fh.Name.Length; i++)
            {
                filename[i] = (byte)fh.Name[i];
            }
            filename[63] = 0x00;
            while (i < 64)
            {
                filename[i++] = 0x00;
            }

            // 8
            CopyArray(fh.Cookie, buffer, 0, ref index);
            // 16
            InsertUshort(buffer, fh.Encryption, ref index);
            InsertUshort(buffer, fh.Compression, ref index);
            InsertUshort(buffer, (ushort)conn.TotalFiles, ref index);
            InsertUshort(buffer, (ushort)conn.FilesRemaining, ref index);
            InsertUshort(buffer, (ushort)conn.TotalParts, ref index);
            InsertUshort(buffer, fh.PartsLeft, ref index);
            // 28
            InsertUint(buffer, conn.TotalFileSize, ref index);
            InsertUint(buffer, fh.Size, ref index);
            InsertUint(buffer, fh.modtime, ref index);
            InsertUint(buffer, fh.Checksum, ref index);
            InsertUint(buffer, fh.ResourceForkReceivedChecksum, ref index);
            InsertUint(buffer, fh.ResourceForkSize, ref index);
            InsertUint(buffer, fh.cretime, ref index);
            InsertUint(buffer, fh.ResourceForkChecksum, ref index);
            InsertUint(buffer, fh.nrecvd, ref index);
            InsertUint(buffer, fh.ReceivedChecksum, ref index);
            // 68
            CopyArray(idstring, buffer, 0, ref index);
            // 100
            buffer[index++] = fh.flags;
            buffer[index++] = fh.lnameoffset;
            buffer[index++] = fh.lsizeoffset;
            // 103
            CopyArray(dummy, buffer, 0, ref index);
            // 172
            CopyArray(macinfo, buffer, 0, ref index);
            // 188
            InsertUshort(buffer, fh.nencode, ref index);
            InsertUshort(buffer, fh.nlanguage, ref index);
            // 192
            CopyArray(filename, buffer, 0, ref index);
            // 256
        }
Exemple #6
0
 /// <summary>
 /// Creates a new file transfer connection
 /// </summary>
 /// <param name="method">The <see cref="DirectConnectionMethod"/> to use for the transfer</param>
 /// <param name="role">The <see cref="DirectConnectRole"/> of the local client in the transfer</param>
 public FileTransferConnection CreateNewFileTransferConnection(DirectConnectionMethod method,
                                                               DirectConnectRole role)
 {
     FileTransferConnection retval = new FileTransferConnection(_parent, _id++, method, role);
     _directconnections.Add(retval);
     return retval;
 }