Exemplo n.º 1
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static WebServiceProxy()
        {
            // Set default proxy configuration values.
            _internetProtocol   = InternetProtocol.Https;
            _webServiceProtocol = WebServiceProtocol.Binary;
            Configuration       = new WebServiceConfiguration();

            // Create web service proxies.
            AnalysisService     = new AnalysisServiceProxy();
            NorsService         = new NorsServiceProxy();
            GeoReferenceService = new GeoReferenceServiceProxy();
            KulService          = new KulServiceProxy();
            MvmService          = new MvmServiceProxy();
            NorwayTaxonService  = new NorwayTaxonServiceProxy();
            PESINameService     = new PESINameServiceProxy();
            PictureService      = new PictureServiceProxy();
            ReferenceService    = new ReferenceServiceProxy();
            SersService         = new SersServiceProxy();
            SpeciesObservationHarvestService     = new SpeciesObservationHarvestServiceProxy();
            SwedishSpeciesObservationService     = new SwedishSpeciesObservationServiceProxy();
            SwedishSpeciesObservationSOAPService = new SwedishSpeciesObservationSOAPServiceProxy();
            TaxonAttributeService  = new TaxonAttributeServiceProxy();
            TaxonService           = new TaxonServiceProxy();
            DyntaxaInternalService = new DyntaxaInternalServiceProxy();
            UserService            = new UserServiceProxy();
            WramService            = new WramServiceProxy();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="port"></param>
        /// <param name="protocol"></param>
        /// <param name="enable"></param>
        /// <param name="name"></param>
        public static void AddSharedAccessFirewallPort(int port, InternetProtocol protocol, bool enable, string name)
        {
            string protocolStr = "";
            string enableStr = "";
            if (protocol == InternetProtocol.Tcp) { protocolStr = "TCP"; }
            else if (protocol == InternetProtocol.Udp) { protocolStr = "UDP"; }

            if (enable) { enableStr = "Enabled"; } else { enableStr = "Disabled"; }

            string portStr = port.ToString();

            RegistryKey k1 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile", true);
            if (!SmString.FindFormStringArray(k1.GetSubKeyNames(), "GloballyOpenPorts"))
                k1.CreateSubKey("GloballyOpenPorts");
            k1.Close();

            RegistryKey k2 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts", true);
            if (!SmString.FindFormStringArray(k2.GetSubKeyNames(), "List"))
                k2.CreateSubKey("List");
            k2.Close();

            RegistryKey k3 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List", true);
            k3.SetValue(portStr + ":" + protocolStr, portStr + ":" + protocolStr + ":*:" + enableStr + ":" + name, RegistryValueKind.String);
            k3.Close();
        }
Exemplo n.º 3
0
        //
        //   public Packet(byte[] raw):(byte[] raw, DateTime time

        //   {
        //    Packet(raw, DateTime.Now);
        //   }
        public Packet(byte[] raw, DateTime time)
        {
            if (raw == null)
            {
                throw new ArgumentNullException();
            }
            if (raw.Length < 20)
            {
                throw new ArgumentException();
            }

            this.m_Raw          = raw;
            this.m_Time         = time;
            this.m_HeaderLength = (raw[0] & 0xF) * 4;
            if ((raw[0] & 0xF) < 5)
            {
                throw new ArgumentException();
            }
            this.m_Precedence  = (Precedence)((raw[1] & 0xE0) >> 5);
            this.m_Delay       = (Delay)((raw[1] & 0x10) >> 4);
            this.m_Throughput  = (Throughput)((raw[1] & 0x8) >> 3);
            this.m_Reliability = (Reliability)((raw[1] & 0x4) >> 2);
            this.m_TotalLength = raw[2] * 256 + raw[3];
            if (!(this.m_TotalLength == raw.Length))
            {
                throw new ArgumentException();
            }                                                                           // invalid size of packet;
            this.m_Identification = raw[4] * 256 + raw[5];
            this.m_TimeToLive     = raw[8];

            m_Protocol = (InternetProtocol)raw[9];

            m_Checksum    = new byte[2];
            m_Checksum[0] = raw[11];
            m_Checksum[1] = raw[10];

            try
            {
                m_SourceAddress      = GetIPAddress(raw, 12);
                m_DestinationAddress = GetIPAddress(raw, 16);
            }
            catch (Exception e)
            {
                throw;
            }

            if (m_Protocol == InternetProtocol.Tcp || m_Protocol == InternetProtocol.Udp)
            {
                m_SourcePort      = raw[m_HeaderLength] * 256 + raw[m_HeaderLength + 1];
                m_DestinationPort = raw[m_HeaderLength + 2] * 256 + raw[m_HeaderLength + 3];
            }
            else
            {
                m_SourcePort      = -1;
                m_DestinationPort = -1;
            }
        }
Exemplo n.º 4
0
        public static InternetLayerPacket ParsePacket(InternetProtocol type, byte[] bytes)
        {
            if (!InternetLayerTypes.ContainsKey(type))
                return null;

            Type internetLayerType = InternetLayerTypes[type];

            return (InternetLayerPacket) Activator.CreateInstance(internetLayerType, new object[]{bytes});
        }
Exemplo n.º 5
0
 internal InternetDataReceivedEventArgs(IPAddress sourceAddress, ushort destinationPort, ushort sourcePort,
                                        InternetProtocol protocol, byte[] data)
 {
     SourceAddress   = sourceAddress;
     DestinationPort = destinationPort;
     SourcePort      = sourcePort;
     Protocol        = protocol;
     Data            = data;
 }
Exemplo n.º 6
0
        public EthernetPacket(byte[] bytes)
        {
            _destination = new PhysicalAddress(ReadBytes(0, 6, bytes));
            _source = new PhysicalAddress(ReadBytes(6, 6, bytes));

            ushort type = (ushort) IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, 12));

            if (!Enum.IsDefined(typeof(InternetProtocol), type))
                _internetLayerType = InternetProtocol.Unknown;
            else
                _internetLayerType = (InternetProtocol)type;

            PayloadPacket = InternetLayerPacket.ParsePacket(_internetLayerType, bytes);
        }
Exemplo n.º 7
0
        public ArpPacket(byte[] bytes)
            : base(bytes)
        {
            _hardwareType = (HardwareType)IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, 14));
            _internetProtocol = (InternetProtocol)IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, 16));
            _hardwareSize = bytes[18];
            _protocolSize = bytes[19];
            _opcode = (ArpOpCode)IPAddress.HostToNetworkOrder(BitConverter.ToInt16(bytes, 20));

            _senderMac = new PhysicalAddress(ReadBytes(22, _hardwareSize, bytes));
            _senderIp = new IPAddress(ReadBytes(22 + _hardwareSize, _protocolSize, bytes));

            _targetMac = new PhysicalAddress(ReadBytes(22 + _hardwareSize + _protocolSize, _hardwareSize, bytes));
            _targetIp = new IPAddress(ReadBytes(22 + _hardwareSize + _protocolSize + _hardwareSize, _protocolSize, bytes));
        }
Exemplo n.º 8
0
        public TxIPv4Frame(uint address, ushort port, ushort sourcePort, InternetProtocol protocol, TxIPv4Options options, byte[] data)
        {
            if (data.Length > MaxPayloadLength)
            {
                throw new ArgumentException($"Payload must be less than {MaxPayloadLength} bytes in length.", nameof(data));
            }

            Address    = address;
            Port       = port;
            SourcePort = sourcePort;
            Protocol   = protocol;
            Options    = options;

            Data = data;
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="port"></param>
        /// <param name="protocol"></param>
        /// <param name="enable"></param>
        /// <param name="name"></param>
        public static void AddSharedAccessFirewallPort(int port, InternetProtocol protocol, bool enable, string name)
        {
            string protocolStr = "";
            string enableStr   = "";

            if (protocol == InternetProtocol.Tcp)
            {
                protocolStr = "TCP";
            }
            else if (protocol == InternetProtocol.Udp)
            {
                protocolStr = "UDP";
            }

            if (enable)
            {
                enableStr = "Enabled";
            }
            else
            {
                enableStr = "Disabled";
            }

            string portStr = port.ToString();


            RegistryKey k1 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile", true);

            if (!SmString.FindFormStringArray(k1.GetSubKeyNames(), "GloballyOpenPorts"))
            {
                k1.CreateSubKey("GloballyOpenPorts");
            }
            k1.Close();

            RegistryKey k2 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts", true);

            if (!SmString.FindFormStringArray(k2.GetSubKeyNames(), "List"))
            {
                k2.CreateSubKey("List");
            }
            k2.Close();

            RegistryKey k3 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List", true);

            k3.SetValue(portStr + ":" + protocolStr, portStr + ":" + protocolStr + ":*:" + enableStr + ":" + name, RegistryValueKind.String);
            k3.Close();
        }
Exemplo n.º 10
0
 public MulticastServer(Service service, int port, InternetProtocol protocol) : base(service, port, protocol)
 {
 }
Exemplo n.º 11
0
 public EchoServer(Service service, int port, InternetProtocol protocol) : base(service, port, protocol)
 {
 }
Exemplo n.º 12
0
 public async Task TransmitDataAsync(IPAddress address, ushort port, ushort sourcePort, InternetProtocol protocol,
                                     TxIPv4Options options, byte[] data)
 {
     var addressData  = address.GetAddressBytes();
     var addressValue = BitConverter.ToUInt32(addressData, 0);
     var txIPv4Frame  = new TxIPv4Frame(addressValue, port, sourcePort, protocol, options, data);
     await Controller.ExecuteAsync(txIPv4Frame);
 }
Exemplo n.º 13
0
 public async Task TransmitDataAsync(IPAddress address, ushort port, InternetProtocol protocol, byte[] data)
 {
     await TransmitDataAsync(address, port, 0, protocol, TxIPv4Options.None, data);
 }
Exemplo n.º 14
0
 /// <summary>
 ///     Sets the Internet protocol for the device.
 /// </summary>
 /// <param name="protocol"></param>
 /// <returns></returns>
 public async Task SetInternetProtocolAsync(InternetProtocol protocol)
 {
     await ExecuteAtCommandAsync(new InternetProtocolCommand(protocol));
 }
Exemplo n.º 15
0
 public ChatServer(Service service, SslContext context, InternetProtocol protocol, int port) : base(service, context, protocol, port)
 {
 }
Exemplo n.º 16
0
        //
        //   public Packet(byte[] raw):(byte[] raw, DateTime time
        //   {
        //    Packet(raw, DateTime.Now);
        //   }
        public Packet(byte[] raw, DateTime time)
        {
            if (raw == null)
            {
                throw new ArgumentNullException();
            }
            if (raw.Length < 20)
            {
                throw new ArgumentException();
            }

            this.m_Raw = raw;
            this.m_Time = time;
            this.m_HeaderLength = (raw[0] & 0xF) * 4;
            if ((raw[0] & 0xF) < 5) { throw new ArgumentException(); }
            this.m_Precedence = (Precedence)((raw[1] & 0xE0) >> 5);
            this.m_Delay = (Delay)((raw[1] & 0x10) >> 4);
            this.m_Throughput = (Throughput)((raw[1] & 0x8) >> 3);
            this.m_Reliability = (Reliability)((raw[1] & 0x4) >> 2);
            this.m_TotalLength = raw[2] * 256 + raw[3];
            if (!(this.m_TotalLength == raw.Length)) { throw new ArgumentException(); } // invalid size of packet;
            this.m_Identification = raw[4] * 256 + raw[5];
            this.m_TimeToLive = raw[8];

            m_Protocol = (InternetProtocol)raw[9];

            m_Checksum = new byte[2];
            m_Checksum[0] = raw[11];
            m_Checksum[1] = raw[10];

            try
            {
                m_SourceAddress = GetIPAddress(raw, 12);
                m_DestinationAddress = GetIPAddress(raw, 16);
            }
            catch (Exception e)
            {
                throw;
            }

            if (m_Protocol == InternetProtocol.Tcp || m_Protocol == InternetProtocol.Udp)
            {
                m_SourcePort = raw[m_HeaderLength] * 256 + raw[m_HeaderLength + 1];
                m_DestinationPort = raw[m_HeaderLength + 2] * 256 + raw[m_HeaderLength + 3];
            }
            else
            {

                m_SourcePort = -1;
                m_DestinationPort = -1;
            }
        }
Exemplo n.º 17
0
 public ChatServer(Service service, InternetProtocol protocol, int port) : base(service, protocol, port)
 {
 }
Exemplo n.º 18
0
 public InternetProtocolCommand(InternetProtocol protocol)
 {
     Parameter = protocol;
 }
Exemplo n.º 19
0
 public MulticastServer(Service service, SslContext context, int port, InternetProtocol protocol) : base(service, context, port, protocol)
 {
 }
Exemplo n.º 20
0
 public InternetLayerAttribute(string name, InternetProtocol type)
 {
     _name = name;
     _type = type;
 }