VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/win/NetAdpInstall.cpp@ 29616

Last change on this file since 29616 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: NetAdpInstall.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * NetAdpInstall - VBoxNetAdp installer command line tool
4 */
5
6/*
7 * Copyright (C) 2009 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include <vbox/WinNetConfig.h>
19#include <stdio.h>
20
21#define VBOX_NETADP_INF L".\\VBoxNetAdp.inf"
22
23static VOID winNetCfgLogger (LPCWSTR szString)
24{
25 wprintf(L"%s", szString);
26}
27
28static int InstallNetAdp()
29{
30 int r = 1;
31 VBoxNetCfgWinSetLogging(winNetCfgLogger);
32
33 HRESULT hr = CoInitialize(NULL);
34 if(hr == S_OK)
35 {
36#ifndef DEBUG_misha
37 printf("not implemented yet, please use device manager for Host-Only net interface installation.. sorry :( \n");
38#else
39 /* this installs the Net Adp from the pre-installed driver package,
40 * it does NOT install the new driver package, so the installation might use old drivers
41 * or fail in case no NetAdp package is currently installed
42 * the code is here for debugging NetAdp installation only */
43 GUID guid;
44 BSTR name, errMsg;
45 printf("adding host-only interface..\n");
46 DWORD WinEr;
47 WCHAR MpInf[MAX_PATH];
48 GetFullPathNameW(VBOX_NETADP_INF, sizeof(MpInf)/sizeof(MpInf[0]), MpInf, NULL);
49 WinEr = GetLastError();
50 if(WinEr == ERROR_SUCCESS)
51 {
52 hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface (MpInf, true, &guid, &name, &errMsg);
53 if(hr == S_OK)
54 {
55 ULONG ip, mask;
56 hr = VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(&ip, &mask);
57 if(hr == S_OK)
58 {
59 /* ip returned by VBoxNetCfgWinGenHostOnlyNetworkNetworkIp is a network ip,
60 * i.e. 192.168.xxx.0, assign 192.168.xxx.1 for the hostonly adapter */
61 ip = ip | (1 << 24);
62 hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask);
63 if(hr != S_OK)
64 {
65 printf("VBoxNetCfgWinEnableStaticIpConfig failed: hr = 0x%x\n", hr);
66 }
67 else
68 {
69 r = 0;
70 }
71 }
72 else
73 {
74 printf("VBoxNetCfgWinGenHostOnlyNetworkNetworkIp failed: hr = 0x%x\n", hr);
75 }
76 }
77 else
78 {
79 printf("VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr = 0x%x\n", hr);
80 }
81 }
82 else
83 {
84 printf("GetFullPathNameW failed: winEr = %d\n", WinEr);
85 }
86#endif
87
88 CoUninitialize();
89 }
90 else
91 {
92 wprintf(L"Error initializing COM (0x%x)\n", hr);
93 }
94
95 VBoxNetCfgWinSetLogging(NULL);
96
97 return r;
98}
99
100int __cdecl main(int argc, char **argv)
101{
102 return InstallNetAdp();
103}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette