PDA

View Full Version : Native Mac Address



genny77
4th August 2007, 09:08
Hi,

I know that Ethernet Card 's Mac Address can be changed.
Now I have a question:
Through the function QNetworkInterface::hardwareAddress () we can obtain the native Mac Address or the Mac Address modified?

Thanks
Gennaro

genny77
4th August 2007, 09:09
Hi,

I know that Ethernet Card 's Mac Address can be changed.
Now I have a question:
Through the function QNetworkInterface::hardwareAddress () we can obtain the native Mac Address or the Mac Address modified?

Thanks
Gennaro

patrik08
4th August 2007, 09:57
Hi,

I know that Ethernet Card 's Mac Address can be changed.
Now I have a question:
Through the function QNetworkInterface::hardwareAddress () we can obtain the native Mac Address or the Mac Address modified?

Thanks
Gennaro

before i launch mysql connecto from external server i check network ...
&& it return forever the actual status....




/* if external network is up? */
static inline bool NetworkEnable() {

bool validip = false;
QList<QHostAddress> addrlist = QNetworkInterface::allAddresses();
int o = -1;
foreach(QHostAddress addr, addrlist){
o++;
QNetworkInterface hop = QNetworkInterface::interfaceFromIndex(o);
QString mach = hop.hardwareAddress();
QString name = hop.name();
QString oneip = addr.toString();
if (!oneip.contains("127.")) {
bool actual = hop.isValid();
if (actual) {
validip = true;
}
}
}
return validip;
}

marcel
4th August 2007, 11:02
You can't rely on the Qt API on this one.
You better use the platform API:

Windows:
http://www.codeproject.com/internet/NetCnfgVersion2.asp
http://www.codeproject.com/internet/getmac.asp

Linux:
http://kasperd.net/~kasperd/comp.os.linux.development.faq#IP
See paragraph 29.

Mac:
Search http://developer.apple.com


Regards