Beispiel #1
0
 public AAAA(String           Name,
             DNSQueryClasses  Class,
             TimeSpan         TimeToLive,
             IPv6Address      IPv6Address)
     : base(Name, TypeId, Class, TimeToLive, IPv6Address.ToString())
 {
     this._IPv6Address  = IPv6Address;
 }
Beispiel #2
0
 /// <summary>
 /// Simple constructor for the IPv6 header that initializes the fields to zero.
 /// </summary>
 public Ipv6Header()
     : base()
 {
     ipVersion = 6;
     ipTrafficClass = 0;
     ipFlow = 0;
     ipPayloadLength = 0;
     ipNextHeader = 0;
     ipHopLimit = 32;
     ipSourceAddress = IPv6Address.Any;
     ipDestinationAddress = IPv6Address.Any;
 }
Beispiel #3
0
        // host        = IP-literal / IPv4address / reg-name
        private static bool ParseHost(ParserState state)
        {
            string part = state.remaining;

            if (state.elements.scheme == Uri.UriSchemeFile && part.Length >= 2 &&
                (part [0] == '\\' || part [0] == '/') && part [1] == part [0])
            {
                part            = part.TrimStart(part [0]);
                state.remaining = part;
            }

            if (!ParseWindowsFilePath(state))
            {
                return(false);
            }

            StringBuilder sb = new StringBuilder();

            var tmpHost = "";

            var possibleIpv6 = false;

            int index;

            for (index = 0; index < part.Length; index++)
            {
                char ch = part [index];

                if (ch == '/' || ch == '#' || ch == '?')
                {
                    break;
                }

                // Possible IPv6
                if (string.IsNullOrEmpty(tmpHost) && ch == ':')
                {
                    tmpHost      = sb.ToString();
                    possibleIpv6 = true;
                }

                sb.Append(ch);

                if (possibleIpv6 && ch == ']')
                {
                    break;
                }
            }

            if (possibleIpv6)
            {
                IPv6Address ipv6addr;
                if (IPv6Address.TryParse(sb.ToString(), out ipv6addr))
                {
                    var ipStr = ipv6addr.ToString(false);
                    //remove scope
                    ipStr = ipStr.Split('%') [0];

                    state.elements.host    = "[" + ipStr + "]";
                    state.elements.scopeId = ipv6addr.ScopeId;

                    state.remaining = part.Substring(sb.Length);
                    return(state.remaining.Length > 0);
                }
                state.elements.host = tmpHost;
            }
            else
            {
                state.elements.host = sb.ToString();
            }

            state.elements.host = state.elements.host.ToLowerInvariant();

            state.remaining = part.Substring(state.elements.host.Length);

            if (state.elements.scheme == Uri.UriSchemeFile &&
                state.elements.host != "")
            {
                // under Windows all file://host URI are considered UNC, which is not the case other MacOS (e.g. Silverlight)
#if BOOTSTRAP_BASIC
                state.elements.isUnc = (Path.DirectorySeparatorChar == '\\');
#else
                state.elements.isUnc = Environment.IsRunningOnWindows;
#endif
            }

            return(state.remaining.Length > 0);
        }
Beispiel #4
0
        // host        = IP-literal / IPv4address / reg-name
        private static bool ParseHost(ParserState state)
        {
            string part = state.remaining;

            if (state.elements.scheme == Uri.UriSchemeFile && part.Length >= 2 &&
                (part [0] == '\\' || part [0] == '/') && part [1] == part [0])
            {
                part            = part.TrimStart(part [0]);
                state.remaining = part;
            }

            if (!ParseWindowsFilePath(state))
            {
                return(false);
            }

            StringBuilder sb = new StringBuilder();

            var tmpHost = "";

            var possibleIpv6 = false;

            int index;

            for (index = 0; index < part.Length; index++)
            {
                char ch = part [index];

                if (ch == '/' || ch == '#' || ch == '?')
                {
                    break;
                }

                // Possible IPv6
                if (string.IsNullOrEmpty(tmpHost) && ch == ':')
                {
                    tmpHost      = sb.ToString();
                    possibleIpv6 = true;
                }

                sb.Append(ch);

                if (possibleIpv6 && ch == ']')
                {
                    break;
                }
            }

            if (possibleIpv6)
            {
                IPv6Address ipv6addr;
                if (IPv6Address.TryParse(sb.ToString(), out ipv6addr))
                {
#if NET_4_5
                    var ipStr = ipv6addr.ToString(false);
#else
                    var ipStr = ipv6addr.ToString(true);
#endif
                    //remove scope
                    ipStr = ipStr.Split('%') [0];

                    state.elements.host    = "[" + ipStr + "]";
                    state.elements.scopeId = ipv6addr.ScopeId;

                    state.remaining = part.Substring(sb.Length);
                    return(state.remaining.Length > 0);
                }
                state.elements.host = tmpHost;
            }
            else
            {
                state.elements.host = sb.ToString();
            }

            state.elements.host = state.elements.host.ToLowerInvariant();

            state.remaining = part.Substring(state.elements.host.Length);

            return(state.remaining.Length > 0);
        }
Beispiel #5
0
 public AAAA(String  Name,
             Stream  Stream)
     : base(Name, TypeId, Stream)
 {
     this._IPv6Address  = new IPv6Address(Stream);
 }
Beispiel #6
0
 public AAAA(Stream  Stream)
     : base(Stream, TypeId)
 {
     this._IPv6Address  = new IPv6Address(Stream);
 }