示例#1
0
        public void Close()
        {
            Apps.System.Debugger.debugger.Send("Closing TCP Connection...");

            IPV4.Address source = IPV4.Config.FindNetwork(this.destination);

            TCPConnection.Connection connection = new TCPConnection.Connection();

            Apps.System.Debugger.debugger.Send("Closing " + destination.ToString() + ":" + this.destinationPort + "now!");

            connection.dest   = this.destination;
            connection.source = source;

            connection.localPort = (ushort)this.localPort;
            connection.destPort  = (ushort)this.destinationPort;

            connection.acknowledgmentnb = lastack;

            connection.WSValue = 1024;

            connection.sequencenumber = lastsn;

            connection.Checksum = 0x0000;

            connection.Flags = 0x11;

            connection.Send(false);

            readytosend = false;

            Apps.System.Debugger.debugger.Send("Closed!");
        }
示例#2
0
        public void Send(byte[] data, IPV4.Address dest, Int32 destPort)
        {
            IPV4.Address source = IPV4.Config.FindNetwork(dest);

            //Console.WriteLine("Sending " + "TCP Packet Src=" + source + ":" + localPort + ", Dest=" + dest + ":" + destPort + ", DataLen=" + data.Length);

            TCPConnection.Connection connection = new TCPConnection.Connection();

            connection.dest   = dest;
            connection.source = source;

            connection.localPort = (ushort)localPort;
            connection.destPort  = (ushort)destPort;

            connection.acknowledgmentnb = lastack;

            connection.WSValue = 1024;

            connection.sequencenumber = lastsn;

            connection.Checksum = 0x0000;

            connection.Flags = 0x18;

            connection.data = data;

            connection.Send(true);

            readytosend = false;
        }
示例#3
0
        public void Send(byte[] data, IPV4.Address dest, Int32 destPort)
        {
            IPV4.Address       source = IPV4.Config.FindNetwork(dest);
            IPV4.UDP.UDPPacket packet = new IPV4.UDP.UDPPacket(source, dest, (UInt16)this.localPort, (UInt16)destPort, data);

            Console.WriteLine("Sending " + packet.ToString());
            IPV4.OutgoingBuffer.AddPacket(packet);
        }
示例#4
0
        internal static MACAddress Resolve(IPV4.Address ipAddress)
        {
            ensureCacheExists();
            if (cache.ContainsKey(ipAddress.Hash) == false)
            {
                return(null);
            }

            return(cache[ipAddress.Hash]);
        }
示例#5
0
        public void Connect(IPV4.Address dest, Int32 destPort)
        {
            this.destination     = dest;
            this.destinationPort = destPort;

            TCPConnection.Connection connection = new TCPConnection.Connection();
            Address source = Config.FindNetwork(dest);

            ulong CID = (ulong)(dest.Hash + this.localPort + destPort);

            TCPConnection.Connections.Add((uint)CID, connection);

            connection.CID = CID;

            Apps.System.Debugger.debugger.Send(CID.ToString());

            connection.dest   = dest;
            connection.source = source;

            connection.localPort = (ushort)localPort;
            connection.destPort  = (ushort)destPort;

            connection.acknowledgmentnb = 0x0000;

            connection.WSValue = 1024;

            connection.sequencenumber = 3455719727;

            connection.Checksum = 0x0000;

            connection.Flags = 0x02;

            connection.Send(false);

            int _deltaT = 0;
            int second  = 0;

            while (!connection.IsOpen)
            {
                if (_deltaT != Cosmos.HAL.RTC.Second)
                {
                    second++;
                    _deltaT = Cosmos.HAL.RTC.Second;
                }

                if (second >= 4)
                {
                    Apps.System.Debugger.debugger.Send("No response in 4 secondes...");
                    break;
                }
            }

            Apps.System.Debugger.debugger.Send("Connected!!");
        }
示例#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;
            }
        }
示例#7
0
        //from ip, port, incoming bool, outcoming bool
        //192.168.1.1, 25565, true, true

        public static bool TCPIncomingFilter(IPV4.TCP.TCPPacket packet)
        {
            IPV4.Address IPSource = packet.SourceIP;
            ushort       Port     = packet.SourcePort;

            for (int i = 0; i < TCPFilterList.Count; i++)
            {
                if (TCPFilterList[i].Contains(IPSource.ToString() + "," + Port.ToString() + ",true"))
                {
                    //string[] FilterList = TCPFilterList[i].Split(',');
                    //bool INCOMING = bool.Parse(FilterList[2]);

                    return(true);
                }
                if (TCPFilterList[i].Contains(IPSource.ToString() + ",*,true"))
                {
                    //string[] FilterList = TCPFilterList[i].Split(',');
                    //bool INCOMING = bool.Parse(FilterList[2]);

                    return(true);
                }
            }
            return(false);
        }
示例#8
0
 internal static bool Contains(IPV4.Address ipAddress)
 {
     ensureCacheExists();
     return(cache.ContainsKey(ipAddress.Hash));
 }
示例#9
0
 public void Connect(IPV4.Address dest, Int32 destPort)
 {
     this.destination     = dest;
     this.destinationPort = destPort;
 }
示例#10
0
 public DNSClient(IPV4.Address dest, Int32 destPort)
     : this(0)
 {
     this.destination     = dest;
     this.destinationPort = destPort;
 }