public void Start(SoftwallRule[] rules) { if (listenerThread != null) throw new Exception("Already running"); this.rules = rules; listenerThread = new Thread(ListenerThread); listenerThread.Start(); }
public SoftwallRule[] GetRules() { DataRowCollection rows = softwallDataSet.Tables[0].Rows; List <SoftwallRule> rules = new List <SoftwallRule>(rows.Count); foreach (DataRow row in rows) { SoftwallRule rule = new SoftwallRule(); rule.conditions = 0; object obj = row["ProcessName"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_PROCESS_NAME; rule.process_name = obj as string; } obj = row["FunctionName"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_FUNCTION_NAME; rule.function_name = obj as string; } obj = row["ReturnAddress"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_RETURN_ADDRESS; rule.return_address = (UInt32)obj; } obj = row["LocalAddress"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_LOCAL_ADDRESS; rule.local_address = IPAddrFromStr(obj as string); } obj = row["LocalPort"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_LOCAL_PORT; rule.local_port = PortToBigEndian((UInt16)obj); } obj = row["RemoteAddress"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_REMOTE_ADDRESS; rule.remote_address = IPAddrFromStr(obj as string); } obj = row["RemotePort"]; if (!(obj is DBNull)) { rule.conditions |= Manager.SOFTWALL_CONDITION_REMOTE_PORT; rule.remote_port = PortToBigEndian((UInt16)obj); } rule.retval = (Int32)row["ReturnValue"]; rule.last_error = (UInt32)row["LastError"]; rules.Add(rule); } return(rules.ToArray()); }