First of all thanks for the link, i managed to obtain the DUID and the Physical Address modifying that code and it's working....the only problem is that I have to do it in C#, I have to convert it....do you have any solutions ?
#include <stdafx.h>
#include <winsock2.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#pragma comment(lib, "IPHLPAPI.lib")
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
int __cdecl main(int argc, char **argv)
{
DWORD dwSize = 0;
DWORD dwRetVal = 0;
unsigned int i = 0;
ULONG flags = GAA_FLAG_INCLUDE_PREFIX;
ULONG family = AF_UNSPEC;
LPVOID lpMsgBuf = NULL;
PIP_ADAPTER_ADDRESSES pAddresses = NULL;
ULONG outBufLen = 0;
PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL;
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = NULL;
PIP_ADAPTER_ANYCAST_ADDRESS pAnycast = NULL;
PIP_ADAPTER_MULTICAST_ADDRESS pMulticast = NULL;
IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = NULL;
IP_ADAPTER_PREFIX *pPrefix = NULL;
family = AF_INET6;
outBufLen = sizeof (IP_ADAPTER_ADDRESSES);
pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen);
if (GetAdaptersAddresses(family, flags, NULL, pAddresses, &outBufLen) == ERROR_BUFFER_OVERFLOW) {
FREE(pAddresses);
pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen);
}
if (pAddresses == NULL) {
printf("Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
exit(1);
}
printf("Calling GetAdaptersAddresses function with family = ");
if (family == AF_INET)
printf("AF_INET\n");
if (family == AF_INET6)
printf("AF_INET6\n");
if (family == AF_UNSPEC)
printf("AF_UNSPEC\n\n");
dwRetVal = GetAdaptersAddresses(family, NULL, NULL, pAddresses, &outBufLen);
if (dwRetVal == NO_ERROR) {
pCurrAddresses = pAddresses;
while (pCurrAddresses) {
if(pCurrAddresses->Dhcpv6ClientDuidLength){
if (pCurrAddresses->PhysicalAddressLength != 0) {
printf("\tPhysical address: ");
for (i = 0; i < pCurrAddresses->PhysicalAddressLength;
i++) {
if (i == (pCurrAddresses->PhysicalAddressLength - 1))
printf("%.2X\n",(int) pCurrAddresses->PhysicalAddress[i]);
else
printf("%.2X-",(int) pCurrAddresses->PhysicalAddress[i]);
}
}
if (pCurrAddresses->Dhcpv6ClientDuidLength != 0) {
printf("\tDUID: ");
for (i = 0; i < (int) pCurrAddresses->Dhcpv6ClientDuidLength;i++) {
if (i == (pCurrAddresses->Dhcpv6ClientDuidLength - 1))
printf("%.2X\n",(int) pCurrAddresses->Dhcpv6ClientDuid[i]);
else
printf("%.2X-",(int) pCurrAddresses->Dhcpv6ClientDuid[i]);
}
}
printf("\n");
}
pPrefix = pCurrAddresses->FirstPrefix;
pCurrAddresses = pCurrAddresses->Next;
}
} else {
printf("Call to GetAdaptersAddresses failed with error: %d\n",dwRetVal);
if (dwRetVal == ERROR_NO_DATA)
printf("\tNo addresses were found for the requested parameters\n");
else {
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) & lpMsgBuf, 0, NULL)) {
printf("\tError: %s", lpMsgBuf);
LocalFree(lpMsgBuf);
FREE(pAddresses);
exit(1);
}
}
}
FREE(pAddresses);
system ("pause");
return 0;
}