Esempio n. 1
0
        /// <summary>
        /// Adds a host entry to this host table. This will not overwrite static entries.
        /// </summary>
        /// <param name="arphEntry">The host entry to add.</param>
        public void AddHost(ARPHostEntry arphEntry)
        {
            bool bAdded = false;

            lock (dMACHostTable)
            {
                if (dMACHostTable.ContainsKey(arphEntry.MAC))
                {
                    if (!dMACHostTable[arphEntry.MAC].IsStatic)
                    {
                        InvokeExternalAsync(EntryRemoved, new HostTableEventArgs(dMACHostTable[arphEntry.MAC]));
                        dMACHostTable[arphEntry.MAC] = arphEntry;
                        bAdded = true;
                    }
                }
                else
                {
                    dMACHostTable.Add(arphEntry.MAC, arphEntry);
                    bAdded = true;
                }
            }
            lock (dIPHostTable)
            {
                if (dIPHostTable.ContainsKey(arphEntry.IP))
                {
                    if (!dIPHostTable[arphEntry.IP].IsStatic)
                    {
                        dIPHostTable[arphEntry.IP] = arphEntry;
                        bAdded = true;
                    }
                }
                else
                {
                    dIPHostTable.Add(arphEntry.IP, arphEntry);
                    bAdded = true;
                }
            }
            if (bAdded)
            {
                InvokeExternalAsync(EntryAdded, new HostTableEventArgs(arphEntry));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new instance of this class
 /// </summary>
 /// <param name="ahEntry">The ARP host entry associated with this event</param>
 public HostTableEventArgs(ARPHostEntry ahEntry)
 {
     this.ahEntry = ahEntry;
 }
Esempio n. 3
0
 /// <summary>
 /// Returns all hosts known in this host table
 /// </summary>
 /// <returns>All hosts known in this host table</returns>
 public ARPHostEntry[] GetKnownHosts()
 {
     ARPHostEntry[] ipa = new ARPHostEntry[dIPHostTable.Count];
     dIPHostTable.Values.CopyTo(ipa, 0);
     return(ipa);
 }