public override string ToString()
 {
     return
         (InterfaceId.ToString() + " - " +
          (Address == null ? "unassigned" : Address.ToString()) + " - " +
          Ok.ToString() + " - " +
          Method.ToString() + " - " +
          Status.ToString() + " - " +
          ProtocolStatus.ToString());
 }
Пример #2
0
        public override bool Equals(object obj)
        {
            if (obj is IPAddressItem other)
            {
                return
                    (IPAddress?.Equals(other.IPAddress) == true &&
                     InterfaceId?.Equals(other.InterfaceId) == true);
            }

            return(base.Equals(obj));
        }
Пример #3
0
 /// <summary>
 /// Returns a string representation of this object.
 /// </summary>
 /// <returns>A string representation of this object.</returns>
 public override String ToString()
 {
     return(String.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}{8}",
                          IPAddressArray[0].ToString("x2") + IPAddressArray[1].ToString("x2"),
                          IPAddressArray[2].ToString("x2") + IPAddressArray[3].ToString("x2"),
                          IPAddressArray[4].ToString("x2") + IPAddressArray[5].ToString("x2"),
                          IPAddressArray[6].ToString("x2") + IPAddressArray[7].ToString("x2"),
                          IPAddressArray[8].ToString("x2") + IPAddressArray[9].ToString("x2"),
                          IPAddressArray[10].ToString("x2") + IPAddressArray[11].ToString("x2"),
                          IPAddressArray[12].ToString("x2") + IPAddressArray[13].ToString("x2"),
                          IPAddressArray[14].ToString("x2") + IPAddressArray[15].ToString("x2"),
                          (InterfaceId.IsNotNullOrEmpty() ? "%" + InterfaceId : "")));
 }
Пример #4
0
        /// <summary>
        /// Load interface description from YAML file
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static KeyValuePair<InterfaceId, JstpDescInterface> LoadDescriptionInterface([NotNull] string file)
        {
            if (file == null) throw new ArgumentNullException("file");

            Logger.Info("Load model from file {0}",file);
            try
            {
                JstpDescInterface ifc;
                using (var rdr = new StreamReader(file))
                {
                    ifc = new Deserializer(ignoreUnmatched: true).Deserialize<JstpDescInterface>(rdr);
                }
                ifc.Validate();
                var key = new InterfaceId(ifc.Name, Version.Parse(ifc.Version));
                Logger.Debug("Load interface '{0}' version '{1}'", key.Name, key.Version);
                return new KeyValuePair<InterfaceId, JstpDescInterface>(key,ifc);
            }
            catch (Exception ex)
            {
                Logger.Error(ex,"Filed to load interface description from file {0}",file);
                throw;
            }
        }
Пример #5
0
 public override int GetHashCode()
 {
     return((IPAddress?.GetHashCode() ?? 0) ^ (InterfaceId?.GetHashCode() ?? 0));
 }
Пример #6
0
        public Error GetInterfaces(out InterfaceId[] interfaces, ReferenceTypeId referenceType)
        {
            byte[] packet = new byte[HeaderSize + ReferenceTypeIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, ReferenceTypeCommand.Interfaces);
            WriteReferenceTypeId(packet, HeaderSize, referenceType);

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                interfaces = null;
                return errorCode;
            }

            int offset = HeaderSize;
            int interfaceCount = ReadInt32(response, ref offset);
            interfaces = new InterfaceId[interfaceCount];
            for (int i = 0; i < interfaceCount; i++)
            {
                interfaces[i] = (InterfaceId)ReadReferenceTypeId(response, ref offset);
            }

            return Error.None;
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="byteId"></param>
 public MalformedAtrException(InterfaceId byteId)
     : base(String.Format("Parsing error looking for {0}", byteId))
 {
     ByteId = byteId;
 }
 internal InterfaceType(VirtualMachine virtualMachine, InterfaceId typeId)
     : base(virtualMachine, new TaggedReferenceTypeId(TypeTag.Interface, typeId))
 {
     Contract.Requires(virtualMachine != null);
 }
Пример #9
0
        public Error GetInterfaces(ReferenceTypeId referenceType, out InterfaceId[] interfaces)
        {
            interfaces = null;

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            using (var classHandle = VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, referenceType))
            {
                if (!classHandle.IsAlive)
                    return Error.InvalidClass;

                TaggedReferenceTypeId[] taggedInterfaces;
                error = environment.GetImplementedInterfaces(nativeEnvironment, classHandle.Value, out taggedInterfaces);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                interfaces = Array.ConvertAll(taggedInterfaces, i => (InterfaceId)i);
                return Error.None;
            }
        }
Пример #10
0
 /// <summary>
 /// Return the HashCode of this object.
 /// </summary>
 /// <returns>The HashCode of this object.</returns>
 public override Int32 GetHashCode()
 {
     return(IPAddressArray.GetHashCode() ^ InterfaceId.GetHashCode());
 }
Пример #11
0
        internal InterfaceType GetMirrorOf(InterfaceId interfaceId)
        {
            if (interfaceId == default(InterfaceId))
                return null;

            return new InterfaceType(this, interfaceId);
        }