Beispiel #1
0
        /// <summary>
        /// Connect to UDP client
        /// </summary>
        /// <param name="ip">IP</param>
        /// <param name="port">Target port</param>
        /// <returns>If the connection was successful</returns>
        public bool Connect(string ip, ushort port)
        {
            m_ip = NetworkTools.StringToIp(ip);
            if (m_ip == null)
            {
                return(false);
            }

            bool found = Route.FindRoute(m_ip);

            if (!found)
            {
                return(false);
            }

            m_connected = true;

            m_queue = new Queue();

            m_targetPort = port;

            m_ipSpecified = true;

            // Register a sourcePort
            UDP.BindSocketRequest(this);

            return(true);
        }
        /// <summary>
        /// Connect to TCP client
        /// </summary>
        /// <param name="ip">IP</param>
        /// <param name="port">Target port</param>
        /// <returns>If the connection was successful</returns>
        public bool Connect(string ip, ushort port)
        {
            m_ip = NetworkTools.StringToIp(ip);
            if (m_ip == null)
            {
                return(false);
            }

            bool found = Route.FindRoute(m_ip);

            if (!found)
            {
                return(false);
            }

            m_connected = true;

            m_queue = new Queue();

            m_targetPort = port;

            m_ipSpecified = true;

            Connection = TCP.Connect(m_ip, m_targetPort);

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// FS finddir
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="name">The name to look for</param>
        /// <returns>The node</returns>
        private static unsafe Node findDirImpl(Node node, string name)
        {
            byte[] ip = NetworkTools.StringToIp(name);
            if (ip == null)
            {
                return(null);
            }

            byte *dstMac = (byte *)Heap.Alloc(6);

            Memory.Memset(dstMac, 0, 6);

            ARP.Lookup(ip, dstMac);

            if (dstMac[0] == 0x00 && dstMac[1] == 0x00 && dstMac[2] == 0x00 && dstMac[3] == 0x00 && dstMac[4] == 0x00 && dstMac[5] == 0x00)
            {
                byte[] mac = new byte[6];
                for (int i = 0; i < 6; i++)
                {
                    mac[i] = 0xFF;
                }

                ARP.ArpSend(ARP.OP_REQUEST, mac, ip);
                Heap.Free(mac);

                return(null);
            }
            Heap.Free(dstMac);

            return(new Node());
        }