Ejemplo n.º 1
0
 /// <summary>
 ///     Process the "ports" section of the XML document
 /// </summary>
 /// <param name="portsSection">Object representing the ports section</param>
 /// <returns>A collection of Port objects containing information about each individual port</returns>
 private static IEnumerable <Port> PortsSection(ports portsSection)
 {
     return(portsSection != null && portsSection.port != null
         ? portsSection.port.Select(
                x => new Port
     {
         PortNumber = int.Parse(x.portid),
         Protocol = x.protocol != portProtocol.sctp
                     ? (ProtocolType)
                    Enum.Parse(typeof(ProtocolType),
                               x.protocol == portProtocol.ip
                             ? x.protocol.ToString().ToUpperInvariant()
                             : x.protocol.ToString().Capitalize())
                     : ProtocolType.Unknown,
         Filtered = x.state.state1.Contains("filtered"),
         Closed = x.state.state1.Contains("closed"),
         Service = x.service != null
                     ? new Service
         {
             Name = x.service.name,
             Product = x.service.product,
             Os = x.service.ostype,
             Version = x.service.version
         }
                     : default(Service)
     }
                )
         : Enumerable.Empty <Port>());
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Process the "extraports" section of the XML document (contains large numbers of ports in the same state)
 /// </summary>
 /// <param name="portsSection">Object representing the ports section</param>
 /// <returns>A collection of ExtraPorts objects if the extraports section exists, empty otherwise</returns>
 private static IEnumerable <ExtraPorts> ExtraPortsSection(ports portsSection)
 {
     return(portsSection != null && portsSection.extraports != null
         ? portsSection.extraports.Select(
                x => new ExtraPorts
     {
         Count = int.Parse(x.count),
         State = x.state
     })
         : Enumerable.Empty <ExtraPorts>());
 }
Ejemplo n.º 3
0
        public Task <ports> CreateNewPort(ports item)
        {
            using (var db = new OcphDbContext())
            {
                item.Id = db.Ports.InsertAndGetLastID(item);
                if (item.Id <= 0)
                {
                    throw new SystemException("Data Tidak Tersimpan");
                }

                return(Task.FromResult(item));
            }
        }
Ejemplo n.º 4
0
        private async void SaveAction(object obj)
        {
            try
            {
                var   item   = (ports)this;
                ports result = await context.CreateNewPort(item);

                this.SaveSuccess = true;
                this.SaveResult  = result;
                WindowClose();
            }
            catch (Exception ex)
            {
                Helpers.ShowErrorMessage(ex.Message);
            }
        }
Ejemplo n.º 5
0
 public int calc_address(int reg, ports port, bool RD_WR)
 {
     int value = 1;
     if (RD_WR) //read
     {
         value = ((reg << 6 & 0x000007c0) |
             ((int)port << 0xB & 0x0000F800) |
             (1));
     }
     else //Write
     {
         value = ((reg << 6 & 0x000007c0) |
            ((int)port << 0xB & 0x0000F800) |
            (3));
     }
     return value;
 }
Ejemplo n.º 6
0
 /// <summary>
 ///     Process the "ports" section of the XML document
 /// </summary>
 /// <param name="portsSection">Object representing the ports section</param>
 /// <returns>A collection of Port objects containing information about each individual port</returns>
 private static IEnumerable<Port> PortsSection(ports portsSection)
 {
     return portsSection != null && portsSection.port != null
                ? portsSection.port.Select(
                    x => new Port
                        {
                            PortNumber = int.Parse(x.portid),
                            Protocol = x.protocol != portProtocol.sctp
                                           ? (ProtocolType)
                                             Enum.Parse(typeof (ProtocolType),
                                                        x.protocol == portProtocol.ip
                                                            ? x.protocol.ToString().ToUpperInvariant()
                                                            : x.protocol.ToString().Capitalize())
                                           : ProtocolType.Unknown,
                            Filtered = x.state.state1 == "filtered",
                            Service = x.service != null
                                          ? new Service
                                              {
                                                  Name = x.service.name,
                                                  Product = x.service.product,
                                                  Os = x.service.ostype,
                                                  Version = x.service.version
                                              }
                                          : default(Service)
                        }
                      )
                : Enumerable.Empty<Port>();
 }
Ejemplo n.º 7
0
 /// <summary>
 ///     Process the "extraports" section of the XML document (contains large numbers of ports in the same state)
 /// </summary>
 /// <param name="portsSection">Object representing the ports section</param>
 /// <returns>A collection of ExtraPorts objects if the extraports section exists, empty otherwise</returns>
 private static IEnumerable<ExtraPorts> ExtraPortsSection(ports portsSection)
 {
     return portsSection != null && portsSection.extraports != null
                ? portsSection.extraports.Select(
                    x => new ExtraPorts
                        {
                            Count = int.Parse(x.count),
                            State = x.state
                        })
                : Enumerable.Empty<ExtraPorts>();
 }