directmanipulation: Return S_OK form viewport_SetViewportOptions stub.
[wine/zf.git] / dlls / dhcpcsvc / tests / dhcpcsvc.c
blob547fb5153297eb1b4a983c58663bc4367888b8fb
1 /*
2 * Copyright 2019 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include "winsock2.h"
21 #include "windef.h"
22 #include "winbase.h"
23 #include "iphlpapi.h"
24 #include "dhcpcsdk.h"
25 #include "wine/test.h"
27 static IP_ADAPTER_ADDRESSES *get_adapters(void)
29 ULONG err, size = 1024;
30 IP_ADAPTER_ADDRESSES *ret = HeapAlloc( GetProcessHeap(), 0, size );
31 for (;;)
33 err = GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST |
34 GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME,
35 NULL, ret, &size );
36 if (err != ERROR_BUFFER_OVERFLOW) break;
37 ret = HeapReAlloc( GetProcessHeap(), 0, ret, size );
39 if (err == ERROR_SUCCESS) return ret;
40 HeapFree( GetProcessHeap(), 0, ret );
41 return NULL;
44 static void test_DhcpRequestParams(void)
46 static WCHAR nosuchW[] = L"nosuchadapter";
47 DHCPCAPI_PARAMS params[6];
48 DHCPCAPI_PARAMS_ARRAY send_params, recv_params;
49 IP_ADAPTER_ADDRESSES *adapters, *ptr;
50 BYTE *buf;
51 WCHAR name[MAX_ADAPTER_NAME_LENGTH + 1];
52 DWORD err, size, i;
54 if (!(adapters = get_adapters())) return;
56 for (ptr = adapters; ptr; ptr = ptr->Next)
58 MultiByteToWideChar( CP_ACP, 0, ptr->AdapterName, -1, name, ARRAY_SIZE(name) );
59 trace( "adapter '%s' type %u dhcpv4 enabled %d\n", wine_dbgstr_w(ptr->Description), ptr->IfType, ptr->Dhcpv4Enabled );
61 if (ptr->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
63 memset( &send_params, 0, sizeof(send_params) );
64 memset( &recv_params, 0, sizeof(recv_params) );
65 err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, NULL, NULL, send_params, recv_params, NULL, NULL, NULL );
66 ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
68 err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, nosuchW, NULL, send_params, recv_params, NULL, NULL, NULL );
69 ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
71 err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params, NULL, NULL, NULL );
72 ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
74 size = 0;
75 err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params, NULL, &size, NULL );
76 ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
78 memset( params, 0, sizeof(params) );
79 params[0].OptionId = OPTION_SUBNET_MASK;
80 params[1].OptionId = OPTION_ROUTER_ADDRESS;
81 params[2].OptionId = OPTION_HOST_NAME;
82 params[3].OptionId = OPTION_DOMAIN_NAME;
83 params[4].OptionId = OPTION_BROADCAST_ADDRESS;
84 params[5].OptionId = OPTION_MSFT_IE_PROXY;
85 recv_params.nParams = 6;
86 recv_params.Params = params;
88 size = 0;
89 buf = HeapAlloc( GetProcessHeap(), 0, size );
90 err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params,
91 buf, &size, NULL );
92 while (err == ERROR_MORE_DATA)
94 buf = HeapReAlloc( GetProcessHeap(), 0, buf, size );
95 err = DhcpRequestParams( DHCPCAPI_REQUEST_SYNCHRONOUS, NULL, name, NULL, send_params, recv_params,
96 buf, &size, NULL );
98 if (err == ERROR_SUCCESS)
100 for (i = 0; i < ARRAY_SIZE(params); i++)
102 switch( params[i].OptionId )
104 case OPTION_SUBNET_MASK:
105 case OPTION_ROUTER_ADDRESS:
106 case OPTION_BROADCAST_ADDRESS:
107 if (params[i].Data)
109 ok( params[i].nBytesData == sizeof(DWORD), "got %u\n", params[i].nBytesData );
110 trace( "%u: Data %p (%08x) nBytesData %u OptionId %u Flags %08x IsVendor %d\n",
111 i, params[i].Data, *(DWORD *)params[i].Data, params[i].nBytesData, params[i].OptionId,
112 params[i].Flags, params[i].IsVendor );
114 break;
115 case OPTION_HOST_NAME:
116 case OPTION_DOMAIN_NAME:
117 case OPTION_MSFT_IE_PROXY:
118 if (params[i].Data)
120 char *str = HeapAlloc( GetProcessHeap(), 0, params[i].nBytesData + 1 );
121 memcpy( str, params[i].Data, params[i].nBytesData );
122 str[params[i].nBytesData] = 0;
123 trace( "%u: Data %p (%s) nBytesData %u OptionId %u Flags %08x IsVendor %d\n",
124 i, params[i].Data, str, params[i].nBytesData, params[i].OptionId,
125 params[i].Flags, params[i].IsVendor );
126 HeapFree( GetProcessHeap(), 0, str );
128 break;
129 default:
130 ok( 0, "unexpected option %u\n", params[i].OptionId );
131 break;
135 HeapFree( GetProcessHeap(), 0, buf );
137 HeapFree( GetProcessHeap(), 0, adapters );
140 START_TEST(dhcpcsvc)
142 test_DhcpRequestParams();