VirtualBox

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

Last change on this file since 21559 was 21343, checked in by vboxsync, 16 years ago

export vboxnetflt for Windows to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: NetAdpInstall.cpp 21343 2009-07-07 15:30:08Z vboxsync $ */
2/** @file
3 * NetAdpInstall - VBoxNetAdp installer command line tool
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include <vbox/WinNetConfig.h>
23#include <stdio.h>
24
25static VOID winNetCfgLogger (LPCWSTR szString)
26{
27 wprintf(L"%s", szString);
28}
29
30static int InstallNetAdp()
31{
32 int r = 0;
33 VBoxNetCfgWinSetLogging(winNetCfgLogger);
34
35 HRESULT hr = CoInitialize(NULL);
36 if(hr == S_OK)
37 {
38#ifndef DEBUG_misha
39 printf("not implemented yet, please use device manager for Host-Only net interface installation.. sorry :( \n");
40#else
41 /* this installs the Net Adp from the pre-installed driver package,
42 * it does NOT install the new driver package, so the installation might use old drivers
43 * or fail in case no NetAdp package is currently installed
44 * the code is here for debugging NetAdp installation only */
45 GUID guid;
46 BSTR name, errMsg;
47 printf("adding host-only interface..\n");
48 hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface (&guid, &name, &errMsg);
49 if(hr == S_OK)
50 {
51 ULONG ip, mask;
52 hr = VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(&ip, &mask);
53 if(hr == S_OK)
54 {
55 /* ip returned by VBoxNetCfgWinGenHostOnlyNetworkNetworkIp is a network ip,
56 * i.e. 192.168.xxx.0, assign 192.168.xxx.1 for the hostonly adapter */
57 ip = ip | (1 << 24);
58 hr = VBoxNetCfgWinEnableStaticIpConfig(&guid, ip, mask);
59 if(hr != S_OK)
60 {
61 printf("VBoxNetCfgWinEnableStaticIpConfig failed: hr = 0x%x\n", hr);
62 }
63 }
64 else
65 {
66 printf("VBoxNetCfgWinGenHostOnlyNetworkNetworkIp failed: hr = 0x%x\n", hr);
67 }
68 }
69 else
70 {
71 printf("VBoxNetCfgWinCreateHostOnlyNetworkInterface failed: hr = 0x%x\n", hr);
72 }
73#endif
74
75 r = 1;
76
77 CoUninitialize();
78 }
79 else
80 {
81 wprintf(L"Error initializing COM (0x%x)\n", hr);
82 r = 1;
83 }
84
85 VBoxNetCfgWinSetLogging(NULL);
86
87 return r;
88}
89
90int __cdecl main(int argc, char **argv)
91{
92 return InstallNetAdp();
93}
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