VirtualBox

source: vbox/trunk/src/VBox/Main/include/netif.h@ 17419

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

VBoxManage interface to hostonly if basis

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/** @file
2 * Main - Network Interfaces.
3 */
4
5/*
6 * Copyright (C) 2008 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
17 * Clara, CA 95054 USA or visit http://www.sun.com if you need
18 * additional information or have any questions.
19 */
20
21#ifndef ___netif_h
22#define ___netif_h
23
24#include <iprt/cdefs.h>
25#include <iprt/types.h>
26#include <iprt/net.h>
27
28//#include "VBox/com/ptr.h"
29//#include <list>
30
31#if 1
32/**
33 * Encapsulation type.
34 */
35typedef enum NETIFTYPE
36{
37 NETIF_T_UNKNOWN,
38 NETIF_T_ETHERNET,
39 NETIF_T_PPP,
40 NETIF_T_SLIP
41} NETIFTYPE;
42
43/**
44 * Current state of the interface.
45 */
46typedef enum NETIFSTATUS
47{
48 NETIF_S_UNKNOWN,
49 NETIF_S_UP,
50 NETIF_S_DOWN
51} NETIFSTATUS;
52
53/**
54 * Host Network Interface Information.
55 */
56typedef struct NETIFINFO
57{
58 NETIFINFO *pNext;
59 RTNETADDRIPV4 IPAddress;
60 RTNETADDRIPV4 IPNetMask;
61 RTNETADDRIPV6 IPv6Address;
62 RTNETADDRIPV6 IPv6NetMask;
63 RTMAC MACAddress;
64 NETIFTYPE enmMediumType;
65 NETIFSTATUS enmStatus;
66 RTUUID Uuid;
67 char szShortName[50];
68 char szName[1];
69} NETIFINFO;
70
71/** Pointer to a network interface info. */
72typedef NETIFINFO *PNETIFINFO;
73/** Pointer to a const network interface info. */
74typedef NETIFINFO const *PCNETIFINFO;
75#endif
76
77int NetIfList(std::list <ComObjPtr <HostNetworkInterface> > &list);
78int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask);
79int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength);
80int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf);
81
82DECLINLINE(Bstr) composeIPv6Address(PRTNETADDRIPV6 aAddrPtr)
83{
84 char szTmp[8*5];
85
86 RTStrPrintf(szTmp, sizeof(szTmp),
87 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:"
88 "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
89 aAddrPtr->au8[0], aAddrPtr->au8[1],
90 aAddrPtr->au8[2], aAddrPtr->au8[3],
91 aAddrPtr->au8[4], aAddrPtr->au8[5],
92 aAddrPtr->au8[6], aAddrPtr->au8[7],
93 aAddrPtr->au8[8], aAddrPtr->au8[9],
94 aAddrPtr->au8[10], aAddrPtr->au8[11],
95 aAddrPtr->au8[12], aAddrPtr->au8[13],
96 aAddrPtr->au8[14], aAddrPtr->au8[15]);
97 return Bstr(szTmp);
98}
99
100DECLINLINE(int) prefixLength2IPv6Address(ULONG cPrefix, PRTNETADDRIPV6 aAddrPtr)
101{
102 if(cPrefix > 128)
103 return VERR_INVALID_PARAMETER;
104 if(!aAddrPtr)
105 return VERR_INVALID_PARAMETER;
106
107 ULONG index = cPrefix >> 3;
108 ULONG subindex = cPrefix & 0x7;
109 ULONG i;
110
111 for(i = 0; i < index; i++)
112 aAddrPtr->au8[i] = ~0;
113
114 for(i = index + 1; i < 16; i++)
115 aAddrPtr->au8[i] = 0;
116
117 if(subindex)
118 aAddrPtr->au32[index] = (~0) >> (8 - subindex);
119
120 return VINF_SUCCESS;
121}
122
123DECLINLINE(Bstr) composeHardwareAddress(PRTMAC aMacPtr)
124{
125 char szTmp[6*3];
126
127 RTStrPrintf(szTmp, sizeof(szTmp),
128 "%02x:%02x:%02x:%02x:%02x:%02x",
129 aMacPtr->au8[0], aMacPtr->au8[1],
130 aMacPtr->au8[2], aMacPtr->au8[3],
131 aMacPtr->au8[4], aMacPtr->au8[5]);
132 return Bstr(szTmp);
133}
134
135#endif
136
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