Exemplo n.º 1
0
        public MessageBase Read(SlpReader reader)
        {
            var v = reader.ReadByte();
            if (v != 1 && v != 2)
                throw new ServiceProtocolException(ServiceErrorCode.VersionNotSupported);

            var tmp = reader.ReadByte();
            MessageBase result = null;
            switch (tmp)
            {
                case 1:
                    result = new ServiceRequest();
                    break;
                case 2:
                    result = new ServiceReply();
                    break;
                case 3:
                    result = new ServiceRegistrationRequest();
                    break;
                case 4:
                    result = new ServiceDeregistrationRequest();
                    break;
                case 5:
                    result = new ServiceAcknowledgement();
                    break;
                case 6:
                    result = new AttributeRequest();
                    break;
                case 7:
                    result = new AttributeReply();
                    break;
                case 8:
                    result = new DirectoryAgentAdvert();
                    break;
                case 9:
                    result = new ServiceTypeRequest();
                    break;
                case 10:
                    result = new ServiceTypeReply();
                    break;
                case 11:
                    result = new ServiceAgentAdvert();
                    break;
                default:
                    throw new ServiceProtocolException(ServiceErrorCode.ParseError);
            }

            result.Version = v;
            result.Create(reader);

            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read the message bytes and set the properties on this instance
        /// </summary>
        /// <param name="reader"></param>
        internal virtual void Create(SlpReader reader)
        {
            reader.ReadInt24();

            var flags = reader.ReadByte();

            IsOverFlow  = (flags & 0x80) == 0x80;
            IsFresh     = (flags & 0x40) == 0x40;
            IsMulticast = (flags & 0x20) == 0x20;

            reader.ReadByte();
            _ExtensionOffset = reader.ReadInt24();
            MessageId        = reader.ReadInt16();
            Language         = reader.ReadString();
        }
Exemplo n.º 3
0
        public virtual ServiceEntry CreateServiceEntry(SlpReader reader)
        {
            if (reader.ReadByte() != 0)
                throw new ServiceProtocolException(ServiceErrorCode.ParseError);

            var result = new ServiceEntry();
            result.Lifetime = reader.ReadTimeSpan();
            result.Uri = new ServiceUri(reader.ReadString());

            var count = reader.ReadByte();
            for (int i = 0; i < count; i++)
            {
                var a = CreateAuthenticationBlock(reader);
                result.AuthBlocks.Add(a);
                ServiceEntry.OnAuthenticated(result, a);
            }

            return result;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Read the authblocks bytes and create any authblocks, firing the event when a block is added
        /// </summary>
        /// <param name="reader">reader</param>
        /// <param name="authBlocks">list of authblocks</param>
        protected void ReadAuthBlocks(SlpReader reader, ICollection <Security.AuthenticationBlock> authBlocks)
        {
            var count = reader.ReadByte();

            for (int i = 0; i < count; i++)
            {
                var a = Services.Locator.GetInstance <Security.AuthenticationBlock>(reader);
                authBlocks.Add(a);
                OnAuthenticated(this, a);
            }
        }
Exemplo n.º 5
0
        public virtual ServiceEntry CreateServiceEntry(SlpReader reader)
        {
            if (reader.ReadByte() != 0)
            {
                throw new ServiceProtocolException(ServiceErrorCode.ParseError);
            }

            var result = new ServiceEntry();

            result.Lifetime = reader.ReadTimeSpan();
            result.Uri      = new ServiceUri(reader.ReadString());

            var count = reader.ReadByte();

            for (int i = 0; i < count; i++)
            {
                var a = CreateAuthenticationBlock(reader);
                result.AuthBlocks.Add(a);
                ServiceEntry.OnAuthenticated(result, a);
            }

            return(result);
        }
Exemplo n.º 6
0
        public MessageBase Read(SlpReader reader)
        {
            var v = reader.ReadByte();

            if (v != 1 && v != 2)
            {
                throw new ServiceProtocolException(ServiceErrorCode.VersionNotSupported);
            }

            var         tmp    = reader.ReadByte();
            MessageBase result = null;

            switch (tmp)
            {
            case 1:
                result = new ServiceRequest();
                break;

            case 2:
                result = new ServiceReply();
                break;

            case 3:
                result = new ServiceRegistrationRequest();
                break;

            case 4:
                result = new ServiceDeregistrationRequest();
                break;

            case 5:
                result = new ServiceAcknowledgement();
                break;

            case 6:
                result = new AttributeRequest();
                break;

            case 7:
                result = new AttributeReply();
                break;

            case 8:
                result = new DirectoryAgentAdvert();
                break;

            case 9:
                result = new ServiceTypeRequest();
                break;

            case 10:
                result = new ServiceTypeReply();
                break;

            case 11:
                result = new ServiceAgentAdvert();
                break;

            default:
                throw new ServiceProtocolException(ServiceErrorCode.ParseError);
            }

            result.Version = v;
            result.Create(reader);

            return(result);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Read the authblocks bytes and create any authblocks, firing the event when a block is added
 /// </summary>
 /// <param name="reader">reader</param>
 /// <param name="authBlocks">list of authblocks</param>
 protected void ReadAuthBlocks(SlpReader reader, ICollection<Security.AuthenticationBlock> authBlocks)
 {
     var count = reader.ReadByte();
     for (int i = 0; i < count; i++)
     {
         var a = Services.Locator.GetInstance<Security.AuthenticationBlock>(reader);
         authBlocks.Add(a);
         OnAuthenticated(this, a);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Read the message bytes and set the properties on this instance
        /// </summary>
        /// <param name="reader"></param>
        internal virtual void Create(SlpReader reader)
        {
            reader.ReadInt24();

            var flags = reader.ReadByte();
            IsOverFlow = (flags & 0x80) == 0x80;
            IsFresh = (flags & 0x40) == 0x40;
            IsMulticast = (flags & 0x20) == 0x20;

            reader.ReadByte();
            _ExtensionOffset = reader.ReadInt24();
            MessageId = reader.ReadInt16();
            Language = reader.ReadString();
        }