public EthernetInterface(ILinkLayer linkLayer)
        {
            _linkLayer = linkLayer;
            _cachedPhysicalAddress = _linkLayer.GetMacAddress();

            _linkLayer.LinkStateChanged += _linkLayer_LinkStateChanged;
            _linkLayer.PacketReceived += _linkLayer_PacketReceived;
        }
        public EthernetInterface(ILinkLayer linkLayer)
        {
            _linkLayer             = linkLayer;
            _cachedPhysicalAddress = _linkLayer.GetMacAddress();

            _linkLayer.LinkStateChanged += _linkLayer_LinkStateChanged;
            _linkLayer.PacketReceived   += _linkLayer_PacketReceived;
        }
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;

            _linkLayer                      = null;
            _ethernetHeaderBuffer           = null;
            _ethernetHeaderBufferWaitHandle = null;

            _bufferArray = null;
            _indexArray  = null;
            _countArray  = null;
        }
示例#4
0
        static internal void Initialize()
        {
            lock (_initializeMethodSyncObject)
            {
                if (_isInitialized)
                {
                    return;
                }

#if CC3100
                Type socketNativeType = Type.GetType("Netduino.IP.LinkLayers.CC3100SocketNative, Netduino.IP.LinkLayers.CC3100");
                System.Reflection.MethodInfo initializeMethod = socketNativeType.GetMethod("Initialize", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                initializeMethod.Invoke(null, new object[] { });
#else
                // create the appropriate link layer object
                Type linkLayerType = Type.GetType(LINK_LAYER_BASE_TYPENAME);
                System.Reflection.ConstructorInfo linkLayerConstructor = linkLayerType.GetConstructor(new Type[] { typeof(SPI.SPI_module), typeof(Cpu.Pin), typeof(Cpu.Pin), typeof(Cpu.Pin), typeof(Cpu.Pin) });
#if NETDUINOIP_AX88796C
                ILinkLayer linkLayer = (ILinkLayer)linkLayerConstructor.Invoke(new object[] { SPI.SPI_module.SPI2 /* spiBusID */, (Cpu.Pin) 0x28 /* csPinID */, (Cpu.Pin) 0x04 /* intPinID */, (Cpu.Pin) 0x12 /* resetPinID */, (Cpu.Pin) 0x44 /* wakeupPinID */ });
#elif NETDUINOIP_ENC28J60
                ILinkLayer linkLayer = (ILinkLayer)linkLayerConstructor.Invoke(new object[] { SPI.SPI_module.SPI2 /* spiBusID */, (Cpu.Pin) 0x28 /* csPinID */, (Cpu.Pin) 0x04 /* intPinID */, (Cpu.Pin) 0x32 /* resetPinID */, Cpu.Pin.GPIO_NONE /* wakeupPinID */ });
#elif NETDUINOIP_CC3100
#endif
                // retrieve MAC address from the config sector
                object networkInterface = Netduino.IP.Interop.NetworkInterface.GetNetworkInterface(0);
                byte[] physicalAddress  = (byte[])networkInterface.GetType().GetMethod("get_PhysicalAddress").Invoke(networkInterface, new object[] { });
                linkLayer.SetMacAddress(physicalAddress);

                // create EthernetInterface instance
                _ethernetInterface = new Netduino.IP.EthernetInterface(linkLayer);
                // create our IPv4Layer instance
                _ipv4Layer = new IPv4Layer(_ethernetInterface);

                // start up our link layer
                linkLayer.Start();
#endif

                _isInitialized = true;
            }
        }
        public void Dispose()
        {
            if (_isDisposed) return;

            _isDisposed = true;

            _linkLayer = null;
            _ethernetHeaderBuffer = null;
            _ethernetHeaderBufferWaitHandle = null;

            _bufferArray = null;
            _indexArray = null;
            _countArray = null;
        }