Esempio n. 1
0
        //******************************************************
        //�p�P�b�g�̉��
        //******************************************************
        public bool Read(byte[] buffer)
        {
            unsafe {
                int offSet = 0;
                fixed(byte *p = buffer)
                {
                    //�R�s�[��\���̂̃T�C�Y�m�F
                    int size = Marshal.SizeOf(typeof(HeaderDhcp));

                    //�R�s�[��̃T�C�Y���K�v�����݂��邩�ǂ����̊m�F
                    if (offSet + size > buffer.Length)
                    {
                        return(false);// ��M�o�C�g������
                    }
                    _headerDhcp = (HeaderDhcp)Marshal.PtrToStructure((IntPtr)(p + offSet), typeof(HeaderDhcp));
                    offSet     += size;

                    if (_headerDhcp.MagicCookie == 0x63538263)
                    {
                        _optionLen = buffer.Length - offSet;
                        if (_optionLen > 0)
                        {
                            _option = new byte[_optionLen];
                            Marshal.Copy((IntPtr)(p + offSet), _option, 0, _optionLen);
                        }
                    }
                }

                return(true);
            }
        }
Esempio n. 2
0
        //******************************************************
        //�p�P�b�g�̉��
        //******************************************************
        public bool Read(byte[] buffer)
        {
            unsafe {
                int offSet = 0;
                fixed (byte* p = buffer) {
                    //�R�s�[��\���̂̃T�C�Y�m�F
                    int size = Marshal.SizeOf(typeof(HeaderDhcp));
                    //�R�s�[��̃T�C�Y���K�v�����݂��邩�ǂ����̊m�F
                    if (offSet + size > buffer.Length) {
                        return false;// ��M�o�C�g������
                    }
                    _headerDhcp = (HeaderDhcp)Marshal.PtrToStructure((IntPtr)(p + offSet), typeof(HeaderDhcp));
                    offSet += size;

                    if (_headerDhcp.MagicCookie == 0x63538263) {
                        _optionLen = buffer.Length - offSet;
                        if (_optionLen > 0) {
                            _option = new byte[_optionLen];
                            Marshal.Copy((IntPtr)(p + offSet), _option, 0, _optionLen);
                        }
                    }

                }
                return true;
            }
        }