Opened 15 years ago
Closed 14 years ago
#63 closed enhancement (fixed)
Query hardware address of the network interface
Reported by: | Dmitry A. Kuminov | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | Qt 4.6.3 |
Component: | QtNetwork | Version: | 4.5.1 Beta 1 |
Severity: | medium | Keywords: | |
Cc: |
Description
Currently, QNetworkInterface::hardwareAddress() returns an empty string (#19). We should query the hardware address of the network interface using the native API. It may be simpler to replace ::ioctl(SIOCGIF*) with the native API completely.
Change History (7)
comment:1 by , 15 years ago
Type: | defect → enhancement |
---|
comment:2 by , 15 years ago
Severity: | → medium |
---|
comment:3 by , 14 years ago
comment:4 by , 14 years ago
Note that kLIBC tries to be smart and expresses both ioctl() and os2_ioctl() through its single ::ioctl() call.
comment:5 by , 14 years ago
Found some information in MSDN and in Odin sources for iphlpapi.dll. Will use it.
comment:6 by , 14 years ago
Milestone: | Qt Enhanced → Qt 4.6.3 |
---|
Will do that until I completely forgot the internals.
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Done in r801. Actually took more than planned since I had to completely redo the interface enumeration function. But this also fixed a couple of other bugs.
Actually there is no native API other than the ioctl() and os2_ioctl() calls provided by tcpip32.dll (well, you may use NetBIOS command 0x33 as described here comp.os.os2.programmer.misc, but you have to have the NetBIOS protocol installed for that to work I suppose).
Anyway, os2_ioctl() has a SIOSTATIF command that returns the same information as printed by the 'netstat -n' command, including the MAC address of the interface. However, it is not fully clear how to match entries from SIOSTATIF (identified by interface index + type) with the entries returned by SIOCGIFCONF (identified by strings like 'lan0'). It looks that there is a correlation between them (like type 6 is 'lanX' and index is X, or type 0 is 'lo') but I couldn't find any proof of that so far. It's also not clear what type number 'pppX' or 'slX' interfaces have. If anyone got this information, please share.
Also, it loosk that SIOCGIFCONF returns interfaces that are actually missing -- for example, here it returns a lot of garbage entries which I fixed in r783), and also a non-existent interface lan2' (I only have 'lan0' and 'lo' actually). While SIOSTATIF returns only what is really there (two entries in my case, as i said, one is type 6 index 0 and the other one is type 0 index 0), so it would be good to make that matching one day which will solve both problems.