VirtualBox

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

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

#3282 HostNetIf API: updated common part, added draft implementation for Solaris.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: HostNetworkInterfaceImpl.h 15442 2008-12-13 13:40:42Z 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.virtualbox.org. 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/* class HostNetworkInterface; */
31/* #include "netif.h" */
32struct NETIFINFO;
33#endif
34
35class ATL_NO_VTABLE HostNetworkInterface :
36 public VirtualBoxBaseNEXT,
37 public VirtualBoxSupportErrorInfoImpl <HostNetworkInterface, IHostNetworkInterface>,
38 public VirtualBoxSupportTranslation <HostNetworkInterface>,
39 public IHostNetworkInterface
40{
41public:
42
43 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (HostNetworkInterface)
44
45 DECLARE_NOT_AGGREGATABLE (HostNetworkInterface)
46
47 DECLARE_PROTECT_FINAL_CONSTRUCT()
48
49 BEGIN_COM_MAP (HostNetworkInterface)
50 COM_INTERFACE_ENTRY (ISupportErrorInfo)
51 COM_INTERFACE_ENTRY (IHostNetworkInterface)
52 END_COM_MAP()
53
54 NS_DECL_ISUPPORTS
55
56 DECLARE_EMPTY_CTOR_DTOR (HostNetworkInterface)
57
58 HRESULT FinalConstruct();
59 void FinalRelease();
60
61 // public initializer/uninitializer for internal purposes only
62 HRESULT init (Bstr interfaceName, Guid guid);
63#ifdef VBOX_WITH_HOSTNETIF_API
64 HRESULT init (Bstr aInterfaceName, struct NETIFINFO *pIfs);
65#endif
66
67 // IHostNetworkInterface properties
68 STDMETHOD(COMGETTER(Name)) (BSTR *aInterfaceName);
69 STDMETHOD(COMGETTER(Id)) (OUT_GUID aGuid);
70 STDMETHOD(COMGETTER(IPAddress)) (ULONG *aIPAddress);
71 STDMETHOD(COMGETTER(NetworkMask)) (ULONG *aNetworkMask);
72 STDMETHOD(COMGETTER(IPV6Address)) (BSTR *aIPV6Address);
73 STDMETHOD(COMGETTER(IPV6NetworkMask)) (BSTR *aIPV6Mask);
74 STDMETHOD(COMGETTER(HardwareAddress)) (BSTR *aHardwareAddress);
75 STDMETHOD(COMGETTER(Type)) (HostNetworkInterfaceType_T *aType);
76 STDMETHOD(COMGETTER(Status)) (HostNetworkInterfaceStatus_T *aStatus);
77
78 // for VirtualBoxSupportErrorInfoImpl
79 static const wchar_t *getComponentName() { return L"HostNetworkInterface"; }
80
81private:
82 const Bstr mInterfaceName;
83 const Guid mGuid;
84 struct Data
85 {
86 Data() : IPAddress (0), networkMask (0),
87 type (HostNetworkInterfaceType_Unknown),
88 status(HostNetworkInterfaceStatus_Down) {}
89
90 ULONG IPAddress;
91 ULONG networkMask;
92 Bstr IPV6Address;
93 Bstr IPV6NetworkMask;
94 Bstr hardwareAddress;
95 HostNetworkInterfaceType_T type;
96 HostNetworkInterfaceStatus_T status;
97 } m;
98
99};
100
101COM_DECL_READONLY_ENUM_AND_COLLECTION_BEGIN (HostNetworkInterface)
102
103 STDMETHOD(FindByName) (IN_BSTR name, IHostNetworkInterface **networkInterface)
104 {
105 if (!name)
106 return E_INVALIDARG;
107 if (!networkInterface)
108 return E_POINTER;
109
110 *networkInterface = NULL;
111 Vector::value_type found;
112 Vector::iterator it = vec.begin();
113 while (it != vec.end() && !found)
114 {
115 Bstr n;
116 (*it)->COMGETTER(Name) (n.asOutParam());
117 if (n == name)
118 found = *it;
119 ++ it;
120 }
121
122 if (!found)
123 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
124 "The host network interface with the given name could not be found"));
125
126 return found.queryInterfaceTo (networkInterface);
127 }
128
129 STDMETHOD(FindById) (IN_GUID id, IHostNetworkInterface **networkInterface)
130 {
131 if (Guid(id).isEmpty())
132 return E_INVALIDARG;
133 if (!networkInterface)
134 return E_POINTER;
135
136 *networkInterface = NULL;
137 Vector::value_type found;
138 Vector::iterator it = vec.begin();
139 while (it != vec.end() && !found)
140 {
141 Guid g;
142 (*it)->COMGETTER(Id) (g.asOutParam());
143 if (g == Guid(id))
144 found = *it;
145 ++ it;
146 }
147
148 if (!found)
149 return setError (E_INVALIDARG, HostNetworkInterfaceCollection::tr (
150 "The host network interface with the given GUID could not be found"));
151
152 return found.queryInterfaceTo (networkInterface);
153 }
154
155
156COM_DECL_READONLY_ENUM_AND_COLLECTION_END (HostNetworkInterface)
157
158
159#endif // ____H_H_HOSTNETWORKINTERFACEIMPL
160/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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