Changeset 17380 in vbox
- Timestamp:
- Mar 5, 2009 10:05:30 AM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
r17358 r17380 75 75 76 76 #ifdef VBOX_WITH_HOSTNETIF_API 77 static Bstr composeIPv6Address(PRTNETADDRIPV6 aAddrPtr)78 {79 char szTmp[8*5];80 81 RTStrPrintf(szTmp, sizeof(szTmp),82 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:"83 "%02x%02x:%02x%02x:%02x%02x:%02x%02x",84 aAddrPtr->au8[0], aAddrPtr->au8[1],85 aAddrPtr->au8[2], aAddrPtr->au8[3],86 aAddrPtr->au8[4], aAddrPtr->au8[5],87 aAddrPtr->au8[6], aAddrPtr->au8[7],88 aAddrPtr->au8[8], aAddrPtr->au8[9],89 aAddrPtr->au8[10], aAddrPtr->au8[11],90 aAddrPtr->au8[12], aAddrPtr->au8[13],91 aAddrPtr->au8[14], aAddrPtr->au8[15]);92 return Bstr(szTmp);93 }94 95 static Bstr composeHardwareAddress(PRTMAC aMacPtr)96 {97 char szTmp[6*3];98 99 RTStrPrintf(szTmp, sizeof(szTmp),100 "%02x:%02x:%02x:%02x:%02x:%02x",101 aMacPtr->au8[0], aMacPtr->au8[1],102 aMacPtr->au8[2], aMacPtr->au8[3],103 aMacPtr->au8[4], aMacPtr->au8[5]);104 return Bstr(szTmp);105 }106 77 107 78 HRESULT HostNetworkInterface::updateConfig (struct NETIFINFO *pIf) -
trunk/src/VBox/Main/include/netif.h
r17358 r17380 82 82 int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf); 83 83 84 DECLINLINE(Bstr) composeIPv6Address(PRTNETADDRIPV6 aAddrPtr) 85 { 86 char szTmp[8*5]; 87 88 RTStrPrintf(szTmp, sizeof(szTmp), 89 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:" 90 "%02x%02x:%02x%02x:%02x%02x:%02x%02x", 91 aAddrPtr->au8[0], aAddrPtr->au8[1], 92 aAddrPtr->au8[2], aAddrPtr->au8[3], 93 aAddrPtr->au8[4], aAddrPtr->au8[5], 94 aAddrPtr->au8[6], aAddrPtr->au8[7], 95 aAddrPtr->au8[8], aAddrPtr->au8[9], 96 aAddrPtr->au8[10], aAddrPtr->au8[11], 97 aAddrPtr->au8[12], aAddrPtr->au8[13], 98 aAddrPtr->au8[14], aAddrPtr->au8[15]); 99 return Bstr(szTmp); 100 } 101 102 DECLINLINE(int) prefixLength2IPv6Address(ULONG cPrefix, PRTNETADDRIPV6 aAddrPtr) 103 { 104 if(cPrefix > 128) 105 return VERR_INVALID_PARAMETER; 106 if(!aAddrPtr) 107 return VERR_INVALID_PARAMETER; 108 109 ULONG index = cPrefix >> 3; 110 ULONG subindex = cPrefix & 0x7; 111 ULONG i; 112 113 for(i = 0; i < index; i++) 114 aAddrPtr->au8[i] = ~0; 115 116 for(i = index + 1; i < 16; i++) 117 aAddrPtr->au8[i] = 0; 118 119 if(subindex) 120 aAddrPtr->au32[index] = (~0) >> (8 - subindex); 121 122 return VINF_SUCCESS; 123 } 124 125 DECLINLINE(Bstr) composeHardwareAddress(PRTMAC aMacPtr) 126 { 127 char szTmp[6*3]; 128 129 RTStrPrintf(szTmp, sizeof(szTmp), 130 "%02x:%02x:%02x:%02x:%02x:%02x", 131 aMacPtr->au8[0], aMacPtr->au8[1], 132 aMacPtr->au8[2], aMacPtr->au8[3], 133 aMacPtr->au8[4], aMacPtr->au8[5]); 134 return Bstr(szTmp); 135 } 136 84 137 #endif 85 138 -
trunk/src/VBox/Main/win/NetIfList-win.cpp
r17358 r17380 733 733 int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway) 734 734 { 735 return VERR_GENERAL_FAILURE; 735 RTNETADDRIPV6 Mask; 736 int rc = prefixLength2IPv6Address(aIPV6MaskPrefixLength, &Mask); 737 if(RT_SUCCESS(rc)) 738 { 739 Bstr maskStr = composeIPv6Address(&Mask); 740 rc = NetIfEnableStaticIpConfigV6(pIf, aIPV6Address, maskStr, aIPV6DefaultGateway); 741 } 742 return rc; 736 743 } 737 744
Note:
See TracChangeset
for help on using the changeset viewer.