Beispiel #1
0
 public static bool IsValidIPv4(IPv4 ip)
 {
     if ((ip == null) || (ip.IsNull))
         return false;
     else
         return true;
 }
Beispiel #2
0
        public void Send(byte[] data, IPv4.Address dest, Int32 destPort)
        {
            IPv4.Address source = IPv4.Config.FindNetwork(dest);
            IPv4.UDPPacket packet = new IPv4.UDPPacket(source, dest, (UInt16)this.localPort, (UInt16)destPort, data);

            Sys.Console.WriteLine("Sending " + packet.ToString());
            IPv4.OutgoingBuffer.AddPacket(packet);
        }
Beispiel #3
0
 public static IPv4 CreateIPv4(SqlByte i1, SqlByte i2, SqlByte i3, SqlByte i4)
 {
     IPv4 ip = new IPv4(i1.Value, i2.Value, i3.Value, i4.Value);
     if (ip == null)
         return IPv4.Null;
     else
         return ip;
 }
Beispiel #4
0
    public static int SwitchIPv4(ref IPv4 ip1, ref IPv4 ip2)
    {
        if ((ip1 == null) || (ip2 == null) || ip1.IsNull || ip2.IsNull)
            return (0);

        IPv4 ipTemp = ip1;
        ip1 = ip2;
        ip2 = ipTemp;
        return (1);
    }
Beispiel #5
0
        internal static MACAddress Resolve(IPv4.Address ipAddress)
        {
            ensureCacheExists();
            if (cache.ContainsKey(ipAddress.Hash) == false)
            {
                return null;
            }

            return cache[ipAddress.Hash];
        }
Beispiel #6
0
        internal static void Update(IPv4.Address ipAddress, MACAddress macAddress)
        {
            ensureCacheExists();
            if (ipAddress == null)
            {
              global::System.Console.Write("");
            }
            UInt32 ip_hash = ipAddress.Hash;
            if (ip_hash == 0)
            {
                return;
            }

            if (cache.ContainsKey(ip_hash) == false)
            {
                cache.Add(ip_hash, macAddress);
            }
            else
            {
                cache[ip_hash] = macAddress;
            }
        }
Beispiel #7
0
 /// <summary>
 /// Configure a IP configuration on the given network device.
 /// <remarks>Multiple IP Configurations can be made, like *nix environments</remarks>
 /// </summary>
 /// <param name="nic"><see cref="Cosmos.Hardware.NetworkDevice"/> that will have the assigned configuration</param>
 /// <param name="config"><see cref="Cosmos.System.Network.IPv4.Config"/> instance that defines the IP Address, Subnet
 /// Mask and Default Gateway for the device</param>
 public static void ConfigIP(NetworkDevice nic, IPv4.Config config)
 {
     AddressMap.Add(config.IPAddress.Hash, nic);
     IPv4.Config.Add(config);
     nic.DataReceived = HandlePacket;
 }
Beispiel #8
0
 public override void Visit(IPv4 node) { this.action(node); }
 public override void ExplicitVisit(IPv4 fragment)
 {
     _fragments.Add(fragment);
 }
Beispiel #10
0
 public void Connect(IPv4.Address dest, Int32 destPort)
 {
     this.destination = dest;
     this.destinationPort = destPort;
 }
Beispiel #11
0
 public UdpClient(IPv4.Address dest, Int32 destPort)
     : this(0)
 {
     this.destination = dest;
     this.destinationPort = destPort;
 }
Beispiel #12
0
 internal DataGram(byte[] data, IPv4.EndPoint src)
 {
     this.data = data;
     this.source = src;
 }
Beispiel #13
0
        internal void receiveData(IPv4.UDPPacket packet)
        {
            byte[] data = packet.UDP_Data;
            IPv4.EndPoint source = new IPv4.EndPoint(packet.SourceIP, packet.SourcePort);

            Sys.Console.WriteLine("Received " + data.Length + " bytes data from " + source.ToString());

            this.rxBuffer.Enqueue(new DataGram(data, source));
        }
Beispiel #14
0
        public byte[] Receive(ref IPv4.EndPoint source)
        {
            if (this.rxBuffer.Count < 1)
            {
                return null;
            }

            DataGram packet = rxBuffer.Dequeue();
            source.address = packet.source.address;
            source.port = packet.source.port;

            return packet.data;
        }
Beispiel #15
0
 internal static bool Contains(IPv4.Address ipAddress)
 {
     ensureCacheExists();
     return cache.ContainsKey(ipAddress.Hash);
 }