/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static bool resetAdapter(NetData netData) { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; wifiRadio.RadioState = RadioState.Off; wifiRadio.RadioState = RadioState.On; } } INetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (INetworkInterface networkInterface in networkInterfaces) { if (netData.NetworkAdapter.Name.Equals(networkInterface.Name)) { networkInterface.Rebind(); return(true); } } return(false); }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static void setRegistryDHCP(NetData netData) { string regName = "\\comm\\" + netData.NetworkAdapter.Name + "\\Parms\\Tcpip"; RegistryKey tcpipkey = Registry.LocalMachine.OpenSubKey(regName, true); tcpipkey.SetValue("EnableDHCP", (UInt32)1); tcpipkey.Close(); }
/// <summary> /// Constructor /// </summary> /// <param name="netData">Los parámetros de configuración</param> /// <param name="commHandler">El comunicador que maneja los eventos generados en la red</param> public NetHandler(NetData netData, CommHandlerI commHandler) { this.netData = netData; this.commHandler = commHandler; this.connectLock = new Object(); this.resetLock = new Object(); this.iphandlerPoint = 0; netData.pickNewIp(); init(); }
/// <summary> /// Cambia la Ip del sistema operativo a la configuración de red adhoc /// Si ocurre un error se arroja la excepción /// </summary> internal static void setRegistryIP(NetData netData) { string regName = "\\comm\\" + netData.NetworkAdapter.Name + "\\Parms\\Tcpip"; RegistryKey tcpipkey = Registry.LocalMachine.OpenSubKey(regName, true); tcpipkey.SetValue("EnableDHCP", (UInt32)0); tcpipkey.SetValue("IPAddress", netData.IpTcpListener.ToString()); tcpipkey.SetValue("SubnetMask", netData.SubnetMask); tcpipkey.Close(); }
/// <summary> /// Constructor /// </summary> /// <param name="netData">los datos de red</param> /// <param name="wifiInformation">el manejador de eventos</param> public WifiHandler(NetData netData, WifiInformationDelegate wifiInformation) { this.netData = netData; this.wifiInformation = wifiInformation; //inicializa los objetos Wlan wLanClient = new WlanClient(); wlanConnectionNotificationEventHandler = new WlanClient.WlanInterface.WlanConnectionNotificationEventHandler(WlanConnectionAction); wlanAdhocNetworkNotificationEventHandler = new WlanClient.WlanInterface.WlanAdhocNetworkNotificationEventHandler(WlanAdhocNetworkAction); connectionState = WifiConnectionState.DISCONNECTED; syncPoint = new Object(); }
/// <summary> /// Constructor /// </summary> /// <param name="netData">Los datos de configuración de red</param> /// <param name="resetIpDelegate">la función que se gatilla cuando la Ip debe ser cambiada</param> public IpHandler(NetData netData, ResetIpDelegate resetIpDelegate) { this.resetIpDelegate = resetIpDelegate; this.netData = netData; checkIpThread = new Thread(new ThreadStart(checkIp)); state = IphandlerState.STOPPED; stopLock = new Object(); queueLock = new Object(); queue = new Queue<IPAddress>(); lolinessTimeOut = 0; lastAliveValue = 0; }
/// <summary> /// Constructor /// </summary> /// <param name="netData">Los datos de configuración de red</param> /// <param name="resetIpDelegate">la función que se gatilla cuando la Ip debe ser cambiada</param> public IpHandler(NetData netData, ResetIpDelegate resetIpDelegate) { this.resetIpDelegate = resetIpDelegate; this.netData = netData; checkIpThread = new Thread(new ThreadStart(checkIp)); state = IphandlerState.STOPPED; stopLock = new Object(); queueLock = new Object(); queue = new Queue <IPAddress>(); lolinessTimeOut = 0; lastAliveValue = 0; }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static void turnOffAdapter(NetData netData) { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; wifiRadio.RadioState = RadioState.Off; } } }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static bool resetAdapter2(NetData netData) { INetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (INetworkInterface networkInterface in networkInterfaces) { try { networkInterface.Rebind(); break; } catch (Exception) { } } return(true); }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static bool rebindAdapter(NetData netData) { INetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (INetworkInterface networkInterface in networkInterfaces) { if (netData.NetworkAdapter.Name.Equals(networkInterface.Name)) { WirelessZeroConfigNetworkInterface adapter = (WirelessZeroConfigNetworkInterface)networkInterface; adapter.Unbind(); adapter.Bind(); return(true); } } return(false); }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static void turnOnAdapter(NetData netData, Boolean forced) { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; if (forced) { wifiRadio.RadioState = RadioState.On; } else if (wifiRadio.RadioState == RadioState.Off) { wifiRadio.RadioState = RadioState.On; } } } }
/// <summary> /// Constructor /// </summary> /// <param name="netData">los datos de red</param> /// <param name="wifiInformation">el manejador de eventos</param> public WifiHandler(NetData netData, WifiInformationDelegate wifiInformation) { this.netData = netData; this.wifiInformation = wifiInformation; connectionState = WifiConnectionState.DISCONNECTED; }
/// <summary> /// Setea el time Out del este usuario para medir calidad de señal /// </summary> /// <param name="newTimeOut">El nuevo timeout</param> /// <param name="netData">Los datos de configuración de red</param> internal void setTimeOut(Int32 newTimeOut, NetData netData) { if (newTimeOut > netData.QualityMaxNetUser) { _timeout = netData.QualityMaxNetUser; } else { _timeout = newTimeOut; } if (_timeout > netData.QualityNormalNetUser) { this.SignalQuality = NetUserQuality.NORMAL; } else if (_timeout > netData.QualityLowNetUser) { this.SignalQuality = NetUserQuality.LOW; } else { this.SignalQuality = NetUserQuality.CRITICAL; } }
/// <summary> /// Chequea que el usuario ha sido detectado, incrementando su valor de calidad /// Método para uso interno /// </summary> /// <param name="netData">Los parámetros de configuración de red</param> internal void qualityUp(NetData netData) { setTimeOut(Timeout + netData.QualityRiseNetUser, netData); }
/// <summary> /// Decrementa la calidad de señal, método para uso interno /// </summary> internal void qualityDown(NetData netData) { setTimeOut(Timeout - 1, netData); }
/// <summary> /// Constructor parametrizado, para uso interno, no se debe usar directamente /// </summary> /// <param name="id">El id del usuario</param> /// <param name="name">El nombre del usuario</param> /// <param name="ip">La dirección IP del usuario</param> /// <param name="neighborhood">Un array con los ids de los nodos vecinos al usuario</param> /// <param name="netData">Los datos de configuración</param> internal NetUser(Guid id, String name, IPAddress ip, Guid[] neighborhood, NetData netData) { this.Id = id; this.Name = name; this.Ip = ip; this.NeighborhoodIds = neighborhood; this.SignalQuality = NetUserQuality.NORMAL; setTimeOut(netData.QualityMaxNetUser, netData); this.JumpsAway = 0; this.WaitTimeOut = 0; this.State = CommunicationQuality.NORMAL; this.UpLayerData = new byte[0]; }
/// <summary> /// Constructor Parametrizado /// </summary> /// <param name="netUser">Datos del usuario</param> /// <param name="netData">Datos de configuración de red</param> public Configuration(NetUser netUser, NetData netData) { this.NetUser = netUser; this.NetData = netData; }