Skip to content

Commit 34e8f18

Browse files
committed
[NTDLL_WINETEST] Add tests for RtlIpv6AddressToString(Ex) by Mark Jansen.
svn path=/trunk/; revision=67079
1 parent eb06c06 commit 34e8f18

File tree

1 file changed

+246
-0
lines changed
  • rostests/winetests/ntdll

1 file changed

+246
-0
lines changed

rostests/winetests/ntdll/rtl.c

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ static CHAR * (WINAPI *pRtlIpv4AddressToStringA)(const IN_ADDR *, LPSTR);
9393
static NTSTATUS (WINAPI *pRtlIpv4AddressToStringExA)(const IN_ADDR *, USHORT, LPSTR, PULONG);
9494
static NTSTATUS (WINAPI *pRtlIpv4StringToAddressA)(PCSTR, BOOLEAN, PCSTR *, IN_ADDR *);
9595
static NTSTATUS (WINAPI *pRtlIpv4StringToAddressExA)(PCSTR, BOOLEAN, IN_ADDR *, PUSHORT);
96+
static CHAR * (WINAPI *pRtlIpv6AddressToStringA)(struct in6_addr *, PSTR);
97+
static NTSTATUS (WINAPI *pRtlIpv6AddressToStringExA)(struct in6_addr *, ULONG, USHORT, PCHAR, PULONG);
9698
static NTSTATUS (WINAPI *pRtlIpv6StringToAddressA)(PCSTR, PCSTR *, struct in6_addr *);
9799
static NTSTATUS (WINAPI *pRtlIpv6StringToAddressW)(PCWSTR, PCWSTR *, struct in6_addr *);
98100
static NTSTATUS (WINAPI *pRtlIpv6StringToAddressExA)(PCSTR, struct in6_addr *, PULONG, PUSHORT);
@@ -152,6 +154,8 @@ static void InitFunctionPtrs(void)
152154
pRtlIpv4AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringExA");
153155
pRtlIpv4StringToAddressA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressA");
154156
pRtlIpv4StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressExA");
157+
pRtlIpv6AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringA");
158+
pRtlIpv6AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringExA");
155159
pRtlIpv6StringToAddressA = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressA");
156160
pRtlIpv6StringToAddressW = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressW");
157161
pRtlIpv6StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressExA");
@@ -1968,6 +1972,246 @@ static void init_ip6(IN6_ADDR* addr, const int src[8])
19681972
}
19691973
}
19701974

1975+
static void test_RtlIpv6AddressToString(void)
1976+
{
1977+
CHAR buffer[50];
1978+
LPCSTR result;
1979+
IN6_ADDR ip;
1980+
DWORD_PTR len;
1981+
struct
1982+
{
1983+
PCSTR address;
1984+
int ip[8];
1985+
} tests[] =
1986+
{
1987+
/* ipv4 addresses & ISATAP addresses */
1988+
{ "::13.1.68.3", { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
1989+
{ "::ffff:13.1.68.3", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0x344 } },
1990+
{ "::feff:d01:4403", { 0, 0, 0, 0, 0, 0xfffe, 0x10d, 0x344 } },
1991+
{ "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 } },
1992+
{ "::100:d01:4403", { 0, 0, 0, 0, 0, 1, 0x10d, 0x344 } },
1993+
{ "::1:d01:4403", { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
1994+
{ "::ffff:0:4403", { 0, 0, 0, 0, 0, 0xffff, 0, 0x344 } },
1995+
{ "::ffff:13.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0 } },
1996+
{ "::ffff:0:0", { 0, 0, 0, 0, 0, 0xffff, 0, 0 } },
1997+
{ "::ffff:0:13.1.68.3", { 0, 0, 0, 0, 0xffff, 0, 0x10d, 0x344 } },
1998+
{ "::ffff:ffff:d01:4403", { 0, 0, 0, 0, 0xffff, 0xffff, 0x10d, 0x344 } },
1999+
{ "::ffff:0:0:d01:4403", { 0, 0, 0, 0xffff, 0, 0, 0x10d, 0x344 } },
2000+
{ "::ffff:255.255.255.255", { 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff } },
2001+
{ "::ffff:129.144.52.38", { 0, 0, 0, 0, 0, 0xffff, 0x9081, 0x2634 } },
2002+
{ "::5efe:129.144.52.38", { 0, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
2003+
{ "1111:2222:3333:4444:0:5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2004+
{ "1111:2222:3333::5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
2005+
{ "1111:2222::5efe:129.144.52.38", { 0x1111, 0x2222, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
2006+
{ "1111::5efe:129.144.52.38", { 0x1111, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
2007+
{ "::200:5efe:129.144.52.38", { 0, 0, 0, 0, 2, 0xfe5e, 0x9081, 0x2634 } },
2008+
{ "::100:5efe:8190:3426", { 0, 0, 0, 0, 1, 0xfe5e, 0x9081, 0x2634 } },
2009+
/* 'normal' addresses */
2010+
{ "::1", { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2011+
{ "0:1:2:3:4:5:6:7", { 0, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700 } },
2012+
{ "1080::8:800:200c:417a", { 0x8010, 0, 0, 0, 0x800, 0x8, 0x0c20, 0x7a41 } },
2013+
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2014+
{ "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
2015+
{ "1111:2222:3333:4444:5555:6666::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0 } },
2016+
{ "1111:2222:3333:4444:5555:6666:0:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0x8888 } },
2017+
{ "1111:2222:3333:4444:5555::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0 } },
2018+
{ "1111:2222:3333:4444:5555:0:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0x7b7b, 0x7b7b } },
2019+
{ "1111:2222:3333:4444:5555:0:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0x7777, 0x8888 } },
2020+
{ "1111:2222:3333:4444:5555::8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8888 } },
2021+
{ "1111::", { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2022+
{ "1111::7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } },
2023+
{ "1111:0:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2024+
{ "1111:0:3333:4444:5555:6666:7777:8888", { 0x1111, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
2025+
{ "1111::4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2026+
{ "1111::4444:5555:6666:7777:8888", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
2027+
{ "1111::5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2028+
{ "1111::5555:6666:7777:8888", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7777, 0x8888 } },
2029+
{ "1111::6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7b7b, 0x7b7b } },
2030+
{ "1111::6666:7777:8888", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7777, 0x8888 } },
2031+
{ "1111::7777:8888", { 0x1111, 0, 0, 0, 0, 0, 0x7777, 0x8888 } },
2032+
{ "1111::8888", { 0x1111, 0, 0, 0, 0, 0, 0, 0x8888 } },
2033+
{ "1:2:3:4:5:6:102:304", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x201, 0x403 } },
2034+
{ "1:2:3:4:5:6:7:8", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700, 0x800 } },
2035+
{ "1:2:3:4:5:6::", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0 } },
2036+
{ "1:2:3:4:5:6:0:8", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0x800 } },
2037+
{ "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 } },
2038+
{ "2001:0:4136:e378:8000:63bf:3fff:fdd2", { 0x120, 0, 0x3641, 0x78e3, 0x80, 0xbf63, 0xff3f, 0xd2fd } },
2039+
{ "2001:db8::1428:57ab", { 0x120, 0xb80d, 0, 0, 0, 0, 0x2814, 0xab57 } },
2040+
{ "2001:db8:1234:ffff:ffff:ffff:ffff:ffff", { 0x120, 0xb80d, 0x3412, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } },
2041+
{ "2001:0:ce49:7601:2cad:dfff:7c94:fffe", { 0x120, 0, 0x49ce, 0x176, 0xad2c, 0xffdf, 0x947c, 0xfeff } },
2042+
{ "2001:db8:85a3::8a2e:370:7334", { 0x120, 0xb80d, 0xa385, 0, 0, 0x2e8a, 0x7003, 0x3473 } },
2043+
{ "3ffe:b00::1:0:0:a", { 0xfe3f, 0xb, 0, 0, 0x100, 0, 0, 0xa00 } },
2044+
{ "::a:b:c:d:e", { 0, 0, 0, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00 } },
2045+
{ "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } },
2046+
{ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } },
2047+
{ "1111:2222:3333:4444:5555:6666:7777:1", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x100 } },
2048+
{ "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
2049+
{ "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 } },
2050+
{ "1111::3333:4444:5555:6666:7777", { 0x1111, 0, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777 } },
2051+
{ "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 } },
2052+
{ "1111::3333", { 0x1111, 0, 0, 0, 0, 0, 0, 0x3333 } },
2053+
{ "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 } },
2054+
{ "2001::ffd3", { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2055+
};
2056+
const size_t testcount = sizeof(tests) / sizeof(tests[0]);
2057+
unsigned int i;
2058+
2059+
if (!pRtlIpv6AddressToStringA)
2060+
{
2061+
skip("RtlIpv6AddressToStringA not available\n");
2062+
return;
2063+
}
2064+
2065+
memset(buffer, '#', sizeof(buffer));
2066+
buffer[sizeof(buffer)-1] = 0;
2067+
memset(&ip, 0, sizeof(ip));
2068+
result = pRtlIpv6AddressToStringA(&ip, buffer);
2069+
2070+
len = strlen(buffer);
2071+
ok(result == (buffer + len) && !strcmp(buffer, "::"),
2072+
"got %p with '%s' (expected %p with '::')\n", result, buffer, buffer + len);
2073+
2074+
result = pRtlIpv6AddressToStringA(&ip, NULL);
2075+
ok(result == (LPCSTR)~0 || broken(result == (LPCSTR)len) /* WinXP / Win2k3 */,
2076+
"got %p, expected %p\n", result, (LPCSTR)~0);
2077+
2078+
for (i = 0; i < testcount; i++)
2079+
{
2080+
init_ip6(&ip, tests[i].ip);
2081+
memset(buffer, '#', sizeof(buffer));
2082+
buffer[sizeof(buffer)-1] = 0;
2083+
2084+
result = pRtlIpv6AddressToStringA(&ip, buffer);
2085+
len = strlen(buffer);
2086+
ok(result == (buffer + len) && !strcmp(buffer, tests[i].address),
2087+
"got %p with '%s' (expected %p with '%s')\n", result, buffer, buffer + len, tests[i].address);
2088+
2089+
ok(buffer[45] == 0 || broken(buffer[45] != 0) /* WinXP / Win2k3 */,
2090+
"expected data at buffer[45] to always be NULL\n");
2091+
ok(buffer[46] == '#', "expected data at buffer[46] not to change\n");
2092+
}
2093+
}
2094+
2095+
static void test_RtlIpv6AddressToStringEx(void)
2096+
{
2097+
CHAR buffer[70];
2098+
NTSTATUS res;
2099+
IN6_ADDR ip;
2100+
ULONG len;
2101+
struct
2102+
{
2103+
PCSTR address;
2104+
ULONG scopeid;
2105+
USHORT port;
2106+
int ip[8];
2107+
} tests[] =
2108+
{
2109+
/* ipv4 addresses & ISATAP addresses */
2110+
{ "::13.1.68.3", 0, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
2111+
{ "::13.1.68.3%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
2112+
{ "::13.1.68.3%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
2113+
{ "[::13.1.68.3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
2114+
{ "[::13.1.68.3%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
2115+
{ "[::13.1.68.3]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
2116+
2117+
{ "::1:d01:4403", 0, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
2118+
{ "::1:d01:4403%1", 1, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
2119+
{ "::1:d01:4403%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
2120+
{ "[::1:d01:4403%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
2121+
{ "[::1:d01:4403%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
2122+
{ "[::1:d01:4403]:256", 0, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
2123+
2124+
{ "1111:2222:3333:4444:0:5efe:129.144.52.38", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2125+
{ "1111:2222:3333:4444:0:5efe:129.144.52.38%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2126+
{ "1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819", 0xffffbbbb, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2127+
{ "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:65518",0xffffbbbb, 0xeeff, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2128+
{ "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2129+
{ "[1111:2222:3333:4444:0:5efe:129.144.52.38]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
2130+
2131+
{ "::1", 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2132+
{ "::1%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2133+
{ "::1%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2134+
{ "[::1%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2135+
{ "[::1%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2136+
{ "[::1]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
2137+
2138+
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2139+
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2140+
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b%4294949819", 0xffffbbbb, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2141+
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2142+
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2143+
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
2144+
2145+
{ "1111::", 0, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2146+
{ "1111::%1", 1, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2147+
{ "1111::%4294949819", 0xffffbbbb, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2148+
{ "[1111::%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2149+
{ "[1111::%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2150+
{ "[1111::]:256", 0, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
2151+
2152+
{ "2001::ffd3", 0, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2153+
{ "2001::ffd3%1", 1, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2154+
{ "2001::ffd3%4294949819", 0xffffbbbb, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2155+
{ "[2001::ffd3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2156+
{ "[2001::ffd3%4294949819]:256", 0xffffbbbb, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2157+
{ "[2001::ffd3]:256", 0, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
2158+
};
2159+
const size_t testcount = sizeof(tests) / sizeof(tests[0]);
2160+
unsigned int i;
2161+
2162+
if (!pRtlIpv6AddressToStringExA)
2163+
{
2164+
skip("RtlIpv6AddressToStringExA not available\n");
2165+
return;
2166+
}
2167+
2168+
memset(buffer, '#', sizeof(buffer));
2169+
buffer[sizeof(buffer)-1] = 0;
2170+
memset(&ip, 0, sizeof(ip));
2171+
len = sizeof(buffer);
2172+
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, &len);
2173+
2174+
ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res);
2175+
ok(len == 3 && !strcmp(buffer, "::"),
2176+
"got len %d with '%s' (expected 3 with '::')\n", len, buffer);
2177+
2178+
memset(buffer, '#', sizeof(buffer));
2179+
buffer[sizeof(buffer)-1] = 0;
2180+
2181+
len = sizeof(buffer);
2182+
res = pRtlIpv6AddressToStringExA(NULL, 0, 0, buffer, &len);
2183+
ok(res == STATUS_INVALID_PARAMETER, "[null ip] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res);
2184+
2185+
len = sizeof(buffer);
2186+
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, NULL, &len);
2187+
ok(res == STATUS_INVALID_PARAMETER, "[null buffer] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res);
2188+
2189+
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, NULL);
2190+
ok(res == STATUS_INVALID_PARAMETER, "[null length] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res);
2191+
2192+
len = 2;
2193+
memset(buffer, '#', sizeof(buffer));
2194+
buffer[sizeof(buffer)-1] = 0;
2195+
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, &len);
2196+
ok(res == STATUS_INVALID_PARAMETER, "[null length] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res);
2197+
ok(buffer[0] == '#', "got first char %c (expected '#')\n", buffer[0]);
2198+
ok(len == 3, "got len %d (expected len 3)\n", len);
2199+
2200+
for (i = 0; i < testcount; i++)
2201+
{
2202+
init_ip6(&ip, tests[i].ip);
2203+
len = sizeof(buffer);
2204+
memset(buffer, '#', sizeof(buffer));
2205+
buffer[sizeof(buffer)-1] = 0;
2206+
2207+
res = pRtlIpv6AddressToStringExA(&ip, tests[i].scopeid, tests[i].port, buffer, &len);
2208+
2209+
ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res);
2210+
ok(len == (strlen(tests[i].address) + 1) && !strcmp(buffer, tests[i].address),
2211+
"got len %d with '%s' (expected %d with '%s')\n", len, buffer, strlen(tests[i].address), tests[i].address);
2212+
}
2213+
}
2214+
19712215
static void compare_RtlIpv6StringToAddressW(PCSTR name_a, int terminator_offset_a,
19722216
const struct in6_addr *addr_a, NTSTATUS res_a)
19732217
{
@@ -3223,6 +3467,8 @@ START_TEST(rtl)
32233467
test_RtlIpv4AddressToStringEx();
32243468
test_RtlIpv4StringToAddress();
32253469
test_RtlIpv4StringToAddressEx();
3470+
test_RtlIpv6AddressToString();
3471+
test_RtlIpv6AddressToStringEx();
32263472
test_RtlIpv6StringToAddress();
32273473
test_RtlIpv6StringToAddressEx();
32283474
test_LdrAddRefDll();

0 commit comments

Comments
 (0)