//struct EchoRequest //{ // public UInt32 DestinationIPAddress; // public UInt16 Identifier; // public UInt16 SequenceNumber; // public byte[] Data; // AutoResetEvent _responseReceivedEvent; // public EchoRequest(UInt32 destinationIPAddress, UInt16 identifier, UInt16 sequenceNumber, byte[] data) // { // this.DestinationIPAddress = destinationIPAddress; // this.Identifier = identifier; // this.SequenceNumber = sequenceNumber; // this.Data = data; // _responseReceivedEvent = new AutoResetEvent(false); // } // public bool WaitForResponse(Int32 millisecondsTimeout) // { // return _responseReceivedEvent.WaitOne(millisecondsTimeout, false); // } // internal void SetResponseReceived() // { // _responseReceivedEvent.Set(); // } //} //System.Collections.ArrayList _outstandingEchoRequests = new System.Collections.ArrayList(); //object _outstandingEchoRequestsLock = new object(); //UInt16 _nextEchoRequestSequenceNumber = 0; internal ICMPv4Handler(IPv4Layer ipv4Layer) { _ipv4Layer = ipv4Layer; // start our "send ICMP messages transmission" thread _sendIcmpMessagesInBackgroundQueue = new System.Collections.Queue(); _sendIcmpMessagesInBackgroundThread = new Thread(SendIcmpMessagesThread); _sendIcmpMessagesInBackgroundThread.Start(); }
public DnsResolver(IPv4Layer ipv4Layer) { _ipv4Layer = ipv4Layer; // create our DNS cache _dnsCache = new System.Collections.Hashtable(); // enable our "cleanup DNS cache" timer (fired every 600 seconds) _cleanupDnsCacheTimer = new Timer(CleanupDnsCache, null, 600000, 600000); }
const Int32 RECEIVE_BUFFER_MIN_SIZE = 536; /* 536 bytes is the minimum receive buffer size allowed by UDP spec */ public UdpSocket(IPv4Layer ipv4Layer, int handle) : base(handle) { // save a reference to our IPv4Layer; we'll use this to send IPv4 frames _ipv4Layer = ipv4Layer; base._protocolType = IPv4Layer.ProtocolType.Udp; InitializeReceivedPacketBuffer(_receivedPacketBuffer); }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; if (_dnsCache != null) { _dnsCache.Clear(); } _cleanupDnsCacheTimer.Dispose(); _ipv4Layer = null; }
public void Dispose() { _ipv4Layer = null; _tcpHeaderBuffer = null; _tcpHeaderBufferLockObject = null; _tcpPseudoHeaderBuffer = null; _tcpPseudoHeaderBufferLockObject = null; _checksumBufferArray = null; _checksumOffsetArray = null; _checksumCountArray = null; _bufferArray = null; _indexArray = null; _countArray = null; }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; // shut down our icmp messages transmission thread if (_sendIcmpMessagesInBackgroundEvent != null) { _sendIcmpMessagesInBackgroundEvent.Set(); _sendIcmpMessagesInBackgroundEvent = null; } _ipv4Layer = null; _icmpFrameBuffer = null; _icmpFrameBufferLock = null; //if (_outstandingEchoRequests != null) //{ // for (int i = 0; i < _outstandingEchoRequests.Count; i++) // { // if (_outstandingEchoRequests[i] != null) // { // ((IDisposable)_outstandingEchoRequests[i]).Dispose(); // } // } //} //_outstandingEchoRequests = null; //_outstandingEchoRequestsLock = null; _bufferArray = null; _indexArray = null; _countArray = null; _checksumBufferArray = null; _checksumOffsetArray = null; _checksumCountArray = null; _checksumLock = null; }
public override void Dispose() { base.Dispose(); _ipv4Layer = null; _udpHeaderBuffer = null; _udpHeaderBufferLockObject = null; _udpPseudoHeaderBuffer = null; _udpPseudoHeaderBufferLockObject = null; _checksumBufferArray = null; _checksumOffsetArray = null; _checksumCountArray = null; _bufferArray = null; _indexArray = null; _countArray = null; }
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; } }
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 DHCPv4Client(IPv4Layer ipv4Layer) { _ipv4Layer = ipv4Layer; _physicalAddress = ipv4Layer.GetPhysicalAddressAsUInt64(); // create DHCP state machine thread _dhcpStateMachineThread = new Thread(DhcpStateMachine); _dhcpStateMachineThread.Start(); _leaseUpdateTimer = new Timer(LeaseUpdateTimerCallback, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); // wire up LinkStateChanged event _ipv4Layer.LinkStateChanged += _ipv4Layer_LinkStateChanged; }
public TcpHandler(IPv4Layer ipv4Layer) { // save a reference to our IPv4Layer; we'll use this to send IPv4 frames _ipv4Layer = ipv4Layer; }
public void Dispose() { if (_isDisposed) return; _isDisposed = true; if (_dnsCache != null) _dnsCache.Clear(); _cleanupDnsCacheTimer.Dispose(); _ipv4Layer = null; }
public void Dispose() { if (_isDisposed) return; _isDisposed = true; // shut down our icmp messages transmission thread if (_sendIcmpMessagesInBackgroundEvent != null) { _sendIcmpMessagesInBackgroundEvent.Set(); _sendIcmpMessagesInBackgroundEvent = null; } _ipv4Layer = null; _icmpFrameBuffer = null; _icmpFrameBufferLock = null; //if (_outstandingEchoRequests != null) //{ // for (int i = 0; i < _outstandingEchoRequests.Count; i++) // { // if (_outstandingEchoRequests[i] != null) // { // ((IDisposable)_outstandingEchoRequests[i]).Dispose(); // } // } //} //_outstandingEchoRequests = null; //_outstandingEchoRequestsLock = null; _bufferArray = null; _indexArray = null; _countArray = null; _checksumBufferArray = null; _checksumOffsetArray = null; _checksumCountArray = null; _checksumLock = null; }
public void Dispose() { if (_isDisposed) return; _isDisposed = true; if (_leaseUpdateTimer != null) _leaseUpdateTimer.Dispose(); // shut down our state machine thread if (_dhcpStateMachineEvent != null) { _dhcpStateMachineEvent.Set(); _dhcpStateMachineEvent = null; } //_cleanupArpCacheTimer.Dispose(); try { _ipv4Layer.LinkStateChanged -= _ipv4Layer_LinkStateChanged; } catch { } _ipv4Layer = null; //_bufferArray = null; //_indexArray = null; //_countArray = null; _randomGenerator = null; // unwire all event handlers IpConfigChanged = null; DnsConfigChanged = null; }