Ejemplo n.º 1
0
        private StatusCode AskDnsServer(IPv4 dnsServer,
                                        byte[] !outData,
                                        out byte[] rcvData)
        {
            Core      core      = Core.Instance();
            UdpModule udpModule = core.GetProtocolByName("UDP") as UdpModule;

            if (udpModule == null)
            {
                rcvData = null;
                return(StatusCode.TransportError);
            }

            UdpSession udpSession =
                udpModule.CreateBoundSession(IPv4.Any, 0,
                                             dnsServer, Dns.Format.ServerPort);

            udpSession.WriteData(outData);
            rcvData = udpSession.PollCopyData(TimeSpan.FromTicks(timeout.Ticks));
            if (rcvData == null)
            {
                return(StatusCode.Timeout);
            }

            return(StatusCode.Success);
        }
Ejemplo n.º 2
0
        public bool Start()
        {
            lock (this) {
                if (udpSession != null)
                {
                    return(false);
                }

                Core      core      = Core.Instance();
                UdpModule udpModule =
                    core.GetProtocolByName("UDP") as UdpModule;
                if (udpModule == null)
                {
                    DebugPrint("DhcpClient.Start() failed -- " +
                               "UdpModule not found.\n");
                    return(false);
                }

                udpSession = udpModule.CreateBoundSession(
                    IPv4.Any, DhcpFormat.ClientPort,
                    IPv4.Any, DhcpFormat.ServerPort
                    );
                udpSession.BoundMux = core.GetMuxForAdapter(adapter);
                ResetAdapterIPInfo();

                workerDone   = false;
                workerThread = new Thread(new ThreadStart(WorkerMain));
#if !SINGULARITY
                workerThread.Name = String.Format("DhcpClient/{0}",
                                                  adapter.HardwareAddress);
#endif
                workerThread.Start();
                return(true);
            }
        }