public static unsafe uint Ipv6AddressToString(byte[] address, uint scopeId, StringBuilder buffer) { Debug.Assert(address != null); Debug.Assert(address.Length == IPAddressParser.IPv6AddressBytes); Debug.Assert(buffer != null); Debug.Assert(buffer.Capacity >= IPAddressParser.INET6_ADDRSTRLEN); var sockaddr = new Interop.libc.sockaddr_in6 { sin6_family = Interop.libc.AF_INET6, sin6_port = 0, sin6_scope_id = scopeId }; Debug.Assert(sizeof(Interop.libc.in6_addr) == IPAddressParser.IPv6AddressBytes); for (int i = 0; i < IPAddressParser.IPv6AddressBytes; i++) { sockaddr.sin6_addr.s6_addr[i] = address[i]; } int err = Interop.libc.getnameinfo((Interop.libc.sockaddr*)&sockaddr, (uint)sizeof(Interop.libc.sockaddr_in6), buffer, (uint)buffer.Capacity, null, 0, Interop.libc.NI_NUMERICHOST); return unchecked((uint)err); }
public static unsafe uint Ipv6AddressToString(byte[] address, uint scopeId, StringBuilder buffer) { Debug.Assert(address != null); Debug.Assert(address.Length == IPAddressParser.IPv6AddressBytes); Debug.Assert(buffer != null); Debug.Assert(buffer.Capacity >= IPAddressParser.INET6_ADDRSTRLEN); var sockaddr = new Interop.libc.sockaddr_in6 { sin6_family = Interop.libc.AF_INET6, sin6_port = 0, sin6_scope_id = scopeId }; Debug.Assert(sizeof(Interop.libc.in6_addr) == IPAddressParser.IPv6AddressBytes); for (int i = 0; i < IPAddressParser.IPv6AddressBytes; i++) { sockaddr.sin6_addr.s6_addr[i] = address[i]; } int err = Interop.libc.getnameinfo((Interop.libc.sockaddr *) & sockaddr, (uint)sizeof(Interop.libc.sockaddr_in6), buffer, (uint)buffer.Capacity, null, 0, Interop.libc.NI_NUMERICHOST); return(unchecked ((uint)err)); }