d3d10/effect: Use case-insensitive comparison in GetMemberTypeBySemantic().
[wine.git] / dlls / dhcpcsvc / dhcpcsvc.c
blob1fc5077ff88b976ed6aa944ad855fdae8dabf592
1 /*
2 * Copyright 2011 Stefan Leichter
3 * Copyright 2019 Hans Leidekker for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "dhcpcsdk.h"
24 #include "winioctl.h"
25 #include "winternl.h"
26 #include "ws2def.h"
27 #include "ws2ipdef.h"
28 #include "iphlpapi.h"
29 #include "netioapi.h"
30 #define WINE_MOUNTMGR_EXTENSIONS
31 #include "ddk/mountmgr.h"
33 #include "wine/debug.h"
34 #include "wine/heap.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dhcpcsvc);
38 void WINAPI DhcpCApiCleanup(void)
40 FIXME(": stub\n");
43 DWORD WINAPI DhcpCApiInitialize(LPDWORD version)
45 *version = 2; /* 98, XP, and 8 */
46 FIXME(": stub\n");
47 return ERROR_SUCCESS;
50 static DWORD get_adapter_luid( const WCHAR *adapter, NET_LUID *luid )
52 UNICODE_STRING ustr;
53 NTSTATUS status;
54 GUID guid;
56 if (adapter[0] == '{')
58 RtlInitUnicodeString( &ustr, adapter );
59 status = RtlGUIDFromString( &ustr, &guid );
60 if (!status) return ConvertInterfaceGuidToLuid( &guid, luid );
62 return ConvertInterfaceNameToLuidW( adapter, luid );
65 DWORD WINAPI DhcpRequestParams( DWORD flags, void *reserved, WCHAR *adapter, DHCPCAPI_CLASSID *class_id,
66 DHCPCAPI_PARAMS_ARRAY send_params, DHCPCAPI_PARAMS_ARRAY recv_params, BYTE *buf,
67 DWORD *buflen, WCHAR *request_id )
69 struct mountmgr_dhcp_request_params *query;
70 DWORD i, size, err;
71 BYTE *src, *dst;
72 NET_LUID luid;
73 HANDLE mgr;
75 TRACE( "(%08x, %p, %s, %p, %u, %u, %p, %p, %s)\n", flags, reserved, debugstr_w(adapter), class_id,
76 send_params.nParams, recv_params.nParams, buf, buflen, debugstr_w(request_id) );
78 if (!adapter || !buflen) return ERROR_INVALID_PARAMETER;
79 if (flags != DHCPCAPI_REQUEST_SYNCHRONOUS) FIXME( "unsupported flags %08x\n", flags );
80 if ((err = get_adapter_luid( adapter, &luid ))) return err;
82 for (i = 0; i < send_params.nParams; i++)
83 FIXME( "send option %u not supported\n", send_params.Params->OptionId );
85 mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
86 OPEN_EXISTING, 0, 0 );
87 if (mgr == INVALID_HANDLE_VALUE) return GetLastError();
89 size = FIELD_OFFSET(struct mountmgr_dhcp_request_params, params[recv_params.nParams]) + *buflen;
90 if (!(query = heap_alloc_zero( size )))
92 err = ERROR_OUTOFMEMORY;
93 goto done;
95 for (i = 0; i < recv_params.nParams; i++) query->params[i].id = recv_params.Params[i].OptionId;
96 query->count = recv_params.nParams;
97 query->adapter = luid;
99 if (!DeviceIoControl( mgr, IOCTL_MOUNTMGR_QUERY_DHCP_REQUEST_PARAMS, query, size, query, size, NULL, NULL ))
101 err = GetLastError();
102 if (err == ERROR_MORE_DATA) *buflen = query->size - (size - *buflen);
103 goto done;
106 dst = buf;
107 for (i = 0; i < query->count; i++)
109 if (buf)
111 recv_params.Params[i].OptionId = query->params[i].id;
112 recv_params.Params[i].IsVendor = FALSE; /* FIXME */
113 if (query->params[i].size)
115 src = (BYTE *)query + query->params[i].offset;
116 memcpy( dst, src, query->params[i].size );
118 recv_params.Params[i].Data = dst;
119 recv_params.Params[i].nBytesData = query->params[i].size;
121 else
123 recv_params.Params[i].Data = NULL;
124 recv_params.Params[i].nBytesData = 0;
127 dst += query->params[i].size;
130 *buflen = dst - buf;
131 err = ERROR_SUCCESS;
133 done:
134 heap_free( query );
135 CloseHandle( mgr );
136 return err;