public UdpSession CreateUnboundSession() { UdpSession s = new UdpSession(this); Core.Instance().RegisterSession(this, s); return(s); }
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); }
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); } }
public UdpSession !CreateBoundSession(IPv4 localAddress, ushort localPort, IPv4 remoteAddress, ushort remotePort) { UdpSession s = new UdpSession(this); Core.Instance().RegisterSession(this, s); s.BindEndPoints(localAddress, localPort, remoteAddress, remotePort); return(s); }
public void Stop() { lock (this) { workerDone = true; workerThread.Join(); udpSession.Close(); udpSession = null; workerThread = null; CancelTimeouts(); @state = null; } DebugPrint("DhcpClient.Stop()\n"); }