private static void SyncModelHosts(ModelHost _dummy) { if (ModelHost.Exists(_dummy)) { ModelHost.UpdateHost(_dummy, _dummy); } else { ModelHost.AddToList(_dummy); } }
private void ProcessData() { try { if (NetworkHelper.IsDhcp(_data) && NetworkHelper.IsDhcpRequest(_data)) { ModelHost _tmpModel = new ModelHost(); _tmpModel.hostMac = NetworkHelper.getPhysicalAddressStringFromDhcp(_data); _tmpModel.macGiven = true; for (uint i = NetworkHelper.DHCP_COOKIE_POSITION; i < _data.Length; i++) { switch (Convert.ToUInt16(_data[i])) { case 50: byte[] _ipBytes = new byte[4]; for (uint ii = 0; ii < 4; ii++) { _ipBytes[ii] = _data[i + 2 + ii]; } _tmpModel.ipGiven = true; _tmpModel.hostIP = new IPAddress(_ipBytes); continue; case 55: i = 1 + i + _data[i + 1]; continue; case 12: byte _nameLength = _data[i + 1]; _tmpModel.hostName = ""; try { for (uint iii = 1; iii <= _nameLength; iii++) { _tmpModel.hostName += (char)_data[i + 1 + iii]; _tmpModel.nameGiven = true; } } catch { } continue; default: break; } } if (ModelHost.Exists(_tmpModel)) { if (_tmpModel.nameGiven) { ModelHost.UpdateHost(_tmpModel, _tmpModel.hostIP, _tmpModel.hostName); } else { ModelHost.UpdateHost(_tmpModel, _tmpModel.hostIP); } } else { ModelHost.AddToList(_tmpModel); } _js.SyncNodes(ModelHost.hostList); } } catch { } }