VirtualBox

source: vbox/trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h@ 15235

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

#3282: API, RT generic part, updated VBoxManage list hostif.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: HostNetworkInterfaceImpl.h 15235 2008-12-10 09:29:07Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.215389.xyz. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_HOSTNETWORKINTERFACEIMPL
25#define ____H_HOSTNETWORKINTERFACEIMPL
26
27#include "VirtualBoxBase.h"
28#include "Collection.h"
29#ifdef VBOX_WITH_HOSTNETIF_API
30#include "iprt/netif.h"
31#endif
32
33class ATL_NO_VTABLE HostNetworkInterface :
34 public VirtualBoxBaseNEXT,
35 public VirtualBoxSupportErrorInfoImpl <HostNetworkInterface, IHostNetworkInterface>,
36 public VirtualBoxSupportTranslation <HostNetworkInterface>,
37 public IHostNetworkInterface
38{
39public:
40
41 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostNetworkInterface)
42
43 DECLARE_NOT_AGGREGATABLE (HostNetworkInterface)
44
45 DECLARE_PROTECT_FINAL_CONSTRUCT()
46
47 BEGIN_COM_MAP (HostNetworkInterface)
48 COM_INTERFACE_ENTRY (ISupportErrorInfo)
49 COM_INTERFACE_ENTRY (IHostNetworkInterface)
50 END_COM_MAP()
51
52 NS_DECL_ISUPPORTS
53
54 DECLARE_EMPTY_CTOR_DTOR (HostNetworkInterface)
55
56 HRESULT FinalConstruct();
57 void FinalRelease();
58
59 // public initializer/uninitializer for internal purposes only
60 HRESULT init (Bstr interfaceName, Guid guid);
61#ifdef VBOX_WITH_HOSTNETIF_API
62 HRESULT init (PRTNETIFINFO pIfs);
63#endif
64
65 // IHostNetworkInterface properties
66 STDMETHOD(COMGETTER(Name)) (BSTR *aInterfaceName);
67 STDMETHOD(COMGETTER(Id)) (OUT_GUID aGuid);
68 STDMETHOD(COMGETTER(IPAddress)) (ULONG *aIPAddress);
69 STDMETHOD(COMGETTER(NetworkMask)) (ULONG *aNetworkMask);
70 STDMETHOD(COMGETTER(IPV6Address)) (BSTR *aIPV6Address);
71 STDMETHOD(COMGETTER(HardwareAddress)) (BSTR *aHardwareAddress);
72 STDMETHOD(COMGETTER(Type)) (HostNetworkInterfaceType_T *aType);
73 STDMETHOD(COMGETTER(Status)) (HostNetworkInterfaceStatus_T *aStatus);
74
75 // for VirtualBoxSupportErrorInfoImpl
76 static const wchar_t *getComponentName() { return L"HostNetworkInterface"; }
77
78private:
79 const Bstr mInterfaceName;
80 const Guid mGuid;
81 struct Data
82 {
83 Data() : IPAddress (0), networkMask (0),
84 type (HostNetworkInterfaceType_Unknown),
85 status(HostNetworkInterfaceStatus_Down) {}
86
87 ULONG IPAddress;
88 ULONG networkMask;
89 Bstr IPV6Address;
90 Bstr hardwareAddress;
91 HostNetworkInterfaceType_T type;
92 HostNetworkInterfaceStatus_T status;
93 } m;
94
95};
96
97COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostNetworkInterface)
98
99 STDMETHOD(FindByName) (IN_BSTR name, IHostNetworkInterface **networkInterface)
100 {
101 if (!name)
102 return E_INVALIDARG;
103 if (!networkInterface)
104 return E_POINTER;
105
106 *networkInterface = NULL;
107 Vector::value_type found;
108 Vector::iterator it = vec.begin();
109 while (it != vec.end() && !found)
110 {
111 Bstr n;
112 (*it)->COMGETTER(Name) (n.asOutParam());
113 if (n == name)
114 found = *it;
115 ++ it;
116 }
117
118 if (!found)
119 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
120 "The host network interface with the given name could not be found"));
121
122 return found.queryInterfaceTo (networkInterface);
123 }
124
125 STDMETHOD(FindById) (IN_GUID id, IHostNetworkInterface **networkInterface)
126 {
127 if (Guid(id).isEmpty())
128 return E_INVALIDARG;
129 if (!networkInterface)
130 return E_POINTER;
131
132 *networkInterface = NULL;
133 Vector::value_type found;
134 Vector::iterator it = vec.begin();
135 while (it != vec.end() && !found)
136 {
137 Guid g;
138 (*it)->COMGETTER(Id) (g.asOutParam());
139 if (g == Guid(id))
140 found = *it;
141 ++ it;
142 }
143
144 if (!found)
145 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
146 "The host network interface with the given GUID could not be found"));
147
148 return found.queryInterfaceTo (networkInterface);
149 }
150
151
152COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostNetworkInterface)
153
154
155#endif // ____H_H_HOSTNETWORKINTERFACEIMPL
156/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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