VirtualBox

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

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

Solaris/Main/VBoxNet: use different network for auto vboxnet IP assigning.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/** @file
2 * Main - Network Interfaces.
3 */
4
5/*
6 * Copyright (C) 2008-2009 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#include <iprt/asm.h>
28
29#define VBOXNET_IPV4ADDR_DEFAULT "192.168.56.1"
30#define VBOXNET_IPV4NET_DEFAULT "192.168."
31#define VBOXNET_IPV4NETPREFIX_DEFAULT 56
32#define VBOXNET_IPV4NETHOST_DEFAULT 1
33#define VBOXNET_IPV4MASK_DEFAULT "255.255.255.0"
34
35#define VBOXNET_MAX_SHORT_NAME 50
36
37#if 1
38/**
39 * Encapsulation type.
40 */
41typedef enum NETIFTYPE
42{
43 NETIF_T_UNKNOWN,
44 NETIF_T_ETHERNET,
45 NETIF_T_PPP,
46 NETIF_T_SLIP
47} NETIFTYPE;
48
49/**
50 * Current state of the interface.
51 */
52typedef enum NETIFSTATUS
53{
54 NETIF_S_UNKNOWN,
55 NETIF_S_UP,
56 NETIF_S_DOWN
57} NETIFSTATUS;
58
59/**
60 * Host Network Interface Information.
61 */
62typedef struct NETIFINFO
63{
64 NETIFINFO *pNext;
65 RTNETADDRIPV4 IPAddress;
66 RTNETADDRIPV4 IPNetMask;
67 RTNETADDRIPV6 IPv6Address;
68 RTNETADDRIPV6 IPv6NetMask;
69 BOOL bDhcpEnabled;
70 RTMAC MACAddress;
71 NETIFTYPE enmMediumType;
72 NETIFSTATUS enmStatus;
73 RTUUID Uuid;
74 char szShortName[VBOXNET_MAX_SHORT_NAME];
75 char szName[1];
76} NETIFINFO;
77
78/** Pointer to a network interface info. */
79typedef NETIFINFO *PNETIFINFO;
80/** Pointer to a const network interface info. */
81typedef NETIFINFO const *PCNETIFINFO;
82#endif
83
84int NetIfList(std::list <ComObjPtr<HostNetworkInterface> > &list);
85int NetIfEnableStaticIpConfig(VirtualBox *pVbox, HostNetworkInterface * pIf, ULONG aOldIp, ULONG aNewIp, ULONG aMask);
86int NetIfEnableStaticIpConfigV6(VirtualBox *pVbox, HostNetworkInterface * pIf, IN_BSTR aOldIPV6Address, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength);
87int NetIfEnableDynamicIpConfig(VirtualBox *pVbox, HostNetworkInterface * pIf);
88int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress);
89int NetIfRemoveHostOnlyNetworkInterface (VirtualBox *pVbox, IN_GUID aId, IProgress **aProgress);
90int NetIfGetConfig(HostNetworkInterface * pIf, NETIFINFO *);
91int NetIfGetConfigByName(PNETIFINFO pInfo);
92int NetIfDhcpRediscover(VirtualBox *pVbox, HostNetworkInterface * pIf);
93
94DECLINLINE(Bstr) composeIPv6Address(PRTNETADDRIPV6 aAddrPtr)
95{
96 char szTmp[8*5] = "";
97
98 if (aAddrPtr->s.Lo || aAddrPtr->s.Hi)
99 RTStrPrintf(szTmp, sizeof(szTmp),
100 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:"
101 "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
102 aAddrPtr->au8[0], aAddrPtr->au8[1],
103 aAddrPtr->au8[2], aAddrPtr->au8[3],
104 aAddrPtr->au8[4], aAddrPtr->au8[5],
105 aAddrPtr->au8[6], aAddrPtr->au8[7],
106 aAddrPtr->au8[8], aAddrPtr->au8[9],
107 aAddrPtr->au8[10], aAddrPtr->au8[11],
108 aAddrPtr->au8[12], aAddrPtr->au8[13],
109 aAddrPtr->au8[14], aAddrPtr->au8[15]);
110 return Bstr(szTmp);
111}
112
113DECLINLINE(ULONG) composeIPv6PrefixLenghFromAddress(PRTNETADDRIPV6 aAddrPtr)
114{
115 int res = ASMBitFirstClear(aAddrPtr, sizeof(RTNETADDRIPV6)*8);
116 return res != -1 ? res : 128;
117}
118
119DECLINLINE(int) prefixLength2IPv6Address(ULONG cPrefix, PRTNETADDRIPV6 aAddrPtr)
120{
121 if(cPrefix > 128)
122 return VERR_INVALID_PARAMETER;
123 if(!aAddrPtr)
124 return VERR_INVALID_PARAMETER;
125
126 memset(aAddrPtr, 0, sizeof(RTNETADDRIPV6));
127
128 ASMBitSetRange(aAddrPtr, 0, cPrefix);
129
130 return VINF_SUCCESS;
131}
132
133DECLINLINE(Bstr) composeHardwareAddress(PRTMAC aMacPtr)
134{
135 char szTmp[6*3];
136
137 RTStrPrintf(szTmp, sizeof(szTmp),
138 "%02x:%02x:%02x:%02x:%02x:%02x",
139 aMacPtr->au8[0], aMacPtr->au8[1],
140 aMacPtr->au8[2], aMacPtr->au8[3],
141 aMacPtr->au8[4], aMacPtr->au8[5]);
142 return Bstr(szTmp);
143}
144
145#endif /* ___netif_h */
146/* 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