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 Changed 15 years ago by Dmitry A. Kuminov

Type: defectenhancement

comment:2 Changed 14 years ago by Silvan Scherrer

Severity: medium

comment:3 Changed 14 years ago by Dmitry A. Kuminov

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.

comment:4 Changed 14 years ago by Dmitry A. Kuminov

Note that kLIBC tries to be smart and expresses both ioctl() and os2_ioctl() through its single ::ioctl() call.

comment:5 Changed 14 years ago by Dmitry A. Kuminov

Found some information in MSDN and in Odin sources for iphlpapi.dll. Will use it.

comment:6 Changed 14 years ago by Dmitry A. Kuminov

Milestone: Qt EnhancedQt 4.6.3

Will do that until I completely forgot the internals.

comment:7 Changed 14 years ago by Dmitry A. Kuminov

Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.