public virtual void Disconnect( )
        {
            var other = otherInterface;

            if (other != null)
            {
                otherInterface = null;
                EmulatorLogger.Log(LogLevel.Info, EventType.Disconnected, this.Name);
                other.Disconnect( );
            }
        }
 public virtual void Connect(INetHwInterface other)
 {
     if (other == null)
         throw new ArgumentNullException("other");
     if (ReferenceEquals(this, other))
         throw new ArgumentException("Can not connect the same interface instances");
     if (ReferenceEquals(this.otherInterface, other))
         throw new ArgumentException("That connection was made already");
     if (other is NetHwInterface) {
         this.Connect((NetHwInterface)other);
     } else {
         throw new ArgumentException("Invalid other type, it require [NetHwInterface] object");
     }
 }
 private void Connect(NetHwInterface other)
 {
     if (otherInterface != null)
     {
         otherInterface.Disconnect( );
     }
     if (other != null)
     {
         other.Disconnect( );
         other.otherInterface = this;
         EmulatorLogger.Log(LogLevel.Info, EventType.Connected, other.Name);
     }
     otherInterface = other;
     EmulatorLogger.Log(LogLevel.Info, EventType.Connected, this.Name);
 }
        private bool disposedValue = false;         // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    this.parent         = null;
                    this.otherInterface = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Example #5
0
        public void ReceiveData(INetPacket data, INetHwInterface iface)
        {
            int ifaceNo = this.interfaces.FindIndex(x => x.Equals(iface));

            foreach (var ipInterface in interfaces)
            {
                if (ipInterface.Address != null && ipInterface.Address.Value.Address == data.DestinationAddress?.Address)
                {
                    return;
                }
            }
            if (data.TTL > 0)
            {
                data.TTL--;
                this.SendData(data);
            }
        }
Example #6
0
 public void ReceiveData(INetPacket data, INetHwInterface iface)
 {
     if (busyInterface != null) {
         EmulatorLogger.Log(LogLevel.Error, EventType.HubPacketColision, this.Name);
         return;
     } else {
         int ifaceNo = this.interfaces.FindIndex(x => ReferenceEquals(x, iface));
         if (ifaceNo >= 0) {
             busyInterface = ifaceNo;
             if (data.TTL > 0) {
                 data.TTL--;
                 this.SendData(data);
             }
             busyInterface = null;
         }
     }
 }
Example #7
0
 public void ReceiveData(INetPacket data, INetHwInterface iface)
 {
     if (busyInterface != null)
     {
         EmulatorLogger.Log(LogLevel.Error, EventType.HubPacketColision, this.Name);
         return;
     }
     else
     {
         int ifaceNo = this.interfaces.FindIndex(x => ReferenceEquals(x, iface));
         if (ifaceNo >= 0)
         {
             busyInterface = ifaceNo;
             if (data.TTL > 0)
             {
                 data.TTL--;
                 this.SendData(data);
             }
             busyInterface = null;
         }
     }
 }
 public virtual void Connect(INetHwInterface other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     if (ReferenceEquals(this, other))
     {
         throw new ArgumentException("Can not connect the same interface instances");
     }
     if (ReferenceEquals(this.otherInterface, other))
     {
         throw new ArgumentException("That connection was made already");
     }
     if (other is NetHwInterface)
     {
         this.Connect((NetHwInterface)other);
     }
     else
     {
         throw new ArgumentException("Invalid other type, it require [NetHwInterface] object");
     }
 }
 private static void Connect(INetHwInterface a, INetHwInterface b)
 {
     a.Connect(b);
 }
 public static void UnLink(INetHwInterface a)
 {
     Disconnect(a);
 }
 public static void MakeLink(INetHwInterface a, INetHwInterface b)
 {
     Disconnect(a);
     Disconnect(b);
     Connect(a, b);
 }
Example #12
0
 public void ReceiveData(INetPacket data, INetHwInterface iface)
 {
     int ifaceNo = this.interfaces.FindIndex(x => x.Equals(iface));
     foreach (var ipInterface in interfaces) {
         if (ipInterface.Address != null && ipInterface.Address.Value.Address == data.DestinationAddress?.Address) {
             return;
         }
     }
     if (data.TTL > 0) {
         data.TTL--;
         this.SendData(data);
     }
 }
 public virtual void Disconnect( )
 {
     var other = otherInterface;
     if (other != null) {
         otherInterface = null;
         EmulatorLogger.Log(LogLevel.Info, EventType.Disconnected, this.Name);
         other.Disconnect( );
     }
 }
Example #14
0
 public static void MakeLink(INetHwInterface a, INetHwInterface b)
 {
     Disconnect(a);
     Disconnect(b);
     Connect(a, b);
 }
 private void Connect(NetHwInterface other)
 {
     if (otherInterface != null) {
         otherInterface.Disconnect( );
     }
     if (other != null) {
         other.Disconnect( );
         other.otherInterface = this;
         EmulatorLogger.Log(LogLevel.Info, EventType.Connected, other.Name);
     }
     otherInterface = other;
     EmulatorLogger.Log(LogLevel.Info, EventType.Connected, this.Name);
 }
Example #16
0
 private static void Disconnect(INetHwInterface a)
 {
     a.Disconnect( );
 }
Example #17
0
 private static void Connect(INetHwInterface a, INetHwInterface b)
 {
     a.Connect(b);
 }
Example #18
0
 public static void UnLink(INetHwInterface a)
 {
     Disconnect(a);
 }
 private static void Disconnect(INetHwInterface a)
 {
     a.Disconnect( );
 }
Example #20
0
        public void ReceiveData(INetPacket data, INetHwInterface iface)
        {
#if DEBUG
            System.Diagnostics.Debug.WriteLine("{0} recived {1}", this.Name, data);
#endif
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue) {
                if (disposing) {
                    this.parent = null;
                    this.otherInterface = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Example #22
0
 public void ReceiveData(INetPacket data, INetHwInterface iface)
 {
     #if DEBUG
     System.Diagnostics.Debug.WriteLine("{0} recived {1}", this.Name, data);
     #endif
 }