コード例 #1
0
        public ZB_SEND_DATA_CONFIRM(byte[] framedata)
        {
            Handle = framedata[0];
            Status = (PacketStatus)framedata[1];

            BuildPacket(new DoubleByte(ZToolCMD.ZB_SEND_DATA_CONFIRM), framedata);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="packetId"></param>
        /// <param name="status"></param>
        /// <param name="frameworkId"></param>
        public void SetPacketStatus(int frameworkId, PacketStatus status)
        {
            lock (locker)
            {
                using (var realm = PacketBufferHelper.GetBufferInstance())
                {
                    var source = realm.All <Part>().SingleOrDefault(x => x.FrameworkId == frameworkId);

                    if (source == null)
                    {
                        throw new NullReferenceException();
                    }

                    realm.Write(() =>
                    {
                        source.Status = (int)status;

                        if (status == PacketStatus.Transmitted)
                        {
                            source.TransmittedDate = DateTimeOffset.UtcNow;
                        }
                        else
                        {
                            source.TransmittedDate = DateTimeOffset.MinValue;
                        }
                    });
                }
            }
        }
コード例 #3
0
        public ZDO_STATUS_ERROR_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket(new DoubleByte(ZToolCMD.ZDO_STATUS_ERROR_RSP), data);
        }
コード例 #4
0
        public override PacketMainReturnType interiorMain(ref Packet in_packet)
        {
            LogEvent le;

            lock (padlock)
            {
                PacketStatus status = PacketStatus.UNDETERMINED;
                foreach (MacRule r in rules)
                {
                    status = r.GetStatus(in_packet);
                    if (status == PacketStatus.BLOCKED)
                    {
                        PacketMainReturnType pmr = PacketMainReturnType.Drop;
                        if (r.GetLogMessage() != null)
                        {
                            pmr |= PacketMainReturnType.Log;
                            le   = new LogEvent(String.Format(r.GetLogMessage()), this);
                            LogCenter.Instance.LogEvent(le);
                        }
                        if (r.notify)
                        {
                            pmr |= PacketMainReturnType.Popup;
                        }
                        return(pmr);
                    }
                    else if (status == PacketStatus.ALLOWED)
                    {
                        return(PacketMainReturnType.Allow);
                    }
                }
            }
            return(PacketMainReturnType.Allow);
        }
コード例 #5
0
            public static Rule MakeRule(RuleType ruleType, PacketStatus ps, Direction dir, string args, bool log, bool notify)
            {
                switch (ruleType)
                {
                case RuleType.IP:
                    return(GenIPRule(ps, args, dir, log, notify));

                case RuleType.TCPALL:
                    return(new TCPAllRule(ps, dir, log, notify));

                case RuleType.TCPIPPORT:
                    return(new TCPIPPortRule(ps, IPAddress.Parse(args.Split(' ')[0]), int.Parse(args.Split(' ')[1]), dir, log, notify));

                case RuleType.TCPPORT:
                    return(GenTCPPORT(ps, args, dir, log, notify));

                case RuleType.UDPALL:
                    return(new UDPAllRule(ps, dir, log, notify));

                case RuleType.UDPPORT:
                    return(GenUDPPORT(ps, args, dir, log, notify));

                case RuleType.ALL:
                    return(new AllRule(ps, dir, log, notify));
                }
                return(null);
            }
コード例 #6
0
        public ZDO_BIND_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_BIND_RSP), data);
        }
コード例 #7
0
 public override PacketMainReturn interiorMain(ref Packet in_packet)
 {
     lock (padlock)
     {
         PacketStatus status = PacketStatus.UNDETERMINED;
         foreach (MacRule r in rules)
         {
             status = r.GetStatus(in_packet);
             if (status == PacketStatus.BLOCKED)
             {
                 PacketMainReturn pmr = new PacketMainReturn(this);
                 pmr.returnType = PacketMainReturnType.Drop;
                 if (r.GetLogMessage() != null)
                 {
                     pmr.returnType |= PacketMainReturnType.Log;
                     pmr.logMessage  = r.GetLogMessage();
                 }
                 if (r.notify)
                 {
                     pmr.returnType |= PacketMainReturnType.Popup;
                 }
                 return(pmr);
             }
             else if (status == PacketStatus.ALLOWED)
             {
                 return(null);
             }
         }
     }
     return(null);
 }
コード例 #8
0
        public ZDO_STATUS_ERROR_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket((ushort)ZToolCMD.ZDO_STATUS_ERROR_RSP, data);
        }
コード例 #9
0
 public Packet() : base()
 {
     this.m_oData        = new Data();
     this.m_bType        = new Bit(1);
     this.m_szbtStatus   = PacketStatus.NotCopied;
     this.m_szbtSequence = new Bit[4];
 }
コード例 #10
0
        public ZDO_MGMT_PERMIT_JOIN_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket((ushort)ZToolCMD.ZDO_MGMT_PERMIT_JOIN_RSP, data);
        }
コード例 #11
0
        public ZB_SEND_DATA_CONFIRM(byte[] framedata)
        {
            Handle = framedata[0];
            Status = (PacketStatus)framedata[1];

            BuildPacket((ushort)ZToolCMD.ZB_SEND_DATA_CONFIRM, framedata);
        }
コード例 #12
0
 public TCPPortRule(PacketStatus ps, List <int> port, Direction direction, bool log, bool notify)
 {
     this.ps        = ps;
     this.direction = direction;
     this.port      = port;
     this.log       = log;
 }
コード例 #13
0
        public bool TryAddPackets(int count, PacketStatus packetStatus)
        {
            switch (packetStatus)
            {
            case PacketStatus.Failure:
                FailedCount.Value += 1;
                break;

            case PacketStatus.Success:
                SucceededCount.Value += 1;
                break;
            }

            var failedCount = FailedCount.Value != 0 ? FailedCount.Value : 1.0f;

            if ((SucceededCount.Value / (float)(SucceededCount.Value + FailedCount.Value) <= FailureThreashold) &&
                (FailedCount.Value + SucceededCount.Value >= MinimumPacketsRequired))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #14
0
 public TCPAllRule(PacketStatus ps, Direction direction, bool log, bool notify)
 {
     this.ps        = ps;
     this.direction = direction;
     this.log       = log;
     this.notify    = notify;
 }
コード例 #15
0
ファイル: fireBwallModule.cs プロジェクト: hatRiot/fireBwall
 public AllRule(PacketStatus ps, Direction direction, bool log, bool notify)
 {
     this.ps = ps;
     this.direction = direction;
     this.log = log;
     this.notify = notify;
 }
コード例 #16
0
        /// <summary>
        /// Used to generate a new IPRule
        /// </summary>
        /// <returns></returns>
        private static IPRule GenIPRule(PacketStatus ps, string args, Direction dir, bool log, bool notify)
        {
            List <string> tokens = new List <string>(args.Split(' '));
            IPRule        rule   = new IPRule();

            try
            {
                // iterate through the tokens and try and parse them into
                // an IP address
                foreach (string s in tokens)
                {
                    IPAddress tmp = IPAddress.Parse(s);
                    rule.ips.Add(tmp);
                }

                // set the rest of the fields
                rule.ps        = ps;
                rule.direction = dir;
                rule.log       = log;
                rule.notify    = notify;
            }
            catch (Exception)
            {
                // probably a parse error
                throw new Exception();
            }
            return(rule);
        }
コード例 #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="frameworkId"></param>
        public void SetPacketStatus(string packetId, PacketStatus status, int?frameworkId = null)
        {
            lock (locker)
            {
                using (var realm = PacketBufferHelper.GetBufferInstance())
                {
                    var source = realm.Find <Part>(packetId);

                    if (source == null)
                    {
                        throw new NullReferenceException();
                    }

                    if (status == PacketStatus.TransferredToDevice && frameworkId == null)
                    {
                        throw new ArgumentException("Framework id must be specified");
                    }

                    realm.Write(() =>
                    {
                        source.Status      = (int)status;
                        source.FrameworkId = frameworkId ?? source.FrameworkId;

                        if (status == PacketStatus.Transmitted)
                        {
                            source.TransmittedDate = DateTimeOffset.UtcNow;
                        }
                        else
                        {
                            source.TransmittedDate = DateTimeOffset.MinValue;
                        }
                    });
                }
            }
        }
コード例 #18
0
 public MacRule(PacketStatus ps, PhysicalAddress mac, Direction direction, bool log, bool notify)
 {
     this.ps = ps;
     this.mac = mac.GetAddressBytes();
     this.direction = direction;
     this.log = log;
     this.notify = notify;
 }
コード例 #19
0
 public IPRule(PacketStatus ps, List <IPAddress> ip, Direction direction, bool log, bool notify)
 {
     this.ps        = ps;
     this.direction = direction;
     this.ips       = ip;
     this.log       = log;
     this.notify    = notify;
 }
コード例 #20
0
 public MacRule(PacketStatus ps, Direction direction, bool log, bool notify)
 {
     this.ps        = ps;
     this.mac       = null;
     this.direction = direction;
     this.log       = log;
     this.notify    = notify;
 }
コード例 #21
0
 public MacRule(PacketStatus ps, PhysicalAddress mac, Direction direction, bool log, bool notify)
 {
     this.ps        = ps;
     this.mac       = mac.GetAddressBytes();
     this.direction = direction;
     this.log       = log;
     this.notify    = notify;
 }
コード例 #22
0
ファイル: MiClient.cs プロジェクト: slb1988/agame
        private List <NetPacketV1> recvPacketList()
        {
            if (!this.isConnected())
            {
                return(null);
            }
            List <NetPacketV1> list = new List <NetPacketV1>();

            try
            {
                NetPacketV1 tv;
                byte[]      buffer  = new byte[0x40000];
                SocketError success = SocketError.Success;
                int         length  = this.socket_.Receive(buffer, 0, buffer.Length, SocketFlags.None, out success);
                switch (success)
                {
                case SocketError.TimedOut:
                case SocketError.WouldBlock:
                case SocketError.IOPending:
                    return(list);
                }
                if ((success != SocketError.Success) || (length == 0))
                {
                    this.socket_.Close();
                    this.socket_ = null;
                    return(list);
                }
                byte[] destinationArray = new byte[0x40000];
                Array.Copy(this.left_buf_, 0, destinationArray, 0, this.left_buf_len_);
                Array.Copy(buffer, 0, destinationArray, this.left_buf_len_, length);
                int num2 = length + this.left_buf_len_;
                this.left_buf_len_ = 0;
                for (int i = num2; i > 0; i -= tv.getPacketLen())
                {
                    byte[] buffer3 = new byte[i];
                    Array.Copy(destinationArray, num2 - i, buffer3, 0, i);
                    tv = new NetPacketV1();
                    PacketStatus status = tv.deserialize(ref buffer3);
                    if (status != PacketStatus.PACKET_CORRECT)
                    {
                        if (status == PacketStatus.PACKET_NOT_COMPLETE)
                        {
                            this.left_buf_len_ = i;
                            Array.Copy(buffer3, 0, this.left_buf_, 0, this.left_buf_len_);
                        }
                        return(list);
                    }
                    list.Add(tv);
                }
            }
            catch (SystemException)
            {
                if (this.isConnected())
                {
                }
            }
            return(list);
        }
コード例 #23
0
 private void ResetControlVariables()
 {
     _packet.Clear();
     _packetLength       = 0;
     _packetLengthOffset = 0;
     _status             = PacketStatus.Empty;
     _pendingBytes       = 4;
     _completed          = true;
 }
コード例 #24
0
 public TCPIPPortRule(PacketStatus ps, IPAddress ip, int port, Direction direction, bool log, bool notify)
 {
     this.ps        = ps;
     this.direction = direction;
     this.port      = port;
     this.ip        = ip;
     this.log       = log;
     this.notify    = notify;
 }
コード例 #25
0
        /// <summary>
        /// Parses out the arguments of a UDPPort rule
        ///
        /// We accept single or multiple ports and port ranges
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private static UDPPortRule GenUDPPORT(PacketStatus ps, string args, Direction dir, bool log, bool notify)
        {
            // first tokenize the args
            List <string> tmp  = new List <string>(args.Split(' '));
            UDPPortRule   rule = new UDPPortRule();

            try
            {
                // iterate through the given arguments
                foreach (string s in tmp)
                {
                    string loc = s;
                    // parse the port range
                    if (loc.Contains("-"))
                    {
                        // parse the start/end ports out of the arguments
                        PortRange p     = new PortRange();
                        string[]  split = loc.Split('-');
                        p.start = Convert.ToInt32(split[0]);
                        p.end   = Convert.ToInt32(split[1]);

                        // instead of an error message, we can just swap them
                        if (p.start > p.end)
                        {
                            int temp = p.start;
                            p.start = p.end;
                            p.end   = temp;
                        }

                        // add it to the rule port ranges list
                        rule.port_ranges.Add(p);
                    }
                    // else it's just a port, add it as usual
                    else
                    {
                        rule.port.Add(Convert.ToInt32(s));
                    }
                }

                // set the other rule stuff
                rule.ps        = ps;
                rule.direction = dir;
                rule.log       = log;
                rule.notify    = notify;
            }
            catch (Exception e)
            {
                // probably a parsing error; log it and throw an
                // exception so the rule isn't touched
                //LogCenter.WriteErrorLog(e);
                throw new Exception();
            }
            return(rule);
        }
コード例 #26
0
        /// <summary>
        /// Parses out the arguments of a TCPPort rule
        ///
        /// We accept single or multiple ports and port ranges
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private static TCPPortRule GenTCPPORT(PacketStatus ps, string args, Direction dir, bool log, bool notify)
        {
            // first tokenize the args
            List <string> tmp  = new List <string>(args.Split(' '));
            TCPPortRule   rule = new TCPPortRule();

            try
            {
                // iterate through the given arguments
                foreach (string s in tmp)
                {
                    string loc = s;
                    // parse the port range
                    if (loc.Contains("-"))
                    {
                        // parse the start/end ports out of the arguments
                        PortRange p     = new PortRange();
                        string[]  split = loc.Split('-');
                        p.start = Convert.ToInt32(split[0]);
                        p.end   = Convert.ToInt32(split[1]);

                        // someday we'll give more meaningful error messages, but
                        // for now just throw an exception if they're doing something
                        // dumb like range 200-50
                        if (p.start > p.end)
                        {
                            throw new Exception();
                        }

                        // add it to the rule port ranges list
                        rule.port_ranges.Add(p);
                    }
                    // else it's just a port, add it as usual
                    else
                    {
                        rule.port.Add(Convert.ToInt32(s));
                    }
                }

                // set the other rule stuff
                rule.ps        = ps;
                rule.direction = dir;
                rule.log       = log;
                rule.notify    = notify;
            }
            catch (Exception)
            {
                // probably a parsing error; log it
                // and throw an exception so the rule isn't changed
                //LogCenter.WriteErrorLog(e);
                throw new Exception();
            }
            return(rule);
        }
コード例 #27
0
        /// <summary>
        /// Parses out the arguments of a UDPPort rule
        /// 
        /// We accept single or multiple ports and port ranges
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private static UDPPortRule GenUDPPORT(PacketStatus ps, string args, Direction dir, bool log, bool notify)
        {
            // first tokenize the args
            List<string> tmp = new List<string>(args.Split(' '));
            UDPPortRule rule = new UDPPortRule();
            rule.port_ranges = new List<PortRange>();
            try
            {
                // iterate through the given arguments
                foreach (string s in tmp)
                {
                    string loc = s;
                    // parse the port range
                    if (loc.Contains("-"))
                    {
                        // parse the start/end ports out of the arguments
                        PortRange p = new PortRange();
                        string[] split = loc.Split('-');
                        p.start = Convert.ToInt32(split[0]);
                        p.end = Convert.ToInt32(split[1]);

                        // instead of an error message, we can just swap them
                        if (p.start > p.end)
                        {
                            int temp = p.start;
                            p.start = p.end;
                            p.end = temp;
                        }

                        // add it to the rule port ranges list
                        rule.port_ranges.Add(p);
                    }
                    // else it's just a port, add it as usual
                    else
                    {
                        rule.port.Add(Convert.ToInt32(s));
                    }
                }

                // set the other rule stuff
                rule.ps = ps;
                rule.direction = dir;
                rule.log = log;
                rule.notify = notify;
            }
            catch (Exception e)
            {
                // probably a parsing error; log it and throw an 
                // exception so the rule isn't touched
                //LogCenter.WriteErrorLog(e);
                throw new Exception();
            }
            return rule;
        }
コード例 #28
0
ファイル: WOL_Events.cs プロジェクト: jackyaz/KodiWOLLauncher
        public static void PacketReceived(PacketStatus packetstatus)
        {
            // Make sure someone is listening to event
            if (OnPacketReceived == null)
            {
                return;
            }

            WOLEventArgs args = new WOLEventArgs(packetstatus);

            OnPacketReceived(null, args);
        }
コード例 #29
0
        public void StopListener(PacketStatus _packetstatus)
        {
            packetstatus = _packetstatus;

            if (bgListenforWOL.IsBusy)
            {
                bgListenforWOL.CancelAsync();
                _wolsock.Close();
            }

            while (bgListenforWOL.IsBusy)
            {
                Application.DoEvents();
            }
        }
コード例 #30
0
 /// <summary>
 /// This function contains the actions that will be carried out on the background thread.
 /// </summary>
 /// <param name="sender">Object which triggers this event handler, typically a Background Worker</param>
 /// <param name="e">Arguments pased to the event handler</param>
 private void bgListenforWOL_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         int portno = this.portno;
         _wolsock = new WOL_Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp, portno);
         Console.WriteLine("Ready to receive...");
         _wolsock.ReceiveWOLPacket();
         packetstatus = PacketStatus.Received;
         Console.WriteLine(_wolsock.IEP.Address.ToString()); //print sender IP address
     }
     catch (SocketException se)
     {
         if (se.SocketErrorCode == SocketError.Interrupted)
         {
             e.Cancel = true; //set DoWork result as cancelled
         }
     }
 }
コード例 #31
0
            public virtual void ReadXml(XmlReader reader)
            {
                XmlSerializer logSerializer    = new XmlSerializer(typeof(bool));
                XmlSerializer notifySerializer = new XmlSerializer(typeof(bool));

                reader.ReadStartElement("macrule");

                reader.ReadStartElement("log");
                log = (bool)logSerializer.Deserialize(reader);
                reader.ReadEndElement();

                reader.ReadStartElement("notify");
                notify = (bool)notifySerializer.Deserialize(reader);
                reader.ReadEndElement();

                XmlSerializer dirSerializer = new XmlSerializer(typeof(Direction));

                reader.ReadStartElement("direction");
                direction = (Direction)dirSerializer.Deserialize(reader);
                reader.ReadEndElement();

                XmlSerializer statusSerializer = new XmlSerializer(typeof(PacketStatus));

                reader.ReadStartElement("status");
                ps = (PacketStatus)statusSerializer.Deserialize(reader);
                reader.ReadEndElement();

                XmlSerializer macSerializer = new XmlSerializer(typeof(string));

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement("mac");
                    mac = Convert.FromBase64String((string)macSerializer.Deserialize(reader));
                    reader.ReadEndElement();
                }
                else
                {
                    reader.ReadStartElement("mac");
                }

                reader.ReadEndElement();
            }
コード例 #32
0
        private void AcceptPacketLength(byte b)
        {
            _packetLength |= b << (4 - ++_packetLengthOffset);
            _status        = _packetLengthOffset < 4
                          ? PacketStatus.ReceivingPacketLength
                          : PacketStatus.ReceivingData;

            _pendingBytes--;
            if (_status == PacketStatus.ReceivingData)
            {
                if (_packetLength == 0)
                {
                    EndProcessingData(new byte[0]);
                }
                else
                {
                    _pendingBytes = _packetLength;
                }
            }
        }
コード例 #33
0
 public static Rule MakeRule(RuleType ruleType, PacketStatus ps, Direction dir, string args, bool log, bool notify)
 {
     switch (ruleType)
     {
         case RuleType.IP:
             return GenIPRule(ps, args, dir, log, notify);
         case RuleType.TCPALL:
             return new TCPAllRule(ps, dir, log, notify);
         case RuleType.TCPIPPORT:
             return new TCPIPPortRule(ps, IPAddr.Parse(args.Split(' ')[0]), int.Parse(args.Split(' ')[1]), dir, log, notify);
         case RuleType.TCPPORT:
             return GenTCPPORT(ps, args, dir, log, notify);
         case RuleType.UDPALL:
             return new UDPAllRule(ps, dir, log, notify);
         case RuleType.UDPPORT:
             return GenUDPPORT(ps, args, dir, log, notify);
         case RuleType.ALL:
             return new AllRule(ps, dir, log, notify);
     }
     return null;
 }
コード例 #34
0
        private void AcceptPacketLength(byte b)
        {
            _packetLength |= b << (4 - ++_packetLengthOffset);
            _status = _packetLengthOffset < 4
                          ? PacketStatus.ReceivingPacketLength
                          : PacketStatus.ReceivingData;

            _pendingBytes--;
            if (_status == PacketStatus.ReceivingData)
            {
                if (_packetLength == 0)
                {
                    EndProcessingData(new byte[0]);
                }
                else
                {
                    _pendingBytes = _packetLength;
                }
            }
        }
コード例 #35
0
ファイル: fireBwallModule.cs プロジェクト: hatRiot/fireBwall
        /// <summary>
        /// Parses out the arguments of a TCPPort rule
        /// 
        /// We accept single or multiple ports and port ranges
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private static TCPPortRule GenTCPPORT(PacketStatus ps, string args, Direction dir, bool log, bool notify)
        {
            // first tokenize the args
            List<string> tmp = new List<string>(args.Split(' '));
            TCPPortRule rule = new TCPPortRule();

            try
            {
                // iterate through the given arguments
                foreach (string s in tmp)
                {
                    string loc = s;
                    // parse the port range
                    if (loc.Contains("-"))
                    {
                        // parse the start/end ports out of the arguments
                        PortRange p = new PortRange();
                        string[] split = loc.Split('-');
                        p.start = Convert.ToInt32(split[0]);
                        p.end = Convert.ToInt32(split[1]);

                        // someday we'll give more meaningful error messages, but
                        // for now just throw an exception if they're doing something
                        // dumb like range 200-50
                        if (p.start > p.end)
                            throw new Exception();

                        // add it to the rule port ranges list
                        rule.port_ranges.Add(p);
                    }
                    // else it's just a port, add it as usual
                    else
                    {
                        rule.port.Add(Convert.ToInt32(s));
                    }
                }

                // set the other rule stuff
                rule.ps = ps;
                rule.direction = dir;
                rule.log = log;
                rule.notify = notify;
            }
            catch (Exception)
            {
                // probably a parsing error; log it
                // and throw an exception so the rule isn't changed
                //LogCenter.WriteErrorLog(e);
                throw new Exception();
            }
            return rule;
        }
コード例 #36
0
ファイル: fireBwallModule.cs プロジェクト: hatRiot/fireBwall
 public IPRule(PacketStatus ps, List<IPAddress> ip, Direction direction, bool log, bool notify)
 {
     this.ps = ps;
     this.direction = direction;
     this.ips = ip;
     this.log = log;
     this.notify = notify;
 }
コード例 #37
0
        public ZDO_BIND_REQ_SRSP(byte[] data)
        {
            Status = (PacketStatus)data[0];

            BuildPacket((ushort)ZToolCMD.ZDO_BIND_REQ_SRSP, data);
        }
コード例 #38
0
ファイル: fireBwallModule.cs プロジェクト: hatRiot/fireBwall
 public TCPIPPortRule(PacketStatus ps, IPAddress ip, int port, Direction direction, bool log, bool notify)
 {
     this.ps = ps;
     this.direction = direction;
     this.port = port;
     this.ip = ip;
     this.log = log;
     this.notify = notify;
 }
コード例 #39
0
ファイル: fireBwallModule.cs プロジェクト: hatRiot/fireBwall
 public TCPPortRule(PacketStatus ps, List<int> port, Direction direction, bool log, bool notify)
 {
     this.ps = ps;
     this.direction = direction;
     this.port = port;
     this.log = log;
 }
コード例 #40
0
            public virtual void ReadXml(XmlReader reader) 
            {
                XmlSerializer logSerializer = new XmlSerializer(typeof(bool));
                XmlSerializer notifySerializer = new XmlSerializer(typeof(bool));

                reader.ReadStartElement("macrule");

                reader.ReadStartElement("log");
                log = (bool)logSerializer.Deserialize(reader);
                reader.ReadEndElement();

                reader.ReadStartElement("notify");
                notify = (bool)notifySerializer.Deserialize(reader);
                reader.ReadEndElement();

                XmlSerializer dirSerializer = new XmlSerializer(typeof(Direction));
                reader.ReadStartElement("direction");
                direction = (Direction)dirSerializer.Deserialize(reader);
                reader.ReadEndElement();

                XmlSerializer statusSerializer = new XmlSerializer(typeof(PacketStatus));
                reader.ReadStartElement("status");
                ps = (PacketStatus)statusSerializer.Deserialize(reader);
                reader.ReadEndElement();

                XmlSerializer macSerializer = new XmlSerializer(typeof(string));
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement("mac");
                    mac = Convert.FromBase64String((string)macSerializer.Deserialize(reader));
                    reader.ReadEndElement();
                }
                else
                    reader.ReadStartElement("mac");

                reader.ReadEndElement();
            }
コード例 #41
0
 private void ResetControlVariables()
 {
     _packet.Clear();
     _packetLength = 0;
     _packetLengthOffset = 0;
     _status = PacketStatus.Empty;
     _pendingBytes = 4;
     _completed = true;
 }
コード例 #42
0
ファイル: fireBwallModule.cs プロジェクト: hatRiot/fireBwall
        /// <summary>
        /// Used to generate a new IPRule
        /// </summary>
        /// <returns></returns>
        private static IPRule GenIPRule(PacketStatus ps, string args, Direction dir, bool log, bool notify)
        {
            List<string> tokens = new List<string>(args.Split(' '));
            IPRule rule = new IPRule();

            try
            {
                // iterate through the tokens and try and parse them into
                // an IP address
                foreach ( string s in tokens )
                {
                    IPAddress tmp = IPAddress.Parse(s);
                    rule.ips.Add(tmp);
                }

                // set the rest of the fields
                rule.ps = ps;
                rule.direction = dir;
                rule.log = log;
                rule.notify = notify;
            }
            catch (Exception)
            {
                // probably a parse error
                throw new Exception();
            }
            return rule;
        }