예제 #1
0
		/// <summary>
		/// Create from a type and string value
		/// </summary>
		/// <param name="tlvType">
		/// A <see cref="TLVTypes"/>
		/// </param>
		/// <param name="StringValue">
		/// A <see cref="System.String"/>
		/// </param>
		public StringTLV(TLVTypes tlvType, string StringValue) {
			var bytes = new byte[TLVTypeLength.TypeLengthLength];
			var offset = 0;
			tlvData = new ByteArraySegment(bytes, offset, bytes.Length);

			Type = tlvType;
			this.StringValue = StringValue;
		}
예제 #2
0
 public StringTLV(TLVTypes tlvType, string StringValue)
 {
     byte[] bytes = new byte[2];
     int offset = 0;
     base.tlvData = new ByteArraySegment(bytes, offset, bytes.Length);
     base.Type = tlvType;
     this.StringValue = StringValue;
 }
예제 #3
0
        public StringTLV(TLVTypes tlvType, string StringValue)
        {
            byte[] bytes  = new byte[2];
            int    offset = 0;

            base.tlvData     = new ByteArraySegment(bytes, offset, bytes.Length);
            base.Type        = tlvType;
            this.StringValue = StringValue;
        }
예제 #4
0
        /// <summary>
        /// Create from a type and string value
        /// </summary>
        /// <param name="tlvType">
        /// A <see cref="TLVTypes"/>
        /// </param>
        /// <param name="StringValue">
        /// A <see cref="System.String"/>
        /// </param>
        public StringTLV(TLVTypes tlvType, string StringValue)
        {
            var bytes  = new byte[TLVTypeLength.TypeLengthLength];
            var offset = 0;

            tlvData = new ByteArraySegment(bytes, offset, bytes.Length);

            Type             = tlvType;
            this.StringValue = StringValue;
        }
예제 #5
0
        /// <summary>
        /// Create from a type and string value
        /// </summary>
        /// <param name="tlvType">
        /// A <see cref="TLVTypes" />
        /// </param>
        /// <param name="stringValue">
        /// A <see cref="string" />
        /// </param>
        public StringTLV(TLVTypes tlvType, String stringValue)
        {
            var       bytes  = new Byte[TLVTypeLength.TypeLengthLength];
            const int offset = 0;

            TLVData = new ByteArraySegment(bytes, offset, bytes.Length);

            Type        = tlvType;
            StringValue = stringValue;
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Bytes">
        /// A <see cref="T:System.Byte[]"/>
        /// </param>
        /// <param name="offset">
        /// A <see cref="System.Int32"/>
        /// </param>
        /// <param name="type">
        /// A <see cref="TLVTypes"/>
        /// </param>
        /// <returns>
        /// A <see cref="TLV"/>
        /// </returns>
        private static TLV TLVFactory(byte[] Bytes, int offset, TLVTypes type)
        {
            switch (type)
            {
            case TLVTypes.ChassisID:
                return(new ChassisID(Bytes, offset));

            case TLVTypes.PortID:
                return(new PortID(Bytes, offset));

            case TLVTypes.TimeToLive:
                return(new TimeToLive(Bytes, offset));

            case TLVTypes.PortDescription:
                return(new PortDescription(Bytes, offset));

            case TLVTypes.SystemName:
                return(new SystemName(Bytes, offset));

            case TLVTypes.SystemDescription:
                return(new SystemDescription(Bytes, offset));

            case TLVTypes.SystemCapabilities:
                return(new SystemCapabilities(Bytes, offset));

            case TLVTypes.ManagementAddress:
                return(new ManagementAddress(Bytes, offset));

            case TLVTypes.OrganizationSpecific:
                return(new OrganizationSpecific(Bytes, offset));

            case TLVTypes.EndOfLLDPU:
                return(new EndOfLLDPDU(Bytes, offset));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #7
0
        private static TLV TLVFactory(byte[] Bytes, int offset, TLVTypes type)
        {
            switch (type)
            {
                case TLVTypes.EndOfLLDPU:
                    return new EndOfLLDPDU(Bytes, offset);

                case TLVTypes.ChassisID:
                    return new ChassisID(Bytes, offset);

                case TLVTypes.PortID:
                    return new PortID(Bytes, offset);

                case TLVTypes.TimeToLive:
                    return new TimeToLive(Bytes, offset);

                case TLVTypes.PortDescription:
                    return new PortDescription(Bytes, offset);

                case TLVTypes.SystemName:
                    return new SystemName(Bytes, offset);

                case TLVTypes.SystemDescription:
                    return new SystemDescription(Bytes, offset);

                case TLVTypes.SystemCapabilities:
                    return new SystemCapabilities(Bytes, offset);

                case TLVTypes.ManagementAddress:
                    return new ManagementAddress(Bytes, offset);

                case TLVTypes.OrganizationSpecific:
                    return new OrganizationSpecific(Bytes, offset);
            }
            throw new ArgumentOutOfRangeException();
        }